mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 04:37:00 +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
|
|
@ -247,6 +247,7 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
|
|||
|
||||
SetDisplayId(display_id);
|
||||
SetNativeDisplayId(display_id);
|
||||
|
||||
SetByteValue(UNIT_FIELD_BYTES_0, 2, minfo->gender);
|
||||
|
||||
// Load creature equipment
|
||||
|
|
@ -264,9 +265,6 @@ bool Creature::InitEntry(uint32 Entry, uint32 team, const CreatureData *data )
|
|||
|
||||
SetName(normalInfo->Name); // at normal entry always
|
||||
|
||||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, minfo->bounding_radius);
|
||||
SetFloatValue(UNIT_FIELD_COMBATREACH, minfo->combat_reach);
|
||||
|
||||
SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f);
|
||||
|
||||
SetSpeedRate(MOVE_WALK, cinfo->speed_walk);
|
||||
|
|
|
|||
|
|
@ -739,8 +739,6 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate)
|
|||
{
|
||||
pCreature->SetDisplayId(itr->second.modelid);
|
||||
pCreature->SetNativeDisplayId(itr->second.modelid);
|
||||
pCreature->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS,minfo->bounding_radius);
|
||||
pCreature->SetFloatValue(UNIT_FIELD_COMBATREACH,minfo->combat_reach );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -754,8 +752,6 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate)
|
|||
{
|
||||
pCreature->SetDisplayId(itr->second.modelid_prev);
|
||||
pCreature->SetNativeDisplayId(itr->second.modelid_prev);
|
||||
pCreature->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS,minfo->bounding_radius);
|
||||
pCreature->SetFloatValue(UNIT_FIELD_COMBATREACH,minfo->combat_reach );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -835,6 +835,7 @@ bool Pet::InitStatsForLevel(uint32 petlevel, Unit* owner)
|
|||
scale = cFamily->minScale + float(getLevel() - cFamily->minScaleLevel) / cFamily->maxScaleLevel * (cFamily->maxScale - cFamily->minScale);
|
||||
|
||||
SetObjectScale(scale);
|
||||
UpdateModelData();
|
||||
}
|
||||
m_bonusdamage = 0;
|
||||
|
||||
|
|
|
|||
|
|
@ -4439,8 +4439,6 @@ void Player::BuildPlayerRepop()
|
|||
|
||||
StopMirrorTimers(); //disable timers(bars)
|
||||
|
||||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, (float)1.0); //see radius of death player?
|
||||
|
||||
// set and clear other
|
||||
SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND);
|
||||
}
|
||||
|
|
@ -18441,6 +18439,9 @@ void Player::InitDisplayIds()
|
|||
return;
|
||||
}
|
||||
|
||||
// reset scale before reapply auras
|
||||
SetObjectScale(DEFAULT_OBJECT_SCALE);
|
||||
|
||||
uint8 gender = getGender();
|
||||
switch(gender)
|
||||
{
|
||||
|
|
@ -18456,21 +18457,6 @@ void Player::InitDisplayIds()
|
|||
sLog.outError("Invalid gender %u for player",gender);
|
||||
return;
|
||||
}
|
||||
|
||||
// reset scale before reapply auras
|
||||
SetObjectScale(DEFAULT_OBJECT_SCALE);
|
||||
|
||||
if (CreatureModelInfo const* modelInfo = sObjectMgr.GetCreatureModelInfo(GetDisplayId()))
|
||||
{
|
||||
// bounding_radius and combat_reach is normally modified by scale, but player is always 1.0 scale by default so no need to modify values here.
|
||||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, modelInfo->bounding_radius);
|
||||
SetFloatValue(UNIT_FIELD_COMBATREACH, modelInfo->combat_reach);
|
||||
}
|
||||
else
|
||||
{
|
||||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE);
|
||||
SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f);
|
||||
}
|
||||
}
|
||||
|
||||
// Return true is the bought item has a max count to force refresh of window by caller
|
||||
|
|
|
|||
|
|
@ -3597,6 +3597,7 @@ void Aura::HandleAuraTrackStealthed(bool apply, bool /*Real*/)
|
|||
void Aura::HandleAuraModScale(bool apply, bool /*Real*/)
|
||||
{
|
||||
GetTarget()->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X, float(m_modifier.m_amount), apply);
|
||||
GetTarget()->UpdateModelData();
|
||||
}
|
||||
|
||||
void Aura::HandleModPossess(bool apply, bool Real)
|
||||
|
|
|
|||
|
|
@ -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())
|
||||
|
|
|
|||
|
|
@ -1706,6 +1706,9 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
|
|||
void setTransForm(uint32 spellid) { m_transform = spellid;}
|
||||
uint32 getTransForm() const { return m_transform;}
|
||||
|
||||
// at any changes to scale and/or displayId
|
||||
void UpdateModelData();
|
||||
|
||||
DynamicObject* GetDynObject(uint32 spellId, SpellEffectIndex effIndex);
|
||||
DynamicObject* GetDynObject(uint32 spellId);
|
||||
void AddDynObject(DynamicObject* dynObj);
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "10114"
|
||||
#define REVISION_NR "10115"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue