Fixes code according to modern code style. Fixes a few expression bugs.

This commit is contained in:
Kamron Batman 2018-09-15 09:58:51 -07:00
parent 89eea25e5f
commit 970fd563b2
3324 changed files with 441118 additions and 433755 deletions

View file

@ -4,122 +4,118 @@ using Server.Spells;
namespace Server.Items
{
public class IcyPatch : Item
{
public override int LabelNumber => 1095159; //An Icy Patch
public override double DefaultWeight => 5.0;
public class IcyPatch : Item
{
/* On OSI, the iceypatch with itemid 0x122a is "rarer", so we will give it 1:10 chance of creating it that way */
/* On OSI, the iceypatch with itemid 0x122a is "rarer", so we will give it 1:10 chance of creating it that way */
[Constructible]
public IcyPatch()
: this(Utility.Random(10) == 0 ? 0x122A : 0x122F)
{
}
[Constructible]
public IcyPatch()
: this((Utility.Random(10) == 0) ? 0x122A : 0x122F)
{
}
public IcyPatch(int itemid)
: base(itemid)
{
Hue = 0x481;
}
public IcyPatch(int itemid)
: base (itemid)
{
Hue = 0x481;
}
public IcyPatch(Serial serial)
: base(serial)
{
}
public IcyPatch(Serial serial)
: base(serial)
{
}
public override int LabelNumber => 1095159; //An Icy Patch
public override double DefaultWeight => 5.0;
public override bool OnMoveOver(Mobile m)
{
if (m is PlayerMobile && m.Alive && m.AccessLevel == AccessLevel.Player)
{
switch (Utility.Random(3))
{
case 0: RunSequence(m, 1095160, false); break; //You steadily walk over the slippery surface.
case 1: RunSequence(m, 1095161, true); break; //You skillfully manage to maintain your balance.
default: RunSequence(m, 1095162, true); break; //You lose your footing and ungracefully splatter on the ground.
}
}
return base.OnMoveOver(m);
}
public override bool OnMoveOver(Mobile m)
{
if (m is PlayerMobile && m.Alive && m.AccessLevel == AccessLevel.Player)
switch (Utility.Random(3))
{
case 0:
RunSequence(m, 1095160, false);
break; //You steadily walk over the slippery surface.
case 1:
RunSequence(m, 1095161, true);
break; //You skillfully manage to maintain your balance.
default:
RunSequence(m, 1095162, true);
break; //You lose your footing and ungracefully splatter on the ground.
}
return base.OnMoveOver(m);
}
public virtual void RunSequence(Mobile m, int message, bool freeze)
{
object[] arg = null;
public virtual void RunSequence(Mobile m, int message, bool freeze)
{
object[] arg = null;
if (freeze)
{
m.Frozen = freeze;
Timer.DelayCall(TimeSpan.FromSeconds((message==1095162) ? 2.0 : 1.25), new TimerStateCallback(EndFall_Callback), m);
}
if (freeze)
{
m.Frozen = freeze;
Timer.DelayCall(TimeSpan.FromSeconds(message == 1095162 ? 2.0 : 1.25),
new TimerStateCallback(EndFall_Callback), m);
}
m.SendLocalizedMessage(message);
m.SendLocalizedMessage(message);
if (message == 1095162)
{
if (m.Mounted)
{
m.Mount.Rider = null;
}
if (message == 1095162)
{
if (m.Mounted) m.Mount.Rider = null;
Point3D p = new Point3D(Location);
Point3D p = new Point3D(Location);
if (SpellHelper.FindValidSpawnLocation(Map, ref p, true))
{
Timer.DelayCall(TimeSpan.FromSeconds(0), new TimerStateCallback(Relocate_Callback), new object[] { m, p });
}
if (SpellHelper.FindValidSpawnLocation(Map, ref p, true))
Timer.DelayCall(TimeSpan.FromSeconds(0), new TimerStateCallback(Relocate_Callback),
new object[] { m, p });
arg = new object[] { m, (21 + Utility.Random(2)), !m.Female ? 0x426 : 0x317 };
}
else if (message == 1095161)
{
arg = new object[] { m, 17, !m.Female ? 0x429 : 0x319 };
}
if (arg != null)
{
Timer.DelayCall(TimeSpan.FromSeconds(.4), new TimerStateCallback(BeginFall_Callback), arg);
}
}
arg = new object[] { m, 21 + Utility.Random(2), !m.Female ? 0x426 : 0x317 };
}
else if (message == 1095161)
{
arg = new object[] { m, 17, !m.Female ? 0x429 : 0x319 };
}
private static void Relocate_Callback(object state)
{
object[] states = (object[])state;
Mobile m = (Mobile)states[0];
Point3D to = (Point3D)states[1];
if (arg != null) Timer.DelayCall(TimeSpan.FromSeconds(.4), new TimerStateCallback(BeginFall_Callback), arg);
}
m.MoveToWorld(to, m.Map);
}
private static void Relocate_Callback(object state)
{
object[] states = (object[])state;
Mobile m = (Mobile)states[0];
Point3D to = (Point3D)states[1];
private static void BeginFall_Callback(object state)
{
object[] states = (object[])state;
m.MoveToWorld(to, m.Map);
}
Mobile m = (Mobile)states[0];
int action = (int)states[1];
int sound = (int)states[2];
if (!m.Mounted)
{
m.Animate(action, 1, 1, false, true, 0);
}
m.PlaySound(sound);
}
private static void BeginFall_Callback(object state)
{
object[] states = (object[])state;
private static void EndFall_Callback(object state)
{
((Mobile)state).Frozen = false;
}
Mobile m = (Mobile)states[0];
int action = (int)states[1];
int sound = (int)states[2];
if (!m.Mounted) m.Animate(action, 1, 1, false, true, 0);
m.PlaySound(sound);
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
private static void EndFall_Callback(object state)
{
((Mobile)state).Frozen = false;
}
writer.Write((int)0);
}
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
writer.Write(0);
}
int version = reader.ReadInt();
}
}
}
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
}
}
}