MagicTypeOP


SUBMITTED BY: Avalanche

DATE: Aug. 5, 2017, 10:52 a.m.

FORMAT: C#

SIZE: 13.5 kB

HITS: 255

  1. public class MagicTypeOP : List<Tuple<byte, byte, byte, MagicTypeOP.Action, List<Enums.SkillIDs>>>
  2. {
  3. public List<Enums.SkillIDs> StaticSpells = new List<Enums.SkillIDs>()
  4. {
  5. Enums.SkillIDs.NightDevil,
  6. Enums.SkillIDs.SpeedGun,
  7. Enums.SkillIDs.Penetration,
  8. Enums.SkillIDs.Boreas,
  9. Enums.SkillIDs.Boom,
  10. Enums.SkillIDs.Phoenix,
  11. Enums.SkillIDs.StrandedMonster,
  12. Enums.SkillIDs.Snow,
  13. Enums.SkillIDs.FastBlade,
  14. Enums.SkillIDs.ScentSword,
  15. Enums.SkillIDs.DragonTail,
  16. Enums.SkillIDs.ViperFang,
  17. Enums.SkillIDs.Seizer,
  18. Enums.SkillIDs.EarthQuake,
  19. Enums.SkillIDs.Rage,
  20. Enums.SkillIDs.Celestial,
  21. Enums.SkillIDs.Roamer,
  22. Enums.SkillIDs.ChargingVortex,
  23. Enums.SkillIDs.Riding,
  24. Enums.SkillIDs.Spook,
  25. Enums.SkillIDs.WarCry,
  26. Enums.SkillIDs.Halt,
  27. Enums.SkillIDs.Dance2,
  28. Enums.SkillIDs.Dance3,
  29. Enums.SkillIDs.Dance4,
  30. Enums.SkillIDs.Dance5,
  31. Enums.SkillIDs.Dance6,
  32. Enums.SkillIDs.Dance7,
  33. Enums.SkillIDs.Dance8,
  34. Enums.SkillIDs.Restore,
  35. };
  36. public enum Action : byte
  37. {
  38. Delete = 0,
  39. Downgrade = 2,
  40. AllClassSpells = 4,//???
  41. PureSpell = 5,
  42. Add = 6,
  43. AddRebornSpells = 7
  44. }
  45. public MagicTypeOP()
  46. {
  47. Load();
  48. }
  49. public void Load()
  50. {
  51. string[] baseplusText = File.ReadAllLines(Constants.DataHolderPath + "\\magictypeop.txt");
  52. foreach (string line in baseplusText)
  53. {
  54. string[] data = line.Split(',');
  55. byte Reborn = byte.Parse(data[1]);
  56. byte MyClass = byte.Parse(data[2]);
  57. byte RebornClass = byte.Parse(data[3]);
  58. Action Info = (Action)byte.Parse(data[4]);
  59. List<Enums.SkillIDs> Spells = new List<Enums.SkillIDs>();
  60. for (int x = 5; x < data.Length; x++)
  61. {
  62. ushort ID = ushort.Parse(data[x]);
  63. if (ID != 0)
  64. Spells.Add((Enums.SkillIDs)ID);
  65. }
  66. this.Add(new Tuple<byte, byte, byte, Action, List<Enums.SkillIDs>>(Reborn, MyClass, RebornClass, Info, Spells));
  67. }
  68. }
  69. private void RebornAction(GameState client, Tuple<byte, byte, byte, MagicTypeOP.Action, List<Enums.SkillIDs>> info, bool remove = false)
  70. {
  71. switch (info.Item4)
  72. {
  73. case Action.AllClassSpells:
  74. {
  75. if (remove)
  76. {
  77. foreach (var spellid in info.Item5)
  78. {
  79. if (!StaticSpells.Contains(spellid))
  80. {
  81. if (client.Spells.ContainsKey((ushort)spellid))
  82. {
  83. var spell = client.Spells[(ushort)spellid];
  84. client.RemoveSpell(spell);
  85. }
  86. }
  87. }
  88. }
  89. else
  90. {
  91. foreach (var spellid in info.Item5)
  92. {
  93. if (!StaticSpells.Contains(spellid))
  94. {
  95. var spell = Npcs.LearnableSpell((ushort)spellid);
  96. client.Spells.Add(spell.ID, spell);
  97. }
  98. }
  99. }
  100. break;
  101. }
  102. case Action.PureSpell:
  103. {
  104. if (remove)
  105. {
  106. foreach (var spellid in info.Item5)
  107. {
  108. if (client.Spells.ContainsKey((ushort)spellid))
  109. {
  110. var spell = client.Spells[(ushort)spellid];
  111. client.RemoveSpell(spell);
  112. }
  113. }
  114. }
  115. else
  116. {
  117. foreach (var spellid in info.Item5)
  118. {
  119. var spell = Npcs.LearnableSpell((ushort)spellid);
  120. client.Spells.Add(spell.ID, spell);
  121. }
  122. }
  123. break;
  124. }
  125. case Action.AddRebornSpells:
  126. case Action.Add:
  127. {
  128. foreach (var spellid in info.Item5)
  129. {
  130. var spell = Npcs.LearnableSpell((ushort)spellid);
  131. client.Spells.Add(spell.ID, spell);
  132. }
  133. break;
  134. }
  135. case Action.Delete:
  136. {
  137. foreach (var spellid in info.Item5)
  138. {
  139. if (client.Spells.ContainsKey((ushort)spellid))
  140. {
  141. var spell = client.Spells[(ushort)spellid];
  142. client.RemoveSpell(spell);
  143. }
  144. }
  145. break;
  146. }
  147. case Action.Downgrade:
  148. {
  149. foreach (var spellid in info.Item5)
  150. {
  151. if (client.Spells.ContainsKey((ushort)spellid))
  152. {
  153. var spell = client.Spells[(ushort)spellid];
  154. if (spell.Level != 0)
  155. {
  156. spell.PreviousLevel = spell.Level;
  157. spell.Level = 0;
  158. spell.Experience = 0;
  159. if (spell.ID != (ushort)COServer.Game.Enums.SkillIDs.Reflect)
  160. spell.Send(client);
  161. }
  162. }
  163. }
  164. break;
  165. }
  166. }
  167. }
  168. private byte GetClass(byte Class)
  169. {
  170. if (Class != 0)
  171. {
  172. if (Class / 10 == 13)
  173. Class = 132;
  174. else if (Class / 10 == 14)
  175. Class = 142;
  176. else
  177. Class = (byte)(((Class / 10) * 10) + 1);
  178. }
  179. return Class;
  180. }
  181. public void Reborn(GameState Client, byte RebornClass)
  182. {
  183. try
  184. {
  185. var Class = GetClass(Client.Player.Class);
  186. var Class1 = GetClass(Client.Player.FirstRebornClass);
  187. var Class2 = GetClass(Client.Player.SecondRebornClass);
  188. if (RebornClass != 0)
  189. {
  190. if (RebornClass % 10 == 1 || RebornClass == 132 || RebornClass == 142)
  191. {
  192. switch (Client.Player.Reborn)
  193. {
  194. case 0:
  195. {
  196. foreach (var info in this)
  197. {
  198. if (info.Item1 == 1 && info.Item2 == Client.Player.Class && info.Item3 == RebornClass)
  199. RebornAction(Client, info);
  200. }
  201. break;
  202. }
  203. case 1:
  204. {
  205. foreach (var info in this)
  206. {
  207. if (info.Item1 == 1 && info.Item2 == Client.Player.FirstRebornClass && info.Item3 == Class)
  208. RebornAction(Client, info);
  209. if (info.Item1 == 2 && info.Item2 == Client.Player.Class && info.Item3 == RebornClass)
  210. RebornAction(Client, info);
  211. else if (info.Item1 == 0 && info.Item2 == Class1 && info.Item2 == Class && info.Item3 == RebornClass)
  212. RebornAction(Client, info);
  213. }
  214. break;
  215. }
  216. case 2:
  217. {
  218. foreach (var spellid in StaticSpells)
  219. {
  220. if (Client.Spells.ContainsKey((ushort)spellid))
  221. {
  222. var spell = Client.Spells[(ushort)spellid];
  223. Client.RemoveSpell(spell);
  224. }
  225. }
  226. foreach (var info in this)
  227. {
  228. if (info.Item1 == 1 && info.Item2 == Client.Player.SecondRebornClass && info.Item3 == Class)
  229. RebornAction(Client, info);
  230. if (info.Item1 == 2 && info.Item2 == Client.Player.Class && info.Item3 == RebornClass)
  231. RebornAction(Client, info);
  232. if (info.Item1 == 0 && info.Item2 == Class2 && info.Item2 == Class && info.Item3 == RebornClass)
  233. RebornAction(Client, info);
  234. if (info.Item1 == 0 && info.Item2 == Class1 && info.Item2 == Class2 && info.Item2 == Class2 && info.Item2 != RebornClass)
  235. RebornAction(Client, info, true);
  236. if (info.Item1 == 0 && info.Item2 == 0 && info.Item3 == Class1)
  237. RebornAction(Client, info, true);
  238. if (info.Item1 == 0 && info.Item2 == 0 && info.Item3 == RebornClass)
  239. RebornAction(Client, info);
  240. }
  241. break;
  242. }
  243. }
  244. }
  245. var spellx = new List<Enums.SkillIDs>();
  246. foreach (var spell in Client.Spells.Values)
  247. spellx.Add((Enums.SkillIDs)spell.ID);
  248. Client.Send(new MsgTalk(string.Format("Lenght [{0}] : {1}", spellx.Count, string.Join("||", spellx.ToArray())), MsgTalk.Tip));
  249. foreach (var spell in Client.Spells.Values)
  250. if (spell.ID != 3060)
  251. spell.Send(Client);
  252. }
  253. else
  254. {
  255. foreach (var info in this)
  256. {
  257. if (info.Item1 == 0 && info.Item2 == 0 && info.Item3 == Class)
  258. {
  259. if (info.Item4 == Action.AllClassSpells)
  260. {
  261. foreach (var spellid in info.Item5)
  262. {
  263. if (!StaticSpells.Contains(spellid))
  264. {
  265. if (!Client.Spells.ContainsKey((ushort)spellid))
  266. {
  267. var spell = COServer.Database.SpellTable.GetSpell((ushort)spellid, 0);
  268. if (spell != null)
  269. if (Client.Player.Level >= spell.NeedLevel)
  270. Client.AddSpell(new MsgMagicInfo(true) { ID = (ushort)spellid });
  271. }
  272. }
  273. }
  274. }
  275. }
  276. }
  277. }
  278. }
  279. catch (Exception)
  280. {
  281. throw;
  282. }
  283. }
  284. public List<Tuple<byte, byte, byte, MagicTypeOP.Action, List<Enums.SkillIDs>>> GetInfosByType(Action action)
  285. {
  286. return this.Where(infox => infox.Item4 == action).ToList();
  287. }
  288. }

comments powered by Disqus