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

namespace Server
{
    public enum Terrain
    {
        None, Water, Cave, Dirt, Forest, Grass, Jungle, Rock, Sand, Swamp, Snow
    }

    public class SpawnList
    {
//--------------------------------- Critters --------------------------------------------

        private static Type[] ForestCritters = new Type[]
        {
            typeof( Rat ), typeof( Snake ), typeof( Rabbit ), typeof( Squirrel)
        };
        
        private static Type[] DesertCritters = new Type[]
        {
            typeof( Snake ), typeof( Rabbit ), typeof( Rat )
        };

        private static Type[] SnowCritters = new Type[]
        {
            typeof( Rabbit ), typeof( Squirrel )
        };

        private static Type[] JungleCritters = new Type[]
        {
            typeof( Snake )
        };

        private static Type[] FieldCritters = new Type[]
        {
            typeof( Rat ), typeof( Snake ), typeof( Rabbit ), typeof( Squirrel )
        };

        private static Type[] SwampCritters = new Type[]
        {
            typeof( Rat ), typeof( Snake )
        };

        private static Type[] DirtCritters = new Type[]
        {
            typeof( Rat )
        };

//------------------------------------ Birds -----------------------------------------

        private static Type[] ForestBirds = new Type[]
        {
            typeof( Bird ), typeof( Turkey ), typeof( Eagle ), typeof( AxeBeak )
        };

        private static Type[] DesertBirds = new Type[]
        {
            typeof( Bird ), typeof( Eagle ), typeof( Phoenix )
        };

        private static Type[] SnowBirds = new Type[]
        {
            typeof( Bird ), typeof( Eagle )
        };

        private static Type[] FieldBirds = new Type[]
        {
            typeof( Bird ), typeof( Eagle ), typeof( Chicken )
        };

        private static Type[] JungleBirds = new Type[]
        {
            typeof( Bird ), typeof( AxeBeak ), typeof( Eagle )
        };

        private static Type[] SwampBirds = new Type[]
        {
            typeof( Bird ), typeof( Eagle ), typeof( AxeBeak )
        };

        private static Type[] DirtBirds = new Type[]
        {
            typeof( Bird ), typeof( Chicken ), typeof( AxeBeak )
        };

//---------------------------------------- Animals ----------------------------------------

        private static Type[] ForestAnimals = new Type[]
        {
            typeof( BlackBear ), typeof( Boar ), typeof( BrownBear ), 
            typeof( Cougar ), typeof( GreatDeer ), typeof( TimberWolf ), 
            typeof( GrizzlyBear), typeof( Deer ), typeof( GreyWolf ),
            typeof( Bat )
        };

        private static Type[] JungleAnimals = new Type[]
        {
            typeof( Boar ), typeof( Gorilla ), typeof( PandaBear ), typeof( Panther ), 
            typeof( Tiger ), typeof( Ape )
        };

        private static Type[] FieldAnimals = new Type[]
        {
            typeof( BrownBear ), typeof( Goat ), typeof( MountainGoat ),
            typeof( Cow ), typeof( Bull ), typeof( Lion ), typeof( GreyWolf )
        };

        private static Type[] SnowAnimals = new Type[]
        {
            typeof( PolarBear ), typeof( SnowLeopard ), typeof( Deer ), typeof( GreatDeer ),
            typeof( Goat ), typeof( Walrus ), typeof( Rabbit ), typeof( WhiteWolf ),
            typeof( MountainGoat ), typeof( KodiakBear ) 
        };

        private static Type[] DesertAnimals = new Type[]
        {
        };

        private static Type[] SwampAnimals = new Type[]
        {
            typeof( Boar ), typeof( BlackBear ), typeof( Turtle ), typeof( BullFrog ),
            typeof( SwampDragon ), typeof( GreatDeer ), typeof( GiantSerpent ), typeof( Alligator ),
            typeof( WoolyBanta )
        };

        private static Type[] DirtAnimals = new Type[]
        {
            typeof( Boar ), typeof( BlackBear ), typeof( BrownBear ), typeof( GreyWolf )
        };

//-------------------------------------- Tier A------------------------------------------------

        private static Type[] Dirt_A = new Type[]
        {
            typeof( Brigand ), typeof( Skeleton ), typeof( BoneClaw ), typeof( CarcassWorm ),
            typeof( Slime ), typeof( Mongbat ), typeof( HeadlessOne )
        };

        private static Type[] Forest_A = new Type[]
        {
            typeof( DireWolf ), typeof( GiantRat ), typeof( GiantSpider ),
            typeof( GiantToad ), typeof( Ratman ), typeof( Mongbat ), typeof( Goblin ), 
            typeof( Corpser ), typeof( Shambler ), typeof( GiantHawk ),
            typeof( GiantRaven )
        };

        private static Type[] Jungle_A = new Type[]
        {
            typeof( Tiger ), typeof( SkeletonArcher ), typeof( Skeleton ), typeof( GiantSpider ),
            typeof( GiantRat ), typeof( VampireBat ), typeof( BullFrog ), 
            typeof( GiantLizard ), typeof( GiantSerpent ), typeof( Mongbat )
        };

        private static Type[] Snow_A = new Type[]
        {
            typeof( FrostSpider ), typeof( FrostOoze ), typeof( IceSerpent ),
            typeof( IceSalamander ), typeof( IceToad )
        };

        private static Type[] Field_A = new Type[]
        {
            typeof( Hobgoblin ), typeof( HobgoblinChief ), typeof( HobgoblinShaman ),
            typeof( DireWolf ), typeof( Ratman ), typeof( Skeleton ), typeof( SkeletonArcher ),
            typeof( GiantSpider ), typeof( Snake )
        };

        private static Type[] Desert_A = new Type[]
        {
            typeof( SandSpider ), typeof( Snake ), typeof( FireToad ), typeof( Skeleton ),
            typeof( SkeletonArcher ), typeof( BoneClaw )
        };

