diff --git a/rc.c b/rc.c index b038668..dd6f333 100644 --- a/rc.c +++ b/rc.c @@ -460,10 +460,15 @@ int main (int argc, char **argv) { } } } - if (player->powerup == PW_GUNNER) { // red overlay for machine gunner + // gunner effect - red overlay + if (player->powerup == PW_GUNNER) { if (levelcomplete != LV_DOPOKER) { SDL_BlitSurface(redbox,NULL,screen,NULL); } + if (uncaughtmonsters() <= 0) { + // finish if no monsters are left alive & uncaught + losepowerup(player); + } } /********************************************** @@ -885,12 +890,14 @@ void tick(void) { // never reach hurryup time resethurryup(curlevel); + + // decrement counter guntime--; if (guntime < 0) { // finished! losepowerup(player); - } + } } } @@ -1443,6 +1450,23 @@ int countmonsters(int montype) { return mcount; } +// count of monsters left alive and uncaught +int uncaughtmonsters(void) { + sprite_t *s2; + int mcount; + mcount = 0; + /* any monsters left? */ + for (s2 = sprite->next ; s2 ; s2 = s2->next) { + if (ismonster(s2->id) && !s2->dead && !s2->caughtby) { + if (s2->id != P_BLACKCLOUD) { + mcount++; + } + } + } + + return mcount; +} + void cleanup(void) { int i; printf("commencing cleanup routine....\n"); diff --git a/rc.h b/rc.h index 2b57edf..70ab6e0 100644 --- a/rc.h +++ b/rc.h @@ -104,3 +104,4 @@ void keeponscreen(sprite_t *s); void stopteleporting(sprite_t *s); void losepowerup(sprite_t *s); int easymode(void); +int uncaughtmonsters(void);