From 9c113f2263ac916c823ec55c17ae76691fd60be2 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 1 May 2016 16:34:29 +0100 Subject: [PATCH] Kill missile if its target is dead. --- src/battle/bullets.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/battle/bullets.c b/src/battle/bullets.c index 7fcebf0..6af5c0a 100644 --- a/src/battle/bullets.c +++ b/src/battle/bullets.c @@ -335,12 +335,12 @@ static void selectNewTarget(Bullet *b) int i; Entity *e, **candidates; - b->target = NULL; - - candidates = getAllEntsWithin(b->x - (SCREEN_WIDTH / 2), b->y - (SCREEN_HEIGHT / 2), SCREEN_WIDTH, SCREEN_HEIGHT, NULL); - if (app.gameplay.missileReTarget) { + b->target = NULL; + + candidates = getAllEntsWithin(b->x - (SCREEN_WIDTH / 2), b->y - (SCREEN_HEIGHT / 2), SCREEN_WIDTH, SCREEN_HEIGHT, NULL); + for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i]) { if (e->type == ET_FIGHTER && e->side != b->owner->side && e->health > 0) @@ -356,6 +356,11 @@ static void selectNewTarget(Bullet *b) } } } + + /* no target, just explode */ + b->life = 0; + addMissileExplosion(b); + playBattleSound(SND_EXPLOSION_1, b->x, b->y); } static Bullet *createBullet(int type, int x, int y, Entity *owner)