Skip to content

Commit 87fbdb7

Browse files
authored
feat(Core/Scripting): Add hook for applying weapon damage (#20350)
Add hook for applying weapon damage
1 parent 7746287 commit 87fbdb7

File tree

4 files changed

+11
-0
lines changed

4 files changed

+11
-0
lines changed

src/server/game/Entities/Player/Player.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -6936,6 +6936,8 @@ void Player::_ApplyWeaponDamage(uint8 slot, ItemTemplate const* proto, ScalingSt
69366936

69376937
if (apply)
69386938
{
6939+
sScriptMgr->OnApplyWeaponDamage(this, slot, proto, minDamage, maxDamage, i);
6940+
69396941
if (minDamage > 0.f)
69406942
{
69416943
SetBaseWeaponDamage(WeaponAttackType(attType), MINDAMAGE, minDamage, i);

src/server/game/Scripting/ScriptDefines/PlayerScript.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,11 @@ void ScriptMgr::OnApplyEnchantmentItemModsBefore(Player* player, Item* item, Enc
644644
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_APPLY_ENCHANTMENT_ITEM_MODS_BEFORE, script->OnApplyEnchantmentItemModsBefore(player, item, slot, apply, enchant_spell_id, enchant_amount));
645645
}
646646

647+
void ScriptMgr::OnApplyWeaponDamage(Player* player, uint8 slot, ItemTemplate const* proto, float& minDamage, float& maxDamage, uint8 damageIndex)
648+
{
649+
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_APPLY_WEAPON_DAMAGE, script->OnApplyWeaponDamage(player, slot, proto, minDamage, maxDamage, damageIndex));
650+
}
651+
647652
bool ScriptMgr::CanArmorDamageModifier(Player* player)
648653
{
649654
CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_ARMOR_DAMAGE_MODIFIER, !script->CanArmorDamageModifier(player));

src/server/game/Scripting/ScriptDefines/PlayerScript.h

+3
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ enum PlayerHook
150150
PLAYERHOOK_ON_CUSTOM_SCALING_STAT_VALUE,
151151
PLAYERHOOK_ON_APPLY_ITEM_MODS_BEFORE,
152152
PLAYERHOOK_ON_APPLY_ENCHANTMENT_ITEM_MODS_BEFORE,
153+
PLAYERHOOK_ON_APPLY_WEAPON_DAMAGE,
153154
PLAYERHOOK_CAN_ARMOR_DAMAGE_MODIFIER,
154155
PLAYERHOOK_ON_GET_FERAL_AP_BONUS,
155156
PLAYERHOOK_CAN_APPLY_WEAPON_DEPENDENT_AURA_DAMAGE_MOD,
@@ -547,6 +548,8 @@ class PlayerScript : public ScriptObject
547548

548549
virtual void OnApplyEnchantmentItemModsBefore(Player* /*player*/, Item* /*item*/, EnchantmentSlot /*slot*/, bool /*apply*/, uint32 /*enchant_spell_id*/, uint32& /*enchant_amount*/) { }
549550

551+
virtual void OnApplyWeaponDamage(Player* /*player*/, uint8 /*slot*/, ItemTemplate const* /*proto*/, float& /*minDamage*/, float& /*maxDamage*/, uint8 /*damageIndex*/) { }
552+
550553
[[nodiscard]] virtual bool CanArmorDamageModifier(Player* /*player*/) { return true; }
551554

552555
virtual void OnGetFeralApBonus(Player* /*player*/, int32& /*feral_bonus*/, int32 /*dpsMod*/, ItemTemplate const* /*proto*/, ScalingStatValuesEntry const* /*ssv*/) { }

src/server/game/Scripting/ScriptMgr.h

+1
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ class ScriptMgr
411411
void OnCustomScalingStatValue(Player* player, ItemTemplate const* proto, uint32& statType, int32& val, uint8 itemProtoStatNumber, uint32 ScalingStatValue, ScalingStatValuesEntry const* ssv);
412412
void OnApplyItemModsBefore(Player* player, uint8 slot, bool apply, uint8 itemProtoStatNumber, uint32 statType, int32& val);
413413
void OnApplyEnchantmentItemModsBefore(Player* player, Item* item, EnchantmentSlot slot, bool apply, uint32 enchant_spell_id, uint32& enchant_amount);
414+
void OnApplyWeaponDamage(Player* player, uint8 slot, ItemTemplate const* proto, float& minDamage, float& maxDamage, uint8 damageIndex);
414415
bool CanArmorDamageModifier(Player* player);
415416
void OnGetFeralApBonus(Player* player, int32& feral_bonus, int32 dpsMod, ItemTemplate const* proto, ScalingStatValuesEntry const* ssv);
416417
bool CanApplyWeaponDependentAuraDamageMod(Player* player, Item* item, WeaponAttackType attackType, AuraEffect const* aura, bool apply);

0 commit comments

Comments
 (0)