Code: Select all
void CUnit::KillUnit(bool selfDestruct, bool reclaimed, CUnit* attacker, bool showDeathSequence)
{
if (isDead) { return; }
if (crashing && !beingBuilt) { return; }
isDead = true;
deathSpeed = speed;
eventHandler.UnitDestroyed(this, attacker);
Code: Select all
eoh->UnitDestroyed(*this, attacker);
// Will be called in the destructor again, but this can not hurt
this->SetGroup(NULL);
blockHeightChanges = false;
if (unitDef->windGenerator > 0.0f) {
wind.DelUnit(this);
}
if (showDeathSequence && (!reclaimed && !beingBuilt)) {
const WeaponDef* wd = (selfDestruct)? unitDef->selfdExpWeaponDef: unitDef->deathExpWeaponDef;
if (wd != NULL) {
CGameHelper::ExplosionParams params = {
pos,
ZeroVector,
wd->damages,
wd,
this, // owner
NULL, // hitUnit
NULL, // hitFeature
wd->craterAreaOfEffect,
wd->damageAreaOfEffect,
wd->edgeEffectiveness,
wd->explosionSpeed,
wd->damages[0] > 500? 1.0f: 2.0f, // gfxMod
false, // impactOnly
false, // ignoreOwner
true, // damageGround
};
helper->Explosion(params);
}
if (selfDestruct) {
recentDamage += maxHealth * 2;
}
// start running the unit's kill-script
script->Killed();
Code: Select all
} else {
deathScriptFinished = true;
}
Code: Select all
if (!deathScriptFinished) {
// put the unit in a pseudo-zombie state until Killed finishes
speed = ZeroVector;
SetStunned(true);
paralyzeDamage = 100.0f * maxHealth;
health = std::max(health, 0.0f);
}
}
is there a callin to know when a unitId has actually been freed and has returned to the ID pool? Aka the unit is actually dead and no longer in game.