public static void Chat(Client pClient, Packet pPacket) { string message; bool bubble; if (!pPacket.ReadString(out message) || !pPacket.ReadBool(out bubble)) { pClient.Disconnect(); return; } Packet packet = new Packet(EOpcode.SMSG_PLAYER_CHAT); packet.WriteInt(pClient.Player.Identifier); packet.WriteBool(pClient.Account.Level > 0); packet.WriteString(message); packet.WriteBool(bubble); pClient.Player.Map.SendPacketToAll(packet); }
public static void Action(Client pClient, Packet pPacket) { int uniqueIdentifier; short moveIdentifier; bool isUsingAbility; byte usingAbility; Coordinates projectileTarget; if (!pPacket.ReadInt(out uniqueIdentifier) || !pPacket.ReadShort(out moveIdentifier) || !pPacket.ReadBool(out isUsingAbility) || !pPacket.ReadByte(out usingAbility) || !pPacket.ReadCoordinates(out projectileTarget) || !pPacket.ReadSkip(5)) { pClient.Disconnect(); return; } Mob mob = pClient.Player.Map.GetMob(uniqueIdentifier); if (mob == null || mob.Controller != pClient.Player) return; int rewindOffset = pPacket.Cursor; Coordinates unknownPosition; if (!pPacket.ReadCoordinates(out unknownPosition) || !pClient.Player.Map.ReadMovement(mob, pPacket)) { pClient.Disconnect(); return; } Packet packet = new Packet(EOpcode.SMSG_MOB_ACTION_CONFIRM); packet.WriteInt(uniqueIdentifier); packet.WriteShort(moveIdentifier); packet.WriteBool(isUsingAbility); packet.WriteUShort((ushort)mob.Mana); packet.WriteByte(0x00); // Ability Identifier packet.WriteByte(0x00); // Ability Level pClient.SendPacket(packet); pPacket.Rewind(rewindOffset); packet = new Packet(EOpcode.SMSG_MOB_ACTION); packet.WriteInt(uniqueIdentifier); packet.WriteBool(isUsingAbility); packet.WriteByte(usingAbility); packet.WriteCoordinates(projectileTarget); packet.WriteBytes(pPacket.InnerBuffer, pPacket.Cursor, pPacket.Remaining); pClient.Player.Map.SendPacketToAllExcept(packet, pClient.Player); pClient.Player.Map.UpdateMobControllers(true); }
internal void WriteInitial(Packet pPacket) { pPacket.WriteByte((byte)mMacros.Length); Array.ForEach(mMacros, m => { if (m != null) { pPacket.WriteString(m.Name); pPacket.WriteBool(m.Shout); pPacket.WriteInt(m.FirstSkillIdentifier); pPacket.WriteInt(m.SecondSkillIdentifier); pPacket.WriteInt(m.ThirdSkillIdentifier); } else { pPacket.WriteString(""); pPacket.WriteBool(false); pPacket.WriteInt(0); pPacket.WriteInt(0); pPacket.WriteInt(0); } }); }
internal void SendControl(bool pTakeControl) { if (mController != null) { Packet packet = new Packet(EOpcode.SMSG_MOB_CONTROL); packet.WriteBool(pTakeControl); packet.WriteInt(UniqueIdentifier); if (pTakeControl) { packet.WriteByte(0x05); packet.WriteInt(mData.MobIdentifier); WriteStatus(packet); packet.WriteCoordinates(mPosition); packet.WriteByte((byte)(0x02 | (FacingLeft ? 0x01 : 0x00))); packet.WriteUShort(mFoothold); packet.WriteUShort(mData.Foothold); packet.WriteBool(false); packet.WriteByte(0xFF); packet.WriteInt(0); } mController.SendPacket(packet); } }
private static void WritePlayer(Packet pPacket, DatabaseQuery pQuery) { pPacket.WriteInt((int)pQuery["identifier"]); pPacket.WritePaddedString((string)pQuery["name"], 13); pPacket.WriteByte((byte)pQuery["gender"]); pPacket.WriteByte((byte)pQuery["skin"]); pPacket.WriteInt((int)pQuery["eyes_identifier"]); pPacket.WriteInt((int)pQuery["hair_identifier"]); pPacket.WriteSkip(24); pPacket.WriteByte((byte)pQuery["level"]); pPacket.WriteUShort((ushort)pQuery["job"]); pPacket.WriteUShort((ushort)pQuery["strength"]); pPacket.WriteUShort((ushort)pQuery["dexterity"]); pPacket.WriteUShort((ushort)pQuery["intellect"]); pPacket.WriteUShort((ushort)pQuery["luck"]); pPacket.WriteUShort((ushort)pQuery["health"]); pPacket.WriteUShort((ushort)pQuery["max_health"]); pPacket.WriteUShort((ushort)pQuery["mana"]); pPacket.WriteUShort((ushort)pQuery["max_mana"]); pPacket.WriteUShort((ushort)pQuery["ability_points"]); pPacket.WriteUShort((ushort)pQuery["skill_points"]); pPacket.WriteInt((int)pQuery["experience"]); pPacket.WriteUShort((ushort)pQuery["fame"]); pPacket.WriteSkip(4); pPacket.WriteInt((int)pQuery["map_identifier"]); pPacket.WriteByte((byte)pQuery["map_spawn"]); pPacket.WriteSkip(4); pPacket.WriteByte((byte)pQuery["gender"]); pPacket.WriteByte((byte)pQuery["skin"]); pPacket.WriteInt((int)pQuery["eyes_identifier"]); pPacket.WriteBool(true); pPacket.WriteInt((int)pQuery["hair_identifier"]); SortedDictionary<byte, Doublet<int, int>> equipment = new SortedDictionary<byte, Doublet<int, int>>(); using (DatabaseQuery queryEquipment = Database.Query("SELECT inventory_slot,item_identifier FROM player_item WHERE player_identifier=@player_identifier AND inventory_type=0 AND inventory_slot<0", new MySqlParameter("@player_identifier", (int)pQuery["identifier"]))) { while (queryEquipment.NextRow()) { short slot = (short)(-((short)queryEquipment["inventory_slot"])); if (slot > 100) slot -= 100; Doublet<int, int> pair = equipment.GetOrDefault((byte)slot, null); if (pair == null) { pair = new Doublet<int, int>((int)queryEquipment["item_identifier"], 0); equipment.Add((byte)slot, pair); } else if ((short)queryEquipment["inventory_slot"] < -100) { pair.Second = pair.First; pair.First = (int)queryEquipment["item_identifier"]; } else pair.Second = (int)queryEquipment["item_identifier"]; } } foreach (KeyValuePair<byte, Doublet<int, int>> pair in equipment) { pPacket.WriteByte(pair.Key); if (pair.Key == 11 && pair.Value.Second > 0) pPacket.WriteInt(pair.Value.Second); else pPacket.WriteInt(pair.Value.First); } pPacket.WriteByte(0xFF); foreach (KeyValuePair<byte, Doublet<int, int>> pair in equipment) { if (pair.Key != 11 && pair.Value.Second > 0) { pPacket.WriteByte(pair.Key); pPacket.WriteInt(pair.Value.Second); } } pPacket.WriteByte(0xFF); Doublet<int, int> cashWeapon = equipment.GetOrDefault((byte)11, null); pPacket.WriteInt(cashWeapon == null ? 0 : cashWeapon.First); pPacket.WriteSkip(12); pPacket.WriteBool(false); }
private static void SendPlayerNameCheck(Client pClient, string pName, bool pUnusable) { Packet packet = new Packet(EOpcode.SMSG_PLAYER_NAME_CHECK); packet.WriteString(pName); packet.WriteBool(pUnusable); pClient.SendPacket(packet); }
internal void SendNPCDetails(Player pPlayer) { int index = 0; foreach (NPC npc in mNPCs) { Packet packet = new Packet(EOpcode.SMSG_NPC_DETAILS); packet.WriteInt(index + 0x64); packet.WriteInt(npc.Data.NPCIdentifier); packet.WriteShort(npc.Data.X); packet.WriteShort(npc.Data.Y); packet.WriteBool((npc.Data.Flags & MapData.MapNPCData.EMapNPCFlags.FacesLeft) != MapData.MapNPCData.EMapNPCFlags.None); packet.WriteUShort(npc.Data.Foothold); packet.WriteShort(npc.Data.MinClickX); packet.WriteShort(npc.Data.MaxClickX); packet.WriteBool(true); pPlayer.SendPacket(packet); packet = new Packet(EOpcode.SMSG_NPC_CONTROL); packet.WriteBool(true); packet.WriteInt(index + 0x64); packet.WriteInt(npc.Data.NPCIdentifier); packet.WriteShort(npc.Data.X); packet.WriteShort(npc.Data.Y); packet.WriteBool((npc.Data.Flags & MapData.MapNPCData.EMapNPCFlags.FacesLeft) != MapData.MapNPCData.EMapNPCFlags.None); packet.WriteUShort(npc.Data.Foothold); packet.WriteShort(npc.Data.MinClickX); packet.WriteShort(npc.Data.MaxClickX); packet.WriteBool(true); pPlayer.SendPacket(packet); ++index; } }
internal void WriteAppearance(Packet pPacket) { pPacket.WriteByte(mGender); pPacket.WriteByte(mSkin); pPacket.WriteInt(mEyesIdentifier); pPacket.WriteBool(true); pPacket.WriteInt(mHairIdentifier); mItems.WriteEquipment(pPacket); pPacket.WriteUInt(0); pPacket.WriteUInt(0); pPacket.WriteUInt(0); }