public static AddStatInfo RecvAddStatRequest(Packet p) { p.Skip(2); byte stat = p.ReadByte(); byte amount = p.ReadByte(); AddStatInfo asi = new AddStatInfo { Stat = stat, Amount = amount }; return asi; }
public static AddItemToShopInfo RecvAddItemToShop(Packet p) { p.Skip(2); byte frombag = p.ReadByte(); byte fromslot = p.ReadByte(); int itemid = p.ReadInt(); byte slot = p.ReadByte(); int price = p.ReadInt(); AddItemToShopInfo i = new AddItemToShopInfo { FromBag = frombag, FromSlot = fromslot, ItemID = itemid, Slot = slot, Price = price }; return i; }
public static BuyItemInfo RecvBuyItem(Packet p) { p.Skip(2); int npcid = p.ReadInt(); short wref = p.ReadShort(); p.Skip(2); short amount = p.ReadShort(); p.Skip(2); byte bag = p.ReadByte(); BuyItemInfo i = new BuyItemInfo { NpcID = npcid, ReferenceID = wref, Amount = amount, Bag = bag }; return i; }
/// <summary> /// Decrypts the given packet /// </summary> /// <param name="p">The packet to decrypt</param> public static Packet Decrypt(Packet p, int key) { byte[] data = p.GetBuffer(); int packetLength = data.Length - 4; string value; int Lenght; byte BL, DL, CL; long AL; value = data[3].ToString("x2"); value += data[2].ToString("x2"); Lenght = Int32.Parse(value, NumberStyles.HexNumber); BL = (byte)key; CL = data[0]; AL = Lenght + 4; DL = CL; DL = (byte)(DL - AL); DL = (byte)(DL - BL); data[0] = DL; DL = data[1]; BL = DL; BL = (byte)(BL - AL); BL = (byte)(BL - CL); BL = (byte)(BL - key); data[1] = BL; for (int a = 0; a < Lenght; a++) { BL = data[a + 4]; BL = (byte)(BL - AL); BL = (byte)(BL - DL); BL = (byte)(BL - key); DL = data[a + 4]; data[a + 4] = BL; } return new Packet(data); }
public static AcceptImbueItem RecvAcceptImbueItem(Packet p) { p.Skip(2); int NpcID = p.ReadInt(); int toImbueID = p.ReadInt(); byte toImbueBag = p.ReadByte(); byte toImbueSlot = p.ReadByte(); int imbueItem1ID = p.ReadInt(); byte imbueItem1Bag = p.ReadByte(); byte imbueItem1Slot = p.ReadByte(); int imbueItem2ID = p.ReadInt(); byte imbueItem2Bag = p.ReadByte(); byte imbueItem2Slot = p.ReadByte(); int imbueItem3ID = p.ReadInt(); byte imbueItem3Bag = p.ReadByte(); byte imbueItem3Slot = p.ReadByte(); AcceptImbueItem i = new AcceptImbueItem { NpcID = NpcID, ToImbueItemID = toImbueID, ToImbueItemBag = toImbueBag, ToImbueItemSlot = toImbueSlot, ImbueItem1ID = imbueItem1ID, ImbueItem1Bag = imbueItem1Bag, ImbueItem1Slot = imbueItem1Slot, ImbueItem2ID = imbueItem2ID, ImbueItem2Bag = imbueItem2Bag, ImbueItem2Slot = imbueItem2Slot, ImbueItem3ID = imbueItem3ID, ImbueItem3Bag = imbueItem3Bag, ImbueItem3Slot = imbueItem3Slot }; return i; }
public static AddItemToWarehouseInfo RecvAddItemToWarehouse(Packet p) { p.Skip(2); int charid = p.ReadInt(); int itemid = p.ReadInt(); byte frombag = p.ReadByte(); byte fromslot = p.ReadByte(); byte toslot = p.ReadByte(); byte tobag = p.ReadByte(); AddItemToWarehouseInfo i = new AddItemToWarehouseInfo { CharacterID = charid, ItemID = itemid, FromBag = frombag, FromSlot = fromslot, ToBag = tobag, ToSlot = toslot }; return i; }
public static byte[] SendBagItems(List<BaseItem> items, int bag) { Packet p = new Packet(200); // p.WriteHexString("18 31 A4 00 00 02 00 73 83 D0 00 2A 4E 01 02 B0 04 00 00 00 00 00 00 02 00 00 04 00 05 00 06 00 07 00 08 00 C0 C8 00 C8 00 05 00 06 00 07 00 08 00 09 00 0A 00 0B 00 0C 00 0D 00 0E 00 0F 08 00 00 00 04 00 05 00 07 00 0A 00 0B 00 0C 00 0D 00 00 00 00 01 01 01 02 02 74 83 D0 00 35 4E 02 01 34 08 00 00 00 00 00 00 02 01 00 01 00 00 00 00 00 01 00 00 00 C8 64 00 64 00 00 00 03 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"); p.WriteByte(bag); p.WriteByte(items.Count); foreach (BaseItem i in items) { p.WriteByte(i.Slot); p.WriteInt(i.ItemID); p.WriteShort(i.ReferenceID); p.WriteByte(i.bType); p.WriteByte(i.bKind); p.WriteShort(i.VisualID); p.WriteInt(i.Price); p.WriteHexString("00 00"); if (i is Equipment) { Equipment e = i as Equipment; p.WriteByte(e.RequiredClass); p.WriteShort(e.Amount); p.WriteShort(e.RequiredLevel); p.WriteShort(e.RequiredDexterity); p.WriteShort(e.RequiredStrength); p.WriteShort(e.RequiredStamina); p.WriteShort(e.RequiredEnergy); p.WriteByte(e.MaxImbueTries); p.WriteShort(e.Durability); p.WriteShort(e.MaxDurability); p.WriteShort(e.Damage); p.WriteShort(e.Defence); p.WriteShort(e.AttackRating); p.WriteShort(e.AttackSpeed); p.WriteShort(e.AttackRange); p.WriteShort(e.IncMaxLife); p.WriteShort(e.IncMaxMana); p.WriteShort(e.IncLifeRegen); p.WriteShort(e.IncManaRegen); p.WriteShort(e.Critical); p.WriteByte(e.Plus); p.WriteByte(e.Slvl); p.WriteHexString("00"); // unknown p.WriteByte(e.ImbueTries); p.WriteHexString("00"); // unknown p.WriteShort(e.DragonSuccessImbueTries); p.WriteByte(e.DiscountRepairFee); p.WriteShort(e.TotalDragonImbueTries); p.WriteShort(e.DragonDamage); p.WriteShort(e.DragonDefence); p.WriteShort(e.DragonAttackRating); p.WriteShort(e.DragonLife); p.WriteByte(e.MappedData); if (!(e is Ring) && !(e is Necklace) && !(e is Cape)) p.WriteByte(e.ForceSlot); p.WriteHexString("00 00"); // unknown if (e is Cape) { Cape c = e as Cape; p.WriteHexString("00 00"); // required guild position p.WriteHexString("00 00 00 00 00 00 00"); p.WriteHexString("01 00"); // decrease times of durability p.WriteByte(c.PolishImbueTries); // polish imbue tries p.WriteShort(c.MaxPolishImbueTries); // polish max tries p.WriteShort(c.VigiStat1); // stat1 p.WriteShort(c.VigiStat2); // stat2 p.WriteShort(c.VigiStat3); // stat3 p.WriteShort(c.VigiStat4); // stat4 p.WriteHexString("00 00"); // stat5 p.WriteShort(c.VigiStatAdd1); // stat1 increase p.WriteShort(c.VigiStatAdd2); // stat2 increase p.WriteShort(c.VigiStatAdd3); // stat3 increase p.WriteShort(c.VigiStatAdd4); // stat4 increase p.WriteHexString("00 00"); // stat5 increase p.WriteHexString("00 00"); // unknown } if (!(e is Ring) && !(e is Necklace) && !(e is Cape)) { p.WriteByte(e.RebirthHole); p.WriteByte(e.RebirthHoleItem); p.WriteShort(e.RebirthHoleStat); } } if (i is ImbueItem) { ImbueItem im = i as ImbueItem; p.WriteByte(im.RequiredClass); p.WriteShort(i.Amount); p.WriteHexString("00"); // imbuestat, eg dec level, increase value etc p.WriteShort(im.ImbueChance); p.WriteShort(im.IncreaseValue); p.WriteHexString("00 00"); // could be lowest lvl who knows p.WriteHexString("00 00"); // maxlevel of usage, for dragon stones p.WriteHexString("00 00"); // unknown } if (i is PotionItem) { PotionItem pot = i as PotionItem; p.WriteByte(pot.RequiredClass); p.WriteShort(pot.Amount); p.WriteHexString("00 00 00 00"); p.WriteShort(pot.HealHp); p.WriteShort(pot.HealMana); p.WriteHexString("00 20 4E 00 00 00 00"); } if (i is BookItem) { BookItem book = i as BookItem; p.WriteByte(book.RequiredClass); p.WriteShort(book.Amount); p.WriteShort(book.RequiredLevel); p.WriteInt(book.SkillID); p.WriteByte(book.SkillLevel); p.WriteInt(book.SkillData); } if (i is BeadItem) { BeadItem bead = i as BeadItem; p.WriteByte(bead.RequiredClass); p.WriteShort(bead.Amount); p.WriteInt(bead.ToMapID); p.WriteHexString("01 00 00 00 00 00 00"); } } return p.GetWrittenBuffer(PacketIds.SendItemList); }
public static byte[] SendHardSkillList() { Packet p = new Packet(200); p.WriteHexString("1D 31 01 00 00"); return p.GetWrittenBuffer(); }
/// <summary> /// Create character /// </summary> /// <param name="ms">State of character making</param> /// <param name="playerid">ID of character that was made</param> /// <returns></returns> public static byte[] SendCreateCharacter(CharCreationState ms, int playerid) { Packet p = new Packet(500); p.WriteByte((byte)ms); if (ms == CharCreationState.Success) p.WriteInt(playerid); else p.WriteHexString("00 00 00 00"); return p.GetWrittenBuffer(PacketIds.SendCreateCharacter); }
public static byte[] SendChannelChange(int something, int something2) { Packet p = new Packet(200); p.WriteByte(0); p.WriteByte(something); p.WriteByte(something2); return p.GetWrittenBuffer(PacketIds.SendChannelChange); }
/// <summary> /// Generates the unit server login information from packet /// </summary> /// <param name="p"></param> /// <returns></returns> public static UnitLogin RecvUnitLogin(Packet p) { p.Skip(2); string account = p.ReadString(); int hash = p.ReadShort(); int map = p.ReadShort(); int channel = p.ReadByte(); p.Skip(6); int characterID = p.ReadInt(); UnitLogin u = new UnitLogin() { Account = account, AccountID = hash, Channel = channel, CharacterID = characterID }; return u; }
public static MovementInfo RecvStopMoving(Packet p) { p.Skip(2); int charid = p.ReadInt(); short from_x = p.ReadShort(); short from_y = p.ReadShort(); byte from_z = p.ReadByte(); MovementInfo mi = new MovementInfo { PacketID = 3, CharacterID = charid, FromX = from_x, FromY = from_y, FromZ = from_z, }; return mi; }
public static StatRequestInfo RecvStatRequest(Packet p) { p.Skip(2); int charid = p.ReadInt(); int mapid = p.ReadInt(); StatRequestInfo sr = new StatRequestInfo { CharacterID = charid, MapID = mapid }; return sr; }
public static MovementInfo RecvStartMoving(Packet p) { p.Skip(2); int charid = p.ReadInt(); short from_x = p.ReadShort(); short from_y = p.ReadShort(); byte from_z = p.ReadByte(); short to_x = p.ReadShort(); short to_y = p.ReadShort(); byte to_z = p.ReadByte(); short direction = p.ReadShort(); MovementInfo mi = new MovementInfo { PacketID = 1, CharacterID = charid, FromX = from_x, FromY = from_y, FromZ = from_z, ToX = to_x, ToY = to_y, ToZ = to_z, Rotation = direction }; return mi; }
public static SpawnRequestInfo RecvSpawnOtherPlayerRequest(Packet p) { p.Skip(2); int charid = p.ReadInt(); int mapid = p.ReadInt(); SpawnRequestInfo sr = new SpawnRequestInfo { CharacterID = charid, MapID = mapid }; return sr; }
public static int RecvSkillListRequest(Packet p) { p.Skip(2); int skill = p.ReadByte(); return skill; }
public static PickItemInfo RecvPickItem(Packet p) { p.Skip(2); int mapid = p.ReadInt(); int itemid = p.ReadInt(); short fromx = p.ReadShort(); short fromy = p.ReadShort(); byte fromz = p.ReadByte(); int mapitemid = p.ReadInt(); short amount = p.ReadShort(); PickItemInfo pi = new PickItemInfo { MapID = mapid, ItemID = itemid, FromX = fromx, FromY = fromy, FromZ = fromz, MapItemID = mapitemid, Amount = amount }; return pi; }
public static byte[] SendBuyItemState(BuyItemState b) { Packet p = new Packet(20); p.WriteByte((byte)b); return p.GetWrittenBuffer(PacketIds.SendBuyItemState); }
/// <summary> /// Send channel to client /// </summary> /// <param name="CI">Channel Info, containing id, name, desc, ip address and port</param> /// <param name="TotalChannels"></param> /// <returns></returns> public static byte[] SendChannel(ChannelInfo CI, int TotalChannels) { Packet p = new Packet(500); p.WriteByte(TotalChannels); // total channels p.WriteByte(CI.ChannelId); // channel id p.WriteString(CI.ChannelName); // name p.WriteString(CI.ChannelDesc); // desc p.WriteHexString("12 F4 01"); p.WriteString(CI.IPAddress); // ip p.WriteShort(CI.Port); // port p.WriteHexString("00 00 00"); return p.GetWrittenBuffer(PacketIds.SendChannelList); }
/// <summary> /// Send character list to client /// </summary> /// <returns></returns> public static byte[] SendCharacterList(Character[] characters) { Packet p = new Packet(200); p.WriteByte(characters.Length); foreach (Character c in characters) { p.WriteInt(c.MapId); p.WriteInt(c.CharacterId); p.WriteString(c.Name); p.WriteByte(c.Class); p.WriteShort(c.Level); p.WriteInt(c.CurrentHp); p.WriteInt(c.MaxHp); p.WriteInt(c.MaxMana); p.WriteShort(c.Strength); p.WriteShort(c.Stamina); p.WriteShort(c.Dexterity); p.WriteShort(c.Energy); p.WriteHexString("00 00 00 00 02 00 00 00 00 00 00 00"); // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00"); foreach (Equipment e in c.GetVisuals()) { p.WriteShort(e.VisualID); p.WriteByte(e.Plus); p.WriteByte(e.Slvl); } p.WriteHexString("01 00"); // ending bytes } return p.GetWrittenBuffer(PacketIds.SendCharacterList); }
public static byte[] SendChannelStatus() { Packet p = new Packet(200); p.WriteHexString("02 00 01 01 01 32 00 01 02 01 08 00"); return p.GetWrittenBuffer(PacketIds.SendChannelStatus); }
public static byte[] SendChatMessage(Character ch, ChatMessageInfo cmi) { Packet p = new Packet(200); p.WriteInt(ch.CharacterId); p.WriteByte((byte)cmi.Type); // chat type probably p.WriteString(cmi.Message); p.WriteString(ch.Name); if (cmi.Type == ChatType.Whisper) { p.WriteInt(cmi.TargetID); p.WriteString(cmi.TargetName); } return p.GetWrittenBuffer(PacketIds.SendChatMessage); }
public static ChannelChangeInfo RecvChannelChange(Packet p) { p.Skip(2); byte something1 = p.ReadByte(); byte something2 = p.ReadByte(); ChannelChangeInfo cci = new ChannelChangeInfo { Something = something1, Something2 = something2 }; return cci; }
public static int RecvWalkToPortal(Packet p) { p.Skip(2); int mapid = p.ReadInt(); return mapid; }
public static byte[] SendCommand(Character ch, CommandInfo ci) { Packet p = new Packet(200); p.WriteInt(ch.CharacterId); p.WriteByte(ci.Type); p.WriteByte(ci.Action); p.WriteByte(ci.Something); p.WriteByte(ci.Something2); return p.GetWrittenBuffer(PacketIds.SendCommand); }
public static byte[] SendAcceptImbueItem(ImbueState i) { Packet p = new Packet(5); p.WriteByte((byte)i); return p.GetWrittenBuffer(PacketIds.SendAcceptImbueItem); }
public static byte[] SendGuildList() { Packet p = new Packet(200); p.WriteHexString("35 3B 01 00 00"); return p.GetWrittenBuffer(); }
public static byte[] SendAddStat(int error, AddStatInfo asi, int pointsleft, int statamount) { Packet p = new Packet(200); p.WriteHexString("1E 35 07 00"); p.WriteByte(error); p.WriteByte(asi.Stat); p.WriteByte(asi.Amount); p.WriteShort(pointsleft); p.WriteShort(statamount); return p.GetWrittenBuffer(); }
public static byte[] SendImbuedItem(BaseItem i) { Packet p = new Packet(500); p.WriteByte(i.Bag); p.WriteByte(i.Slot); p.WriteInt(i.ItemID); p.WriteShort(i.ReferenceID); p.WriteByte(i.bType); p.WriteByte(i.bKind); p.WriteShort(i.VisualID); p.WriteInt(i.Price); p.WriteHexString("00 00"); Equipment e = i as Equipment; p.WriteByte(e.RequiredClass); p.WriteShort(e.Amount); p.WriteShort(e.RequiredLevel); p.WriteShort(e.RequiredDexterity); p.WriteShort(e.RequiredStrength); p.WriteShort(e.RequiredStamina); p.WriteShort(e.RequiredEnergy); p.WriteByte(e.MaxImbueTries); p.WriteShort(e.Durability); p.WriteShort(e.MaxDurability); p.WriteShort(e.Damage); p.WriteShort(e.Defence); p.WriteShort(e.AttackRating); p.WriteShort(e.AttackSpeed); p.WriteShort(e.AttackRange); p.WriteShort(e.IncMaxLife); p.WriteShort(e.IncMaxMana); p.WriteShort(e.IncLifeRegen); p.WriteShort(e.IncManaRegen); p.WriteShort(e.Critical); p.WriteByte(e.Plus); p.WriteByte(e.Slvl); p.WriteHexString("00"); // unknown p.WriteByte(e.ImbueTries); p.WriteHexString("00"); // unknown p.WriteShort(e.DragonSuccessImbueTries); p.WriteByte(e.DiscountRepairFee); p.WriteShort(e.TotalDragonImbueTries); p.WriteShort(e.DragonDamage); p.WriteShort(e.DragonDefence); p.WriteShort(e.DragonAttackRating); p.WriteShort(e.DragonLife); p.WriteByte(e.MappedData); if (!(e is Ring) && !(e is Necklace) && !(e is Cape)) p.WriteByte(e.ForceSlot); p.WriteHexString("00 00"); // unknown if (e is Cape) { Cape c = e as Cape; p.WriteHexString("00 00"); // required guild position p.WriteHexString("00 00 00 00 00 00 00"); p.WriteHexString("01 00"); // decrease times of durability p.WriteByte(c.PolishImbueTries); // polish imbue tries p.WriteShort(c.MaxPolishImbueTries); // polish max tries p.WriteShort(c.VigiStat1); // stat1 p.WriteShort(c.VigiStat2); // stat2 p.WriteShort(c.VigiStat3); // stat3 p.WriteShort(c.VigiStat4); // stat4 p.WriteHexString("00 00"); // stat5 p.WriteShort(c.VigiStatAdd1); // stat1 increase p.WriteShort(c.VigiStatAdd2); // stat2 increase p.WriteShort(c.VigiStatAdd3); // stat3 increase p.WriteShort(c.VigiStatAdd4); // stat4 increase p.WriteHexString("00 00"); // stat5 increase p.WriteHexString("00 00"); // unknown } if (!(e is Ring) && !(e is Necklace) && !(e is Cape)) { p.WriteByte(e.RebirthHole); p.WriteByte(e.RebirthHoleItem); p.WriteShort(e.RebirthHoleStat); } return p.GetWrittenBuffer(PacketIds.SendImbuedItem); }
public static byte[] SendBagIsFull() { Packet p = new Packet(200); p.WriteHexString("02 33 01 00 01"); return p.GetWrittenBuffer(); }