public CustomAI LoadCustomAI(string mobName) { if (mobName.Length <= 0) return null; try { InIReader Reader = new InIReader(@".\Custom\Unique AIs\" + mobName + ".ini"); CustomAI mobAI = new CustomAI(); mobAI.Name = mobName; #region Loading the Bools mobAI.SetXY = Reader.ReadBoolean("Bools", "SetXY", mobAI.SetXY); mobAI.MapSpecific = Reader.ReadBoolean("Bools", "MapSpecific", mobAI.MapSpecific); mobAI.AnnounceSpawn = Reader.ReadBoolean("Bools", "AnnounceSpawn", mobAI.AnnounceSpawn); mobAI.AnnounceDrop = Reader.ReadBoolean("Bools", "AnnounceDrop", mobAI.AnnounceDrop); mobAI.AnnounceDeath = Reader.ReadBoolean("Bools", "AnnounceDeath", mobAI.AnnounceDeath); mobAI.UseMassAttack = Reader.ReadBoolean("Bools", "UseMassAttack", mobAI.UseMassAttack); mobAI.UseSpecialAttack = Reader.ReadBoolean("Bools", "UseSpecialAttack", mobAI.UseSpecialAttack); mobAI.UseMeleeAttack = Reader.ReadBoolean("Bools", "UseMeleeAttack", mobAI.UseMeleeAttack); mobAI.UseRangeAttack = Reader.ReadBoolean("Bools", "UseRangeAttack", mobAI.UseRangeAttack); mobAI.UseMagicAttack = Reader.ReadBoolean("Bools", "UseMagicAttack", mobAI.UseMagicAttack); mobAI.Target = Reader.ReadBoolean("Bools", "Target", mobAI.Target); mobAI.UseKillTimer = Reader.ReadBoolean("Bools", "UseKillTimer", mobAI.UseKillTimer); mobAI.IgnorePets = Reader.ReadBoolean("Bools", "IgnorePets", mobAI.IgnorePets); mobAI.DamagePetsMore = Reader.ReadBoolean("Bools", "DamagePetsMore", mobAI.DamagePetsMore); mobAI.CanPara = Reader.ReadBoolean("Bools", "CanPara", mobAI.CanPara); mobAI.CanGreen = Reader.ReadBoolean("Bools", "CanGreen", mobAI.CanGreen); mobAI.CanRed = Reader.ReadBoolean("Bools", "CanRed", mobAI.CanRed); mobAI.Spawn_Slaves = Reader.ReadBoolean("Bools", "SpawnSlaves", mobAI.Spawn_Slaves); #endregion #region Loading the Kill Timer if (mobAI.UseKillTimer) { mobAI.KillTimer = Reader.ReadString("Strings", "KillTimer", mobAI.KillTimer); if (mobAI.killTimer.Length > 0) { string[] timeString = mobAI.KillTimer.Split(' '); string[] dateString = timeString[0].Split('-'); dateString[0] = dateString[0].Replace("(", ""); mobAI.LastKillDay = Convert.ToInt32(dateString[0]); mobAI.LastKillMonth = Convert.ToInt32(dateString[1]); mobAI.LastKillYear = Convert.ToInt32(dateString[2]); dateString[1] = dateString[1].Replace("(", ""); dateString[1] = dateString[1].Replace(")", ""); string[] tempString = timeString[1].Split(':'); if (tempString[0].Contains("(")) tempString[0] = tempString[0].Replace("(", ""); if (tempString[1].Contains(")")) tempString[1] = tempString[1].Replace(")", ""); mobAI.LastKillHour = Convert.ToInt32(tempString[0]); mobAI.LastKillMinute = Convert.ToInt32(tempString[1]); } mobAI.RespawnDay = Reader.ReadInt32("Ints", "RespawnDays", mobAI.RespawnDay); mobAI.RespawnMonth = Reader.ReadInt32("Ints", "RespawnMonths", mobAI.RespawnMonth); mobAI.RespawnYear = Reader.ReadInt32("Ints", "RespawnYears", mobAI.RespawnYear); mobAI.RespawnHour = Reader.ReadInt32("Ints", "RespawnHours", mobAI.RespawnHour); mobAI.RespawnMinute = Reader.ReadInt32("Ints", "RespawnMinutes", mobAI.RespawnMinute); } #endregion if (mobAI.MapSpecific) mobAI.MapName = Reader.ReadString("Strings", "MapName", mobAI.MapName); #region Loading the announcers if (mobAI.AnnounceSpawn) mobAI.SpawnMessage = Reader.ReadString("Strings", "SpawnMessage", mobAI.SpawnMessage); if (mobAI.AnnounceDeath) mobAI.DeadMessage = Reader.ReadString("Strings", "DeathMessage", mobAI.DeadMessage); if (mobAI.AnnounceDrop) mobAI.ItemMessage = Reader.ReadString("Strings", "ItemMessage", mobAI.ItemMessage); #endregion if (SetXY) { mobAI.MapX = Reader.ReadInt32("Ints", "MapX", mobAI.MapX); mobAI.MapY = Reader.ReadInt32("Ints", "MapY", mobAI.MapY); } #region Loading the Attacks if (mobAI.UseMassAttack) { mobAI.MassAttackEffect = Reader.ReadInt32("Ints", "MassAttackEffect", mobAI.MassAttackEffect); mobAI.MassAttackDamage = Reader.ReadInt32("Damage", "MassAttackDamage", mobAI.MassAttackDamage); } if (mobAI.UseSpecialAttack) { mobAI.SpecialAttackEffect = Reader.ReadInt32("Ints", "SpecialAttackEffect", mobAI.SpecialAttackEffect); mobAI.SpecialAttackDamage = Reader.ReadInt32("Damage", "SpecialAttackDamage", mobAI.SpecialAttackDamage); } if (mobAI.UseMeleeAttack) { mobAI.MeleeAttackEffect = Reader.ReadInt32("Ints", "MeleeAttackEffect", mobAI.MeleeAttackEffect); mobAI.MeleeAttackDamage = Reader.ReadInt32("Damage", "MeleeAttackDamage", mobAI.MeleeAttackDamage); } if (mobAI.UseRangeAttack) { mobAI.RangeAttackEffect = Reader.ReadInt32("Ints", "RangeAttackEffect", mobAI.RangeAttackEffect); mobAI.RangeAttackDamage = Reader.ReadInt32("Damage", "RangeAttackDamage", mobAI.RangeAttackDamage); } if (mobAI.UseMagicAttack) { mobAI.MagicAttackEffect = Reader.ReadInt32("Ints", "MagicAttackEffect", mobAI.MagicAttackEffect); mobAI.MagicAttackDamage = Reader.ReadInt32("Damage", "MagicAttackDamage", mobAI.MagicAttackDamage); } if (mobAI.Target) { mobAI.TargetClass = Reader.ReadInt32("Strings", "TargetClass", mobAI.TargetClass); //Default = Warrior mobAI.TargetedClass = (MirClass)mobAI.TargetClass; mobAI.TargetAttackDamage = Reader.ReadInt32("Damage", "TargetDamage", mobAI.TargetAttackDamage); } if (mobAI.DamagePetsMore) mobAI.PetAttackDamage = Reader.ReadInt32("Damage", "PetDamage", mobAI.PetAttackDamage); #endregion #region Loading the Slaves Spawns if (mobAI.Spawn_Slaves) { for (int i = 0; i < 4; i++) { SpawnSlaves monsters = new SpawnSlaves(); monsters.Name = Reader.ReadString("Slaves", "Slave" + i, monsters.Name); monsters.Count = Reader.ReadInt32("Slaves", "SlaveCount" + i, monsters.Count); mobAI.Slaves.Add(monsters); } } #endregion #region Loading the Item Drops mobAI.ItemCount = Reader.ReadInt32("Ints", "ItemCount", mobAI.ItemCount); if (mobAI.ItemCount > 0) { for (int i = 0; i < mobAI.ItemCount; i++) { DropItemsWithAnnounce items = new DropItemsWithAnnounce(); items.Name = Reader.ReadString("Items", "Item" + i, items.Name); items.Chance = Reader.ReadInt32("Items", "ItemChance" + i, items.Chance); mobAI.Drops.Add(items); } } #endregion #region Loading the current location mobAI.CurrentMap = Reader.ReadString("States", "CurrentMap", CurrentMap); mobAI.CurrentX = Reader.ReadInt32("States", "CurrentX", CurrentX); mobAI.CurrentY = Reader.ReadInt32("States", "CurrentY", CurrentY); #endregion return mobAI; } catch { SMain.Enqueue("Error with loading config"); return null; } }
public bool Save(CustomAI mobToSave) { if (mobToSave == null || mobToSave.Name.Length <= 0) return false; InIReader Writer = new InIReader(@".\Custom\Unique AIs\" + mobToSave.Name + ".ini"); Writer.Write("Bools", "SetXY", mobToSave.SetXY); Writer.Write("Bools", "MapSpecific", mobToSave.MapSpecific); Writer.Write("Bools", "AnnounceSpawn", mobToSave.AnnounceSpawn); Writer.Write("Bools", "AnnounceDrop", mobToSave.AnnounceDrop); Writer.Write("Bools", "AnnounceDeath", mobToSave.AnnounceDeath); Writer.Write("Bools", "UseMassAttack", mobToSave.UseMassAttack); Writer.Write("Bools", "UseSpecialAttack", mobToSave.UseSpecialAttack); Writer.Write("Bools", "UseMeleeAttack", mobToSave.UseMeleeAttack); Writer.Write("Bools", "UseRangeAttack", mobToSave.UseRangeAttack); Writer.Write("Bools", "Target", mobToSave.Target); Writer.Write("Bools", "UseKillTimer", mobToSave.UseKillTimer); Writer.Write("Bools", "IgnorePets", mobToSave.IgnorePets); Writer.Write("Bools", "DamagePetsMore", mobToSave.DamagePetsMore); Writer.Write("Bools", "CanPara", mobToSave.CanPara); Writer.Write("Bools", "CanGreen", mobToSave.CanGreen); Writer.Write("Bools", "CanRed", mobToSave.CanRed); Writer.Write("Bools", "SpawnSlaves", mobToSave.Spawn_Slaves); if (mobToSave.MapSpecific) Writer.Write("Strings", "MapName", mobToSave.MapName); if (mobToSave.AnnounceSpawn) Writer.Write("Strings", "SpawnMessage", mobToSave.SpawnMessage); if (mobToSave.AnnounceDeath) Writer.Write("Strings", "DeathMessage", mobToSave.DeadMessage); if (mobToSave.AnnounceDrop) Writer.Write("Strings", "ItemMessage", mobToSave.ItemMessage); if (mobToSave.SetXY) { Writer.Write("Ints", "MapX", mobToSave.MapX); Writer.Write("Ints", "MapY", mobToSave.MapY); } if (mobToSave.UseMassAttack) { Writer.Write("Ints", "MassAttackEffect", mobToSave.MassAttackEffect); Writer.Write("Damage", "MassAttackDamage", mobToSave.MassAttackDamage); } if (mobToSave.UseSpecialAttack) { Writer.Write("Ints", "SpecialAttackEffect", mobToSave.SpecialAttackEffect); Writer.Write("Damage", "SpecialAttackDamage", mobToSave.SpecialAttackDamage); } if (mobToSave.UseMeleeAttack) { Writer.Write("Ints", "MeleeAttackEffect", mobToSave.MeleeAttackEffect); Writer.Write("Damage", "MeleeAttackDamage", mobToSave.MeleeAttackDamage); } if (mobToSave.UseRangeAttack) { Writer.Write("Ints", "RangeAttackEffect", mobToSave.RangeAttackEffect); Writer.Write("Damage", "RangeAttackDamage", mobToSave.RangeAttackDamage); } if (mobToSave.UseMagicAttack) { Writer.Write("Ints", "MagicAttackEffect", mobToSave.MagicAttackEffect); Writer.Write("Damage", "MagicAttackDamage", mobToSave.MagicAttackDamage); } if (mobToSave.Target) { Writer.Write("Strings", "TargetClass", mobToSave.TargetClass); //Default = Warrior Writer.Write("Damage", "TargetDamage", mobToSave.TargetAttackDamage); } if (mobToSave.DamagePetsMore || !mobToSave.IgnorePets) Writer.Write("Damage", "PetDamage", mobToSave.PetAttackDamage); if (mobToSave.UseKillTimer) { Writer.Write("Strings", "KillTimer", mobToSave.KillTimer); Writer.Write("Ints", "RespawnDays", mobToSave.RespawnDay); Writer.Write("Ints", "RespawnMonths", mobToSave.RespawnMonth); Writer.Write("Ints", "RespawnYears", mobToSave.RespawnYear); Writer.Write("Ints", "RespawnHours", mobToSave.RespawnHour); Writer.Write("Ints", "RespawnMinutes", mobToSave.RespawnMinute); } Writer.Write("Ints", "ItemCount", mobToSave.ItemCount); if (mobToSave.Spawn_Slaves) { for (int i = 0; i < mobToSave.Slaves.Count; i++) { Writer.Write("Slaves", "Slave" + i, mobToSave.Slaves[i].Name); Writer.Write("Slaves", "SlaveCount" + i, mobToSave.Slaves[i].Count); } } if (mobToSave.ItemCount > 0) { for (int i = 0; i < mobToSave.ItemCount; i++) { Writer.Write("Items", "Item" + i, mobToSave.Drops[i].Name); Writer.Write("Items", "ItemChance" + i, mobToSave.Drops[i].Chance); } } Writer.Write("States", "Status", mobToSave.Alive); Writer.Write("States", "CurrentMap", mobToSave.CurrentMap); Writer.Write("States", "CurrentX", mobToSave.CurrentX); Writer.Write("States", "CurrentY", mobToSave.CurrentY); return true; }
protected internal MonsterObject(MonsterInfo info) { Info = info; Undead = Info.Undead; AutoRev = info.AutoRev; CoolEye = info.CoolEye > Envir.Random.Next(100); Direction = (MirDirection)Envir.Random.Next(8); AMode = AttackMode.All; PMode = PetMode.Both; RegenTime = Envir.Random.Next(RegenDelay) + Envir.Time; SearchTime = Envir.Random.Next(SearchDelay) + Envir.Time; RoamTime = Envir.Random.Next(RoamDelay) + Envir.Time; if (Info.AI == 255) // This needs to change { uniqueAI = uniqueAI.LoadCustomAI(Info.Name); if (uniqueAI == null) SMain.Enqueue("Error attaching system to monster."); else SMain.Enqueue("Monsters AI has been Loaded"); } }