Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.62 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5.  
  6. namespace Project_Terror_v2.Game.MsgServer
  7. {
  8. public unsafe struct MsgRuns
  9. {
  10. public enum RuneType : byte
  11. {
  12. Equip = 57,
  13. UnEquip = 58,
  14. InventoryRune = 61,
  15. UpgradeRune = 63
  16. }
  17. public static bool IsRune(uint ID)
  18. {
  19. return ID >= 4010101 && ID <= 4031309 || ID >= 4010001 && ID <= 4010901;
  20. }
  21. public static void Runs(Client.GameClient client, ServerSockets.Packet _stream)
  22. {
  23. var packet = new byte[_stream.Size];
  24. System.Runtime.InteropServices.Marshal.Copy(new IntPtr(_stream.Memory), packet, 0, _stream.Size);
  25. switch ((RuneType)packet[20])
  26. {
  27. case RuneType.Equip:
  28. {
  29. MsgGameItem DataItem;
  30. if (client.Warehouse.TryGetItem((uint)Game.MsgNpc.NpcID.WHRune, (uint)BitConverter.ToUInt32(packet, 8), out DataItem))
  31. {
  32.  
  33. if (IsRune(DataItem.ITEM_ID) == false)
  34. return;
  35. var DBItem = Database.ItemType.GetItemRecord(DataItem.ITEM_ID);
  36. if (DBItem != null)
  37. {
  38. if (client.Warehouse.CanEquipRune((ushort)packet[12]))
  39. {
  40. if (client.Warehouse.DeleteItem((uint)Game.MsgNpc.NpcID.WHRune, (uint)BitConverter.ToUInt32(packet, 8)))
  41. {
  42. client.Warehouse.AddItem(DataItem, (uint)Game.MsgNpc.NpcID.MainRune);
  43. DataItem.Mode = Role.Flags.ItemMode.Update;
  44. DataItem.Position = (byte)packet[12];
  45. DataItem.Send(client, _stream);
  46. client.Equipment.QueryEquipment(client.Equipment.Alternante, false);
  47. client.Send(_stream.ItemUsageCreate((MsgItemUsuagePacket.ItemUsuageID)packet[20], BitConverter.ToUInt32(packet, 8), BitConverter.ToUInt32(packet, 12), BitConverter.ToUInt32(packet, 22), 0, 0, 0));
  48.  
  49. var spell = Database.MagicType.GetSpellRecord(DBItem.SpellID, DBItem.SpellLevel);
  50.  
  51. if (spell != null)
  52. {
  53. if (!client.MySpells.ClientSpells.ContainsKey((ushort)spell.ID))
  54. client.MySpells.Add(_stream, (ushort)spell.ID);
  55. }
  56. }
  57. }
  58. }
  59. }
  60. break;
  61. }
  62. case RuneType.UnEquip:
  63. {
  64. MsgGameItem DataItem;
  65. if (client.Warehouse.TryGetItem((uint)Game.MsgNpc.NpcID.MainRune, (uint)BitConverter.ToUInt32(packet, 8), out DataItem))
  66. {
  67.  
  68. if (Database.ItemType.IsRune(DataItem.ITEM_ID) == false)
  69. return;
  70.  
  71. if (client.Warehouse.AddItem(DataItem, (uint)Game.MsgNpc.NpcID.WHRune, 100))
  72. {
  73. if (client.Warehouse.DeleteItem((uint)Game.MsgNpc.NpcID.MainRune, (uint)BitConverter.ToUInt32(packet, 8)))
  74. {
  75. DataItem.Mode = Role.Flags.ItemMode.Update;
  76. DataItem.Position = (byte)Role.Flags.ConquerItem.Rune;
  77. DataItem.Send(client, _stream);
  78.  
  79. client.Equipment.QueryEquipment(client.Equipment.Alternante, false);
  80. client.Send(_stream.ItemUsageCreate((MsgItemUsuagePacket.ItemUsuageID)packet[20], BitConverter.ToUInt32(packet, 8), BitConverter.ToUInt32(packet, 12), BitConverter.ToUInt32(packet, 22), 0, 0, 0));
  81.  
  82. var DBItem = Database.ItemType.GetItemRecord(DataItem.ITEM_ID);
  83. if (DBItem != null)
  84. {
  85. var spell = Database.MagicType.GetSpellRecord(DBItem.SpellID, DBItem.SpellLevel);
  86.  
  87. if (spell != null)
  88. {
  89. if (client.MySpells.ClientSpells.ContainsKey((ushort)spell.ID))
  90. client.MySpells.Remove((ushort)spell.ID, _stream);
  91. }
  92. }
  93. }
  94. }
  95. else
  96. client.SendSysMesage("Sorry, your container is full.");
  97. }
  98. break;
  99. }
  100. }
  101. }
  102. }
  103. }
  104.  
  105.  
  106.  
  107.  
  108.  
  109. if (action == (ItemUsuageID)57 || action == (ItemUsuageID)58 || action == (ItemUsuageID)61 || action == (ItemUsuageID)63)
  110. {
  111. MsgRuns.Runs(client, stream);
  112. }
  113.  
  114.  
  115. MainRune = 62,
  116. WHRune = 61,
  117. ف ال public enum NpcID : uint
  118. هتروح ل public class Warehouse
  119. تضيف || ID == Game.MsgNpc.NpcID.WHRune
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement