mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 19:37:03 +00:00
[10115] Add function to update model_info at changes to scale or model.
* At every change to model or scale, the related data (bounding_radius/combat_reach) is now updated accordingly (note that player combat_reach are not changed like creature). * UpdateModelData is called from within SetDisplayId while changes to scale has explicit call to UpdateModelData after new scale is set (mostly for aura scale) * The updated values are calculated by (scale*bounding_radius)/(scale*combat_reach) * Database values for bounding_radius/combat_reach are expected to be relative to scale like 1.0 Signed-off-by: NoFantasy <nofantasy@nf.no>
This commit is contained in:
parent
67a7892075
commit
1713caae17
8 changed files with 27 additions and 25 deletions
|
|
@ -12980,6 +12980,8 @@ void Unit::SetDisplayId(uint32 modelId)
|
|||
{
|
||||
SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId);
|
||||
|
||||
UpdateModelData();
|
||||
|
||||
if(GetTypeId() == TYPEID_UNIT && ((Creature*)this)->isPet())
|
||||
{
|
||||
Pet *pet = ((Pet*)this);
|
||||
|
|
@ -12991,6 +12993,21 @@ void Unit::SetDisplayId(uint32 modelId)
|
|||
}
|
||||
}
|
||||
|
||||
void Unit::UpdateModelData()
|
||||
{
|
||||
if (CreatureModelInfo const* modelInfo = sObjectMgr.GetCreatureModelInfo(GetDisplayId()))
|
||||
{
|
||||
// we expect values in database to be relative to scale = 1.0
|
||||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, GetObjectScale() * modelInfo->bounding_radius);
|
||||
|
||||
// never actually update combat_reach for player, it's always the same. Below player case is for initialization
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f);
|
||||
else
|
||||
SetFloatValue(UNIT_FIELD_COMBATREACH, GetObjectScale() * modelInfo->combat_reach);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::ClearComboPointHolders()
|
||||
{
|
||||
while(!m_ComboPointHolders.empty())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue