Example #1
0
        public static void ConvertRegionSpawners(Region r)
        {
            foreach (Sector s in r.Sectors)
            {
                foreach (Item i in s.Items.Where(i => i is XmlSpawner && _SpawnerBounds.Contains(i)))
                {
                    XmlSpawner spawner = i as XmlSpawner;

                    foreach (XmlSpawner.SpawnObject obj in spawner.SpawnObjects)
                    {
                        if (obj.TypeName != null)
                        {
                            string name = obj.TypeName.ToLower();

                            if (name == "gazer" || name == "gazerlarva")
                            {
                                obj.TypeName = "StrangeGazer";
                            }
                            else if (name == "headlessone")
                            {
                                obj.TypeName = "HeadlessMiner";
                            }
                            else if (name == "harpy")
                            {
                                obj.TypeName = "DazzledHarpy";
                            }
                            else if (name == "stoneharpy")
                            {
                                obj.TypeName = "VampireMongbat";
                            }
                        }
                    }
                }
            }
        }
Example #2
0
        public static object Spawn(string spawnString, object caller)
        {
            if (spawnString == null || spawnString == "")
            {
                return(null);
            }

            int  commaIndex = spawnString.IndexOf(',');
            Type type;

            if (commaIndex != -1)
            {
                type = ScriptCompiler.FindTypeByName(spawnString.Substring(0, commaIndex));
            }
            else
            {
                type = ScriptCompiler.FindTypeByName(spawnString);
            }

            // do not allow mobiles to be spawned into item backpack
            if (type != null)
            {
                object o = XmlSpawner.CreateObject(type, spawnString);
                if (o == null)
                {
                    throw new UberScriptException("Could not create spawn: " + spawnString + "... should be impossible!");
                }
                return(o);
            }
            return(null);
        }
Example #3
0
        public static int Remove(XmlSpawner spawner, string toRemove)
        {
            List <XmlSpawner.SpawnObject> remove  = new List <XmlSpawner.SpawnObject>();
            List <XmlSpawner.SpawnObject> objects = spawner.SpawnObjects.ToList();

            foreach (var obj in objects)
            {
                if (obj == null || obj.TypeName == null)
                {
                    continue;
                }

                string typeName   = obj.TypeName.ToLower();
                string lookingFor = toRemove.ToLower();

                if (typeName != null && typeName.IndexOf(lookingFor) >= 0)
                {
                    remove.Add(obj);
                }
            }

            int count = remove.Count;

            foreach (var obj in remove)
            {
                spawner.RemoveSpawnObject(obj);
            }

            ColUtility.Free(remove);
            return(count);
        }
Example #4
0
        public static bool Replace(ISpawner spwner, string current, string replace, string check)
        {
            bool replaced = false;

            if (spwner is XmlSpawner)
            {
                XmlSpawner spawner = (XmlSpawner)spwner;

                foreach (var obj in spawner.SpawnObjects)
                {
                    if (obj == null || obj.TypeName == null)
                    {
                        continue;
                    }

                    string typeName   = obj.TypeName.ToLower();
                    string lookingFor = current.ToLower();

                    if (typeName != null && typeName.IndexOf(lookingFor) >= 0)
                    {
                        if (String.IsNullOrEmpty(check) || typeName.IndexOf(check) < 0)
                        {
                            obj.TypeName = typeName.Replace(lookingFor, replace);

                            if (!replaced)
                            {
                                replaced = true;
                            }
                        }
                    }
                }
            }
            else if (spwner is Spawner)
            {
                Spawner spawner = (Spawner)spwner;

                for (int i = 0; i < spawner.SpawnObjects.Count; i++)
                {
                    var so = spawner.SpawnObjects[i];

                    string typeName   = so.SpawnName.ToLower();
                    string lookingFor = current.ToLower();

                    if (typeName != null && typeName.IndexOf(lookingFor) >= 0)
                    {
                        if (String.IsNullOrEmpty(check) || typeName.IndexOf(check) < 0)
                        {
                            so.SpawnName = typeName.Replace(lookingFor, replace);

                            if (!replaced)
                            {
                                replaced = true;
                            }
                        }
                    }
                }
            }

            return(replaced);
        }
