OK so I got this script from the resource section and I think its pretty neat. I think some cool things can be done with it but I am having trouble understanding how it actually works and what its doing. I mean overall I know what it does, its a massive spawner generator obviously. I have made notes in the code that are at best my best guess for what's going on. I really need someone who is far better versed in C# to explain this to me. I have questions like is this script limited to a certain region? How do I change the spawn values properly. Can I add other criteria for this script to use like other land tiles etc? Anyway Ill post the code below. I know this is beginner stuff but I'd really appreciate listening to you guys explain this script and break it down.

C#:
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Commands;
using System.Collections;
using System.Collections.Generic;

namespace Server
{
    public class AnimalSpawnGenerator
    {
            private static Rectangle2D[] m_BritRegions = new Rectangle2D[]//Make a working area for spawn generation arount this region?
            {
                new Rectangle2D( new Point2D( 0, 0 ), new Point2D( 6142, 4094 ) ),
            };
         
        private static XmlSpawner.SpawnObject spawnAnimal01;//What are these for? I don't see spawnAnimal01 02 03 04 etc in the script.
        private static XmlSpawner.SpawnObject spawnAnimal02;
        private static XmlSpawner.SpawnObject spawnAnimal03;
        private static XmlSpawner.SpawnObject spawnAnimal04;
        private static XmlSpawner.SpawnObject spawnAnimal05;
        private static XmlSpawner.SpawnObject spawnAnimal06;
        private static XmlSpawner.SpawnObject spawnAnimal07;
        private static XmlSpawner.SpawnObject spawnAnimal08;
        private static XmlSpawner.SpawnObject spawnAnimal09;
        private static XmlSpawner.SpawnObject spawnAnimal10;
        private static XmlSpawner.SpawnObject spawnAnimal11;
        private static XmlSpawner.SpawnObject spawnAnimal12;
 
            private static int[] m_Criterion = new int[]
            {
              //Trees
                0xC9E, 0xCA8, 0xCAA, 0xCCA, 0xCCB, 0xCCC, 0xCCD, 0xCD0, 0xCD3, 0xCD6, 0xCD8, 0xCDA, 0xCDD, 0xCE0, 0xCE3,//Tree tile definitions
                0xCE6, 0xCF8, 0xCFB, 0xCFE, 0xD01, 0xD43, 0xD59, 0xD70, 0xD85, 0xD94, 0xD98, 0xD9C, 0xDA0, 0xDA4, 0xDA8,
             
              //Rocks
                4943, 4944, 4945, 4946, 4947, 4948, 4949, 4950, 4951, 4951, 4953, 4954, 4955, 4956, 4957, 4958, 4959,//Rock tile defenitions
                4960, 4961, 4962, 4963, 4964, 4965, 4966, 4967, 4968, 4969, 4970, 4971, 4972, 4973, 6001, 6002, 6003,
                6004, 6005, 6006, 6007, 6008, 6009, 6010, 6011, 6012, 13121, 13122, 13123, 13124, 13125, 13126, 13127,
                13128, 13129, 13130, 13131, 13132, 13133, 13134, 13135, 13136, 13137, 13354, 13355, 13361, 13362, 13363,
                13364, 13365, 13366, 13367, 13368, 13369, 13625, 13626, 13627, 13628,
              //Oak Tree Trunk
                0x12B9,
            };

        public static void Initialize()
        {
            CommandSystem.Register( "AnimalSpawnGen", AccessLevel.Administrator, new CommandEventHandler( AnimalSpawnGen_OnCommand ) );//Command Register
            CommandSystem.Register( "AnimalSpawnRem", AccessLevel.Administrator, new CommandEventHandler( AnimalSpawnRem_OnCommand ) );//Command Register

         
        }

        [Usage( "AnimalSpawnGen" )]//Command
        [Description( "Generates animal wildlife spawners by analyzing the map. Slow." )]//Description generated in docs
        public static void AnimalSpawnGen_OnCommand( CommandEventArgs e )
        {
            Generate();//Action
        }
     
