[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:
NoFantasy 2010-06-28 12:10:13 +02:00
parent 67a7892075
commit 1713caae17
8 changed files with 27 additions and 25 deletions

View file

@ -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