Make flying creatures fall on ground when killed.

Fix also fly speed computation for creatures.

Signed-off-by: Neo2003 <neo.2003@hotmail.fr>
This commit is contained in:
Neo2003 2008-12-07 00:26:07 +01:00
parent 8eccdbc046
commit 211f987aa9
4 changed files with 39 additions and 2 deletions

View file

@ -446,6 +446,11 @@ void Creature::Update(uint32 diff)
m_regenTimer = 2000;
break;
}
case DEAD_FALLING:
{
if (!FallGround())
setDeathState(JUST_DIED);
}
default:
break;
}
@ -1487,6 +1492,9 @@ void Creature::setDeathState(DeathState s)
if(sWorld.getConfig(CONFIG_SAVE_RESPAWN_TIME_IMMEDIATLY) || isWorldBoss())
SaveRespawnTime();
if (canFly() && FallGround())
return;
if(!IsStopped())
StopMoving();
}
@ -1501,6 +1509,9 @@ void Creature::setDeathState(DeathState s)
if ( LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId) )
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
if (canFly() && FallGround())
return;
Unit::setDeathState(CORPSE);
}
if(s == JUST_ALIVED)
@ -1520,6 +1531,25 @@ void Creature::setDeathState(DeathState s)
}
}
bool Creature::FallGround()
{
// Let's abort after we called this function one time
if (getDeathState() == DEAD_FALLING)
return false;
// Let's do with no vmap because no way to get far distance with vmap high call
float tz = GetMap()->GetHeight(GetPositionX(), GetPositionY(), GetPositionZ(), false);
// Abort too if the ground is very near
if (fabs(GetPositionZ() - tz) < 0.1f)
return false;
Unit::setDeathState(DEAD_FALLING);
GetMotionMaster()->MovePoint(0, GetPositionX(), GetPositionY(), tz);
Relocate(GetPositionX(), GetPositionY(), tz);
return true;
}
void Creature::Respawn()
{
RemoveCorpse();