Various Game Plus tweaks.

This commit is contained in:
Steve 2018-05-01 18:15:56 +01:00
parent 3ae8a2a717
commit cdc69cc6a5
11 changed files with 59 additions and 40 deletions

View File

@ -433,3 +433,11 @@ enum
ST_EMPTY_SAVE, ST_EMPTY_SAVE,
ST_MAX ST_MAX
}; };
enum
{
PLUS_NONE,
PLUS,
PLUS_PLUS,
PLUS_PLUS_PLUS
};

View File

@ -48,7 +48,7 @@ Entity *initCell(void)
static void init(void) static void init(void)
{ {
if (game.isComplete && rand() % 3 > 0) if ((game.isComplete && rand() % 3 > 0) || game.plus != PLUS_NONE)
{ {
self->alive = ALIVE_DEAD; self->alive = ALIVE_DEAD;
} }

View File

@ -50,7 +50,7 @@ Entity *initHeart(Entity *e)
static void init(void) static void init(void)
{ {
if (game.isComplete && rand() % 3 > 0) if ((game.isComplete && rand() % 3 > 0) || game.plus != PLUS_NONE)
{ {
self->alive = ALIVE_DEAD; self->alive = ALIVE_DEAD;
} }

View File

@ -76,6 +76,11 @@ static void init(void)
s->closedX = s->x; s->closedX = s->x;
s->closedY = s->y; s->closedY = s->y;
} }
if (game.plus != PLUS_NONE)
{
s->alive = ALIVE_DEAD;
}
} }
Entity *initBronzeDoor(void) Entity *initBronzeDoor(void)

View File

@ -37,3 +37,4 @@ extern void setGameplayMessage(int type, char *format, ...);
extern App app; extern App app;
extern Dev dev; extern Dev dev;
extern Entity *self; extern Entity *self;
extern Game game;

View File

@ -75,15 +75,16 @@ static void init(void)
u->canCarryItem = rand() % 100 < 85; u->canCarryItem = rand() % 100 < 85;
if (world.missionType == MT_OUTPOST || game.plus) if (world.missionType == MT_OUTPOST)
{ {
u->canCarryItem = 1; u->canCarryItem = 1;
u->health = u->healthMax = rrnd(1, 4); u->health = u->healthMax = rrnd(1, 4);
}
if (game.plus)
{ if (game.plus == PLUS_PLUS_PLUS)
u->health = u->healthMax = rrnd(4, 8); {
} u->canCarryItem = 1;
u->health = u->healthMax = rrnd(4, 8);
} }
} }

View File

@ -94,11 +94,17 @@ static void saveGameAndWorld(void)
saveGame(1); saveGame(1);
saveWorld(); if (game.plus == PLUS_NONE)
{
saveWorld();
src = buildFormattedString("%s/%d/%s.json.tmp", app.saveDir, game.saveSlot, world.id); src = buildFormattedString("%s/%d/%s.json.tmp", app.saveDir, game.saveSlot, world.id);
dest = buildFormattedString("%s/%d/%s.json", app.saveDir, game.saveSlot, world.id); dest = buildFormattedString("%s/%d/%s.json", app.saveDir, game.saveSlot, world.id);
renameFile(src, dest); renameFile(src, dest);
free(src);
free(dest);
}
src = buildFormattedString("%s/%d/game.json.tmp", app.saveDir, game.saveSlot); src = buildFormattedString("%s/%d/game.json.tmp", app.saveDir, game.saveSlot);
dest = buildFormattedString("%s/%d/game.json", app.saveDir, game.saveSlot, world.id); dest = buildFormattedString("%s/%d/game.json", app.saveDir, game.saveSlot, world.id);

View File

@ -115,7 +115,7 @@ static void handleCommandLine(int argc, char *argv[])
char *worldId; char *worldId;
worldId = NULL; worldId = NULL;
plus = 0; plus = PLUS_NONE;
for (i = 1 ; i < argc ; i++) for (i = 1 ; i < argc ; i++)
{ {
@ -186,7 +186,7 @@ static void handleCommandLine(int argc, char *argv[])
if (strcmp(argv[i], "-plus") == 0) if (strcmp(argv[i], "-plus") == 0)
{ {
plus = 1; plus = atoi(argv[++i]);
} }
} }

View File

@ -30,7 +30,7 @@ void initWorldTest(char *worldId, int plus)
{ {
STRNCPY(game.worldId, worldId, MAX_NAME_LENGTH); STRNCPY(game.worldId, worldId, MAX_NAME_LENGTH);
game.plus = 1; game.plus = plus;
initWorld(); initWorld();
} }