Example #5
0
            protected override void OnTick()
            {
                foreach (Item ps in m_Owner.GetItemsInRange(m_Owner.Hue))
                {
                    if (ps != null && ps is XmlSpawner)
                    {
                        XmlSpawner sp = (XmlSpawner)ps;
                        if (ps.Hue == 10)
                        {
                            sp.Running = true;
                        }
                    }
                }

                if (m_Owner.Weight == 1.0)
                {
                    Orc orc = new Orc();
                    orc.MoveToWorld(m_Owner.Location, m_Owner.Map);
                    orc.Hidden = true;
                    Regions.GuardedRegion reg = (Regions.GuardedRegion)orc.Region.GetRegion(typeof(Regions.GuardedRegion));
                    if (reg != null && reg.Disabled)
                    {
                        reg.Disabled = false;
                    }

                    orc.Delete();
                }

                StopTimer(m_Owner);
                m_Owner.Delete();
            }
Example #6
0
        public override void Delete()
        {
            if (_MutateTo != null)
            {
                ISpawner s = Spawner;

                if (s is XmlSpawner)
                {
                    XmlSpawner xml = (XmlSpawner)s;

                    if (xml.SpawnObjects == null)
                    {
                        return;
                    }

                    foreach (XmlSpawner.SpawnObject so in xml.SpawnObjects)
                    {
                        for (int i = 0; i < so.SpawnedObjects.Count; ++i)
                        {
                            if (so.SpawnedObjects[i] == this)
                            {
                                so.SpawnedObjects[i] = _MutateTo;

                                Spawner = null;
                                base.Delete();
                                return;
                            }
                        }
                    }
                }
            }

            base.Delete();
        }
Example #7
0
        public XmlCategorizedAddGump(Mobile owner, XmlAddCAGCategory category, int page, int index, Gump gump) : base(GumpOffsetX, GumpOffsetY)
        {
            if (category == null)
            {
                category = XmlAddCAGCategory.Root;
                page     = 0;
            }

            owner.CloseGump(typeof(WhoGump));

            m_Owner    = owner;
            m_Category = category;

            m_Index = index;
            m_Gump  = gump;
            if (gump is XmlAddGump)
            {
                XmlAddGump xmladdgump = (XmlAddGump)gump;

                if (xmladdgump != null && xmladdgump.defs != null)
                {
                    xmladdgump.defs.CurrentCategory     = category;
                    xmladdgump.defs.CurrentCategoryPage = page;
                }
            }
            else
            if (gump is XmlSpawnerGump)
            {
                m_Spawner = ((XmlSpawnerGump)gump).m_Spawner;
            }

            Initialize(page);
        }
Example #8
0
        public static bool Replace(XmlSpawner spawner, string current, string replace, string check)
        {
            bool replaced = false;

            foreach (var obj in spawner.SpawnObjects)
            {
                if (obj == null || obj.TypeName == null)
                {
                    continue;
                }

                string typeName   = obj.TypeName.ToLower();
                string lookingFor = current.ToLower();

                if (typeName != null && typeName.IndexOf(lookingFor) >= 0)
                {
                    if (String.IsNullOrEmpty(check) || typeName.IndexOf(check) < 0)
                    {
                        obj.TypeName = typeName.Replace(lookingFor, replace);

                        if (!replaced)
                        {
                            replaced = true;
                        }
                    }
                }
            }

            return(replaced);
        }
Example #9
0
        private void Start()
        {
            m_NextMsgTime = DateTime.Now + TimeSpan.FromMinutes(msgevery);

            foreach (Item ps in this.GetItemsInRange(range))
            {
                if (ps != null && ps is XmlSpawner)
                {
                    XmlSpawner sp = (XmlSpawner)ps;
                    if (ps.Hue == 5)
                    {
                        sp.Running = true;
                        sp.Respawn();
                    }
                    if (ps.Hue == 10)
                    {
                        sp.Running = false;
                    }
                }
            }

            Regions.GuardedRegion reg = (Regions.GuardedRegion) this.Region.GetRegion(typeof(Regions.GuardedRegion));
            if (reg != null && !(reg.Disabled))
            {
                restoreguards = true;
                reg.Disabled  = true;
            }

            string meg = this.Region.Name + " is under attack by forces of " + this.Name + "!!!";

            BroadcastMessage(34, meg, true);
            init = true;
        }
