[9497] Implement basic use of SPLINETYPE_FACINGTARGET

Adjust related helper function accordingly.

Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
NoFantasy 2010-03-01 14:12:07 +01:00
parent 4a051e2443
commit 44d768cac5
3 changed files with 24 additions and 4 deletions

View file

@ -388,8 +388,8 @@ void Unit::SendMonsterMove(float NewPosX, float NewPosY, float NewPosZ, SplineTy
data << float(0);
data << float(0);
break;
case SPLINETYPE_FACINGTARGET: // not used currently
data << uint64(0); // probably target guid (facing target?)
case SPLINETYPE_FACINGTARGET:
data << uint64(m_InteractionObject); // set in SetFacingToObject()
break;
case SPLINETYPE_FACINGANGLE: // not used currently
data << float(0); // facing angle
@ -3515,6 +3515,24 @@ void Unit::SetFacingTo(float ori)
SendMessageToSet(&data, false);
}
// Consider move this to Creature:: since only creature appear to be able to use this
void Unit::SetFacingToObject(WorldObject* pObject)
{
if (GetTypeId() != TYPEID_UNIT)
return;
// never face when already moving
if (!IsStopped())
return;
m_InteractionObject = pObject->GetGUID();
// TODO: figure out under what conditions creature will move towards object instead of facing it where it currently is.
SetOrientation(GetAngle(pObject));
SendMonsterMove(GetPositionX(), GetPositionY(), GetPositionZ(), SPLINETYPE_FACINGTARGET, ((Creature*)this)->GetSplineFlags(), 0);
}
bool Unit::isInAccessablePlaceFor(Creature const* c) const
{
if(IsInWater())