        private static Type[] Swamp_A = new Type[]
        {
            typeof( Alligator ), typeof( GiantRat ), typeof( Slime ), typeof( Mongbat ),
            typeof( Corpser ), typeof( WhippingVine ), typeof( Shambler )
        };

//------------------------ Tier B -------------------------------------------------------

        private static Type[] Dirt_B = new Type[]
        {
            typeof( Dwarf ), typeof( Caveman ), typeof( SkeletalMage ), typeof( Ghoul ),
            typeof( Gazer ), typeof( Gargoyle ), typeof( EarthElemental ), typeof( Minion ),
            typeof( LargeSlime )
        };

        private static Type[] Forest_B = new Type[]
        {
            typeof( StandardOrc ), typeof( OrcCaptain ), typeof( OrcishLord ), typeof( Hobgoblin ),
            typeof( Ratman ), typeof( Ettin ), typeof( Ogre ), typeof( Troll ), typeof( Bugbear ),
            typeof( Owlbear ), typeof( Reaper ), typeof( WoodElemental ),
            typeof( Werewolf )
        };

        private static Type[] Jungle_B = new Type[]
        {
            typeof( Sakkhra ), typeof( SakkhraShaman ), typeof( Cobra ), typeof( Viper ),
            typeof( Drasolisk ), typeof( GiantLizard ), typeof( GoraxHorned )
        };

        private static Type[] Field_B = new Type[]
        {
            typeof( Ettin ), typeof( Ogre ), typeof( Troll ), typeof( Gazer ), typeof( DireWolf )
        };

        private static Type[] Snow_B = new Type[]
        {
            typeof( SnowEttin ), typeof( Yeti ), typeof( IceImp ), typeof( IceSerpent )
        };

        private static Type[] Desert_B = new Type[]
        {
            typeof( AntaurWorker ), typeof( AntaurSoldier ), typeof( SandScorpion ),
            typeof( Scorpion ), typeof( Scarab ), typeof( Sphinx ), typeof( HellCat ),
            typeof( LavaLizard ), typeof( FireImp ), typeof( HellHound )
        };

        private static Type[] Swamp_B = new Type[]
        {
            typeof( Lizardman ), typeof( SwampTentacle ), typeof( Fungal ), typeof( Sludge )
        };

//----------------------------------- Tier C -------------------------------------

        private static Type[] Dirt_C = new Type[]
        {
            typeof( CorpseGolem ), typeof( Shade ), typeof( Spectre ), typeof( Wraith ),
            typeof( Xorn ), typeof( Drake ), typeof( Manticore ), typeof( IronBeetle )
        };

        private static Type[] Forest_C = new Type[]
        {
            typeof( Beetle ), typeof( BloodSpider ), typeof( Fairy ),
            typeof( OgreLord ), typeof( Satyr ), typeof( Kith )
        };

        private static Type[] Jungle_C = new Type[]
        {
            typeof( Mantis ), typeof( GoraxSlicer ), typeof( Kobra ), typeof( SavageLeader )
        };

        private static Type[] Field_C = new Type[]
        {
            typeof( Wisp ), typeof( AirElemental ), typeof( Cyclops ), typeof( LightningElemental ),
            typeof( Minotaur )
        };
        private static Type[] Snow_C = new Type[]
        {
            typeof( IceSalamander ), typeof( FrostTroll ), typeof( IceElemental ), typeof( ArcticOgreLord ),
            typeof( SnowElemental )
        };

        private static Type[] Desert_C = new Type[]
        {
            typeof( FireSalamander ), typeof( DeadlyScorpion ), typeof( FireBeetle ), typeof( FlameCrawler ),
            typeof( Mummy ), typeof( AntLion ), typeof( SandVortex ), typeof( FireGargoyle ), typeof( LavaDrake )
        };

        private static Type[] Swamp_C = new Type[]
        {
            typeof( FungalMage ), typeof( OphidianMage ), typeof( BloodLotus ), typeof( MudElemental ),
            typeof( OphidianWarrior ), typeof( SwampDragon ), typeof( SwampThing )
        };

//------------------------------------- Tier D -----------------------------------------

        private static Type[] Dirt_D = new Type[]
        {
            typeof( CyclopsChief ), typeof( MinotaurLord ), typeof( GargoyleCrimson ),
            typeof( BoneDrake ), typeof( Lich ), typeof( Genie ), typeof( DemonClaw ),
            typeof( Demoness ), typeof( Seeker )
        };
        private static Type[] Forest_D = new Type[]
        {
            typeof( HobgoblinArcher ), typeof( OgreMagi ), typeof( RatmanArcher ), typeof( Pixie ),
            typeof( RatmanMage ), typeof( VampiricDrake ), typeof( TerathanMatriarch ), typeof( Ent )
        };

        private static Type[] Jungle_D = new Type[]
        {
            typeof( SilverSerpent ), typeof( Drakkhen ), typeof( FireNaga )
        };

        private static Type[] Field_D = new Type[]
        {
            typeof( Centaur ), typeof( ShamblingMound ), typeof( Titan ), typeof( Cerberus )
        };

        private static Type[] Snow_D = new Type[]
        {
            typeof( GargoyleIce ), typeof( WaterElementalElder ), typeof( Serperus )
        };

        private static Type[] Desert_D = new Type[]
        {
            typeof( MummyLord ), typeof( RoyalSphinx ), typeof( AntaurLord ), typeof( Haderus )
        };

        private static Type[] Swamp_D = new Type[]
        {
            typeof( OphidianKnight ), typeof( OphidianArchmage ), typeof( PoisonElemental ),
            typeof( AcidElemental ), typeof( GasCloud )
        };

//------------------------------------- Tier E ------------------------------------------

        private static Type[] Dirt_E = new Type[]
        {
            typeof( Daemon ), typeof( Dragon ), typeof( MountainGiant )
        };

        private static Type[] Forest_E = new Type[]
        {
            typeof( HillGiant ), typeof( ForestGiant ), typeof( Hydra ), typeof( Roc )
        };

