/**********************************************************
RunUO 2.0 AoV C# script file
Official Age of Valor Script :: www.uovalor.com
Last modified by 
Filepath: scripts\_custom\items\resources\Masterpiece Resources\_masterpieceresources.cs
Lines of code: 230
***********************************************************/


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

namespace Server.Misc
{
	public class mastres
	{
	private static Mobile killer;
	private static Mobile victim;
	
	private static PlayerMobile pm;
	private static BaseCreature bc;

		public static int ComputeAmount(int amt)
		{				
			
		if(victim.Map==Map.Felucca)amt*=2;	
			
		return amt;	
		}
	
		public static int ComputeAmount()
		{
		return ComputeAmount(1);
		}
	

			
		public static void HandleKill( Mobile pvictim, Mobile pkiller )
		{
			if(pvictim==null || pkiller==null)return;
			
			victim=pvictim;
			killer=pkiller;
			
			if(killer is BaseCreature)
			{
			BaseCreature killerbc = killer as BaseCreature;
			if(killerbc.ControlMaster!=null)killer=killerbc.ControlMaster;
			else if(killerbc.SummonMaster!=null)killer=killerbc.SummonMaster;			
			}
			
			
		
			pm = killer as PlayerMobile;
			bc = victim as BaseCreature;

			if( pm == null || bc == null || !killer.InRange( victim, 100 )) return;

			if( bc.Controlled || bc.Owners.Count > 0 || victim.Map!=killer.Map)	return; 
				
			double luckfactor = 1;
			if(killer!=null && killer is PlayerMobile)luckfactor = 1+(double)killer.Luck/500;
			if(luckfactor>3)luckfactor=3;  //max luck of about 1500
			
			int Fame=bc.Fame;
			if(Fame>25000)Fame=25000;
			
			double famefactor=1+((double)Fame/6000); 
			
		
	
			
			//START DROPS:	
			
			//Detriment Powder (All creatures within fame threshold)
			
			if(Fame>=10000)
			{
				if((0.03*luckfactor)>Utility.RandomDouble() && pm.Map != Map.Felucca)bc.PackItem( new LesserDetriment() ); 
				else if((0.03*luckfactor)>Utility.RandomDouble() && pm.Map == Map.Felucca)bc.PackItem( new GreaterDetriment() );
			}
			
			//Scales of Balance (All creatures within fame threshold)
			if(Fame>=8000)
			{
				if((0.0025*luckfactor)>Utility.RandomDouble())bc.PackItem( new ScalesOfBalance() ); 
			}
			
			//Ethereal Weaponry (All creatures within fame threshold)
			if(Fame>=12000)
			{
				if((0.02*luckfactor)>Utility.RandomDouble() && pm.Map != Map.Felucca)bc.PackItem( new EtherealWeaponry() ); 
			}
			
			//Ethereal Shielding (All creatures within fame threshold)
			if(Fame>=12000)
			{
				if((0.02*luckfactor)>Utility.RandomDouble() && pm.Map != Map.Felucca)bc.PackItem( new EtherealShielding() ); 
			}
			
			//Volcanic Aura (Fire creatures)

			if((0.02*luckfactor*famefactor)>Utility.RandomDouble() && (bc is LavaSnake ||bc is FireElemental ||bc is LavaLizard ||bc is FireSteed
			||bc is FireBeetle ||bc is FireGargoyle ||bc is Phoenix ||bc is Pyrolisk ||bc is humusminion ||bc is Pyre ||bc is LavaSnake || bc is MagmaSerpent))
			bc.PackItem(new VolcanicAura(ComputeAmount(1)));
			
			//Contaminating Slime (Poisonous creatures)
						
			if((0.02*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is Wyvern ||bc is PoisonIvySpawn ||bc is ToxicElemental || 
			bc is SilverSerpent ||bc is RottingCorpse ||bc is Betrayer ||bc is PlagueBeast ||bc is PlagueBeastLord ||bc is PoisonElemental ||
			bc is PoisonIvy ||bc is PhantomAsp ||bc is Putrefier || bc is Noxequus))
			bc.PackItem(new ContaminatingSlime(ComputeAmount(1)));
			
			//Withering Cold (Ice creatures)	
			
			if((0.02*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is IceElemental ||bc is FrostTroll ||bc is FrostBat || 
			bc is FrostBeetle ||bc is FrostSpider ||bc is WhiteWyrm ||bc is IceSerpent ||bc is GiantIceWorm ||bc is SnowElemental ||
			bc is ArcticOgreLord ||bc is IceDevil ||bc is IceFiend || bc is UnfrozenMummy))
			bc.PackItem(new WitheringCold(ComputeAmount(1)));		
			
			//Iron Force (Physical creatures)	
			
			if((0.02*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is Petralisk ||bc is Hiryu ||bc is LesserHiryu || 
			bc is Moloch ||bc is EarthElemental ||bc is OrcBrute ||bc is Minotaur ||bc is Reptalon ||bc is Rend ||bc is MinotaurScout ||bc is MinotaurCaptain ||bc is Juggernaut ||bc is ExodusOverseer ||bc is ExodusMinion ||bc is OgreLord ||bc is Cyclops || bc is Drake ||bc is Grim ||bc is StoneHarpy ||bc is StoneGargoyle ||bc is TsukiWolf || bc is CopperElemental ||bc is DullCopperElemental ||bc is GoldenElemental || bc is ShadowIronElemental ||bc is AgapiteElemental ||bc is VeriteElemental ||bc is ValoriteElemental))
			bc.PackItem(new IronForce(ComputeAmount(1)));	
			
			//Electric Storm (Energy Creatures)
			
			if((0.02*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is Coeurl ||bc is CuSidhe ||bc is Wisp || 
			bc is PrismCrystalDaemon ||bc is CrystalElemental ||bc is CrystalHydra ||bc is CrystalWisp ||bc is CrystalLatticeSeeker ||bc is CrystalVortex ||
			bc is RaiJu ||bc is WandererOfTheVoid || bc is Flurry || bc is Mistal || bc is Tempest || bc is SaintHorse))
			bc.PackItem(new ElectricStorm(ComputeAmount(1)));	
			
			//Mithril Ingot (Mine Creatures)
			
			if((0.035*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is EarthElemental || bc is CopperElemental ||bc is DullCopperElemental ||bc is GoldenElemental || bc is ShadowIronElemental ||bc is AgapiteElemental ||bc is VeriteElemental ||bc is ValoriteElemental ||bc is YomotsuWarrior ||bc is YomotsuPriest || bc is YomotsuElder))
			bc.PackItem(new MythrilIngot());	
			
			//Shimmering Light (Light expelling Creatures)
			
			if((0.07*luckfactor*famefactor)>Utility.RandomDouble() && (bc is Wisp ||bc is CrystalWisp ||bc is FireElemental || bc is ShadowWisp || bc is EnchantedBubble || bc is HordeMinion))
			bc.PackItem(new ShimmeringLight());
			
			//Soul of Fire (Fire creatures)

			if((0.01*luckfactor*famefactor)>Utility.RandomDouble() && (bc is LavaSnake ||bc is FireElemental ||bc is LavaLizard ||bc is FireSteed
			||bc is FireBeetle ||bc is FireGargoyle ||bc is Phoenix ||bc is Pyrolisk ||bc is humusminion ||bc is Pyre ||bc is LavaSnake || bc is MagmaSerpent))
			bc.PackItem(new SoulOfFire());
			
			//Spectre of Nox (Poisonous creatures)
						
			if((0.01*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is Wyvern ||bc is PoisonIvySpawn ||bc is ToxicElemental || 
			bc is SilverSerpent ||bc is RottingCorpse ||bc is Betrayer ||bc is PlagueBeast ||bc is PlagueBeastLord ||bc is PoisonElemental ||
			bc is PoisonIvy ||bc is PhantomAsp ||bc is Putrefier || bc is Noxequus))
			bc.PackItem(new SpectreOfNox());
			
			//Essence Of Frost (Ice creatures)	
			
			if((0.01*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is IceElemental ||bc is FrostTroll ||bc is FrostBat || 
			bc is FrostBeetle ||bc is FrostSpider ||bc is WhiteWyrm ||bc is IceSerpent ||bc is GiantIceWorm ||bc is SnowElemental ||
			bc is ArcticOgreLord ||bc is IceDevil ||bc is IceFiend || bc is UnfrozenMummy))
			bc.PackItem(new EssenceOfFrost());		
			
			//Spirit Of Rock (Physical creatures)	
			
			if((0.01*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is Petralisk ||bc is Hiryu ||bc is LesserHiryu || 
			bc is Moloch ||bc is EarthElemental ||bc is OrcBrute ||bc is Minotaur ||bc is Reptalon ||bc is Rend ||bc is MinotaurScout ||bc is MinotaurCaptain ||bc is Juggernaut ||bc is ExodusOverseer ||bc is ExodusMinion ||bc is OgreLord ||bc is Cyclops ||bc is Drake ||bc is Grim ||bc is StoneHarpy ||bc is StoneGargoyle ||bc is TsukiWolf))
			bc.PackItem(new SpiritOfRock());	
			
			//Ghost Of Energy (Energy Creatures)
			
			if((0.01*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is Coeurl ||bc is CuSidhe ||bc is Wisp || 
			bc is PrismCrystalDaemon ||bc is CrystalElemental ||bc is CrystalHydra ||bc is CrystalWisp ||bc is CrystalLatticeSeeker ||bc is CrystalVortex ||
			bc is RaiJu ||bc is WandererOfTheVoid))
			bc.PackItem(new GhostOfEnergy());
			
			//Lucky Clovers (Plant creatures)	
			
			if((0.02*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is PoisonIvy ||bc is PoisonIvySpawn ||bc is Quagmire || 
			bc is Bogling ||bc is BogThing ||bc is tangle ||bc is WhippingVine ||bc is Reaper ||bc is Faleryn ||bc is Corpser ||bc is SwampTentacle))
			bc.PackItem(new LuckyClovers(ComputeAmount(2)));	
			
			//Pearls of Speed (Fast creatures)	
			
			if((0.015*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is Berserker ||bc is PhantomAsp || 
			bc is Minotaur ||bc is MinotaurScout ||bc is MinotaurCaptain ||bc is hydra ||bc is Miasma ||bc is Scylla ||bc is Lorkest ||bc is PlagueBeastLord ||bc is Virulent ||bc is abscess ||bc is SilverSerpent || bc is thrasher || bc is Grobu))
			bc.PackItem(new SpeedPearls(ComputeAmount(1)));
			
			//Captured Dark Soul (Drain creatures)	
			
			if((0.01*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is Vampire ||bc is Succubus || 
			bc is BloodBeast ||bc is SirPatrick ||bc is HarrowerTentacles || bc is CrystalLatticeSeeker))
			bc.PackItem(new CapturedDarkSoul(ComputeAmount(1)));
			
			//Essence Of Dispelling (Mage creatures)	
			
			if((0.015*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is Lich ||bc is LichLord || 
			bc is AncientLich ||bc is BoneMagi ||bc is EvilMage ||bc is EvilMageLord ||bc is SkeletalMage || bc is RatmanMage ||bc is OrcishMage ||bc is KhaldunSummoner ||bc is SeaHag ||bc is MasterMikael ||bc is MasterJonath ||bc is MasterTheophilus))
			bc.PackItem(new EssenceOfDispelling(ComputeAmount(2)));	
			
			//Draught of Alchemy (Mage creatures)	
			
			if((0.015*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is Lich ||bc is LichLord || 
			bc is AncientLich ||bc is BoneMagi ||bc is EvilMage ||bc is EvilMageLord ||bc is SkeletalMage || bc is RatmanMage ||bc is OrcishMage ||bc is KhaldunSummoner ||bc is SeaHag ||bc is MasterMikael ||bc is MasterJonath ||bc is MasterTheophilus))
			bc.PackItem(new DraughtOfAlchemy(ComputeAmount(2)));	
			
			//Surrendering Attack (Jukas)
			
			if((0.025*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is JukaLord ||bc is JukaMage ||bc is JukaWarrior))
			bc.PackItem(new SurrenderingAttack(ComputeAmount(1)));	
			
			//Surrendering Defense (Meer)
			
			if((0.025*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is MeerMage ||bc is MeerCaptain ||bc is MeerEternal ||bc is MeerWarrior))
			bc.PackItem(new SurrenderingDefense(ComputeAmount(1)));	
			
			//Captured Mage Soul (Powerful mage creatures)
			
			if((0.01*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is AncientLich ||bc is SeaHag ||bc is BlackOrderMage ||bc is BlackOrderGrandMage ||bc is MasterTheophilus ||bc is MasterMikael ||bc is MasterJonath))
			bc.PackItem(new CapturedMageSoul(ComputeAmount(1)));
			
			//Captured Light Soul (Greater Fey)
			
			if((0.01*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is EtherealWarrior ||bc is LordOaks || 
			bc is Silvani ||bc is SaintHorse || bc is Fairy))
			bc.PackItem(new CapturedLightSoul(ComputeAmount(1)));
			
			//Potion of Repair (Armor corroders)
			
			if((0.005*luckfactor*famefactor)>Utility.RandomDouble() &&  (bc is ToxicElemental ||bc is RuneBeetle ||bc is InterredGrizzle))
			bc.PackItem(new PotionOfRepair());	
			
			if(killer!=null && killer is PlayerMobile)luckfactor = 1+(double)killer.Luck/1500;
			if(luckfactor>1)luckfactor=1;  //max luck of about 1500
			if((0.005*luckfactor*famefactor)>Utility.RandomDouble() && (bc is CorrosiveSlime))
			bc.PackItem(new PotionOfRepair());	
			
			
			
			//supremes
			if(bc.IsSupreme)
			{
			int AMT = (bc.Fame/4000)+Utility.Random(bc.Fame/4000);
			
			if (AMT > 7) AMT = 7;
			
			int Uncommons = 0, Rares = 0;
			
			
				for ( int j = 0; j < AMT; j++ )
				{
					switch ( Utility.Random( 18 ))
					{                                   
						case 0: bc.PackItem ( new LesserDetriment( Utility.Random(2,5) )); break;   
						case 1: bc.PackItem ( new GreaterDetriment( Utility.Random(2,5) )); break;
						case 2: bc.PackItem ( new VolcanicAura( Utility.Random(1,3) )); break;
						case 3: bc.PackItem ( new ContaminatingSlime( Utility.Random(1,3) )); break;    
						case 4: bc.PackItem ( new WitheringCold( Utility.Random(1,3) )); break;   
						case 5: bc.PackItem ( new IronForce( Utility.Random(1,3) )); break;  
						case 6: bc.PackItem ( new ElectricStorm( Utility.Random(1,3) )); break;
						case 7: bc.PackItem ( new ShimmeringLight()); break;    
						case 8: bc.PackItem ( new MythrilIngot());break;   
						case 9: bc.PackItem ( new SoulOfFire()); break;  
						case 10: bc.PackItem ( new EssenceOfFrost()); break;
						case 11: bc.PackItem ( new SpectreOfNox()); break;    
						case 12: bc.PackItem ( new SpiritOfRock());break;   
						case 13: bc.PackItem ( new GhostOfEnergy()); break;  
						case 14: bc.PackItem ( new LuckyClovers( Utility.Random(1,5) )); break;
						case 15: bc.PackItem ( new SurrenderingAttack( Utility.Random(1,2) )); break;  
						case 16: bc.PackItem ( new SurrenderingDefense( Utility.Random(1,2) )); break;
						case 17: bc.PackItem ( new DraughtOfAlchemy( Utility.Random(1,3) )); break;
					}	
				}		
				
				if ( Fame >= 30000 )
				{
					Uncommons = 5;
					Rares = 1;
				}
				else if ( Fame >= 20000)
				{
					Uncommons = 4;
				}
				else if ( Fame >= 15000)
				{
					Uncommons = 3;
				}
				else if (Fame >= 10000)
				{	
					Uncommons = 2;
				}
				else if (Fame >= 5000)
				{
					Uncommons = 1;
				}
				
				for ( int k = 0; k < Uncommons; k++ )
				{
					switch ( Utility.Random( 17 ))
					{                                   
						case 0: bc.PackItem ( new PiercingFrostbite( Utility.Random(1,3) ));break; 
						case 1: bc.PackItem ( new SpeedPearls( Utility.Random(1,3) )); break;    
						case 2: bc.PackItem ( new EtherealShielding( Utility.Random(1,2) ));break; 
						case 3: bc.PackItem ( new EtherealWeaponry( Utility.Random(1,2) ));break; 
						case 4: bc.PackItem ( new ScalesOfBalance()); break;
						case 5: bc.PackItem ( new OrbOfElements()); break;
						case 6: bc.PackItem ( new HealthyPearls( Utility.Random(1,2) )); break;						
						case 7: bc.PackItem ( new CapturedDarkSoul( Utility.Random(1,3) ));break;  
						case 8: bc.PackItem ( new CapturedMageSoul( Utility.Random(1,3) ));break; 
						case 9: bc.PackItem ( new CapturedLightSoul( Utility.Random(1,3) ));break; 
						case 10: bc.PackItem ( new ConflagrantArrow( Utility.Random(1,3) ));break;  
						case 11: bc.PackItem ( new RagingThunderstorm( Utility.Random(1,3) ));break; 
						case 12: bc.PackItem ( new BlazingInferno( Utility.Random(1,3) ));break; 
						case 13: bc.PackItem ( new HerbsOfStamina( Utility.Random(1,2) )); break;
						case 14: bc.PackItem ( new PotionOfRepair( Utility.Random(1,3) )); break;
						case 15: bc.PackItem ( new EssenceOfDispelling( Utility.Random(1,3) )); break;
						case 16: bc.PackItem ( new ReagentPowder( Utility.Random(1,4))); break;
					}	
				}
				
				
				for ( int l = 0; l < Rares; l++ )
				{
					switch ( Utility.Random( 18 ))
					{                                   
						case 0: bc.PackItem ( new MagesMind( Utility.Random(1,2) )); break; 
						case 1: bc.PackItem ( new MagesWisdom( Utility.Random(1,2) )); break;
						case 2: bc.PackItem ( new MagesWrath( Utility.Random(1,2) )); break;  
						case 3: bc.PackItem ( new MagesPower( Utility.Random(1,2) )); break;  
						case 4: bc.PackItem ( new MagesRest( Utility.Random(1,2) )); break;      
						case 5: bc.PackItem ( new GuidingLight()); break; 
						case 6: bc.PackItem ( new SpellcastersWeaponry()); break;  
						case 7: bc.PackItem ( new ScrollOfLesserKnowledge()); break;  
						case 8: bc.PackItem ( new ScrollOfKnowledge()); break;  
						case 9: bc.PackItem ( new ScrollOfGreaterKnowledge()); break;   
						case 10: bc.PackItem ( new TotemOfEradication()); break;  
						case 11: bc.PackItem ( new MagicPowder(Utility.Random(1,2))); break;						
						case 12: bc.PackItem ( new ReflectiveStance( Utility.Random(1,2) )); break;
						case 13: bc.PackItem ( new OrbsOfPower( Utility.Random(1,2) )); break;
						case 14: bc.PackItem ( new PowderOfAgility( Utility.Random(1,2) )); break; 
						case 15: bc.PackItem ( new EssenceOfStamina()); break;
						case 16: bc.PackItem ( new EssenceOfRejuvenation()); break;
						case 17: bc.PackItem ( new MagesRegeneration()); break;
					}	
				}
			}
		}
	}
}



ÿ