fix: Fixes spell durations for older expansions (#1119)

This commit is contained in:
Kamron Batman 2022-07-15 12:49:14 -07:00 • committed by GitHub
parent d6d02de296
commit 56c97ca84a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 68 additions and 59 deletions

View file

@ -69,8 +69,8 @@ namespace Server.Spells.Seventh
{
Caster.SendLocalizedMessage(501942); // That location is blocked.
}
else if (Core.SE && (GateExistsAt(map, loc) || GateExistsAt(Caster.Map, Caster.Location))
) // SE restricted stacking gates
// SE restricted stacking gates
else if (Core.SE && (GateExistsAt(map, loc) || GateExistsAt(Caster.Map, Caster.Location)))
{
Caster.SendLocalizedMessage(1071242); // There is already a gate there.
}
@ -127,7 +127,7 @@ namespace Server.Spells.Seventh
return SpellHelper.CheckTravel(Caster, TravelCheckType.GateFrom);
}
private bool GateExistsAt(Map map, Point3D loc)
private static bool GateExistsAt(Map map, Point3D loc)
{
var eable = map.GetItemsInRange(loc, 0);
@ -182,7 +182,7 @@ namespace Server.Spells.Seventh
{
private readonly Item m_Item;
public InternalTimer(Item item) : base(TimeSpan.FromSeconds(30.0))
public InternalTimer(Item item) : base(TimeSpan.FromSeconds(Core.T2A ? 30.0 : 10.0))
{
m_Item = item;
}

View file

@ -142,41 +142,44 @@ namespace Server.Spells.Seventh
if (CheckSequence())
{
if (caster.BeginAction<PolymorphSpell>())
{
if (m_NewBody != 0)
{
if (!((Body)m_NewBody).IsHuman)
{
var mt = caster.Mount;
if (mt != null)
{
mt.Rider = null;
}
}
caster.BodyMod = m_NewBody;
caster.HueMod = m_NewBody is 400 or 401 ? caster.Race.RandomSkinHue() : 0;
BaseArmor.ValidateMobile(caster);
BaseClothing.ValidateMobile(caster);
if (!Core.ML)
{
StopTimer(caster);
var duration = Math.Max((int)caster.Skills.Magery.Value, 120);
Timer.StartTimer(TimeSpan.FromSeconds(duration), () => EndPolymorph(caster), out var timerToken);
_table[caster] = timerToken;
}
}
}
else
if (!caster.BeginAction<PolymorphSpell>())
{
caster.SendLocalizedMessage(1005559); // This spell is already in effect.
return;
}
if (m_NewBody != 0)
{
if (!((Body)m_NewBody).IsHuman)
{
var mt = caster.Mount;
if (mt != null)
{
mt.Rider = null;
}
}
caster.BodyMod = m_NewBody;
caster.HueMod = m_NewBody is 400 or 401 ? caster.Race.RandomSkinHue() : 0;
BaseArmor.ValidateMobile(caster);
BaseClothing.ValidateMobile(caster);
if (!Core.ML)
{
StopTimer(caster);
var duration = Core.Expansion switch
{
Expansion.None => TimeSpan.FromSeconds(6 * caster.Skills.Magery.Value / 5.0),
_ => TimeSpan.FromSeconds(Math.Max(caster.Skills.Magery.Value, 120))
};
Timer.StartTimer(duration, () => EndPolymorph(caster), out var timerToken);
_table[caster] = timerToken;
}
}
}