[-] Correct explosion for critters

This commit is contained in:
cybermind 2015-02-15 15:00:38 +05:00
parent 951f59e4c5
commit 53ed03e055
3 changed files with 8 additions and 3 deletions

View file

@ -511,7 +511,7 @@ void CommandDismiss(CUnit &unit)
unit.CurrentOrder()->Cancel(unit);
} else {
DebugPrint("Suicide unit ... \n");
LetUnitDie(unit);
LetUnitDie(unit, true);
}
ClearSavedAction(unit);
}

View file

@ -546,7 +546,7 @@ extern int ExtraDeathIndex(const char *death);
extern CUnit *UnitOnScreen(int x, int y);
/// Let a unit die
extern void LetUnitDie(CUnit &unit);
extern void LetUnitDie(CUnit &unit, bool suicide = false);
/// Destroy all units inside another unit
extern void DestroyAllInside(CUnit &source);
/// Calculate some value to measure the unit's priority for AI

View file

@ -2230,7 +2230,7 @@ PixelPos CUnit::GetMapPixelPosCenter() const
**
** @param unit Unit to be destroyed.
*/
void LetUnitDie(CUnit &unit)
void LetUnitDie(CUnit &unit, bool suicide)
{
unit.Variable[HP_INDEX].Value = std::min<int>(0, unit.Variable[HP_INDEX].Value);
unit.Moving = 0;
@ -2270,6 +2270,11 @@ void LetUnitDie(CUnit &unit)
type->DeathExplosion->pushInteger(pixelPos.y);
type->DeathExplosion->run();
}
if (suicide) {
const PixelPos pixelPos = unit.GetMapPixelPosCenter();
MakeMissile(*type->Missile.Missile, pixelPos, pixelPos);
}
// Handle Teleporter Destination Removal
if (type->Teleporter && unit.Goal) {
unit.Goal->Remove(NULL);