        [Usage( "AnimalSpawnRem" )]//Command
        [Description( "Removes animal wildlife spawners by analyzing the map. Slow." )]//Description generated in docs
        public static void AnimalSpawnRem_OnCommand( CommandEventArgs e )
        {
            Remove();//Action
        }

        private static Map m_Map;
        private static int m_Count;

        public static void Generate()//When generating DO
        {
            World.Broadcast( 0x35, true, "Generating animal spawners, please wait." );//Broadcast Message to everyone

            Network.NetState.FlushAll();
            Network.NetState.Pause();

            m_Map = Map.Felucca;//Map you want the spawns in
            m_Count = 0;//Counts the spawned objects?

            for ( int i = 0; i < m_BritRegions.Length; ++i )//Seems to indicate the region the spawner is bound to operate in ?
                Generate( m_BritRegions[i] );//Do generate in this region?

            int feluccaCount = m_Count;//Map Count

            Network.NetState.Resume();//No Idea

            World.Broadcast( 0x35, true, "Animal spawner generation complete. {0}", feluccaCount );//Map Count Broadcast
        }

        public static bool IsRock( int id )//If this script finds a rock?
        {
            if ( id > m_Criterion[m_Criterion.Length - 1] )
                return false;

            for ( int i = 0; i < m_Criterion.Length; ++i )
            {
                int delta = id - m_Criterion[i];

                if ( delta < 0 )
                    return false;
                else if ( delta == 0 )
                    return true;
            }

            return false;
        }