Example #10
0
        private void End()
        {
            foreach (Item ps in this.GetItemsInRange(range))
            {
                if (ps != null && ps is XmlSpawner)
                {
                    XmlSpawner sp = (XmlSpawner)ps;
                    if (ps.Hue == 5)
                    {
                        sp.Running = false;
                    }
                }
            }

            FinalStone stone = new FinalStone();

            if (restoreguards)
            {
                stone.Weight = 1.0;
            }
            stone.Hue = range;
            stone.MoveToWorld(this.Location, this.Map);

            string meg = this.Name + " has fallen !!! " + this.Region.Name + " has been liberated.";

            BroadcastMessage(77, meg, true);
        }
Example #11
0
        public void CreateVendor(TownIDValue town, Point3D location, Map map, TownVendorType vendorType, int vendorCount, int spawnRange, int homeRange)
        {
            XmlSpawner xmlSpawner = null;

            switch (vendorType)
            {
            case TownVendorType.Banker: xmlSpawner = new XmlSpawner(new List <string> {
                    "Banker"
                }, new List <int> {
                    vendorCount
                }); break;
            }

            if (xmlSpawner == null)
            {
                return;
            }

            xmlSpawner.MoveToWorld(location, map);
            xmlSpawner.SpawnRange = spawnRange;
            xmlSpawner.HomeRange  = homeRange;
            xmlSpawner.MaxCount   = vendorCount;

            xmlSpawner.SmartRespawn();
        }
Example #12
0
        /// <summary>
        /// Converts a BoxSpawn to an actual spawner object. This function is used to generate
        /// spawn groups created in Pandora's Box
        /// </summary>
        /// <param name="spawn">The BoxSpawn object describing the spawn that should be created</param>
        /// <returns>A Spawner object - null if not valid</returns>
        public static Item CreateBoxSpawn(BoxSpawn spawn)
        {
            if (spawn == null || spawn.Entries.Count == 0)
            {
                return(null);
            }

            XmlSpawner spawner = new XmlSpawner();

            spawner.Amount    = spawn.Count;
            spawner.MaxCount  = spawn.Count;
            spawner.MinDelay  = TimeSpan.FromSeconds(spawn.MinDelay);
            spawner.MaxDelay  = TimeSpan.FromSeconds(spawn.MaxDelay);
            spawner.Team      = spawn.Team;
            spawner.HomeRange = spawn.HomeRange;

            spawner.Running = false;

            spawner.Group = spawn.Group;

            XmlSpawner.SpawnObject[] spawnObjects = new Server.Mobiles.XmlSpawner.SpawnObject[spawn.Entries.Count];

            for (int i = 0; i < spawnObjects.Length; i++)
            {
                BoxSpawnEntry entry = spawn.Entries[i] as BoxSpawnEntry;

                spawnObjects[i] = new Server.Mobiles.XmlSpawner.SpawnObject(entry.Type, entry.MaxCount);
            }

            spawner.SpawnObjects = spawnObjects;

            return(spawner);
        }
Example #13
0
        /// <summary>
        /// Converts a spawner to a SpawnEntry used in SpawnData.
        /// </summary>
        /// <param name="spawnerItem">The spawner to convert</param>
        /// <returns>The SpawnEntry representing the spawner</returns>
        public static SpawnEntry SpawnerToData(Item spawnerItem)
        {
            XmlSpawner spawner = spawnerItem as XmlSpawner;

            if (spawner == null || spawner.Map == Server.Map.Internal)
            {
                return(null);
            }

            SpawnEntry entry = new SpawnEntry();

            entry.Map = spawner.Map.MapID;
            entry.X   = spawner.X;
            entry.Y   = spawner.Y;
            entry.Z   = spawner.Z;

            entry.Team     = spawner.Team;
            entry.Count    = spawner.MaxCount;
            entry.Range    = spawner.HomeRange;
            entry.MinDelay = spawner.MinDelay.TotalSeconds;
            entry.MaxDelay = spawner.MaxDelay.TotalSeconds;

            foreach (XmlSpawner.SpawnObject spawn in spawner.SpawnObjects)
            {
                entry.Names.Add(spawn.TypeName);
            }

            return(entry);
        }
