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


using System;
using Server;
using Server.Mobiles;

namespace Server
{
	public class HarmItem
	{	
		//this function for use on harmful items that do not have a source mobile as damager

		public static bool ShouldHarm(Mobile m)
		{
		if(m.AccessLevel>AccessLevel.Player)return false;
		
		BaseCreature bc = m as BaseCreature;
			if(m==null || !m.Alive)return false;
			
			if(bc!=null)
			{
			if(!bc.Controlled && !bc.Summoned && bc.ControlMaster==null && bc.SummonMaster==null)return false;		
			}
		
		return true;
		}
		
		
		//this function to validate if something that happens at one Z index can affect something at another Z index
		
		public static bool ValidateZ(object a,object b)
		{
			const int tolerance=7;  //tolerate tiles up or down from origin object
			
			int Az=0,Bz=0;
			
			if(a is Item)Az=((Item)a).Z;
			else if(a is Mobile)Az=((Mobile)a).Z;
			
			if(b is Item)Bz=((Item)b).Z;
			else if(b is Mobile)Bz=((Mobile)b).Z;			
			
			if((Az>=Bz && (Az-Bz)<=tolerance) || (Bz>=Az && (Bz-Az)<=tolerance))return true;
			
			return false;
		}
		
		
		
	}
}