        private static void AddAnimalSpawner( int x, int y, int z )
        {
              if ( Utility.RandomDouble() < 0.9750 )
                    return;
           
              Map map = Map.Felucca;//Map you want the spawn in
              IPooledEnumerable eable = map.GetItemsInRange(new Point3D(x, y, z), 20);
           
              foreach ( Item item in eable )
              {
                  if ( item is XmlSpawner ) {
                      if ( item.Hue == 346 ) {
                          return;
                      }
                  }
              }
       
              if ( !m_Map.CanFit( x, y, z, 1, false, false ) )
                  return;
     
        //XmlSpawner(int amount, int minDelay, int maxDelay, int team, int homeRange, int spawnrange, string creatureName)
              XmlSpawner spawner = null;
              int MaxSpawn = 0;
              int Counter = 0;
              switch( Utility.Random(6) ) {
                  case 0:
                      spawner = new XmlSpawner( 10, 1, 3, 0, 0, Utility.RandomMinMax(22,30), "Bird" );//A random list of animals this puppy can spawn?
                       spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("Chicken", 4) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("Eagle", 2) );
                      MaxSpawn = 12;
                      Counter = 3;
                      break;
              case 1:
                  spawner = new XmlSpawner( 4, 2, 5, 0, 0, Utility.RandomMinMax(8,10), "BrownBear" );//A random list of animals this puppy can spawn?
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("BlackBear", 4) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("GrizzlyBear", 2) );
                      MaxSpawn = 6;
                      Counter = 3;
                      break;
              case 2:
                  spawner = new XmlSpawner( 4, 1, 3, 0, 0, Utility.RandomMinMax(18,24), "Dog" );//A random list of animals this puppy can spawn?
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("Cat", 4) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("GiantRat", 2) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("SewerRat", 4) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("JackRabbit", 4) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("Rabbit", 4) );
                      MaxSpawn = 10;
                      Counter = 6;
                      break;
              case 3:
                  spawner = new XmlSpawner( 2, 1, 3, 0, 0, Utility.RandomMinMax(26,30), "Bull" );//A random list of animals this puppy can spawn?
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("Cow", 4) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("Goat", 2) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("MountainGoat", 2) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("Boar", 2) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("Pig", 4) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("GreatHart", 2) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("Hind", 6) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("Sheep", 6) );
                      MaxSpawn = 14;
                      Counter = 8;
                      break;
              case 4:
                  spawner = new XmlSpawner( 2, 2, 5, 0, 0, Utility.RandomMinMax(8,10), "DireWolf" );//A random list of animals this puppy can spawn?
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("GreyWolf", 4) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("TimberWolf", 4) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("Panther", 2) );
                      MaxSpawn = 6;
                      Counter = 4;
                      break;
              case 5:
                  spawner = new XmlSpawner( 6, 3, 7, 0, 0, Utility.RandomMinMax(8,10), "Gorilla" );//A random list of animals this puppy can spawn?
                  spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("Alligator", 3) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("GiantSerpent", 2) );
                      spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("Raptor", 1) );
                      MaxSpawn = 6;
                      Counter = 4;
                      break;
        }
     
        //Spawn Orcs ( 30% )                                           //where is this calulated? Is it the combined total of the 10% and 20% below?
        if ( spawner != null ) {//If spawner is empty?
            switch( Utility.Random(10) ) {
                case 0:
                case 1: // 20%                                        //and where is this? calculated?
                    spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("Orc", 2) );//What the heck is this random orc generation for?
                    break;
                case 2: // 10%                                        //and this also?
                    spawner.m_SpawnObjects.Add( new XmlSpawner.SpawnObject("OrcCaptain", 2) );//What about this one?
                    break;
                default:
                    break;
            }
              }
           
              if ( spawner != null ) {//If spawner is empty?
                  for ( int i = 0; i < Counter; i++ ) {//Unsure what this does.
                      spawner.SpawnObjects[i].SpawnsPerTick = 1;//No idea what this is ticking
                  }
               
                  spawner.Name = "Animal Spawner #" + m_Count;//Displays "Animal Spawner" with a count?
                  spawner.MoveToWorld( new Point3D( x, y, z), Map.Felucca);//Move to Map
                  spawner.MaxCount = MaxSpawn;//Defines the MaxCount is the Max amount Spawned?
                  spawner.Hue = 346;//Hue of said spawner?
              }

              ++m_Count;//counting something again
        }

        public static void Generate( Rectangle2D region )//Generate instructions but really don't undertand what its doing
        {
            int OakTree = 0x12B9;//Is it just this sole tile we are looking for?
         
            for ( int rx = 0; rx < region.Width; ++rx )//something about the x region coordinate
            {
                for ( int ry = 0; ry < region.Height; ++ry )//something about the y region coordinate
                {
                    int vx = rx + region.X;//x coordinate?
                    int vy = ry + region.Y;//y coordinate?

                    StaticTile[] tiles = m_Map.Tiles.GetStaticTiles( vx, vy );

                    for ( int i = 0; i < tiles.Length; ++i )
                    {
                        StaticTile tile = tiles[i];

                        int id = tile.ID;
                        id &= 0x3FFF;
                        int z = tile.Z;

                        if ( IsRock( id ) )
                        {
                            AddAnimalSpawner( vx + 1, vy, z );//adding a spawner at a coordinate?
                        }
                    }
                }
            }
        }
     
        public static void Remove() {
            List<Item> itemList = new List<Item>( World.Items.Values );//no idea what this is doing except telling the server to expect a list of items?
         
            List<Item> AnimalSpawner = new List<Item>();
         
            foreach ( Item item in itemList )//Removal instructions also no idea what this is doing
              {
                  if ( item is XmlSpawner ) {
                      XmlSpawner spawner = item as XmlSpawner;
                      if ( spawner.SpawnObjects.Length > 0 ) {
                          if ( spawner.SpawnObjects[0].TypeName.ToUpper() == "BROWNBEAR" ) {//why are these animals here in all caps?
                              AnimalSpawner.Add(item);
                          }
                          else if ( spawner.SpawnObjects[0].TypeName.ToUpper() == "BLACKBEAR" ) {
                              AnimalSpawner.Add(item);
                          }
                          else if ( spawner.SpawnObjects[0].TypeName.ToUpper() == "GRIZZLYBEAR" ) {
                              AnimalSpawner.Add(item);
                          }
                          else if ( spawner.SpawnObjects[0].TypeName.ToUpper() == "POLARBEAR" ) {
                              AnimalSpawner.Add(item);
                          }
                          else if ( spawner.SpawnObjects[0].TypeName.ToUpper() == "BIRD" ) {
                              AnimalSpawner.Add(item);
                          }
                          else if ( spawner.SpawnObjects[0].TypeName.ToUpper() == "CHICKEN" ) {
                              AnimalSpawner.Add(item);
                          }
                          else if ( spawner.SpawnObjects[0].TypeName.ToUpper() == "EAGLE" ) {
                              AnimalSpawner.Add(item);
                          }
                          else if ( spawner.SpawnObjects[0].TypeName.ToUpper() == "DOG" ) {
                              AnimalSpawner.Add(item);
                          }
                          else if ( spawner.SpawnObjects[0].TypeName.ToUpper() == "BULL" ) {
                              AnimalSpawner.Add(item);
                          }
                          else if ( spawner.SpawnObjects[0].TypeName.ToUpper() == "DIREWOLF" ) {
                              AnimalSpawner.Add(item);
                          }
                          else if ( spawner.SpawnObjects[0].TypeName.ToUpper() == "GORILLA" ) {
                              AnimalSpawner.Add(item);
                          }
                      }
                  }
              }
           
              Console.WriteLine("Total Counted Spawners : {0}", AnimalSpawner.Count);//End Result message with a total count
           
              foreach (Item item in AnimalSpawner)
            item.Delete();
        }
    }
}
 
