[11244] Collect in CreatureCreatePos data for delayed pos setup into Creature::Create.

* CreatureCreatePos work in 3 modes:
    - exactly provided coordinates/orientation/map/phasemask
    - exactly object + orientation as coordinates/map/phasemask
    - delayed position calculation near provided object at specific dist/angle.
* Use in similar way and for Pet/Vehicle Create functions.
  For Totem created new Totem::Create function with some moved in to it totem specific code.
* This let resolve recent problems with creature spawn and preserve fix for cases when
  Creature::Create addon/script code expected known correct possition for creature.
This commit is contained in:
VladimirMangos 2011-03-14 05:42:44 +03:00
parent 44915f6f13
commit 2b65cdb3bb
13 changed files with 223 additions and 362 deletions

View file

@ -1653,33 +1653,18 @@ Creature* WorldObject::SummonCreature(uint32 id, float x, float y, float z, floa
if (GetTypeId()==TYPEID_PLAYER)
team = ((Player*)this)->GetTeam();
// FIXME: Setup near to finish point because GetObjectBoundingRadius set in Create but some Create calls can be dependent from proper position
// if creature have creature_template_addon.auras with persistent point for example or script call
CreatureCreatePos pos(GetMap(), x, y, x, ang, GetPhaseMask());
if (x == 0.0f && y == 0.0f && z == 0.0f)
GetClosePoint(x, y, z, 0);
pos = CreatureCreatePos(this, GetOrientation(), CONTACT_DISTANCE, ang);
pCreature->Relocate(x, y, z, ang);
if (!pCreature->Create(GetMap()->GenerateLocalLowGuid(HIGHGUID_UNIT), GetMap(), GetPhaseMask(), id, team))
if (!pCreature->Create(GetMap()->GenerateLocalLowGuid(HIGHGUID_UNIT), pos, id, team))
{
delete pCreature;
return NULL;
}
if (x == 0.0f && y == 0.0f && z == 0.0f)
{
GetClosePoint(x, y, z, pCreature->GetObjectBoundingRadius());
pCreature->Relocate(x, y, z, ang);
}
pCreature->SetSummonPoint(x, y, z, ang);
if(!pCreature->IsPositionValid())
{
sLog.outError("Creature (guidlow %d, entry %d) not summoned. Suggested coordinates isn't valid (X: %f Y: %f)",pCreature->GetGUIDLow(),pCreature->GetEntry(),pCreature->GetPositionX(),pCreature->GetPositionY());
delete pCreature;
return NULL;
}
pCreature->SetSummonPoint(pos);
// Active state set before added to map
pCreature->SetActiveObjectState(asActiveObject);