feat(core): add hooks for applying item mods (#18760)
This commit is contained in:
@@ -6584,6 +6584,8 @@ void Player::_ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply
|
|||||||
|
|
||||||
statType = proto->ItemStat[i].ItemStatType;
|
statType = proto->ItemStat[i].ItemStatType;
|
||||||
val = proto->ItemStat[i].ItemStatValue;
|
val = proto->ItemStat[i].ItemStatValue;
|
||||||
|
|
||||||
|
sScriptMgr->OnApplyItemModsBefore(this, slot, apply, i, statType, val);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (val == 0)
|
if (val == 0)
|
||||||
|
|||||||
@@ -4451,6 +4451,8 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sScriptMgr->OnApplyEnchantmentItemModsBefore(this, item, slot, apply, enchant_spell_id, enchant_amount);
|
||||||
|
|
||||||
LOG_DEBUG("entities.player.items", "Adding {} to stat nb {}", enchant_amount, enchant_spell_id);
|
LOG_DEBUG("entities.player.items", "Adding {} to stat nb {}", enchant_amount, enchant_spell_id);
|
||||||
switch (enchant_spell_id)
|
switch (enchant_spell_id)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -639,6 +639,16 @@ void ScriptMgr::OnCustomScalingStatValue(Player* player, ItemTemplate const* pro
|
|||||||
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CUSTOM_SCALING_STAT_VALUE, script->OnCustomScalingStatValue(player, proto, statType, val, itemProtoStatNumber, ScalingStatValue, ssv));
|
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_CUSTOM_SCALING_STAT_VALUE, script->OnCustomScalingStatValue(player, proto, statType, val, itemProtoStatNumber, ScalingStatValue, ssv));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnApplyItemModsBefore(Player* player, uint8 slot, bool apply, uint8 itemProtoStatNumber, uint32 statType, int32& val)
|
||||||
|
{
|
||||||
|
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_APPLY_ITEM_MODS_BEFORE, script->OnApplyItemModsBefore(player, slot, apply, itemProtoStatNumber, statType, val));
|
||||||
|
}
|
||||||
|
|
||||||
|
void ScriptMgr::OnApplyEnchantmentItemModsBefore(Player* player, Item* item, EnchantmentSlot slot, bool apply, uint32 enchant_spell_id, uint32& enchant_amount)
|
||||||
|
{
|
||||||
|
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_APPLY_ENCHANTMENT_ITEM_MODS_BEFORE, script->OnApplyEnchantmentItemModsBefore(player, item, slot, apply, enchant_spell_id, enchant_amount));
|
||||||
|
}
|
||||||
|
|
||||||
bool ScriptMgr::CanArmorDamageModifier(Player* player)
|
bool ScriptMgr::CanArmorDamageModifier(Player* player)
|
||||||
{
|
{
|
||||||
CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_ARMOR_DAMAGE_MODIFIER, !script->CanArmorDamageModifier(player));
|
CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_ARMOR_DAMAGE_MODIFIER, !script->CanArmorDamageModifier(player));
|
||||||
|
|||||||
@@ -146,6 +146,8 @@ enum PlayerHook
|
|||||||
PLAYERHOOK_ON_VICTIM_REWARD_AFTER,
|
PLAYERHOOK_ON_VICTIM_REWARD_AFTER,
|
||||||
PLAYERHOOK_ON_CUSTOM_SCALING_STAT_VALUE_BEFORE,
|
PLAYERHOOK_ON_CUSTOM_SCALING_STAT_VALUE_BEFORE,
|
||||||
PLAYERHOOK_ON_CUSTOM_SCALING_STAT_VALUE,
|
PLAYERHOOK_ON_CUSTOM_SCALING_STAT_VALUE,
|
||||||
|
PLAYERHOOK_ON_APPLY_ITEM_MODS_BEFORE,
|
||||||
|
PLAYERHOOK_ON_APPLY_ENCHANTMENT_ITEM_MODS_BEFORE,
|
||||||
PLAYERHOOK_CAN_ARMOR_DAMAGE_MODIFIER,
|
PLAYERHOOK_CAN_ARMOR_DAMAGE_MODIFIER,
|
||||||
PLAYERHOOK_ON_GET_FERAL_AP_BONUS,
|
PLAYERHOOK_ON_GET_FERAL_AP_BONUS,
|
||||||
PLAYERHOOK_CAN_APPLY_WEAPON_DEPENDENT_AURA_DAMAGE_MOD,
|
PLAYERHOOK_CAN_APPLY_WEAPON_DEPENDENT_AURA_DAMAGE_MOD,
|
||||||
@@ -542,6 +544,10 @@ public:
|
|||||||
|
|
||||||
virtual void OnCustomScalingStatValue(Player* /*player*/, ItemTemplate const* /*proto*/, uint32& /*statType*/, int32& /*val*/, uint8 /*itemProtoStatNumber*/, uint32 /*ScalingStatValue*/, ScalingStatValuesEntry const* /*ssv*/) { }
|
virtual void OnCustomScalingStatValue(Player* /*player*/, ItemTemplate const* /*proto*/, uint32& /*statType*/, int32& /*val*/, uint8 /*itemProtoStatNumber*/, uint32 /*ScalingStatValue*/, ScalingStatValuesEntry const* /*ssv*/) { }
|
||||||
|
|
||||||
|
virtual void OnApplyItemModsBefore(Player* /*player*/, uint8 /*slot*/, bool /*apply*/, uint8 /*itemProtoStatNumber*/, uint32 /*statType*/, int32& /*val*/) { }
|
||||||
|
|
||||||
|
virtual void OnApplyEnchantmentItemModsBefore(Player* /*player*/, Item* /*item*/, EnchantmentSlot /*slot*/, bool /*apply*/, uint32 /*enchant_spell_id*/, uint32& /*enchant_amount*/) { }
|
||||||
|
|
||||||
[[nodiscard]] virtual bool CanArmorDamageModifier(Player* /*player*/) { return true; }
|
[[nodiscard]] virtual bool CanArmorDamageModifier(Player* /*player*/) { return true; }
|
||||||
|
|
||||||
virtual void OnGetFeralApBonus(Player* /*player*/, int32& /*feral_bonus*/, int32 /*dpsMod*/, ItemTemplate const* /*proto*/, ScalingStatValuesEntry const* /*ssv*/) { }
|
virtual void OnGetFeralApBonus(Player* /*player*/, int32& /*feral_bonus*/, int32 /*dpsMod*/, ItemTemplate const* /*proto*/, ScalingStatValuesEntry const* /*ssv*/) { }
|
||||||
|
|||||||
@@ -412,6 +412,8 @@ public: /* PlayerScript */
|
|||||||
void OnVictimRewardAfter(Player* player, Player* victim, uint32& killer_title, uint32& victim_rank, float& honor_f);
|
void OnVictimRewardAfter(Player* player, Player* victim, uint32& killer_title, uint32& victim_rank, float& honor_f);
|
||||||
void OnCustomScalingStatValueBefore(Player* player, ItemTemplate const* proto, uint8 slot, bool apply, uint32& CustomScalingStatValue);
|
void OnCustomScalingStatValueBefore(Player* player, ItemTemplate const* proto, uint8 slot, bool apply, uint32& CustomScalingStatValue);
|
||||||
void OnCustomScalingStatValue(Player* player, ItemTemplate const* proto, uint32& statType, int32& val, uint8 itemProtoStatNumber, uint32 ScalingStatValue, ScalingStatValuesEntry const* ssv);
|
void OnCustomScalingStatValue(Player* player, ItemTemplate const* proto, uint32& statType, int32& val, uint8 itemProtoStatNumber, uint32 ScalingStatValue, ScalingStatValuesEntry const* ssv);
|
||||||
|
void OnApplyItemModsBefore(Player* player, uint8 slot, bool apply, uint8 itemProtoStatNumber, uint32 statType, int32& val);
|
||||||
|
void OnApplyEnchantmentItemModsBefore(Player* player, Item* item, EnchantmentSlot slot, bool apply, uint32 enchant_spell_id, uint32& enchant_amount);
|
||||||
bool CanArmorDamageModifier(Player* player);
|
bool CanArmorDamageModifier(Player* player);
|
||||||
void OnGetFeralApBonus(Player* player, int32& feral_bonus, int32 dpsMod, ItemTemplate const* proto, ScalingStatValuesEntry const* ssv);
|
void OnGetFeralApBonus(Player* player, int32& feral_bonus, int32 dpsMod, ItemTemplate const* proto, ScalingStatValuesEntry const* ssv);
|
||||||
bool CanApplyWeaponDependentAuraDamageMod(Player* player, Item* item, WeaponAttackType attackType, AuraEffect const* aura, bool apply);
|
bool CanApplyWeaponDependentAuraDamageMod(Player* player, Item* item, WeaponAttackType attackType, AuraEffect const* aura, bool apply);
|
||||||
|
|||||||
Reference in New Issue
Block a user