From 60d8020c4e4d0c4b6b065a0045a5b4d7ae64fa34 Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 2 May 2018 07:55:55 +0100 Subject: [PATCH] Game plus tweaks. --- src/structs.h | 2 ++ src/world/hud.c | 18 +++++++++++++----- src/world/objectives.c | 2 +- src/world/world.c | 2 ++ src/world/worldLoader.c | 23 +++++++++++++++++++---- 5 files changed, 37 insertions(+), 10 deletions(-) diff --git a/src/structs.h b/src/structs.h index ec58990..a2d0dcf 100644 --- a/src/structs.h +++ b/src/structs.h @@ -470,6 +470,8 @@ typedef struct { int spawnInterval; int numToSpawn; int saveDelay; + unsigned long time; + int numObjectives; Bob *bob; Boss *boss; Entity *entityToTrack; diff --git a/src/world/hud.c b/src/world/hud.c index 1cec958..65a7b1d 100644 --- a/src/world/hud.c +++ b/src/world/hud.c @@ -256,7 +256,7 @@ static void drawBossHealth(void) void drawMissionStatus(void) { Objective *o; - int y, x, w, h, size, mid, i; + int y, x, w, h, size, mid, i, textSize, lineSpacing; float rw, rh, d; SDL_Color c; SDL_Rect *r; @@ -274,6 +274,14 @@ void drawMissionStatus(void) drawText(SCREEN_WIDTH / 2, 100, 40, TA_CENTER, colors.white, app.strings[ST_OBJECTIVES]); y = 180; + textSize = 24; + lineSpacing = 55; + + if (world.numObjectives > 5) + { + textSize -= (world.numObjectives - 5) * 2; + lineSpacing -= (world.numObjectives - 5) * 8; + } for (o = world.objectiveHead.next ; o != NULL ; o = o->next) { @@ -286,11 +294,11 @@ void drawMissionStatus(void) status = app.strings[ST_COMPLETE]; } - drawText(x + 20, y, 24, TA_LEFT, c, o->description); - drawText(SCREEN_WIDTH / 2 + 100, y, 24, TA_LEFT, c, "%d / %d", MIN(o->currentValue, o->targetValue), o->targetValue); - drawText(x + w - 20, y, 24, TA_RIGHT, c, status); + drawText(x + 20, y, textSize, TA_LEFT, c, o->description); + drawText(SCREEN_WIDTH / 2 + 100, y, textSize, TA_LEFT, c, "%d / %d", MIN(o->currentValue, o->targetValue), o->targetValue); + drawText(x + w - 20, y, textSize, TA_RIGHT, c, status); - y += 55; + y += lineSpacing; } size = 60; diff --git a/src/world/objectives.c b/src/world/objectives.c index f15185f..cc9e18a 100644 --- a/src/world/objectives.c +++ b/src/world/objectives.c @@ -55,7 +55,7 @@ void initObjectives(void) if (world.isReturnVisit || game.plus != PLUS_NONE) { o->targetValue = o->totalValue; - o->required = 0; + o->required = game.plus != PLUS_NONE; } if ((strcmp(o->targetName, "ENEMY") == 0 && o->targetValue == o->totalValue) || game.plus != PLUS_PLUS_PLUS) diff --git a/src/world/world.c b/src/world/world.c index 12cb42d..dca6e32 100644 --- a/src/world/world.c +++ b/src/world/world.c @@ -339,6 +339,8 @@ static void doWorldInProgress(void) doCommon(); doLocationTriggers(); + + world.time++; if (world.allObjectivesComplete && world.state != WS_COMPLETE) { diff --git a/src/world/worldLoader.c b/src/world/worldLoader.c index 84b14b2..75585e2 100644 --- a/src/world/worldLoader.c +++ b/src/world/worldLoader.c @@ -29,7 +29,7 @@ static void loadObjectives(cJSON *root); void loadWorld(char *id) { cJSON *root; - char *text, *filename; + char *text, *filename, enemyTypes[MAX_DESCRIPTION_LENGTH]; memset(&world, 0, sizeof(World)); @@ -72,7 +72,8 @@ void loadWorld(char *id) } else { - loadEnemyTypes("Pistol|Grenade|MachineGun|Shotgun|Laser|SpreadGun|Plasma"); + STRNCPY(enemyTypes, "Pistol|Grenade|MachineGun|Shotgun|Laser|SpreadGun|Plasma", MAX_DESCRIPTION_LENGTH); + loadEnemyTypes(enemyTypes); } loadTriggers(cJSON_GetObjectItem(root, "triggers")); @@ -196,6 +197,9 @@ static void loadObjectives(cJSON *root) { Objective *o; cJSON *node; + int hasEliminateAll; + + hasEliminateAll = 0; for (node = root->child ; node != NULL ; node = node->next) { @@ -212,13 +216,20 @@ static void loadObjectives(cJSON *root) o->currentValue = cJSON_GetObjectItem(node, "currentValue")->valueint; o->required = cJSON_GetObjectItem(node, "required")->valueint; + if (strcmp(o->targetName, "ENEMY") == 0) + { + hasEliminateAll = 1; + } + if (game.plus != PLUS_NONE) { o->required = 1; } + + world.numObjectives++; } - if (game.plus == PLUS_PLUS_PLUS) + if (game.plus == PLUS_PLUS_PLUS && !hasEliminateAll) { o = malloc(sizeof(Objective)); memset(o, 0, sizeof(Objective)); @@ -227,7 +238,11 @@ static void loadObjectives(cJSON *root) STRNCPY(o->id, "O99", MAX_NAME_LENGTH); STRNCPY(o->targetName, "ENEMY", MAX_NAME_LENGTH); - STRNCPY(o->description, "Eliminate all enemies", MAX_DESCRIPTION_LENGTH); + STRNCPY(o->description, _("Defeat enemies"), MAX_DESCRIPTION_LENGTH); o->required = 1; + + world.minEnemySpawnTime = world.maxEnemySpawnTime = 0; + + world.numObjectives++; } }