Permalink
Browse files

thurion now spawns. It is using empire ships as placeholders for now.

  • Loading branch information...
1 parent d73cbdf commit dca7382583afd25421869491ae62765d28ee8f53 @nloewen nloewen committed Nov 21, 2011
Showing with 173 additions and 0 deletions.
  1. +111 −0 ai/spawn/thurion.lua
  2. +54 −0 ai/thurion.lua
  3. +1 −0 dat/faction.xml
  4. +7 −0 dat/fleet.xml
View
@@ -0,0 +1,111 @@
+include("ai/spawn/common.lua")
+
+
+-- @brief Spawns a small patrol fleet.
+function spawn_patrol ()
+ local pilots = {}
+ local r = rnd.rnd()
+
+ if r < 0.5 then
+ scom.addPilot( pilots, "Thurion Ingenuity", 25 );
+ elseif r < 0.8 then
+ scom.addPilot( pilots, "Empire Shark", 20 );
+ scom.addPilot( pilots, "Thurion Ingenuity", 25 );
+ else
+ scom.addPilot( pilots, "Empire Pacifier", 75 );
+ end
+
+ return pilots
+end
+
+
+-- @brief Spawns a medium sized squadron.
+function spawn_squad ()
+ local pilots = {}
+ local r = rnd.rnd()
+
+ if r < 0.5 then
+ scom.addPilot( pilots, "Empire Shark", 20 );
+ scom.addPilot( pilots, "Thurion Ingenuity", 25 );
+ scom.addPilot( pilots, "Empire Admonisher", 45 );
+ elseif r < 0.8 then
+ scom.addPilot( pilots, "Empire Lancelot", 25 );
+ scom.addPilot( pilots, "Empire Admonisher", 45 );
+ else
+ scom.addPilot( pilots, "Empire Shark", 20 );
+ scom.addPilot( pilots, "Empire Lancelot", 25 );
+ scom.addPilot( pilots, "Empire Pacifier", 75 );
+ end
+
+ return pilots
+end
+
+
+-- @brief Spawns a capship with escorts.
+function spawn_capship ()
+ local pilots = {}
+ local r = rnd.rnd()
+
+ -- Generate the capship
+ if r < 0.7 then
+ scom.addPilot( pilots, "Empire Hawking", 140 )
+ else
+ scom.addPilot( pilots, "Empire Peacemaker", 165 )
+ end
+
+ -- Generate the escorts
+ r = rnd.rnd()
+ if r < 0.5 then
+ scom.addPilot( pilots, "Empire Shark", 20 );
+ scom.addPilot( pilots, "Thurion Ingenuity", 25 );
+ scom.addPilot( pilots, "Thurion Ingenuity", 25 );
+ elseif r < 0.8 then
+ scom.addPilot( pilots, "Thurion Ingenuity", 25 );
+ scom.addPilot( pilots, "Empire Admonisher", 45 );
+ else
+ scom.addPilot( pilots, "Thurion Ingenuity", 25 );
+ scom.addPilot( pilots, "Empire Pacifier", 75 );
+ end
+
+ return pilots
+end
+
+
+-- @brief Creation hook.
+function create ( max )
+ local weights = {}
+
+ -- Create weights for spawn table
+ weights[ spawn_patrol ] = 100
+ weights[ spawn_squad ] = math.max(1, -80 + 0.80 * max)
+ weights[ spawn_capship ] = math.max(1, -500 + 1.70 * max)
+
+ -- Create spawn table base on weights
+ spawn_table = scom.createSpawnTable( weights )
+
+ -- Calculate spawn data
+ spawn_data = scom.choose( spawn_table )
+
+ return scom.calcNextSpawn( 0, scom.presence(spawn_data), max )
+end
+
+
+-- @brief Spawning hook
+function spawn ( presence, max )
+ local pilots
+
+ -- Over limit
+ if presence > max then
+ return 5
+ end
+
+ -- Actually spawn the pilots
+ pilots = scom.spawn( spawn_data )
+
+ -- Calculate spawn data
+ spawn_data = scom.choose( spawn_table )
+
+ return scom.calcNextSpawn( presence, scom.presence(spawn_data), max ), pilots
+end
+
+
View
@@ -0,0 +1,54 @@
+include("ai/tpl/generic.lua")
+include("ai/personality/civilian.lua")
+
+
+mem.shield_run = 20
+mem.armour_run = 20
+mem.defensive = true
+mem.enemyclose = 500
+mem.distressmsgfunc = sos
+
+
+-- Sends a distress signal which causes faction loss
+function sos ()
+ msg = {
+ "Local security: requesting assistance!",
+ "Requesting assistance. We are under attack!",
+ "Vessel under attack! Requesting help!",
+ "Help! Ship under fire!",
+ "Taking hostile fire! Need assistance!",
+ "We are under attack, require support!",
+ "Mayday! Ship taking damage!",
+ "01010101011011100110010001100101011100100010000001100001011101000111010001100001011000110110101100100001" -- "Under attack!" in binary
+ }
+ ai.settarget( ai.target() )
+ ai.distress( msg[ rnd.int(1,#msg) ])
+end
+
+
+function create ()
+
+ -- Credits.
+ ai.setcredits( rnd.int(ai.shipprice()/500, ai.shipprice()/200) )
+
+ -- No bribe
+ local bribe_msg = {
+ "\"The Thurion will not be bribed!\"",
+ "\"I have no use for your money.\"",
+ "\"Credits are no replacement for a good shield.\""
+ }
+ mem.bribe_no = bribe_msg[ rnd.int(1,#bribe_msg) ]
+
+ -- Refuel
+ mem.refuel = rnd.rnd( 1000, 3000 )
+ p = ai.getPlayer()
+ if ai.exists(p) then
+ standing = ai.getstanding( p ) or -1
+ mem.refuel_msg = string.format("\"I'll supply your ship with fuel for %d credits.\"",
+ mem.refuel);
+ end
+
+ mem.loiter = 3 -- This is the amount of waypoints the pilot will pass through before leaving the system
+ create_post()
+end
+
View
@@ -123,6 +123,7 @@
<colour>grey50</colour>
<player>1</player>
<lua>thurion</lua>
+ <spawn>thurion</spawn>
<enemies>
<enemy>Pirate</enemy>
</enemies>
View
@@ -743,4 +743,11 @@
<pilot name="Dvaered Vigilance" ship="Dvaered Vigilance"></pilot>
</pilots>
</fleet>
+ <fleet name="Thurion Ingenuity">
+ <ai>thurion</ai>
+ <faction>Thurion</faction>
+ <pilots>
+ <pilot name="Thurion Ingenuity" ship="Thurion Ingenuity"></pilot>
+ </pilots>
+ </fleet>
</Fleets>

0 comments on commit dca7382

Please sign in to comment.