AvatarsConquest/Scripts/Items/Traps/DartTrap.cs

117 lines
No EOL
2.4 KiB
C#

using System;
using Server;
using Server.Network;
using Server.Mobiles;
namespace Server.Items
{
public enum DartTrapType
{
NorthWall,
WestWall
}
public class DartTrap : BaseTrap
{
private Poison m_Poison;
[CommandProperty( AccessLevel.GameMaster )]
public Poison Poison
{
get{ return m_Poison; }
set{ m_Poison = value; }
}
[CommandProperty( AccessLevel.GameMaster )]
public DartTrapType Type
{
get
{
if ( ItemID >= 0x0403 && ItemID <=0x0408 )
return DartTrapType.WestWall;
return DartTrapType.NorthWall;
}
set
{
ItemID = GetBaseID( value );
}
}
public static int GetBaseID( DartTrapType type )
{
if ( type ==DartTrapType.NorthWall )
return 0x063F;
return 0x0403;
}
[Constructable]
public DartTrap() : this( DartTrapType.NorthWall )
{
}
[Constructable]
public DartTrap( DartTrapType type ) : this( type, Poison.Lesser )
{
}
[Constructable]
public DartTrap( Poison poison ) : this( DartTrapType.NorthWall, Poison.Lesser )
{
}
[Constructable]
public DartTrap( DartTrapType type, Poison poison ) : base( GetBaseID( type ) )
{
m_Poison = poison;
Name = "dart trap";
}
public override bool PassivelyTriggered{ get{ return false; } }
public override TimeSpan PassiveTriggerDelay{ get{ return TimeSpan.Zero; } }
public override int PassiveTriggerRange{ get{ return 0; } }
public override TimeSpan ResetDelay{ get{ return TimeSpan.FromSeconds( 0.0 ); } }
public override void OnTrigger( Mobile from )
{
base.OnTrigger( from );
Effects.SendLocationEffect( Location, Map, GetBaseID( this.Type ) + 1, 18, 3, GetEffectHue(), 0 );
Effects.PlaySound( Location, Map, 0x224 );
from.ApplyPoison( from, m_Poison );
from.LocalOverheadMessage( MessageType.Regular, 0x22, 502380 ); // A dart imbeds itself in your flesh!
}
public DartTrap( Serial serial ) : base( serial )
{
}
public override void Serialize( GenericWriter writer )
{
base.Serialize( writer );
writer.Write( (int) 0 ); // version
Poison.Serialize( m_Poison, writer );
}
public override void Deserialize( GenericReader reader )
{
base.Deserialize( reader );
int version = reader.ReadInt();
switch ( version )
{
case 0:
{
m_Poison = Poison.Deserialize( reader );
break;
}
}
}
}
}