mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Scripts: fix Nightfall proc chance and reduce it for victims with level above 60
Closes #15734
(cherrypicked from eac9c1f0b9)
This commit is contained in:
@@ -0,0 +1,3 @@
|
||||
DELETE FROM `item_script_names` WHERE `Id`=19169;
|
||||
INSERT INTO `item_script_names` (`Id`, `ScriptName`) VALUES (19169, 'item_generic_limit_chance_above_60');
|
||||
UPDATE `item_template_addon` SET `SpellPPMChance`='2.5' WHERE `Id`=19169;
|
||||
@@ -7978,7 +7978,7 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT
|
||||
else if (chance > 100.0f)
|
||||
chance = GetWeaponProcChance();
|
||||
|
||||
if (roll_chance_f(chance))
|
||||
if (roll_chance_f(chance) && sScriptMgr->OnCastItemCombatSpell(this, damageInfo.GetVictim(), spellInfo, item))
|
||||
CastSpell(damageInfo.GetVictim(), spellInfo->Id, true, item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1685,6 +1685,17 @@ bool ScriptMgr::OnItemRemove(Player* player, Item* item)
|
||||
return tmpscript->OnRemove(player, item);
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnCastItemCombatSpell(Player* player, Unit* victim, SpellInfo const* spellInfo, Item* item)
|
||||
{
|
||||
ASSERT(player);
|
||||
ASSERT(victim);
|
||||
ASSERT(spellInfo);
|
||||
ASSERT(item);
|
||||
|
||||
GET_SCRIPT_RET(ItemScript, item->GetScriptId(), tmpscript, true);
|
||||
return tmpscript->OnCastItemCombatSpell(player, victim, spellInfo, item);
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Creature* target)
|
||||
{
|
||||
ASSERT(caster);
|
||||
|
||||
@@ -52,6 +52,7 @@ class Player;
|
||||
class Quest;
|
||||
class ScriptMgr;
|
||||
class Spell;
|
||||
class SpellInfo;
|
||||
class SpellScript;
|
||||
class SpellCastTargets;
|
||||
class Transport;
|
||||
@@ -388,6 +389,9 @@ class TC_GAME_API ItemScript : public ScriptObject
|
||||
|
||||
// Called when the item is destroyed.
|
||||
virtual bool OnRemove(Player* /*player*/, Item* /*item*/) { return false; }
|
||||
|
||||
// Called before casting a combat spell from this item (chance on hit spells of item template, can be used to prevent cast if returning false)
|
||||
virtual bool OnCastItemCombatSpell(Player* /*player*/, Unit* /*victim*/, SpellInfo const* /*spellInfo*/, Item* /*item*/) { return true; }
|
||||
};
|
||||
|
||||
class TC_GAME_API UnitScript : public ScriptObject
|
||||
@@ -1028,6 +1032,7 @@ class TC_GAME_API ScriptMgr
|
||||
bool OnItemUse(Player* player, Item* item, SpellCastTargets const& targets, ObjectGuid castId);
|
||||
bool OnItemExpire(Player* player, ItemTemplate const* proto);
|
||||
bool OnItemRemove(Player* player, Item* item);
|
||||
bool OnCastItemCombatSpell(Player* player, Unit* victim, SpellInfo const* spellInfo, Item* item);
|
||||
|
||||
public: /* CreatureScript */
|
||||
|
||||
|
||||
@@ -414,6 +414,30 @@ public:
|
||||
}
|
||||
};
|
||||
|
||||
// Only used currently for
|
||||
// 19169: Nightfall
|
||||
class item_generic_limit_chance_above_60 : public ItemScript
|
||||
{
|
||||
public:
|
||||
item_generic_limit_chance_above_60() : ItemScript("item_generic_limit_chance_above_60") { }
|
||||
|
||||
bool OnCastItemCombatSpell(Player* player, Unit* victim, SpellInfo const* /*spellInfo*/, Item* /*item*/) override
|
||||
{
|
||||
// spell proc chance gets severely reduced on victims > 60 (formula unknown)
|
||||
if (victim->getLevel() > 60)
|
||||
{
|
||||
// gives ~0.1% proc chance at lvl 70
|
||||
float const lvlPenaltyFactor = 9.93f;
|
||||
float const failureChance = (victim->GetLevelForTarget(player) - 60) * lvlPenaltyFactor;
|
||||
|
||||
// base ppm chance was already rolled, only roll success chance
|
||||
return !roll_chance_f(failureChance);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
void AddSC_item_scripts()
|
||||
{
|
||||
new item_only_for_flight();
|
||||
@@ -427,4 +451,5 @@ void AddSC_item_scripts()
|
||||
new item_dehta_trap_smasher();
|
||||
new item_trident_of_nazjan();
|
||||
new item_captured_frog();
|
||||
new item_generic_limit_chance_above_60();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user