public class MagicTypeOP : List>> { public List StaticSpells = new List() { Enums.SkillIDs.NightDevil, Enums.SkillIDs.SpeedGun, Enums.SkillIDs.Penetration, Enums.SkillIDs.Boreas, Enums.SkillIDs.Boom, Enums.SkillIDs.Phoenix, Enums.SkillIDs.StrandedMonster, Enums.SkillIDs.Snow, Enums.SkillIDs.FastBlade, Enums.SkillIDs.ScentSword, Enums.SkillIDs.DragonTail, Enums.SkillIDs.ViperFang, Enums.SkillIDs.Seizer, Enums.SkillIDs.EarthQuake, Enums.SkillIDs.Rage, Enums.SkillIDs.Celestial, Enums.SkillIDs.Roamer, Enums.SkillIDs.ChargingVortex, Enums.SkillIDs.Riding, Enums.SkillIDs.Spook, Enums.SkillIDs.WarCry, Enums.SkillIDs.Halt, Enums.SkillIDs.Dance2, Enums.SkillIDs.Dance3, Enums.SkillIDs.Dance4, Enums.SkillIDs.Dance5, Enums.SkillIDs.Dance6, Enums.SkillIDs.Dance7, Enums.SkillIDs.Dance8, Enums.SkillIDs.Restore, }; public enum Action : byte { Delete = 0, Downgrade = 2, AllClassSpells = 4,//??? PureSpell = 5, Add = 6, AddRebornSpells = 7 } public MagicTypeOP() { Load(); } public void Load() { string[] baseplusText = File.ReadAllLines(Constants.DataHolderPath + "\\magictypeop.txt"); foreach (string line in baseplusText) { string[] data = line.Split(','); byte Reborn = byte.Parse(data[1]); byte MyClass = byte.Parse(data[2]); byte RebornClass = byte.Parse(data[3]); Action Info = (Action)byte.Parse(data[4]); List Spells = new List(); for (int x = 5; x < data.Length; x++) { ushort ID = ushort.Parse(data[x]); if (ID != 0) Spells.Add((Enums.SkillIDs)ID); } this.Add(new Tuple>(Reborn, MyClass, RebornClass, Info, Spells)); } } private void RebornAction(GameState client, Tuple> info, bool remove = false) { switch (info.Item4) { case Action.AllClassSpells: { if (remove) { foreach (var spellid in info.Item5) { if (!StaticSpells.Contains(spellid)) { if (client.Spells.ContainsKey((ushort)spellid)) { var spell = client.Spells[(ushort)spellid]; client.RemoveSpell(spell); } } } } else { foreach (var spellid in info.Item5) { if (!StaticSpells.Contains(spellid)) { var spell = Npcs.LearnableSpell((ushort)spellid); client.Spells.Add(spell.ID, spell); } } } break; } case Action.PureSpell: { if (remove) { foreach (var spellid in info.Item5) { if (client.Spells.ContainsKey((ushort)spellid)) { var spell = client.Spells[(ushort)spellid]; client.RemoveSpell(spell); } } } else { foreach (var spellid in info.Item5) { var spell = Npcs.LearnableSpell((ushort)spellid); client.Spells.Add(spell.ID, spell); } } break; } case Action.AddRebornSpells: case Action.Add: { foreach (var spellid in info.Item5) { var spell = Npcs.LearnableSpell((ushort)spellid); client.Spells.Add(spell.ID, spell); } break; } case Action.Delete: { foreach (var spellid in info.Item5) { if (client.Spells.ContainsKey((ushort)spellid)) { var spell = client.Spells[(ushort)spellid]; client.RemoveSpell(spell); } } break; } case Action.Downgrade: { foreach (var spellid in info.Item5) { if (client.Spells.ContainsKey((ushort)spellid)) { var spell = client.Spells[(ushort)spellid]; if (spell.Level != 0) { spell.PreviousLevel = spell.Level; spell.Level = 0; spell.Experience = 0; if (spell.ID != (ushort)COServer.Game.Enums.SkillIDs.Reflect) spell.Send(client); } } } break; } } } private byte GetClass(byte Class) { if (Class != 0) { if (Class / 10 == 13) Class = 132; else if (Class / 10 == 14) Class = 142; else Class = (byte)(((Class / 10) * 10) + 1); } return Class; } public void Reborn(GameState Client, byte RebornClass) { try { var Class = GetClass(Client.Player.Class); var Class1 = GetClass(Client.Player.FirstRebornClass); var Class2 = GetClass(Client.Player.SecondRebornClass); if (RebornClass != 0) { if (RebornClass % 10 == 1 || RebornClass == 132 || RebornClass == 142) { switch (Client.Player.Reborn) { case 0: { foreach (var info in this) { if (info.Item1 == 1 && info.Item2 == Client.Player.Class && info.Item3 == RebornClass) RebornAction(Client, info); } break; } case 1: { foreach (var info in this) { if (info.Item1 == 1 && info.Item2 == Client.Player.FirstRebornClass && info.Item3 == Class) RebornAction(Client, info); if (info.Item1 == 2 && info.Item2 == Client.Player.Class && info.Item3 == RebornClass) RebornAction(Client, info); else if (info.Item1 == 0 && info.Item2 == Class1 && info.Item2 == Class && info.Item3 == RebornClass) RebornAction(Client, info); } break; } case 2: { foreach (var spellid in StaticSpells) { if (Client.Spells.ContainsKey((ushort)spellid)) { var spell = Client.Spells[(ushort)spellid]; Client.RemoveSpell(spell); } } foreach (var info in this) { if (info.Item1 == 1 && info.Item2 == Client.Player.SecondRebornClass && info.Item3 == Class) RebornAction(Client, info); if (info.Item1 == 2 && info.Item2 == Client.Player.Class && info.Item3 == RebornClass) RebornAction(Client, info); if (info.Item1 == 0 && info.Item2 == Class2 && info.Item2 == Class && info.Item3 == RebornClass) RebornAction(Client, info); if (info.Item1 == 0 && info.Item2 == Class1 && info.Item2 == Class2 && info.Item2 == Class2 && info.Item2 != RebornClass) RebornAction(Client, info, true); if (info.Item1 == 0 && info.Item2 == 0 && info.Item3 == Class1) RebornAction(Client, info, true); if (info.Item1 == 0 && info.Item2 == 0 && info.Item3 == RebornClass) RebornAction(Client, info); } break; } } } var spellx = new List(); foreach (var spell in Client.Spells.Values) spellx.Add((Enums.SkillIDs)spell.ID); Client.Send(new MsgTalk(string.Format("Lenght [{0}] : {1}", spellx.Count, string.Join("||", spellx.ToArray())), MsgTalk.Tip)); foreach (var spell in Client.Spells.Values) if (spell.ID != 3060) spell.Send(Client); } else { foreach (var info in this) { if (info.Item1 == 0 && info.Item2 == 0 && info.Item3 == Class) { if (info.Item4 == Action.AllClassSpells) { foreach (var spellid in info.Item5) { if (!StaticSpells.Contains(spellid)) { if (!Client.Spells.ContainsKey((ushort)spellid)) { var spell = COServer.Database.SpellTable.GetSpell((ushort)spellid, 0); if (spell != null) if (Client.Player.Level >= spell.NeedLevel) Client.AddSpell(new MsgMagicInfo(true) { ID = (ushort)spellid }); } } } } } } } } catch (Exception) { throw; } } public List>> GetInfosByType(Action action) { return this.Where(infox => infox.Item4 == action).ToList(); } }