Added mission target flag, Pirate Uprising 03, and scatter radius for fighter groups, to prevent battles initially being too chaotic.

This commit is contained in:
Steve 2015-10-24 08:51:43 +01:00
parent 67d92cedb9
commit 5b7410dc1f
15 changed files with 144 additions and 43 deletions

View File

@ -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"
]
},
{

View File

@ -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
}
]
}

View File

@ -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
}
]
}

View File

@ -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
}
]
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 814 B

After

Width:  |  Height:  |  Size: 798 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 230 B

After

Width:  |  Height:  |  Size: 276 B

View File

@ -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);
}
}
}
}

View File

@ -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)

View File

@ -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();
}

View File

@ -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);
}
}

View File

@ -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
{

View File

@ -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);
}

View File

@ -223,6 +223,7 @@ typedef struct {
int status;
int missionFinishedTimer;
int numObjectivesComplete, numObjectivesTotal;
Fighter *missionTarget;
SDL_Texture *background, *planetTexture;
PointF planet;
Fighter fighterHead, *fighterTail;

View File

@ -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);

View File

@ -26,6 +26,8 @@ void loadTestMission(char *filename)
{
memset(&mission, 0, sizeof(Mission));
STRNCPY(mission.filename, filename, MAX_DESCRIPTION_LENGTH);
game.currentMission = &mission;
initBattle();