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_MAX
};
enum
{
PLUS_NONE,
PLUS,
PLUS_PLUS,
PLUS_PLUS_PLUS
};

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -30,7 +30,7 @@ void initWorldTest(char *worldId, int plus)
{
STRNCPY(game.worldId, worldId, MAX_NAME_LENGTH);
game.plus = 1;
game.plus = plus;
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->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;
}

View File

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