Added mag cannons and Ray.

This commit is contained in:
Steve 2015-10-21 19:21:45 +01:00
parent 10c72dc5fd
commit a8a5d507fb
17 changed files with 193 additions and 43 deletions

View File

@ -21,5 +21,13 @@
"textureName" : "gfx/bullets/missile.png",
"sound" : "SND_PLASMA",
"flags" : "BF_ENGINE"
},
{
"type" : "BT_MAG",
"damage" : 10,
"textureName" : "gfx/bullets/magBolt.png",
"sound" : "SND_MAG",
"flags" : "BF_SYSTEM_DAMAGE"
}
]

View File

@ -6,5 +6,6 @@
"data/fighters/sphinx.json",
"data/fighters/staticDart.json",
"data/fighters/taf.json",
"data/fighters/unarmedDart.json"
"data/fighters/unarmedDart.json",
"data/fighters/ray.json"
]

25
data/fighters/ray.json Normal file
View File

@ -0,0 +1,25 @@
{
"name" : "Ray",
"health" : 45,
"shield" : 45,
"speed" : 1.85,
"reloadTime" : 16,
"shieldRechargeRate" : 60,
"textureName" : "gfx/fighters/ray.png",
"guns" : [
{
"type" : "BT_MAG",
"x" : -12,
"y" : -12
},
{
"type" : "BT_MAG",
"x" : 12,
"y" : -12
}
],
"missiles" : {
"type" : "MISSILE_MISSILE",
"ammo" : 4
}
}

View File

@ -0,0 +1,35 @@
{
"name" : "Pirate Uprising #3",
"description" : "Allied intelligence have managed to locate one of the pirate ring leaders. We need to bring this man in alive, as he could provide us with further useful information that will allow us to eliminate other high ranking individuals.",
"background" : "gfx/backgrounds/background03.jpg",
"planet" : "gfx/planets/spirit.png",
"music" : "music/battleThemeA.mp3",
"objectives" : [
{
"description" : "Capture Pirate Leader",
"targetName" : "Pirate Leader",
"targetValue" : 1
},
{
"description" : "Do not kill pirate leader",
"targetName" : "Pirate Leader",
"targetValue" : 1,
"condition" : 1
}
],
"player" : {
"type" : "Ray",
"side" : "SIDE_ALLIES",
"pilot" : "Ian Barclay",
"squadron" : "Steel Bulls"
},
"fighters" : [
{
"name" : "Pirate Leader",
"type" : "UnarmedDart",
"side" : "SIDE_PIRATE",
"x" : 800,
"y" : 200
}
]
}

View File

@ -1,6 +1,6 @@
PROG = tbftss
VERSION = 0.1
VERSION = 0.2
CXXFLAGS += `sdl2-config --cflags` -DVERSION=$(VERSION) -DUNIX=1
CXXFLAGS += -DUNIX

Binary file not shown.

Binary file not shown.

View File

@ -114,7 +114,7 @@ static void checkCollisions(Bullet *b)
battle.stats.shotsHit++;
}
damageFighter(f, b->damage);
damageFighter(f, b->damage, b->flags);
b->life = 0;
/* assuming that health <= 0 will always mean killed */

View File

@ -30,7 +30,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern SDL_Texture *getTexture(char *filename);
extern void blitRotated(SDL_Texture *texture, int x, int y, int angle);
extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
extern void damageFighter(Fighter *f, int damage);
extern void damageFighter(Fighter *f, int damage, long flags);
extern void playBattleSound(int id, int x, int y);
extern long flagsToLong(char *flags);
extern long lookup(char *name);

View File

@ -81,7 +81,7 @@ static void loadFighterDef(char *filename)
STRNCPY(f->name, cJSON_GetObjectItem(root, "name")->valuestring, MAX_NAME_LENGTH);
f->health = f->maxHealth = cJSON_GetObjectItem(root, "health")->valueint;
f->shield = f->maxShield = cJSON_GetObjectItem(root, "shield")->valueint;
f->speed = cJSON_GetObjectItem(root, "speed")->valueint;
f->speed = cJSON_GetObjectItem(root, "speed")->valuedouble;
f->reloadTime = cJSON_GetObjectItem(root, "reloadTime")->valueint;
f->shieldRechargeRate = cJSON_GetObjectItem(root, "shieldRechargeRate")->valueint;
f->texture = getTexture(cJSON_GetObjectItem(root, "textureName")->valuestring);
@ -118,6 +118,9 @@ static void loadFighterDef(char *filename)
f->separationRadius = MAX(w, h);
f->separationRadius *= 2;
/* all craft default to 100 system power */
f->systemPower = 100;
cJSON_Delete(root);
free(text);
}

