[Add] Mule ship, and applied turrets to them.

This commit is contained in:
Allanis 2013-02-28 21:22:06 +00:00
parent 452c77f30c
commit 9d966458d7
10 changed files with 61 additions and 7 deletions

View File

@ -14,12 +14,21 @@
<pilot chance='100'>Merchant Ship</pilot> <pilot chance='100'>Merchant Ship</pilot>
</pilots> </pilots>
</fleet> </fleet>
<fleet name="Merchant Mule">
<ai>merchant</ai>
<faction>Merchant</faction>
<pilots>
<pilot chance='100'>Merchant Mule</pilot>
</pilots>
</fleet>
<fleet name="Sml Merchant Convoy"> <fleet name="Sml Merchant Convoy">
<ai>merchant</ai> <ai>merchant</ai>
<faction>Merchant</faction> <faction>Merchant</faction>
<pilots> <pilots>
<pilot chance='100'>Merchant Ship</pilot>
<pilot chance='80'>Merchant Ship</pilot> <pilot chance='80'>Merchant Ship</pilot>
<pilot chance='80'>Merchant Ship</pilot>
<pilot chance='80'>Merchant Mule</pilot>
<pilot chance='80'>Merchant Mule</pilot>
</pilots> </pilots>
</fleet> </fleet>
<fleet name="Pirate"> <fleet name="Pirate">

View File

@ -28,7 +28,7 @@
<mass>20</mass> <mass>20</mass>
<price>25000</price> <price>25000</price>
</general> </general>
<specific type="13" secondary="1"> <specific type="13">
<gfx>lasergreen</gfx> <gfx>lasergreen</gfx>
<sound>laser</sound> <sound>laser</sound>
<spfx>ExpS</spfx> <spfx>ExpS</spfx>

View File

@ -84,11 +84,39 @@
<cap_cargo>40</cap_cargo> <cap_cargo>40</cap_cargo>
</characteristics> </characteristics>
<outfits> <outfits>
<outfit quantity="3">Laser</outfit> <outfit quantity="10">Laser</outfit>
<outfit quantity='20'>Laser Turret</outfit>
<outfit quantity='2'>Missile Launcher</outfit> <outfit quantity='2'>Missile Launcher</outfit>
<outfit quantity='20'>Missile</outfit> <outfit quantity='20'>Missile</outfit>
</outfits> </outfits>
</ship> </ship>
<ship name="Merchant Mule">
<GFX>mule</GFX>
<GUI>minimal</GUI>
<sound>engine</sound>
<class>2</class>
<price>900000</price>
<movement>
<thrust>180</thrust>
<turn>100</turn>
<speed>220</speed>
</movement>
<health>
<shield>200</shield>
<armour>240</armour>
<energy>200</energy>
<shield_regen>100</shield_regen>
<armour_regen>40</armour_regen>
<energy_regen>250</energy_regen>
</health>
<characteristics>
<crew>13</crew>
<mass>350</mass>
<cap_weapon>50</cap_weapon>
<cap_cargo>250</cap_cargo>
</characteristics>
<outfits>
<outfit quantity='2'>Laser Turret</outfit>
</outfits>
</ship>
</Ships> </Ships>

View File

@ -17,7 +17,7 @@
<fleet chance="100">Enemy Test</fleet> <fleet chance="100">Enemy Test</fleet>
<fleet chance="60">Pirate</fleet> <fleet chance="60">Pirate</fleet>
<fleet chance="60">Merchant Ship</fleet> <fleet chance="60">Merchant Ship</fleet>
<fleet chance="50">Merchant Ship</fleet> <fleet chance="50">Merchant Mule</fleet>
<fleet chance="40">Merchant Ship</fleet> <fleet chance="40">Merchant Ship</fleet>
<fleet chance="50">Sml Merchant Convoy</fleet> <fleet chance="50">Sml Merchant Convoy</fleet>
<fleet chance="40">Sml Merchant Convoy</fleet> <fleet chance="40">Sml Merchant Convoy</fleet>
@ -41,6 +41,7 @@
</planets> </planets>
<fleets> <fleets>
<fleet chance="80">Merchant Ship</fleet> <fleet chance="80">Merchant Ship</fleet>
<fleet chance="60">Merchant Mule</fleet>
<fleet chance="60">Merchant Ship</fleet> <fleet chance="60">Merchant Ship</fleet>
</fleets> </fleets>
<jumps> <jumps>

BIN
gfx/ship/mule.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 138 KiB

BIN
gfx/ship/mule_target.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 13 KiB

View File

@ -37,6 +37,13 @@ function runaway()
target = ai.targetid() target = ai.targetid()
dir = ai.face(target, 1) dir = ai.face(target, 1)
ai.accel() ai.accel()
if ai.hasturrets() then
dist = ai.dist(ai.pos(target))
if dist < 300 then
ai.settarget(target)
ai.shoot()
end
end
end end
-- Fly to the target. -- Fly to the target.

View File

@ -126,6 +126,7 @@ static int ai_stop(lua_State* L); // stop()
static int ai_combat(lua_State* L); // combat(number) static int ai_combat(lua_State* L); // combat(number)
static int ai_settarget(lua_State* L); // settarget(number) static int ai_settarget(lua_State* L); // settarget(number)
static int ai_secondary(lua_State* L); // string secondary() static int ai_secondary(lua_State* L); // string secondary()
static int ai_hasturrets(lua_State* L); // bool hasturrets()
static int ai_shoot(lua_State* L); // shoot(number) number = 1,2,3. static int ai_shoot(lua_State* L); // shoot(number) number = 1,2,3.
static int ai_getenemy(lua_State* L); // number getenemy(). static int ai_getenemy(lua_State* L); // number getenemy().
static int ai_hostile(lua_State* L); // hostile(number). static int ai_hostile(lua_State* L); // hostile(number).
@ -172,6 +173,7 @@ static const luaL_Reg ai_methods[] = {
{ "combat", ai_combat }, { "combat", ai_combat },
{ "settarget", ai_settarget }, { "settarget", ai_settarget },
{ "secondary", ai_secondary }, { "secondary", ai_secondary },
{ "hasturrets", ai_hasturrets },
{ "shoot", ai_shoot }, { "shoot", ai_shoot },
{ "getenemy", ai_getenemy }, { "getenemy", ai_getenemy },
{ "hostile", ai_hostile }, { "hostile", ai_hostile },
@ -750,6 +752,11 @@ static int ai_secondary(lua_State* L) {
return 1; return 1;
} }
static int ai_hasturrets(lua_State* L) {
lua_pushboolean(L, pilot_isFlag(cur_pilot, PILOT_HASTURRET));
return 1;
}
// Pew pew.. Says the pilot. // Pew pew.. Says the pilot.
static int ai_shoot(lua_State* L) { static int ai_shoot(lua_State* L) {
int n = 1; int n = 1;

View File

@ -419,7 +419,6 @@ void pilot_init(Pilot* pilot, Ship* ship, char* name, Faction* faction, AI_Profi
pilot->shield = pilot->shield_max; pilot->shield = pilot->shield_max;
pilot->energy = pilot->energy_max; pilot->energy = pilot->energy_max;
// Initially idle. // Initially idle.
pilot->task = NULL; pilot->task = NULL;
@ -436,6 +435,8 @@ void pilot_init(Pilot* pilot, Ship* ship, char* name, Faction* faction, AI_Profi
pilot->outfits[pilot->noutfits].quantity = so->quantity; pilot->outfits[pilot->noutfits].quantity = so->quantity;
pilot->outfits[pilot->noutfits].timer = 0; pilot->outfits[pilot->noutfits].timer = 0;
(pilot->noutfits)++; (pilot->noutfits)++;
if(outfit_isTurret(so->data)) // Used to speed up AI a bit.
pilot_setFlag(pilot, PILOT_HASTURRET);
} }
} }

View File

@ -25,6 +25,7 @@
#define pilot_rmFlag(p,f) (p->flags ^= f) #define pilot_rmFlag(p,f) (p->flags ^= f)
// Creation. // Creation.
#define PILOT_PLAYER (1<<0) // Pilot is a player. #define PILOT_PLAYER (1<<0) // Pilot is a player.
#define PILOT_HASTURRET (1<<20) // Pilit has turrets.
// Dynamic. // Dynamic.
#define PILOT_HOSTILE (1<<1) // Pilot is hostile to the player. #define PILOT_HOSTILE (1<<1) // Pilot is hostile to the player.
#define PILOT_COMBAT (1<<2) // Pilot is engaged in combat. #define PILOT_COMBAT (1<<2) // Pilot is engaged in combat.
@ -74,7 +75,7 @@ typedef struct Pilot_ {
PilotOutfit* ammo; // Secondary ammo (if needed). PilotOutfit* ammo; // Secondary ammo (if needed).
// Misc. // Misc.
unsigned int flags; // Used for AI etc. uint32_t flags; // Used for AI etc.
unsigned int ptimer; // Generic timer for internal pilot use. unsigned int ptimer; // Generic timer for internal pilot use.
// AI. // AI.