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


using System;
using Server;
using Server.Items;

namespace Server.Mobiles
{
	public class supremecreature
	{
		public static Map[] Maps         = new Map[]    // Maps that supremecreatures will spawn on
		{
			Map.Ilshenar,Map.Trammel,Map.Felucca,Map.Malas,Map.Tokuno
		};

		public static int    Hue   = 1;        // supremecreature hue
		
		// Buffs
		public static double HitsBuff   = 1000;  //added
		public static double HitsBuffMult   = 3; //multiplied 		
		public static double StrBuff    = 1000; //added
		public static double IntBuff    = 5;  //multiplied
		public static double ManaBuff = 500000; //added
		public static double DexBuff    = 10000; //added
		public static double SkillsBuff = 1.30;
		public static double FameBuff   = 1.90;
		public static double KarmaBuff  = 1.90;
		public static int DamageBuff = 7;
		
		
		public static void MaxOutSkill(Mobile bc, SkillName skill)
		{
		bc.Skills[skill].Base=bc.Skills[skill].Cap;
		}
		

		public static void Convert( BaseCreature bc )
		{
			if ( bc.IsSupreme )
				return;

			bc.Hue = Hue;

			if ( bc.HitsMaxSeed >= 0 )
				bc.HitsMaxSeed = (int)( bc.HitsMaxSeed*HitsBuffMult + HitsBuff );
				
			bc.ManaMaxSeed+=(int)ManaBuff;
			
			bc.RawStr = (int)( bc.RawStr + StrBuff );
			bc.RawInt = (int)( bc.RawInt * IntBuff );
			bc.RawDex = (int)( bc.RawDex + DexBuff );

			bc.Hits = bc.HitsMax;
			bc.Mana = bc.ManaMax;
			bc.Stam = bc.StamMax;

			
			MaxOutSkill(bc,SkillName.Magery);	
			MaxOutSkill(bc,SkillName.Spellweaving);	
			MaxOutSkill(bc,SkillName.Healing);	
			MaxOutSkill(bc,SkillName.Anatomy);	
			MaxOutSkill(bc,SkillName.Meditation);				
			MaxOutSkill(bc,SkillName.Wrestling);	
			MaxOutSkill(bc,SkillName.Tactics);	
			MaxOutSkill(bc,SkillName.EvalInt);			
			MaxOutSkill(bc,SkillName.Alchemy);			
			
			
			bc.AI=AIType.AI_Super;
			bc.FightMode=FightMode.Weakest;
			
			bc.DamageMin += DamageBuff;
			bc.DamageMax += DamageBuff;

			if ( bc.Fame > 0 )
				bc.Fame = (int)( bc.Fame * FameBuff );

			if ( bc.Fame > 32000 )
				bc.Fame = 32000;


			if ( bc.Karma != 0 )
			{
				bc.Karma = (int)( bc.Karma * KarmaBuff );

				if( Math.Abs( bc.Karma ) > 32000 )
					bc.Karma = 32000 * Math.Sign( bc.Karma );
			}
		}

		public static void UnConvert( BaseCreature bc )
		{
			if ( !bc.IsSupreme )
				return;

			bc.Hue = 0;

			if ( bc.HitsMaxSeed >= 0 )
				bc.HitsMaxSeed = (int)( (bc.HitsMaxSeed-HitsBuff)/HitsBuffMult );
				
			bc.ManaMaxSeed = (int)( bc.ManaMaxSeed - ManaBuff );
				
			
			bc.RawStr = (int)( bc.RawStr - StrBuff );
			bc.RawInt = (int)( bc.RawInt / IntBuff );
			bc.RawDex = (int)( bc.RawDex - DexBuff );

			bc.Hits = bc.HitsMax;
			bc.Mana = bc.ManaMax;
			bc.Stam = bc.StamMax;

			
			//we let skills slip by, they stay the same (no way to really know what they previously were)		
		

			bc.DamageMin -= DamageBuff;
			bc.DamageMax -= DamageBuff;

			if ( bc.Fame > 0 )
				bc.Fame = (int)( bc.Fame / FameBuff );
			if ( bc.Karma != 0 )
				bc.Karma = (int)( bc.Karma / KarmaBuff );
		}

		public static bool CheckConvert( BaseCreature bc )
		{
			return CheckConvert( bc, bc.Location, bc.Map );
		}
		
		
		public static bool CanBeSupreme(BaseCreature bc, Point3D location, Map m)
		{
			if ( Array.IndexOf( Maps, m ) == -1 )
				return false;

			if ( bc is BaseChampion || bc is Harrower || bc is BaseVendor || bc is BaseEscortable || bc is Clone || bc is basedemitel || bc is BaseHire || bc is Engines.Quests.BaseQuester)
				return false;
				
			if(bc.IsMLBoss || bc.CantbeSupreme)
				return false;
				
			if(bc.champmob)
				return false;
				
			if(bc.Region.IsPartOf("NewbieDungeon"))
				return false;
				
			if(bc.Region!=null && !bc.Region.CanSpawnSupreme(bc))return false;	
			
			return true;
		}
		

		public static bool CheckConvert( BaseCreature bc, Point3D location, Map m )
		{
			if(!CanBeSupreme(bc,location,m))return false;
				
			if(bc.Fame<=1500) return ( 0.0001 > Utility.RandomDouble() );

			return ( 0.0050 > Utility.RandomDouble() );
		}
	}
}