        private static Type[] Jungle_E = new Type[]
        {
            typeof( Naga ), typeof( JungleGiant ), typeof( NagaQueen )
        };

        private static Type[] Field_E = new Type[]
        {
            typeof( CyclopsLord ), typeof( Balron ), typeof( StormGiant ), typeof( Dragon )
        };

        private static Type[] Snow_E = new Type[]
        {
            typeof( FrostGiant ), typeof( IceFiend ), typeof( WhiteWyrm ), typeof( IceDevil )
        };

        private static Type[] Desert_E = new Type[]
        {
            typeof( ArcaneScarab ), typeof( SandGiant ), typeof( Succubus )
        };

        private static Type[] Swamp_E = new Type[]
        {
            typeof( OphidianMatriarch ), typeof( PoisonElementalElder ), typeof( AncientWyrm )
        };

//---------------------------- End of Mob Definitions --------------------------------------

        public static Terrain GetTerrain( Map map, Point3D location, int x, int y )
        {
            if ( map == Map.Internal || x < 0 || y < 0 )
                return Terrain.None;

            LandTile LTile = map.Tiles.GetLandTile( x, y );

			int[] WaterTerrain = { 0x00A8, 0x00A9, 0x00AA, 0x00AB, 0x0136, 0x0138 };
			int[] CaveTerrain = { 0x024A, 0x024B, 0x024C, 0x024D, 0x024E, 0x024F, 0x0250, 0x0251, 0x0252, 0x0253, 0x0254, 0x0255, 0x0256, 0x0257, 0x0258, 0x0259, 0x025A, 0x025B, 0x025C, 0x025D, 0x025E, 0x025F, 0x0260, 0x0261, 0x0262, 0x0263, 0x0264, 0x0265, 0x0266, 0x0267, 0x0268, 0x0269, 0x026A, 0x026B, 0x026C, 0x026D, 0x02BC, 0x02BD, 0x02BE, 0x02BF, 0x02C0, 0x02C1, 0x02C2, 0x02C3, 0x02C4, 0x02C5, 0x02C6, 0x02C7, 0x02C8, 0x02C9, 0x02CA, 0x02CB, 0x0245, 0x0246, 0x0247, 0x0248, 0x0249, 0x063B, 0x063C, 0x063D, 0x063E };
			int[] DirtTerrain = { 0x008D, 0x008E, 0x008F, 0x0090, 0x0091, 0x0092, 0x0093, 0x0094, 0x0095, 0x0096, 0x0097, 0x0098, 0x0099, 0x009A, 0x009B, 0x009C, 0x009D, 0x009E, 0x009F, 0x00A0, 0x00A1, 0x00A2, 0x00A3, 0x00A4, 0x00A5, 0x00A6, 0x00A7, 0x00DC, 0x00DD, 0x00DE, 0x00DF, 0x00E0, 0x00E1, 0x00E2, 0x00E3, 0x02D0, 0x02D1, 0x02D2, 0x02D3, 0x02D4, 0x02D5, 0x02D6, 0x02D7, 0x02E5, 0x02E6, 0x02E7, 0x02E8, 0x02E9, 0x02EA, 0x02EB, 0x02EC, 0x02ED, 0x02EE, 0x02EF, 0x02F0, 0x02F1, 0x02F2, 0x02F3, 0x02F4, 0x02F5, 0x02F6, 0x02F7, 0x02F8, 0x02F9, 0x02FA, 0x02FB, 0x02FC, 0x02FD, 0x02FE, 0x02FF, 0x0303, 0x0304, 0x0305, 0x0306, 0x0307, 0x0308, 0x0309, 0x030A, 0x030B, 0x030C, 0x030D, 0x030E, 0x030F, 0x0310, 0x0311, 0x0312, 0x0313, 0x0314, 0x0315, 0x0316, 0x0317, 0x0318, 0x0319, 0x031A, 0x031B, 0x031C, 0x031D, 0x031E, 0x031F, 0x06F4, 0x0777, 0x0778, 0x0779, 0x077A, 0x077B, 0x077C, 0x077D, 0x077E, 0x077F, 0x0780, 0x0781, 0x0782, 0x0783, 0x0784, 0x0785, 0x0786, 0x0787, 0x0788, 0x0789, 0x078A, 0x078B, 0x078C, 0x078D, 0x078E, 0x078F, 0x0790, 0x0791, 0x0071, 0x0072, 0x0073, 0x0074, 0x75, 0x0076, 0x0077, 0x0078, 0x0079, 0x007A, 0x007B, 0x007C, 0x0082, 0x0083, 0x0085, 0x0086, 0x0087, 0x0088, 0x0089, 0x008A, 0x008B, 0x008C, 0x00E8, 0x00E9, 0x00EA, 0x00EB, 0x0141, 0x0142, 0x0143, 0x0144, 0x014C, 0x014D, 0x014E, 0x014F, 0x0169, 0x016A, 0x016B, 0x016C, 0x016D, 0x016E, 0x016F, 0x0170, 0x0171, 0x0172, 0x0173, 0x0174, 0x01DC, 0x01DD, 0x01DE, 0x01DF, 0x01E0, 0x01E1, 0x01E2, 0x01E3, 0x01E4, 0x01E5, 0x01E6, 0x01E7, 0x01EC, 0x01ED, 0x01EE, 0x01EF, 0x0272, 0x0273, 0x0274, 0x0275, 0x027E, 0x027F, 0x0280, 0x0281, 0x032C, 0x032D, 0x032E, 0x032F, 0x033D, 0x033E, 0x033F, 0x0340, 0x0345, 0x0346, 0x0347, 0x0348, 0x0349, 0x034A, 0x034B, 0x034C, 0x0355, 0x0356, 0x0357, 0x0358, 0x0367, 0x0368, 0x0369, 0x036A, 0x036B, 0x036C, 0x036D, 0x036E, 0x0377, 0x0378, 0x0379, 0x037A, 0x038D, 0x038E, 0x038F, 0x0390, 0x0395, 0x0396, 0x0397, 0x0398, 0x0399, 0x039A, 0x039B, 0x039C, 0x03A5, 0x03A6, 0x03A7, 0x03A8, 0x03F6, 0x03F7, 0x03F9, 0x03FA, 0x03FB, 0x03FC, 0x03FD, 0x03FE, 0x03FF, 0x0400, 0x0401, 0x0402, 0x0403, 0x0404, 0x0405, 0x0547, 0x0548, 0x0549, 0x054A, 0x054B, 0x054C, 0x054D, 0x054E, 0x0553, 0x0554, 0x0555, 0x0556, 0x0597, 0x0598, 0x0599, 0x059A, 0x059B, 0x059C, 0x059D, 0x059E, 0x0623, 0x0624, 0x0625, 0x0626, 0x0627, 0x0628, 0x0629, 0x062A, 0x062B, 0x062C, 0x062D, 0x062E, 0x062F, 0x0630, 0x0631, 0x0632, 0x0633, 0x0634, 0x0635, 0x0636, 0x0637, 0x0638, 0x0639, 0x063A, 0x06F3, 0x06F5, 0x06F6, 0x06F7, 0x06F8, 0x06F9, 0x06FA };
			int[] ForestTerrain = { 0x00ED, 0x00EE, 0x00EF, 0x3AF0, 0x3AF1, 0x3AF2, 0x3AF3, 0x3AF4, 0x3AF5, 0x3AF6, 0x3AF7, 0x3AF8, 0x00C4, 0x00C5, 0x00C6, 0x00C7, 0x00C8, 0x00C9, 0x00CA, 0x00CB, 0x00CC, 0x00CD, 0x00CE, 0x00CF, 0x00D0, 0x00D1, 0x00D2, 0x00D3, 0x00D4, 0x00D5, 0x00D6, 0x00D7, 0x00F0, 0x00F1, 0x00F2, 0x00F3, 0x00F8, 0x00F9, 0x00FA, 0x00FB, 0x015D, 0x015E, 0x015F, 0x0160, 0x0161, 0x0162, 0x0163, 0x0164, 0x0165, 0x0166, 0x0167, 0x0168, 0x0324, 0x0325, 0x0326, 0x0327, 0x0328, 0x0329, 0x032A, 0x032B, 0x054F, 0x0550, 0x0551, 0x0552, 0x05F1, 0x05F2, 0x05F3, 0x05F4, 0x05F9, 0x05FA, 0x05FB, 0x05FC, 0x05FD, 0x05FE, 0x05FF, 0x0600, 0x0601, 0x0602, 0x0603, 0x0604, 0x0611, 0x0612, 0x0613, 0x0614, 0x0653, 0x0654, 0x0655, 0x0656, 0x065B, 0x065C, 0x065D, 0x065E, 0x065F, 0x0660, 0x0661, 0x0662, 0x066B, 0x066C, 0x066D, 0x066E, 0x06AF, 0x06B0, 0x06B1, 0x06B2, 0x06B3, 0x06B4, 0x06BB, 0x06BC, 0x06BD, 0x06BE, 0x0709, 0x070A, 0x070B, 0x070C, 0x0715, 0x0716, 0x0717, 0x0718, 0x0719, 0x071A, 0x071B, 0x071C };
			int[] GrassTerrain = { 0x0231, 0x0232, 0x0233, 0x0234, 0x0239, 0x023A, 0x023B, 0x023C, 0x023D, 0x023E, 0x023F, 0x0240, 0x0241, 0x06D2, 0x06D3, 0x06D4, 0x06D5, 0x06D6, 0x06D7, 0x06D8, 0x06D9, 0x3, 0x0004, 0x0005, 0x0006, 0x003B, 0x003C, 0x003D, 0x003E, 0x007D, 0x007E, 0x007F, 0x00C0, 0x00C1, 0x00C2, 0x00C3, 0x00D8, 0x00D9, 0x00DA, 0x00DB, 0x01A4, 0x01A5, 0x01A6, 0x01A7, 0x0242, 0x0243, 0x036F, 0x0370, 0x0371, 0x0372, 0x0373, 0x0374, 0x0375, 0x0376, 0x037B, 0x037C, 0x037D, 0x037E, 0x03BF, 0x03C0, 0x03C1, 0x03C2, 0x03C3, 0x03C4, 0x03C5, 0x03C6, 0x03CB, 0x03CC, 0x03CD, 0x03CE, 0x0579, 0x057A, 0x057B, 0x057C, 0x057D, 0x057E, 0x057F, 0x0580, 0x058B, 0x058C, 0x05D7, 0x05D8, 0x05D9, 0x05DA, 0x05DB, 0x05DC, 0x05DD, 0x05DE, 0x05E3, 0x05E4, 0x05E5, 0x05E6, 0x067D, 0x067E, 0x067F, 0x0680, 0x0681, 0x0682, 0x0683, 0x0684, 0x0689, 0x068A, 0x068B, 0x068C, 0x0695, 0x0696, 0x0697, 0x0698, 0x0699, 0x069A, 0x069B, 0x069C, 0x06A1, 0x06A2, 0x06A3, 0x06A4, 0x06B5, 0x06B6, 0x06B7, 0x06B8, 0x06B9, 0x06BA, 0x06BF, 0x06C0, 0x06C1, 0x06C2, 0x06DE, 0x06DF, 0x06E0, 0x06E1 };
			int[] JungleTerrain = { 0x00EC, 0x00FC, 0x00FD, 0x00FE, 0x00FF, 0x072A, 0x00AC, 0x00AD, 0x00AE, 0x00AF, 0x00B0, 0x00B3, 0x00B6, 0x00B9, 0x00BC, 0x00BD, 0x00BE, 0x00BF, 0x0100, 0x0101, 0x0102, 0x0103, 0x0108, 0x0109, 0x010A, 0x010B, 0x01F0, 0x01F1, 0x01F2, 0x01F3, 0x026E, 0x026F, 0x0270, 0x0271, 0x0276, 0x0277, 0x0278, 0x0279, 0x027A, 0x027B, 0x027C, 0x027D, 0x0286, 0x0287, 0x0288, 0x0289, 0x0292, 0x0293, 0x0294, 0x0295, 0x0581, 0x0582, 0x0583, 0x0584, 0x0585, 0x0586, 0x0587, 0x0588, 0x0589, 0x058A, 0x058D, 0x058E, 0x058F, 0x0590, 0x059F, 0x05A0, 0x05A1, 0x05A2, 0x05A3, 0x05A4, 0x05A5, 0x05A6, 0x05B3, 0x05B4, 0x05B5, 0x05B6, 0x05B7, 0x05B8, 0x05B9, 0x05BA, 0x05F5, 0x05F6, 0x05F7, 0x05F8, 0x0605, 0x0606, 0x0607, 0x0608, 0x0609, 0x060A, 0x060B, 0x060C, 0x060D, 0x060E, 0x060F, 0x0610, 0x0615, 0x0616, 0x0617, 0x0618, 0x0727, 0x0728, 0x0729, 0x0733, 0x0734, 0x0735, 0x0736, 0x0737, 0x0738, 0x0739, 0x073A };
			int[] RockTerrain = { 0x00E4, 0x00E5, 0x00E6, 0x00E7, 0x00F4, 0x00F5, 0x00F6, 0x00F7, 0x0104, 0x0105, 0x0106, 0x0107, 0x0110, 0x0111, 0x0112, 0x0113, 0x0122, 0x0123, 0x0124, 0x0125, 0x01D3, 0x01D4, 0x01D5, 0x01D6, 0x01D7, 0x01D8, 0x01D9, 0x01DA, 0x021F, 0x0220, 0x0221, 0x0222, 0x0223, 0x0224, 0x0225, 0x0226, 0x0227, 0x0228, 0x0229, 0x022A, 0x022B, 0x022C, 0x022D, 0x022E, 0x022F, 0x0230, 0x0235, 0x0236, 0x0237, 0x0238, 0x06CD, 0x06CE, 0x06CF, 0x06D0, 0x06D1, 0x06DA, 0x06DB, 0x06DC, 0x06DD, 0x06EB, 0x06EC, 0x06ED, 0x06EE, 0x06EF, 0x06F0, 0x06F1, 0x06F2, 0x06FB, 0x06FC, 0x06FD, 0x06FE, 0x070E, 0x070F, 0x0710, 0x0711, 0x0712, 0x0713, 0x0714, 0x071D, 0x071E, 0x071F, 0x0720, 0x072B, 0x072C, 0x072D, 0x072E, 0x072F, 0x0730, 0x0731, 0x0732, 0x073B, 0x073C, 0x073D, 0x073E, 0x0749, 0x074A, 0x074B, 0x074C, 0x074D, 0x074E, 0x074F, 0x0750, 0x0759, 0x075A, 0x075B, 0x075C, 0x09EC, 0x09ED, 0x09EE, 0x09EF, 0x09F0, 0x09F1, 0x09F2, 0x09F3, 0x09F4, 0x09F5, 0x09F6, 0x09F7, 0x09F8, 0x09F9, 0x09FA, 0x09FB, 0x09FC, 0x09FD, 0x09FE, 0x09FF, 0x0A00, 0x0A01, 0x0A02, 0x0A03, 0x3F39, 0x3F3A, 0x3F3B, 0x3F3C, 0x3F3D, 0x3F3E, 0x3F3F, 0x3F40, 0x3F41, 0x3F42, 0x3F43, 0x3F44, 0x3F45, 0x3F46, 0x3F47, 0x3F48, 0x3F49, 0x3F4A, 0x3F4B, 0x3F4C, 0x3F4D, 0x3F4E, 0x3F4F, 0x3F50, 0x3F51, 0x3F52, 0x3F53, 0x3F54, 0x3F55, 0x3F56, 0x3F57, 0x3F58, 0x3F59, 0x3F5A, 0x3F5B, 0x3F5C, 0x3F5D, 0x3F5E, 0x3F5F, 0x3F60, 0x3F61, 0x3F62, 0x3F63, 0x3F64, 0x3F65, 0x3F66, 0x3F67, 0x3F68, 0x3F82, 0x3F83, 0x3F84, 0x3F85, 0x3F86, 0x3F87, 0x3F88, 0x3F89, 0x3F8A, 0x3F8B, 0x3F8C, 0x3F8D, 0x3F8E, 0x3F8F, 0x3F92, 0x3F93, 0x3F94, 0x3F95, 0x3F96, 0x3F97, 0x3F98, 0x3F99, 0x3F9A, 0x3F9B, 0x3F9C, 0x3F9D, 0x3F9E, 0x3F9F, 0x3FA0, 0x3FA1, 0x3FA2, 0x3FA3, 0x3FA4, 0x3FA5, 0x3FA6, 0x3FA7, 0x3FA8, 0x3FA9, 0x3FAA, 0x3FAB, 0x3FAC, 0x3FAD, 0x3FAE, 0x3FAF, 0x3FB0, 0x3FB1, 0x3FB2, 0x3FB3, 0x3FB4, 0x3FB5, 0x3FB6, 0x3FB7, 0x3FB8, 0x3FB9, 0x3FBA, 0x3FBB, 0x3FBC, 0x3FBD, 0x3FBE, 0x3FBF, 0x3FC0, 0x3FC1, 0x3FC2, 0x3FC3, 0x3FC4, 0x3FC5, 0x3FC6, 0x3FC7, 0x3FC8, 0x3FC9, 0x3FCA, 0x3FCB, 0x3FCC, 0x3FCD, 0x3FCE, 0x3FCF, 0x0436, 0x0437, 0x0438, 0x0439, 0x043A, 0x043B, 0x043C, 0x043D, 0x043E, 0x043F, 0x0440, 0x0441, 0x0442, 0x0443, 0x0444, 0x0445 };
			int[] SandTerrain = { 0x001A, 0x001B, 0x001C, 0x001D, 0x001E, 0x001F, 0x0020, 0x0021, 0x0022, 0x0023, 0x0024, 0x0025, 0x0026, 0x0027, 0x0028, 0x0029, 0x002A, 0x002B, 0x002C, 0x002D, 0x002E, 0x002F, 0x0030, 0x0031, 0x0032, 0x0044, 0x0045, 0x0046, 0x0047, 0x0048, 0x0049, 0x004A, 0x004B, 0x0126, 0x0127, 0x0128, 0x0129, 0x01B9, 0x01BA, 0x01BB, 0x01BC, 0x01BD, 0x01BE, 0x01BF, 0x01C0, 0x01C1, 0x01C2, 0x01C3, 0x01C4, 0x01C5, 0x01C6, 0x01C7, 0x01C8, 0x01C9, 0x01CA, 0x01CB, 0x01CC, 0x01CD, 0x01CE, 0x01CF, 0x01D0, 0x01D1, 0x0016, 0x0017, 0x0018, 0x0019, 0x0033, 0x0034, 0x0035, 0x0036, 0x0037, 0x0038, 0x0039, 0x003A, 0x011E, 0x011F, 0x0120, 0x0121, 0x12A, 0x012B, 0x012C, 0x012D, 0x01A8, 0x01A9, 0x01AA, 0x01AB, 0x0282, 0x0283, 0x0284, 0x0285, 0x028A, 0x028B, 0x028C, 0x028D, 0x028E, 0x028F, 0x0290, 0x0291, 0x0335, 0x0336, 0x0337, 0x0338, 0x0339, 0x033A, 0x033B, 0x033C, 0x0341, 0x0342, 0x0343, 0x0344, 0x034D, 0x034E, 0x034F, 0x0350, 0x0351, 0x0352, 0x0353, 0x0354, 0x0359, 0x035A, 0x035B, 0x035C, 0x03B7, 0x03B8, 0x03B9, 0x03BA, 0x03BB, 0x03BC, 0x03BD, 0x03BE, 0x03C7, 0x03C8, 0x03C9, 0x03CA, 0x05A7, 0x05A8, 0x05A9, 0x05AA, 0x05AB, 0x05AC, 0x05AD, 0x05AE, 0x05AF, 0x05B0, 0x05B1, 0x05B2, 0x064B, 0x064C, 0x064D, 0x064E, 0x064F, 0x0650, 0x0651, 0x0652, 0x0657, 0x0658, 0x0659, 0x065A, 0x0663, 0x0664, 0x0665, 0x0666, 0x0667, 0x0668, 0x0669, 0x066A, 0x066F, 0x0670, 0x0671, 0x0672 };
			int[] SwampTerrain = { 0x3D65, 0x3D66, 0x3D67, 0x3D68, 0x3D69, 0x3D6A, 0x3D6B, 0x3D6C, 0x3D6D, 0x3D6E, 0x3D6F, 0x3D70, 0x3D71, 0x3D72, 0x3D73, 0x3D74, 0x3D75, 0x3D76, 0x3D77, 0x3D78, 0x3D79, 0x3D7A, 0x3D7B, 0x3D7C, 0x3D7D, 0x3D7E, 0x3D7F, 0x3D80, 0x3D81, 0x3D82, 0x3D83, 0x3D84, 0x3D85, 0x3D86, 0x3D87, 0x3D88, 0x3D89, 0x3D8A, 0x3D8B, 0x3D8C, 0x3D8D, 0x3D8E, 0x3D8F, 0x3D90, 0x3D91, 0x3D92, 0x3D93, 0x3D94, 0x3D95, 0x3D96, 0x3D97, 0x3D98, 0x3D99, 0x3D9A, 0x3D9B, 0x3D9C, 0x3D9D, 0x3D9E, 0x3D9F, 0x3DA0, 0x3DA1, 0x3DA2, 0x3DA3, 0x3DA4, 0x3DA5, 0x3DA6, 0x3DA7, 0x3DA8, 0x3DA9, 0x3DAA, 0x3DAB, 0x3DAC, 0x3DAD, 0x3DAE, 0x3DAF, 0x3DB0, 0x3DB1, 0x3DB2, 0x3DB3, 0x3DB4, 0x3DB5, 0x3DB6, 0x3DB7, 0x3DB8, 0x3DB9, 0x3DBA, 0x3DBB, 0x3DBC, 0x3DBD, 0x3DBE, 0x3DBF, 0x3DC0, 0x3DC1, 0x3DC2, 0x3DC3, 0x3DC4, 0x3DC5, 0x3DC6, 0x3DC7, 0x3DC8, 0x3DC9, 0x3DCA, 0x3DCB, 0x3DCC, 0x3DCD, 0x3DCE, 0x3DCF, 0x3DD0, 0x3DD1, 0x3DD2, 0x3DD3, 0x3DD4, 0x3DD5, 0x3DD6, 0x3DD7, 0x3DD8, 0x3DD9, 0x3DDA, 0x3DDB, 0x3DDC, 0x3DDD, 0x3DDE, 0x3DDF, 0x3DE0, 0x3DE1, 0x3DE2, 0x3DE3, 0x3DE4, 0x3DE5, 0x3DE6, 0x3DE7, 0x3DE8, 0x3DE9, 0x3DEA, 0x3DEB, 0x3DEC, 0x3DED, 0x3DEE, 0x3DEF, 0x3DF0, 0x3DF1 };
			int[] SnowTerrain = { 0x010C, 0x010D, 0x010E, 0x010F, 0x0114, 0x0115, 0x0116, 0x0117, 0x017C, 0x017D, 0x017E, 0x017F, 0x0180, 0x0181, 0x0182, 0x0183, 0x0184, 0x0185, 0x0186, 0x0187, 0x0188, 0x0189, 0x018A, 0x0755, 0x0756, 0x0757, 0x0758, 0x076D, 0x076E, 0x076F, 0x0770, 0x0771, 0x0772, 0x0773, 0x011A, 0x011B, 0x011C, 0x011D, 0x012E, 0x012F, 0x0130, 0x0131, 0x0179, 0x017A, 0x017B, 0x0385, 0x0386, 0x0387, 0x0388, 0x0389, 0x038A, 0x038B, 0x038C, 0x0391, 0x0392, 0x0393, 0x0394, 0x039D, 0x039E, 0x039F, 0x03A0, 0x03A1, 0x03A2, 0x03A3, 0x03A4, 0x03A9, 0x03AA, 0x03AB, 0x03AC, 0x05BF, 0x05C0, 0x05C1, 0x05C2, 0x05C3, 0x05C4, 0x05C5, 0x05C6, 0x05C7, 0x05C8, 0x05C9, 0x05CA, 0x05CB, 0x05CC, 0x05CD, 0x05CE, 0x05CF, 0x05D0, 0x05D1, 0x05D2, 0x05D3, 0x05D4, 0x05D5, 0x05D6, 0x05DF, 0x05E0, 0x05E1, 0x05E2, 0x0745, 0x0746, 0x0747, 0x0748, 0x0751, 0x0752, 0x0753, 0x0754, 0x075D, 0x075E, 0x075F, 0x0760 };

            if ( Array.IndexOf( WaterTerrain, LTile.ID ) >= 0 )
                return Terrain.Water;
            else if ( Array.IndexOf( CaveTerrain, LTile.ID ) >= 0 )
                return Terrain.Cave;
            else if ( Array.IndexOf( DirtTerrain, LTile.ID ) >= 0 )
                return Terrain.Dirt;
            else if ( Array.IndexOf( ForestTerrain, LTile.ID ) >= 0 )
                return Terrain.Forest;
            else if ( Array.IndexOf( GrassTerrain, LTile.ID ) >= 0 )
                return Terrain.Grass;
            else if ( Array.IndexOf( JungleTerrain, LTile.ID ) >= 0 )
                return Terrain.Jungle;
            else if ( Array.IndexOf( RockTerrain, LTile.ID ) >= 0 )
                return Terrain.Rock;
            else if ( Array.IndexOf( SandTerrain, LTile.ID ) >= 0 )
                return Terrain.Sand;
            else if ( Array.IndexOf( SwampTerrain, LTile.ID ) >= 0 )
                return Terrain.Swamp;
            else if ( Array.IndexOf( SnowTerrain, LTile.ID ) >= 0 )
                return Terrain.Snow;

            return Terrain.None;
        }

