Core/Creatures: Implemented automatic detection of trigger models, their order in creature_template no longer matters
(cherry picked from commit c488fb219ab080031488593a0b86ac785a7d2cae)
This commit is contained in:
1 parent
0170b79ae9
commit
f72795240a
6 files changed
+72
-21
No files matched your search
@@ -809,7 +809,7 @@ struct CreatureModelDataEntry
|
||||
{
|
||||
uint32 Id;
|
||||
uint32 Flags;
|
||||
//char* ModelPath[16]
|
||||
char* ModelPath;
|
||||
//uint32 Unk1;
|
||||
float Scale; // Used in calculation of unit collision data
|
||||
//int32 Unk2
|
||||
|
||||
@@ -42,7 +42,7 @@ char const CinematicSequencesEntryfmt[] = "nxxxxxxxxx";
|
||||
char const CreatureDisplayInfofmt[] = "nixifxxxxxxxxxxx";
|
||||
char const CreatureDisplayInfoExtrafmt[] = "diixxxxxxxxxxxxxxxxxx";
|
||||
char const CreatureFamilyfmt[] = "nfifiiiiixssssssssssssssssxx";
|
||||
char const CreatureModelDatafmt[] = "nixxfxxxxxxxxxxffxxxxxxxxxxx";
|
||||
char const CreatureModelDatafmt[] = "nisxfxxxxxxxxxxffxxxxxxxxxxx";
|
||||
char const CreatureSpellDatafmt[] = "niiiixxxx";
|
||||
char const CreatureTypefmt[] = "nxxxxxxxxxxxxxxxxxx";
|
||||
char const CurrencyTypesfmt[] = "xnxi";
|
||||
|
||||
@@ -103,6 +103,48 @@ uint32 CreatureTemplate::GetFirstValidModelId() const
|
||||
return 0;
|
||||
}
|
||||
|
||||
uint32 CreatureTemplate::GetFirstInvisibleModel() const
|
||||
{
|
||||
CreatureModelInfo const* modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid1);
|
||||
if (modelInfo && modelInfo->is_trigger)
|
||||
return Modelid1;
|
||||
|
||||
modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid2);
|
||||
if (modelInfo && modelInfo->is_trigger)
|
||||
return Modelid2;
|
||||
|
||||
modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid3);
|
||||
if (modelInfo && modelInfo->is_trigger)
|
||||
return Modelid3;
|
||||
|
||||
modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid4);
|
||||
if (modelInfo && modelInfo->is_trigger)
|
||||
return Modelid4;
|
||||
|
||||
return 11686;
|
||||
}
|
||||
|
||||
uint32 CreatureTemplate::GetFirstVisibleModel() const
|
||||
{
|
||||
CreatureModelInfo const* modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid1);
|
||||
if (modelInfo && !modelInfo->is_trigger)
|
||||
return Modelid1;
|
||||
|
||||
modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid2);
|
||||
if (modelInfo && !modelInfo->is_trigger)
|
||||
return Modelid2;
|
||||
|
||||
modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid3);
|
||||
if (modelInfo && !modelInfo->is_trigger)
|
||||
return Modelid3;
|
||||
|
||||
modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid4);
|
||||
if (modelInfo && !modelInfo->is_trigger)
|
||||
return Modelid4;
|
||||
|
||||
return 17519;
|
||||
}
|
||||
|
||||
bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||
{
|
||||
if (Unit* victim = ObjectAccessor::GetUnit(m_owner, m_victim))
|
||||
|
||||
@@ -137,6 +137,8 @@ struct CreatureTemplate
|
||||
uint32 ScriptID;
|
||||
uint32 GetRandomValidModelId() const;
|
||||
uint32 GetFirstValidModelId() const;
|
||||
uint32 GetFirstInvisibleModel() const;
|
||||
uint32 GetFirstVisibleModel() const;
|
||||
|
||||
// helpers
|
||||
SkillType GetRequiredLootSkill() const
|
||||
@@ -278,6 +280,7 @@ struct CreatureModelInfo
|
||||
float combat_reach;
|
||||
uint8 gender;
|
||||
uint32 modelid_other_gender;
|
||||
bool is_trigger;
|
||||
};
|
||||
|
||||
// Benchmarked: Faster than std::map (insert/find)
|
||||
|
||||
@@ -17791,22 +17791,8 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target)
|
||||
}
|
||||
|
||||
if (cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER)
|
||||
{
|
||||
if (target->IsGameMaster())
|
||||
{
|
||||
if (cinfo->Modelid1)
|
||||
displayId = cinfo->Modelid1; // Modelid1 is a visible model for gms
|
||||
else
|
||||
displayId = 17519; // world visible trigger's model
|
||||
}
|
||||
else
|
||||
{
|
||||
if (cinfo->Modelid2)
|
||||
displayId = cinfo->Modelid2; // Modelid2 is an invisible model for players
|
||||
else
|
||||
displayId = 11686; // world invisible trigger's model
|
||||
}
|
||||
}
|
||||
displayId = cinfo->GetFirstVisibleModel();
|
||||
}
|
||||
|
||||
fieldBuffer << uint32(displayId);
|
||||
|
||||
@@ -1236,7 +1236,11 @@ uint32 ObjectMgr::ChooseDisplayId(CreatureTemplate const* cinfo, CreatureData co
|
||||
if (data && data->displayid)
|
||||
return data->displayid;
|
||||
|
||||
return cinfo->GetRandomValidModelId();
|
||||
if (!(cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER))
|
||||
return cinfo->GetRandomValidModelId();
|
||||
|
||||
// Triggers by default receive the invisible model
|
||||
return cinfo->GetFirstInvisibleModel();
|
||||
}
|
||||
|
||||
void ObjectMgr::ChooseCreatureFlags(const CreatureTemplate* cinfo, uint32& npcflag, uint32& unit_flags, uint32& dynamicflags, const CreatureData* data /*= NULL*/)
|
||||
@@ -1301,6 +1305,12 @@ void ObjectMgr::LoadCreatureModelInfo()
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 modelId = fields[0].GetUInt32();
|
||||
CreatureDisplayInfoEntry const* creatureDisplay = sCreatureDisplayInfoStore.LookupEntry(modelId);
|
||||
if (!creatureDisplay)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has model for nonexistent display id (%u).", modelId);
|
||||
continue;
|
||||
}
|
||||
|
||||
CreatureModelInfo& modelInfo = _creatureModelStore[modelId];
|
||||
|
||||
@@ -1308,12 +1318,10 @@ void ObjectMgr::LoadCreatureModelInfo()
|
||||
modelInfo.combat_reach = fields[2].GetFloat();
|
||||
modelInfo.gender = fields[3].GetUInt8();
|
||||
modelInfo.modelid_other_gender = fields[4].GetUInt32();
|
||||
modelInfo.is_trigger = false;
|
||||
|
||||
// Checks
|
||||
|
||||
if (!sCreatureDisplayInfoStore.LookupEntry(modelId))
|
||||
TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has model for nonexistent display id (%u).", modelId);
|
||||
|
||||
if (modelInfo.gender > GENDER_NONE)
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `creature_model_info` has wrong gender (%u) for display id (%u).", uint32(modelInfo.gender), modelId);
|
||||
@@ -1329,6 +1337,18 @@ void ObjectMgr::LoadCreatureModelInfo()
|
||||
if (modelInfo.combat_reach < 0.1f)
|
||||
modelInfo.combat_reach = DEFAULT_COMBAT_REACH;
|
||||
|
||||
if (CreatureModelDataEntry const* modelData = sCreatureModelDataStore.LookupEntry(creatureDisplay->ModelId))
|
||||
{
|
||||
for (uint32 i = 0; i < 5; ++i)
|
||||
{
|
||||
if (strstr(modelData->ModelPath, "InvisibleStalker"))
|
||||
{
|
||||
modelInfo.is_trigger = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
++count;
|
||||
}
|
||||
while (result->NextRow());
|
||||
|
||||
Reference in new issue
Block a user