View File

@ -203,6 +203,7 @@ void doFighters(void)
f->shieldRecharge = MAX(f->shieldRecharge - 1, 0);
f->armourHit = MAX(f->armourHit - 25, 0);
f->shieldHit = MAX(f->shieldHit - 5, 0);
f->systemHit = MAX(f->systemHit - 25, 0);
if (self->thrust > 0.25)
{
@ -237,6 +238,21 @@ void doFighters(void)
f->die();
}
if (f->systemPower <= 0 && f->alive == ALIVE_ALIVE)
{
f->dx *= 0.995;
f->dy *= 0.995;
f->thrust = 0;
f->shield = f->maxShield = 0;
f->action = NULL;
if (f->dx <= 0.01 && f->dy <= 0.01)
{
updateObjective(f->name);
f->alive = ALIVE_DISABLED;
}
}
if (f->alive == ALIVE_DEAD)
{
if (f == player)
@ -260,6 +276,8 @@ void doFighters(void)
}
updateObjective(f->name);
updateCondition(f->name);
}
if (f == battle.fighterTail)
@ -340,6 +358,11 @@ void drawFighters(void)
SDL_SetTextureColorMod(f->texture, 255, 255 - f->armourHit, 255 - f->armourHit);
}
if (f->systemHit > 0)
{
SDL_SetTextureColorMod(f->texture, 255 - f->systemHit, 255, 255);
}
blitRotated(f->texture, f->x, f->y, f->angle);
if (f->shieldHit > 0)
@ -386,21 +409,36 @@ void applyFighterBrakes(void)
self->thrust = sqrt((self->dx * self->dx) + (self->dy * self->dy));
}
void damageFighter(Fighter *f, int damage)
void damageFighter(Fighter *f, int amount, long flags)
{
f->shield -= damage;
if (f->shield < 0)
if (flags & BF_SYSTEM_DAMAGE)
{
f->health -= abs(f->shield);
f->shield = 0;
f->armourHit = 255;
f->systemPower = MAX(0, f->systemPower - amount);
playBattleSound(SND_ARMOUR_HIT, f->x, f->y);
f->systemHit = 255;
if (f->systemPower == 0)
{
f->shield = f->maxShield = 0;
f->action = f->defaultAction = NULL;
}
}
else if (f->shield > 0)
else
{
f->shieldHit = 255;
f->shield -= amount;
if (f->shield < 0)
{
f->health -= abs(f->shield);
f->shield = 0;
f->armourHit = 255;
playBattleSound(SND_ARMOUR_HIT, f->x, f->y);
}
else if (f->shield > 0)
{
f->shieldHit = 255;
}
}
}
@ -441,6 +479,7 @@ static void spinDie(void)
self->thinkTime = 0;
self->armourHit = 0;
self->shieldHit = 0;
self->systemHit = 0;
self->angle += 8;
@ -463,6 +502,7 @@ static void straightDie(void)
self->thinkTime = 0;
self->armourHit = 0;
self->shieldHit = 0;
self->systemHit = 0;
if (rand() % 2 == 0)
{

View File

@ -34,6 +34,7 @@ extern void addFighterExplosion(void);
extern void addSmallFighterExplosion(void);
extern void playBattleSound(int id, int x, int y);
extern void updateObjective(char *name);
extern void updateCondition(char *name);
extern Fighter *getFighterDef(char *name);
extern void addHudMessage(SDL_Color c, char *format, ...);

View File

@ -24,9 +24,11 @@ void failIncompleteObjectives(void);
void doObjectives(void)
{
int conditionFailed;
Objective *o;
battle.numObjectivesComplete = battle.numObjectivesTotal = 0;
conditionFailed = 0;
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
{
@ -34,18 +36,39 @@ void doObjectives(void)
if (o->currentValue == o->targetValue)
{
battle.numObjectivesComplete++;
switch (o->status)
{
case OS_COMPLETE:
battle.numObjectivesComplete++;
break;
case OS_FAILED:
if (!o->optional)
{
conditionFailed = 1;
}
break;
}
}
}
if (battle.numObjectivesTotal > 0 && battle.numObjectivesComplete == battle.numObjectivesTotal && battle.status == MS_IN_PROGRESS)
if (battle.status == MS_IN_PROGRESS)
{
battle.status = MS_COMPLETE;
battle.missionFinishedTimer = FPS;
if (battle.numObjectivesTotal > 0 && battle.numObjectivesComplete == battle.numObjectivesTotal)
{
battle.status = MS_COMPLETE;
battle.missionFinishedTimer = FPS;
game.stats.missionsCompleted++;
game.stats.missionsCompleted++;
updateChallenges();
updateChallenges();
}
if (conditionFailed)
{
battle.status = MS_FAILED;
battle.missionFinishedTimer = FPS;
}
}
}
@ -55,9 +78,9 @@ void updateObjective(char *name)
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
{
if (strcmp(o->targetName, name) == 0)
if (o->status != OS_CONDITION && o->currentValue < o->targetValue && strcmp(o->targetName, name) == 0)
{
o->currentValue = MIN(o->targetValue, o->currentValue + 1);
o->currentValue++;
if (o->targetValue - o->currentValue <= 10)
{
@ -70,20 +93,27 @@ void updateObjective(char *name)
if (o->currentValue == o->targetValue)
{
switch (o->status)
{
case OS_INCOMPLETE:
o->status = OS_COMPLETE;
addHudMessage(colors.green, "%s - Objective Complete!", o->description);
break;
o->status = OS_COMPLETE;
addHudMessage(colors.green, "%s - Objective Complete!", o->description);
}
}
}
}
case OS_CONDITIONAL:
o->status = OS_FAILED;
battle.status = MS_FAILED;
battle.missionFinishedTimer = FPS;
failIncompleteObjectives();
break;
}
void updateCondition(char *name)
{
Objective *o;
for (o = battle.objectiveHead.next ; o != NULL ; o = o->next)
{
if (o->status == OS_CONDITION && o->currentValue < o->targetValue && strcmp(o->targetName, name) == 0)
{
o->currentValue++;
if (o->currentValue == o->targetValue)
{
o->status = OS_FAILED;
addHudMessage(colors.green, "%s - Objective Failed!", o->description);
}
}
}

View File

@ -46,8 +46,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define MAX_FIGHTER_GUNS 12
#define BF_NONE 0
#define BF_ENGINE (2 << 0)
#define BF_NONE 0
#define BF_ENGINE (2 << 0)
#define BF_SYSTEM_DAMAGE (2 << 1)
enum
{
@ -60,7 +61,8 @@ enum
{
ALIVE_ALIVE,
ALIVE_DYING,
ALIVE_DEAD
ALIVE_DEAD,
ALIVE_DISABLED
};
enum
@ -125,7 +127,7 @@ enum
OS_INCOMPLETE,
OS_COMPLETE,
OS_FAILED,
OS_CONDITIONAL
OS_CONDITION
};
enum

View File

@ -76,7 +76,7 @@ struct Fighter {
float dx;
float dy;
float thrust;
int speed;
float speed;
int angle;
int alive;
int health;
@ -87,8 +87,10 @@ struct Fighter {
int reloadTime;
int shieldRecharge;
int shieldRechargeRate;
int systemPower;
int armourHit;
int shieldHit;
int systemHit;
int thinkTime;
int aiActionTime;
int aggression;
@ -158,6 +160,7 @@ struct Objective {
int currentValue;
int targetValue;
int status;
int optional;
Objective *next;
};

View File

@ -53,6 +53,7 @@ void initLookups(void)
addLookup("BF_NONE", BF_NONE);
addLookup("BF_ENGINE", BF_ENGINE);
addLookup("BF_SYSTEM_DAMAGE", BF_SYSTEM_DAMAGE);
addLookup("MISSILE_ROCKET", MISSILE_ROCKET);
addLookup("MISSILE_MISSILE", MISSILE_MISSILE);

View File

@ -93,6 +93,7 @@ static void loadSounds(void)
{
sounds[SND_ARMOUR_HIT] = Mix_LoadWAV("sound/275151__bird-man__gun-shot.ogg");
sounds[SND_PLASMA] = Mix_LoadWAV("sound/268344__julien-matthey__jm-noiz-laser-01.ogg");
sounds[SND_MAG] = Mix_LoadWAV("sound/18382__inferno__hvylas.ogg");
sounds[SND_PARTICLE] = Mix_LoadWAV("sound/77087__supraliminal__laser-short.ogg");
sounds[SND_EXPLOSION_1] = Mix_LoadWAV("sound/162265__qubodup__explosive.ogg");
sounds[SND_EXPLOSION_2] = Mix_LoadWAV("sound/207322__animationisaac__short-explosion.ogg");