diff --git a/src/defs.h b/src/defs.h index 3f0da94..04fcad9 100644 --- a/src/defs.h +++ b/src/defs.h @@ -433,3 +433,11 @@ enum ST_EMPTY_SAVE, ST_MAX }; + +enum +{ + PLUS_NONE, + PLUS, + PLUS_PLUS, + PLUS_PLUS_PLUS +}; diff --git a/src/entities/items/cell.c b/src/entities/items/cell.c index f844040..7b307e9 100644 --- a/src/entities/items/cell.c +++ b/src/entities/items/cell.c @@ -48,7 +48,7 @@ Entity *initCell(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; } diff --git a/src/entities/items/heart.c b/src/entities/items/heart.c index 93d7032..64c1b5a 100644 --- a/src/entities/items/heart.c +++ b/src/entities/items/heart.c @@ -50,7 +50,7 @@ Entity *initHeart(Entity *e) static void init(void) { - if (game.isComplete && rand() % 3 > 0) + if ((game.isComplete && rand() % 3 > 0) || game.plus != PLUS_NONE) { self->alive = ALIVE_DEAD; } diff --git a/src/entities/structures/door.c b/src/entities/structures/door.c index 9d15f7d..b00b9bb 100644 --- a/src/entities/structures/door.c +++ b/src/entities/structures/door.c @@ -76,6 +76,11 @@ static void init(void) s->closedX = s->x; s->closedY = s->y; } + + if (game.plus != PLUS_NONE) + { + s->alive = ALIVE_DEAD; + } } Entity *initBronzeDoor(void) diff --git a/src/entities/structures/door.h b/src/entities/structures/door.h index e54ebe0..87bad5a 100644 --- a/src/entities/structures/door.h +++ b/src/entities/structures/door.h @@ -37,3 +37,4 @@ extern void setGameplayMessage(int type, char *format, ...); extern App app; extern Dev dev; extern Entity *self; +extern Game game; diff --git a/src/entities/unit.c b/src/entities/unit.c index 9a34c69..186b966 100644 --- a/src/entities/unit.c +++ b/src/entities/unit.c @@ -75,15 +75,16 @@ static void init(void) u->canCarryItem = rand() % 100 < 85; - if (world.missionType == MT_OUTPOST || game.plus) + if (world.missionType == MT_OUTPOST) { u->canCarryItem = 1; u->health = u->healthMax = rrnd(1, 4); - - if (game.plus) - { - u->health = u->healthMax = rrnd(4, 8); - } + } + + if (game.plus == PLUS_PLUS_PLUS) + { + u->canCarryItem = 1; + u->health = u->healthMax = rrnd(4, 8); } } diff --git a/src/hub/postMission.c b/src/hub/postMission.c index 5a4a9dd..7eed48c 100644 --- a/src/hub/postMission.c +++ b/src/hub/postMission.c @@ -94,11 +94,17 @@ static void saveGameAndWorld(void) saveGame(1); - saveWorld(); + if (game.plus == PLUS_NONE) + { + saveWorld(); - 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); - renameFile(src, dest); + 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); + renameFile(src, dest); + + free(src); + free(dest); + } src = buildFormattedString("%s/%d/game.json.tmp", app.saveDir, game.saveSlot); dest = buildFormattedString("%s/%d/game.json", app.saveDir, game.saveSlot, world.id); diff --git a/src/main.c b/src/main.c index 5ba3e03..be3355a 100644 --- a/src/main.c +++ b/src/main.c @@ -115,7 +115,7 @@ static void handleCommandLine(int argc, char *argv[]) char *worldId; worldId = NULL; - plus = 0; + plus = PLUS_NONE; for (i = 1 ; i < argc ; i++) { @@ -186,7 +186,7 @@ static void handleCommandLine(int argc, char *argv[]) if (strcmp(argv[i], "-plus") == 0) { - plus = 1; + plus = atoi(argv[++i]); } } diff --git a/src/test/worldTest.c b/src/test/worldTest.c index 77273ae..c80eb7a 100644 --- a/src/test/worldTest.c +++ b/src/test/worldTest.c @@ -30,7 +30,7 @@ void initWorldTest(char *worldId, int plus) { STRNCPY(game.worldId, worldId, MAX_NAME_LENGTH); - game.plus = 1; + game.plus = plus; initWorld(); } diff --git a/src/world/objectives.c b/src/world/objectives.c index be0a9c4..f15185f 100644 --- a/src/world/objectives.c +++ b/src/world/objectives.c @@ -52,13 +52,13 @@ void initObjectives(void) } } - if (world.isReturnVisit) + if (world.isReturnVisit || game.plus != PLUS_NONE) { o->targetValue = o->totalValue; 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; } diff --git a/src/world/worldLoader.c b/src/world/worldLoader.c index 72819ad..84b14b2 100644 --- a/src/world/worldLoader.c +++ b/src/world/worldLoader.c @@ -25,7 +25,6 @@ static void loadTriggers(cJSON *root); static void loadBob(cJSON *root); static void loadEntities(cJSON *root); static void loadObjectives(cJSON *root); -static void initPlusEnemyTypes(void); 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, "boss", 4) == 0 ? MT_BOSS : world.missionType; - if (!game.plus) + if (game.plus < PLUS_PLUS) { loadEnemyTypes(cJSON_GetObjectItem(root, "enemyTypes")->valuestring); } else { - initPlusEnemyTypes(); + loadEnemyTypes("Pistol|Grenade|MachineGun|Shotgun|Laser|SpreadGun|Plasma"); } loadTriggers(cJSON_GetObjectItem(root, "triggers")); @@ -156,6 +155,12 @@ static void loadBob(cJSON *root) world.bob->init(); 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) @@ -184,11 +189,6 @@ static void loadEntities(cJSON *root) { 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->required = cJSON_GetObjectItem(node, "required")->valueint; - if (game.plus) + if (game.plus != PLUS_NONE) { o->required = 1; } } -} -static void initPlusEnemyTypes(void) -{ - world.numEnemyTypes = 7; - - world.enemyTypes = malloc(world.numEnemyTypes * sizeof(char*)); - - world.enemyTypes[0] = "Pistol"; - world.enemyTypes[1] = "Grenade"; - world.enemyTypes[2] = "MachineGun"; - world.enemyTypes[3] = "Shotgun"; - world.enemyTypes[4] = "Laser"; - world.enemyTypes[5] = "SpreadGun"; - world.enemyTypes[6] = "Plasma"; + if (game.plus == PLUS_PLUS_PLUS) + { + o = malloc(sizeof(Objective)); + memset(o, 0, sizeof(Objective)); + world.objectiveTail->next = o; + world.objectiveTail = o; + + STRNCPY(o->id, "O99", MAX_NAME_LENGTH); + STRNCPY(o->targetName, "ENEMY", MAX_NAME_LENGTH); + STRNCPY(o->description, "Eliminate all enemies", MAX_DESCRIPTION_LENGTH); + o->required = 1; + } }