fix: Fixes PainSpike, ManaVampire, Evil Omen, and Curse (#1622)
Co-authored-by: Kamron Batman <3953314+kamronbatman@users.noreply.github.com>
This commit is contained in:
parent
fec78040bc
commit
4ebdc75bdf
9 changed files with 119 additions and 73 deletions
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Runtime.CompilerServices;
|
||||
using System.Threading;
|
||||
|
||||
namespace Server.Diagnostics;
|
||||
|
|
|
|||
|
|
@ -5884,7 +5884,7 @@ public partial class Mobile : IHued, IComparable<Mobile>, ISpawnable, IObjectPro
|
|||
|
||||
public virtual bool CanBeDamaged() => !m_Blessed;
|
||||
|
||||
public virtual void Damage(int amount, Mobile from = null, bool informMount = true)
|
||||
public virtual void Damage(int amount, Mobile from = null, bool informMount = true, bool ignoreEvilOmen = false)
|
||||
{
|
||||
if (amount <= 0)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1415,7 +1415,7 @@ namespace Server.Mobiles
|
|||
return chance / 1000.0;
|
||||
}
|
||||
|
||||
public override void Damage(int amount, Mobile from = null, bool informMount = true)
|
||||
public override void Damage(int amount, Mobile from = null, bool informMount = true, bool ignoreEvilOmen = false)
|
||||
{
|
||||
var oldHits = Hits;
|
||||
|
||||
|
|
|
|||
|
|
@ -2769,11 +2769,11 @@ namespace Server.Mobiles
|
|||
}
|
||||
}
|
||||
|
||||
public override void Damage(int amount, Mobile from = null, bool informMount = true)
|
||||
public override void Damage(int amount, Mobile from = null, bool informMount = true, bool ignoreEvilOmen = false)
|
||||
{
|
||||
var damageBonus = 1.0;
|
||||
|
||||
if (EvilOmenSpell.EndEffect(this) && !PainSpikeSpell.UnderEffect(this))
|
||||
if (EvilOmenSpell.EndEffect(this) && !ignoreEvilOmen)
|
||||
{
|
||||
damageBonus += 0.25;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -291,11 +291,14 @@ namespace Server.Spells
|
|||
caster,
|
||||
target,
|
||||
type,
|
||||
GetOffset(caster, target, type, false, skillCheck),
|
||||
duration
|
||||
GetOffset(caster, target, type, false),
|
||||
duration,
|
||||
skillCheck
|
||||
);
|
||||
|
||||
public static bool AddStatBonus(Mobile caster, Mobile target, StatType type, int bonus, TimeSpan duration)
|
||||
public static bool AddStatBonus(
|
||||
Mobile caster, Mobile target, StatType type, int bonus, TimeSpan duration, bool skillCheck = false
|
||||
)
|
||||
{
|
||||
var name = $"[Magic] {type} Buff";
|
||||
|
||||
|
|
@ -311,20 +314,37 @@ namespace Server.Spells
|
|||
target.RemoveStatMod(mod);
|
||||
}
|
||||
|
||||
if (skillCheck)
|
||||
{
|
||||
caster.CheckSkill(SkillName.EvalInt, 0.0, 120.0);
|
||||
}
|
||||
|
||||
target.AddStatMod(new StatMod(type, name, bonus, duration));
|
||||
return true;
|
||||
}
|
||||
|
||||
public static int GetCurse(Mobile caster, Mobile target, StatType type)
|
||||
{
|
||||
var name = $"[Magic] {type} Curse";
|
||||
|
||||
var mod = target.GetStatMod(name);
|
||||
|
||||
return mod?.Offset ?? 0;
|
||||
}
|
||||
|
||||
public static bool AddStatCurse(Mobile caster, Mobile target, StatType type, TimeSpan duration, bool skillCheck = true) =>
|
||||
AddStatCurse(
|
||||
caster,
|
||||
target,
|
||||
type,
|
||||
GetOffset(caster, target, type, true, skillCheck),
|
||||
duration
|
||||
GetOffset(caster, target, type, true),
|
||||
duration,
|
||||
skillCheck
|
||||
);
|
||||
|
||||
public static bool AddStatCurse(Mobile caster, Mobile target, StatType type, int curse, TimeSpan duration)
|
||||
public static bool AddStatCurse(
|
||||
Mobile caster, Mobile target, StatType type, int curse, TimeSpan duration, bool skillCheck = false
|
||||
)
|
||||
{
|
||||
var malus = -curse;
|
||||
var name = $"[Magic] {type} Curse";
|
||||
|
|
@ -341,6 +361,12 @@ namespace Server.Spells
|
|||
target.RemoveStatMod(mod);
|
||||
}
|
||||
|
||||
if (skillCheck)
|
||||
{
|
||||
caster.CheckSkill(SkillName.EvalInt, 0.0, 120.0);
|
||||
target.CheckSkill(SkillName.MagicResist, 0.0, 120.0);
|
||||
}
|
||||
|
||||
target.AddStatMod(new StatMod(type, name, malus, duration));
|
||||
return true;
|
||||
}
|
||||
|
|
@ -351,47 +377,29 @@ namespace Server.Spells
|
|||
|
||||
public static double GetOffsetScalar(Mobile caster, Mobile target, bool curse)
|
||||
{
|
||||
double percent;
|
||||
|
||||
if (curse)
|
||||
{
|
||||
percent = 8 + (caster.Skills.EvalInt.Value - target.Skills.MagicResist.Value) / 10;
|
||||
}
|
||||
else
|
||||
{
|
||||
percent = 1 + caster.Skills.EvalInt.Value / 10;
|
||||
}
|
||||
var percent = curse
|
||||
? 8 + (caster.Skills.EvalInt.Value - target.Skills.MagicResist.Value) / 10
|
||||
: 1 + caster.Skills.EvalInt.Value / 10;
|
||||
|
||||
percent *= 0.01;
|
||||
|
||||
return Math.Max(percent, 0);
|
||||
}
|
||||
|
||||
public static int GetOffset(Mobile caster, Mobile target, StatType type, bool curse, bool skillCheck)
|
||||
public static int GetOffset(Mobile caster, Mobile target, StatType type, bool curse)
|
||||
{
|
||||
if (!Core.AOS)
|
||||
{
|
||||
return 1 + (int)(caster.Skills.Magery.Value * 0.1);
|
||||
}
|
||||
|
||||
if (skillCheck)
|
||||
{
|
||||
caster.CheckSkill(SkillName.EvalInt, 0.0, 120.0);
|
||||
|
||||
if (curse)
|
||||
{
|
||||
target.CheckSkill(SkillName.MagicResist, 0.0, 120.0);
|
||||
}
|
||||
}
|
||||
|
||||
var percent = GetOffsetScalar(caster, target, curse);
|
||||
|
||||
return type switch
|
||||
{
|
||||
StatType.Str => (int)(target.RawStr * percent),
|
||||
StatType.Dex => (int)(target.RawDex * percent),
|
||||
StatType.Int => (int)(target.RawInt * percent),
|
||||
_ => 1 + (int)(caster.Skills.Magery.Value * 0.1)
|
||||
StatType.Int => (int)(target.RawInt * percent)
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ namespace Server.Spells.Fifth
|
|||
|
||||
if (Core.AOS)
|
||||
{
|
||||
var secs = (int)(GetDamageSkill(Caster) / 10 - GetResistSkill(m) / 10);
|
||||
var secs = (GetDamageSkill(Caster) / 10 - GetResistSkill(m) / 10);
|
||||
|
||||
if (!Core.AOS)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Server.Targeting;
|
||||
|
||||
|
|
@ -23,6 +24,66 @@ namespace Server.Spells.Fourth
|
|||
|
||||
public override SpellCircle Circle => SpellCircle.Fourth;
|
||||
|
||||
public static bool DoCurse(Mobile caster, Mobile m)
|
||||
{
|
||||
var duration = SpellHelper.GetDuration(caster, m);
|
||||
|
||||
if (duration == TimeSpan.Zero)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
// Allow curse duration to refresh if the new curse is longer
|
||||
if (_table.TryGetValue(m, out var existingTimer) && existingTimer.Next - Core.Now > duration && Core.AOS)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var newStrOffset = SpellHelper.GetOffset(caster, m, StatType.Str, true);
|
||||
var newDexOffset = SpellHelper.GetOffset(caster, m, StatType.Dex, true);
|
||||
var newIntOffset = SpellHelper.GetOffset(caster, m, StatType.Int, true);
|
||||
|
||||
if (newStrOffset == 0 && newDexOffset == 0 && newIntOffset == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var oldStrOffset = SpellHelper.GetCurse(caster, m, StatType.Str);
|
||||
var oldDexOffset = SpellHelper.GetCurse(caster, m, StatType.Dex);
|
||||
var oldIntOffset = SpellHelper.GetCurse(caster, m, StatType.Int);
|
||||
|
||||
if (oldStrOffset <= newStrOffset && oldDexOffset <= newDexOffset && oldIntOffset <= newIntOffset)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var strCurse = SpellHelper.AddStatCurse(caster, m, StatType.Str, newStrOffset, duration);
|
||||
var dexCurse = SpellHelper.AddStatCurse(caster, m, StatType.Dex, newDexOffset, duration);
|
||||
var intCurse = SpellHelper.AddStatCurse(caster, m, StatType.Int, newIntOffset, duration, true);
|
||||
|
||||
if (!strCurse && !dexCurse && !intCurse)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
existingTimer?.Stop();
|
||||
m.UpdateResistances();
|
||||
_table[m] = Timer.DelayCall(duration, mob => RemoveEffect(mob), m);
|
||||
|
||||
m.Spell?.OnCasterHurt();
|
||||
|
||||
m.Paralyzed = false;
|
||||
|
||||
m.FixedParticles(0x374A, 10, 15, 5028, EffectLayer.Waist);
|
||||
m.PlaySound(0x1E1);
|
||||
|
||||
var percentage = (int)(SpellHelper.GetOffsetScalar(caster, m, true) * 100);
|
||||
var args = $"{percentage}\t{percentage}\t{percentage}\t{10}\t{10}\t{10}\t{10}";
|
||||
|
||||
BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Curse, 1075835, 1075836, duration, m, args));
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Target(Mobile m)
|
||||
{
|
||||
if (CheckHSequence(m))
|
||||
|
|
@ -30,31 +91,15 @@ namespace Server.Spells.Fourth
|
|||
SpellHelper.Turn(Caster, m);
|
||||
|
||||
SpellHelper.CheckReflect((int)Circle, Caster, ref m);
|
||||
var length = SpellHelper.GetDuration(Caster, m);
|
||||
|
||||
SpellHelper.AddStatCurse(Caster, m, StatType.Str, length, false);
|
||||
SpellHelper.AddStatCurse(Caster, m, StatType.Dex, length);
|
||||
SpellHelper.AddStatCurse(Caster, m, StatType.Int, length);
|
||||
|
||||
if (Caster.Player && m.Player)
|
||||
if (DoCurse(Caster, m))
|
||||
{
|
||||
RemoveEffect(m);
|
||||
_table[m] = Timer.DelayCall(length, () => RemoveEffect(m));
|
||||
HarmfulSpell(m);
|
||||
}
|
||||
else
|
||||
{
|
||||
DoHurtFizzle();
|
||||
}
|
||||
|
||||
m.Spell?.OnCasterHurt();
|
||||
|
||||
m.Paralyzed = false;
|
||||
|
||||
m.FixedParticles(0x374A, 10, 15, 5028, EffectLayer.Waist);
|
||||
m.PlaySound(0x1E1);
|
||||
|
||||
var percentage = (int)(SpellHelper.GetOffsetScalar(Caster, m, true) * 100);
|
||||
var args = $"{percentage}\t{percentage}\t{percentage}\t{10}\t{10}\t{10}\t{10}";
|
||||
|
||||
BuffInfo.AddBuff(m, new BuffInfo(BuffIcon.Curse, 1075835, 1075836, length, m, args));
|
||||
|
||||
HarmfulSpell(m);
|
||||
}
|
||||
|
||||
FinishSequence();
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ namespace Server.Spells.Necromancy
|
|||
|
||||
// TODO: Find a better way to do this
|
||||
StaminaSystem.DFA = DFAlgorithm.PainSpike;
|
||||
m.Damage((int)damage, Caster);
|
||||
m.Damage((int)damage, Caster, ignoreEvilOmen: true);
|
||||
SpellHelper.DoLeech((int)damage, Caster, m);
|
||||
StaminaSystem.DFA = DFAlgorithm.Standard;
|
||||
|
||||
|
|
|
|||
|
|
@ -45,26 +45,20 @@ namespace Server.Spells.Seventh
|
|||
toDrain /= 2;
|
||||
}
|
||||
}
|
||||
else if (CheckResisted(m))
|
||||
{
|
||||
m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy.
|
||||
}
|
||||
else
|
||||
{
|
||||
if (CheckResisted(m))
|
||||
{
|
||||
m.SendLocalizedMessage(501783); // You feel yourself resisting magical energy.
|
||||
}
|
||||
else
|
||||
{
|
||||
toDrain = m.Mana;
|
||||
}
|
||||
toDrain = m.Mana;
|
||||
}
|
||||
|
||||
// Will not drain more than the target has currently and will not put the caster over his maximum mana
|
||||
toDrain = Math.Clamp(toDrain, 0, Math.Min(m.Mana, Caster.ManaMax - Caster.Mana));
|
||||
// Will not drain more than the target has currently
|
||||
toDrain = Math.Min(m.Mana, toDrain);
|
||||
m.Mana -= toDrain;
|
||||
|
||||
if (toDrain > 0)
|
||||
{
|
||||
m.Mana -= toDrain;
|
||||
Caster.Mana += toDrain;
|
||||
}
|
||||
Caster.Mana += toDrain;
|
||||
|
||||
if (Core.AOS)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue