From cfecdbd5851798c5a9706940fac8fae3a3d24c86 Mon Sep 17 00:00:00 2001 From: Layla Marchant Date: Sat, 7 Mar 2020 13:42:11 -0500 Subject: [PATCH] Made Chris not leave until all worthwhile collectables are gone. This is something I've been thinking of doing for awhile. The automatic leaving can be frustrating if you were trying to collect the money dropped by the enemy and you're suddenly forced out of the mission. This prevents that by simply waiting to do the exit sequence until no worthwhile collectables are left in the area. Ellesh and Mars are excluded since this won't really work in those areas. Also excluded by Classic and Nightmare difficulties. --- src/collectable.c | 39 +++++++++++++++++++++++++++++++++++++++ src/collectable.h | 1 + src/game.c | 6 +++++- 3 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/collectable.c b/src/collectable.c index 1ea6180..8b11047 100644 --- a/src/collectable.c +++ b/src/collectable.c @@ -315,3 +315,42 @@ void collectable_explode(Collectable *collectable) player_checkShockDamage(collectable->x, collectable->y); } + +/* +Returns the number of "good" collectables (all collectables excluding +mines and unneeded refills) that exist. +*/ +int collectable_numGood() +{ + Collectable *col = engine.collectableHead->next; + int n = 0; + + while (col != NULL) + { + if ((col->type != P_MINE) && + ((col->type != P_SHIELD) || (player.shield < player.maxShield)) && + ((col->type != P_ROCKET) || (player.ammo[1] < game.maxRocketAmmo)) && + ((col->type != P_PLASMA_AMMO) || (player.ammo[0] < game.maxPlasmaAmmo)) && + ((col->type != P_PLASMA_SHOT) || + (player.ammo[0] < game.maxPlasmaAmmo) || + (weapons[W_PLAYER_WEAPON].ammo[0] < game.maxPlasmaOutput)) && + ((col->type != P_PLASMA_DAMAGE) || + (player.ammo[0] < game.maxPlasmaAmmo) || + (weapons[W_PLAYER_WEAPON].damage < game.maxPlasmaDamage)) && + ((col->type != P_PLASMA_RATE) || + (player.ammo[0] < game.maxPlasmaAmmo) || + (weapons[W_PLAYER_WEAPON].reload[0] > rate2reload[game.maxPlasmaRate])) && + ((col->type != P_SUPER) || + (player.ammo[0] < game.maxPlasmaAmmo) || + (weapons[W_PLAYER_WEAPON].ammo[0] < game.maxPlasmaOutput) || + (weapons[W_PLAYER_WEAPON].damage < game.maxPlasmaDamage) || + (weapons[W_PLAYER_WEAPON].reload[0] > rate2reload[game.maxPlasmaRate]))) + { + n++; + } + + col = col->next; + } + + return n; +} diff --git a/src/collectable.h b/src/collectable.h index d7323e6..4d1233a 100644 --- a/src/collectable.h +++ b/src/collectable.h @@ -41,5 +41,6 @@ typedef struct Collectable_ { void collectable_add(float x, float y, int type, int value, int life); int collectable_collision(Collectable *collectable, Object *ship); void collectable_explode(Collectable *collectable); +int collectable_numGood(); #endif diff --git a/src/game.c b/src/game.c index 3e2a6f2..570a39d 100644 --- a/src/game.c +++ b/src/game.c @@ -2601,7 +2601,11 @@ int game_mainLoop() engine.gameSection = SECTION_INTERMISSION; if (player.shield > 0) { - if (SDL_GetTicks() >= engine.missionCompleteTimer) + if ((SDL_GetTicks() >= engine.missionCompleteTimer) && + ((game.difficulty == DIFFICULTY_ORIGINAL) || + (game.difficulty == DIFFICULTY_NIGHTMARE) || + (game.area == MISN_ELLESH) || (game.area == MISN_MARS) || + (mission_checkFailed()) || (collectable_numGood() <= 0))) { if ((!mission_checkFailed()) && (game.area != MISN_VENUS)) {