mirror of
https://github.com/mangosfour/server.git
synced 2025-12-28 13:37:13 +00:00
[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:
parent
44915f6f13
commit
2b65cdb3bb
13 changed files with 223 additions and 362 deletions
|
|
@ -24,6 +24,7 @@
|
|||
#include "ObjectMgr.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "CreatureAI.h"
|
||||
#include "InstanceData.h"
|
||||
|
||||
Totem::Totem() : Creature(CREATURE_SUBTYPE_TOTEM)
|
||||
{
|
||||
|
|
@ -31,6 +32,43 @@ Totem::Totem() : Creature(CREATURE_SUBTYPE_TOTEM)
|
|||
m_type = TOTEM_PASSIVE;
|
||||
}
|
||||
|
||||
bool Totem::Create(uint32 guidlow, CreatureCreatePos& cPos, uint32 Entry, Unit* owner)
|
||||
{
|
||||
SetMap(cPos.GetMap());
|
||||
SetPhaseMask(cPos.GetPhaseMask(), false);
|
||||
|
||||
Team team = owner->GetTypeId() == TYPEID_PLAYER ? ((Player*)owner)->GetTeam() : TEAM_NONE;
|
||||
|
||||
if (!CreateFromProto(guidlow, Entry, team))
|
||||
return false;
|
||||
|
||||
// special model selection case for totems
|
||||
if (owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
if (uint32 modelid_race = sObjectMgr.GetModelForRace(GetNativeDisplayId(), owner->getRaceMask()))
|
||||
SetDisplayId(modelid_race);
|
||||
}
|
||||
|
||||
cPos.SelectFinalPoint(this);
|
||||
|
||||
// totem must be at same Z in case swimming caster and etc.
|
||||
if (fabs(cPos.m_pos.z - owner->GetPositionZ() ) > 5.0f)
|
||||
cPos.m_pos.z = owner->GetPositionZ();
|
||||
|
||||
if (!cPos.Relocate(this))
|
||||
return false;
|
||||
|
||||
//Notify the map's instance data.
|
||||
//Only works if you create the object in it, not if it is moves to that map.
|
||||
//Normally non-players do not teleport to other maps.
|
||||
if (InstanceData* iData = GetMap()->GetInstanceData())
|
||||
iData->OnCreatureCreate(this);
|
||||
|
||||
LoadCreatureAddon();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Totem::Update(uint32 update_diff, uint32 time )
|
||||
{
|
||||
Unit *owner = GetOwner();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue