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;
|
||||
}
|
||||
|
||||
if (HandleSpellFocus(null, true))
|
||||
if (HasSpellFocusTarget())
|
||||
return true;
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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 DoNotReacquireTarget()
|
||||
|
||||
@@ -604,16 +604,16 @@ namespace Game.Entities
|
||||
switch (spellInfo.DmgClass)
|
||||
{
|
||||
case SpellDmgClass.Magic:
|
||||
{
|
||||
if (schoolMask.HasAnyFlag(SpellSchoolMask.Normal))
|
||||
crit_chance = 0.0f;
|
||||
// For other schools
|
||||
else if (IsTypeId(TypeId.Player))
|
||||
crit_chance = ToPlayer().m_activePlayerData.SpellCritPercentage;
|
||||
else
|
||||
crit_chance = BaseSpellCritChance;
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (schoolMask.HasAnyFlag(SpellSchoolMask.Normal))
|
||||
crit_chance = 0.0f;
|
||||
// For other schools
|
||||
else if (IsTypeId(TypeId.Player))
|
||||
crit_chance = ToPlayer().m_activePlayerData.SpellCritPercentage;
|
||||
else
|
||||
crit_chance = BaseSpellCritChance;
|
||||
break;
|
||||
}
|
||||
case SpellDmgClass.Melee:
|
||||
case SpellDmgClass.Ranged:
|
||||
crit_chance += GetUnitCriticalChanceDone(attackType);
|
||||
@@ -643,74 +643,74 @@ namespace Game.Entities
|
||||
switch (spellInfo.DmgClass)
|
||||
{
|
||||
case SpellDmgClass.Magic:
|
||||
{
|
||||
// taken
|
||||
if (!spellInfo.IsPositive())
|
||||
{
|
||||
// taken
|
||||
if (!spellInfo.IsPositive())
|
||||
{
|
||||
// Modify critical chance by victim SPELL_AURA_MOD_ATTACKER_SPELL_AND_WEAPON_CRIT_CHANCE
|
||||
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%
|
||||
var mOverrideClassScript = caster.GetAuraEffectsByType(AuraType.OverrideClassScripts);
|
||||
foreach (var eff in mOverrideClassScript)
|
||||
{
|
||||
if (!eff.IsAffectingSpell(spellInfo))
|
||||
continue;
|
||||
if (!eff.IsAffectingSpell(spellInfo))
|
||||
continue;
|
||||
|
||||
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)
|
||||
switch (eff.GetMiscValue())
|
||||
{
|
||||
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))
|
||||
case 911: // Shatter
|
||||
if (HasAuraState(AuraStateType.Frozen, spellInfo, this))
|
||||
{
|
||||
if (GetAuraEffect(AuraType.PeriodicDamage, SpellFamilyNames.Shaman, new FlagArray128(0x10000000, 0, 0), caster.GetGUID()) != null)
|
||||
if (GetTotalAuraModifier(AuraType.ModAttackerSpellAndWeaponCritChance) > -100)
|
||||
return 100.0f;
|
||||
break;
|
||||
crit_chance *= 1.5f;
|
||||
AuraEffect _eff = eff.GetBase().GetEffect(1);
|
||||
if (_eff != null)
|
||||
crit_chance += _eff.GetAmount();
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Spell crit suppression
|
||||
if (IsCreature())
|
||||
{
|
||||
int levelDiff = (int)(GetLevelForTarget(this) - caster.GetLevel());
|
||||
crit_chance -= levelDiff * 1.0f;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
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.Ranged:
|
||||
{
|
||||
if (caster != null)
|
||||
crit_chance += GetUnitCriticalChanceTaken(caster, attackType, crit_chance);
|
||||
break;
|
||||
}
|
||||
{
|
||||
if (caster != null)
|
||||
crit_chance += GetUnitCriticalChanceTaken(caster, attackType, crit_chance);
|
||||
break;
|
||||
}
|
||||
case SpellDmgClass.None:
|
||||
default:
|
||||
return 0f;
|
||||
@@ -1043,6 +1043,8 @@ namespace Game.Entities
|
||||
|
||||
public virtual bool HandleSpellFocus(Spell focusSpell = null, bool withDelay = false) { return false; }
|
||||
|
||||
public virtual bool HasSpellFocusTarget() { return false; }
|
||||
|
||||
/// <summary>
|
||||
/// Check if our current channel spell has attribute SPELL_ATTR5_CAN_CHANNEL_WHEN_MOVING
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user