mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-21 23:38:54 -04:00
Core/Objects: Object scale will now also affect bounding radius and combat reach fields
This commit is contained in:
@@ -139,7 +139,7 @@ bool GameObjectModel::initialize(const GameObject& go, const GameObjectDisplayIn
|
||||
if (Creature* c = const_cast<GameObject&>(go).SummonCreature(24440, pos.x, pos.y, pos.z, 0, TEMPSUMMON_MANUAL_DESPAWN))
|
||||
{
|
||||
c->setFaction(35);
|
||||
c->SetFloatValue(OBJECT_FIELD_SCALE_X, 0.1f);
|
||||
c->SetObjectScale(0.1f);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -330,9 +330,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);
|
||||
|
||||
SetSpeed(MOVE_WALK, cinfo->speed_walk);
|
||||
@@ -340,6 +337,7 @@ bool Creature::InitEntry(uint32 entry, uint32 /*team*/, const CreatureData* data
|
||||
SetSpeed(MOVE_SWIM, 1.0f); // using 1.0 rate
|
||||
SetSpeed(MOVE_FLIGHT, 1.0f); // using 1.0 rate
|
||||
|
||||
// Will set UNIT_FIELD_BOUNDINGRADIUS and UNIT_FIELD_COMBATREACH
|
||||
SetObjectScale(cinfo->scale);
|
||||
|
||||
SetFloatValue(UNIT_FIELD_HOVERHEIGHT, cinfo->HoverHeight);
|
||||
@@ -2555,3 +2553,25 @@ void Creature::UpdateMovementFlags()
|
||||
else
|
||||
RemoveUnitMovementFlag(MOVEMENTFLAG_SWIMMING);
|
||||
}
|
||||
|
||||
void Creature::SetObjectScale(float scale)
|
||||
{
|
||||
Unit::SetObjectScale(scale);
|
||||
|
||||
if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(GetDisplayId()))
|
||||
{
|
||||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, minfo->bounding_radius * scale);
|
||||
SetFloatValue(UNIT_FIELD_COMBATREACH, minfo->combat_reach * scale);
|
||||
}
|
||||
}
|
||||
|
||||
void Creature::SetDisplayId(uint32 modelId)
|
||||
{
|
||||
Unit::SetDisplayId(modelId);
|
||||
|
||||
if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(modelId))
|
||||
{
|
||||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, minfo->bounding_radius * GetFloatValue(OBJECT_FIELD_SCALE_X));
|
||||
SetFloatValue(UNIT_FIELD_COMBATREACH, minfo->combat_reach * GetFloatValue(OBJECT_FIELD_SCALE_X));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -454,6 +454,9 @@ class Creature : public Unit, public GridObject<Creature>, public MapCreature
|
||||
void AddToWorld();
|
||||
void RemoveFromWorld();
|
||||
|
||||
void SetObjectScale(float scale);
|
||||
void SetDisplayId(uint32 modelId);
|
||||
|
||||
void DisappearAndDie();
|
||||
|
||||
bool Create(uint32 guidlow, Map* map, uint32 phaseMask, uint32 Entry, uint32 vehId, uint32 team, float x, float y, float z, float ang, const CreatureData* data = NULL);
|
||||
|
||||
@@ -2078,3 +2078,16 @@ Player* Pet::GetOwner() const
|
||||
{
|
||||
return Minion::GetOwner()->ToPlayer();
|
||||
}
|
||||
|
||||
void Pet::SetDisplayId(uint32 modelId)
|
||||
{
|
||||
Guardian::SetDisplayId(modelId);
|
||||
|
||||
if (!isControlled())
|
||||
return;
|
||||
|
||||
if (Unit* owner = GetOwner())
|
||||
if (Player* player = owner->ToPlayer())
|
||||
if (owner->ToPlayer()->GetGroup())
|
||||
owner->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MODEL_ID);
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ class Pet : public Guardian
|
||||
void AddToWorld();
|
||||
void RemoveFromWorld();
|
||||
|
||||
void SetDisplayId(uint32 modelId);
|
||||
|
||||
PetType getPetType() const { return m_petType; }
|
||||
void setPetType(PetType type) { m_petType = type; }
|
||||
bool isControlled() const { return getPetType() == SUMMON_PET || getPetType() == HUNTER_PET; }
|
||||
|
||||
@@ -965,8 +965,7 @@ bool Player::Create(uint32 guidlow, CharacterCreateInfo* createInfo)
|
||||
|
||||
uint8 powertype = cEntry->powerType;
|
||||
|
||||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE);
|
||||
SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f);
|
||||
SetObjectScale(1.0f);
|
||||
|
||||
setFactionForRace(createInfo->Race);
|
||||
|
||||
@@ -5125,8 +5124,6 @@ void Player::BuildPlayerRepop()
|
||||
|
||||
StopMirrorTimers(); //disable timers(bars)
|
||||
|
||||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, float(1.0f)); //see radius of death player?
|
||||
|
||||
// set and clear other
|
||||
SetByteValue(UNIT_FIELD_BYTES_1, 3, UNIT_BYTE1_FLAG_ALWAYS_STAND);
|
||||
}
|
||||
@@ -16985,8 +16982,7 @@ bool Player::LoadFromDB(uint32 guid, SQLQueryHolder *holder)
|
||||
_LoadIntoDataField(fields[61].GetCString(), PLAYER_EXPLORED_ZONES_1, PLAYER_EXPLORED_ZONES_SIZE);
|
||||
_LoadIntoDataField(fields[64].GetCString(), PLAYER__FIELD_KNOWN_TITLES, KNOWN_TITLES_SIZE*2);
|
||||
|
||||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE);
|
||||
SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f);
|
||||
SetObjectScale(1.0f);
|
||||
SetFloatValue(UNIT_FIELD_HOVERHEIGHT, 1.0f);
|
||||
|
||||
// load achievements before anything else to prevent multiple gains for the same achievement/criteria on every loading (as loading does call UpdateAchievementCriteria)
|
||||
|
||||
@@ -1063,7 +1063,7 @@ class Player : public Unit, public GridObject<Player>
|
||||
friend void Item::AddToUpdateQueueOf(Player* player);
|
||||
friend void Item::RemoveFromUpdateQueueOf(Player* player);
|
||||
public:
|
||||
explicit Player (WorldSession* session);
|
||||
explicit Player(WorldSession* session);
|
||||
~Player();
|
||||
|
||||
void CleanupsBeforeDelete(bool finalCleanup = true);
|
||||
@@ -1071,6 +1071,13 @@ class Player : public Unit, public GridObject<Player>
|
||||
void AddToWorld();
|
||||
void RemoveFromWorld();
|
||||
|
||||
void SetObjectScale(float scale)
|
||||
{
|
||||
Unit::SetObjectScale(scale);
|
||||
SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, scale * DEFAULT_WORLD_OBJECT_SIZE);
|
||||
SetFloatValue(UNIT_FIELD_COMBATREACH, scale * DEFAULT_COMBAT_REACH);
|
||||
}
|
||||
|
||||
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options = 0);
|
||||
bool TeleportTo(WorldLocation const &loc, uint32 options = 0);
|
||||
bool TeleportToBGEntryPoint();
|
||||
|
||||
@@ -14512,16 +14512,6 @@ bool Unit::IsPolymorphed() const
|
||||
void Unit::SetDisplayId(uint32 modelId)
|
||||
{
|
||||
SetUInt32Value(UNIT_FIELD_DISPLAYID, modelId);
|
||||
|
||||
if (GetTypeId() == TYPEID_UNIT && ToCreature()->isPet())
|
||||
{
|
||||
Pet* pet = ToPet();
|
||||
if (!pet->isControlled())
|
||||
return;
|
||||
Unit* owner = GetOwner();
|
||||
if (owner && (owner->GetTypeId() == TYPEID_PLAYER) && owner->ToPlayer()->GetGroup())
|
||||
owner->ToPlayer()->SetGroupUpdateFlag(GROUP_UPDATE_FLAG_PET_MODEL_ID);
|
||||
}
|
||||
}
|
||||
|
||||
void Unit::RestoreDisplayId()
|
||||
|
||||
@@ -1921,7 +1921,7 @@ class Unit : public WorldObject
|
||||
void UpdateInterruptMask();
|
||||
|
||||
uint32 GetDisplayId() const { return GetUInt32Value(UNIT_FIELD_DISPLAYID); }
|
||||
void SetDisplayId(uint32 modelId);
|
||||
virtual void SetDisplayId(uint32 modelId);
|
||||
uint32 GetNativeDisplayId() const { return GetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID); }
|
||||
void RestoreDisplayId();
|
||||
void SetNativeDisplayId(uint32 modelId) { SetUInt32Value(UNIT_FIELD_NATIVEDISPLAYID, modelId); }
|
||||
|
||||
@@ -1331,13 +1331,10 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate)
|
||||
creature->LoadEquipment(itr->second.equipment_id, true);
|
||||
if (itr->second.modelid > 0 && itr->second.modelid_prev != itr->second.modelid)
|
||||
{
|
||||
CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(itr->second.modelid);
|
||||
if (minfo)
|
||||
if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(itr->second.modelid))
|
||||
{
|
||||
creature->SetDisplayId(itr->second.modelid);
|
||||
creature->SetNativeDisplayId(itr->second.modelid);
|
||||
creature->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, minfo->bounding_radius);
|
||||
creature->SetFloatValue(UNIT_FIELD_COMBATREACH, minfo->combat_reach);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1346,13 +1343,10 @@ void GameEventMgr::ChangeEquipOrModel(int16 event_id, bool activate)
|
||||
creature->LoadEquipment(itr->second.equipement_id_prev, true);
|
||||
if (itr->second.modelid_prev > 0 && itr->second.modelid_prev != itr->second.modelid)
|
||||
{
|
||||
CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(itr->second.modelid_prev);
|
||||
if (minfo)
|
||||
if (CreatureModelInfo const* minfo = sObjectMgr->GetCreatureModelInfo(itr->second.modelid_prev))
|
||||
{
|
||||
creature->SetDisplayId(itr->second.modelid_prev);
|
||||
creature->SetNativeDisplayId(itr->second.modelid_prev);
|
||||
creature->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, minfo->bounding_radius);
|
||||
creature->SetFloatValue(UNIT_FIELD_COMBATREACH, minfo->combat_reach);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2069,7 +2069,9 @@ void AuraEffect::HandleAuraModScale(AuraApplication const* aurApp, uint8 mode, b
|
||||
|
||||
Unit* target = aurApp->GetTarget();
|
||||
|
||||
target->ApplyPercentModFloatValue(OBJECT_FIELD_SCALE_X, (float)GetAmount(), apply);
|
||||
float scale = target->GetFloatValue(OBJECT_FIELD_SCALE_X);
|
||||
ApplyPercentModFloatVar(scale, float(GetAmount()), apply);
|
||||
target->SetObjectScale(scale);
|
||||
}
|
||||
|
||||
void AuraEffect::HandleAuraCloneCaster(AuraApplication const* aurApp, uint8 mode, bool apply) const
|
||||
|
||||
@@ -102,9 +102,6 @@ public:
|
||||
if (!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT))
|
||||
player->SetShapeshiftForm(FORM_NONE);
|
||||
|
||||
player->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE);
|
||||
player->SetFloatValue(UNIT_FIELD_COMBATREACH, DEFAULT_COMBAT_REACH);
|
||||
|
||||
player->setFactionForRace(player->getRace());
|
||||
|
||||
player->SetUInt32Value(UNIT_FIELD_BYTES_0, ((player->getRace()) | (player->getClass() << 8) | (player->getGender() << 16) | (powerType << 24)));
|
||||
@@ -119,8 +116,6 @@ public:
|
||||
|
||||
//-1 is default value
|
||||
player->SetUInt32Value(PLAYER_FIELD_WATCHED_FACTION_INDEX, uint32(-1));
|
||||
|
||||
//player->SetUInt32Value(PLAYER_FIELD_BYTES, 0xEEE00000);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user