diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index 759e20416..a7975b282 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -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); diff --git a/src/game/GameEventMgr.cpp b/src/game/GameEventMgr.cpp index 0d55dfbd8..380bce860 100644 --- a/src/game/GameEventMgr.cpp +++ b/src/game/GameEventMgr.cpp @@ -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 ); } } } diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index b2fc38c79..29dcde733 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -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; diff --git a/src/game/Player.cpp b/src/game/Player.cpp index 3ef6d9027..965345b11 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -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 diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp index 3bc652493..a89ac3da5 100644 --- a/src/game/SpellAuras.cpp +++ b/src/game/SpellAuras.cpp @@ -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) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 77bfa8fc8..e3c0f0544 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -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()) diff --git a/src/game/Unit.h b/src/game/Unit.h index 76533ffcb..c482db10a 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -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); diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index ad55c560f..c3a84219e 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "10114" + #define REVISION_NR "10115" #endif // __REVISION_NR_H__