From 994c0b55dd0dc1c3da7bdf6b8dce1383fab9bccb Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 1 Apr 2016 14:19:55 +0100 Subject: [PATCH] Don't explode mine on owner. --- src/battle/mine.c | 21 +++++++++++++-------- src/battle/mine.h | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/battle/mine.c b/src/battle/mine.c index 99e6265..332e447 100644 --- a/src/battle/mine.c +++ b/src/battle/mine.c @@ -25,23 +25,28 @@ static void die(void); static void lookForFighters(void); static void doSplashDamage(void); -static SDL_Texture *mineWarning; -static SDL_Texture *mineNormal; +static SDL_Texture *mineWarning = NULL; +static SDL_Texture *mineNormal = NULL; Entity *spawnMine(void) { Entity *mine = spawnEntity(); + + if (!mineNormal || !mineWarning) + { + mineNormal = getTexture("gfx/entities/mine.png"); + mineWarning = getTexture("gfx/entities/mineWarning.png"); + } mine->type = ET_MINE; mine->health = mine->maxHealth = 1; mine->systemPower = SYSTEM_POWER; - mine->texture = getTexture("gfx/entities/mine.png"); + mine->texture = mineNormal; mine->action = think; mine->die = die; - mine->flags = EF_TAKES_DAMAGE+EF_SHORT_RADAR_RANGE+EF_NO_TARGET; + mine->flags = EF_TAKES_DAMAGE+EF_NO_TARGET; - mineNormal = getTexture("gfx/entities/mine.png"); - mineWarning = getTexture("gfx/entities/mineWarning.png"); + SDL_QueryTexture(mine->texture, NULL, NULL, &mine->w, &mine->h); return mine; } @@ -59,7 +64,7 @@ static void think(void) lookForFighters(); - if (self->systemPower < SYSTEM_POWER && SDL_GetTicks() % 150 < 75) + if (self->systemPower < SYSTEM_POWER && battle.stats[STAT_TIME] % 8 < 4) { playBattleSound(SND_MINE_WARNING, self->x, self->y); @@ -76,7 +81,7 @@ static void lookForFighters(void) for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i]) { - if (e->health > 0 && e->type == ET_FIGHTER && getDistance(self->x, self->y, e->x, e->y) <= TRIGGER_RANGE) + if (e->side != self->side && e->health > 0 && e->type == ET_FIGHTER && getDistance(self->x, self->y, e->x, e->y) <= TRIGGER_RANGE) { self->systemPower--; diff --git a/src/battle/mine.h b/src/battle/mine.h index 71299db..6c613d9 100644 --- a/src/battle/mine.h +++ b/src/battle/mine.h @@ -22,7 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define TRIGGER_RANGE 150 #define DAMAGE_RANGE 255 -#define SYSTEM_POWER 75 +#define SYSTEM_POWER 50 extern Entity *spawnEntity(void); extern SDL_Texture *getTexture(char *filename); @@ -32,4 +32,5 @@ extern void addMineExplosion(void); extern void damageFighter(Entity *e, int amount, long flags); extern void playBattleSound(int id, int x, int y); +extern Battle battle; extern Entity *self;