/**********************************************************
RunUO AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by Death on Mar-31-2012 06:03:43pm
Filepath: scripts\events and scenarios\Long Live the King 2012\Britain Undead Invasions\HazardsAndCollisions\OilBarrel.cs
Lines of code: 61

Description: 

***********************************************************/


using System;
using Server.Items;
using Server.Mobiles;
using System.Collections;

namespace Server.Items
{

	public class OilBarrel : Item
	{
		[Constructable]
		public OilBarrel( ) : base(4014)
		{
			Hue=0;
			Name="Oil Barrel";
			Movable=false;		
		}
		
		public override bool CanBeTriggered{get{return true;} }		
		
		public override bool OnTrigger(Mobile from,Item itemfrom,TriggerType type)
		{
		
		if(type==TriggerType.Heat || type==TriggerType.Explosion) {
			Item oil = new BurningOil();
		
			for (int k = 0; k < Utility.RandomMinMax( 9, 14 ); k++ )
			{
				oil = new BurningOil();
				BurningOil oilburn = (BurningOil)oil;	
			
				if(k==0) oilburn.MoveToWorld( new Point3D( this.X, this.Y, this.Z), this.Map );
				else oilburn.MoveToWorld( new Point3D( this.X - Utility.RandomMinMax( -2, 2), this.Y - Utility.RandomMinMax( -2, 2), this.Z), this.Map );
			
				oilburn.StartBurn(from);
			}
		
			if(from!=null && from.InRange(this,15))from.SendMessage("The oil barrel expels a fury of flame");
		}
		else if (type==TriggerType.Impact && 0.3>Utility.RandomDouble()) {
			Item oil = new BurningOil();
		
			for (int k = 0; k < Utility.RandomMinMax( 9, 14 ); k++ )
			{
				oil = new BurningOil();
				if(k==0) oil.MoveToWorld( new Point3D( this.X, this.Y, this.Z), this.Map );
				else oil.MoveToWorld( new Point3D( this.X - Utility.RandomMinMax( -2, 2), this.Y - Utility.RandomMinMax( -2, 2), this.Z), this.Map );
			}
		
			if(from!=null && from.InRange(this,15))from.SendMessage("The oil barrel collapses, spreading forth a stream of flamable liquid");
		}
		else {
			return false;
		}

		this.Delete();
		return true;
		}

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

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

			writer.Write( (int) 1 ); 
		}

		public override void Deserialize( GenericReader reader )
		{
			base.Deserialize( reader );
			int version = reader.ReadInt();
		}
	}	
}