From 691068a634fdc674b0fe43449572a708a6a657b6 Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 14 Dec 2015 14:04:48 +0000 Subject: [PATCH] Shield smash bug fix. --- src/battle/entities.c | 19 ++++++++++++++++++- src/battle/fighters.c | 14 +++++++------- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/battle/entities.c b/src/battle/entities.c index 06eb561..2f3bfe2 100644 --- a/src/battle/entities.c +++ b/src/battle/entities.c @@ -79,7 +79,24 @@ void doEntities(void) self = e; e->reload = MAX(e->reload - 1, 0); - e->shieldRecharge = MAX(e->shieldRecharge - 1, 0); + + if (e->shieldRechargeRate) + { + if (e->shield >= 0) + { + if (--e->shieldRecharge <= 0) + { + e->shield = MIN(e->shield + 1, e->maxShield); + + e->shieldRecharge = e->shieldRechargeRate; + } + } + else + { + e->shield++; + } + } + e->armourHit = MAX(e->armourHit - 25, 0); e->shieldHit = MAX(e->shieldHit - 5, 0); e->systemHit = MAX(e->systemHit - 25, 0); diff --git a/src/battle/fighters.c b/src/battle/fighters.c index 8de0961..133540e 100644 --- a/src/battle/fighters.c +++ b/src/battle/fighters.c @@ -198,12 +198,6 @@ void doFighter(void) addEngineEffect(); } - if (!self->shieldRecharge) - { - self->shield = MIN(self->shield + 1, self->maxShield); - self->shieldRecharge = self->shieldRechargeRate; - } - if (self->health <= 0) { self->health = 0; @@ -403,13 +397,16 @@ void damageFighter(Entity *e, int amount, long flags) } else if (flags & BF_SHIELD_DAMAGE) { - e->shield = MAX(-(FPS * 10), e->shield - amount); + e->shield -= amount; if (e->shield <= 0 && prevShield > 0) { playBattleSound(SND_SHIELD_BREAK, e->x, e->y); addShieldSplinterEffect(e); + e->shield = -(FPS * 10); } + + e->shield = MAX(-(FPS * 10), e->shield); } else { @@ -436,6 +433,9 @@ void damageFighter(Entity *e, int amount, long flags) { e->shieldHit = 255; + /* don't allow the shield to recharge immediately after taking a hit */ + e->shieldRecharge = e->shieldRechargeRate; + playBattleSound(SND_SHIELD_HIT, e->x, e->y); } }