/*
-Copyright (C) 2004-2010 Parallel Realities
+Copyright (C) 2004-2011 Parallel Realities
+Copyright (C) 2011-2015 Perpendicular Dimensions
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
void addEnemy(const char *name, int x, int y, int flags)
{
- Entity *enemy = new Entity();
Entity *defEnemy = getDefinedEnemy(name);
if (defEnemy == NULL)
return;
}
+ Entity *enemy = new Entity();
enemy->setName(defEnemy->name);
enemy->setSprites(defEnemy->sprite[0], defEnemy->sprite[1], defEnemy->sprite[2]);
enemy->currentWeapon = defEnemy->currentWeapon;
if (!(enemy->flags & ENT_EXPLODES))
{
- audio.playSound(SND_HIT, CH_ANY);
+ audio.playSound(SND_HIT, CH_ANY, enemy->x);
if (game.gore)
{
addBlood(enemy, bullet->dx / 4, Math::rrand(-6, -3), 1);
}
else
{
- audio.playSound(SND_CLANG, CH_ANY);
+ audio.playSound(SND_CLANG, CH_ANY, enemy->x);
addColorParticles(bullet->x, bullet->y, Math::rrand(25, 75), -1);
}
if (enemy->flags & ENT_EXPLODES)
{
- audio.playSound(SND_ELECDEATH1 + Math::prand() % 3, CH_DEATH);
+ audio.playSound(SND_ELECDEATH1 + Math::prand() % 3, CH_DEATH, enemy->x);
}
else if (game.gore)
{
- audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH);
+ audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH, enemy->x);
}
}
}
if (enemy->flags & ENT_EXPLODES)
{
- audio.playSound(SND_ELECDEATH1 + Math::prand() % 3, CH_DEATH);
+ audio.playSound(SND_ELECDEATH1 + Math::prand() % 3, CH_DEATH, enemy->x);
}
else if (game.gore)
{
- audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH);
+ audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH, enemy->x);
}
if (bullet->owner == &player)
}
}
- (game.gore) ? audio.playSound(SND_SPLAT, CH_ANY) : audio.playSound(SND_POP, CH_ANY);
+ (game.gore) ? audio.playSound(SND_SPLAT, CH_ANY) : audio.playSound(SND_POP, CH_ANY, enemy->x);
}
void doEnemies()
{
if (game.gore)
{
- audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH);
+ audio.playSound(SND_DEATH1 + Math::prand() % 3, CH_DEATH, enemy->x);
}
}
}
{
int enemy = -1;
- for (int i = MAX_ENEMIES ; i > -1 ; i--)
+ for (int i = MAX_ENEMIES - 1; i >= 0; i--)
if (strcmp(defEnemy[i].name, "") == 0)
enemy = i;
if (!engine.loadData("data/defEnemies"))
{
- graphics.showErrorAndExit("Couldn't load enemy definitions file (%s)", "data/defEnemies");
+ return graphics.showErrorAndExit("Couldn't load enemy definitions file (%s)", "data/defEnemies");
}
char *token = strtok((char*)engine.dataBuffer, "\n");