Core/Creature: add a spell-focus-check method.
Port From (https://github.com/TrinityCore/TrinityCore/commit/44e9572a77061a8ddf04940f8e76f6585ad4ca05)
This commit is contained in:
@@ -1121,7 +1121,7 @@ namespace Game.Entities
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (HandleSpellFocus(null, true))
|
if (HasSpellFocusTarget())
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
if (HasUnitState(UnitState.Casting))
|
if (HasUnitState(UnitState.Casting))
|
||||||
@@ -3059,6 +3059,8 @@ namespace Game.Entities
|
|||||||
_spellFocusDelay = (!IsPet() && withDelay) ? GameTime.GetGameTimeMS() : 0; // don't allow re-target right away to prevent visual bugs
|
_spellFocusDelay = (!IsPet() && withDelay) ? GameTime.GetGameTimeMS() : 0; // don't allow re-target right away to prevent visual bugs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override bool HasSpellFocusTarget() { return IsAlive() && (_focusSpell != null || _spellFocusDelay != 0); }
|
||||||
|
|
||||||
public void MustReacquireTarget() { _shouldReacquireSpellFocusTarget = true; } // flags the Creature for forced (client displayed) target reacquisition in the next Update call
|
public void MustReacquireTarget() { _shouldReacquireSpellFocusTarget = true; } // flags the Creature for forced (client displayed) target reacquisition in the next Update call
|
||||||
|
|
||||||
public void DoNotReacquireTarget()
|
public void DoNotReacquireTarget()
|
||||||
|
|||||||
@@ -604,16 +604,16 @@ namespace Game.Entities
|
|||||||
switch (spellInfo.DmgClass)
|
switch (spellInfo.DmgClass)
|
||||||
{
|
{
|
||||||
case SpellDmgClass.Magic:
|
case SpellDmgClass.Magic:
|
||||||
{
|
{
|
||||||
if (schoolMask.HasAnyFlag(SpellSchoolMask.Normal))
|
if (schoolMask.HasAnyFlag(SpellSchoolMask.Normal))
|
||||||
crit_chance = 0.0f;
|
crit_chance = 0.0f;
|
||||||
// For other schools
|
// For other schools
|
||||||
else if (IsTypeId(TypeId.Player))
|
else if (IsTypeId(TypeId.Player))
|
||||||
crit_chance = ToPlayer().m_activePlayerData.SpellCritPercentage;
|
crit_chance = ToPlayer().m_activePlayerData.SpellCritPercentage;
|
||||||
else
|
else
|
||||||
crit_chance = BaseSpellCritChance;
|
crit_chance = BaseSpellCritChance;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SpellDmgClass.Melee:
|
case SpellDmgClass.Melee:
|
||||||
case SpellDmgClass.Ranged:
|
case SpellDmgClass.Ranged:
|
||||||
crit_chance += GetUnitCriticalChanceDone(attackType);
|
crit_chance += GetUnitCriticalChanceDone(attackType);
|
||||||
@@ -643,74 +643,74 @@ namespace Game.Entities
|
|||||||
switch (spellInfo.DmgClass)
|
switch (spellInfo.DmgClass)
|
||||||
{
|
{
|
||||||
case SpellDmgClass.Magic:
|
case SpellDmgClass.Magic:
|
||||||
|
{
|
||||||
|
// taken
|
||||||
|
if (!spellInfo.IsPositive())
|
||||||
{
|
{
|
||||||
// taken
|
// Modify critical chance by victim SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE
|
||||||
if (!spellInfo.IsPositive())
|
crit_chance += GetTotalAuraModifier(AuraType.ModAttackerSpellAndWeaponCritChance);
|
||||||
{
|
}
|
||||||
// Modify critical chance by victim SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE
|
|
||||||
crit_chance += GetTotalAuraModifier(AuraType.ModAttackerSpellAndWeaponCritChance);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (caster)
|
if (caster)
|
||||||
|
{
|
||||||
|
// scripted (increase crit chance ... against ... target by x%
|
||||||
|
var mOverrideClassScript = caster.GetAuraEffectsByType(AuraType.OverrideClassScripts);
|
||||||
|
foreach (var eff in mOverrideClassScript)
|
||||||
{
|
{
|
||||||
// scripted (increase crit chance ... against ... target by x%
|
if (!eff.IsAffectingSpell(spellInfo))
|
||||||
var mOverrideClassScript = caster.GetAuraEffectsByType(AuraType.OverrideClassScripts);
|
continue;
|
||||||
foreach (var eff in mOverrideClassScript)
|
|
||||||
{
|
|
||||||
if (!eff.IsAffectingSpell(spellInfo))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
switch (eff.GetMiscValue())
|
switch (eff.GetMiscValue())
|
||||||
{
|
|
||||||
case 911: // Shatter
|
|
||||||
if (HasAuraState(AuraStateType.Frozen, spellInfo, this))
|
|
||||||
{
|
|
||||||
crit_chance *= 1.5f;
|
|
||||||
AuraEffect _eff = eff.GetBase().GetEffect(1);
|
|
||||||
if (_eff != null)
|
|
||||||
crit_chance += _eff.GetAmount();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// Custom crit by class
|
|
||||||
switch (spellInfo.SpellFamilyName)
|
|
||||||
{
|
{
|
||||||
case SpellFamilyNames.Rogue:
|
case 911: // Shatter
|
||||||
// Shiv-applied poisons can't crit
|
if (HasAuraState(AuraStateType.Frozen, spellInfo, this))
|
||||||
if (caster.FindCurrentSpellBySpellId(5938) != null)
|
|
||||||
crit_chance = 0.0f;
|
|
||||||
break;
|
|
||||||
case SpellFamilyNames.Shaman:
|
|
||||||
// Lava Burst
|
|
||||||
if (spellInfo.SpellFamilyFlags[1].HasAnyFlag(0x00001000u))
|
|
||||||
{
|
{
|
||||||
if (GetAuraEffect(AuraType.PeriodicDamage, SpellFamilyNames.Shaman, new FlagArray128(0x10000000, 0, 0), caster.GetGUID()) != null)
|
crit_chance *= 1.5f;
|
||||||
if (GetTotalAuraModifier(AuraType.ModAttackerSpellAndWeaponCritChance) > -100)
|
AuraEffect _eff = eff.GetBase().GetEffect(1);
|
||||||
return 100.0f;
|
if (_eff != null)
|
||||||
break;
|
crit_chance += _eff.GetAmount();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
default:
|
||||||
|
break;
|
||||||
// Spell crit suppression
|
|
||||||
if (IsCreature())
|
|
||||||
{
|
|
||||||
int levelDiff = (int)(GetLevelForTarget(this) - caster.GetLevel());
|
|
||||||
crit_chance -= levelDiff * 1.0f;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
// Custom crit by class
|
||||||
|
switch (spellInfo.SpellFamilyName)
|
||||||
|
{
|
||||||
|
case SpellFamilyNames.Rogue:
|
||||||
|
// Shiv-applied poisons can't crit
|
||||||
|
if (caster.FindCurrentSpellBySpellId(5938) != null)
|
||||||
|
crit_chance = 0.0f;
|
||||||
|
break;
|
||||||
|
case SpellFamilyNames.Shaman:
|
||||||
|
// Lava Burst
|
||||||
|
if (spellInfo.SpellFamilyFlags[1].HasAnyFlag(0x00001000u))
|
||||||
|
{
|
||||||
|
if (GetAuraEffect(AuraType.PeriodicDamage, SpellFamilyNames.Shaman, new FlagArray128(0x10000000, 0, 0), caster.GetGUID()) != null)
|
||||||
|
if (GetTotalAuraModifier(AuraType.ModAttackerSpellAndWeaponCritChance) > -100)
|
||||||
|
return 100.0f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Spell crit suppression
|
||||||
|
if (IsCreature())
|
||||||
|
{
|
||||||
|
int levelDiff = (int)(GetLevelForTarget(this) - caster.GetLevel());
|
||||||
|
crit_chance -= levelDiff * 1.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
case SpellDmgClass.Melee:
|
case SpellDmgClass.Melee:
|
||||||
case SpellDmgClass.Ranged:
|
case SpellDmgClass.Ranged:
|
||||||
{
|
{
|
||||||
if (caster != null)
|
if (caster != null)
|
||||||
crit_chance += GetUnitCriticalChanceTaken(caster, attackType, crit_chance);
|
crit_chance += GetUnitCriticalChanceTaken(caster, attackType, crit_chance);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SpellDmgClass.None:
|
case SpellDmgClass.None:
|
||||||
default:
|
default:
|
||||||
return 0f;
|
return 0f;
|
||||||
@@ -1043,6 +1043,8 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public virtual bool HandleSpellFocus(Spell focusSpell = null, bool withDelay = false) { return false; }
|
public virtual bool HandleSpellFocus(Spell focusSpell = null, bool withDelay = false) { return false; }
|
||||||
|
|
||||||
|
public virtual bool HasSpellFocusTarget() { return false; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check if our current channel spell has attribute SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING
|
/// Check if our current channel spell has attribute SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user