Added ability to specify death type of fighters (e.g. supply ships shouldn't spin).

This commit is contained in:
Steve 2015-12-24 12:12:23 +00:00
parent 5075adc0b4
commit e2ffe9ba84
6 changed files with 38 additions and 16 deletions

View File

@ -6,6 +6,7 @@
"reloadTime" : 8, "reloadTime" : 8,
"shieldRechargeRate" : 30, "shieldRechargeRate" : 30,
"textureName" : "gfx/cannons/rocketTurret.png", "textureName" : "gfx/cannons/rocketTurret.png",
"deathType" : "DT_NO_SPIN",
"guns" : [ "guns" : [
{ {
"type" : "BT_ROCKET", "type" : "BT_ROCKET",
@ -14,5 +15,5 @@
} }
], ],
"flags" : "EF_TAKES_DAMAGE", "flags" : "EF_TAKES_DAMAGE",
"aiFlags" : "AIF_MISSILE_BOAT+AIF_AGGRESSIVE+AIF_INSTANT_DIE+AIF_LONG_RANGE_FIRE" "aiFlags" : "AIF_MISSILE_BOAT+AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
} }

View File

@ -6,6 +6,7 @@
"reloadTime" : 10, "reloadTime" : 10,
"shieldRechargeRate" : 0, "shieldRechargeRate" : 0,
"textureName" : "gfx/craft/supplyShip.png", "textureName" : "gfx/craft/supplyShip.png",
"deathType" : "DT_NO_SPIN",
"flags" : "EF_TAKES_DAMAGE", "flags" : "EF_TAKES_DAMAGE",
"aiFlags" : "AIF_AVOIDS_COMBAT" "aiFlags" : "AIF_AVOIDS_COMBAT"
} }

View File

@ -463,24 +463,29 @@ void damageFighter(Entity *e, int amount, long flags)
static void die(void) static void die(void)
{ {
int n = rand() % 3; int n = rand() % 3;
if (self == player)
switch (self->deathType)
{ {
n = rand() % 2; case DT_ANY:
} n = rand() % 3;
else if (self->aiFlags & AIF_INSTANT_DIE) break;
{ case DT_NO_SPIN:
n = 2; n = 1 + rand() % 2;
break;
case DT_INSTANT:
n = 2;
break;
} }
switch (n) switch (n)
{ {
case 0: case 0:
self->action = straightDie;
break;
case 1:
self->action = spinDie; self->action = spinDie;
break; break;
case 1:
self->action = straightDie;
break;
case 2: case 2:
self->action = immediateDie; self->action = immediateDie;
@ -684,6 +689,11 @@ static void loadFighterDef(char *filename)
e->aiFlags = flagsToLong(cJSON_GetObjectItem(root, "aiFlags")->valuestring, NULL); e->aiFlags = flagsToLong(cJSON_GetObjectItem(root, "aiFlags")->valuestring, NULL);
} }
if (cJSON_GetObjectItem(root, "deathType"))
{
e->deathType = lookup(cJSON_GetObjectItem(root, "deathType")->valuestring);
}
e->separationRadius = MAX(e->w, e->h); e->separationRadius = MAX(e->w, e->h);
e->separationRadius *= 3; e->separationRadius *= 3;

View File

@ -101,10 +101,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define AIF_DEFENSIVE (2 << 8) #define AIF_DEFENSIVE (2 << 8)
#define AIF_MISSILE_BOAT (2 << 9) #define AIF_MISSILE_BOAT (2 << 9)
#define AIF_AGGRESSIVE (2 << 10) #define AIF_AGGRESSIVE (2 << 10)
#define AIF_INSTANT_DIE (2 << 11) #define AIF_LONG_RANGE_FIRE (2 << 11)
#define AIF_LONG_RANGE_FIRE (2 << 12) #define AIF_MOVES_TO_LEADER (2 << 12)
#define AIF_MOVES_TO_LEADER (2 << 13) #define AIF_EVADE (2 << 13)
#define AIF_EVADE (2 << 14)
/* player abilities */ /* player abilities */
#define BOOST_RECHARGE_TIME (FPS * 7) #define BOOST_RECHARGE_TIME (FPS * 7)
@ -163,6 +162,13 @@ enum
BT_MAX BT_MAX
}; };
enum
{
DT_ANY,
DT_NO_SPIN,
DT_INSTANT
};
enum enum
{ {
EFFECT_LINE, EFFECT_LINE,

View File

@ -125,6 +125,7 @@ struct Entity {
int aiDamageTimer; int aiDamageTimer;
int aiEvadeTimer; int aiEvadeTimer;
int separationRadius; int separationRadius;
int deathType;
Weapon guns[MAX_FIGHTER_GUNS]; Weapon guns[MAX_FIGHTER_GUNS];
int missiles; int missiles;
long flags; long flags;

View File

@ -61,10 +61,13 @@ void initLookups(void)
addLookup("AIF_DEFENSIVE", AIF_DEFENSIVE); addLookup("AIF_DEFENSIVE", AIF_DEFENSIVE);
addLookup("AIF_MISSILE_BOAT", AIF_MISSILE_BOAT); addLookup("AIF_MISSILE_BOAT", AIF_MISSILE_BOAT);
addLookup("AIF_AGGRESSIVE", AIF_AGGRESSIVE); addLookup("AIF_AGGRESSIVE", AIF_AGGRESSIVE);
addLookup("AIF_INSTANT_DIE", AIF_INSTANT_DIE);
addLookup("AIF_LONG_RANGE_FIRE", AIF_LONG_RANGE_FIRE); addLookup("AIF_LONG_RANGE_FIRE", AIF_LONG_RANGE_FIRE);
addLookup("AIF_MOVES_TO_LEADER", AIF_MOVES_TO_LEADER); addLookup("AIF_MOVES_TO_LEADER", AIF_MOVES_TO_LEADER);
addLookup("DT_ANY", DT_ANY);
addLookup("DT_NO_SPIN", DT_NO_SPIN);
addLookup("DT_INSTANT", DT_INSTANT);
addLookup("TT_DESTROY", TT_DESTROY); addLookup("TT_DESTROY", TT_DESTROY);
addLookup("TT_DISABLE", TT_DISABLE); addLookup("TT_DISABLE", TT_DISABLE);
addLookup("TT_WAYPOINT", TT_WAYPOINT); addLookup("TT_WAYPOINT", TT_WAYPOINT);