DB/Creatures: Port master model system

Fixes incorrect displayid for creatures, due to probability
This commit is contained in:
funjoker committed 2023-09-15 23:52:51 +02:00
1 parent eb5cbdf948
commit df32b341a5
43 files changed
+65170 -262

No files matched your search

File diff suppressed because it is too large. Load diff
@@ -377,10 +377,10 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
{
if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
{
uint32 displayId = ObjectMgr::ChooseDisplayId(ci);
target->ToCreature()->SetDisplayId(displayId);
CreatureModel const* model = ObjectMgr::ChooseDisplayId(ci);
target->ToCreature()->SetDisplayId(model->CreatureDisplayID);
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature entry %u, GuidLow %u set displayid to %u",
target->GetEntry(), target->GetGUID().GetCounter(), displayId);
target->GetEntry(), target->GetGUID().GetCounter(), model->CreatureDisplayID);
}
}
//if no param1, then use value from param2 (modelId)
@@ -1141,7 +1141,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
if (e.action.morphOrMount.creature > 0)
{
if (CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
target->ToUnit()->Mount(ObjectMgr::ChooseDisplayId(cInfo));
target->ToUnit()->Mount(ObjectMgr::ChooseDisplayId(cInfo)->CreatureDisplayID);
}
else
target->ToUnit()->Mount(e.action.morphOrMount.model);
+79 -72
View File
@@ -108,68 +108,74 @@ VendorItem const* VendorItemData::FindItemCostPair(uint32 item_id, uint32 extend
return nullptr;
}
uint32 CreatureTemplate::GetRandomValidModelId() const
CreatureModel const CreatureModel::DefaultInvisibleModel(11686, 0, 1.0f);
CreatureModel const CreatureModel::DefaultVisibleModel(17519, 0, 1.0f);
CreatureModel const* CreatureTemplate::GetModelByIdx(uint32 idx) const
{
uint8 c = 0;
uint32 modelIDs[4];
auto itr = std::find_if(Models.begin(), Models.end(), [&](CreatureModel const& model)
{
return model.Idx == idx;
});
if (itr != Models.end())
return &*itr;
if (Modelid1) modelIDs[c++] = Modelid1;
if (Modelid2) modelIDs[c++] = Modelid2;
if (Modelid3) modelIDs[c++] = Modelid3;
if (Modelid4) modelIDs[c++] = Modelid4;
return ((c>0) ? modelIDs[urand(0, c-1)] : 0);
return nullptr;
}
uint32 CreatureTemplate::GetFirstValidModelId() const
CreatureModel const* CreatureTemplate::GetRandomValidModel() const
{
if (Modelid1) return Modelid1;
if (Modelid2) return Modelid2;
if (Modelid3) return Modelid3;
if (Modelid4) return Modelid4;
return 0;
if (!Models.size())
return nullptr;
// If only one element, ignore the Probability (even if 0)
if (Models.size() == 1)
return &Models[0];
auto selectedItr = Trinity::Containers::SelectRandomWeightedContainerElement(Models, [](CreatureModel const& model)
{
return model.Probability;
});
return &(*selectedItr);
}
uint32 CreatureTemplate::GetFirstInvisibleModel() const
CreatureModel const* CreatureTemplate::GetFirstValidModel() const
{
CreatureModelInfo const* modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid1);
if (modelInfo && modelInfo->is_trigger)
return Modelid1;
for (CreatureModel const& model : Models)
if (model.CreatureDisplayID)
return &model;
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;
return nullptr;
}
uint32 CreatureTemplate::GetFirstVisibleModel() const
CreatureModel const* CreatureTemplate::GetModelWithDisplayId(uint32 displayId) const
{
CreatureModelInfo const* modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid1);
if (modelInfo && !modelInfo->is_trigger)
return Modelid1;
for (CreatureModel const& model : Models)
if (displayId == model.CreatureDisplayID)
return &model;
modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid2);
if (modelInfo && !modelInfo->is_trigger)
return Modelid2;
return nullptr;
}
modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid3);
if (modelInfo && !modelInfo->is_trigger)
return Modelid3;
CreatureModel const* CreatureTemplate::GetFirstInvisibleModel() const
{
for (CreatureModel const& model : Models)
if (CreatureModelInfo const* modelInfo = sObjectMgr->GetCreatureModelInfo(model.CreatureDisplayID))
if (modelInfo && modelInfo->is_trigger)
return &model;
modelInfo = sObjectMgr->GetCreatureModelInfo(Modelid4);
if (modelInfo && !modelInfo->is_trigger)
return Modelid4;
return &CreatureModel::DefaultInvisibleModel;
}
return 17519;
CreatureModel const* CreatureTemplate::GetFirstVisibleModel() const
{
for (CreatureModel const& model : Models)
if (CreatureModelInfo const* modelInfo = sObjectMgr->GetCreatureModelInfo(model.CreatureDisplayID))
if (modelInfo && !modelInfo->is_trigger)
return &model;
return &CreatureModel::DefaultVisibleModel;
}
void CreatureTemplate::InitializeQueryData()
@@ -212,10 +218,14 @@ WorldPacket CreatureTemplate::BuildQueryData(LocaleConstant loc) const
for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i)
queryTemp.Stats.ProxyCreatureID[i] = KillCredit[i];
queryTemp.Stats.CreatureDisplayID[0] = Modelid1;
queryTemp.Stats.CreatureDisplayID[1] = Modelid2;
queryTemp.Stats.CreatureDisplayID[2] = Modelid3;
queryTemp.Stats.CreatureDisplayID[3] = Modelid4;
for (uint8 i = 0; i < MAX_CREATURE_MODELS; ++i)
{
if (CreatureModel const* model = GetModelByIdx(i))
queryTemp.Stats.CreatureDisplayID[i] = model->CreatureDisplayID;
else
queryTemp.Stats.CreatureDisplayID[i] = 0;
}
queryTemp.Stats.HpMulti = ModHealth;
queryTemp.Stats.EnergyMulti = ModMana;
queryTemp.Stats.Leader = RacialLeader;
@@ -499,27 +509,21 @@ bool Creature::InitEntry(uint32 entry, CreatureData const* data /*= nullptr*/)
SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_CLASS, uint8(cinfo->unit_class));
// Cancel load if no model defined
if (!(cinfo->GetFirstValidModelId()))
if (!(cinfo->GetFirstValidModel()))
{
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has no model defined in table `creature_template`, can't load. ", entry);
return false;
}
uint32 displayID = ObjectMgr::ChooseDisplayId(normalInfo, data);
CreatureModelInfo const* minfo = nullptr;
if (!data || !data->displayid)
minfo = sObjectMgr->GetCreatureModelRandomGender(&displayID);
else
minfo = sObjectMgr->GetCreatureModelInfo(displayID);
CreatureModel model = *ObjectMgr::ChooseDisplayId(cinfo, data);
CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelRandomGender(&model, cinfo);
if (!minfo) // Cancel load if no model defined
{
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has invalid model %u defined in table `creature_template`, can't load.", entry, displayID);
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) has invalid model %u defined in table `creature_template`, can't load.", entry, model.CreatureDisplayID);
return false;
}
SetDisplayId(displayID);
SetNativeDisplayId(displayID);
SetDisplayId(model.CreatureDisplayID, true);
// Load creature equipment
if (!data || data->equipmentId == 0)
@@ -1325,9 +1329,9 @@ void Creature::SaveToDB(uint32 mapid, uint8 spawnMask)
CreatureTemplate const* cinfo = GetCreatureTemplate();
if (cinfo)
{
if (displayId == cinfo->Modelid1 || displayId == cinfo->Modelid2 ||
displayId == cinfo->Modelid3 || displayId == cinfo->Modelid4)
displayId = 0;
for (CreatureModel model : cinfo->Models)
if (displayId && displayId == model.CreatureDisplayID)
displayId = 0;
if (npcflag == cinfo->npcflag)
npcflag = 0;
@@ -2057,12 +2061,9 @@ void Creature::Respawn(bool force)
setDeathState(JUST_RESPAWNED);
uint32 displayID = GetNativeDisplayId();
if (sObjectMgr->GetCreatureModelRandomGender(&displayID))
{
SetDisplayId(displayID);
SetNativeDisplayId(displayID);
}
CreatureModel display(GetNativeDisplayId(), 0, 1.0f);
if (sObjectMgr->GetCreatureModelRandomGender(&display, GetCreatureTemplate()))
SetDisplayId(display.CreatureDisplayID, true);
GetMotionMaster()->InitDefault();
//Re-initialize reactstate that could be altered by movementgenerators
@@ -3080,9 +3081,9 @@ void Creature::SetObjectScale(float scale)
}
}
void Creature::SetDisplayId(uint32 modelId)
void Creature::SetDisplayId(uint32 modelId, bool setNative /*= false*/)
{
Unit::SetDisplayId(modelId);
Unit::SetDisplayId(modelId, setNative);
if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(modelId))
{
@@ -3091,6 +3092,12 @@ void Creature::SetDisplayId(uint32 modelId)
}
}
void Creature::SetDisplayFromModel(uint32 modelIdx)
{
if (CreatureModel const* model = GetCreatureTemplate()->GetModelByIdx(modelIdx))
SetDisplayId(model->CreatureDisplayID);
}
void Creature::SetTarget(ObjectGuid guid)
{
if (HasSpellFocus())
+2 -1
View File
@@ -69,7 +69,8 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
float GetNativeObjectScale() const override;
void SetObjectScale(float scale) override;
void SetDisplayId(uint32 modelId) override;
void SetDisplayId(uint32 modelId, bool setNative = false) override;
void SetDisplayFromModel(uint32 modelIdx);
void DisappearAndDie();
@@ -356,16 +356,29 @@ static uint32 const MAX_CREATURE_MODELS = 4;
static uint32 const MAX_CREATURE_QUEST_ITEMS = 6;
static uint32 const MAX_CREATURE_SPELLS = 8;
struct CreatureModel
{
static CreatureModel const DefaultInvisibleModel;
static CreatureModel const DefaultVisibleModel;
CreatureModel() :
CreatureDisplayID(0), Idx(0), Probability(0.0f) { }
CreatureModel(uint32 creatureDisplayID, uint8 idx, float probability) :
CreatureDisplayID(creatureDisplayID), Idx(idx), Probability(probability) { }
uint32 CreatureDisplayID;
uint8 Idx;
float Probability;
};
// from `creature_template` table
struct TC_GAME_API CreatureTemplate
{
uint32 Entry;
uint32 DifficultyEntry[MAX_DIFFICULTY - 1];
uint32 KillCredit[MAX_KILL_CREDIT];
uint32 Modelid1;
uint32 Modelid2;
uint32 Modelid3;
uint32 Modelid4;
std::vector<CreatureModel> Models;
std::string Name;
std::string FemaleName;
std::string Title;
@@ -424,10 +437,12 @@ struct TC_GAME_API CreatureTemplate
CreatureStaticFlagsHolder StaticFlags;
uint32 ScriptID;
WorldPacket QueryData[TOTAL_LOCALES];
uint32 GetRandomValidModelId() const;
uint32 GetFirstValidModelId() const;
uint32 GetFirstInvisibleModel() const;
uint32 GetFirstVisibleModel() const;
CreatureModel const* GetModelByIdx(uint32 idx) const;
CreatureModel const* GetRandomValidModel() const;
CreatureModel const* GetFirstValidModel() const;
CreatureModel const* GetModelWithDisplayId(uint32 displayId) const;
CreatureModel const* GetFirstInvisibleModel() const;
CreatureModel const* GetFirstVisibleModel() const;
// helpers
SkillType GetRequiredLootSkill() const
+3 -4
View File
@@ -189,8 +189,7 @@ bool Pet::LoadPetData(Player* owner, uint32 petEntry, uint32 petnumber, bool cur
m_charmInfo->SetPetNumber(petId, IsPermanentPetFor(owner));
SetDisplayId(playerPetData->DisplayId);
SetNativeDisplayId(playerPetData->DisplayId);
SetDisplayId(playerPetData->DisplayId, true);
uint32 petlevel = playerPetData->Petlevel;
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
SetName(playerPetData->Name);
@@ -1962,9 +1961,9 @@ float Pet::GetNativeObjectScale() const
return Guardian::GetNativeObjectScale();
}
void Pet::SetDisplayId(uint32 modelId)
void Pet::SetDisplayId(uint32 modelId, bool setNative /*= false*/)
{
Guardian::SetDisplayId(modelId);
Guardian::SetDisplayId(modelId, setNative);
if (!isControlled())
return;
+1 -1
View File
@@ -62,7 +62,7 @@ class TC_GAME_API Pet : public Guardian
void RemoveFromWorld() override;
float GetNativeObjectScale() const override;
void SetDisplayId(uint32 modelId) override;
void SetDisplayId(uint32 modelId, bool setNative = false) override;
PetType getPetType() const { return m_petType; }
void setPetType(PetType type) { m_petType = type; }
+2 -4
View File
@@ -21381,12 +21381,10 @@ void Player::InitDisplayIds()
switch (gender)
{
case GENDER_FEMALE:
SetDisplayId(info->displayId_f);
SetNativeDisplayId(info->displayId_f);
SetDisplayId(info->displayId_f, true);
break;
case GENDER_MALE:
SetDisplayId(info->displayId_m);
SetNativeDisplayId(info->displayId_m);
SetDisplayId(info->displayId_m, true);
break;
default:
TC_LOG_ERROR("entities.player", "Player::InitDisplayIds: Player '%s' (%s) has invalid gender %u", GetName().c_str(), GetGUID().ToString().c_str(), gender);
+5 -2
View File
@@ -10354,12 +10354,15 @@ void Unit::RecalculateObjectScale()
SetObjectScale(std::max(scale, scaleMin));
}
void Unit::SetDisplayId(uint32 modelId)
void Unit::SetDisplayId(uint32 modelId, bool setNative /*= false*/)
{
SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId);
// Set Gender by modelId
if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(modelId))
SetByteValue(UNIT_FIELD_BYTES_0, UNIT_BYTES_0_OFFSET_GENDER, minfo->gender);
if (setNative)
SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId);
}
void Unit::RestoreDisplayId()
@@ -13997,7 +14000,7 @@ void Unit::BuildValuesUpdate(uint8 updateType, ByteBuffer* data, Player* target)
if (cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER)
if (target->IsGameMaster())
displayId = cinfo->GetFirstVisibleModel();
displayId = cinfo->GetFirstVisibleModel()->CreatureDisplayID;
}
fieldBuffer << uint32(displayId);
+1 -2
View File
@@ -1563,10 +1563,9 @@ class TC_GAME_API Unit : public WorldObject
virtual float GetNativeObjectScale() const { return 1.0f; }
virtual void RecalculateObjectScale();
uint32 GetDisplayId() const { return GetUInt32Value(UNIT_FIELD_DISPLAYID); }
virtual void SetDisplayId(uint32 modelId);
virtual void SetDisplayId(uint32 modelId, bool setNative = false);
uint32 GetNativeDisplayId() const { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); }
void RestoreDisplayId();
void SetNativeDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId); }
void setTransForm(uint32 spellid) { m_transform = spellid;}
uint32 getTransForm() const { return m_transform;}
+2 -4
View File
@@ -1444,8 +1444,7 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate)
if (itr->second.modelid > 0 && itr->second.modelid_prev != itr->second.modelid &&
sObjectMgr->GetCreatureModelInfo(itr->second.modelid))
{
creature->SetDisplayId(itr->second.modelid);
creature->SetNativeDisplayId(itr->second.modelid);
creature->SetDisplayId(itr->second.modelid, true);
}
}
else
@@ -1454,8 +1453,7 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate)
if (itr->second.modelid_prev > 0 && itr->second.modelid_prev != itr->second.modelid &&
sObjectMgr->GetCreatureModelInfo(itr->second.modelid_prev))
{
creature->SetDisplayId(itr->second.modelid_prev);
creature->SetNativeDisplayId(itr->second.modelid_prev);
creature->SetDisplayId(itr->second.modelid_prev, true);
}
}
}
+100 -96
View File
@@ -454,6 +454,9 @@ void ObjectMgr::LoadCreatureTemplates()
}
while (result->NextRow());
// We load the creature models after loading but before checking
LoadCreatureTemplateModels();
// Checking needs to be done after loading because of the difficulty self referencing
for (CreatureTemplateContainer::const_iterator itr = _creatureTemplateStore.begin(); itr != _creatureTemplateStore.end(); ++itr)
CheckCreatureTemplate(&itr->second);
@@ -475,10 +478,10 @@ void ObjectMgr::LoadCreatureTemplate(Field* fields)
for (uint8 i = 0; i < MAX_KILL_CREDIT; ++i)
creatureTemplate.KillCredit[i] = fields[4 + i].GetUInt32();
creatureTemplate.Modelid1 = fields[6].GetUInt32();
creatureTemplate.Modelid2 = fields[7].GetUInt32();
creatureTemplate.Modelid3 = fields[8].GetUInt32();
creatureTemplate.Modelid4 = fields[9].GetUInt32();
//creatureTemplate.Modelid1 = fields[6].GetUInt32();
//creatureTemplate.Modelid2 = fields[7].GetUInt32();
//creatureTemplate.Modelid3 = fields[8].GetUInt32();
//creatureTemplate.Modelid4 = fields[9].GetUInt32();
creatureTemplate.Name = fields[10].GetString();
creatureTemplate.FemaleName = fields[11].GetString();
creatureTemplate.Title = fields[12].GetString();
@@ -562,6 +565,70 @@ void ObjectMgr::LoadCreatureTemplate(Field* fields)
creatureTemplate.ScriptID = GetScriptId(fields[87].GetCString());
}
void ObjectMgr::LoadCreatureTemplateModels()
{
uint32 oldMSTime = getMSTime();
// 0 1 2 3
QueryResult result = WorldDatabase.Query("SELECT CreatureID, Idx, CreatureDisplayID, Probability FROM creature_template_model ORDER BY Idx ASC");
if (!result)
{
TC_LOG_INFO("server.loading", ">> Loaded 0 creature template model definitions. DB table `creature_template_model` is empty.");
return;
}
uint32 count = 0;
do
{
Field* fields = result->Fetch();
uint32 creatureId = fields[0].GetUInt32();
uint32 idx = fields[1].GetUInt32();
uint32 creatureDisplayId = fields[2].GetUInt32();
float probability = fields[3].GetFloat();
CreatureTemplate const* cInfo = GetCreatureTemplate(creatureId);
if (!cInfo)
{
TC_LOG_ERROR("sql.sql", "Creature template (Entry: %u) does not exist but has a record in `creature_template_model`", creatureId);
continue;
}
if (idx >= MAX_CREATURE_MODELS)
{
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) lists CreatureDisplayID id (%u) at Idx (%u), max supported Idx is 3. Skipped!.", creatureId, creatureDisplayId, idx);
continue;
}
CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(creatureDisplayId);
if (!displayEntry)
{
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) lists non-existing CreatureDisplayID id (%u), this can crash the client.", creatureId, creatureDisplayId);
continue;
}
CreatureModelInfo const* modelInfo = GetCreatureModelInfo(creatureDisplayId);
if (!modelInfo)
TC_LOG_ERROR("sql.sql", "No model data exist for `CreatureDisplayID` = %u listed by creature (Entry: %u).", creatureDisplayId, creatureId);
/// if not set custom creature scale then load scale from CreatureDisplayInfo.dbc
if (cInfo->scale <= 0.0f)
{
if (displayEntry)
const_cast<CreatureTemplate*>(cInfo)->scale = displayEntry->CreatureModelScale;
else
const_cast<CreatureTemplate*>(cInfo)->scale = 1.0f;
}
const_cast<CreatureTemplate*>(cInfo)->Models.emplace_back(creatureDisplayId, idx, probability);
++count;
} while (result->NextRow());
TC_LOG_INFO("server.loading", ">> Loaded %u creature template models in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
}
void ObjectMgr::LoadCreatureTemplateAddons()
{
uint32 oldMSTime = getMSTime();
@@ -950,75 +1017,8 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
ABORT();
}
// used later for scale
CreatureDisplayInfoEntry const* displayScaleEntry = nullptr;
if (cInfo->Modelid1)
{
CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid1);
if (!displayEntry)
{
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) lists non-existing Modelid1 id (%u), this can crash the client.", cInfo->Entry, cInfo->Modelid1);
const_cast<CreatureTemplate*>(cInfo)->Modelid1 = 0;
}
else
displayScaleEntry = displayEntry;
CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid1);
if (!modelInfo)
TC_LOG_ERROR("sql.sql", "No model data exist for `Modelid1` = %u listed by creature (Entry: %u).", cInfo->Modelid1, cInfo->Entry);
}
if (cInfo->Modelid2)
{
CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid2);
if (!displayEntry)
{
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) lists non-existing Modelid2 id (%u), this can crash the client.", cInfo->Entry, cInfo->Modelid2);
const_cast<CreatureTemplate*>(cInfo)->Modelid2 = 0;
}
else if (!displayScaleEntry)
displayScaleEntry = displayEntry;
CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid2);
if (!modelInfo)
TC_LOG_ERROR("sql.sql", "No model data exist for `Modelid2` = %u listed by creature (Entry: %u).", cInfo->Modelid2, cInfo->Entry);
}
if (cInfo->Modelid3)
{
CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid3);
if (!displayEntry)
{
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) lists non-existing Modelid3 id (%u), this can crash the client.", cInfo->Entry, cInfo->Modelid3);
const_cast<CreatureTemplate*>(cInfo)->Modelid3 = 0;
}
else if (!displayScaleEntry)
displayScaleEntry = displayEntry;
CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid3);
if (!modelInfo)
TC_LOG_ERROR("sql.sql", "No model data exist for `Modelid3` = %u listed by creature (Entry: %u).", cInfo->Modelid3, cInfo->Entry);
}
if (cInfo->Modelid4)
{
CreatureDisplayInfoEntry const* displayEntry = sCreatureDisplayInfoStore.LookupEntry(cInfo->Modelid4);
if (!displayEntry)
{
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) lists non-existing Modelid4 id (%u), this can crash the client.", cInfo->Entry, cInfo->Modelid4);
const_cast<CreatureTemplate*>(cInfo)->Modelid4 = 0;
}
else if (!displayScaleEntry)
displayScaleEntry = displayEntry;
CreatureModelInfo const* modelInfo = GetCreatureModelInfo(cInfo->Modelid4);
if (!modelInfo)
TC_LOG_ERROR("sql.sql", "No model data exist for `Modelid4` = %u listed by creature (Entry: %u).", cInfo->Modelid4, cInfo->Entry);
}
if (!displayScaleEntry)
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) does not have any existing display id in Modelid1/Modelid2/Modelid3/Modelid4.", cInfo->Entry);
if (cInfo->Models.empty())
TC_LOG_ERROR("sql.sql", "Creature (Entry: %u) does not have any existing display id in creature_template_model.", cInfo->Entry);
for (uint8 k = 0; k < MAX_KILL_CREDIT; ++k)
{
@@ -1115,15 +1115,6 @@ void ObjectMgr::CheckCreatureTemplate(CreatureTemplate const* cInfo)
const_cast<CreatureTemplate*>(cInfo)->MovementType = IDLE_MOTION_TYPE;
}
/// if not set custom creature scale then load scale from CreatureDisplayInfo.dbc
if (cInfo->scale <= 0.0f)
{
if (displayScaleEntry)
const_cast<CreatureTemplate*>(cInfo)->scale = displayScaleEntry->CreatureModelScale;
else
const_cast<CreatureTemplate*>(cInfo)->scale = 1.0f;
}
if (cInfo->expansion > (MAX_EXPANSIONS - 1))
{
TC_LOG_ERROR("sql.sql", "Table `creature_template` lists creature (Entry: %u) with expansion %u. Ignored and set to 0.", cInfo->Entry, cInfo->expansion);
@@ -1620,14 +1611,16 @@ CreatureModelInfo const* ObjectMgr::GetCreatureModelInfo(uint32 modelId) const
return nullptr;
}
uint32 ObjectMgr::ChooseDisplayId(CreatureTemplate const* cinfo, CreatureData const* data /*= nullptr*/)
CreatureModel const* ObjectMgr::ChooseDisplayId(CreatureTemplate const* cinfo, CreatureData const* data /*= nullptr*/)
{
// Load creature model (display id)
if (data && data->displayid)
return data->displayid;
if (CreatureModel const* model = cinfo->GetModelWithDisplayId(data->displayid))
return model;
if (!(cinfo->flags_extra & CREATURE_FLAG_EXTRA_TRIGGER))
return cinfo->GetRandomValidModelId();
if (CreatureModel const* model = cinfo->GetRandomValidModel())
return model;
// Triggers by default receive the invisible model
return cinfo->GetFirstInvisibleModel();
@@ -1652,9 +1645,9 @@ void ObjectMgr::ChooseCreatureFlags(CreatureTemplate const* cinfo, uint32& npcfl
}
}
CreatureModelInfo const* ObjectMgr::GetCreatureModelRandomGender(uint32* displayID) const
CreatureModelInfo const* ObjectMgr::GetCreatureModelRandomGender(CreatureModel* model, CreatureTemplate const* creatureTemplate) const
{
CreatureModelInfo const* modelInfo = GetCreatureModelInfo(*displayID);
CreatureModelInfo const* modelInfo = GetCreatureModelInfo(model->CreatureDisplayID);
if (!modelInfo)
return nullptr;
@@ -1663,11 +1656,20 @@ CreatureModelInfo const* ObjectMgr::GetCreatureModelRandomGender(uint32* display
{
CreatureModelInfo const* minfo_tmp = GetCreatureModelInfo(modelInfo->modelid_other_gender);
if (!minfo_tmp)
TC_LOG_ERROR("sql.sql", "Model (Entry: %u) has modelid_other_gender %u not found in table `creature_model_info`. ", *displayID, modelInfo->modelid_other_gender);
TC_LOG_ERROR("sql.sql", "Model (Entry: {}) has modelid_other_gender {} not found in table `creature_model_info`. ", model->CreatureDisplayID, modelInfo->modelid_other_gender);
else
{
// Model ID changed
*displayID = modelInfo->modelid_other_gender;
// DisplayID changed
model->CreatureDisplayID = modelInfo->modelid_other_gender;
if (creatureTemplate)
{
auto itr = std::find_if(creatureTemplate->Models.begin(), creatureTemplate->Models.end(), [&](CreatureModel const& templateModel)
{
return templateModel.CreatureDisplayID == modelInfo->modelid_other_gender;
});
if (itr != creatureTemplate->Models.end())
*model = *itr;
}
return minfo_tmp;
}
}
@@ -6260,7 +6262,8 @@ void ObjectMgr::GetTaxiPath(uint32 source, uint32 destination, uint32 &path, uin
uint32 ObjectMgr::GetTaxiMountDisplayId(uint32 id, uint32 team, bool allowed_alt_team /* = false */)
{
uint32 mount_id = 0;
CreatureModel mountModel;
CreatureTemplate const* mount_info = nullptr;
// select mount creature id
TaxiNodesEntry const* node = sTaxiNodesStore.LookupEntry(id);
@@ -6280,22 +6283,23 @@ uint32 ObjectMgr::GetTaxiMountDisplayId(uint32 id, uint32 team, bool allowed_alt
mount_entry = team == ALLIANCE ? node->MountCreatureID[0] : node->MountCreatureID[1];
}
CreatureTemplate const* mount_info = GetCreatureTemplate(mount_entry);
mount_info = GetCreatureTemplate(mount_entry);
if (mount_info)
{
mount_id = mount_info->GetRandomValidModelId();
if (!mount_id)
CreatureModel const* model = mount_info->GetRandomValidModel();
if (!model)
{
TC_LOG_ERROR("sql.sql", "No displayid found for the taxi mount with the entry %u! Can't load it!", mount_entry);
return 0;
}
mountModel = *model;
}
}
// minfo is not actually used but the mount_id was updated
GetCreatureModelRandomGender(&mount_id);
GetCreatureModelRandomGender(&mountModel, mount_info);
return mount_id;
return mountModel.CreatureDisplayID;
}
Quest const* ObjectMgr::GetQuestTemplate(uint32 quest_id) const
+3 -2
View File
@@ -1013,8 +1013,8 @@ class TC_GAME_API ObjectMgr
CreatureTemplate const* GetCreatureTemplate(uint32 entry) const;
CreatureTemplateContainer const* GetCreatureTemplates() const { return &_creatureTemplateStore; }
CreatureModelInfo const* GetCreatureModelInfo(uint32 modelId) const;
CreatureModelInfo const* GetCreatureModelRandomGender(uint32* displayID) const;
static uint32 ChooseDisplayId(CreatureTemplate const* cinfo, CreatureData const* data = nullptr);
CreatureModelInfo const* GetCreatureModelRandomGender(CreatureModel* model, CreatureTemplate const* creatureTemplate) const;
static CreatureModel const* 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);
EquipmentInfo const* GetEquipmentInfo(uint32 entry, int8& id) const;
CreatureAddon const* GetCreatureAddon(ObjectGuid::LowType lowguid) const;
@@ -1187,6 +1187,7 @@ class TC_GAME_API ObjectMgr
void LoadCreatureTemplateAddons();
void LoadCreatureSparringTemplate();
void LoadCreatureTemplate(Field* fields);
void LoadCreatureTemplateModels();
void CheckCreatureTemplate(CreatureTemplate const* cInfo);
void CheckCreatureMovement(char const* table, uint64 id, CreatureMovementData& creatureMovement);
void LoadGameObjectQuestItems();
@@ -2190,7 +2190,7 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode,
uint32 model_id = 0;
// choose a model, based on trigger flag
if (uint32 modelid = ObjectMgr::ChooseDisplayId(ci))
if (uint32 modelid = ObjectMgr::ChooseDisplayId(ci)->CreatureDisplayID)
model_id = modelid;
// Polymorph (sheep)
@@ -2240,10 +2240,10 @@ void AuraEffect::HandleAuraTransform(AuraApplication const* aurApp, uint8 mode,
uint32 cr_id = target->GetAuraEffectsByType(SPELL_AURA_MOUNTED).front()->GetMiscValue();
if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(cr_id))
{
uint32 displayID = ObjectMgr::ChooseDisplayId(ci);
sObjectMgr->GetCreatureModelRandomGender(&displayID);
CreatureModel model = *ObjectMgr::ChooseDisplayId(ci);
sObjectMgr->GetCreatureModelRandomGender(&model, ci);
target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, displayID);
target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, model.CreatureDisplayID);
}
}
}
@@ -2760,11 +2760,12 @@ void AuraEffect::HandleAuraMounted(AuraApplication const* aurApp, uint8 mode, bo
if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creatureEntry))
{
displayId = ObjectMgr::ChooseDisplayId(creatureInfo);
sObjectMgr->GetCreatureModelRandomGender(&displayId);
vehicleId = creatureInfo->VehicleId;
CreatureModel model = *ObjectMgr::ChooseDisplayId(creatureInfo);
sObjectMgr->GetCreatureModelRandomGender(&model, creatureInfo);
displayId = model.CreatureDisplayID;
//some spell has one aura of mount and one of vehicle
for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
if (GetSpellInfo()->Effects[i].Effect == SPELL_EFFECT_SUMMON
@@ -4851,10 +4852,9 @@ void AuraEffect::HandleAuraDummy(AuraApplication const* aurApp, uint8 mode, bool
if (CreatureTemplate const* creatureInfo = sObjectMgr->GetCreatureTemplate(creatureEntry))
{
uint32 displayID = ObjectMgr::ChooseDisplayId(creatureInfo);
sObjectMgr->GetCreatureModelRandomGender(&displayID);
target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, displayID);
CreatureModel model = *ObjectMgr::ChooseDisplayId(creatureInfo);
sObjectMgr->GetCreatureModelRandomGender(&model, creatureInfo);
target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, model.CreatureDisplayID);
}
}
break;
+1 -2
View File
@@ -995,8 +995,7 @@ public:
return false;
}
creature->SetDisplayId(displayId);
creature->SetNativeDisplayId(displayId);
creature->SetDisplayId(displayId, true);
creature->SaveToDB();
@@ -208,7 +208,7 @@ struct npc_romogg_chains_of_woe : public NullCreatureAI
void IsSummonedBy(Unit* /*summoner*/) override
{
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
DoCastSelf(SPELL_CHAINS_OF_WOE_TELEPORT);
DoCastSelf(SPELL_CHAINS_OF_WOE_CHANNELED);
}
@@ -315,7 +315,7 @@ struct boss_magmaw : public BossAI
{
case NPC_PILLAR_OF_FLAME:
summon->CastSpell(summon, SPELL_PILLAR_OF_FLAME_DUMMY);
summon->SetDisplayId(summon->GetCreatureTemplate()->Modelid1);
summon->SetDisplayFromModel(0);
summon->DespawnOrUnsummon(7s);
Talk(SAY_ANNOUNCE_LAVA_PARASITES);
summons.Summon(summon);
@@ -533,7 +533,7 @@ private:
if (pincer1)
{
pincer1->EnterVehicle(me, SEAT_MAGMAWS_PINCER_1);
pincer1->SetDisplayId(pincer1->GetCreatureTemplate()->Modelid3);
pincer1->SetDisplayFromModel(2);
_bodyPartGUIDs[BODY_PART_PINCER_1] = pincer1->GetGUID();
}
@@ -541,7 +541,7 @@ private:
if (pincer2)
{
pincer2->EnterVehicle(me, SEAT_MAGMAWS_PINCER_2);
pincer2->SetDisplayId(pincer2->GetCreatureTemplate()->Modelid3);
pincer2->SetDisplayFromModel(2);
_bodyPartGUIDs[BODY_PART_PINCER_2] = pincer2->GetGUID();
}
@@ -198,7 +198,7 @@ class npc_pure_energy : public CreatureScript
{
npc_pure_energyAI(Creature* creature) : ScriptedAI(creature)
{
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
}
void JustDied(Unit* killer) override
@@ -382,7 +382,7 @@ struct npc_eye_of_acherus : public ScriptedAI
{
npc_eye_of_acherus(Creature* creature) : ScriptedAI(creature)
{
creature->SetDisplayId(creature->GetCreatureTemplate()->Modelid1);
creature->SetDisplayFromModel(0);
creature->SetReactState(REACT_PASSIVE);
}
@@ -157,7 +157,7 @@ public:
switch (creature->GetEntry())
{
case NPC_FORSAKEN_BLIGHTSPREADER:
creature->SetDisplayId(creature->GetCreatureTemplate()->Modelid1);
creature->SetDisplayFromModel(0);
break;
case NPC_HIGH_WARLORD_CROMUSH:
if (creature->ToTempSummon())
@@ -402,7 +402,7 @@ public:
void Initialize()
{
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
me->SetReactState(REACT_PASSIVE);
DoCast(me, SPELL_DARKFIEND_SKIN, true);
@@ -740,7 +740,7 @@ struct npc_brazie_fertilitize_o_tron_2000 : public ScriptedAI
void IsSummonedBy(Unit* summoner) override
{
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
if (Creature* vehicle = summoner->GetVehicleCreatureBase())
if (vehicle->IsAIEnabled())
@@ -828,7 +828,7 @@ struct npc_brazie_spot : public ScriptedAI
me->SetFullHealth();
me->UpdateEntry(NPC_EMPTY_SPOT);
_currentEntry = NPC_EMPTY_SPOT;
me->SetDisplayId(me->GetCreatureTemplate()->Modelid1);
me->SetDisplayFromModel(0);
me->AttackStop();
me->SetFacingTo(me->GetHomePosition().GetOrientation());
_events.Reset();
@@ -840,7 +840,7 @@ struct npc_brazie_spot : public ScriptedAI
me->m_SightDistance = 150.0f;
me->m_CombatDistance = 150.0f;
me->SetDisplayId(me->GetCreatureTemplate()->Modelid1);
me->SetDisplayFromModel(0);
if (Creature* vehicle = summoner->GetVehicleCreatureBase())
if (vehicle->IsAIEnabled())
@@ -899,7 +899,7 @@ struct npc_brazie_spot : public ScriptedAI
}
if (spell->Id != SPELL_PLAGUE_GAS)
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
}
void UpdateAI(uint32 diff) override
@@ -969,7 +969,7 @@ struct npc_brazie_zombie : public ScriptedAI
DoCastSelf(SPELL_ZOMBIE_GROWL);
else if (me->GetEntry() == NPC_GHOUL)
{
me->SetDisplayId(me->GetCreatureTemplate()->Modelid4);
me->SetDisplayFromModel(3);
DoCastSelf(SPELL_GHOUL_GROWL, true);
DoCastSelf(SPELL_BUCKET_HEAD, true);
}
@@ -1125,15 +1125,15 @@ struct npc_brazie_vehicle_notifier : public ScriptedAI
{
case NPC_SOLAR_POWER:
case NPC_FREEZYA_SEEDS:
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
me->SetFlag(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_SPELLCLICK);
break;
case NPC_PLACE_IT_HERE:
me->Relocate(EmptySpotPositions[0]);
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
break;
default:
me->SetDisplayId(me->GetCreatureTemplate()->Modelid1);
me->SetDisplayFromModel(0);
break;
}
@@ -324,7 +324,6 @@ public:
{
_events.Reset();
_events.ScheduleEvent(EVENT_DETERMINE_EVENT, Seconds(2));
me->SetDisplayId(me->GetCreatureTemplate()->GetRandomValidModelId());
}
void UpdateAI(uint32 diff) override
@@ -346,7 +346,7 @@ class npc_shard_of_torment : public CreatureScript
me->SetReactState(REACT_PASSIVE);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_REMOVE_CLIENT_CONTROL | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_NON_ATTACKABLE);
me->SetFlag(UNIT_FIELD_FLAGS_2, UNIT_FLAG2_DISABLE_TURN);
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
_instance = creature->GetInstanceScript();
}
@@ -225,7 +225,7 @@ struct boss_lord_rhyolith : public BossAI
{
if (Creature* foot = DoSummon(entry, me->GetPosition(), 0, TEMPSUMMON_MANUAL_DESPAWN))
{
foot->SetDisplayId(foot->GetCreatureTemplate()->Modelid2);
foot->SetDisplayFromModel(1);
foot->CastSpell(me, SPELL_RIDE_VEHICLE, CastSpellExtraArgs().AddSpellBP0(seatId));
foot->CastSpell(foot, SPELL_START_FIGHT);
foot->CastSpell(foot, SPELL_FOOT_DAMAGE_TRACKER);
@@ -323,7 +323,7 @@ struct boss_lord_rhyolith : public BossAI
break;
case NPC_VOLCANO:
summon->CastSpell(nullptr, SPELL_VOLCANO_BASE);
summon->SetDisplayId(summon->GetCreatureTemplate()->Modelid2);
summon->SetDisplayFromModel(1);
summons.Summon(summon);
break;
case NPC_PILLAR:
@@ -906,7 +906,7 @@ struct npc_rhyolith_volcano : public NullCreatureAI
case ACTION_ACTIVATE_VOLCANO:
me->UpdateEntry(NPC_VOLCANO_HEATED, nullptr, false);
if (CreatureTemplate const* transformTemplate = sObjectMgr->GetCreatureTemplate(NPC_VOLCANO_HEATED))
me->SetDisplayId(transformTemplate->Modelid2);
me->SetDisplayFromModel(1);
_events.ScheduleEvent(EVENT_ERUPTION, 5s);
break;
case ACTION_SCHEDULE_MAGMA_FLOW:
@@ -921,7 +921,7 @@ struct npc_rhyolith_volcano : public NullCreatureAI
me->UpdateEntry(NPC_VOLCANO_CRATER, nullptr, false);
if (CreatureTemplate const* transformTemplate = sObjectMgr->GetCreatureTemplate(NPC_VOLCANO_CRATER))
me->SetDisplayId(transformTemplate->Modelid2);
me->SetDisplayFromModel(1);
break;
default:
break;
@@ -701,7 +701,7 @@ struct npc_hoo_whirling_winds : public ScriptedAI
void InitializeAI() override
{
me->SetReactState(REACT_AGGRESSIVE);
me->SetDisplayId(me->GetCreatureTemplate()->Modelid1);
me->SetDisplayFromModel(0);
}
void AttackStart(Unit* who) override
@@ -256,7 +256,7 @@ struct npc_husam_tolvir_land_mine : public NullCreatureAI
{
npc_husam_tolvir_land_mine(Creature* creature) : NullCreatureAI(creature)
{
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
}
void JustAppeared() override
@@ -194,7 +194,7 @@ struct boss_siamat : public BossAI
break;
case NPC_CLOUD_BURST:
summons.Summon(summon);
summon->SetDisplayId(summon->GetCreatureTemplate()->Modelid2);
summon->SetDisplayFromModel(1);
break;
case NPC_MINION_OF_SIAMAT_STORM:
summons.Summon(summon);
@@ -129,7 +129,7 @@ class instance_vortex_pinnacle : public InstanceMapScript
switch (creature->GetEntry())
{
case NPC_HOWLING_GALE:
creature->SetDisplayId(creature->GetCreatureTemplate()->Modelid2);
creature->SetDisplayFromModel(1);
break;
case NPC_AIR_CURRENT:
_airCurrentGUIDs.push_back(creature->GetGUID());
@@ -163,7 +163,7 @@ class instance_vortex_pinnacle : public InstanceMapScript
}
break;
case NPC_GOLDEN_ORB:
creature->SetDisplayId(creature->GetCreatureTemplate()->Modelid2);
creature->SetDisplayFromModel(1);
break;
default:
break;
@@ -250,7 +250,7 @@ public:
void Reset() override
{
_events.Reset();
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
}
void JustEngagedWith(Unit* /*who*/) override
@@ -566,7 +566,7 @@ private:
if (Creature* warden = DoSummon(NPC_GROVE_WARDEN, GroveWardenSummonPositions[spawnIndex], 20000))
{
warden->DespawnOrUnsummon(3min);
warden->SetDisplayId(warden->GetCreatureTemplate()->Modelid1);
warden->SetDisplayFromModel(0);
Position waypointPos = GroveWardenWaypointPosition1;
Position homePos = me->GetHomePosition();
if (me->GetExactDist2d(GroveWardenWaypointPosition1) < me->GetExactDist2d(GroveWardenWaypointPosition2))
@@ -177,7 +177,7 @@ public:
events.Reset();
events.ScheduleEvent(EVENT_AURA, 1 * IN_MILLISECONDS);
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
DoCast(SPELL_PUTRID_MUSHROOM);
if (me->GetEntry() == NPC_POISONOUS_MUSHROOM)
@@ -254,10 +254,10 @@ class boss_anubarak_trial : public CreatureScript
_burrowGUID.push_back(summoned->GetGUID());
summoned->SetReactState(REACT_PASSIVE);
summoned->CastSpell(summoned, SPELL_CHURNING_GROUND, false);
summoned->SetDisplayId(summoned->GetCreatureTemplate()->Modelid2);
summoned->SetDisplayFromModel(1);
break;
case NPC_SPIKE:
summoned->SetDisplayId(summoned->GetCreatureTemplate()->Modelid1);
summoned->SetDisplayFromModel(0);
if (Unit* target = SelectTarget(SELECT_TARGET_RANDOM, 0, 0.0f, true))
{
summoned->EngageWithTarget(target);
@@ -621,7 +621,7 @@ class npc_frost_sphere : public CreatureScript
{
me->SetReactState(REACT_PASSIVE);
DoCast(SPELL_FROST_SPHERE);
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
me->GetMotionMaster()->MoveRandom(20.0f);
}
@@ -489,7 +489,7 @@ class npc_firebomb : public CreatureScript
DoCast(me, SPELL_FIRE_BOMB_DOT, true);
SetCombatMovement(false);
me->SetReactState(REACT_PASSIVE);
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
}
void UpdateAI(uint32 /*diff*/) override
@@ -314,7 +314,7 @@ class boss_lich_king_toc : public CreatureScript
if (Creature* summoned = me->SummonCreature(NPC_TRIGGER, ToCCommonLoc[2].GetPositionX(), ToCCommonLoc[2].GetPositionY(), ToCCommonLoc[2].GetPositionZ(), 5, TEMPSUMMON_TIMED_DESPAWN, 1*MINUTE*IN_MILLISECONDS))
{
summoned->CastSpell(summoned, 51807, false);
summoned->SetDisplayId(summoned->GetCreatureTemplate()->Modelid2);
summoned->SetDisplayFromModel(1);
}
_instance->SetBossState(BOSS_LICH_KING, IN_PROGRESS);
@@ -510,7 +510,7 @@ class npc_fizzlebang_toc : public CreatureScript
{
_triggerGUID = pTrigger->GetGUID();
pTrigger->SetObjectScale(2.0f);
pTrigger->SetDisplayId(pTrigger->ToCreature()->GetCreatureTemplate()->Modelid1);
pTrigger->ToCreature()->SetDisplayFromModel(0);
pTrigger->CastSpell(pTrigger, SPELL_WILFRED_PORTAL, false);
}
_instance->SetData(TYPE_EVENT, 1132);
@@ -2585,7 +2585,7 @@ class npc_quel_delar_sword : public CreatureScript
npc_quel_delar_swordAI(Creature* creature) : ScriptedAI(creature)
{
_instance = me->GetInstanceScript();
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
_intro = true;
}
@@ -270,7 +270,7 @@ class npc_pit_of_saron_icicle : public CreatureScript
{
npc_pit_of_saron_icicleAI(Creature* creature) : PassiveAI(creature)
{
me->SetDisplayId(me->GetCreatureTemplate()->Modelid1);
me->SetDisplayFromModel(0);
}
void IsSummonedBy(Unit* summoner) override
@@ -223,7 +223,7 @@ class npc_chaotic_rift : public CreatureScript
void Reset() override
{
Initialize();
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
DoCast(me, SPELL_ARCANEFORM, false);
}
@@ -614,7 +614,7 @@ class boss_flame_leviathan_seat : public CreatureScript
boss_flame_leviathan_seatAI(Creature* creature) : ScriptedAI(creature)
{
me->SetReactState(REACT_PASSIVE);
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
instance = creature->GetInstanceScript();
}
@@ -186,7 +186,7 @@ class npc_flash_freeze : public CreatureScript
{
Initialize();
instance = me->GetInstanceScript();
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED | UNIT_FLAG_PACIFIED);
me->SetControlled(true, UNIT_STATE_ROOT);
}
@@ -262,7 +262,7 @@ class npc_ice_block : public CreatureScript
npc_ice_blockAI(Creature* creature) : ScriptedAI(creature)
{
instance = me->GetInstanceScript();
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_STUNNED | UNIT_FLAG_PACIFIED);
me->SetControlled(true, UNIT_STATE_ROOT);
}
@@ -554,7 +554,7 @@ class npc_icicle : public CreatureScript
npc_icicleAI(Creature* creature) : ScriptedAI(creature)
{
Initialize();
me->SetDisplayId(me->GetCreatureTemplate()->Modelid1);
me->SetDisplayFromModel(0);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_PACIFIED | UNIT_FLAG_NOT_SELECTABLE);
me->SetControlled(true, UNIT_STATE_ROOT);
me->SetReactState(REACT_PASSIVE);
@@ -609,7 +609,7 @@ class npc_snowpacked_icicle : public CreatureScript
npc_snowpacked_icicleAI(Creature* creature) : ScriptedAI(creature)
{
Initialize();
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
me->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_NON_ATTACKABLE | UNIT_FLAG_NOT_SELECTABLE | UNIT_FLAG_PACIFIED);
me->SetControlled(true, UNIT_STATE_ROOT);
me->SetReactState(REACT_PASSIVE);
@@ -951,7 +951,7 @@ class npc_toasty_fire : public CreatureScript
{
npc_toasty_fireAI(Creature* creature) : ScriptedAI(creature)
{
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
}
void Reset() override
@@ -197,7 +197,7 @@ class boss_razorscale_controller : public CreatureScript
boss_razorscale_controllerAI(Creature* creature) : ScriptedAI(creature), summons(me)
{
instance = creature->GetInstanceScript();
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
}
InstanceScript* instance;
+1 -1
View File
@@ -309,7 +309,7 @@ struct npc_pet_dk_rune_weapon : public AggressorAI
if (!summoner)
return;
me->SetDisplayId(me->GetCreatureTemplate()->Modelid2);
me->SetDisplayFromModel(1);
for (uint32 spellId : { SPELL_COPY_WEAPON_1, SPELL_COPY_WEAPON_2 })
DoCast(summoner, spellId, true);
+2 -2
View File
@@ -2894,8 +2894,8 @@ public:
init.SetFacing(o);
who->GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_VEHICLE_BOARD, MOTION_SLOT_CONTROLLED);
who->m_Events.AddEvent(new CastFoodSpell(who, _chairSpells.at(who->GetEntry())), who->m_Events.CalculateTime(1000));
if (who->GetTypeId() == TYPEID_UNIT)
who->SetDisplayId(who->ToCreature()->GetCreatureTemplate()->Modelid1);
if (Creature* creature = who->ToCreature())
creature->SetDisplayFromModel(0);
}
};