diff --git a/data/fighters/firefly.json b/data/fighters/firefly.json index 87ee435..7619664 100644 --- a/data/fighters/firefly.json +++ b/data/fighters/firefly.json @@ -18,11 +18,12 @@ "y" : -2 }, { - "type" : "BT_PARTICLE", + "type" : "BT_PLASMA", "x" : 0, "y" : -4 } ], + "combinedGuns" : 1, "missiles" : { "type" : "MISSILE_MISSILE", "ammo" : 3 diff --git a/data/missions/alba/02 - patrol #2.json b/data/missions/alba/02 - patrol #2.json new file mode 100644 index 0000000..7afe13d --- /dev/null +++ b/data/missions/alba/02 - patrol #2.json @@ -0,0 +1,52 @@ +{ + "name" : "Patrol #2", + "description" : "Patrols so far have not uncovered anything unusual, and it seems as though the increase in military presense is reducing the amount of illegal activity in this sector, with reported incidents down 80%. Still, we cannot afford to become complacent, and must continue with our sweeps.", + "background" : "gfx/backgrounds/background03.jpg", + "planet" : "gfx/planets/torelli.png", + "music" : "music/heroism.ogg", + "requires" : "PREVIOUS", + "objectives" : [ + { + "description" : "Check all Wayponts", + "targetName" : "Waypoint", + "targetValue" : 5, + "targetType" : "TT_WAYPOINT" + } + ], + "player" : { + "type" : "Firefly", + "side" : "SIDE_ALLIES", + "pilot" : "Curtis Rice", + "squadron" : "Eightballers" + }, + "fighterGroups" : [ + { + "name" : "Ally", + "types" : "Firefly;Nymph", + "number" : 4, + "side" : "SIDE_ALLIES", + "x" : 640, + "y" : 1000, + "scatter" : 64 + }, + { + "name" : "Pandoran", + "types" : "Jackal", + "number" : 3, + "side" : "SIDE_PANDORAN", + "x" : 640, + "y" : 1000, + "scatter" : 64 + } + ], + "entityGroups" : [ + { + "type" : "ET_WAYPOINT", + "number" : 5, + "x" : 640, + "y" : 480, + "scatter" : 7500 + } + ] +} + diff --git a/src/battle/bullets.c b/src/battle/bullets.c index 1ec6ed2..13794a1 100644 --- a/src/battle/bullets.c +++ b/src/battle/bullets.c @@ -101,12 +101,7 @@ static void checkCollisions(Bullet *b) for (f = battle.entityHead.next ; f != NULL ; f = f->next) { - if (!f->active) - { - continue; - } - - if (f->type == ET_FIGHTER) + if (f->active && f->type == ET_FIGHTER) { SDL_QueryTexture(f->texture, NULL, NULL, &ew, &eh); @@ -221,7 +216,7 @@ static void huntTarget(Bullet *b) } } -Bullet *createBullet(int type, int x, int y, Entity *owner) +static Bullet *createBullet(int type, int x, int y, Entity *owner) { Bullet *b; @@ -255,7 +250,7 @@ void fireGuns(Entity *owner) for (i = 0 ; i < MAX_FIGHTER_GUNS ; i++) { - if (owner->guns[i].type == owner->selectedGunType) + if (owner->guns[i].type == owner->selectedGunType || (owner->guns[i].type != BT_NONE && owner->combinedGuns)) { s = sin(TO_RAIDANS(owner->angle)); c = cos(TO_RAIDANS(owner->angle)); diff --git a/src/battle/entities.c b/src/battle/entities.c index d031657..9a20ff4 100644 --- a/src/battle/entities.c +++ b/src/battle/entities.c @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "entities.h" static void drawEntity(Entity *e); -static void doEntity(Entity *prev); +static void doEntity(void); Entity *spawnEntity(void) { @@ -46,69 +46,79 @@ void doEntities(void) for (e = battle.entityHead.next ; e != NULL ; e = e->next) { + self = e; + if (!e->active) { continue; } - self = e; - - if (self->target != NULL && self->target->health <= 0) + if (e->target != NULL && e->target->health <= 0) { - self->action = self->defaultAction; - self->target = NULL; + e->action = e->defaultAction; + e->target = NULL; } - self->x += self->dx; - self->y += self->dy; + e->x += e->dx; + e->y += e->dy; - if (self != player) + if (e != player) { - self->x -= battle.ssx; - self->y -= battle.ssy; + e->x -= battle.ssx; + e->y -= battle.ssy; } - if (self->action != NULL) + if (e->action != NULL) { - if (--self->thinkTime <= 0) + if (--e->thinkTime <= 0) { - self->thinkTime = 0; - self->action(); + e->thinkTime = 0; + e->action(); } } - switch (self->type) + switch (e->type) { case ET_FIGHTER: - doFighter(prev); + doFighter(); break; default: - doEntity(prev); + doEntity(); break; } - prev = self; + if (e->alive == ALIVE_DEAD) + { + if (e == battle.entityTail) + { + battle.entityTail = prev; + } + + if (e == battle.missionTarget) + { + battle.missionTarget = NULL; + } + + if (e == player) + { + player = NULL; + } + + prev->next = e->next; + free(e); + e = prev; + } + + prev = e; } } -static void doEntity(Entity *prev) +static void doEntity(void) { if (self->health <= 0) { - if (self == battle.entityTail) - { - battle.entityTail = prev; - } - - if (self == battle.missionTarget) - { - battle.missionTarget = NULL; - } - - prev->next = self->next; - free(self); - self = prev; + self->alive = ALIVE_DEAD; } } diff --git a/src/battle/entities.h b/src/battle/entities.h index 5cae36b..84264fc 100644 --- a/src/battle/entities.h +++ b/src/battle/entities.h @@ -25,7 +25,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. extern void blitRotated(SDL_Texture *t, int x, int y, int angle); extern void drawFighter(Entity *e); -extern void doFighter(Entity *prev); +extern void doFighter(void); extern Battle battle; extern Entity *self; diff --git a/src/battle/fighterDefs.c b/src/battle/fighterDefs.c index cb17d29..fe027c0 100644 --- a/src/battle/fighterDefs.c +++ b/src/battle/fighterDefs.c @@ -106,6 +106,11 @@ static void loadFighterDef(char *filename) exit(1); } } + + if (cJSON_GetObjectItem(root, "combinedGuns")) + { + f->combinedGuns = cJSON_GetObjectItem(root, "combinedGuns")->valueint; + } } if (cJSON_GetObjectItem(root, "missiles")) diff --git a/src/battle/fighters.c b/src/battle/fighters.c index 86ce529..e289893 100644 --- a/src/battle/fighters.c +++ b/src/battle/fighters.c @@ -150,7 +150,7 @@ static void randomizeDartGuns(Entity *dart) } } -void doFighter(Entity *prev) +void doFighter(void) { if (player != NULL) { @@ -251,20 +251,6 @@ void doFighter(Entity *prev) checkTrigger(self->name, TRIGGER_KILLS); } - - if (self == battle.entityTail) - { - battle.entityTail = prev; - } - - if (self == player) - { - player = NULL; - } - - prev->next = self->next; - free(self); - self = prev; } } diff --git a/src/battle/player.c b/src/battle/player.c index 2a69a1e..5461351 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -48,6 +48,8 @@ void initPlayer(void) } } } + + STRNCPY(player->name, "Player", MAX_NAME_LENGTH); } void doPlayer(void) diff --git a/src/battle/waypoints.c b/src/battle/waypoints.c index 93af793..9f3e825 100644 --- a/src/battle/waypoints.c +++ b/src/battle/waypoints.c @@ -56,7 +56,7 @@ static void think(void) self->angle -= 360; } - if (getDistance(player->x, player->y, self->x, self->y) <= 32 && teamMatesClose()) + if (player != NULL && getDistance(player->x, player->y, self->x, self->y) <= 32 && teamMatesClose()) { self->health = 0; diff --git a/src/structs.h b/src/structs.h index 7ed0a8d..4a5cd4d 100644 --- a/src/structs.h +++ b/src/structs.h @@ -89,6 +89,7 @@ struct Entity { int reload; int reloadTime; int selectedGunType; + int combinedGuns; int shieldRecharge; int shieldRechargeRate; int systemPower;