Last edited:
Code:
using System;
using Server;
using Server.Items;
using Server.Mobiles;
using Server.Commands;
using System.Collections;
using System.Collections.Generic;

namespace Server
{
    public class AnimalSpawnGenerator
    {
        //This is creating a Rectangle using two points : Starting Point  x = 0, y = 0 and ending point x = 6142, y = 4096
        private static Rectangle2D[] m_BritRegions = new Rectangle2D[]//Make a working area for spawn generation arount this region?
        {
                new Rectangle2D( new Point2D( 0, 0 ), new Point2D( 6142, 4094 ) ),
        };

        //These are static fields to hold the XmlSpawner.SpawnObject (More details to SpawnObject in XmlSpawner Class)
        private static XmlSpawner.SpawnObject spawnAnimal01;//What are these for? I don't see spawnAnimal01 02 03 04 etc in the script.
        private static XmlSpawner.SpawnObject spawnAnimal02;
        private static XmlSpawner.SpawnObject spawnAnimal03;
        private static XmlSpawner.SpawnObject spawnAnimal04;
        private static XmlSpawner.SpawnObject spawnAnimal05;
        private static XmlSpawner.SpawnObject spawnAnimal06;
        private static XmlSpawner.SpawnObject spawnAnimal07;
        private static XmlSpawner.SpawnObject spawnAnimal08;
        private static XmlSpawner.SpawnObject spawnAnimal09;
        private static XmlSpawner.SpawnObject spawnAnimal10;
        private static XmlSpawner.SpawnObject spawnAnimal11;
        private static XmlSpawner.SpawnObject spawnAnimal12;

