/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\items\misc\staff\banstick.cs
Lines of code: 85
***********************************************************/


using System;
using Server;
using Server.Network;
using Server.Mobiles;
using Server.Accounting;
using Server.Items;
using Server.Gumps;

namespace Server.Items
{
	public class banstick : Club
	{
	private int m_HitDisconnect;
	private int m_HitBan;
	
	
	[CommandProperty( AccessLevel.Administrator )]
	public int HitDisconnect
	{
	get{return m_HitDisconnect;}
	set{m_HitDisconnect=value;InvalidateProperties();Modify();}
	}
	
	[CommandProperty( AccessLevel.Administrator )]
	public int HitBan
	{
	get{return m_HitBan;}
	set{m_HitBan=value;InvalidateProperties();Modify();}	
	}	

	
	
	

		[Constructable]
		public banstick()
		{
			Name = "a ban stick";
            
			LootType = LootType.Blessed;
		
			Weight = 1000.0;	
		}
		
		
		
		public override void GetProperties( ObjectPropertyList list )
		{		
			base.GetProperties( list );
			
			if (HitDisconnect != 0 )
				list.Add(1060658,"{0}\t{1}","Hit Disconnect",HitDisconnect);		
		
			if (HitBan != 0 )
				list.Add(1060658,"{0}\t{1}","Hit Ban", HitBan);		
		}
		
		public override void OnHit( Mobile attacker, Mobile defender ,double damagebonus)
		{
		 base.OnHit( attacker, defender, 1.0 );
		
			if(attacker is PlayerMobile && attacker.AccessLevel < AccessLevel.Administrator)return;		
		
			if(defender is PlayerMobile)
			{
							
				if(m_HitBan>Utility.Random(100))
				{
				Effects.SendLocationParticles( EffectItem.Create( defender.Location, defender.Map, EffectItem.DefaultDuration ), 0x3728, 9, 20, 5042,0,0,0 );
				Effects.PlaySound( defender.Location, defender.Map, 0x201 );
				
				Account targAccount = defender.NetState.Account as Account;
				
				targAccount.Banned = true;
				targAccount.SetBanTags( attacker,DateTime.Now , TimeSpan.FromSeconds(10) );
				attacker.SendGump( new BanDurationGump( targAccount ) );			
				defender.Say("I was banned!");
				if(defender.NetState!=null)defender.NetState.Dispose();	
				}
				
				if(m_HitDisconnect>Utility.Random(100))
				{
				Effects.SendLocationParticles( EffectItem.Create( defender.Location, defender.Map, EffectItem.DefaultDuration ), 0x3728, 9, 20, 5042 );
				Effects.PlaySound( defender.Location, defender.Map, 0x201 );
				
				if(defender.NetState!=null)defender.NetState.Dispose();	
				
				if(defender.Map!=Map.Internal)defender.Map=Map.Internal;
				}
				
			}
		
		}		


		public banstick( Serial serial ) : base( serial )
		{
		}

		public override void Serialize( GenericWriter writer )
		{
			base.Serialize( writer );

			writer.Write( (int) 0 );
			
			writer.Write(m_HitDisconnect);
			writer.Write(m_HitBan);
			
		}
		
		public override void Deserialize(GenericReader reader)
		{
			base.Deserialize( reader );

			int version = reader.ReadInt();
			
			m_HitDisconnect=reader.ReadInt();
			m_HitBan=reader.ReadInt();
      	}
	}
}