Core/Creatures: Compute CombatReach and BoundingRadius using DisplayScale (#28863)
This commit is contained in:
@@ -414,7 +414,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
if (CreatureTemplate const* ci = sObjectMgr->GetCreatureTemplate(e.action.morphOrMount.creature))
|
||||
{
|
||||
CreatureModel const* model = ObjectMgr::ChooseDisplayId(ci);
|
||||
target->ToCreature()->SetDisplayId(model->CreatureDisplayID, model->DisplayScale);
|
||||
target->ToCreature()->SetDisplayId(model->CreatureDisplayID);
|
||||
TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_MORPH_TO_ENTRY_OR_MODEL: Creature {} set displayid to {}",
|
||||
target->GetGUID().ToString(), model->CreatureDisplayID);
|
||||
}
|
||||
|
||||
@@ -536,8 +536,7 @@ bool Creature::InitEntry(uint32 entry, CreatureData const* data /*= nullptr*/)
|
||||
return false;
|
||||
}
|
||||
|
||||
SetDisplayId(model.CreatureDisplayID, model.DisplayScale);
|
||||
SetNativeDisplayId(model.CreatureDisplayID, model.DisplayScale);
|
||||
SetDisplayId(model.CreatureDisplayID, true);
|
||||
|
||||
// Load creature equipment
|
||||
if (!data)
|
||||
@@ -2247,10 +2246,7 @@ void Creature::Respawn(bool force)
|
||||
|
||||
CreatureModel display(GetNativeDisplayId(), GetNativeDisplayScale(), 1.0f);
|
||||
if (sObjectMgr->GetCreatureModelRandomGender(&display, GetCreatureTemplate()))
|
||||
{
|
||||
SetDisplayId(display.CreatureDisplayID, display.DisplayScale);
|
||||
SetNativeDisplayId(display.CreatureDisplayID, display.DisplayScale);
|
||||
}
|
||||
SetDisplayId(display.CreatureDisplayID, true);
|
||||
|
||||
GetMotionMaster()->InitializeDefault();
|
||||
|
||||
@@ -3251,26 +3247,26 @@ void Creature::SetObjectScale(float scale)
|
||||
|
||||
if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(GetDisplayId()))
|
||||
{
|
||||
SetBoundingRadius((IsPet() ? 1.0f : minfo->bounding_radius) * scale);
|
||||
SetCombatReach((IsPet() ? DEFAULT_PLAYER_COMBAT_REACH : minfo->combat_reach) * scale);
|
||||
SetBoundingRadius((IsPet() ? 1.0f : minfo->bounding_radius) * scale * GetDisplayScale());
|
||||
SetCombatReach((IsPet() ? DEFAULT_PLAYER_COMBAT_REACH : minfo->combat_reach) * scale * GetDisplayScale());
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::SetDisplayId(uint32 modelId, float displayScale /*= 1.f*/)
|
||||
void Creature::SetDisplayId(uint32 displayId, bool setNative /*= false*/)
|
||||
{
|
||||
Unit::SetDisplayId(modelId, displayScale);
|
||||
Unit::SetDisplayId(displayId, setNative);
|
||||
|
||||
if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(modelId))
|
||||
if (CreatureModelInfo const* modelInfo = sObjectMgr->GetCreatureModelInfo(displayId))
|
||||
{
|
||||
SetBoundingRadius((IsPet() ? 1.0f : minfo->bounding_radius) * GetObjectScale());
|
||||
SetCombatReach((IsPet() ? DEFAULT_PLAYER_COMBAT_REACH : minfo->combat_reach) * GetObjectScale());
|
||||
SetBoundingRadius((IsPet() ? 1.0f : modelInfo->bounding_radius) * GetObjectScale() * GetDisplayScale());
|
||||
SetCombatReach((IsPet() ? DEFAULT_PLAYER_COMBAT_REACH : modelInfo->combat_reach) * GetObjectScale() * GetDisplayScale());
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::SetDisplayFromModel(uint32 modelIdx)
|
||||
{
|
||||
if (CreatureModel const* model = GetCreatureTemplate()->GetModelByIdx(modelIdx))
|
||||
SetDisplayId(model->CreatureDisplayID, model->DisplayScale);
|
||||
SetDisplayId(model->CreatureDisplayID);
|
||||
}
|
||||
|
||||
void Creature::SetTarget(ObjectGuid const& guid)
|
||||
|
||||
@@ -77,7 +77,7 @@ class TC_GAME_API Creature : public Unit, public GridObject<Creature>, public Ma
|
||||
|
||||
float GetNativeObjectScale() const override;
|
||||
void SetObjectScale(float scale) override;
|
||||
void SetDisplayId(uint32 displayId, float displayScale = 1.f) override;
|
||||
void SetDisplayId(uint32 displayId, bool setNative = false) override;
|
||||
void SetDisplayFromModel(uint32 modelIdx);
|
||||
|
||||
void DisappearAndDie() { ForcedDespawn(0); }
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
|
||||
#define DEFAULT_PLAYER_BOUNDING_RADIUS 0.388999998569489f // player size, also currently used (correctly?) for any non Unit world objects
|
||||
#define DEFAULT_PLAYER_COMBAT_REACH 1.5f
|
||||
#define DEFAULT_PLAYER_DISPLAY_SCALE 1.0f
|
||||
#define MIN_MELEE_REACH 2.0f
|
||||
#define NOMINAL_MELEE_RANGE 5.0f
|
||||
#define MELEE_RANGE (NOMINAL_MELEE_RANGE - MIN_MELEE_REACH * 2) //center to center for players
|
||||
|
||||
@@ -271,8 +271,7 @@ bool Pet::LoadPetFromDB(Player* owner, uint32 petEntry, uint32 petnumber, bool c
|
||||
|
||||
m_charmInfo->SetPetNumber(petInfo->PetNumber, IsPermanentPetFor(owner));
|
||||
|
||||
SetDisplayId(petInfo->DisplayId);
|
||||
SetNativeDisplayId(petInfo->DisplayId);
|
||||
SetDisplayId(petInfo->DisplayId, true);
|
||||
uint8 petlevel = petInfo->Level;
|
||||
ReplaceAllNpcFlags(UNIT_NPC_FLAG_NONE);
|
||||
ReplaceAllNpcFlags2(UNIT_NPC_FLAG_2_NONE);
|
||||
@@ -1832,9 +1831,9 @@ float Pet::GetNativeObjectScale() const
|
||||
return Guardian::GetNativeObjectScale();
|
||||
}
|
||||
|
||||
void Pet::SetDisplayId(uint32 modelId, float displayScale /*= 1.f*/)
|
||||
void Pet::SetDisplayId(uint32 modelId, bool setNative /*= false*/)
|
||||
{
|
||||
Guardian::SetDisplayId(modelId, displayScale);
|
||||
Guardian::SetDisplayId(modelId, setNative);
|
||||
|
||||
if (!isControlled())
|
||||
return;
|
||||
|
||||
@@ -52,7 +52,7 @@ class TC_GAME_API Pet : public Guardian
|
||||
void RemoveFromWorld() override;
|
||||
|
||||
float GetNativeObjectScale() const override;
|
||||
void SetDisplayId(uint32 modelId, float displayScale = 1.f) override;
|
||||
void SetDisplayId(uint32 modelId, bool setNative = false) override;
|
||||
|
||||
PetType getPetType() const { return m_petType; }
|
||||
void setPetType(PetType type) { m_petType = type; }
|
||||
|
||||
@@ -22395,8 +22395,7 @@ void Player::InitDisplayIds()
|
||||
return;
|
||||
}
|
||||
|
||||
SetDisplayId(model->DisplayID);
|
||||
SetNativeDisplayId(model->DisplayID);
|
||||
SetDisplayId(model->DisplayID, true);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::StateAnimID), sDB2Manager.GetEmptyAnimStateID());
|
||||
}
|
||||
|
||||
|
||||
@@ -5986,10 +5986,7 @@ void Unit::SetMinion(Minion *minion, bool apply)
|
||||
minion->SetWildBattlePetLevel(pet->PacketInfo.Level);
|
||||
|
||||
if (uint32 display = pet->PacketInfo.DisplayID)
|
||||
{
|
||||
minion->SetDisplayId(display);
|
||||
minion->SetNativeDisplayId(display);
|
||||
}
|
||||
minion->SetDisplayId(display, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10147,14 +10144,26 @@ void Unit::RecalculateObjectScale()
|
||||
SetObjectScale(std::max(scale, scaleMin));
|
||||
}
|
||||
|
||||
void Unit::SetDisplayId(uint32 modelId, float displayScale /*= 1.f*/)
|
||||
void Unit::SetDisplayId(uint32 displayId, bool setNative /*= false*/)
|
||||
{
|
||||
SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::DisplayID), modelId);
|
||||
float displayScale = DEFAULT_PLAYER_DISPLAY_SCALE;
|
||||
|
||||
if (IsCreature() && !IsPet())
|
||||
if (CreatureModel const* model = ToCreature()->GetCreatureTemplate()->GetModelWithDisplayId(displayId))
|
||||
displayScale = model->DisplayScale;
|
||||
|
||||
SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::DisplayID), displayId);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::DisplayScale), displayScale);
|
||||
|
||||
if (setNative)
|
||||
{
|
||||
SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::NativeDisplayID), displayId);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::NativeXDisplayScale), displayScale);
|
||||
}
|
||||
|
||||
// Set Gender by modelId
|
||||
if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(modelId))
|
||||
SetGender(Gender(minfo->gender));
|
||||
if (CreatureModelInfo const* modelInfo = sObjectMgr->GetCreatureModelInfo(displayId))
|
||||
SetGender(Gender(modelInfo->gender));
|
||||
}
|
||||
|
||||
void Unit::RestoreDisplayId(bool ignorePositiveAurasPreventingMounting /*= false*/)
|
||||
|
||||
@@ -1652,15 +1652,11 @@ class TC_GAME_API Unit : public WorldObject
|
||||
virtual float GetNativeObjectScale() const { return 1.0f; }
|
||||
virtual void RecalculateObjectScale();
|
||||
uint32 GetDisplayId() const { return m_unitData->DisplayID; }
|
||||
virtual void SetDisplayId(uint32 modelId, float displayScale = 1.f);
|
||||
float GetDisplayScale() const { return m_unitData->DisplayScale; }
|
||||
virtual void SetDisplayId(uint32 displayId, bool setNative = false);
|
||||
uint32 GetNativeDisplayId() const { return m_unitData->NativeDisplayID; }
|
||||
float GetNativeDisplayScale() const { return m_unitData->NativeXDisplayScale; }
|
||||
void RestoreDisplayId(bool ignorePositiveAurasPreventingMounting = false);
|
||||
void SetNativeDisplayId(uint32 displayId, float displayScale = 1.f)
|
||||
{
|
||||
SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::NativeDisplayID), displayId);
|
||||
SetUpdateFieldValue(m_values.ModifyValue(&Unit::m_unitData).ModifyValue(&UF::UnitData::NativeXDisplayScale), displayScale);
|
||||
}
|
||||
void SetTransformSpell(uint32 spellid) { m_transformSpell = spellid;}
|
||||
uint32 GetTransformSpell() const { return m_transformSpell;}
|
||||
|
||||
|
||||
@@ -1395,22 +1395,14 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate)
|
||||
itr->second.equipement_id_prev = creature->GetCurrentEquipmentId();
|
||||
itr->second.modelid_prev = creature->GetDisplayId();
|
||||
creature->LoadEquipment(itr->second.equipment_id, true);
|
||||
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);
|
||||
}
|
||||
if (itr->second.modelid > 0 && itr->second.modelid_prev != itr->second.modelid && sObjectMgr->GetCreatureModelInfo(itr->second.modelid))
|
||||
creature->SetDisplayId(itr->second.modelid, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
creature->LoadEquipment(itr->second.equipement_id_prev, true);
|
||||
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);
|
||||
}
|
||||
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, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -495,15 +495,12 @@ public:
|
||||
//Edit Player or Creature Scale
|
||||
static bool HandleModifyScaleCommand(ChatHandler* handler, char const* args)
|
||||
{
|
||||
float Scale;
|
||||
float scale;
|
||||
Unit* target = handler->getSelectedUnit();
|
||||
if (CheckModifySpeed(handler, args, target, Scale, 0.1f, 10.0f, false))
|
||||
if (CheckModifySpeed(handler, args, target, scale, 0.1f, 10.0f, false))
|
||||
{
|
||||
NotifyModification(handler, target, LANG_YOU_CHANGE_SIZE, LANG_YOURS_SIZE_CHANGED, Scale);
|
||||
if (Creature* creatureTarget = target->ToCreature())
|
||||
creatureTarget->SetDisplayId(creatureTarget->GetDisplayId(), Scale);
|
||||
else
|
||||
target->SetObjectScale(Scale);
|
||||
NotifyModification(handler, target, LANG_YOU_CHANGE_SIZE, LANG_YOURS_SIZE_CHANGED, scale);
|
||||
target->SetObjectScale(scale);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -693,8 +693,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
creature->SetDisplayId(displayId);
|
||||
creature->SetNativeDisplayId(displayId);
|
||||
creature->SetDisplayId(displayId, true);
|
||||
|
||||
creature->SaveToDB();
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ struct boss_felmyst : public BossAI
|
||||
me->Relocate(madrigosa);
|
||||
|
||||
me->SetDisplayFromModel(0);
|
||||
me->SetNativeDisplayId(me->GetDisplayId());
|
||||
me->SetDisplayId(me->GetDisplayId(), true);
|
||||
}
|
||||
|
||||
void Reset() override
|
||||
|
||||
Reference in New Issue
Block a user