        public static Terrain TestAround ( Terrain ground, Map map, int x, int y, int distance )
        {
            Point3D p = new Point3D( 9000, 9000, 0 );
            Terrain terrain = Terrain.None;
            int i = 8;
            int g = 0;

            while ( i > 0 )
            {
                i--;
                g = Utility.Random(8);

                switch ( g )
                {
                    case 0: terrain = GetTerrain( map, p, x-distance, y-distance ); break;
                    case 1: terrain = GetTerrain( map, p, x, y-distance ); break;
                    case 2: terrain = GetTerrain( map, p, x+distance, y-distance ); break;
                    case 3: terrain = GetTerrain( map, p, x-distance, y ); break;
                    case 4: terrain = GetTerrain( map, p, x+distance, y ); break;
                    case 5: terrain = GetTerrain( map, p, x-distance, y+distance ); break;
                    case 6: terrain = GetTerrain( map, p, x, y+distance ); break;
                    case 7: terrain = GetTerrain( map, p, x+distance, y+distance ); break;
                }

                if ( terrain != Terrain.Water && terrain != Terrain.Cave && terrain != Terrain.Dirt && terrain != Terrain.Rock )
                    return terrain;
            }

            return ground;
        }

        public static Mobile RandomSpawn( Item spawn, Point3D loc, Map map )
        {
            Mobile m = null;
            spawn.MoveToWorld( loc, map );
            int tries = 100;
            
            Terrain terrain = GetTerrain( map, loc, spawn.X, spawn.Y );
            
            if ( terrain != Terrain.Water && terrain != Terrain.Cave && terrain != Terrain.Dirt && terrain != Terrain.Rock )
                terrain = TestAround( terrain, map, spawn.X, spawn.Y, 15 );

            while ( m == null && tries > 0 )
            {
                tries--;

                if ( spawn is SpawnCritters )
                {
                    if ( terrain == Terrain.Forest )
                        m = Construct( ForestCritters ) as Mobile;
                    else if ( terrain == Terrain.Sand )
                        m = Construct( DesertCritters ) as Mobile;
                    else if ( terrain == Terrain.Jungle )
                        m = Construct( JungleCritters ) as Mobile;
                    else if ( terrain == Terrain.Grass )
                        m = Construct( FieldCritters ) as Mobile;
                    else if ( terrain == Terrain.Snow )
                        m = Construct( SnowCritters ) as Mobile;
                    else if ( terrain == Terrain.Swamp )
                        m = Construct( SwampCritters ) as Mobile;
                    else if ( terrain == Terrain.Dirt )
                        m = Construct( DirtCritters ) as Mobile;
                }
                else if ( spawn is SpawnBirds )
                {
                    if ( terrain == Terrain.Forest )
                        m = Construct( ForestBirds ) as Mobile;
                    else if ( terrain == Terrain.Sand )
                        m = Construct( DesertBirds ) as Mobile;
                    else if ( terrain == Terrain.Jungle )
                        m = Construct( JungleBirds ) as Mobile;
                    else if ( terrain == Terrain.Grass )
                        m = Construct( FieldBirds ) as Mobile;
                    else if ( terrain == Terrain.Snow )
                        m = Construct( SnowBirds ) as Mobile;
                    else if ( terrain == Terrain.Swamp )
                        m = Construct( SwampBirds ) as Mobile;
                    else if ( terrain == Terrain.Dirt )
                        m = Construct( DirtBirds ) as Mobile;
                }
                else if ( spawn is SpawnAnimals )
                {
                    if ( terrain == Terrain.Forest )
                        m = Construct( ForestAnimals ) as Mobile;
                    else if ( terrain == Terrain.Sand )
                        m = Construct( DesertAnimals ) as Mobile;
                    else if ( terrain == Terrain.Jungle )
                        m = Construct( JungleAnimals ) as Mobile;
                    else if ( terrain == Terrain.Grass )
                        m = Construct( FieldAnimals ) as Mobile;
                    else if ( terrain == Terrain.Snow )
                        m = Construct( SnowAnimals ) as Mobile;
                    else if ( terrain == Terrain.Swamp )
                        m = Construct( SwampAnimals ) as Mobile;
                    else if ( terrain == Terrain.Dirt )
                        m = Construct( DirtAnimals ) as Mobile;
                }
                else if ( spawn is Spawn_A )
                {
                    if ( terrain == Terrain.Forest )
                        m = Construct( Forest_A ) as Mobile;
                    else if ( terrain == Terrain.Sand )
                        m = Construct( Desert_A ) as Mobile;
                    else if ( terrain == Terrain.Jungle )
                        m = Construct( Jungle_A ) as Mobile;
                    else if ( terrain == Terrain.Grass )
                        m = Construct( Field_A ) as Mobile;
                    else if ( terrain == Terrain.Snow )
                        m = Construct( Snow_A ) as Mobile;
                    else if ( terrain == Terrain.Swamp )
                        m = Construct( Swamp_A ) as Mobile;
                    else if ( terrain == Terrain.Dirt )
                        m = Construct( Dirt_A ) as Mobile;
                }
                else if ( spawn is Spawn_B )
                {
                    if ( terrain == Terrain.Forest )
                        m = Construct( Forest_B ) as Mobile;
                    else if ( terrain == Terrain.Sand )
                        m = Construct( Desert_B ) as Mobile;
                    else if ( terrain == Terrain.Jungle )
                        m = Construct( Jungle_B ) as Mobile;
                    else if ( terrain == Terrain.Grass )
                        m = Construct( Field_B ) as Mobile;
                    else if ( terrain == Terrain.Snow )
                        m = Construct( Snow_B ) as Mobile;
                    else if ( terrain == Terrain.Swamp )
                        m = Construct( Swamp_B ) as Mobile;
                    else if ( terrain == Terrain.Dirt )
                        m = Construct( Dirt_B ) as Mobile;
                }
                else if ( spawn is Spawn_C )
                {
                    if ( terrain == Terrain.Forest )
                        m = Construct( Forest_C ) as Mobile;
                    else if ( terrain == Terrain.Sand )
                        m = Construct( Desert_C ) as Mobile;
                    else if ( terrain == Terrain.Jungle )
                        m = Construct( Jungle_C ) as Mobile;
                    else if ( terrain == Terrain.Grass )
                        m = Construct( Field_C ) as Mobile;
                    else if ( terrain == Terrain.Snow )
                        m = Construct( Snow_C ) as Mobile;
                    else if ( terrain == Terrain.Swamp )
                        m = Construct( Swamp_C ) as Mobile;
                    else if ( terrain == Terrain.Dirt )
                        m = Construct( Dirt_C ) as Mobile;
                }
                else if ( spawn is Spawn_D )
                {
                    if ( terrain == Terrain.Forest )
                        m = Construct( Forest_D ) as Mobile;
                    else if ( terrain == Terrain.Sand )
                        m = Construct( Desert_D ) as Mobile;
                    else if ( terrain == Terrain.Jungle )
                        m = Construct( Jungle_D ) as Mobile;
                    else if ( terrain == Terrain.Grass )
                        m = Construct( Field_D ) as Mobile;
                    else if ( terrain == Terrain.Snow )
                        m = Construct( Snow_D ) as Mobile;
                    else if ( terrain == Terrain.Swamp )
                        m = Construct( Swamp_D ) as Mobile;
                    else if ( terrain == Terrain.Dirt )
                        m = Construct( Dirt_D ) as Mobile;
                }
                else if ( spawn is Spawn_E )
                {
                    if ( terrain == Terrain.Forest )
                        m = Construct( Forest_E ) as Mobile;
                    else if ( terrain == Terrain.Sand )
                        m = Construct( Desert_E ) as Mobile;
                    else if ( terrain == Terrain.Jungle )
                        m = Construct( Jungle_E ) as Mobile;
                    else if ( terrain == Terrain.Grass )
                        m = Construct( Field_E ) as Mobile;
                    else if ( terrain == Terrain.Snow )
                        m = Construct( Snow_E ) as Mobile;
                    else if ( terrain == Terrain.Swamp )
                        m = Construct( Swamp_E ) as Mobile;
                    else if ( terrain == Terrain.Dirt )
                        m = Construct( Dirt_E ) as Mobile;
                }
            }
            
            //spawn.Delete();
            return m;
        }

        public static Mobile Construct( Type type )
        {
            try
            {
                return Activator.CreateInstance( type ) as Mobile;
            }
            catch
            {
                return null;
            }
        }

        public static Mobile Construct( Type[] types )
        {
            if ( types.Length > 0 )
                return Construct( types, Utility.Random( types.Length ) );

            return null;
        }

        public static Mobile Construct( Type[] types, int index )
        {
            if ( index >= 0 && index < types.Length )
                return Construct( types[index] );

            return null;
        }

        public static Mobile Construct( params Type[][] types )
        {
            int totalLength = 0;

            for ( int i = 0; i < types.Length; ++i )
                totalLength += types[i].Length;

            if ( totalLength > 0 )
            {
                int index = Utility.Random( totalLength );

                for ( int i = 0; i < types.Length; ++i )
                {
                    if ( index >= 0 && index < types[i].Length )
                        return Construct( types[i][index] );

                    index -= types[i].Length;
                }
            }

            return null;
        }
    }
}
