Example #1
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            switch (info.ButtonID)
            {
            case 0:                     // Close Gump
            {
                MessagesTitle = "Delete Override Settings";
                Messages      = "You have chosen not to delete the override setting for selected spawners.";

                SetArgsList();

                gumpMobile.SendGump(new PlugInsGump(gumpMobile, ArgsList));

                break;
            }

            case 1:                     // Delete Override Settings
            {
                int count = 0;

                for (int i = 0; i < MC.SpawnerList.Count; i++)
                {
                    MegaSpawner megaSpawner = (MegaSpawner)MC.SpawnerList[i];

                    if ((bool)MSGCheckBoxesList[i])
                    {
                        bool success = false;

                        for (int j = 0; j < megaSpawner.SettingsList.Count; j++)
                        {
                            ArrayList settingList = (ArrayList)megaSpawner.SettingsList[j];

                            if ((Setting)settingList[0] == Setting.OverrideIndividualEntries)
                            {
                                success = true;

                                MegaSpawnerOverride.DeleteEntries(megaSpawner);
                                MegaSpawnerOverride.RemoveRespawnEntries(megaSpawner);
                                megaSpawner.RemoveRespawnEntries();
                                megaSpawner.SpawnedEntries.Clear();
                                megaSpawner.LastMovedList.Clear();

                                for (int k = 0; k < megaSpawner.EntryList.Count; k++)
                                {
                                    int amount = (int)megaSpawner.AmountList[k];

                                    ArrayList respawnEntryList  = new ArrayList();
                                    ArrayList respawnTimeList   = new ArrayList();
                                    ArrayList spawnCounterList  = new ArrayList();
                                    ArrayList spawnTimeList     = new ArrayList();
                                    ArrayList respawnOnSaveList = new ArrayList();
                                    ArrayList despawnTimeList   = new ArrayList();

                                    for (int l = 0; l < amount; l++)
                                    {
                                        respawnEntryList.Add((string)megaSpawner.EntryList[k]);
                                        respawnTimeList.Add(0);
                                        spawnCounterList.Add(DateTime.Now);
                                        spawnTimeList.Add(0);
                                        respawnOnSaveList.Add((bool)false);
                                        despawnTimeList.Add(0);
                                    }

                                    megaSpawner.RespawnEntryList.Add(respawnEntryList);
                                    megaSpawner.RespawnTimeList.Add(respawnTimeList);
                                    megaSpawner.SpawnCounterList.Add(spawnCounterList);
                                    megaSpawner.SpawnTimeList.Add(spawnTimeList);
                                    megaSpawner.RespawnOnSaveList.Add(respawnOnSaveList);
                                    megaSpawner.DespawnTimeList.Add(despawnTimeList);
                                    megaSpawner.SpawnedEntries.Add(new ArrayList());
                                    megaSpawner.LastMovedList.Add(new ArrayList());
                                }

                                megaSpawner.ResetSetting(j);
                                megaSpawner.SettingsList.RemoveAt(j);
                                megaSpawner.Respawn();
                                j--;
                            }
                        }

                        if (success)
                        {
                            count++;
                        }
                    }
                }

                MessagesTitle = "Delete Override Settings";

                if (count > 0)
                {
                    Messages = String.Format("\"Override Individual Entries\" setting has been removed on {0} Mega Spawner{1}.", count, count == 1 ? "" : "s");
                }
                else
                {
                    Messages = "Either no Mega Spawners have been selected or none of them had the \"Override Individual Entries\" setting.";
                }

                SetArgsList();

                gumpMobile.SendGump(new PlugInsGump(gumpMobile, ArgsList));

                break;
            }
            }
        }
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            switch (info.ButtonID)
            {
            case 0:                     // Close Gump
            {
                switch (Select)
                {
                case 1: { MessagesTitle = "Delete All Settings"; Messages = "You have chosen not to delete all settings on the Mega Spawner."; break; }

                case 2: { MessagesTitle = "Delete Selected Settings"; Messages = "You have chosen not to delete selected settings on the Mega Spawner."; break; }
                }

                SetArgsList();

                gumpMobile.SendGump(new SettingsGump(gumpMobile, ArgsList));

                break;
            }

            case 1:                     // Delete Settings
            {
                if (CheckProcess())
                {
                    break;
                }

                switch (Select)
                {
                case 1:                                 // Delete All Settings
                {
                    if (megaSpawner.OverrideIndividualEntries)
                    {
                        MegaSpawnerOverride.DeleteEntries(megaSpawner);
                        MegaSpawnerOverride.RemoveRespawnEntries(megaSpawner);
                        megaSpawner.RemoveRespawnEntries();
                        megaSpawner.SpawnedEntries.Clear();
                        megaSpawner.LastMovedList.Clear();

                        for (int i = 0; i < megaSpawner.EntryList.Count; i++)
                        {
                            int amount = (int)megaSpawner.AmountList[i];

                            ArrayList respawnEntryList  = new ArrayList();
                            ArrayList respawnTimeList   = new ArrayList();
                            ArrayList spawnCounterList  = new ArrayList();
                            ArrayList spawnTimeList     = new ArrayList();
                            ArrayList respawnOnSaveList = new ArrayList();
                            ArrayList despawnTimeList   = new ArrayList();

                            for (int j = 0; j < amount; j++)
                            {
                                respawnEntryList.Add((string)megaSpawner.EntryList[i]);
                                respawnTimeList.Add(0);
                                spawnCounterList.Add(DateTime.Now);
                                spawnTimeList.Add(0);
                                respawnOnSaveList.Add((bool)false);
                                despawnTimeList.Add(0);
                            }

                            megaSpawner.RespawnEntryList.Add(respawnEntryList);
                            megaSpawner.RespawnTimeList.Add(respawnTimeList);
                            megaSpawner.SpawnCounterList.Add(spawnCounterList);
                            megaSpawner.SpawnTimeList.Add(spawnTimeList);
                            megaSpawner.RespawnOnSaveList.Add(respawnOnSaveList);
                            megaSpawner.DespawnTimeList.Add(despawnTimeList);
                            megaSpawner.SpawnedEntries.Add(new ArrayList());
                            megaSpawner.LastMovedList.Add(new ArrayList());
                        }
                    }

                    megaSpawner.ResetSettingValues();
                    megaSpawner.SettingsList.Clear();
                    SettingsCheckBoxesList.Clear();
                    megaSpawner.Respawn();

                    MessagesTitle = "Delete All Settings";
                    Messages      = "All of the settings on the Mega Spawner have been deleted.";

                    break;
                }

                case 2:                                 // Delete Selected Settings
                {
                    for (int i = 0; i < megaSpawner.SettingsList.Count; i++)
                    {
                        if ((bool)SettingsCheckBoxesList[i])
                        {
                            ArrayList settingList = (ArrayList)megaSpawner.SettingsList[i];

                            if ((Setting)settingList[0] == Setting.OverrideIndividualEntries)
                            {
                                MegaSpawnerOverride.DeleteEntries(megaSpawner);
                                MegaSpawnerOverride.RemoveRespawnEntries(megaSpawner);
                                megaSpawner.RemoveRespawnEntries();
                                megaSpawner.SpawnedEntries.Clear();
                                megaSpawner.LastMovedList.Clear();

                                for (int j = 0; j < megaSpawner.EntryList.Count; j++)
                                {
                                    int amount = (int)megaSpawner.AmountList[j];

                                    ArrayList respawnEntryList  = new ArrayList();
                                    ArrayList respawnTimeList   = new ArrayList();
                                    ArrayList spawnCounterList  = new ArrayList();
                                    ArrayList spawnTimeList     = new ArrayList();
                                    ArrayList respawnOnSaveList = new ArrayList();
                                    ArrayList despawnTimeList   = new ArrayList();

                                    for (int k = 0; k < amount; k++)
                                    {
                                        respawnEntryList.Add((string)megaSpawner.EntryList[j]);
                                        respawnTimeList.Add(0);
                                        spawnCounterList.Add(DateTime.Now);
                                        spawnTimeList.Add(0);
                                        respawnOnSaveList.Add((bool)false);
                                        despawnTimeList.Add(0);
                                    }

                                    megaSpawner.RespawnEntryList.Add(respawnEntryList);
                                    megaSpawner.RespawnTimeList.Add(respawnTimeList);
                                    megaSpawner.SpawnCounterList.Add(spawnCounterList);
                                    megaSpawner.SpawnTimeList.Add(spawnTimeList);
                                    megaSpawner.RespawnOnSaveList.Add(respawnOnSaveList);
                                    megaSpawner.DespawnTimeList.Add(despawnTimeList);
                                    megaSpawner.SpawnedEntries.Add(new ArrayList());
                                    megaSpawner.LastMovedList.Add(new ArrayList());
                                }
                            }

                            megaSpawner.ResetSetting(i);
                            megaSpawner.SettingsList.RemoveAt(i);
                            SettingsCheckBoxesList.RemoveAt(i);
                            megaSpawner.Respawn();

                            i--;
                        }
                    }

                    megaSpawner.Respawn();

                    MessagesTitle = "Delete Selected Settings";
                    Messages      = "All selected settings on the Mega Spawner have been deleted.";

                    break;
                }
                }

                SetArgsList();

                gumpMobile.SendGump(new SettingsGump(gumpMobile, ArgsList));

                break;
            }
            }
        }
