fix: Removes duplicate stat offsets (#1293)
This commit is contained in:
parent
bd1db66858
commit
b1cfb10ef8
1 changed files with 19 additions and 9 deletions
|
|
@ -305,13 +305,18 @@ namespace Server.Spells
|
||||||
|
|
||||||
var mod = target.GetStatMod(name);
|
var mod = target.GetStatMod(name);
|
||||||
|
|
||||||
if (mod == null || mod.Offset < bonus)
|
if (mod != null)
|
||||||
{
|
{
|
||||||
target.AddStatMod(new StatMod(type, name, bonus - (mod?.Offset ?? 0), duration));
|
if (mod.Offset >= bonus)
|
||||||
return true;
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
target.RemoveStatMod(mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
target.AddStatMod(new StatMod(type, name, bonus, duration));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool AddStatCurse(Mobile caster, Mobile target, StatType type, TimeSpan duration, bool skillCheck = true) =>
|
public static bool AddStatCurse(Mobile caster, Mobile target, StatType type, TimeSpan duration, bool skillCheck = true) =>
|
||||||
|
|
@ -325,18 +330,23 @@ namespace Server.Spells
|
||||||
|
|
||||||
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)
|
||||||
{
|
{
|
||||||
var offset = -curse;
|
var malus = -curse;
|
||||||
var name = $"[Magic] {type} Curse";
|
var name = $"[Magic] {type} Curse";
|
||||||
|
|
||||||
var mod = target.GetStatMod(name);
|
var mod = target.GetStatMod(name);
|
||||||
|
|
||||||
if (mod == null || mod.Offset < offset)
|
if (mod != null)
|
||||||
{
|
{
|
||||||
target.AddStatMod(new StatMod(type, name, offset - (mod?.Offset ?? 0), duration));
|
if (mod.Offset <= malus)
|
||||||
return true;
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
target.RemoveStatMod(mod);
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
target.AddStatMod(new StatMod(type, name, malus, duration));
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TimeSpan GetDuration(Mobile caster, Mobile target) =>
|
public static TimeSpan GetDuration(Mobile caster, Mobile target) =>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue