diff --git a/dat/fleet.xml b/dat/fleet.xml
index b529d72..fb18c41 100644
--- a/dat/fleet.xml
+++ b/dat/fleet.xml
@@ -14,12 +14,21 @@
Merchant Ship
+
+ merchant
+ Merchant
+
+ Merchant Mule
+
+
merchant
Merchant
- Merchant Ship
Merchant Ship
+ Merchant Ship
+ Merchant Mule
+ Merchant Mule
diff --git a/dat/outfit.xml b/dat/outfit.xml
index a24e1a2..269147e 100644
--- a/dat/outfit.xml
+++ b/dat/outfit.xml
@@ -28,7 +28,7 @@
20
25000
-
+
lasergreen
laser
ExpS
diff --git a/dat/ship.xml b/dat/ship.xml
index d25e8a3..8eb6f19 100644
--- a/dat/ship.xml
+++ b/dat/ship.xml
@@ -84,11 +84,39 @@
40
- Laser
- Laser Turret
+ Laser
Missile Launcher
Missile
+
+ mule
+ minimal
+ engine
+ 2
+ 900000
+
+ 180
+ 100
+ 220
+
+
+ 200
+ 240
+ 200
+ 100
+ 40
+ 250
+
+
+ 13
+ 350
+ 50
+ 250
+
+
+ Laser Turret
+
+
diff --git a/dat/ssys.xml b/dat/ssys.xml
index 3f81cd4..93758b2 100644
--- a/dat/ssys.xml
+++ b/dat/ssys.xml
@@ -17,7 +17,7 @@
Enemy Test
Pirate
Merchant Ship
- Merchant Ship
+ Merchant Mule
Merchant Ship
Sml Merchant Convoy
Sml Merchant Convoy
@@ -41,6 +41,7 @@
Merchant Ship
+ Merchant Mule
Merchant Ship
diff --git a/gfx/ship/mule.png b/gfx/ship/mule.png
new file mode 100644
index 0000000..f4990e0
Binary files /dev/null and b/gfx/ship/mule.png differ
diff --git a/gfx/ship/mule_target.png b/gfx/ship/mule_target.png
new file mode 100644
index 0000000..2a5e1b3
Binary files /dev/null and b/gfx/ship/mule_target.png differ
diff --git a/scripts/ai/merchant.lua b/scripts/ai/merchant.lua
index 3f45a4e..e1622a3 100644
--- a/scripts/ai/merchant.lua
+++ b/scripts/ai/merchant.lua
@@ -37,6 +37,13 @@ function runaway()
target = ai.targetid()
dir = ai.face(target, 1)
ai.accel()
+ if ai.hasturrets() then
+ dist = ai.dist(ai.pos(target))
+ if dist < 300 then
+ ai.settarget(target)
+ ai.shoot()
+ end
+ end
end
-- Fly to the target.
diff --git a/src/ai.c b/src/ai.c
index 977531c..06569a8 100644
--- a/src/ai.c
+++ b/src/ai.c
@@ -126,6 +126,7 @@ static int ai_stop(lua_State* L); // stop()
static int ai_combat(lua_State* L); // combat(number)
static int ai_settarget(lua_State* L); // settarget(number)
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_getenemy(lua_State* L); // number getenemy().
static int ai_hostile(lua_State* L); // hostile(number).
@@ -172,6 +173,7 @@ static const luaL_Reg ai_methods[] = {
{ "combat", ai_combat },
{ "settarget", ai_settarget },
{ "secondary", ai_secondary },
+ { "hasturrets", ai_hasturrets },
{ "shoot", ai_shoot },
{ "getenemy", ai_getenemy },
{ "hostile", ai_hostile },
@@ -750,6 +752,11 @@ static int ai_secondary(lua_State* L) {
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.
static int ai_shoot(lua_State* L) {
int n = 1;
diff --git a/src/pilot.c b/src/pilot.c
index 49e2e47..c492abb 100644
--- a/src/pilot.c
+++ b/src/pilot.c
@@ -419,7 +419,6 @@ void pilot_init(Pilot* pilot, Ship* ship, char* name, Faction* faction, AI_Profi
pilot->shield = pilot->shield_max;
pilot->energy = pilot->energy_max;
-
// Initially idle.
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].timer = 0;
(pilot->noutfits)++;
+ if(outfit_isTurret(so->data)) // Used to speed up AI a bit.
+ pilot_setFlag(pilot, PILOT_HASTURRET);
}
}
diff --git a/src/pilot.h b/src/pilot.h
index cec437b..e0b01dc 100644
--- a/src/pilot.h
+++ b/src/pilot.h
@@ -25,6 +25,7 @@
#define pilot_rmFlag(p,f) (p->flags ^= f)
// Creation.
#define PILOT_PLAYER (1<<0) // Pilot is a player.
+#define PILOT_HASTURRET (1<<20) // Pilit has turrets.
// Dynamic.
#define PILOT_HOSTILE (1<<1) // Pilot is hostile to the player.
#define PILOT_COMBAT (1<<2) // Pilot is engaged in combat.
@@ -74,7 +75,7 @@ typedef struct Pilot_ {
PilotOutfit* ammo; // Secondary ammo (if needed).
// Misc.
- unsigned int flags; // Used for AI etc.
+ uint32_t flags; // Used for AI etc.
unsigned int ptimer; // Generic timer for internal pilot use.
// AI.