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:
Shauren
2012-03-23 00:48:32 +01:00
parent 011a73e3e5
commit 479c0976ab
+14 -8
View File
@@ -433,8 +433,8 @@ bool Creature::UpdateEntry(uint32 Entry, uint32 team, const CreatureData* data)
in relation to DisableGravity also. in relation to DisableGravity also.
else if (GetByteValue(UNIT_FIELD_BYTES_1, 3) & UNIT_BYTE_1_FLAG_HOVER) else if (GetByteValue(UNIT_FIELD_BYTES_1, 3) & UNIT_BYTE_1_FLAG_HOVER)
SetHover(true); SetHover(true);
*/ */
// TODO: Shouldn't we check whether or not the creature is in water first? // TODO: Shouldn't we check whether or not the creature is in water first?
@@ -758,16 +758,14 @@ bool Creature::Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry,
return false; 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; //oX = x; oY = y; dX = x; dY = y; m_moveTime = 0; m_startMove = 0;
if (!CreateFromProto(guidlow, Entry, vehId, team, data)) if (!CreateFromProto(guidlow, Entry, vehId, team, data))
return false; return false;
//! Need to be called after CreateFromProto
if (HasUnitMovementFlag(MOVEMENTFLAG_HOVER))
z += GetFloatValue(UNIT_FIELD_HOVERHEIGHT);
Relocate(x, y, z, ang);
if (!IsPositionValid()) 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); 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(); 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(); uint32 displayID = GetNativeDisplayId();
CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelRandomGender(&displayID); CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelRandomGender(&displayID);
if (minfo && !isTotem()) // Cancel load if no model defined or if totem if (minfo && !isTotem()) // Cancel load if no model defined or if totem