Example #14
0
        private static void GenQuest_Command(CommandEventArgs e)
        {
            e.Mobile.SendMessage("Creating Mad Scientist Quest...");

            foreach (SutekIngredientInfo def in m_Ingredients)
            {
                WeakEntityCollection.Add("sa", new SutekIngredientItem(def));
            }

            XmlSpawner sp = new XmlSpawner("Sutek");

            sp.SpawnRange = 5;
            sp.HomeRange  = 5;
            sp.MoveToWorld(new Point3D(917, 594, -14), Map.TerMur);
            sp.Respawn();
            WeakEntityCollection.Add("sa", sp);

            List <Item> toDelete = new List <Item>(World.Items.Values.Where(i => i is XmlSpawner && (i.Name == "PerfectTimingSpawner" || i.Name == "PerfectTimingSpawner2")));

            foreach (var item in toDelete)
            {
                item.Delete();
            }

            e.Mobile.SendMessage("Generation completed, deleted {0} spawners!", toDelete.Count);
            ColUtility.Free(toDelete);
        }
Example #15
0
        private static void ExecuteDeathAction(Item corpse, Mobile killer, string action)
        {
            if (action == null || action.Length <= 0 || corpse == null)
            {
                return;
            }

            string status_str = null;

            XmlSpawner.SpawnObject TheSpawn = new XmlSpawner.SpawnObject(null, 0);

            TheSpawn.TypeName = action;
            string substitutedtypeName = BaseXmlSpawner.ApplySubstitution(null, corpse, killer, action);
            string typeName            = BaseXmlSpawner.ParseObjectType(substitutedtypeName);

            Point3D loc = corpse.Location;
            Map     map = corpse.Map;

            if (BaseXmlSpawner.IsTypeOrItemKeyword(typeName))
            {
                BaseXmlSpawner.SpawnTypeKeyword(corpse, TheSpawn, typeName, substitutedtypeName, true, killer, loc, map, out status_str);
            }
            else
            {
                // its a regular type descriptor so find out what it is
                Type type = SpawnerType.GetType(typeName);
                try
                {
                    string[] arglist = BaseXmlSpawner.ParseString(substitutedtypeName, 3, "/");
                    object   o       = XmlSpawner.CreateObject(type, arglist[0]);

                    if (o == null)
                    {
                        status_str = "invalid type specification: " + arglist[0];
                    }
                    else
                    if (o is Mobile)
                    {
                        Mobile m = (Mobile)o;
                        if (m is BaseCreature)
                        {
                            BaseCreature c = (BaseCreature)m;
                            c.Home = loc;                                     // Spawners location is the home point
                        }

                        m.Location = loc;
                        m.Map      = map;

                        BaseXmlSpawner.ApplyObjectStringProperties(null, substitutedtypeName, m, killer, corpse, out status_str);
                    }
                    else
                    if (o is Item)
                    {
                        Item item = (Item)o;
                        BaseXmlSpawner.AddSpawnItem(null, corpse, TheSpawn, item, loc, map, killer, false, substitutedtypeName, out status_str);
                    }
                }
                catch { }
            }
        }
Example #16
0
        // determines whether  XmlSpawner, XmlAttachment, or XmlQuest OnSkillUse methods should be invoked.
        public static void CheckSkillUse(Mobile m, Skill skill, bool success)
        {
            if (!(m is PlayerMobile) || skill == null)
            {
                return;
            }

            /*
             * // first check for any attachments that might support OnSkillUse
             * ArrayList list = XmlAttach.FindAttachments(m);
             * if(list != null && list.Count > 0)
             * {
             *  foreach(XmlAttachment a in list)
             *  {
             *      if(a != null && !a.Deleted && a.HandlesOnSkillUse)
             *      {
             *          a.OnSkillUse(m, skill, success);
             *      }
             *  }
             * }
             */

            // then check for registered skills
            ArrayList skilllist = RegisteredSkill.TriggerList(skill.SkillName, m.Map);

            if (skilllist == null)
            {
                return;
            }

            // determine whether there are any registered objects for this skill
            foreach (RegisteredSkill rs in skilllist)
            {
                if (rs.sid == skill.SkillName)
                {
                    // if so then invoke their skill handlers
                    if (rs.target is XmlSpawner)
                    {
                        XmlSpawner spawner = (XmlSpawner)rs.target;

                        if (spawner.HandlesOnSkillUse)
                        {
                            // call the spawner handler
                            spawner.OnSkillUse(m, skill, success);
                        }
                    }
                    else
                    if (rs.target is IXmlQuest)
                    {
                        IXmlQuest quest = (IXmlQuest)rs.target;
                        if (quest.HandlesOnSkillUse)
                        {
                            // call the xmlquest handler
                            quest.OnSkillUse(m, skill, success);
                        }
                    }
                }
            }
        }
