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