fix (Core/Creature): Random Gender on respawn if Gender exsist for Entry (#10108)
* Fix (Core\Creature): Random Gender on respawn if Gender exsrespawn If creature has genders it will consider gender changing on respawn. GetCreatureModelInfo to const * Update Creature.cpp
This commit is contained in:
@@ -411,8 +411,7 @@ bool Creature::InitEntry(uint32 Entry, const CreatureData* data)
|
|||||||
}
|
}
|
||||||
|
|
||||||
uint32 displayID = ObjectMgr::ChooseDisplayId(GetCreatureTemplate(), data);
|
uint32 displayID = ObjectMgr::ChooseDisplayId(GetCreatureTemplate(), data);
|
||||||
CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelRandomGender(&displayID);
|
if (!sObjectMgr->GetCreatureModelRandomGender(&displayID)) // Cancel load if no model defined
|
||||||
if (!minfo) // Cancel load if no model defined
|
|
||||||
{
|
{
|
||||||
LOG_ERROR("sql.sql", "Creature (Entry: %u) has no model defined in table `creature_template`, can't load. ", Entry);
|
LOG_ERROR("sql.sql", "Creature (Entry: %u) has no model defined in table `creature_template`, can't load. ", Entry);
|
||||||
return false;
|
return false;
|
||||||
@@ -420,7 +419,6 @@ bool Creature::InitEntry(uint32 Entry, const CreatureData* data)
|
|||||||
|
|
||||||
SetDisplayId(displayID);
|
SetDisplayId(displayID);
|
||||||
SetNativeDisplayId(displayID);
|
SetNativeDisplayId(displayID);
|
||||||
SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender);
|
|
||||||
|
|
||||||
// Load creature equipment
|
// Load creature equipment
|
||||||
if (!data || data->equipmentId == 0) // use default from the template
|
if (!data || data->equipmentId == 0) // use default from the template
|
||||||
@@ -1062,12 +1060,10 @@ bool Creature::Create(ObjectGuid::LowType guidlow, Map* map, uint32 phaseMask, u
|
|||||||
LoadCreaturesAddon();
|
LoadCreaturesAddon();
|
||||||
|
|
||||||
uint32 displayID = GetNativeDisplayId();
|
uint32 displayID = GetNativeDisplayId();
|
||||||
CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelRandomGender(&displayID);
|
if (sObjectMgr->GetCreatureModelRandomGender(&displayID) && !IsTotem()) // Cancel load if no model defined or if totem
|
||||||
if (minfo && !IsTotem()) // Cancel load if no model defined or if totem
|
|
||||||
{
|
{
|
||||||
SetDisplayId(displayID);
|
SetDisplayId(displayID);
|
||||||
SetNativeDisplayId(displayID);
|
SetNativeDisplayId(displayID);
|
||||||
SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//! Need to be called after LoadCreaturesAddon - MOVEMENTFLAG_HOVER is set there
|
//! Need to be called after LoadCreaturesAddon - MOVEMENTFLAG_HOVER is set there
|
||||||
@@ -1918,14 +1914,18 @@ void Creature::Respawn(bool force)
|
|||||||
SelectLevel();
|
SelectLevel();
|
||||||
|
|
||||||
setDeathState(JUST_RESPAWNED);
|
setDeathState(JUST_RESPAWNED);
|
||||||
|
// MDic - Acidmanifesto
|
||||||
|
// If creature has genders it will consider gender changing on respawn.
|
||||||
|
if (sObjectMgr->GetCreatureTemplate(m_originalEntry))
|
||||||
|
{
|
||||||
|
InitEntry(m_originalEntry);
|
||||||
|
}
|
||||||
|
|
||||||
uint32 displayID = GetNativeDisplayId();
|
uint32 displayID = GetNativeDisplayId();
|
||||||
CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelRandomGender(&displayID);
|
if (sObjectMgr->GetCreatureModelRandomGender(&displayID)) // Cancel load if no model defined
|
||||||
if (minfo) // Cancel load if no model defined
|
|
||||||
{
|
{
|
||||||
SetDisplayId(displayID);
|
SetDisplayId(displayID);
|
||||||
SetNativeDisplayId(displayID);
|
SetNativeDisplayId(displayID);
|
||||||
SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GetMotionMaster()->InitDefault();
|
GetMotionMaster()->InitDefault();
|
||||||
|
|||||||
@@ -1545,7 +1545,7 @@ void ObjectMgr::LoadCreatureMovementOverrides()
|
|||||||
LOG_INFO("server.loading", ">> Loaded " SZFMTD " movement overrides in %u ms", _creatureMovementOverrides.size(), GetMSTimeDiffToNow(oldMSTime));
|
LOG_INFO("server.loading", ">> Loaded " SZFMTD " movement overrides in %u ms", _creatureMovementOverrides.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
CreatureModelInfo const* ObjectMgr::GetCreatureModelInfo(uint32 modelId)
|
CreatureModelInfo const* ObjectMgr::GetCreatureModelInfo(uint32 modelId) const
|
||||||
{
|
{
|
||||||
CreatureModelContainer::const_iterator itr = _creatureModelStore.find(modelId);
|
CreatureModelContainer::const_iterator itr = _creatureModelStore.find(modelId);
|
||||||
if (itr != _creatureModelStore.end())
|
if (itr != _creatureModelStore.end())
|
||||||
|
|||||||
@@ -740,7 +740,7 @@ public:
|
|||||||
|
|
||||||
CreatureTemplate const* GetCreatureTemplate(uint32 entry);
|
CreatureTemplate const* GetCreatureTemplate(uint32 entry);
|
||||||
[[nodiscard]] CreatureTemplateContainer const* GetCreatureTemplates() const { return &_creatureTemplateStore; }
|
[[nodiscard]] CreatureTemplateContainer const* GetCreatureTemplates() const { return &_creatureTemplateStore; }
|
||||||
CreatureModelInfo const* GetCreatureModelInfo(uint32 modelId);
|
CreatureModelInfo const* GetCreatureModelInfo(uint32 modelId) const;
|
||||||
CreatureModelInfo const* GetCreatureModelRandomGender(uint32* displayID);
|
CreatureModelInfo const* GetCreatureModelRandomGender(uint32* displayID);
|
||||||
static uint32 ChooseDisplayId(CreatureTemplate const* cinfo, CreatureData const* data = nullptr);
|
static uint32 ChooseDisplayId(CreatureTemplate const* cinfo, CreatureData const* data = nullptr);
|
||||||
static void ChooseCreatureFlags(CreatureTemplate const* cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, CreatureData const* data = nullptr);
|
static void ChooseCreatureFlags(CreatureTemplate const* cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, CreatureData const* data = nullptr);
|
||||||
|
|||||||
Reference in New Issue
Block a user