From 74c3a32abf0c53d4a02c2f28dc7b784b47e2569f Mon Sep 17 00:00:00 2001 From: Steve Date: Wed, 4 May 2016 09:26:00 +0100 Subject: [PATCH] Added 2 Birds trophy. --- data/trophies/trophies.json | 7 +++++++ src/battle/mine.c | 16 ++++++++++++++-- src/battle/mine.h | 3 ++- src/game/trophies.c | 2 ++ 4 files changed, 25 insertions(+), 3 deletions(-) diff --git a/data/trophies/trophies.json b/data/trophies/trophies.json index 0ab09ab..ceb28d6 100644 --- a/data/trophies/trophies.json +++ b/data/trophies/trophies.json @@ -248,5 +248,12 @@ "description" : "Complete a fighter-based campaign mission without firing", "value" : "TROPHY_BRONZE", "hidden" : 1 + }, + { + "id" : "2_BIRDS", + "title" : "2 birds, 1 stone", + "description" : "Destroy two or more fighters by shooting one mine", + "value" : "TROPHY_BRONZE", + "hidden" : 1 } ] diff --git a/src/battle/mine.c b/src/battle/mine.c index 4765674..a66d9e7 100644 --- a/src/battle/mine.c +++ b/src/battle/mine.c @@ -196,10 +196,12 @@ static void die(void) static void doSplashDamage(void) { Entity *e, **candidates; - int i, dist; + int i, dist, kills; float damage, percent; candidates = getAllEntsWithin(self->x - (self->w / 2), self->y - (self->h / 2), self->w, self->h, self); + + kills = 0; for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i]) { @@ -213,12 +215,17 @@ static void doSplashDamage(void) percent /= DAMAGE_RANGE; percent = 1 - percent; - damage = 255; + damage = DAMAGE_RANGE; damage *= percent; if (e->type == ET_FIGHTER) { damageFighter(e, damage, 0); + + if (self->killedBy == player && e != player && e->health <= 0) + { + kills++; + } } else if (e->type == ET_MINE) { @@ -231,4 +238,9 @@ static void doSplashDamage(void) } } } + + if (kills >= 2) + { + awardTrophy("2_BIRDS"); + } } diff --git a/src/battle/mine.h b/src/battle/mine.h index b83ba95..91d3582 100644 --- a/src/battle/mine.h +++ b/src/battle/mine.h @@ -21,7 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "../common.h" #define TRIGGER_RANGE 150 -#define DAMAGE_RANGE 255 +#define DAMAGE_RANGE 275 #define SYSTEM_POWER 50 extern Entity *spawnEntity(void); @@ -33,6 +33,7 @@ extern void damageFighter(Entity *e, int amount, long flags); extern void playBattleSound(int id, int x, int y); extern void updateObjective(char *name, int type); extern void runScriptFunction(const char *format, ...); +extern void awardTrophy(char *id); extern Battle battle; extern Entity *player; diff --git a/src/game/trophies.c b/src/game/trophies.c index 0fd7396..d42fa20 100644 --- a/src/game/trophies.c +++ b/src/game/trophies.c @@ -215,6 +215,8 @@ void awardTrophy(char *id) t->awarded = 1; t->awardDate = time(NULL); t->notify = 1; + + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Awarding trophy '%s'", id); } if (!t->awarded)