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:
ariel-
2017-02-21 22:37:53 -03:00
committed by Shauren
parent 8e4f5e1627
commit 5f70be050f
5 changed files with 45 additions and 1 deletions

View File

@@ -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;

View File

@@ -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);
}
}

View File

@@ -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);

View File

@@ -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 */

View File

@@ -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();
}