Added 2 Birds trophy.

This commit is contained in:
Steve 2016-05-04 09:26:00 +01:00
parent 9e35c44910
commit 74c3a32abf
4 changed files with 25 additions and 3 deletions

View File

@ -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
}
]

View File

@ -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");
}
}

View File

@ -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;

View File

@ -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)