diff --git a/data/galaxy/starSystems.json b/data/galaxy/starSystems.json index a3e6a64..8de36de 100644 --- a/data/galaxy/starSystems.json +++ b/data/galaxy/starSystems.json @@ -84,7 +84,8 @@ "y": 260, "missions" : [ "data/missions/temper/01 - pirate uprising #1.json", - "data/missions/temper/02 - pirate uprising #2.json" + "data/missions/temper/02 - pirate uprising #2.json", + "data/missions/temper/03 - pirate uprising #3.json" ] }, { diff --git a/data/missions/temper/01 - pirate uprising #1.json b/data/missions/temper/01 - pirate uprising #1.json index 6ee56e6..e5c3e79 100644 --- a/data/missions/temper/01 - pirate uprising #1.json +++ b/data/missions/temper/01 - pirate uprising #1.json @@ -47,7 +47,8 @@ "number" : 10, "side" : "SIDE_PIRATE", "x" : 1000, - "y" : 5000 + "y" : 5000, + "scatter" : 2000 }, { "type" : "SimpleDart", @@ -55,7 +56,8 @@ "number" : 10, "side" : "SIDE_PIRATE", "x" : -3000, - "y" : -3000 + "y" : -3000, + "scatter" : 2000 }, { "type" : "Dart", @@ -63,7 +65,8 @@ "number" : 10, "side" : "SIDE_PIRATE", "x" : 0, - "y" : -6000 + "y" : -6000, + "scatter" : 2000 } ] } diff --git a/data/missions/temper/02 - pirate uprising #2.json b/data/missions/temper/02 - pirate uprising #2.json index 88a8014..72be6ce 100644 --- a/data/missions/temper/02 - pirate uprising #2.json +++ b/data/missions/temper/02 - pirate uprising #2.json @@ -47,7 +47,8 @@ "number" : 12, "side" : "SIDE_PIRATE", "x" : -3000, - "y" : 0 + "y" : 0, + "scatter" : 2000 }, { "type" : "Dart", @@ -55,7 +56,8 @@ "number" : 12, "side" : "SIDE_PIRATE", "x" : 4000, - "y" : 0 + "y" : 0, + "scatter" : 2000 }, { "type" : "Dart", @@ -63,7 +65,8 @@ "number" : 12, "side" : "SIDE_PIRATE", "x" : 0, - "y" : 6000 + "y" : 6000, + "scatter" : 2000 } ] } diff --git a/data/missions/temper/03 - pirate uprising #3.json b/data/missions/temper/03 - pirate uprising #3.json index fe48c0f..7bbcd9a 100644 --- a/data/missions/temper/03 - pirate uprising #3.json +++ b/data/missions/temper/03 - pirate uprising #3.json @@ -1,6 +1,6 @@ { "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.", + "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. You will be piloting a Ray, and will need to use your Mag cannons to disable the target. Do not destroy the leader's Dart.", "background" : "gfx/backgrounds/background03.jpg", "planet" : "gfx/planets/spirit.png", "music" : "music/battleThemeA.mp3", @@ -12,7 +12,13 @@ "targetType" : "TT_DISABLE" }, { - "description" : "Do not kill pirate leader", + "description" : "Destroy all remaining opposition", + "targetName" : "Dart", + "targetValue" : 12, + "targetType" : "TT_DESTROY" + }, + { + "description" : "Do not kill Pirate Leader", "targetName" : "Pirate Leader", "targetValue" : 1, "targetType" : "TT_DESTROY", @@ -28,18 +34,30 @@ "fighters" : [ { "name" : "Pirate Leader", - "type" : "StaticDart", + "type" : "Dart", "side" : "SIDE_PIRATE", - "x" : 800, - "y" : 200, - "flags" : "FF_NO_KILL+FF_DISABLE" + "x" : -5000, + "y" : 0, + "flags" : "FF_NO_KILL+FF_DISABLE+FF_MISSION_TARGET" + } + ], + "fighterGroups" : [ + { + "name" : "Ally", + "type" : "TAF", + "number" : 2, + "side" : "SIDE_ALLIES", + "x" : 1600, + "y" : 400 }, { - "name" : "TAF", - "type" : "Ray", - "side" : "SIDE_ALLIES", - "x" : 100, - "y" : 200 + "type" : "Dart", + "name" : "Dart", + "number" : 12, + "side" : "SIDE_PIRATE", + "x" : -5000, + "y" : 0, + "scatter" : 2000 } ] } diff --git a/gfx/hud/targetCircle.png b/gfx/hud/targetCircle.png index 924ef0e..e1d7b40 100644 Binary files a/gfx/hud/targetCircle.png and b/gfx/hud/targetCircle.png differ diff --git a/gfx/hud/targetPointer.png b/gfx/hud/targetPointer.png index 6f6ff7d..1e35565 100644 Binary files a/gfx/hud/targetPointer.png and b/gfx/hud/targetPointer.png differ diff --git a/src/battle/fighters.c b/src/battle/fighters.c index 87b1682..846bc48 100644 --- a/src/battle/fighters.c +++ b/src/battle/fighters.c @@ -188,6 +188,11 @@ void doFighters(void) self->target = NULL; } + if (!battle.missionTarget && f->flags & FF_MISSION_TARGET && f->health > 0) + { + battle.missionTarget = f; + } + f->x += f->dx; f->y += f->dy; @@ -236,6 +241,11 @@ void doFighters(void) f->health = 0; f->alive = ALIVE_DYING; f->die(); + + if (f == battle.missionTarget) + { + battle.missionTarget = NULL; + } } if (f->systemPower <= 0) @@ -372,15 +382,29 @@ void drawFighters(void) blit(shieldHitTexture, f->x, f->y, 1); } - if (player != NULL && f == player->target) + if (player != NULL) { - r.x = f->x - 32; - r.y = f->y - 32; - r.w = 64; - r.h = 64; + if (f == player->target) + { + r.x = f->x - 32; + r.y = f->y - 32; + r.w = 64; + r.h = 64; + + SDL_SetRenderDrawColor(app.renderer, 255, 64, 0, 255); + SDL_RenderDrawRect(app.renderer, &r); + } - SDL_SetRenderDrawColor(app.renderer, 255, 64, 0, 255); - SDL_RenderDrawRect(app.renderer, &r); + if (f == battle.missionTarget) + { + r.x = f->x - 28; + r.y = f->y - 28; + r.w = 56; + r.h = 56; + + SDL_SetRenderDrawColor(app.renderer, 64, 255, 0, 255); + SDL_RenderDrawRect(app.renderer, &r); + } } } } diff --git a/src/battle/hud.c b/src/battle/hud.c index b8b092f..bc9a8ff 100644 --- a/src/battle/hud.c +++ b/src/battle/hud.c @@ -32,6 +32,9 @@ static void drawHudMessages(void); static HudMessage hudMessageHead; static HudMessage *hudMessageTail; +static SDL_Texture *targetPointer; +static SDL_Texture *targetCircle; +static SDL_Texture *smallFighter; static int healthWarning; static char *gunName[] = {"", "Particle Cannon", "Plasma Cannon", "Laser Cannon", "Mag Cannon"}; @@ -42,6 +45,10 @@ void initHud(void) memset(&hudMessageHead, 0, sizeof(HudMessage)); hudMessageTail = &hudMessageHead; + + targetPointer = getTexture("gfx/hud/targetPointer.png"); + targetCircle = getTexture("gfx/hud/targetCircle.png"); + smallFighter = getTexture("gfx/hud/smallFighter.png"); } void doHud(void) @@ -199,33 +206,45 @@ static void drawPlayerTargeter(void) x = player->x; y = player->y; - x += sin(TO_RAIDANS(angle)) * 44; - y += -cos(TO_RAIDANS(angle)) * 44; + x += sin(TO_RAIDANS(angle)) * 45; + y += -cos(TO_RAIDANS(angle)) * 45; - blitRotated(getTexture("gfx/hud/targetPointer.png"), x, y, angle); + SDL_SetTextureColorMod(targetPointer, 255, 0, 0); + SDL_SetTextureColorMod(targetCircle, 255, 0, 0); - blitRotated(getTexture("gfx/hud/targetCircle.png"), player->x, player->y, angle); + blitRotated(targetPointer, x, y, angle); + blitRotated(targetCircle, player->x, player->y, angle); + } + + if (battle.missionTarget) + { + angle = getAngle(player->x, player->y, battle.missionTarget->x, battle.missionTarget->y); + x = player->x; + y = player->y; + + x += sin(TO_RAIDANS(angle)) * 45; + y += -cos(TO_RAIDANS(angle)) * 45; + + SDL_SetTextureColorMod(targetPointer, 0, 255, 0); + + blitRotated(targetPointer, x, y, angle); } } static void drawNumAllies(void) { - SDL_Texture *t = getTexture("gfx/hud/smallFighter.png"); + SDL_SetTextureColorMod(smallFighter, 150, 200, 255); - SDL_SetTextureColorMod(t, 150, 200, 255); - - blit(t, 400, 15, 0); + blit(smallFighter, 400, 15, 0); drawText(435, 11, 14, TA_CENTER, colors.white, "(%d)", battle.numAllies); } static void drawNumEnemies(void) { - SDL_Texture *t = getTexture("gfx/hud/smallFighter.png"); + SDL_SetTextureColorMod(smallFighter, 255, 100, 100); - SDL_SetTextureColorMod(t, 255, 100, 100); - - blit(t, SCREEN_WIDTH - 410, 15, 0); + blit(smallFighter, SCREEN_WIDTH - 410, 15, 0); drawText(SCREEN_WIDTH - 430, 11, 14, TA_CENTER, colors.white, "(%d)", battle.numEnemies); } @@ -249,6 +268,17 @@ static void drawTargetDistance(void) drawText(SCREEN_WIDTH - 15, 50, 14, TA_RIGHT, colors.red, "Target: %.2fkm", distance); } + + if (battle.missionTarget != NULL) + { + distance = getDistance(player->x, player->y, battle.missionTarget->x, battle.missionTarget->y); + distance /= 50; + + distance = (int)distance; + distance /= 10; + + drawText(SCREEN_WIDTH - 15, 75, 14, TA_RIGHT, colors.green, "Objective: %.2fkm", distance); + } } static void drawHudMessages(void) diff --git a/src/battle/player.c b/src/battle/player.c index d25519c..83de399 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -96,7 +96,7 @@ void doPlayer(void) app.keyboard[SDL_SCANCODE_RETURN] = 0; } - if (!player->target || player->target->health <= 0 || getDistance(player->x, player->y, player->target->x, player->target->y) > 1000) + if (!player->target || player->target->health <= 0 || player->target->systemPower <= 0 || getDistance(player->x, player->y, player->target->x, player->target->y) > 1000) { selectTarget(); } diff --git a/src/battle/radar.c b/src/battle/radar.c index 2494147..e320ca8 100644 --- a/src/battle/radar.c +++ b/src/battle/radar.c @@ -20,6 +20,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "radar.h" +#define RADAR_RANGE 20 + void drawRadar(void) { SDL_Rect r; @@ -34,13 +36,13 @@ void drawRadar(void) for (f = battle.fighterHead.next ; f != NULL ; f = f->next) { - if (getDistance(f->x, f->y, player->x, player->y) / 15 < 70) + if (getDistance(f->x, f->y, player->x, player->y) / RADAR_RANGE < 70) { r.x = SCREEN_WIDTH - 85; r.y = SCREEN_HEIGHT - 85; - r.x -= (player->x - f->x) / 15; - r.y -= (player->y - f->y) / 15; + r.x -= (player->x - f->x) / RADAR_RANGE; + r.y -= (player->y - f->y) / RADAR_RANGE; r.x--; r.y--; @@ -61,11 +63,16 @@ void drawRadar(void) break; } - if (player->target == f) + if (f == player->target) { SDL_SetRenderDrawColor(app.renderer, 255, 255, 0, 255); } + if (f == battle.missionTarget) + { + SDL_SetRenderDrawColor(app.renderer, 255, 255, 255, 255); + } + SDL_RenderFillRect(app.renderer, &r); } } diff --git a/src/defs.h b/src/defs.h index c7f77f1..cd535c4 100644 --- a/src/defs.h +++ b/src/defs.h @@ -54,6 +54,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define FF_NO_KILL (2 << 0) #define FF_DISABLE (2 << 1) #define FF_IMMORTAL (2 << 2) +#define FF_MISSION_TARGET (2 << 3) enum { diff --git a/src/galaxy/mission.c b/src/galaxy/mission.c index 5bddf4d..2dd669e 100644 --- a/src/galaxy/mission.c +++ b/src/galaxy/mission.c @@ -157,9 +157,11 @@ static void loadFighterGroups(cJSON *node) { Fighter *f; char *type, *name; - int side, x, y; + int side, x, y, scatter; int number, i; + scatter = 1; + if (node) { node = node->child; @@ -173,10 +175,18 @@ static void loadFighterGroups(cJSON *node) y = cJSON_GetObjectItem(node, "y")->valueint; name = cJSON_GetObjectItem(node, "name")->valuestring; + if (cJSON_GetObjectItem(node, "scatter")) + { + scatter = cJSON_GetObjectItem(node, "scatter")->valueint; + } + for (i = 0 ; i < number ; i++) { f = spawnFighter(type, x, y, side); + f->x += (rand() % scatter) - (rand() % scatter); + f->y += (rand() % scatter) - (rand() % scatter); + STRNCPY(f->name, name, MAX_NAME_LENGTH); } diff --git a/src/structs.h b/src/structs.h index 542961c..2569500 100644 --- a/src/structs.h +++ b/src/structs.h @@ -223,6 +223,7 @@ typedef struct { int status; int missionFinishedTimer; int numObjectivesComplete, numObjectivesTotal; + Fighter *missionTarget; SDL_Texture *background, *planetTexture; PointF planet; Fighter fighterHead, *fighterTail; diff --git a/src/system/lookup.c b/src/system/lookup.c index 7c48f73..4120586 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -33,6 +33,7 @@ void initLookups(void) addLookup("FF_NO_KILL", FF_NO_KILL); addLookup("FF_DISABLE", FF_DISABLE); addLookup("FF_IMMORTAL", FF_IMMORTAL); + addLookup("FF_MISSION_TARGET", FF_MISSION_TARGET); addLookup("TT_DESTROY", TT_DESTROY); addLookup("TT_DISABLE", TT_DISABLE); diff --git a/src/test/testMission.c b/src/test/testMission.c index b39ca65..2ed1f4a 100644 --- a/src/test/testMission.c +++ b/src/test/testMission.c @@ -26,6 +26,8 @@ void loadTestMission(char *filename) { memset(&mission, 0, sizeof(Mission)); + STRNCPY(mission.filename, filename, MAX_DESCRIPTION_LENGTH); + game.currentMission = &mission; initBattle();