        //These are objects this system is using as a reference to add a spawner
        private static int[] m_Criterion = new int[]
        {
              //Trees
                0xC9E, 0xCA8, 0xCAA, 0xCCA, 0xCCB, 0xCCC, 0xCCD, 0xCD0, 0xCD3, 0xCD6, 0xCD8, 0xCDA, 0xCDD, 0xCE0, 0xCE3,//Tree tile definitions
                0xCE6, 0xCF8, 0xCFB, 0xCFE, 0xD01, 0xD43, 0xD59, 0xD70, 0xD85, 0xD94, 0xD98, 0xD9C, 0xDA0, 0xDA4, 0xDA8,
             
              //Rocks
                4943, 4944, 4945, 4946, 4947, 4948, 4949, 4950, 4951, 4951, 4953, 4954, 4955, 4956, 4957, 4958, 4959,//Rock tile defenitions
                4960, 4961, 4962, 4963, 4964, 4965, 4966, 4967, 4968, 4969, 4970, 4971, 4972, 4973, 6001, 6002, 6003,
                6004, 6005, 6006, 6007, 6008, 6009, 6010, 6011, 6012, 13121, 13122, 13123, 13124, 13125, 13126, 13127,
                13128, 13129, 13130, 13131, 13132, 13133, 13134, 13135, 13136, 13137, 13354, 13355, 13361, 13362, 13363,
                13364, 13365, 13366, 13367, 13368, 13369, 13625, 13626, 13627, 13628,
              //Oak Tree Trunk
                0x12B9,
        };

        public static void Initialize()
        {
            CommandSystem.Register("AnimalSpawnGen", AccessLevel.Administrator, new CommandEventHandler(AnimalSpawnGen_OnCommand));//Command Register
            CommandSystem.Register("AnimalSpawnRem", AccessLevel.Administrator, new CommandEventHandler(AnimalSpawnRem_OnCommand));//Command Register


        }

        [Usage("AnimalSpawnGen")]//Command
        [Description("Generates animal wildlife spawners by analyzing the map. Slow.")]//Description generated in docs
        public static void AnimalSpawnGen_OnCommand(CommandEventArgs e)
        {
            Generate();//Action
        }

        [Usage("AnimalSpawnRem")]//Command
        [Description("Removes animal wildlife spawners by analyzing the map. Slow.")]//Description generated in docs
        public static void AnimalSpawnRem_OnCommand(CommandEventArgs e)
        {
            Remove();//Action
        }

        private static Map m_Map;
        private static int m_Count;

        public static void Generate()//When generating DO
        {
            World.Broadcast(0x35, true, "Generating animal spawners, please wait.");//Broadcast Message to everyone

            Network.NetState.FlushAll(); 
            Network.NetState.Pause(); //Pauses the Network while the lengthy process runs for generating spawners

            m_Map = Map.Felucca;//Map you want the spawns in
            m_Count = 0;//Counts the spawned objects?

            for (int i = 0; i < m_BritRegions.Length; ++i)//Seems to indicate the region the spawner is bound to operate in ? Yes, it will use the rectangle entered above to run the Generate(Rectangle2d region) on, which you find below
                Generate(m_BritRegions[i]);//Do generate in this region? See Generate(Rectangle2d region) below 

            int feluccaCount = m_Count;//Map Count # of spawners generated

            Network.NetState.Resume(); //resumes the network after the spawners are generated/added to the map

            World.Broadcast(0x35, true, "Animal spawner generation complete. {0}", feluccaCount);//Map Count Broadcast
        }

        public static bool IsRock(int id)//If this script finds a rock? Yep and returns true or false
        {
            if (id > m_Criterion[m_Criterion.Length - 1])
                return false;

            for (int i = 0; i < m_Criterion.Length; ++i)
            {
                int delta = id - m_Criterion[i];

                if (delta < 0)
                    return false;
                else if (delta == 0)
                    return true;
            }

            return false;
        }

