Added killedBy, for easier stat counting.

This commit is contained in:
Steve 2016-04-03 08:37:31 +01:00
parent f9d02696fd
commit e7190150bf
5 changed files with 19 additions and 3 deletions

View File

@ -203,10 +203,9 @@ static void checkCollisions(Bullet *b)
}
/* assuming that health <= 0 will always mean killed */
if (e->health <= 0 && b->owner == player && (!(e->flags & EF_NO_KILL_INC)))
if (e->health <= 0)
{
battle.stats[STAT_ENEMIES_KILLED_PLAYER]++;
battle.stats[STAT_EPIC_KILL_STREAK]++;
e->killedBy = b->owner;
}
if (b->owner == player && b->type == BT_MISSILE)

View File

@ -517,6 +517,16 @@ static void die(void)
self->action = simpleDie;
break;
}
if (self->killedBy == player && (!(self->flags & EF_NO_KILL_INC)))
{
battle.stats[STAT_ENEMIES_KILLED_PLAYER]++;
if (battle.isEpic)
{
battle.stats[STAT_EPIC_KILL_STREAK]++;
}
}
}
static void immediateDie(void)

View File

@ -104,6 +104,11 @@ static void lookForFighters(void)
static void die(void)
{
if (self->killedBy == player)
{
battle.stats[STAT_MINES_DESTROYED]++;
}
addMineExplosion();
doSplashDamage();

View File

@ -33,4 +33,5 @@ extern void damageFighter(Entity *e, int amount, long flags);
extern void playBattleSound(int id, int x, int y);
extern Battle battle;
extern Entity *player;
extern Entity *self;

View File

@ -146,6 +146,7 @@ struct Entity {
Entity *target;
Entity *leader;
Entity *owner;
Entity *killedBy;
void (*action)(void);
void (*draw)(void);
void (*die)(void);