mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-29 08:33:47 +00:00
refactor(Core): use the WeaponAttackType enum (#23457)
This commit is contained in:
@@ -78,6 +78,7 @@
|
||||
#include "TicketMgr.h"
|
||||
#include "Tokenize.h"
|
||||
#include "Transport.h"
|
||||
#include "Unit.h"
|
||||
#include "UpdateData.h"
|
||||
#include "Util.h"
|
||||
#include "Vehicle.h"
|
||||
@@ -6595,13 +6596,13 @@ void Player::_ApplyItemMods(Item* item, uint8 slot, bool apply)
|
||||
|
||||
LOG_DEBUG("entities.player", "applying mods for item {} ", item->GetGUID().ToString());
|
||||
|
||||
uint8 attacktype = Player::GetAttackBySlot(slot);
|
||||
WeaponAttackType attacktype = Player::GetAttackBySlot(slot);
|
||||
|
||||
if (item->HasSocket()) //only (un)equipping of items with sockets can influence metagems, so no need to waste time with normal items
|
||||
CorrectMetaGemEnchants(slot, apply);
|
||||
|
||||
if (attacktype < MAX_ATTACK)
|
||||
_ApplyWeaponDependentAuraMods(item, WeaponAttackType(attacktype), apply);
|
||||
_ApplyWeaponDependentAuraMods(item, attacktype, apply);
|
||||
|
||||
_ApplyItemBonuses(proto, slot, apply);
|
||||
|
||||
@@ -6888,7 +6889,7 @@ void Player::_ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply
|
||||
if (proto->ArcaneRes)
|
||||
HandleStatModifier(UNIT_MOD_RESISTANCE_ARCANE, BASE_VALUE, float(proto->ArcaneRes), apply);
|
||||
|
||||
uint8 attType = Player::GetAttackBySlot(slot);
|
||||
WeaponAttackType attType = Player::GetAttackBySlot(slot);
|
||||
if (attType != MAX_ATTACK)
|
||||
{
|
||||
_ApplyWeaponDamage(slot, proto, ssv, apply);
|
||||
@@ -6935,7 +6936,7 @@ void Player::_ApplyWeaponDamage(uint8 slot, ItemTemplate const* proto, ScalingSt
|
||||
ssv = ScalingStatValue ? sScalingStatValuesStore.LookupEntry(ssd_level) : nullptr;
|
||||
}
|
||||
|
||||
uint8 attType = Player::GetAttackBySlot(slot);
|
||||
WeaponAttackType attType = Player::GetAttackBySlot(slot);
|
||||
if (!IsInFeralForm() && apply && !CanUseAttackType(attType))
|
||||
{
|
||||
return;
|
||||
@@ -6966,12 +6967,12 @@ void Player::_ApplyWeaponDamage(uint8 slot, ItemTemplate const* proto, ScalingSt
|
||||
|
||||
if (minDamage > 0.f)
|
||||
{
|
||||
SetBaseWeaponDamage(WeaponAttackType(attType), MINDAMAGE, minDamage, i);
|
||||
SetBaseWeaponDamage(attType, MINDAMAGE, minDamage, i);
|
||||
}
|
||||
|
||||
if (maxDamage > 0.f)
|
||||
{
|
||||
SetBaseWeaponDamage(WeaponAttackType(attType), MAXDAMAGE, maxDamage, i);
|
||||
SetBaseWeaponDamage(attType, MAXDAMAGE, maxDamage, i);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6980,8 +6981,8 @@ void Player::_ApplyWeaponDamage(uint8 slot, ItemTemplate const* proto, ScalingSt
|
||||
{
|
||||
for (uint8 i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
|
||||
{
|
||||
SetBaseWeaponDamage(WeaponAttackType(attType), MINDAMAGE, 0.f, i);
|
||||
SetBaseWeaponDamage(WeaponAttackType(attType), MAXDAMAGE, 0.f, i);
|
||||
SetBaseWeaponDamage(attType, MINDAMAGE, 0.f, i);
|
||||
SetBaseWeaponDamage(attType, MAXDAMAGE, 0.f, i);
|
||||
}
|
||||
|
||||
if (attType == BASE_ATTACK)
|
||||
@@ -7005,8 +7006,8 @@ void Player::_ApplyWeaponDamage(uint8 slot, ItemTemplate const* proto, ScalingSt
|
||||
if (IsInFeralForm())
|
||||
return;
|
||||
|
||||
if (CanModifyStats() && (GetWeaponDamageRange(WeaponAttackType(attType), MAXDAMAGE) || proto->Delay))
|
||||
UpdateDamagePhysical(WeaponAttackType(attType));
|
||||
if (CanModifyStats() && (GetWeaponDamageRange(attType, MAXDAMAGE) || proto->Delay))
|
||||
UpdateDamagePhysical(attType);
|
||||
}
|
||||
|
||||
void Player::CastAllObtainSpells()
|
||||
@@ -7599,9 +7600,9 @@ void Player::_RemoveAllItemMods()
|
||||
if (!proto)
|
||||
continue;
|
||||
|
||||
uint32 attacktype = Player::GetAttackBySlot(i);
|
||||
WeaponAttackType attacktype = Player::GetAttackBySlot(i);
|
||||
if (attacktype < MAX_ATTACK)
|
||||
_ApplyWeaponDependentAuraMods(m_items[i], WeaponAttackType(attacktype), false);
|
||||
_ApplyWeaponDependentAuraMods(m_items[i], attacktype, false);
|
||||
|
||||
_ApplyItemBonuses(proto, i, false);
|
||||
|
||||
@@ -7628,9 +7629,9 @@ void Player::_ApplyAllItemMods()
|
||||
if (!proto)
|
||||
continue;
|
||||
|
||||
uint32 attacktype = Player::GetAttackBySlot(i);
|
||||
WeaponAttackType attacktype = Player::GetAttackBySlot(i);
|
||||
if (attacktype < MAX_ATTACK)
|
||||
_ApplyWeaponDependentAuraMods(m_items[i], WeaponAttackType(attacktype), true);
|
||||
_ApplyWeaponDependentAuraMods(m_items[i], attacktype, true);
|
||||
|
||||
_ApplyItemBonuses(proto, i, true);
|
||||
|
||||
|
||||
@@ -1257,7 +1257,7 @@ public:
|
||||
bool HasWeapon(WeaponAttackType type) const override { return GetWeaponForAttack(type, false); }
|
||||
bool HasWeaponForAttack(WeaponAttackType type) const override { return (Unit::HasWeaponForAttack(type) && GetWeaponForAttack(type, true)); }
|
||||
[[nodiscard]] Item* GetShield(bool useable = false) const;
|
||||
static uint8 GetAttackBySlot(uint8 slot); // MAX_ATTACK if not weapon slot
|
||||
static WeaponAttackType GetAttackBySlot(uint8 slot); // MAX_ATTACK if not weapon slot
|
||||
std::vector<Item*>& GetItemUpdateQueue() { return m_itemUpdateQueue; }
|
||||
static bool IsInventoryPos(uint16 pos) { return IsInventoryPos(pos >> 8, pos & 255); }
|
||||
static bool IsInventoryPos(uint8 bag, uint8 slot);
|
||||
|
||||
@@ -51,6 +51,7 @@
|
||||
#include "QuestDef.h"
|
||||
#include "ReputationMgr.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "ScriptObjectFwd.h"
|
||||
#include "SocialMgr.h"
|
||||
#include "Spell.h"
|
||||
#include "SpellAuraEffects.h"
|
||||
@@ -539,7 +540,7 @@ Item* Player::GetShield(bool useable) const
|
||||
return item;
|
||||
}
|
||||
|
||||
uint8 Player::GetAttackBySlot(uint8 slot)
|
||||
WeaponAttackType Player::GetAttackBySlot(uint8 slot)
|
||||
{
|
||||
switch (slot)
|
||||
{
|
||||
|
||||
@@ -8179,7 +8179,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
|
||||
if (triggeredByAura->GetBase() && castItem->GetGUID() != triggeredByAura->GetBase()->GetCastItemGUID())
|
||||
return false;
|
||||
|
||||
WeaponAttackType attType = WeaponAttackType(player->GetAttackBySlot(castItem->GetSlot()));
|
||||
WeaponAttackType attType = player->GetAttackBySlot(castItem->GetSlot());
|
||||
if ((attType != BASE_ATTACK && attType != OFF_ATTACK)
|
||||
|| (attType == BASE_ATTACK && procFlag & PROC_FLAG_DONE_OFFHAND_ATTACK)
|
||||
|| (attType == OFF_ATTACK && procFlag & PROC_FLAG_DONE_MAINHAND_ATTACK))
|
||||
@@ -8370,7 +8370,7 @@ bool Unit::HandleDummyAuraProc(Unit* victim, uint32 damage, AuraEffect* triggere
|
||||
if (!IsPlayer() || !victim || !victim->IsAlive() || !castItem || !castItem->IsEquipped())
|
||||
return false;
|
||||
|
||||
WeaponAttackType attType = WeaponAttackType(Player::GetAttackBySlot(castItem->GetSlot()));
|
||||
WeaponAttackType attType = Player::GetAttackBySlot(castItem->GetSlot());
|
||||
if ((attType != BASE_ATTACK && attType != OFF_ATTACK)
|
||||
|| (attType == BASE_ATTACK && procFlag & PROC_FLAG_DONE_OFFHAND_ATTACK)
|
||||
|| (attType == OFF_ATTACK && procFlag & PROC_FLAG_DONE_MAINHAND_ATTACK))
|
||||
|
||||
@@ -967,7 +967,7 @@ public:
|
||||
inline bool HasMainhandWeaponForAttack() const { return HasWeaponForAttack(BASE_ATTACK); }
|
||||
inline bool HasOffhandWeaponForAttack() const { return HasWeaponForAttack(OFF_ATTACK); }
|
||||
inline bool HasRangedWeaponForAttack() const { return HasWeaponForAttack(RANGED_ATTACK); }
|
||||
[[nodiscard]] bool CanUseAttackType(uint8 attacktype) const
|
||||
[[nodiscard]] bool CanUseAttackType(WeaponAttackType attacktype) const
|
||||
{
|
||||
switch (attacktype)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user