public static void WriteLook(WorldCharacter wchar, Packet packet) { packet.WriteByte(Convert.ToByte(0x00001 | (wchar.Character.Job << 2) | (Convert.ToByte(wchar.Character.Male)) << 7)); packet.WriteByte(wchar.Character.Hair); packet.WriteByte(wchar.Character.HairColor); packet.WriteByte(wchar.Character.Face); }
public static void SendAttackAnimation(MapObject from, ushort objectID, ushort attackspeed, byte stance) { using (var packet = new Packet(SH9Type.AttackAnimation)) { packet.WriteUShort(from.MapObjectID); packet.WriteUShort(objectID); packet.WriteByte(stance); packet.WriteUShort(attackspeed); packet.WriteByte(4); packet.WriteByte(100); from.MapSector.Broadcast(packet); } }
public static Packet CreateWorldMessage(WorldMessageTypes pType, string pMessage) { var packet = new Packet(SH25Type.WorldMessage); packet.WriteByte((byte)pType); packet.WriteStringLen(pMessage, true); return packet; }
public static Packet ShowDrops(List<Drop> drops) { Packet packet = new Packet(SH7Type.ShowDrops); packet.WriteByte((byte)drops.Count); drops.ForEach(d => d.Write(packet)); return packet; }
public static Packet Animation(ZoneCharacter character, byte id) { Packet packet = new Packet(SH8Type.Emote); packet.WriteUShort(character.MapObjectID); packet.WriteByte(id); return packet; }
public static void SendSkillLearnt(ZoneCharacter character, ushort skillid) { using (var packet = new Packet(SH18Type.LearnSkill)) { packet.WriteUShort(skillid); packet.WriteByte(0); //unk character.Client.SendPacket(packet); } }
public static void SendServerTime(WorldClient client) { using (var packet = new Packet(SH2Type.ServerTime)) { packet.WriteByte(Convert.ToByte(DateTime.Now.Hour)); packet.WriteUShort(Convert.ToUInt16(DateTime.Now.Minute)); client.SendPacket(packet); } }
public void Write(Packet packet) { packet.WriteUShort(ID); packet.WriteUShort(Item.ItemID); packet.WriteInt(Position.X); packet.WriteInt(Position.Y); packet.WriteUShort((DroppedBy != null) ? DroppedBy.MapObjectID : (ushort)0xffff); packet.WriteByte(CanTake ? (byte)0x08 : (byte)0x00); }
public static void SendQuestion(ZoneCharacter character, Question question, ushort range) { using (var packet = new Packet(SH15Type.Question)) { packet.WriteString(question.Text, 129); packet.WriteUShort(character.MapObjectID); // Obj id packet.WriteInt(character.Position.X); packet.WriteInt(character.Position.Y); packet.WriteUShort(range); // Distance how far your allowed to run when the question window is closed by Client packet.WriteByte((byte)question.Answers.Count); for (byte i = 0; i < question.Answers.Count; ++i) { packet.WriteByte(i); packet.WriteString(question.Answers[i], 32); } character.Client.SendPacket(packet); } }
public static Packet Equip(ZoneCharacter character, Equip equip) { //B2 00 - AB 38 - 07 - 0D 00 04 Packet packet = new Packet(SH7Type.ShowEquip); packet.WriteUShort(character.MapObjectID); packet.WriteUShort(equip.ItemID); packet.WriteByte(equip.Upgrades); packet.Fill(3, 0xff); return packet; }
public void Write(Packet packet) { packet.WriteUShort(this.MapObjectID); packet.WriteByte(2); //always 2 (type i bet shown / transparent?) packet.WriteUShort(ID); packet.WriteInt(this.Position.X); packet.WriteInt(this.Position.Y); packet.WriteByte(this.Rotation); //TODO: rotation for NPC (from txt official files?) if (Gate != null) { packet.WriteByte(1); packet.WriteString(Gate.MapClient, 12); packet.Fill(41, 0); } else { packet.Fill(54, 0); //find out later } }
public static Packet SpawnMultiPlayer(List<ZoneCharacter> characters, ZoneCharacter exclude = null) { Packet packet = new Packet(SH7Type.SpawnMultiPlayer); packet.WriteByte(exclude == null ? (byte)characters.Count : (byte)(characters.Count - 1)); foreach (var character in characters) { if (character == exclude) continue; character.WriteCharacterDisplay(packet); } return packet; }
public static void SendActiveSkillList(ZoneCharacter character) { using (var packet = new Packet(SH4Type.CharacterActiveSkillList)) { var list = character.SkillsActive.Values; packet.WriteByte(0); packet.WriteInt(character.ID); packet.WriteUShort((ushort)list.Count); // Skill count (max 300) foreach (var skill in list) { skill.Write(packet); } character.Client.SendPacket(packet); } }
public void WritePacket(Packet pPacket) { pPacket.WriteUShort(ItemID); if (this.Type != HouseType.Resting) { pPacket.Fill(10, 0xFF); // Unknown pPacket.WriteString(this.Name, 30); } else { pPacket.WriteHexAsBytes("BE 02 FA 01 F8 01"); pPacket.Fill(34, 0xFF); // No idea!? } pPacket.WriteByte(0xFF); }
public static Packet MultiObjectList(List<MapObject> objs, int start, int end) { Packet packet = new Packet(SH7Type.SpawnMultiObject); packet.WriteByte((byte)(end - start)); Log.WriteLine(LogLevel.Debug, "Sending {0} objects ({1} - {2})", end - start, start, end); for (int i = start; i < end; i++) { var obj = objs[i]; if (obj is NPC) { ((NPC)obj).Write(packet); } else if (obj is Mob) // Just to be sure { ((Mob)obj).Write(packet); } else { Log.WriteLine(LogLevel.Warn, "What the F is {0} doing here lol", obj.ToString()); } } return packet; }
public static void SendAttackDamage(MapObject from, ushort objectID, ushort damage, bool crit, uint hpleft, ushort counter) { using (var packet = new Packet(SH9Type.AttackDamage)) { packet.WriteUShort(from.MapObjectID); packet.WriteUShort(objectID); packet.WriteBool(crit); packet.WriteUShort(damage); packet.WriteUInt(hpleft); packet.WriteUShort(counter); packet.WriteByte(4); packet.WriteByte(100); from.MapSector.Broadcast(packet); } }
public void WriteEquipStats(Packet packet) { byte StatCount = 0; if (Str > 0) StatCount++; if (End > 0) StatCount++; if (Dex > 0) StatCount++; if (Spr > 0) StatCount++; if (Int > 0) StatCount++; packet.WriteUShort(ItemID); switch (this.SlotType) { case ItemSlot.Helm: case ItemSlot.Armor: case ItemSlot.Pants: case ItemSlot.Boots: // case ItemSlot.Bow: // Shield = same case ItemSlot.Weapon2: case ItemSlot.Weapon: packet.WriteByte(this.Upgrades); // Refinement packet.WriteByte(0); packet.WriteShort(0); // Or int? packet.WriteShort(0); if (this.SlotType == ItemSlot.Weapon || (this.SlotType == ItemSlot.Weapon2 && Info.TwoHand)) { packet.WriteByte(0); // Licence data packet.WriteUShort(0xFFFF); // Nr.1 - Mob ID packet.WriteUInt(0); // Nr.1 - Kill count packet.WriteUShort(0xFFFF); // Nr.2 - Mob ID packet.WriteUInt(0); // Nr.2 - Kill count packet.WriteUShort(0xFFFF); // Nr.3 - Mob ID packet.WriteUInt(0); // Nr.3 - Kill count packet.WriteUShort(0xFFFF); // UNK packet.WriteString("", 16); // First licence adder name } packet.WriteByte(0); packet.WriteUInt(GetExpiringTime()); // Expiring time (1992027391 - never expires) //packet.WriteShort(0); break; case ItemSlot.Pet: packet.WriteByte(this.Upgrades); // Pet Refinement Lol packet.Fill(2, 0); // UNK packet.WriteUInt(GetExpiringTime()); // Expiring time (1992027391 - never expires) packet.WriteUInt(0); // Time? (1992027391 - never expires) break; case ItemSlot.Earings: case ItemSlot.Necklace: case ItemSlot.Ring: packet.WriteUInt(GetExpiringTime()); // Expiring time (1992027391 - never expires) packet.WriteUInt(0); // Time? (1992027391 - never expires) packet.WriteByte(this.Upgrades); // Refinement // Stats added while refining packet.WriteUShort(0); // it may be byte + byte too (some kind of counter when item downgrades) packet.WriteUShort(0); // STR packet.WriteUShort(0); // END packet.WriteUShort(0); // DEX packet.WriteUShort(0); // INT packet.WriteUShort(0); // SPR break; case ItemSlot.CostumeWeapon: case ItemSlot.CostumeShield: packet.WriteUInt(25000); // Skin Durability break; default: packet.WriteUInt(GetExpiringTime()); // Expiring time (1992027391 - never expires) packet.WriteUInt(0); // Time? (1992027391 - never expires) break; } // Random stats data (Not those what were added in refinement) switch (this.SlotType) { // Stat count (StatCount << 1 | Visible(0 or 1 are stats shown or not)) case ItemSlot.Earings: packet.WriteByte((byte)(StatCount << 1 | 1)); break; case ItemSlot.Necklace: case ItemSlot.Ring: packet.WriteByte((byte)(StatCount << 1 | 1)); break; case ItemSlot.Helm: case ItemSlot.Armor: case ItemSlot.Pants: case ItemSlot.Boots: case ItemSlot.Weapon2: case ItemSlot.Weapon: packet.WriteByte((byte)(StatCount << 1 | 1)); break; case ItemSlot.Pet: // Yes!! Its possible to give stats to pet also (It overrides default one(s)). packet.WriteByte((byte)(StatCount << 1 | 1)); break; } // foreach stat //pPacket.WriteByte(type); // Stat type ( 0 = STR, 1 = END, 2 = DEX, 3 = INT, 4 = SPR ) //pPacket.WriteUShort(amount); // Amount // end foreach if (Str > 0) { packet.WriteByte(0); packet.WriteUShort(Str); } if (End > 0) { packet.WriteByte(1); packet.WriteUShort(End); } if (Dex > 0) { packet.WriteByte(2); packet.WriteUShort(Dex); } if (Spr > 0) { packet.WriteByte(3); packet.WriteUShort(Spr); } if (Int > 0) { packet.WriteByte(4); packet.WriteUShort(Int); } }
public static void SendSkill(MapObject user, ushort animid, List<SkillVictim> victims) { using (var packet = new Packet(SH9Type.SkillAnimationTarget)) { packet.WriteUShort(animid); packet.WriteUShort(user.MapObjectID); packet.WriteByte((byte)(victims.Count > 255 ? 255 : victims.Count)); for (byte i = 0; i < victims.Count && i != 255; i++) { var victim = victims[i]; packet.WriteUShort(victim.MapObjectID); packet.WriteByte(victim.Stance1); packet.WriteByte(victim.Stance2); packet.WriteUInt(victim.Damage); packet.WriteUInt(victim.HPLeft); packet.WriteUShort(victim.HPCounter); } user.MapSector.Broadcast(packet); } }
public static void SendSetUsablePoint(ZoneClient client, byte stat) { using (var packet = new Packet(SH4Type.SetPointOnStat)) { packet.WriteByte(stat); // amount client.SendPacket(packet); } }
public static void SendLevelUPData(ZoneCharacter who, ushort mobid = 0xFFFF) { using (var packet = new Packet(SH9Type.LevelUP)) { packet.WriteByte(who.Level); packet.WriteUShort(mobid); who.WriteDetailedInfoExtra(packet, true); who.Client.SendPacket(packet); } }
public static void SendSkill(MapObject user, ushort animid, ushort victimid, uint damage, uint newhp, ushort counter, byte special1 = 0x10, byte special2 = 0x00) { // 9 82 | [E5 3F] [8A 27] [01] [8A 27] [10 00] [09 00 00 00] [5E 00 00 00] [A7 4C] // 9 82 | [9A 35] [8A 27] [01] [C2 05] [10 00] [0A 00 00 00] [1D 01 00 00] [73 37] // 9 82 | [43 3C] [42 15] [01] [AC 4C] [01 01] [7A 02 00 00] [00 00 00 00] [35 09] // 9 82 | [0E 39] [42 15] [01] [00 4A] [21 01] [1C 03 00 00] [00 00 00 00] [8C 0E] using (var packet = new Packet(SH9Type.SkillAnimationTarget)) { packet.WriteUShort(animid); packet.WriteUShort(user.MapObjectID); packet.WriteBool(true); packet.WriteUShort(victimid); packet.WriteByte(special1); packet.WriteByte(special2); packet.WriteUInt(damage); packet.WriteUInt(newhp); packet.WriteUShort(counter); user.MapSector.Broadcast(packet); } }
public static Packet Unequip(ZoneCharacter character, Equip equip) { Packet packet = new Packet(SH7Type.ShowUnequip); packet.WriteUShort(character.MapObjectID); packet.WriteByte((byte)equip.Info.Slot); return packet; }
//this is used by the smaller writer (e.g. additem, unequip, equip) public void WriteSmallInfo(Packet packet) { packet.WriteUShort(this.ItemID); switch (SlotType) { case ItemSlot.Helm: case ItemSlot.Armor: case ItemSlot.Pants: case ItemSlot.Boots: case ItemSlot.Weapon2: case ItemSlot.Weapon: packet.WriteByte(Upgrades); packet.Fill(6, 0); packet.WriteUShort(ushort.MaxValue); //unk packet.WriteUInt(GetExpiringTime()); packet.WriteUShort(ushort.MaxValue); break; default: packet.WriteUInt(GetExpiringTime()); packet.WriteInt(0); //unk break; } }
private static void SendCharOKResponse(WorldClient client, WorldCharacter character) { using (var packet = new Packet(SH5Type.CharCreationOK)) { packet.WriteByte(1); PacketHelper.WriteBasicCharInfo(character, packet); client.SendPacket(packet); } }
private static void WorldList(LoginClient pClient, bool pPing) { using (var pack = new Packet(pPing ? SH3Type.WorldistResend : SH3Type.WorldlistNew)) { pack.WriteByte((byte)WorldManager.Instance.WorldCount); foreach (var world in WorldManager.Instance.Worlds.Values) { pack.WriteByte(world.ID); pack.WriteString(world.Name, 16); pack.WriteByte((byte)world.Status); } pClient.SendPacket(pack); } }
private static void SendWorldServerIP(LoginClient pClient, WorldConnection wc, string hash) { using (var pack = new Packet(SH3Type.WorldServerIP)) { pack.WriteByte((byte)wc.Status); string ip = pClient.Host == "127.0.0.1" ? "127.0.0.1" : wc.IP; pack.WriteString(wc.IP, 16); pack.WriteUShort(wc.Port); pack.WriteString(hash, 64); pClient.SendPacket(pack); } }
private static void SendCharacterList(WorldClient client) { if (!client.LoadCharacters()) { SendError(client, ServerError.DATABASE_ERROR); return; } using (var packet = new Packet(SH3Type.CharacterList)) { packet.WriteUShort(client.RandomID); packet.WriteByte((byte)client.Characters.Count); foreach (WorldCharacter ch in client.Characters.Values) { PacketHelper.WriteBasicCharInfo(ch, packet); } client.SendPacket(packet); } }
public static void SendUsablePoints(ZoneClient client) { using (var packet = new Packet(SH4Type.CharacterPoints)) { packet.WriteByte(client.Character.character.UsablePoints); client.SendPacket(packet); } }
private static void SendCharDeleteOKResponse(WorldClient client, byte slot) { using (var packet = new Packet(SH5Type.CharDeleteOK)) { packet.WriteByte(slot); client.SendPacket(packet); } }
public override void WriteInfo(Packet packet) { byte StatCount = 0; if (Str > 0) StatCount++; if (End > 0) StatCount++; if (Dex > 0) StatCount++; if (Spr > 0) StatCount++; if (Int > 0) StatCount++; byte length = CalculateDataLen(); length += (byte)(StatCount * 3); // Stat data length packet.WriteByte(length); packet.WriteByte((byte)Math.Abs(this.Slot)); packet.WriteByte(IsEquipped ? (byte)0x20 : (byte)0x24); WriteEquipStats(packet); }