        private static void AddAnimalSpawner(int x, int y, int z)
        {
            if (Utility.RandomDouble() < 0.9750)
                return;

            Map map = Map.Felucca;//Map you want the spawn in
            IPooledEnumerable eable = map.GetItemsInRange(new Point3D(x, y, z), 20); //This checks to make sure another spawner isn't within 20 tiles

            foreach (Item item in eable)
            {
                if (item is XmlSpawner)
                {
                    if (item.Hue == 346)
                    {
                        return;
                    }
                }
            }

            if (!m_Map.CanFit(x, y, z, 1, false, false))
                return;

            //XmlSpawner(int amount, int minDelay, int maxDelay, int team, int homeRange, int spawnrange, string creatureName)
            XmlSpawner spawner = null;
            int MaxSpawn = 0;
            int Counter = 0;
            switch (Utility.Random(6))
            {
                case 0:
                    spawner = new XmlSpawner(10, 1, 3, 0, 0, Utility.RandomMinMax(22, 30), "Bird");//A random list of animals this puppy can spawn?
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("Chicken", 4));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("Eagle", 2));
                    MaxSpawn = 12;
                    Counter = 3;
                    break;
                case 1:
                    spawner = new XmlSpawner(4, 2, 5, 0, 0, Utility.RandomMinMax(8, 10), "BrownBear");//A random list of animals this puppy can spawn?
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("BlackBear", 4));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("GrizzlyBear", 2));
                    MaxSpawn = 6;
                    Counter = 3;
                    break;
                case 2:
                    spawner = new XmlSpawner(4, 1, 3, 0, 0, Utility.RandomMinMax(18, 24), "Dog");//A random list of animals this puppy can spawn?
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("Cat", 4));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("GiantRat", 2));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("SewerRat", 4));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("JackRabbit", 4));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("Rabbit", 4));
                    MaxSpawn = 10;
                    Counter = 6;
                    break;
                case 3:
                    spawner = new XmlSpawner(2, 1, 3, 0, 0, Utility.RandomMinMax(26, 30), "Bull");//A random list of animals this puppy can spawn?
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("Cow", 4));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("Goat", 2));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("MountainGoat", 2));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("Boar", 2));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("Pig", 4));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("GreatHart", 2));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("Hind", 6));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("Sheep", 6));
                    MaxSpawn = 14;
                    Counter = 8;
                    break;
                case 4:
                    spawner = new XmlSpawner(2, 2, 5, 0, 0, Utility.RandomMinMax(8, 10), "DireWolf");//A random list of animals this puppy can spawn?
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("GreyWolf", 4));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("TimberWolf", 4));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("Panther", 2));
                    MaxSpawn = 6;
                    Counter = 4;
                    break;
                case 5:
                    spawner = new XmlSpawner(6, 3, 7, 0, 0, Utility.RandomMinMax(8, 10), "Gorilla");//A random list of animals this puppy can spawn?
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("Alligator", 3));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("GiantSerpent", 2));
                    spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("Raptor", 1));
                    MaxSpawn = 6;
                    Counter = 4;
                    break;
            }

            //Spawn Orcs ( 30% )                                           //where is this calulated? Is it the combined total of the 10% and 20% below?
            if (spawner != null)
            {//If spawner is empty?
                switch (Utility.Random(10)) //It is Calculated here with the switch statement, as you have a random 10, and case 0 and 1 make up one and 2 is by itself, and 3,4,5,6,7,8,9 are left out so you can assume the first two are 2 of 10 which is 20%
                {
                    case 0:
                    case 1: // 20%                                        //and where is this? calculated?
                        spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("Orc", 2));//What the heck is this random orc generation for?
                        break;
                    case 2: // 10%                                        //and this also?
                        spawner.m_SpawnObjects.Add(new XmlSpawner.SpawnObject("OrcCaptain", 2));//What about this one?
                        break;
                    default:
                        break;
                }
            }

            if (spawner != null)
            {//If spawner is empty?
                for (int i = 0; i < Counter; i++)
                {//Unsure what this does.
                    spawner.SpawnObjects[i].SpawnsPerTick = 1;//No idea what this is ticking
                }

                spawner.Name = "Animal Spawner #" + m_Count;//Displays "Animal Spawner" with a count?
                spawner.MoveToWorld(new Point3D(x, y, z), Map.Felucca);//Move to Map
                spawner.MaxCount = MaxSpawn;//Defines the MaxCount is the Max amount Spawned?
                spawner.Hue = 346;//Hue of said spawner?
            }

            ++m_Count;//counting something again
        }

        public static void Generate(Rectangle2D region)//Generate instructions but really don't undertand what its doing //This is going to check the tiles of the rectangle entered above
        {
            int OakTree = 0x12B9;//Is it just this sole tile we are looking for? Not sure why they have this here, it is doing nothing in this method

            for (int rx = 0; rx < region.Width; ++rx)//something about the x region coordinate
            {
                for (int ry = 0; ry < region.Height; ++ry)//something about the y region coordinate
                {
                    int vx = rx + region.X;//x coordinate?
                    int vy = ry + region.Y;//y coordinate?

                    StaticTile[] tiles = m_Map.Tiles.GetStaticTiles(vx, vy);

                    for (int i = 0; i < tiles.Length; ++i)
                    {
                        StaticTile tile = tiles[i];

                        int id = tile.ID;
                        id &= 0x3FFF;
                        int z = tile.Z;

                        if (IsRock(id))
                        {
                            AddAnimalSpawner(vx + 1, vy, z);//adding a spawner at a coordinate? This is where if runs the AddAnimalSpawner Method, see above
                        }
                    }
                }
            }
        }

        public static void Remove()
        {
            List<Item> itemList = new List<Item>(World.Items.Values);//no idea what this is doing except telling the server to expect a list of items?

            List<Item> AnimalSpawner = new List<Item>();

            foreach (Item item in itemList)//Removal instructions also no idea what this is doing
            {
                if (item is XmlSpawner)
                {
                    XmlSpawner spawner = item as XmlSpawner;
                    if (spawner.SpawnObjects.Length > 0)
                    {
                        if (spawner.SpawnObjects[0].TypeName.ToUpper() == "BROWNBEAR")
                        {//why are these animals here in all caps?
                            AnimalSpawner.Add(item);
                        }
                        else if (spawner.SpawnObjects[0].TypeName.ToUpper() == "BLACKBEAR")
                        {
                            AnimalSpawner.Add(item);
                        }
                        else if (spawner.SpawnObjects[0].TypeName.ToUpper() == "GRIZZLYBEAR")
                        {
                            AnimalSpawner.Add(item);
                        }
                        else if (spawner.SpawnObjects[0].TypeName.ToUpper() == "POLARBEAR")
                        {
                            AnimalSpawner.Add(item);
                        }
                        else if (spawner.SpawnObjects[0].TypeName.ToUpper() == "BIRD")
                        {
                            AnimalSpawner.Add(item);
                        }
                        else if (spawner.SpawnObjects[0].TypeName.ToUpper() == "CHICKEN")
                        {
                            AnimalSpawner.Add(item);
                        }
                        else if (spawner.SpawnObjects[0].TypeName.ToUpper() == "EAGLE")
                        {
                            AnimalSpawner.Add(item);
                        }
                        else if (spawner.SpawnObjects[0].TypeName.ToUpper() == "DOG")
                        {
                            AnimalSpawner.Add(item);
                        }
                        else if (spawner.SpawnObjects[0].TypeName.ToUpper() == "BULL")
                        {
                            AnimalSpawner.Add(item);
                        }
                        else if (spawner.SpawnObjects[0].TypeName.ToUpper() == "DIREWOLF")
                        {
                            AnimalSpawner.Add(item);
                        }
                        else if (spawner.SpawnObjects[0].TypeName.ToUpper() == "GORILLA")
                        {
                            AnimalSpawner.Add(item);
                        }
                    }
                }
            }

            Console.WriteLine("Total Counted Spawners : {0}", AnimalSpawner.Count);//End Result message with a total count

            foreach (Item item in AnimalSpawner)
                item.Delete();
        }
    }
}

Answered some but not all of your questions, this script is not finished, some unused code and poor layout of methods IMO!
 
Thank you so much for taking the time to answer some of these questions for me! The biggest takeaways for me in what you answered is the unused methods and where you pointed out where its checking for spawners within x distance of tiles. That's a big help. I thought it looked unfinished also, but again I don't know much about writing code, which makes it more complicated to customize when there is extra unused stuff in there.
 
Back