Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- namespace Project_Terror_v2.Game.MsgServer
- {
- public unsafe struct MsgRuns
- {
- public enum RuneType : byte
- {
- Equip = 57,
- UnEquip = 58,
- InventoryRune = 61,
- UpgradeRune = 63
- }
- public static bool IsRune(uint ID)
- {
- return ID >= 4010101 && ID <= 4031309 || ID >= 4010001 && ID <= 4010901;
- }
- public static void Runs(Client.GameClient client, ServerSockets.Packet _stream)
- {
- var packet = new byte[_stream.Size];
- System.Runtime.InteropServices.Marshal.Copy(new IntPtr(_stream.Memory), packet, 0, _stream.Size);
- switch ((RuneType)packet[20])
- {
- case RuneType.Equip:
- {
- MsgGameItem DataItem;
- if (client.Warehouse.TryGetItem((uint)Game.MsgNpc.NpcID.WHRune, (uint)BitConverter.ToUInt32(packet, 8), out DataItem))
- {
- if (IsRune(DataItem.ITEM_ID) == false)
- return;
- var DBItem = Database.ItemType.GetItemRecord(DataItem.ITEM_ID);
- if (DBItem != null)
- {
- if (client.Warehouse.CanEquipRune((ushort)packet[12]))
- {
- if (client.Warehouse.DeleteItem((uint)Game.MsgNpc.NpcID.WHRune, (uint)BitConverter.ToUInt32(packet, 8)))
- {
- client.Warehouse.AddItem(DataItem, (uint)Game.MsgNpc.NpcID.MainRune);
- DataItem.Mode = Role.Flags.ItemMode.Update;
- DataItem.Position = (byte)packet[12];
- DataItem.Send(client, _stream);
- client.Equipment.QueryEquipment(client.Equipment.Alternante, false);
- client.Send(_stream.ItemUsageCreate((MsgItemUsuagePacket.ItemUsuageID)packet[20], BitConverter.ToUInt32(packet, 8), BitConverter.ToUInt32(packet, 12), BitConverter.ToUInt32(packet, 22), 0, 0, 0));
- var spell = Database.MagicType.GetSpellRecord(DBItem.SpellID, DBItem.SpellLevel);
- if (spell != null)
- {
- if (!client.MySpells.ClientSpells.ContainsKey((ushort)spell.ID))
- client.MySpells.Add(_stream, (ushort)spell.ID);
- }
- }
- }
- }
- }
- break;
- }
- case RuneType.UnEquip:
- {
- MsgGameItem DataItem;
- if (client.Warehouse.TryGetItem((uint)Game.MsgNpc.NpcID.MainRune, (uint)BitConverter.ToUInt32(packet, 8), out DataItem))
- {
- if (Database.ItemType.IsRune(DataItem.ITEM_ID) == false)
- return;
- if (client.Warehouse.AddItem(DataItem, (uint)Game.MsgNpc.NpcID.WHRune, 100))
- {
- if (client.Warehouse.DeleteItem((uint)Game.MsgNpc.NpcID.MainRune, (uint)BitConverter.ToUInt32(packet, 8)))
- {
- DataItem.Mode = Role.Flags.ItemMode.Update;
- DataItem.Position = (byte)Role.Flags.ConquerItem.Rune;
- DataItem.Send(client, _stream);
- client.Equipment.QueryEquipment(client.Equipment.Alternante, false);
- client.Send(_stream.ItemUsageCreate((MsgItemUsuagePacket.ItemUsuageID)packet[20], BitConverter.ToUInt32(packet, 8), BitConverter.ToUInt32(packet, 12), BitConverter.ToUInt32(packet, 22), 0, 0, 0));
- var DBItem = Database.ItemType.GetItemRecord(DataItem.ITEM_ID);
- if (DBItem != null)
- {
- var spell = Database.MagicType.GetSpellRecord(DBItem.SpellID, DBItem.SpellLevel);
- if (spell != null)
- {
- if (client.MySpells.ClientSpells.ContainsKey((ushort)spell.ID))
- client.MySpells.Remove((ushort)spell.ID, _stream);
- }
- }
- }
- }
- else
- client.SendSysMesage("Sorry, your container is full.");
- }
- break;
- }
- }
- }
- }
- }
- if (action == (ItemUsuageID)57 || action == (ItemUsuageID)58 || action == (ItemUsuageID)61 || action == (ItemUsuageID)63)
- {
- MsgRuns.Runs(client, stream);
- }
- MainRune = 62,
- WHRune = 61,
- ف ال public enum NpcID : uint
- هتروح ل public class Warehouse
- تضيف || ID == Game.MsgNpc.NpcID.WHRune
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement