Fixes code according to modern code style. Fixes a few expression bugs.
This commit is contained in:
parent
89eea25e5f
commit
970fd563b2
3324 changed files with 441118 additions and 433755 deletions
|
|
@ -2,266 +2,267 @@ using System;
|
|||
|
||||
namespace Server.Items
|
||||
{
|
||||
[Flippable( 0x1070, 0x1074 )]
|
||||
public class TrainingDummy : AddonComponent
|
||||
{
|
||||
private Timer m_Timer;
|
||||
[Flippable(0x1070, 0x1074)]
|
||||
public class TrainingDummy : AddonComponent
|
||||
{
|
||||
private Timer m_Timer;
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public double MinSkill { get; set; }
|
||||
[Constructible]
|
||||
public TrainingDummy() : this(0x1074)
|
||||
{
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public double MaxSkill { get; set; }
|
||||
[Constructible]
|
||||
public TrainingDummy(int itemID) : base(itemID)
|
||||
{
|
||||
MinSkill = -25.0;
|
||||
MaxSkill = +25.0;
|
||||
}
|
||||
|
||||
[CommandProperty( AccessLevel.GameMaster )]
|
||||
public bool Swinging => ( m_Timer != null );
|
||||
public TrainingDummy(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public TrainingDummy() : this( 0x1074 )
|
||||
{
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public double MinSkill{ get; set; }
|
||||
|
||||
[Constructible]
|
||||
public TrainingDummy( int itemID ) : base( itemID )
|
||||
{
|
||||
MinSkill = -25.0;
|
||||
MaxSkill = +25.0;
|
||||
}
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public double MaxSkill{ get; set; }
|
||||
|
||||
public void UpdateItemID()
|
||||
{
|
||||
int baseItemID = (ItemID / 2) * 2;
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public bool Swinging => m_Timer != null;
|
||||
|
||||
ItemID = baseItemID + (Swinging ? 1 : 0);
|
||||
}
|
||||
public void UpdateItemID()
|
||||
{
|
||||
int baseItemID = ItemID / 2 * 2;
|
||||
|
||||
public void BeginSwing()
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
ItemID = baseItemID + (Swinging ? 1 : 0);
|
||||
}
|
||||
|
||||
m_Timer = new InternalTimer( this );
|
||||
m_Timer.Start();
|
||||
}
|
||||
public void BeginSwing()
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
|
||||
public void EndSwing()
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
m_Timer = new InternalTimer(this);
|
||||
m_Timer.Start();
|
||||
}
|
||||
|
||||
m_Timer = null;
|
||||
public void EndSwing()
|
||||
{
|
||||
m_Timer?.Stop();
|
||||
|
||||
UpdateItemID();
|
||||
}
|
||||
m_Timer = null;
|
||||
|
||||
public void OnHit()
|
||||
{
|
||||
UpdateItemID();
|
||||
Effects.PlaySound( GetWorldLocation(), Map, Utility.RandomList( 0x3A4, 0x3A6, 0x3A9, 0x3AE, 0x3B4, 0x3B6 ) );
|
||||
}
|
||||
UpdateItemID();
|
||||
}
|
||||
|
||||
public void Use( Mobile from, BaseWeapon weapon )
|
||||
{
|
||||
BeginSwing();
|
||||
public void OnHit()
|
||||
{
|
||||
UpdateItemID();
|
||||
Effects.PlaySound(GetWorldLocation(), Map, Utility.RandomList(0x3A4, 0x3A6, 0x3A9, 0x3AE, 0x3B4, 0x3B6));
|
||||
}
|
||||
|
||||
from.Direction = from.GetDirectionTo( GetWorldLocation() );
|
||||
weapon.PlaySwingAnimation( from );
|
||||
public void Use(Mobile from, BaseWeapon weapon)
|
||||
{
|
||||
BeginSwing();
|
||||
|
||||
from.CheckSkill( weapon.Skill, MinSkill, MaxSkill );
|
||||
}
|
||||
from.Direction = from.GetDirectionTo(GetWorldLocation());
|
||||
weapon.PlaySwingAnimation(from);
|
||||
|
||||
public override void OnDoubleClick( Mobile from )
|
||||
{
|
||||
BaseWeapon weapon = from.Weapon as BaseWeapon;
|
||||
from.CheckSkill(weapon.Skill, MinSkill, MaxSkill);
|
||||
}
|
||||
|
||||
if ( weapon is BaseRanged )
|
||||
SendLocalizedMessageTo( from, 501822 ); // You can't practice ranged weapons on this.
|
||||
else if ( weapon == null || !from.InRange( GetWorldLocation(), weapon.MaxRange ) )
|
||||
SendLocalizedMessageTo( from, 501816 ); // You are too far away to do that.
|
||||
else if ( Swinging )
|
||||
SendLocalizedMessageTo( from, 501815 ); // You have to wait until it stops swinging.
|
||||
else if ( from.Skills[weapon.Skill].Base >= MaxSkill )
|
||||
SendLocalizedMessageTo( from, 501828 ); // Your skill cannot improve any further by simply practicing with a dummy.
|
||||
else if ( from.Mounted )
|
||||
SendLocalizedMessageTo( from, 501829 ); // You can't practice on this while on a mount.
|
||||
else
|
||||
Use( from, weapon );
|
||||
}
|
||||
public override void OnDoubleClick(Mobile from)
|
||||
{
|
||||
BaseWeapon weapon = from.Weapon as BaseWeapon;
|
||||
|
||||
public TrainingDummy( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
if (weapon is BaseRanged)
|
||||
SendLocalizedMessageTo(from, 501822); // You can't practice ranged weapons on this.
|
||||
else if (weapon == null || !from.InRange(GetWorldLocation(), weapon.MaxRange))
|
||||
SendLocalizedMessageTo(from, 501816); // You are too far away to do that.
|
||||
else if (Swinging)
|
||||
SendLocalizedMessageTo(from, 501815); // You have to wait until it stops swinging.
|
||||
else if (from.Skills[weapon.Skill].Base >= MaxSkill)
|
||||
SendLocalizedMessageTo(from,
|
||||
501828); // Your skill cannot improve any further by simply practicing with a dummy.
|
||||
else if (from.Mounted)
|
||||
SendLocalizedMessageTo(from, 501829); // You can't practice on this while on a mount.
|
||||
else
|
||||
Use(from, weapon);
|
||||
}
|
||||
|
||||
public override void Serialize( GenericWriter writer )
|
||||
{
|
||||
base.Serialize( writer );
|
||||
public override void Serialize(GenericWriter writer)
|
||||
{
|
||||
base.Serialize(writer);
|
||||
|
||||
writer.Write( (int) 0 );
|
||||
writer.Write(0);
|
||||
|
||||
writer.Write( MinSkill );
|
||||
writer.Write( MaxSkill );
|
||||
}
|
||||
writer.Write(MinSkill);
|
||||
writer.Write(MaxSkill);
|
||||
}
|
||||
|
||||
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:
|
||||
{
|
||||
MinSkill = reader.ReadDouble();
|
||||
MaxSkill = reader.ReadDouble();
|
||||
switch (version)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
MinSkill = reader.ReadDouble();
|
||||
MaxSkill = reader.ReadDouble();
|
||||
|
||||
if ( MinSkill == 0.0 && MaxSkill == 30.0 )
|
||||
{
|
||||
MinSkill = -25.0;
|
||||
MaxSkill = +25.0;
|
||||
}
|
||||
if (MinSkill == 0.0 && MaxSkill == 30.0)
|
||||
{
|
||||
MinSkill = -25.0;
|
||||
MaxSkill = +25.0;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
UpdateItemID();
|
||||
}
|
||||
UpdateItemID();
|
||||
}
|
||||
|
||||
private class InternalTimer : Timer
|
||||
{
|
||||
private TrainingDummy m_Dummy;
|
||||
private bool m_Delay = true;
|
||||
private class InternalTimer : Timer
|
||||
{
|
||||
private bool m_Delay = true;
|
||||
private TrainingDummy m_Dummy;
|
||||
|
||||
public InternalTimer( TrainingDummy dummy ) : base( TimeSpan.FromSeconds( 0.25 ), TimeSpan.FromSeconds( 2.75 ) )
|
||||
{
|
||||
m_Dummy = dummy;
|
||||
Priority = TimerPriority.FiftyMS;
|
||||
}
|
||||
public InternalTimer(TrainingDummy dummy) : base(TimeSpan.FromSeconds(0.25), TimeSpan.FromSeconds(2.75))
|
||||
{
|
||||
m_Dummy = dummy;
|
||||
Priority = TimerPriority.FiftyMS;
|
||||
}
|
||||
|
||||
protected override void OnTick()
|
||||
{
|
||||
if ( m_Delay )
|
||||
m_Dummy.OnHit();
|
||||
else
|
||||
m_Dummy.EndSwing();
|
||||
protected override void OnTick()
|
||||
{
|
||||
if (m_Delay)
|
||||
m_Dummy.OnHit();
|
||||
else
|
||||
m_Dummy.EndSwing();
|
||||
|
||||
m_Delay = !m_Delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
m_Delay = !m_Delay;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TrainingDummyEastAddon : BaseAddon
|
||||
{
|
||||
public override BaseAddonDeed Deed => new TrainingDummyEastDeed();
|
||||
public class TrainingDummyEastAddon : BaseAddon
|
||||
{
|
||||
[Constructible]
|
||||
public TrainingDummyEastAddon()
|
||||
{
|
||||
AddComponent(new TrainingDummy(0x1074), 0, 0, 0);
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public TrainingDummyEastAddon()
|
||||
{
|
||||
AddComponent( new TrainingDummy( 0x1074 ), 0, 0, 0 );
|
||||
}
|
||||
public TrainingDummyEastAddon(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public TrainingDummyEastAddon( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override BaseAddonDeed Deed => new TrainingDummyEastDeed();
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public class TrainingDummyEastDeed : BaseAddonDeed
|
||||
{
|
||||
public override BaseAddon Addon => new TrainingDummyEastAddon();
|
||||
public override int LabelNumber => 1044335; // training dummy (east)
|
||||
public class TrainingDummyEastDeed : BaseAddonDeed
|
||||
{
|
||||
[Constructible]
|
||||
public TrainingDummyEastDeed()
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public TrainingDummyEastDeed()
|
||||
{
|
||||
}
|
||||
public TrainingDummyEastDeed(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public TrainingDummyEastDeed( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override BaseAddon Addon => new TrainingDummyEastAddon();
|
||||
public override int LabelNumber => 1044335; // training dummy (east)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public class TrainingDummySouthAddon : BaseAddon
|
||||
{
|
||||
public override BaseAddonDeed Deed => new TrainingDummySouthDeed();
|
||||
public class TrainingDummySouthAddon : BaseAddon
|
||||
{
|
||||
[Constructible]
|
||||
public TrainingDummySouthAddon()
|
||||
{
|
||||
AddComponent(new TrainingDummy(0x1070), 0, 0, 0);
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public TrainingDummySouthAddon()
|
||||
{
|
||||
AddComponent( new TrainingDummy( 0x1070 ), 0, 0, 0 );
|
||||
}
|
||||
public TrainingDummySouthAddon(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public TrainingDummySouthAddon( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override BaseAddonDeed Deed => new TrainingDummySouthDeed();
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
public class TrainingDummySouthDeed : BaseAddonDeed
|
||||
{
|
||||
public override BaseAddon Addon => new TrainingDummySouthAddon();
|
||||
public override int LabelNumber => 1044336; // training dummy (south)
|
||||
public class TrainingDummySouthDeed : BaseAddonDeed
|
||||
{
|
||||
[Constructible]
|
||||
public TrainingDummySouthDeed()
|
||||
{
|
||||
}
|
||||
|
||||
[Constructible]
|
||||
public TrainingDummySouthDeed()
|
||||
{
|
||||
}
|
||||
public TrainingDummySouthDeed(Serial serial) : base(serial)
|
||||
{
|
||||
}
|
||||
|
||||
public TrainingDummySouthDeed( Serial serial ) : base( serial )
|
||||
{
|
||||
}
|
||||
public override BaseAddon Addon => new TrainingDummySouthAddon();
|
||||
public override int LabelNumber => 1044336; // training dummy (south)
|
||||
|
||||
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
|
||||
}
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue