Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 23 additions & 18 deletions GameServer/spells/SpellHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2495,13 +2495,15 @@ public virtual bool StartSpell(GameLiving target, InventoryItem item)
return StartSpell(target);
}

protected const int minHitChance = 55;
protected const int maxResistChance = 100 - minHitChance;

/// <summary>
/// Called when spell effect has to be started and applied to targets
/// This is typically called after calling CheckBeginCast
/// </summary>
/// <param name="target">The current target object</param>
public virtual bool StartSpell(GameLiving target)
/// <summary>
/// Called when spell effect has to be started and applied to targets
/// This is typically called after calling CheckBeginCast
/// </summary>
/// <param name="target">The current target object</param>
public virtual bool StartSpell(GameLiving target)
{
// For PBAOE spells always set the target to the caster
if (Spell.SpellType.ToLower() != "TurretPBAoE".ToLower() && (target == null || (Spell.Radius > 0 && Spell.Range == 0)))
Expand Down Expand Up @@ -2561,7 +2563,12 @@ public virtual bool StartSpell(GameLiving target)
&& Caster is GameNPC && (Caster as GameNPC).Brain is IOldAggressiveBrain)
((Caster as GameNPC).Brain as IOldAggressiveBrain).AddToAggroList(t, 1);

if (Util.Chance(CalculateSpellResistChance(t)))
int resistChance = CalculateSpellResistChance(t);

if (resistChance > maxResistChance)
resistChance = maxResistChance;

if (Util.Chance(resistChance))
{
OnSpellResisted(t);
continue;
Expand Down Expand Up @@ -3778,20 +3785,18 @@ public AttackData CalculateDamageToTarget(GameLiving target)
}


/// <summary>
/// Adjust damage based on chance to hit.
/// </summary>
/// <param name="damage"></param>
/// <param name="hitChance"></param>
/// <returns></returns>
public virtual int AdjustDamageForHitChance(int damage, int hitChance)
/// <summary>
/// Adjust damage based on chance to hit.
/// </summary>
/// <param name="damage"></param>
/// <param name="hitChance"></param>
/// <returns></returns>
public virtual int AdjustDamageForHitChance(int damage, int hitChance)
{
int adjustedDamage = damage;

if (hitChance < 55)
{
adjustedDamage += (int)(adjustedDamage * (hitChance - 55) * ServerProperties.Properties.SPELL_HITCHANCE_DAMAGE_REDUCTION_MULTIPLIER * 0.01);
}
if (hitChance < minHitChance)
adjustedDamage += (int)(adjustedDamage * (hitChance - minHitChance) * ServerProperties.Properties.SPELL_HITCHANCE_DAMAGE_REDUCTION_MULTIPLIER * 0.01);

return Math.Max(adjustedDamage, 1);
}
Expand Down