refactor(Core/Object): getLevel() -> GetLevel() (#14122)

* refactor(Core/Object): getLevel() -> GetLevel()

* fix build and sneak some doxygen in

* codeSTLE

* codestyle
This commit is contained in:
Kitzunu
2022-12-31 17:39:23 +01:00
committed by GitHub
parent 089ce9eb41
commit 4870b14b1f
78 changed files with 326 additions and 314 deletions

View File

@@ -330,7 +330,7 @@ void Player::ApplyFeralAPBonus(int32 amount, bool apply)
void Player::UpdateAttackPowerAndDamage(bool ranged)
{
float val2 = 0.0f;
float level = float(getLevel());
float level = float(GetLevel());
sScriptMgr->OnBeforeUpdateAttackPowerAndDamage(this, level, val2, ranged);
@@ -454,14 +454,14 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
switch (GetShapeshiftForm())
{
case FORM_CAT:
val2 = (getLevel() * mLevelMult) + GetStat(STAT_STRENGTH) * 2.0f + GetStat(STAT_AGILITY) - 20.0f + weapon_bonus + m_baseFeralAP;
val2 = (GetLevel() * mLevelMult) + GetStat(STAT_STRENGTH) * 2.0f + GetStat(STAT_AGILITY) - 20.0f + weapon_bonus + m_baseFeralAP;
break;
case FORM_BEAR:
case FORM_DIREBEAR:
val2 = (getLevel() * mLevelMult) + GetStat(STAT_STRENGTH) * 2.0f - 20.0f + weapon_bonus + m_baseFeralAP;
val2 = (GetLevel() * mLevelMult) + GetStat(STAT_STRENGTH) * 2.0f - 20.0f + weapon_bonus + m_baseFeralAP;
break;
case FORM_MOONKIN:
val2 = (getLevel() * mLevelMult) + GetStat(STAT_STRENGTH) * 2.0f - 20.0f + m_baseFeralAP;
val2 = (GetLevel() * mLevelMult) + GetStat(STAT_STRENGTH) * 2.0f - 20.0f + m_baseFeralAP;
break;
default:
val2 = GetStat(STAT_STRENGTH) * 2.0f - 20.0f;
@@ -576,7 +576,7 @@ void Player::CalculateMinMaxDamage(WeaponAttackType attType, bool normalized, bo
if (IsInFeralForm()) // check if player is druid and in cat or bear forms
{
uint8 lvl = getLevel();
uint8 lvl = GetLevel();
if (lvl > 60)
lvl = 60;

View File

@@ -1707,7 +1707,7 @@ void Unit::CalculateMeleeDamage(Unit* victim, CalcDamageInfo* damageInfo, Weapon
damageInfo->HitInfo |= HITINFO_GLANCING;
damageInfo->TargetState = VICTIMSTATE_HIT;
damageInfo->procEx |= PROC_EX_NORMAL_HIT;
int32 leveldif = int32(victim->getLevel()) - int32(getLevel());
int32 leveldif = int32(victim->GetLevel()) - int32(GetLevel());
if (leveldif > 3)
leveldif = 3;
float reducePercent = 1 - leveldif * 0.1f;
@@ -1880,8 +1880,8 @@ void Unit::DealMeleeDamage(CalcDamageInfo* damageInfo, bool durabilityLoss)
float Probability = 20.0f;
// there is a newbie protection, at level 10 just 7% base chance; assuming linear function
if (victim->getLevel() < 30)
Probability = 0.65f * victim->getLevel() + 0.5f;
if (victim->GetLevel() < 30)
Probability = 0.65f * victim->GetLevel() + 0.5f;
uint32 VictimDefense = victim->GetDefenseSkillValue();
uint32 AttackerMeleeSkill = GetUnitMeleeSkill();
@@ -2036,10 +2036,10 @@ uint32 Unit::CalcArmorReducedDamage(Unit const* attacker, Unit const* victim, co
}
float maxArmorPen = 0;
if (victim->getLevel() < 60)
maxArmorPen = float(400 + 85 * victim->getLevel());
if (victim->GetLevel() < 60)
maxArmorPen = float(400 + 85 * victim->GetLevel());
else
maxArmorPen = 400 + 85 * victim->getLevel() + 4.5f * 85 * (victim->getLevel() - 59);
maxArmorPen = 400 + 85 * victim->GetLevel() + 4.5f * 85 * (victim->GetLevel() - 59);
// Cap armor penetration to this number
maxArmorPen = std::min((armor + maxArmorPen) / 3, armor);
@@ -2053,7 +2053,7 @@ uint32 Unit::CalcArmorReducedDamage(Unit const* attacker, Unit const* victim, co
if (armor < 0.0f)
armor = 0.0f;
float levelModifier = attacker ? attacker->getLevel() : attackerLevel;
float levelModifier = attacker ? attacker->GetLevel() : attackerLevel;
if (levelModifier > 59)
levelModifier = levelModifier + (4.5f * (levelModifier - 59));
@@ -2087,11 +2087,11 @@ float Unit::GetEffectiveResistChance(Unit const* owner, SpellSchoolMask schoolMa
victimResistance = std::max(victimResistance, 0.0f);
if (owner)
victimResistance += std::max((float(victim->getLevel()) - float(owner->getLevel())) * 5.0f, 0.0f);
victimResistance += std::max((float(victim->GetLevel()) - float(owner->GetLevel())) * 5.0f, 0.0f);
static uint32 const BOSS_LEVEL = 83;
static float const BOSS_RESISTANCE_CONSTANT = 510.0f;
uint32 level = victim->getLevel();
uint32 level = victim->GetLevel();
float resistanceConstant = 0.0f;
if (level == BOSS_LEVEL)
@@ -2872,7 +2872,7 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst(Unit const* victim, WeaponAttackTy
if (attType != RANGED_ATTACK &&
(GetTypeId() == TYPEID_PLAYER || IsPet()) &&
victim->GetTypeId() != TYPEID_PLAYER && !victim->IsPet() &&
getLevel() < victim->getLevelForTarget(this))
GetLevel() < victim->getLevelForTarget(this))
{
// cap possible value (with bonuses > max skill)
int32 skill = attackerWeaponSkill;
@@ -3001,7 +3001,7 @@ float Unit::CalculateLevelPenalty(SpellInfo const* spellProto) const
if (spellProto->SpellLevel < 20)
LvlPenalty = (20.0f - spellProto->SpellLevel) * 3.75f;
float LvlFactor = (float(spellProto->SpellLevel) + 6.0f) / float(getLevel());
float LvlFactor = (float(spellProto->SpellLevel) + 6.0f) / float(GetLevel());
if (LvlFactor > 1.0f)
LvlFactor = 1.0f;
@@ -3110,7 +3110,7 @@ SpellMissInfo Unit::MeleeSpellHitResult(Unit* victim, SpellInfo const* spellInfo
int32 attackerWeaponSkill;
// skill value for these spells (for example judgements) is 5* level
if (spellInfo->DmgClass == SPELL_DAMAGE_CLASS_RANGED && !spellInfo->IsRangedWeaponSpell())
attackerWeaponSkill = getLevel() * 5;
attackerWeaponSkill = GetLevel() * 5;
// bonus from skills is 0.04% per skill Diff
else
attackerWeaponSkill = int32(GetWeaponSkillValue(attType, victim));
@@ -11436,7 +11436,7 @@ float Unit::SpellPctDamageModsDone(Unit* victim, SpellInfo const* spellProto, Da
if (victim->HasAuraState(AURA_STATE_FROZEN, spellProto, this))
{
// Glyph of Ice Lance
if (owner->HasAura(56377) && victim->getLevel() > owner->getLevel())
if (owner->HasAura(56377) && victim->GetLevel() > owner->GetLevel())
DoneTotalMod *= 4.0f;
else
DoneTotalMod *= 3.0f;
@@ -17456,7 +17456,7 @@ Pet* Unit::CreateTamedPetFrom(Creature* creatureTarget, uint32 spell_id)
return nullptr;
}
uint8 level = creatureTarget->getLevel() + 5 < getLevel() ? (getLevel() - 5) : creatureTarget->getLevel();
uint8 level = creatureTarget->GetLevel() + 5 < GetLevel() ? (GetLevel() - 5) : creatureTarget->GetLevel();
if (!InitTamedPet(pet, level, spell_id))
{
@@ -17478,7 +17478,7 @@ Pet* Unit::CreateTamedPetFrom(uint32 creatureEntry, uint32 spell_id)
Pet* pet = new Pet(ToPlayer(), HUNTER_PET);
if (!pet->CreateBaseAtCreatureInfo(creatureInfo, this) || !InitTamedPet(pet, getLevel(), spell_id))
if (!pet->CreateBaseAtCreatureInfo(creatureInfo, this) || !InitTamedPet(pet, GetLevel(), spell_id))
{
delete pet;
return nullptr;
@@ -20208,11 +20208,11 @@ void Unit::RewardRage(uint32 damage, uint32 weaponSpeedHitFactor, bool attacker)
{
float addRage;
float rageconversion = ((0.0091107836f * getLevel() * getLevel()) + 3.225598133f * getLevel()) + 4.2652911f;
float rageconversion = ((0.0091107836f * GetLevel() * GetLevel()) + 3.225598133f * GetLevel()) + 4.2652911f;
// Unknown if correct, but lineary adjust rage conversion above level 70
if (getLevel() > 70)
rageconversion += 13.27f * (getLevel() - 70);
if (GetLevel() > 70)
rageconversion += 13.27f * (GetLevel() - 70);
if (attacker)
{

View File

@@ -1415,8 +1415,10 @@ public:
[[nodiscard]] bool IsTotem() const { return m_unitTypeMask & UNIT_MASK_TOTEM; }
[[nodiscard]] bool IsVehicle() const { return m_unitTypeMask & UNIT_MASK_VEHICLE; }
/// @deprecated Use GetLevel() instead!
[[nodiscard]] uint8 getLevel() const { return uint8(GetUInt32Value(UNIT_FIELD_LEVEL)); }
uint8 getLevelForTarget(WorldObject const* /*target*/) const override { return getLevel(); }
[[nodiscard]] uint8 GetLevel() const { return getLevel(); }
uint8 getLevelForTarget(WorldObject const* /*target*/) const override { return GetLevel(); }
void SetLevel(uint8 lvl, bool showLevelChange = true);
[[nodiscard]] uint8 getRace(bool original = false) const;
void setRace(uint8 race);
@@ -1542,7 +1544,7 @@ public:
void Mount(uint32 mount, uint32 vehicleId = 0, uint32 creatureEntry = 0);
void Dismount();
uint16 GetMaxSkillValueForLevel(Unit const* target = nullptr) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
uint16 GetMaxSkillValueForLevel(Unit const* target = nullptr) const { return (target ? getLevelForTarget(target) : GetLevel()) * 5; }
static void DealDamageMods(Unit const* victim, uint32& damage, uint32* absorb);
static uint32 DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage const* cleanDamage = nullptr, DamageEffectType damagetype = DIRECT_DAMAGE, SpellSchoolMask damageSchoolMask = SPELL_SCHOOL_MASK_NORMAL, SpellInfo const* spellProto = nullptr, bool durabilityLoss = true, bool allowGM = false, Spell const* spell = nullptr);
static void Kill(Unit* killer, Unit* victim, bool durabilityLoss = true, WeaponAttackType attackType = BASE_ATTACK, SpellInfo const* spellProto = nullptr, Spell const* spell = nullptr);
@@ -1630,7 +1632,7 @@ public:
return value;
}
uint32 GetUnitMeleeSkill(Unit const* target = nullptr) const { return (target ? getLevelForTarget(target) : getLevel()) * 5; }
uint32 GetUnitMeleeSkill(Unit const* target = nullptr) const { return (target ? getLevelForTarget(target) : GetLevel()) * 5; }
uint32 GetDefenseSkillValue(Unit const* target = nullptr) const;
uint32 GetWeaponSkillValue(WeaponAttackType attType, Unit const* target = nullptr) const;
[[nodiscard]] float GetWeaponProcChance() const;