Full Version : 2?'s about XMLSpawner
xmlspawner >>Q&A >>2?'s about XMLSpawner


<< Prev | Next >>

Gembone- 08-13-2006
ok first questiong is this. is there a way to spawn certain dungeons without spawning the entire map. Like a region spawn command or something. I had the entire facet of Tram spawned and only needed a couple dungeons spawned so I removed all spawners in the facet. so I am trying to respawn the dungeons I need without doing it by hand.

second question is this. I am looking to add the hasrummaged code for the smartspawning feature and am not sure where to place the edit in the basecreature.cs mine is already modded for the FSATS system.

any help is greatly appreciated

ArteGordon- 08-13-2006
If you assign the RegionName property on the spawner, then it will place spawns in that region and ignore the SpawnRange and X1Y1_X2Y2 settings.

Make the rummaging mod in the OnThink method where it currently already checks for rummaging. It doesnt matter what other mods you have made to OnThink.

QUOTE

       public virtual void OnThink()
        {
            if (EnableRummaging && CanRummageCorpses && !Summoned && !Controlled && DateTime.Now >= m_NextRummageTime)
            {
                double min, max;

                if (ChanceToRummage > Utility.RandomDouble() && Rummage())
                {
                    min = MinutesToNextRummageMin;
                    max = MinutesToNextRummageMax;
                    // ARTEGORDONMOD
                    // flag mobs that have rummaged
                    XmlAttach.AttachTo(this, new XmlData("HasRummaged"));

                }
                else
                {
                    min = MinutesToNextChanceMin;
                    max = MinutesToNextChanceMax;
                }

                double delay = min + (Utility.RandomDouble() * (max - min));
                m_NextRummageTime = DateTime.Now + TimeSpan.FromMinutes(delay);
            }

            if (CanBreath && DateTime.Now >= m_NextBreathTime) // tested: controled dragons do breath fire, what about summoned skeletal dragons?
            {
                Mobile target = this.Combatant;

                if (target != null && target.Alive && !target.IsDeadBondedPet && CanBeHarmful(target) && target.Map == this.Map && !IsDeadBondedPet && target.InRange(this, BreathRange) && InLOS(target) && !BardPacified)
                    BreathStart(target);

                m_NextBreathTime = DateTime.Now + TimeSpan.FromSeconds(BreathMinDelay + (Utility.RandomDouble() * BreathMaxDelay));
            }
        }


and then in the HoldSmartSpawning property, just add the test for rummaging

QUOTE

        // ARTEGORDONMOD
        // smartspawning control
        public virtual bool HoldSmartSpawning
        {
            get
            {
                // dont smartspawn paragons
                if (IsParagon) return true;

                if (this is BaseChampion) return true;

                // dont smartspawn mobs that have rummaged
                if (XmlAttach.FindAttachment(this, typeof(XmlData), "HasRummaged") != null) return true;

                // dont smartspawn mobs that have been stolen from
                if (StolenFrom) return true;

                // dont smartspawn socketed/socketable mobs
                if(XmlAttach.FindAttachment(this, typeof(XmlSockets)) != null || XmlAttach.FindAttachment(this, typeof(XmlSocketable)) != null) return true;
                return false;
            }
        }

Gembone- 08-13-2006
ok I have the first part in the BaseCreature.cs. brain is having trouble understanding where to put
CODE
// ARTEGORDONMOD
       // smartspawning control
       public virtual bool HoldSmartSpawning
       {
           get
           {
               // dont smartspawn paragons
               if (IsParagon) return true;

               if (this is BaseChampion) return true;

               // dont smartspawn mobs that have rummaged
               if (XmlAttach.FindAttachment(this, typeof(XmlData), "HasRummaged") != null) return true;

               // dont smartspawn mobs that have been stolen from
               if (StolenFrom) return true;

               // dont smartspawn socketed/socketable mobs
               if(XmlAttach.FindAttachment(this, typeof(XmlSockets)) != null || XmlAttach.FindAttachment(this, typeof(XmlSocketable)) != null) return true;
               return false;
           }
       }
and in what script it belongs in.
sorry to not be understanding this. maybe sleep and staying out of the sun would help. thanks in advance for the help

ArteGordon- 08-13-2006
it goes into your basecreature.cs script. If you havent already added it, then it doesnt exist yet (it is not a property that exists in basecreature by default). What I pasted was a slightly modified version of what I use. It has things that you probably havent added. Here is a simpler one that you can try.

It can be placed anywhere within the BaseCreature class definition.
Just put it next to the OnThink method, for example.

CODE

      // ARTEGORDONMOD
       // smartspawning control
       public virtual bool HoldSmartSpawning
       {
           get
           {
               // dont smartspawn paragons
               if (IsParagon) return true;

               // dont smartspawn champs
               if (this is BaseChampion) return true;

               // dont smartspawn mobs that have rummaged
               if (XmlAttach.FindAttachment(this, typeof(XmlData), "HasRummaged") != null) return true;

               return false;
           }
       }

Gembone- 08-13-2006
ok i must be putting in the wrong place I am getting these errors
CODE
RunUO - [www.runuo.com] Version 1.0.0, Build 36918
Scripts: Compiling C# scripts...failed (4 errors, 2 warnings)
- Error: Scripts\Engines\AI\Creature\BaseCreature.cs: CS0246: (line 730, column
61) The type or namespace name 'XmlData' could not be found (are you missing a
using directive or an assembly reference?)
- Error: Scripts\Engines\AI\Creature\BaseCreature.cs: CS0246: (line 730, column
23) The type or namespace name 'XmlAttach' could not be found (are you missing
a using directive or an assembly reference?)
- Error: Scripts\Engines\AI\Creature\BaseCreature.cs: CS0246: (line 4843, colum
n 45) The type or namespace name 'XmlData' could not be found (are you missing a
using directive or an assembly reference?)
- Error: Scripts\Engines\AI\Creature\BaseCreature.cs: CS0246: (line 4843, colum
n 16) The type or namespace name 'XmlAttach' could not be found (are you missing
a using directive or an assembly reference?)
- Warning: Scripts\Customs\ExplodeCommand\Explode.cs: CS0183: (line 38, column
28) The given expression is always of the provided ('Server.Mobile') type
- Warning: Scripts\Customs\ExplodeCommand\Explode.cs: CS0183: (line 44, column
28) The given expression is always of the provided ('Server.Mobile') type
Scripts: One or more scripts failed to compile or no script files were found.
- Press return to exit, or R to try again.

ArteGordon- 08-13-2006
you need to add this to the beginning of basecreature.cs

CODE

using Server.Engines.XmlSpawner2;

Gembone- 08-13-2006
ok that got it going. thanks for the help and patience dealing with me