Scripts/Spells: corrections to Death Knight spell Blood Mastery

Port From (https://github.com/TrinityCore/TrinityCore/commit/0c73895826f691b529026abddf4a64828e7c75ad)
This commit is contained in:
hondacrx
2021-03-17 21:16:32 -04:00
parent 4568cdad48
commit 97a89d0c8c
3 changed files with 90 additions and 14 deletions
+8 -2
View File
@@ -2903,7 +2903,7 @@ namespace Game.Entities
Log.outInfo(LogFilter.ServerLoading, "Loaded spell custom attributes in {0} ms", Time.GetMSTimeDiffToNow(oldMSTime));
}
public void LoadSpellInfoCorrections()
{
uint oldMSTime = Time.GetMSTime();
@@ -3001,7 +3001,8 @@ namespace Game.Entities
spellInfo.GetEffect(0).TriggerSpell = 39856;
break;
case 46736:// Personalized Weather
spellInfo.GetEffect(1).TriggerSpell = 46737;
spellInfo.GetEffect(0).TriggerSpell = 46737;
spellInfo.GetEffect(0).ApplyAuraName = AuraType.PeriodicTriggerSpell;
break;
case 63026: // Summon Aspirant Test NPC (HACK: Target shouldn't be changed)
case 63137: // Summon Valiant Test (HACK: Target shouldn't be changed; summon position should be untied from spell destination)
@@ -3227,6 +3228,10 @@ namespace Game.Entities
case 7853: // The Art of Being a Water Terror: Force Cast on Player
spellInfo.RangeEntry = CliDB.SpellRangeStorage.LookupByKey(13); // 50000yd
break;
case 28864:
case 29105:
spellInfo.GetEffect(0).RadiusEntry = CliDB.SpellRadiusStorage.LookupByKey(EffectRadiusIndex.Yards10);
break;
// VIOLET HOLD SPELLS
//
case 54258: // Water Globule (Ichoron)
@@ -3732,6 +3737,7 @@ namespace Game.Entities
switch (type)
{
case AuraType.Dummy:
case AuraType.PeriodicDummy:
case AuraType.ModConfuse:
case AuraType.ModThreat:
case AuraType.ModStun:
+65 -12
View File
@@ -17,10 +17,12 @@
using Framework.Constants;
using Game.Entities;
using Game.Networking.Packets;
using Game.Scripting;
using Game.Spells;
using System;
using System.Collections.Generic;
using Game.Networking.Packets;
using System.Linq;
namespace Scripts.Spells.DeathKnight
{
@@ -42,6 +44,7 @@ namespace Scripts.Spells.DeathKnight
public const uint DeathGripDummy = 243912;
public const uint DeathGripJump = 49575;
public const uint DeathGripTaunt = 51399;
public const uint DeathStrikeEnabler = 89832; //Server Side
public const uint DeathStrikeHeal = 45470;
public const uint DeathStrikeOffhand = 66188;
public const uint FesteringWound = 194310;
@@ -420,22 +423,34 @@ namespace Scripts.Spells.DeathKnight
{
public override bool Validate(SpellInfo spellInfo)
{
return ValidateSpellInfo(SpellIds.DeathStrikeHeal, SpellIds.BloodShieldMastery, SpellIds.BloodShieldAbsorb, SpellIds.RecentlyUsedDeathStrike, SpellIds.Frost, SpellIds.DeathStrikeOffhand);
return ValidateSpellInfo(SpellIds.DeathStrikeEnabler, SpellIds.DeathStrikeHeal, SpellIds.BloodShieldMastery, SpellIds.BloodShieldAbsorb, SpellIds.RecentlyUsedDeathStrike, SpellIds.Frost, SpellIds.DeathStrikeOffhand)
&& spellInfo.GetEffect(1) != null && spellInfo.GetEffect(2) != null;
}
void HandleHeal(uint effIndex)
void HandleDummy(uint effIndex)
{
Unit caster = GetCaster();
//Todo: heal = std::min(10% health, 20% of all damage taken in last 5 seconds)
int heal = (int)MathFunctions.CalculatePct(caster.GetMaxHealth(), GetSpellInfo().GetEffect(4).CalcValue());
caster.CastCustomSpell(SpellIds.DeathStrikeHeal, SpellValueMod.BasePoint0, heal, caster, true);
AuraEffect aurEff = caster.GetAuraEffect(SpellIds.BloodShieldMastery, 0);
if (aurEff != null)
caster.CastCustomSpell(SpellIds.BloodShieldAbsorb, SpellValueMod.BasePoint0, MathFunctions.CalculatePct(heal, aurEff.GetAmount()), caster);
AuraEffect enabler = caster.GetAuraEffect(SpellIds.DeathStrikeEnabler, 0, GetCaster().GetGUID());
if (enabler != null)
{
SpellInfo spellInfo = GetSpellInfo();
if (caster.HasAura(SpellIds.Frost))
caster.CastSpell(GetHitUnit(), SpellIds.DeathStrikeOffhand, true);
// Heals you for 25% of all damage taken in the last 5 sec,
int heal = MathFunctions.CalculatePct(enabler.CalculateAmount(GetCaster()), spellInfo.GetEffect(1).CalcValue(GetCaster()));
// minimum 7.0% of maximum health.
int pctOfMaxHealth = MathFunctions.CalculatePct(spellInfo.GetEffect(2).CalcValue(GetCaster()), caster.GetMaxHealth());
heal = Math.Max(heal, pctOfMaxHealth);
caster.CastCustomSpell(SpellIds.DeathStrikeHeal, SpellValueMod.BasePoint0, heal, caster, true);
AuraEffect aurEff = caster.GetAuraEffect(SpellIds.BloodShieldMastery, 0);
if (aurEff != null)
caster.CastCustomSpell(SpellIds.BloodShieldAbsorb, SpellValueMod.BasePoint0, MathFunctions.CalculatePct(heal, aurEff.GetAmount()), caster);
if (caster.HasAura(SpellIds.Frost))
caster.CastSpell(GetHitUnit(), SpellIds.DeathStrikeOffhand, true);
}
}
void TriggerRecentlyUsedDeathStrike()
@@ -445,11 +460,49 @@ namespace Scripts.Spells.DeathKnight
public override void Register()
{
OnEffectHitTarget.Add(new EffectHandler(HandleHeal, 1, SpellEffectName.WeaponPercentDamage));
OnEffectLaunch.Add(new EffectHandler(HandleDummy, 1, SpellEffectName.Dummy));
AfterCast.Add(new CastHandler(TriggerRecentlyUsedDeathStrike));
}
}
[Script] // 89832 - Death Strike Enabler - SPELL_DK_DEATH_STRIKE_ENABLER
class spell_dk_death_strike_enabler : AuraScript
{
// Amount of seconds we calculate damage over
uint[] _damagePerSecond = new uint[5];
bool CheckProc(ProcEventInfo eventInfo)
{
return eventInfo.GetDamageInfo() != null;
}
void Update(AuraEffect aurEff)
{
// Move backwards all datas by one from [23][0][0][0][0] -> [0][23][0][0][0]
_damagePerSecond = Enumerable.Range(1, _damagePerSecond.Length).Select(i => _damagePerSecond[i % _damagePerSecond.Length]).ToArray();
_damagePerSecond[0] = 0;
}
void HandleCalcAmount(AuraEffect aurEff, ref int amount, ref bool canBeRecalculated)
{
canBeRecalculated = true;
amount = Enumerable.Range(1, _damagePerSecond.Length).Sum();
}
void HandleProc(AuraEffect aurEff, ProcEventInfo eventInfo)
{
_damagePerSecond[0] += eventInfo.GetDamageInfo().GetDamage();
}
public override void Register()
{
DoCheckProc.Add(new CheckProcHandler(CheckProc));
OnEffectProc.Add(new EffectProcHandler(HandleProc, 0, AuraType.PeriodicDummy));
DoEffectCalcAmount.Add(new EffectCalcAmountHandler(HandleCalcAmount, 0, AuraType.PeriodicDummy));
OnEffectUpdatePeriodic.Add(new EffectUpdatePeriodicHandler(Update, 0, AuraType.PeriodicDummy));
}
}
[Script] // 85948 - Festering Strike
class spell_dk_festering_strike : SpellScript
{
@@ -0,0 +1,17 @@
-- 89832 Death Strike Enabler
DELETE FROM `serverside_spell` WHERE `Id` = 89832 AND `DifficultyID` = 0;
INSERT INTO `serverside_spell` (`Id`, `DifficultyID`, `SpellName`, `Attributes`, `CastingTimeIndex`, `ProcFlags`, `ProcChance`, `DurationIndex`, `RangeIndex`, `SchoolMask`) VALUES
(89832, 0, 'Death Strike Enabler', 0x1d0, 1 /* CastingTimeIndex: 0/0/0 */, 0xAAAA8 /*ProcFlags: Damage Taken */, 100 /*Proc Chance*/, 21 /*Duration: -1/0/-1 */, 1 /*Range: Self Only*/, 0x1 /* Physical */);
DELETE FROM `serverside_spell_effect` WHERE `SpellID` = 89832 AND `DifficultyID` = 0;
INSERT INTO `serverside_spell_effect` (`SpellID`, `EffectIndex`, `DifficultyID`, `Effect`, `EffectAura`, `EffectAuraPeriod`, `EffectChainAmplitude`, `ImplicitTarget1`) VALUES
(89832, 0, 0, 6 /* APPLY_AURA */, 226 /* PERIODIC_DUMMY */, 1000, 1, 1 /* Target: Caster */);
DELETE FROM `spell_script_names` WHERE `ScriptName` IN ('spell_dk_death_strike_enabler');
INSERT INTO `spell_script_names` (`spell_id`,`ScriptName`) VALUES
(89832, 'spell_dk_death_strike_enabler');
-- Link spells Death Knight (137005)
DELETE FROM `spell_linked_spell` WHERE `spell_trigger` = 137005 AND `spell_effect` = 89832 AND `type` = 2;
INSERT INTO `spell_linked_spell` (`spell_trigger`, `spell_effect`, `type`, `comment`) VALUES
(137005, 89832, 2, 'On Death Knight (passive) trigger Death Strike Enabler (Passive)');