public static void Importv1(Mobile mobile, string fileName, StreamReader r, ArrayList ArgsList) { ArrayList SpawnerList = new ArrayList(); int totalErrors = 0; string MessagesTitle = (string)ArgsList[2]; string Messages = (string)ArgsList[4]; ArrayList HideSpawnerList = (ArrayList)ArgsList[6]; ArrayList MSGCheckBoxesList = (ArrayList)ArgsList[13]; mobile.SendMessage("Importing spawners..."); DateTime beginTime = DateTime.Now; int amountOfSpawners = 0, amountOfEntries = 0, locX = 0, locY = 0, locZ = 0; string map = null; Map spawnerMap = null; try{ amountOfSpawners = Convert.ToInt32(r.ReadLine()); } catch { totalErrors++; } for (int i = 0; i < amountOfSpawners; i++) { int errors = 0; MegaSpawner megaSpawner = new MegaSpawner(); megaSpawner.Imported = CropDirectory(fileName.ToLower()); megaSpawner.ImportVersion = "1"; megaSpawner.Editor = null; megaSpawner.Workspace = false; try{ map = r.ReadLine().ToLower(); } catch { errors++; totalErrors++; } if (map == "felucca") { spawnerMap = Map.Felucca; } if (map == "trammel") { spawnerMap = Map.Trammel; } if (map == "ilshenar") { spawnerMap = Map.Ilshenar; } if (map == "malas") { spawnerMap = Map.Malas; } try{ locX = Convert.ToInt32(r.ReadLine()); } catch { errors++; totalErrors++; } try{ locY = Convert.ToInt32(r.ReadLine()); } catch { errors++; totalErrors++; } try{ locZ = Convert.ToInt32(r.ReadLine()); } catch { errors++; totalErrors++; } try{ amountOfEntries = Convert.ToInt32(r.ReadLine()); } catch { errors++; totalErrors++; } for (int cnt = 0; cnt < amountOfEntries; cnt++) { try{ megaSpawner.EntryList.Add(r.ReadLine()); } // Entry List catch { errors++; totalErrors++; } try{ megaSpawner.SpawnRangeList.Add(Convert.ToInt32(r.ReadLine())); } // Spawn Range List catch { errors++; totalErrors++; } try{ megaSpawner.WalkRangeList.Add(Convert.ToInt32(r.ReadLine())); } // Walk Range List catch { errors++; totalErrors++; } try{ megaSpawner.AmountList.Add(Convert.ToInt32(r.ReadLine())); } // Amount List catch { errors++; totalErrors++; } try{ megaSpawner.MinDelayList.Add(Convert.ToInt32(r.ReadLine())); } // Min Delay List catch { errors++; totalErrors++; } try{ megaSpawner.MaxDelayList.Add(Convert.ToInt32(r.ReadLine())); } // Max Delay List catch { errors++; totalErrors++; } megaSpawner.SpawnTypeList.Add(SpawnType.Regular); // Spawn Type List megaSpawner.ActivatedList.Add((bool)true); // Activated List megaSpawner.EventRangeList.Add(10); // EVent Range List megaSpawner.EventKeywordList.Add(""); // EVent Keyword List megaSpawner.KeywordCaseSensitiveList.Add((bool)false); megaSpawner.TriggerEventNowList.Add((bool)true); // Trigger Event Now List megaSpawner.EventAmbushList.Add((bool)true); // Event Ambush List megaSpawner.BeginTimeBasedList.Add(0); // Begin Time Based List megaSpawner.EndTimeBasedList.Add(0); // End Time Based List megaSpawner.GroupSpawnList.Add((bool)false); // Group Spawn List megaSpawner.MinStackAmountList.Add(0); megaSpawner.MaxStackAmountList.Add(0); megaSpawner.MovableList.Add((bool)true); megaSpawner.MinDespawnList.Add(1800); megaSpawner.MaxDespawnList.Add(3600); megaSpawner.DespawnList.Add((bool)false); megaSpawner.DespawnGroupList.Add((bool)false); megaSpawner.DespawnTimeExpireList.Add((bool)true); 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 < (int)megaSpawner.AmountList[cnt]; j++) { respawnEntryList.Add((string)megaSpawner.EntryList[cnt]); 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()); } if (errors > 0) { megaSpawner.Delete(); amountOfSpawners--; } else { SpawnerList.Add(megaSpawner); megaSpawner.MoveToWorld(new Point3D(locX, locY, locZ), spawnerMap); if (megaSpawner.Active) { megaSpawner.Start(); megaSpawner.Respawn(); } HideSpawnerList.Add((bool)false); MSGCheckBoxesList.Add((bool)false); MC.FileImportAdd(megaSpawner.Imported, megaSpawner.ImportVersion); } } r.Close(); TimeSpan finishTime = DateTime.Now - beginTime; MessagesTitle = "Import Spawners"; if (amountOfSpawners > 0) { Messages = String.Format("File type identified as a Mega Spawner v1 file. {0} Mega Spawner{1} imported. The process took {2} second{3}.", amountOfSpawners, amountOfSpawners == 1 ? "" : "s", (int)finishTime.TotalSeconds, (int)finishTime.TotalSeconds == 1 ? "" : "s"); } else { Messages = String.Format("File type identified as a Mega Spawner v1 file. No Mega Spawners were imported due to errors in the file. The process took {0} second{1}.", (int)finishTime.TotalSeconds, (int)finishTime.TotalSeconds == 1 ? "" : "s"); MC.FileImportRemove(CropDirectory(fileName)); } DateTime beginDupeTime = DateTime.Now; Messages = DupeSpawnerCheck(SpawnerList, Messages); TimeSpan finishDupeTime = DateTime.Now - beginDupeTime; Messages = String.Format("{0} The duped spawner check process took {1} second{2}.", Messages, (int)finishDupeTime.TotalSeconds, (int)finishDupeTime.TotalSeconds == 1 ? "" : "s"); if (totalErrors > 0) { Messages = String.Format("{0} {1} error{2} been detected.", Messages, totalErrors, totalErrors == 1 ? " has" : "s have"); } MC.CheckFileImportList(fileName); ArgsList[2] = MessagesTitle; ArgsList[4] = Messages; ArgsList[6] = HideSpawnerList; ArgsList[13] = MSGCheckBoxesList; mobile.CloseGump(typeof(LoadFileGump)); mobile.SendGump(new FileMenuGump(mobile, ArgsList)); }
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; } } }
private void ImportMegaSpawner(XmlNode node, string fileName) { int errors = 0; amountOfSpawners++; Map map = null; Point3D location = new Point3D(); MegaSpawner megaSpawner = new MegaSpawner(); megaSpawner.Imported = MC.CropDirectory(fileName.ToLower()); megaSpawner.ImportVersion = version; megaSpawner.Editor = null; megaSpawner.Workspace = false; double ver; try{ ver = Convert.ToDouble(version); } catch { ver = 0.0; } try{ megaSpawner.Name = GetInnerText(node["Name"]); } catch { errors++; totalErrors++; } try{ megaSpawner.Active = bool.Parse(GetInnerText(node["Active"])); } catch { errors++; totalErrors++; } try{ map = Map.Parse(GetInnerText(node["Map"])); } catch { errors++; totalErrors++; } try{ location = Point3D.Parse(GetInnerText(node["Location"])); } catch { errors++; totalErrors++; } XmlElement entryLists = null; try{ entryLists = node["EntryLists"]; } catch { errors++; totalErrors++; } if (entryLists != null) { int cnt = 0; try { foreach (XmlElement entry in entryLists.GetElementsByTagName("EntryList")) { string entryCompare = null; try{ entryCompare = GetInnerText(entry["EntryType"]); } catch { errors++; totalErrors++; } int entryCount = 0; for (int i = 0; i < megaSpawner.EntryList.Count; i++) { string entryType = (string)megaSpawner.EntryList[i]; if (entryType.ToLower() == entryCompare.ToLower()) { entryCount++; } } if (entryCount == 0) { megaSpawner.EntryList.Add(entryCompare); } try{ megaSpawner.SpawnRangeList.Add(int.Parse(GetInnerText(entry["SpawnRange"]))); } catch { errors++; totalErrors++; } try{ megaSpawner.WalkRangeList.Add(int.Parse(GetInnerText(entry["WalkRange"]))); } catch { errors++; totalErrors++; } try { int amount = int.Parse(GetInnerText(entry["Amount"])); if (amount == 0) { amount = 1; } megaSpawner.AmountList.Add(amount); } catch { errors++; totalErrors++; } try{ megaSpawner.MinDelayList.Add(int.Parse(GetInnerText(entry["MinDelay"]))); } catch { errors++; totalErrors++; } try{ megaSpawner.MaxDelayList.Add(int.Parse(GetInnerText(entry["MaxDelay"]))); } catch { errors++; totalErrors++; } try{ megaSpawner.SpawnTypeList.Add(int.Parse(GetInnerText(entry["SpawnType"]))); } catch { errors++; totalErrors++; } try{ megaSpawner.ActivatedList.Add(bool.Parse(GetInnerText(entry["Activated"]))); } catch { errors++; totalErrors++; } try{ megaSpawner.EventRangeList.Add(int.Parse(GetInnerText(entry["EventRange"]))); } catch { errors++; totalErrors++; } try{ megaSpawner.EventKeywordList.Add(GetInnerText(entry["EventKeyword"])); } catch { errors++; totalErrors++; } try{ megaSpawner.KeywordCaseSensitiveList.Add(bool.Parse(GetInnerText(entry["KeywordCaseSensitive"]))); } catch { megaSpawner.KeywordCaseSensitiveList.Add((bool)false); exceptions++; } megaSpawner.TriggerEventNowList.Add((bool)true); try{ megaSpawner.EventAmbushList.Add(bool.Parse(GetInnerText(entry["EventAmbush"]))); } catch { errors++; totalErrors++; } try{ megaSpawner.BeginTimeBasedList.Add(int.Parse(GetInnerText(entry["BeginTimeBased"]))); } catch { errors++; totalErrors++; } try{ megaSpawner.EndTimeBasedList.Add(int.Parse(GetInnerText(entry["EndTimeBased"]))); } catch { errors++; totalErrors++; } try{ megaSpawner.GroupSpawnList.Add(bool.Parse(GetInnerText(entry["GroupSpawn"]))); } catch { errors++; totalErrors++; } try{ megaSpawner.MinStackAmountList.Add(int.Parse(GetInnerText(entry["MinStackAmount"]))); } catch { megaSpawner.MinStackAmountList.Add(1); exceptions++; } try{ megaSpawner.MaxStackAmountList.Add(int.Parse(GetInnerText(entry["MaxStackAmount"]))); } catch { megaSpawner.MaxStackAmountList.Add(1); exceptions++; } if (ver < 3.2) { try{ megaSpawner.MovableList.Add(bool.Parse(GetInnerText(entry["ItemMovable"]))); } catch { megaSpawner.MovableList.Add((bool)true); exceptions++; } } else { try{ megaSpawner.MovableList.Add(bool.Parse(GetInnerText(entry["Movable"]))); } catch { megaSpawner.MovableList.Add((bool)true); exceptions++; } } if (ver >= 3.5) { try{ megaSpawner.MinDespawnList.Add(int.Parse(GetInnerText(entry["MinDespawn"]))); } catch { errors++; totalErrors++; } try{ megaSpawner.MaxDespawnList.Add(int.Parse(GetInnerText(entry["MaxDespawn"]))); } catch { errors++; totalErrors++; } try{ megaSpawner.DespawnList.Add(bool.Parse(GetInnerText(entry["Despawn"]))); } catch { errors++; totalErrors++; } try{ megaSpawner.DespawnGroupList.Add(bool.Parse(GetInnerText(entry["DespawnGroup"]))); } catch { errors++; totalErrors++; } try{ megaSpawner.DespawnTimeExpireList.Add(bool.Parse(GetInnerText(entry["DespawnTimeExpire"]))); } catch { errors++; totalErrors++; } } else { megaSpawner.MinDespawnList.Add(1800); megaSpawner.MaxDespawnList.Add(3600); megaSpawner.DespawnList.Add((bool)false); megaSpawner.DespawnGroupList.Add((bool)false); megaSpawner.DespawnTimeExpireList.Add((bool)true); } cnt++; } } catch { errors++; totalErrors++; } } XmlElement settingsList = null; try{ settingsList = node["SettingsList"]; } catch { errors++; totalErrors++; } if (settingsList != null) { if (ver >= 3.6) { try { foreach (XmlElement setting in settingsList.GetElementsByTagName("OverrideIndividualEntries")) { int err = errors; ArrayList List = new ArrayList(); List.Add(Setting.OverrideIndividualEntries); try{ List.Add(int.Parse(GetInnerText(setting["SpawnRange"]))); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["WalkRange"]))); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["Amount"]))); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["MinDelay"]))); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["MaxDelay"]))); } catch { errors++; totalErrors++; } try{ List.Add(bool.Parse(GetInnerText(setting["GroupSpawn"]))); } catch { errors++; totalErrors++; } try{ List.Add(bool.Parse(GetInnerText(setting["EventAmbush"]))); } catch { errors++; totalErrors++; } try{ List.Add((SpawnType)int.Parse(GetInnerText(setting["SpawnType"]))); } catch { errors++; totalErrors++; } try{ List.Add(GetInnerText(setting["EventKeyword"])); } catch { errors++; totalErrors++; } try{ List.Add(bool.Parse(GetInnerText(setting["CaseSensitive"]))); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["EventRange"]))); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["BeginTimeBasedHour"]))); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["BeginTimeBasedMinute"]))); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["EndTimeBasedHour"]))); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["EndTimeBasedMinute"]))); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["MinDespawn"]))); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["MaxDespawn"]))); } catch { errors++; totalErrors++; } try{ List.Add(bool.Parse(GetInnerText(setting["Despawn"]))); } catch { errors++; totalErrors++; } try{ List.Add(bool.Parse(GetInnerText(setting["DespawnGroup"]))); } catch { errors++; totalErrors++; } try{ List.Add(bool.Parse(GetInnerText(setting["DespawnTimeExpire"]))); } catch { errors++; totalErrors++; } if (err == errors) { megaSpawner.SettingsList.Add(List); } } } catch {} try { foreach (XmlElement setting in settingsList.GetElementsByTagName("AddItemSetting")) { int err = errors; ArrayList List = new ArrayList(); List.Add(Setting.AddItem); try{ List.Add(GetInnerText(setting["EntryName"])); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["EntryIndex"]))); } catch { errors++; totalErrors++; } try{ List.Add(GetInnerText(setting["AddItem"])); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["MinStackAmount"]))); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["MaxStackAmount"]))); } catch { errors++; totalErrors++; } if (err == errors) { megaSpawner.SettingsList.Add(List); } } } catch {} try { foreach (XmlElement setting in settingsList.GetElementsByTagName("AddContainerSetting")) { int err = errors; ArrayList List = new ArrayList(); List.Add(Setting.AddContainer); try{ List.Add(GetInnerText(setting["EntryName"])); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["EntryIndex"]))); } catch { errors++; totalErrors++; } try{ List.Add(GetInnerText(setting["AddItem"])); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["MinStackAmount"]))); } catch { errors++; totalErrors++; } try{ List.Add(int.Parse(GetInnerText(setting["MaxStackAmount"]))); } catch { errors++; totalErrors++; } XmlElement contList = null; try{ contList = setting["ContainerItems"]; } catch { errors++; totalErrors++; } try { foreach (XmlElement contItem in contList.GetElementsByTagName("ContainerItem")) { ArrayList ItemsList = new ArrayList(); try{ ItemsList.Add(GetInnerText(contItem["AddItem"])); } catch { errors++; totalErrors++; } try{ ItemsList.Add(int.Parse(GetInnerText(contItem["MinStackAmount"]))); } catch { errors++; totalErrors++; } try{ ItemsList.Add(int.Parse(GetInnerText(contItem["MaxStackAmount"]))); } catch { errors++; totalErrors++; } List.Add(ItemsList); } } catch {} if (err == errors) { megaSpawner.SettingsList.Add(List); } } } catch {} } else { foreach (XmlElement setting in settingsList.GetElementsByTagName("Setting")) { try{ megaSpawner.SettingsList.Add(setting.InnerText); } catch { errors++; totalErrors++; } } megaSpawner.ConvertOldSettings(); } } if (errors > 0) { megaSpawner.Delete(); amountOfSpawners--; } else { megaSpawner.MoveToWorld(location, map); if (location.Z == -999) { megaSpawner.Location = GetLocation(megaSpawner, location); } if (megaSpawner.Location.Z == -999) { megaSpawner.Delete(); amountOfSpawners--; autoFailures++; return; } megaSpawner.CheckDupedSettings(); megaSpawner.CompileSettings(); megaSpawner.SettingsList.Sort(new MC.SettingsSorter()); if (megaSpawner.OverrideIndividualEntries) { for (int i = 0; i < megaSpawner.OverrideAmount; i++) { megaSpawner.OverrideRespawnEntryList.Add(""); megaSpawner.OverrideRespawnTimeList.Add(0); megaSpawner.OverrideSpawnCounterList.Add(DateTime.Now); megaSpawner.OverrideSpawnTimeList.Add(0); megaSpawner.OverrideDespawnTimeList.Add(0); } } else { for (int i = 0; i < megaSpawner.EntryList.Count; 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 < (int)megaSpawner.AmountList[i]; 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()); } } SpawnerList.Add(megaSpawner); if (megaSpawner.Active) { megaSpawner.Respawn(); } HideSpawnerList.Add((bool)false); MSGCheckBoxesList.Add((bool)false); MC.FileImportAdd(megaSpawner.Imported, megaSpawner.ImportVersion); } }
public static bool Deserialize(GenericReader reader) { bool success = false; Map map = null; Point3D location = new Point3D(); MegaSpawner megaSpawner = new MegaSpawner(true); try { int version = reader.ReadInt(); if (version >= 1) { location = reader.ReadPoint3D(); map = reader.ReadMap(); megaSpawner.Active = reader.ReadBool(); megaSpawner.Imported = reader.ReadString(); megaSpawner.ImportVersion = reader.ReadString(); megaSpawner.ContainerSpawn = (Container)reader.ReadItem(); megaSpawner.Workspace = reader.ReadBool(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { megaSpawner.EntryList.Add(reader.ReadString()); } for (int i = 0; i < count; i++) { megaSpawner.SpawnRangeList.Add(reader.ReadInt()); } for (int i = 0; i < count; i++) { megaSpawner.WalkRangeList.Add(reader.ReadInt()); } for (int i = 0; i < count; i++) { int amount = reader.ReadInt(); if (amount == 0) { amount = 1; } megaSpawner.AmountList.Add(amount); } for (int i = 0; i < count; i++) { megaSpawner.MinDelayList.Add(reader.ReadInt()); } for (int i = 0; i < count; i++) { megaSpawner.MaxDelayList.Add(reader.ReadInt()); } for (int i = 0; i < count; i++) { megaSpawner.SpawnTypeList.Add(reader.ReadInt()); } for (int i = 0; i < count; i++) { megaSpawner.ActivatedList.Add(reader.ReadBool()); } for (int i = 0; i < count; i++) { megaSpawner.EventRangeList.Add(reader.ReadInt()); } for (int i = 0; i < count; i++) { megaSpawner.EventKeywordList.Add(reader.ReadString()); } for (int i = 0; i < count; i++) { megaSpawner.KeywordCaseSensitiveList.Add(reader.ReadBool()); } for (int i = 0; i < count; i++) { megaSpawner.TriggerEventNowList.Add(reader.ReadBool()); } for (int i = 0; i < count; i++) { megaSpawner.EventAmbushList.Add(reader.ReadBool()); } for (int i = 0; i < count; i++) { megaSpawner.BeginTimeBasedList.Add(reader.ReadInt()); } for (int i = 0; i < count; i++) { megaSpawner.EndTimeBasedList.Add(reader.ReadInt()); } for (int i = 0; i < count; i++) { megaSpawner.GroupSpawnList.Add(reader.ReadBool()); } for (int i = 0; i < count; i++) { megaSpawner.MinStackAmountList.Add(reader.ReadInt()); } for (int i = 0; i < count; i++) { megaSpawner.MaxStackAmountList.Add(reader.ReadInt()); } for (int i = 0; i < count; i++) { megaSpawner.MovableList.Add(reader.ReadBool()); } if (version >= 2) { for (int i = 0; i < count; i++) { megaSpawner.MinDespawnList.Add(reader.ReadInt()); } for (int i = 0; i < count; i++) { megaSpawner.MaxDespawnList.Add(reader.ReadInt()); } for (int i = 0; i < count; i++) { megaSpawner.DespawnList.Add(reader.ReadBool()); } for (int i = 0; i < count; i++) { megaSpawner.DespawnGroupList.Add(reader.ReadBool()); } for (int i = 0; i < count; i++) { megaSpawner.DespawnTimeExpireList.Add(reader.ReadBool()); } } else { for (int i = 0; i < count; i++) { megaSpawner.MinDespawnList.Add(1800); } for (int i = 0; i < count; i++) { megaSpawner.MaxDespawnList.Add(3600); } for (int i = 0; i < count; i++) { megaSpawner.DespawnList.Add((bool)false); } for (int i = 0; i < count; i++) { megaSpawner.DespawnGroupList.Add((bool)false); } for (int i = 0; i < count; i++) { megaSpawner.DespawnTimeExpireList.Add((bool)true); } } int settingsCount = reader.ReadInt(); if (version >= 3) { for (int i = 0; i < settingsCount; i++) { ArrayList List = new ArrayList(); Setting setting = (Setting)reader.ReadInt(); List.Add(setting); switch (setting) { case Setting.OverrideIndividualEntries: { List.Add(reader.ReadInt()); List.Add(reader.ReadInt()); List.Add(reader.ReadInt()); List.Add(reader.ReadInt()); List.Add(reader.ReadInt()); List.Add(reader.ReadBool()); List.Add(reader.ReadBool()); List.Add((SpawnType)reader.ReadInt()); List.Add(reader.ReadString()); List.Add(reader.ReadBool()); List.Add(reader.ReadInt()); List.Add(reader.ReadInt()); List.Add(reader.ReadInt()); List.Add(reader.ReadInt()); List.Add(reader.ReadInt()); List.Add(reader.ReadInt()); List.Add(reader.ReadInt()); List.Add(reader.ReadBool()); List.Add(reader.ReadBool()); List.Add(reader.ReadBool()); break; } case Setting.AddItem: { List.Add(reader.ReadString()); List.Add(reader.ReadInt()); List.Add(reader.ReadString()); List.Add(reader.ReadInt()); List.Add(reader.ReadInt()); break; } case Setting.AddContainer: { List.Add(reader.ReadString()); List.Add(reader.ReadInt()); List.Add(reader.ReadString()); List.Add(reader.ReadInt()); List.Add(reader.ReadInt()); int settingCount = reader.ReadInt(); for (int j = 6; j < settingCount; j++) { ArrayList ItemsList = new ArrayList(); ItemsList.Add(reader.ReadString()); ItemsList.Add(reader.ReadInt()); ItemsList.Add(reader.ReadInt()); List.Add(ItemsList); } break; } } megaSpawner.SettingsList.Add(List); } } else { for (int i = 0; i < settingsCount; i++) { megaSpawner.SettingsList.Add(reader.ReadString()); } megaSpawner.ConvertOldSettings(); } } if (megaSpawner.Workspace) { megaSpawner.Delete(); } else { megaSpawner.MoveToWorld(location, map); megaSpawner.Start(); if (megaSpawner.Imported != "") { MC.FileImportAdd(megaSpawner.Imported, megaSpawner.ImportVersion); } megaSpawner.CompileSettings(); megaSpawner.CheckEntryErrors(); megaSpawner.SettingsList.Sort(new MC.SettingsSorter()); if (megaSpawner.OverrideIndividualEntries) { for (int i = 0; i < megaSpawner.OverrideAmount; i++) { megaSpawner.OverrideRespawnEntryList.Add(""); megaSpawner.OverrideRespawnTimeList.Add(0); megaSpawner.OverrideSpawnCounterList.Add(DateTime.Now); megaSpawner.OverrideSpawnTimeList.Add(0); megaSpawner.OverrideDespawnTimeList.Add(0); } } else { for (int i = 0; i < megaSpawner.EntryList.Count; 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 < (int)megaSpawner.AmountList[i]; 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.Respawn(); } success = true; } catch { if (megaSpawner != null) { megaSpawner.Delete(); } } return(success); }
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; } } }
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(); }