fix(spells): Fixes interruption of spells (#702)

This commit is contained in:
Kamron Batman 2021-08-18 12:17:42 -07:00 • committed by GitHub
parent 50dd7a1146
commit e6de7a5898
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 64 additions and 55 deletions

View file

@ -262,7 +262,7 @@ namespace Server.Mobiles
private readonly List<Type> m_SpellAttack; // List of attack spell/power
private readonly List<Type> m_SpellDefense; // List of defensive spell/power
private bool m_bSummoned;
private bool _summoned;
private bool m_bTamable;
private int m_ColdResistance;
@ -554,7 +554,7 @@ namespace Server.Mobiles
Summoned && m_ControlMaster != null &&
SummonFamiliarSpell.Table.TryGetValue(m_ControlMaster, out var bc) && bc == this;
public virtual bool DeleteCorpseOnDeath => !Core.AOS && m_bSummoned;
public virtual bool DeleteCorpseOnDeath => !Core.AOS && _summoned;
[CommandProperty(AccessLevel.GameMaster)]
public int Loyalty
@ -824,17 +824,17 @@ namespace Server.Mobiles
[CommandProperty(AccessLevel.Administrator)]
public bool Summoned
{
get => m_bSummoned;
get => _summoned;
set
{
if (m_bSummoned == value)
if (_summoned == value)
{
return;
}
NextReacquireTime = Core.TickCount;
m_bSummoned = value;
_summoned = value;
Delta(MobileDelta.Noto);
InvalidateProperties();
@ -855,7 +855,7 @@ namespace Server.Mobiles
public virtual bool CanRummageCorpses => false;
public virtual bool DeleteOnRelease => m_bSummoned;
public virtual bool DeleteOnRelease => _summoned;
public virtual bool CanDrop => IsBonded;
@ -1228,7 +1228,7 @@ namespace Server.Mobiles
return true;
}
return m_Team != c.m_Team || (m_bSummoned || m_Controlled) != (c.m_bSummoned || c.m_Controlled);
return m_Team != c.m_Team || (_summoned || m_Controlled) != (c._summoned || c.m_Controlled);
}
public override string ApplyNameSuffix(string suffix)
@ -1268,28 +1268,31 @@ namespace Server.Mobiles
public virtual double GetControlChance(Mobile m, bool useBaseSkill = false)
{
if (MinTameSkill <= 29.1 || m_bSummoned || m.AccessLevel >= AccessLevel.GameMaster)
if (MinTameSkill <= 29.1 || _summoned || m.AccessLevel >= AccessLevel.GameMaster)
{
return 1.0;
}
var dMinTameSkill = MinTameSkill;
var minTameSkill = MinTameSkill;
if (dMinTameSkill > -24.9 && AnimalTaming.CheckMastery(m, this))
if (minTameSkill > -24.9 && AnimalTaming.CheckMastery(m, this))
{
dMinTameSkill = -24.9;
minTameSkill = -24.9;
}
var taming =
(int)((useBaseSkill ? m.Skills.AnimalTaming.Base : m.Skills.AnimalTaming.Value) * 10);
var lore =
(int)((useBaseSkill ? m.Skills.AnimalLore.Base : m.Skills.AnimalLore.Value) * 10);
var taming = useBaseSkill
? m.Skills.AnimalTaming.BaseFixedPoint
: m.Skills.AnimalTaming.Fixed;
var lore = useBaseSkill
? m.Skills.AnimalLore.BaseFixedPoint
: m.Skills.AnimalLore.Fixed;
int bonus;
if (Core.ML)
{
var skillBonus = taming - (int)(dMinTameSkill * 10);
var loreBonus = lore - (int)(dMinTameSkill * 10);
var skillBonus = taming - (int)(minTameSkill * 10);
var loreBonus = lore - (int)(minTameSkill * 10);
var skillMod = 6;
var loreMod = 6;
@ -1311,7 +1314,7 @@ namespace Server.Mobiles
}
else
{
var difficulty = (int)(dMinTameSkill * 10);
var difficulty = (int)(minTameSkill * 10);
var weighted = (taming * 4 + lore) / 5;
bonus = weighted - difficulty;
@ -1325,20 +1328,11 @@ namespace Server.Mobiles
}
}
var chance = 700 + bonus;
if (chance > 990)
{
chance = 990;
}
else if (chance >= 0)
{
chance = 220;
}
var chance = Math.Clamp(700 + bonus, 220, 990);
chance -= (MaxLoyalty - m_Loyalty) * 10;
return (double)chance / 1000;
return chance / 1000.0;
}
public override void Damage(int amount, Mobile from = null, bool informMount = true)
@ -1732,9 +1726,9 @@ namespace Server.Mobiles
// Removed in version 9
// writer.Write( (double) m_dMaxTameSkill );
writer.Write(m_bTamable);
writer.Write(m_bSummoned);
writer.Write(_summoned);
if (m_bSummoned)
if (_summoned)
{
writer.WriteDeltaTime(SummonEnd);
}
@ -1899,9 +1893,9 @@ namespace Server.Mobiles
}
m_bTamable = reader.ReadBool();
m_bSummoned = reader.ReadBool();
_summoned = reader.ReadBool();
if (m_bSummoned)
if (_summoned)
{
SummonEnd = reader.ReadDeltaTime();
new UnsummonTimer(m_ControlMaster, this, SummonEnd - Core.Now).Start();
@ -2447,7 +2441,7 @@ namespace Server.Mobiles
}
}
if (aggressor.ChangingCombatant && (m_Controlled || m_bSummoned) &&
if (aggressor.ChangingCombatant && (m_Controlled || _summoned) &&
(ct == OrderType.Come || !Core.ML && ct == OrderType.Stay || ct == OrderType.Stop || ct == OrderType.None ||
ct == OrderType.Follow))
{
@ -3703,7 +3697,7 @@ namespace Server.Mobiles
return m_ControlMaster;
}
if (m_bSummoned && m_SummonMaster != null)
if (_summoned && m_SummonMaster != null)
{
return m_SummonMaster;
}
@ -4212,7 +4206,7 @@ namespace Server.Mobiles
public virtual bool IsFriend(Mobile m) =>
OppositionGroup?.IsEnemy(this, m) != true && m is BaseCreature c && m_Team == c.m_Team
&& (m_bSummoned || m_Controlled) == (c.m_bSummoned || c.m_Controlled);
&& (_summoned || m_Controlled) == (c._summoned || c.m_Controlled);
public virtual Allegiance GetFactionAllegiance(Mobile mob)
{