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

@ -1,134 +1,139 @@
using System;
using Server.Engines.ConPVP;
using Server.Targeting;
namespace Server.Items
{
public class SnowPile : Item
{
[Constructible]
public SnowPile() : base( 0x913 )
{
Hue = 0x481;
Weight = 1.0;
LootType = LootType.Blessed;
}
public class SnowPile : Item
{
[Constructible]
public SnowPile() : base(0x913)
{
Hue = 0x481;
Weight = 1.0;
LootType = LootType.Blessed;
}
public override int LabelNumber => 1005578; // a pile of snow
public SnowPile(Serial serial) : base(serial)
{
}
public SnowPile( Serial serial ) : base( serial )
{
}
public override int LabelNumber => 1005578; // a pile of snow
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
public override void Serialize(GenericWriter writer)
{
base.Serialize(writer);
writer.Write( (int) 1 ); // version
}
writer.Write(1); // version
}
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();
if ( version == 0 )
{
Weight = 1.0;
LootType = LootType.Blessed;
}
}
if (version == 0)
{
Weight = 1.0;
LootType = LootType.Blessed;
}
}
public override void OnDoubleClick( Mobile from )
{
if ( !IsChildOf( from.Backpack ) )
{
from.SendLocalizedMessage( 1042010 ); // You must have the object in your backpack to use it.
}
else if ( from.Mounted )
from.SendLocalizedMessage ( 1010097 ); // You cannot use this while mounted.
public override void OnDoubleClick(Mobile from)
{
if (!IsChildOf(from.Backpack))
{
from.SendLocalizedMessage(1042010); // You must have the object in your backpack to use it.
}
else if (from.Mounted)
{
from.SendLocalizedMessage(1010097); // You cannot use this while mounted.
}
else if ( from.CanBeginAction( typeof( SnowPile ) ) )
{
from.SendLocalizedMessage( 1005575 ); // You carefully pack the snow into a ball...
from.Target = new SnowTarget( from, this );
}
else
{
from.SendLocalizedMessage( 1005574 ); // The snow is not ready to be packed yet. Keep trying.
}
}
else if (from.CanBeginAction(typeof(SnowPile)))
{
from.SendLocalizedMessage(1005575); // You carefully pack the snow into a ball...
from.Target = new SnowTarget(from, this);
}
else
{
from.SendLocalizedMessage(1005574); // The snow is not ready to be packed yet. Keep trying.
}
}
private class InternalTimer : Timer
{
private Mobile m_From;
private class InternalTimer : Timer
{
private Mobile m_From;
public InternalTimer( Mobile from ) : base( TimeSpan.FromSeconds( 5.0 ) )
{
m_From = from;
}
public InternalTimer(Mobile from) : base(TimeSpan.FromSeconds(5.0))
{
m_From = from;
}
protected override void OnTick()
{
m_From.EndAction( typeof( SnowPile ) );
}
}
protected override void OnTick()
{
m_From.EndAction(typeof(SnowPile));
}
}
private class SnowTarget : Target
{
private Mobile m_Thrower;
private Item m_Snow;
private class SnowTarget : Target
{
private Item m_Snow;
private Mobile m_Thrower;
public SnowTarget( Mobile thrower, Item snow ) : base ( 10, false, TargetFlags.None )
{
m_Thrower = thrower;
m_Snow = snow;
}
public SnowTarget(Mobile thrower, Item snow) : base(10, false, TargetFlags.None)
{
m_Thrower = thrower;
m_Snow = snow;
}
protected override void OnTarget( Mobile from, object target )
{
if ( target == from )
{
from.SendLocalizedMessage( 1005576 ); // You can't throw this at yourself.
}
else if ( target is Mobile targ )
{
Container pack = targ.Backpack;
protected override void OnTarget(Mobile from, object target)
{
if (target == from)
{
from.SendLocalizedMessage(1005576); // You can't throw this at yourself.
}
else if (target is Mobile targ)
{
Container pack = targ.Backpack;
if ( from.Region.IsPartOf( typeof( Engines.ConPVP.SafeZone ) ) || targ.Region.IsPartOf( typeof( Engines.ConPVP.SafeZone ) ) )
{
from.SendMessage( "You may not throw snow here." );
}
else if ( pack?.FindItemByType( new[]{ typeof( SnowPile ), typeof( PileOfGlacialSnow ) } ) != null )
{
if ( from.BeginAction( typeof( SnowPile ) ) )
{
new InternalTimer( from ).Start();
if (from.Region.IsPartOf(typeof(SafeZone)) || targ.Region.IsPartOf(typeof(SafeZone)))
{
from.SendMessage("You may not throw snow here.");
}
else if (pack?.FindItemByType(new[] { typeof(SnowPile), typeof(PileOfGlacialSnow) }) != null)
{
if (from.BeginAction(typeof(SnowPile)))
{
new InternalTimer(from).Start();
from.PlaySound( 0x145 );
from.PlaySound(0x145);
from.Animate( 9, 1, 1, true, false, 0 );
from.Animate(9, 1, 1, true, false, 0);
targ.SendLocalizedMessage( 1010572 ); // You have just been hit by a snowball!
from.SendLocalizedMessage( 1010573 ); // You throw the snowball and hit the target!
targ.SendLocalizedMessage(1010572); // You have just been hit by a snowball!
from.SendLocalizedMessage(1010573); // You throw the snowball and hit the target!
Effects.SendMovingEffect( from, targ, 0x36E4, 7, 0, false, true, 0x480, 0 );
}
else
{
from.SendLocalizedMessage( 1005574 ); // The snow is not ready to be packed yet. Keep trying.
}
}
else
{
from.SendLocalizedMessage( 1005577 ); // You can only throw a snowball at something that can throw one back.
}
}
else
{
from.SendLocalizedMessage( 1005577 ); // You can only throw a snowball at something that can throw one back.
}
}
}
}
}
Effects.SendMovingEffect(from, targ, 0x36E4, 7, 0, false, true, 0x480, 0);
}
else
{
from.SendLocalizedMessage(1005574); // The snow is not ready to be packed yet. Keep trying.
}
}
else
{
from.SendLocalizedMessage(
1005577); // You can only throw a snowball at something that can throw one back.
}
}
else
{
from.SendLocalizedMessage(
1005577); // You can only throw a snowball at something that can throw one back.
}
}
}
}
}