View File

@ -52,13 +52,13 @@ void initObjectives(void)
} }
} }
if (world.isReturnVisit) if (world.isReturnVisit || game.plus != PLUS_NONE)
{ {
o->targetValue = o->totalValue; o->targetValue = o->totalValue;
o->required = 0; o->required = 0;
} }
if (strcmp(o->targetName, "ENEMY") == 0 && o->targetValue == o->totalValue) if ((strcmp(o->targetName, "ENEMY") == 0 && o->targetValue == o->totalValue) || game.plus != PLUS_PLUS_PLUS)
{ {
world.isEliminateAllEnemies = 1; world.isEliminateAllEnemies = 1;
} }

View File

@ -25,7 +25,6 @@ static void loadTriggers(cJSON *root);
static void loadBob(cJSON *root); static void loadBob(cJSON *root);
static void loadEntities(cJSON *root); static void loadEntities(cJSON *root);
static void loadObjectives(cJSON *root); static void loadObjectives(cJSON *root);
static void initPlusEnemyTypes(void);
void loadWorld(char *id) void loadWorld(char *id)
{ {
@ -67,13 +66,13 @@ void loadWorld(char *id)
world.missionType = strncmp(world.id, "outpost", 7) == 0 ? MT_OUTPOST : world.missionType; world.missionType = strncmp(world.id, "outpost", 7) == 0 ? MT_OUTPOST : world.missionType;
world.missionType = strncmp(world.id, "boss", 4) == 0 ? MT_BOSS : world.missionType; world.missionType = strncmp(world.id, "boss", 4) == 0 ? MT_BOSS : world.missionType;
if (!game.plus) if (game.plus < PLUS_PLUS)
{ {
loadEnemyTypes(cJSON_GetObjectItem(root, "enemyTypes")->valuestring); loadEnemyTypes(cJSON_GetObjectItem(root, "enemyTypes")->valuestring);
} }
else else
{ {
initPlusEnemyTypes(); loadEnemyTypes("Pistol|Grenade|MachineGun|Shotgun|Laser|SpreadGun|Plasma");
} }
loadTriggers(cJSON_GetObjectItem(root, "triggers")); loadTriggers(cJSON_GetObjectItem(root, "triggers"));
@ -156,6 +155,12 @@ static void loadBob(cJSON *root)
world.bob->init(); world.bob->init();
world.bob->animate(); world.bob->animate();
if (game.plus != PLUS_NONE)
{
world.bob->health = world.bob->healthMax = 25;
world.bob->power = world.bob->powerMax = 25;
}
} }
static void loadEntities(cJSON *root) static void loadEntities(cJSON *root)
@ -184,11 +189,6 @@ static void loadEntities(cJSON *root)
{ {
self->alive = ALIVE_DEAD; self->alive = ALIVE_DEAD;
} }
if (self->type == ET_DOOR && game.plus)
{
self->alive = ALIVE_DEAD;
}
} }
} }
@ -212,24 +212,22 @@ static void loadObjectives(cJSON *root)
o->currentValue = cJSON_GetObjectItem(node, "currentValue")->valueint; o->currentValue = cJSON_GetObjectItem(node, "currentValue")->valueint;
o->required = cJSON_GetObjectItem(node, "required")->valueint; o->required = cJSON_GetObjectItem(node, "required")->valueint;
if (game.plus) if (game.plus != PLUS_NONE)
{ {
o->required = 1; o->required = 1;
} }
} }
}
static void initPlusEnemyTypes(void) if (game.plus == PLUS_PLUS_PLUS)
{ {
world.numEnemyTypes = 7; o = malloc(sizeof(Objective));
memset(o, 0, sizeof(Objective));
world.enemyTypes = malloc(world.numEnemyTypes * sizeof(char*)); world.objectiveTail->next = o;
world.objectiveTail = o;
world.enemyTypes[0] = "Pistol";
world.enemyTypes[1] = "Grenade"; STRNCPY(o->id, "O99", MAX_NAME_LENGTH);
world.enemyTypes[2] = "MachineGun"; STRNCPY(o->targetName, "ENEMY", MAX_NAME_LENGTH);
world.enemyTypes[3] = "Shotgun"; STRNCPY(o->description, "Eliminate all enemies", MAX_DESCRIPTION_LENGTH);
world.enemyTypes[4] = "Laser"; o->required = 1;
world.enemyTypes[5] = "SpreadGun"; }
world.enemyTypes[6] = "Plasma";
} }