From 1d033cf32709024fa3e8502183b22a80937de11c Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 6 Mar 2018 08:24:45 +0000 Subject: [PATCH] Don't allow Teeka's shots to hurt the player. --- src/entities/blobs/teeka.c | 7 +++-- src/entities/bullets/bullet.c | 49 +++++++++++++++++++++++------------ src/entities/unit.c | 4 +-- 3 files changed, 36 insertions(+), 24 deletions(-) diff --git a/src/entities/blobs/teeka.c b/src/entities/blobs/teeka.c index 85a95b3..b6d426d 100644 --- a/src/entities/blobs/teeka.c +++ b/src/entities/blobs/teeka.c @@ -144,12 +144,11 @@ static void preFire(void) } attack(); - - u->shotsToFire--; - - if (u->shotsToFire == 0) + + if (--u->shotsToFire <= 0) { u->thinkTime = FPS; + u->action = lookForEnemies; } } diff --git a/src/entities/bullets/bullet.c b/src/entities/bullets/bullet.c index bfac54c..0dcf73b 100644 --- a/src/entities/bullets/bullet.c +++ b/src/entities/bullets/bullet.c @@ -75,6 +75,7 @@ static void tick(void) static void touch(Entity *other) { Bullet *b; + int canHit; b = (Bullet*)self; @@ -95,30 +96,44 @@ static void touch(Entity *other) playBattleSound(SND_RICO_2, b->uniqueId % MAX_SND_CHANNELS, b->x, b->y); } } - else if (other != b->owner && (!(other->flags & EF_IGNORE_BULLETS)) && b->owner->type != other->type) + else { - swapSelf(other); - other->applyDamage(b->damage); - swapSelf(other); - - if (other->flags & EF_EXPLODES) + canHit = ( + other != b->owner && + (!(other->flags & EF_IGNORE_BULLETS)) && + b->owner->type != other->type + ); + + if (b->owner->type == ET_TEEKA && other->type == ET_BOB) { - playBattleSound(SND_METAL_HIT, b->uniqueId % MAX_SND_CHANNELS, b->x, b->y); - - addSparkParticles(b->x, b->y); + canHit = 0; } - else + + if (canHit) { - playBattleSound(SND_FLESH_HIT, b->uniqueId % MAX_SND_CHANNELS, b->x, b->y); + swapSelf(other); + other->applyDamage(b->damage); + swapSelf(other); - addSmallFleshChunk(b->x, b->y); - } + if (other->flags & EF_EXPLODES) + { + playBattleSound(SND_METAL_HIT, b->uniqueId % MAX_SND_CHANNELS, b->x, b->y); - b->alive = ALIVE_DEAD; + addSparkParticles(b->x, b->y); + } + else + { + playBattleSound(SND_FLESH_HIT, b->uniqueId % MAX_SND_CHANNELS, b->x, b->y); - if (b->owner->type == world.bob->type && (other->type == ET_ENEMY || other->type == ET_BOSS || other->type == ET_DESTRUCTABLE)) - { - game.stats[STAT_SHOTS_HIT]++; + addSmallFleshChunk(b->x, b->y); + } + + b->alive = ALIVE_DEAD; + + if (b->owner->type == world.bob->type && (other->type == ET_ENEMY || other->type == ET_BOSS || other->type == ET_DESTRUCTABLE)) + { + game.stats[STAT_SHOTS_HIT]++; + } } } } diff --git a/src/entities/unit.c b/src/entities/unit.c index 1e42a39..39d5230 100644 --- a/src/entities/unit.c +++ b/src/entities/unit.c @@ -269,9 +269,7 @@ static void preFire(void) u->attack(); - u->shotsToFire--; - - if (u->shotsToFire == 0) + if (--u->shotsToFire == 0) { u->action = u->walk; }