diff --git a/data/battle/bullets.json b/data/battle/bullets.json index 025d012..66fd53a 100644 --- a/data/battle/bullets.json +++ b/data/battle/bullets.json @@ -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" } ] diff --git a/data/fighters/list.json b/data/fighters/list.json index f97b142..384f297 100644 --- a/data/fighters/list.json +++ b/data/fighters/list.json @@ -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" ] diff --git a/data/fighters/ray.json b/data/fighters/ray.json new file mode 100644 index 0000000..599dd70 --- /dev/null +++ b/data/fighters/ray.json @@ -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 + } +} diff --git a/data/missions/temper/03 - pirate uprising #3.json b/data/missions/temper/03 - pirate uprising #3.json new file mode 100644 index 0000000..49b580f --- /dev/null +++ b/data/missions/temper/03 - pirate uprising #3.json @@ -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 + } + ] +} diff --git a/makefile b/makefile index 8f6e44e..6dcd124 100644 --- a/makefile +++ b/makefile @@ -1,6 +1,6 @@ PROG = tbftss -VERSION = 0.1 +VERSION = 0.2 CXXFLAGS += `sdl2-config --cflags` -DVERSION=$(VERSION) -DUNIX=1 CXXFLAGS += -DUNIX diff --git a/sound/18382__inferno__hvylas.ogg b/sound/18382__inferno__hvylas.ogg new file mode 100644 index 0000000..cfd324c Binary files /dev/null and b/sound/18382__inferno__hvylas.ogg differ diff --git a/sound/35677__jobro__laser1.ogg b/sound/35677__jobro__laser1.ogg deleted file mode 100644 index 1f7bf2b..0000000 Binary files a/sound/35677__jobro__laser1.ogg and /dev/null differ diff --git a/src/battle/bullets.c b/src/battle/bullets.c index 4528051..ede1435 100644 --- a/src/battle/bullets.c +++ b/src/battle/bullets.c @@ -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 */ diff --git a/src/battle/bullets.h b/src/battle/bullets.h index 7b10524..914c65d 100644 --- a/src/battle/bullets.h +++ b/src/battle/bullets.h @@ -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); diff --git a/src/battle/fighterDefs.c b/src/battle/fighterDefs.c index 7bd8402..168aa7b 100644 --- a/src/battle/fighterDefs.c +++ b/src/battle/fighterDefs.c @@ -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); } diff --git a/src/battle/fighters.c b/src/battle/fighters.c index ac470f6..e4fdcc1 100644 --- a/src/battle/fighters.c +++ b/src/battle/fighters.c @@ -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) { diff --git a/src/battle/fighters.h b/src/battle/fighters.h index 594d838..d2226df 100644 --- a/src/battle/fighters.h +++ b/src/battle/fighters.h @@ -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, ...); diff --git a/src/battle/objectives.c b/src/battle/objectives.c index b995505..ed7a8b1 100644 --- a/src/battle/objectives.c +++ b/src/battle/objectives.c @@ -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++; + + updateChallenges(); + } - game.stats.missionsCompleted++; - - 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; - - case OS_CONDITIONAL: - o->status = OS_FAILED; - battle.status = MS_FAILED; - battle.missionFinishedTimer = FPS; - failIncompleteObjectives(); - break; - } + o->status = OS_COMPLETE; + addHudMessage(colors.green, "%s - Objective Complete!", o->description); + } + } + } +} + +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); } } } diff --git a/src/defs.h b/src/defs.h index 456842a..d614454 100644 --- a/src/defs.h +++ b/src/defs.h @@ -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 diff --git a/src/structs.h b/src/structs.h index 360ab1b..81805c4 100644 --- a/src/structs.h +++ b/src/structs.h @@ -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; }; diff --git a/src/system/lookup.c b/src/system/lookup.c index 87bb20e..6d613a8 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -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); diff --git a/src/system/sound.c b/src/system/sound.c index 8bc84c2..786fa08 100644 --- a/src/system/sound.c +++ b/src/system/sound.c @@ -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");