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

@ -2,135 +2,141 @@ using System;
namespace Server.Items
{
public class FireworksWand : MagicWand
{
public override int LabelNumber => 1041424; // a fireworks wand
public class FireworksWand : MagicWand
{
private int m_Charges;
private int m_Charges;
[Constructible]
public FireworksWand() : this(100)
{
}
[CommandProperty( AccessLevel.GameMaster )]
public int Charges
{
get => m_Charges;
set{ m_Charges = value; InvalidateProperties(); }
}
[Constructible]
public FireworksWand(int charges)
{
m_Charges = charges;
LootType = LootType.Blessed;
}
[Constructible]
public FireworksWand() : this( 100 )
{
}
public FireworksWand(Serial serial) : base(serial)
{
}
[Constructible]
public FireworksWand( int charges )
{
m_Charges = charges;
LootType = LootType.Blessed;
}
public override int LabelNumber => 1041424; // a fireworks wand
public FireworksWand( Serial serial ) : base( serial )
{
}
[CommandProperty(AccessLevel.GameMaster)]
public int Charges
{
get => m_Charges;
set
{
m_Charges = value;
InvalidateProperties();
}
}
public override void AddNameProperties( ObjectPropertyList list )
{
base.AddNameProperties( list );
public override void AddNameProperties(ObjectPropertyList list)
{
base.AddNameProperties(list);
list.Add( 1060741, m_Charges.ToString() ); // charges: ~1_val~
}
list.Add(1060741, m_Charges.ToString()); // charges: ~1_val~
}
public override void OnDoubleClick( Mobile from )
{
BeginLaunch( from, true );
}
public override void OnDoubleClick(Mobile from)
{
BeginLaunch(from, true);
}
public void BeginLaunch( Mobile from, bool useCharges )
{
Map map = from.Map;
public void BeginLaunch(Mobile from, bool useCharges)
{
Map map = from.Map;
if ( map == null || map == Map.Internal )
return;
if (map == null || map == Map.Internal)
return;
if ( useCharges )
{
if ( Charges > 0 )
{
--Charges;
}
else
{
from.SendLocalizedMessage( 502412 ); // There are no charges left on that item.
return;
}
}
if (useCharges)
{
if (Charges > 0)
{
--Charges;
}
else
{
from.SendLocalizedMessage(502412); // There are no charges left on that item.
return;
}
}
from.SendLocalizedMessage( 502615 ); // You launch a firework!
from.SendLocalizedMessage(502615); // You launch a firework!
Point3D ourLoc = GetWorldLocation();
Point3D ourLoc = GetWorldLocation();
Point3D startLoc = new Point3D( ourLoc.X, ourLoc.Y, ourLoc.Z + 10 );
Point3D endLoc = new Point3D( startLoc.X + Utility.RandomMinMax( -2, 2 ), startLoc.Y + Utility.RandomMinMax( -2, 2 ), startLoc.Z + 32 );
Point3D startLoc = new Point3D(ourLoc.X, ourLoc.Y, ourLoc.Z + 10);
Point3D endLoc = new Point3D(startLoc.X + Utility.RandomMinMax(-2, 2), startLoc.Y + Utility.RandomMinMax(-2, 2),
startLoc.Z + 32);
Effects.SendMovingEffect( new Entity( Serial.Zero, startLoc, map ), new Entity( Serial.Zero, endLoc, map ),
0x36E4, 5, 0, false, false );
Effects.SendMovingEffect(new Entity(Serial.Zero, startLoc, map), new Entity(Serial.Zero, endLoc, map),
0x36E4, 5, 0, false, false);
Timer.DelayCall( TimeSpan.FromSeconds( 1.0 ), new TimerStateCallback( FinishLaunch ), new object[]{ from, endLoc, map } );
}
Timer.DelayCall(TimeSpan.FromSeconds(1.0), new TimerStateCallback(FinishLaunch),
new object[] { from, endLoc, map });
}
private void FinishLaunch( object state )
{
object[] states = (object[])state;
private void FinishLaunch(object state)
{
object[] states = (object[])state;
Mobile from = (Mobile)states[0];
Point3D endLoc = (Point3D)states[1];
Map map = (Map)states[2];
Mobile from = (Mobile)states[0];
Point3D endLoc = (Point3D)states[1];
Map map = (Map)states[2];
int hue = Utility.Random( 40 );
int hue = Utility.Random(40);
if ( hue < 8 )
hue = 0x66D;
else if ( hue < 10 )
hue = 0x482;
else if ( hue < 12 )
hue = 0x47E;
else if ( hue < 16 )
hue = 0x480;
else if ( hue < 20 )
hue = 0x47F;
else
hue = 0;
if (hue < 8)
hue = 0x66D;
else if (hue < 10)
hue = 0x482;
else if (hue < 12)
hue = 0x47E;
else if (hue < 16)
hue = 0x480;
else if (hue < 20)
hue = 0x47F;
else
hue = 0;
if ( Utility.RandomBool() )
hue = Utility.RandomList( 0x47E, 0x47F, 0x480, 0x482, 0x66D );
if (Utility.RandomBool())
hue = Utility.RandomList(0x47E, 0x47F, 0x480, 0x482, 0x66D);
int renderMode = Utility.RandomList( 0, 2, 3, 4, 5, 7 );
int renderMode = Utility.RandomList(0, 2, 3, 4, 5, 7);
Effects.PlaySound( endLoc, map, Utility.Random( 0x11B, 4 ) );
Effects.SendLocationEffect( endLoc, map, 0x373A + (0x10 * Utility.Random( 4 )), 16, 10, hue, renderMode );
}
Effects.PlaySound(endLoc, map, Utility.Random(0x11B, 4));
Effects.SendLocationEffect(endLoc, map, 0x373A + 0x10 * Utility.Random(4), 16, 10, hue, renderMode);
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write( (int) 0 ); // version
writer.Write(0); // version
writer.Write( (int) m_Charges );
}
writer.Write(m_Charges);
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
public override void Deserialize(GenericReader reader)
{
base.Deserialize(reader);
int version = reader.ReadInt();
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
m_Charges = reader.ReadInt();
break;
}
}
}
}
}
switch (version)
{
case 0:
{
m_Charges = reader.ReadInt();
break;
}
}
}
}
}