Core/Creatures: Properly initialize m_zoneScript when it depends on zone id (OutdoorPvP/Battlefield) and fixed z offset for hovering creatures at creation
This commit is contained in:
@@ -758,16 +758,14 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry,
|
||||
return false;
|
||||
}
|
||||
|
||||
//! Relocate before CreateFromProto, to initialize coords and allow
|
||||
//! returning correct zone id for selecting OutdoorPvP/Battlefield script
|
||||
Relocate(x, y, z, ang);
|
||||
|
||||
//oX = x; oY = y; dX = x; dY = y; m_moveTime = 0; m_startMove = 0;
|
||||
if (!CreateFromProto(guidlow, Entry, vehId, team, data))
|
||||
return false;
|
||||
|
||||
//! Need to be called after CreateFromProto
|
||||
if (HasUnitMovementFlag(MOVEMENTFLAG_HOVER))
|
||||
z += GetFloatValue(UNIT_FIELD_HOVERHEIGHT);
|
||||
|
||||
Relocate(x, y, z, ang);
|
||||
|
||||
if (!IsPositionValid())
|
||||
{
|
||||
sLog->outError("Creature::Create(): given coordinates for creature (guidlow %d, entry %d) are not valid (X: %f, Y: %f, Z: %f, O: %f)", guidlow, Entry, x, y, z, ang);
|
||||
@@ -794,6 +792,14 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry,
|
||||
}
|
||||
|
||||
LoadCreaturesAddon();
|
||||
|
||||
//! Need to be called after LoadCreaturesAddon - MOVEMENTFLAG_HOVER is set there
|
||||
if (HasUnitMovementFlag(MOVEMENTFLAG_HOVER))
|
||||
z += GetFloatValue(UNIT_FIELD_HOVERHEIGHT);
|
||||
|
||||
//! Relocate again with updated Z coord
|
||||
Relocate(x, y, z, ang);
|
||||
|
||||
uint32 displayID = GetNativeDisplayId();
|
||||
CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelRandomGender(&displayID);
|
||||
if (minfo && !isTotem()) // Cancel load if no model defined or if totem
|
||||
|
||||
Reference in New Issue
Block a user