Example #17
0
            public XmlSpawner CreateSpawner()
            {
                XmlSpawner spawner = new XmlSpawner(m_Amount, (int)m_MinDelay.TotalSeconds, (int)m_MaxDelay.TotalSeconds, 0, 20, 10, m_Creature);

                spawner.MoveToWorld(this.Location, this.Map);

                return(spawner);
            }
Example #18
0
        private static bool ConvertSpawner(string id, DataRow dr)
        {
            XmlSpawner spawner = World.Items.Values.OfType <XmlSpawner>().FirstOrDefault(s => s.UniqueId == id);

            int c = 0;

            return(ConvertSpawner(spawner, dr, ref c));
        }
Example #19
0
        public static void Remove()
        {
            string filename = XmlSpawner.LocateFile("RevampedSpawns/BlackthornDungeonCreature.xml");

            XmlSpawner.XmlLoadFromFile(filename, string.Empty, null, Point3D.Zero, Map.Internal, false, 0, false, out int processedmaps, out int processedspawners);

            RemoveDecoration();
        }
Example #20
0
        /// <summary>
        /// Initializes and starts the spawner, spawning all the creatures
        /// </summary>
        /// <param name="spawner">The spawner item</param>
        public static void StartSpawner(Item spawner)
        {
            XmlSpawner s = spawner as XmlSpawner;

            if (s != null)
            {
                s.Running = true;
                s.Respawn();
            }
        }
Example #21
0
        public static void LoadFromXmlSpawner(string location, Map map, string prefix = null)
        {
            string filename = XmlSpawner.LocateFile(location);

            string SpawnerPrefix = prefix == null ? string.Empty : prefix;
            int    processedmaps;
            int    processedspawners;

            XmlSpawner.XmlLoadFromFile(filename, SpawnerPrefix, null, Point3D.Zero, map, false, 0, false, out processedmaps, out processedspawners);

            ToConsole(String.Format("Created {0} spawners from {1} with -{2}- prefix.", processedspawners, location, SpawnerPrefix == string.Empty ? "NO" : SpawnerPrefix));
        }
Example #22
0
        public static void Generate(CommandEventArgs e)
        {
            Delete(e);

            Point3D[] list = Siege.SiegeShard ? GetMalasPoints() : GetTramPoints();
            Map       map  = Siege.SiegeShard ? Map.Malas : Map.Trammel;

            Item item = new tent_whiteAddon();

            WeakEntityCollection.Add(EntityName, item);
            item.MoveToWorld(list[0], map);

            item = new tent_brownAddon();
            WeakEntityCollection.Add(EntityName, item);
            item.MoveToWorld(list[1], map);

            Mobile mob = new CasinoCashier();

            WeakEntityCollection.Add(EntityName, mob);
            mob.MoveToWorld(list[2], map);

            mob = new CasinoCashier();
            WeakEntityCollection.Add(EntityName, mob);
            mob.MoveToWorld(list[3], map);

            mob = new CasinoCashier();
            WeakEntityCollection.Add(EntityName, mob);
            mob.MoveToWorld(list[4], map);

            mob = new ChucklesLuckDealer();
            WeakEntityCollection.Add(EntityName, mob);
            mob.MoveToWorld(list[5], map);

            mob = new HiMiddleLowDealer();
            WeakEntityCollection.Add(EntityName, mob);
            mob.MoveToWorld(list[6], map);

            mob = new DiceRiderDealer();
            WeakEntityCollection.Add(EntityName, mob);
            mob.MoveToWorld(list[7], map);

            var xmlspawner = new XmlSpawner(8, 1, 2, 0, 25, "CasinoWaitress");

            WeakEntityCollection.Add(EntityName, xmlspawner);
            xmlspawner.MoveToWorld(list[8], map);
            xmlspawner.MaxCount   = 8;
            xmlspawner.SpawnRange = 25;
            xmlspawner.SpawnRange = 25;
            xmlspawner.DoRespawn  = true;

            e.Mobile.SendMessage("Fortune Fire Casino Generated in {0}!", map);
        }
Example #23
0
        public static void ConvertRegionSpawners(Region r)
        {
            if (r == null)
            {
                return;
            }

            List <XmlSpawner> list = new List <XmlSpawner>();

            foreach (Sector s in r.Sectors)
            {
                foreach (Item i in s.Items)
                {
                    if (i is XmlSpawner && _SpawnerBounds.Contains(i))
                    {
                        XmlSpawner spawner = i as XmlSpawner;

                        foreach (XmlSpawner.SpawnObject obj in spawner.SpawnObjects)
                        {
                            if (obj.TypeName != null)
                            {
                                string name = obj.TypeName.ToLower();

                                if (name == "gazer" || name == "gazerlarva")
                                {
                                    obj.TypeName = "StrangeGazer";
                                }
                                else if (name == "headlessone")
                                {
                                    obj.TypeName = "HeadlessMiner";
                                }
                                else if (name == "harpy")
                                {
                                    obj.TypeName = "DazzledHarpy";
                                }
                                else if (name == "stoneharpy")
                                {
                                    obj.TypeName = "VampireMongbat";
                                }
                            }
                        }

                        list.Add(spawner);
                    }
                }
            }

            list.ForEach(spawner => spawner.DoRespawn = true);

            ColUtility.Free(list);
        }
Example #24
0
        protected override void OnTarget(Mobile from, object target)
        {
            if (target is WayPoint && m_ThisWaypoint != null)
            {
                WayPoint nextWaypoint = target as WayPoint;

                if (m_ThisWaypoint == nextWaypoint)
                {
                    from.SendMessage("You cannot make a waypoint it's own waypoint");
                    return;
                }

                m_ThisWaypoint.NextWaypoint = nextWaypoint;
                nextWaypoint.Hue            = m_ThisWaypoint.Hue;

                if (m_ThisWaypoint.Visible)
                {
                    nextWaypoint.Visible = true;
                }

                if (nextWaypoint.PreviousWaypoints.IndexOf(m_ThisWaypoint) < 0)
                {
                    nextWaypoint.PreviousWaypoints.Add(m_ThisWaypoint);
                }
            }

            else if (target is XmlSpawner && m_ThisWaypoint != null)
            {
                XmlSpawner xmlSpawner = target as XmlSpawner;

                xmlSpawner.WayPoint = m_ThisWaypoint;
                m_ThisWaypoint.Hue  = xmlSpawner.Hue;

                if (xmlSpawner.Visible)
                {
                    m_ThisWaypoint.Visible = true;
                }

                if (m_ThisWaypoint.XMLSpawners.IndexOf(xmlSpawner) < 0)
                {
                    m_ThisWaypoint.XMLSpawners.Add(xmlSpawner);
                }
            }

            else
            {
                from.SendMessage("That is not a waypoint or XMLSpawner.");
            }
        }
Example #25
0
        public void ClearArena()
        {
            if (ArenaSize <= 0)
            {
                return;
            }

            ArrayList mlist = new ArrayList();

            IPooledEnumerable eable = this.GetMobilesInRange(ArenaSize);

            // who is currently within the arena
            foreach (Mobile p in eable)
            {
                if (p == null)
                {
                    continue;
                }

                IChallengeEntry entry = GetParticipant(p);

                // if this is not a current participant then move them
                if (entry == null)
                {
                    // prepare to move them off
                    mlist.Add(p);
                }
            }

            eable.Free();

            // move non-participants
            foreach (Mobile p in mlist)
            {
                for (int i = 0; i < 10; i++)
                {
                    int     x      = Location.X + (ArenaSize + i) * (Utility.RandomBool() ? 1 : -1);
                    int     y      = Location.Y + (ArenaSize + i) * (Utility.RandomBool() ? 1 : -1);
                    int     z      = Map.GetAverageZ(x, y);
                    Point3D newloc = new Point3D(x, y, z);

                    if (XmlSpawner.IsValidMapLocation(newloc, p.Map))
                    {
                        p.MoveToWorld(newloc, p.Map);
                    }
                }
            }
        }