Example #3
0
            private void ConvertDistroSpawner(Item item)
            {
                MegaSpawner megaSpawner = new MegaSpawner();
                Spawner     spawner     = (Spawner)item;
                Type        type        = spawner.GetType();

                PropertyInfo[] props = type.GetProperties(BindingFlags.Static | BindingFlags.Instance | BindingFlags.Public);

                int count     = spawner.CreaturesName.Count;
                int walkRange = spawner.HomeRange;

                foreach (PropertyInfo prop in props)
                {
                    if (prop.Name == "WalkingRange")
                    {
                        walkRange = Convert.ToInt32(prop.GetValue(spawner, null));

                        break;
                    }
                }

                if (spawner.Name != "Spawner")
                {
                    megaSpawner.Name = spawner.Name;
                }

                int calcMinDelay = 0, calcMaxDelay = 0;

                for (int i = 0; i < count; i++)
                {
                    int entryCount = 0;

                    for (int j = 0; j < megaSpawner.EntryList.Count; j++)
                    {
                        string entryType = (string)megaSpawner.EntryList[j];

                        if (entryType.ToLower() == ((string)spawner.CreaturesName[i]).ToLower())
                        {
                            entryCount++;
                        }
                    }

                    if (entryCount == 0)
                    {
                        bool movable = true;

                        megaSpawner.EntryList.Add((string)spawner.CreaturesName[i]);

                        megaSpawner.SpawnRangeList.Add(spawner.HomeRange);
                        megaSpawner.WalkRangeList.Add(walkRange);

                        if (count == 1)
                        {
                            megaSpawner.AmountList.Add((int)(spawner.Count));
                        }
                        else if (((int)spawner.Count / count) == (int)((double)spawner.Count / (double)count))
                        {
                            megaSpawner.AmountList.Add((int)(spawner.Count / count));
                        }
                        else
                        {
                            megaSpawner.AmountList.Add((int)(spawner.Count / count) + 1);
                        }

                        calcMinDelay = (spawner.MinDelay.Hours * 3600) + (spawner.MinDelay.Minutes * 60) + spawner.MinDelay.Seconds;
                        calcMaxDelay = (spawner.MaxDelay.Hours * 3600) + (spawner.MaxDelay.Minutes * 60) + spawner.MaxDelay.Seconds;

                        Type entryType = ScriptCompiler.FindTypeByName((string)spawner.CreaturesName[i]);

                        if (entryType != null)
                        {
                            Item toAdd = null;

                            try
                            {
                                toAdd   = (Item)Activator.CreateInstance(entryType);
                                movable = toAdd.Movable;
                            }
                            catch {}

                            if (toAdd != null)
                            {
                                toAdd.Delete();
                            }
                        }

                        megaSpawner.MinDelayList.Add(calcMinDelay);
                        megaSpawner.MaxDelayList.Add(calcMaxDelay);
                        megaSpawner.SpawnTypeList.Add(SpawnType.Regular);
                        megaSpawner.ActivatedList.Add((bool)true);
                        megaSpawner.EventRangeList.Add(10);
                        megaSpawner.EventKeywordList.Add("");
                        megaSpawner.KeywordCaseSensitiveList.Add((bool)false);
                        megaSpawner.TriggerEventNowList.Add((bool)true);
                        megaSpawner.EventAmbushList.Add((bool)true);
                        megaSpawner.BeginTimeBasedList.Add(0);
                        megaSpawner.EndTimeBasedList.Add(0);
                        megaSpawner.GroupSpawnList.Add(spawner.Group);
                        megaSpawner.MinStackAmountList.Add(1);
                        megaSpawner.MaxStackAmountList.Add(1);
                        megaSpawner.MovableList.Add(movable);
                        megaSpawner.MinDespawnList.Add(1800);
                        megaSpawner.MaxDespawnList.Add(3600);
                        megaSpawner.DespawnList.Add((bool)false);
                        megaSpawner.DespawnGroupList.Add((bool)false);
                        megaSpawner.DespawnTimeExpireList.Add((bool)true);
                    }
                }

                ArrayList settingList = new ArrayList();

                settingList.Add(Setting.OverrideIndividualEntries);
                settingList.Add(spawner.HomeRange);
                settingList.Add(walkRange);
                settingList.Add(spawner.Count);
                settingList.Add(calcMinDelay);
                settingList.Add(calcMaxDelay);
                settingList.Add(spawner.Group);
                settingList.Add((bool)true);
                settingList.Add(SpawnType.Regular);
                settingList.Add("");
                settingList.Add((bool)false);
                settingList.Add(10);
                settingList.Add(0);
                settingList.Add(0);
                settingList.Add(0);
                settingList.Add(0);
                settingList.Add(1800);
                settingList.Add(3600);
                settingList.Add((bool)false);
                settingList.Add((bool)false);
                settingList.Add((bool)true);

                megaSpawner.SettingsList.Add(settingList);

                megaSpawner.CompileSettings();

                megaSpawner.SettingsList.Sort(new MC.SettingsSorter());

                for (int j = 0; j < megaSpawner.OverrideAmount; j++)
                {
                    megaSpawner.OverrideRespawnEntryList.Add("");
                    megaSpawner.OverrideRespawnTimeList.Add(0);
                    megaSpawner.OverrideSpawnCounterList.Add(DateTime.Now);
                    megaSpawner.OverrideSpawnTimeList.Add(0);
                    megaSpawner.OverrideDespawnTimeList.Add(0);
                }

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

                if (megaSpawner.Active)
                {
                    MegaSpawnerOverride.CheckDupedEntries(megaSpawner);

                    megaSpawner.Start();
                    megaSpawner.Respawn();
                }

                HideSpawnerList.Add((bool)false);
                MSGCheckBoxesList.Add((bool)false);

                spawner.Delete();
            }