Example #26
0
        public override void OnClick(Mobile from, int page, int index, Gump gump)
        {
            if (m_Type == null)
            {
                from.SendMessage("That is an invalid type name.");
            }
            else
            {
                if (gump is XmlAddGump)
                {
                    XmlAddGump xmladdgump = (XmlAddGump)gump;

                    //Commands.Handle( from, String.Format( "{0}Add {1}", Commands.CommandPrefix, m_Type.Name ) );
                    if (xmladdgump != null && xmladdgump.defs != null && xmladdgump.defs.NameList != null &&
                        index >= 0 && index < xmladdgump.defs.NameList.Length)
                    {
                        xmladdgump.defs.NameList[index] = m_Type.Name;
                        XmlAddGump.Refresh(from, true);
                    }
                    from.SendGump(new XmlCategorizedAddGump(from, m_Parent, page, index, xmladdgump));
                }
                else
                if (gump is XmlSpawnerGump)
                {
                    XmlSpawner m_Spawner = ((XmlSpawnerGump)gump).m_Spawner;

                    if (m_Spawner != null)
                    {
                        XmlSpawnerGump xg = m_Spawner.SpawnerGump;

                        if (xg != null)
                        {
                            xg.Rentry = new XmlSpawnerGump.ReplacementEntry
                            {
                                Typename = m_Type.Name,
                                Index    = index,
                                Color    = 0x1436
                            };

                            Timer.DelayCall(TimeSpan.Zero, new TimerStateCallback(XmlSpawnerGump.Refresh_Callback), new object[] { from });
                            //from.CloseGump(typeof(XmlSpawnerGump));
                            //from.SendGump( new XmlSpawnerGump(xg.m_Spawner, xg.X, xg.Y, xg.m_ShowGump, xg.xoffset, xg.page, xg.Rentry) );
                        }
                    }
                }
            }
        }
Example #27
0
        private static bool DeleteSpawner(string id)
        {
            if (id == null)
            {
                return(false);
            }

            XmlSpawner spawner = World.Items.Values.OfType <XmlSpawner>().FirstOrDefault(s => s.UniqueId == id);

            if (spawner != null)
            {
                spawner.Delete();
                return(true);
            }

            return(false);
        }
        // create an addon with the static components described in the multi.txt file
        public static XmlSpawnerAddon ReadMultiFile(string filename, out string status_str)
        {
            status_str = null;

            if (filename == null)
            {
                return(null);
            }

            XmlSpawnerAddon newaddon = null;

            // look for the file in the default spawner locations
            string dirname = XmlSpawner.LocateFile(filename);

            if (System.IO.File.Exists(dirname))
            {
                int ncomponents = 0;

                newaddon = new XmlSpawnerAddon();

                try
                {
                    ncomponents = LoadAddonFromMulti(newaddon, dirname, out status_str);
                }
                catch
                {
                    newaddon.Delete();
                    status_str = "Bad Multi file : " + filename;
                    return(null);
                }

                if (ncomponents == 0)
                {
                    newaddon.Delete();
                    status_str += " : " + filename;
                    return(null);
                }
            }
            else
            {
                status_str = "No such file : " + filename;
            }

            return(newaddon);
        }
Example #29
0
        public override void Deserialize(GenericReader reader)
        {
            base.Deserialize(reader);

            int version = reader.ReadInt();

            //Version 0
            m_Behavior     = (WaypointBehavior)reader.ReadInt();
            m_NextWaypoint = reader.ReadItem() as WayPoint;

            m_PreviousWaypoints = new List <WayPoint>();
            int previousWaypoints = reader.ReadInt();

            for (int a = 0; a < previousWaypoints; a++)
            {
                WayPoint previousWaypoint = reader.ReadItem() as WayPoint;

                if (m_PreviousWaypoints.IndexOf(previousWaypoint) < 0)
                {
                    m_PreviousWaypoints.Add(previousWaypoint);
                }
            }

            m_XMLSpawner = new List <XmlSpawner>();
            int xmlSpawners = reader.ReadInt();

            for (int a = 0; a < xmlSpawners; a++)
            {
                XmlSpawner xmlspawner = reader.ReadItem() as XmlSpawner;

                if (m_XMLSpawner.IndexOf(xmlspawner) < 0)
                {
                    m_XMLSpawner.Add(xmlspawner);
                }
            }

            m_Description = reader.ReadString();

            if (version >= 1)
            {
                m_DoWaypointAction = reader.ReadBool();
            }
        }
        public override TransferMessage ProcessMessage()
        {
            // place the xml spawner info into a memory buffer
            MemoryStream mstream = new MemoryStream(Data);

            int    processedmaps;
            int    processedspawners;
            Mobile from = null;

            TransferServer.AuthEntry auth = TransferServer.GetAuthEntry(this);

            if (auth != null)
            {
                from = auth.User;
            }
            XmlSpawner.XmlUnLoadFromStream(mstream, "Spawn Editor MemStream", String.Empty, from, out processedmaps, out processedspawners);

            return(new ReturnSpawnerUnloadStatus(processedspawners, processedmaps));
        }