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); }
public static void Action(Client pClient, Packet pPacket) { int firstUnknown; short secondUnknown; if (!pPacket.ReadInt(out firstUnknown) || !pPacket.ReadShort(out secondUnknown)) { pClient.Disconnect(); return; } Packet packet = new Packet(EOpcode.SMSG_NPC_ACTION); byte thirdUnknown; if (!pPacket.ReadByte(out thirdUnknown)) { packet.WriteInt(firstUnknown); packet.WriteShort(secondUnknown); } else packet.WriteBytes(pPacket.InnerBuffer, pPacket.Cursor, pPacket.Remaining); pClient.SendPacket(packet); }
public static void PlayerCreate(Client pClient, Packet pPacket) { string name; int eyesIdentifier; int hairIdentifier; int hairColor; int skin; int shirtIdentifier; int pantsIdentifier; int shoesIdentifier; int weaponIdentifier; byte gender; if (!pPacket.ReadString(out name) || !pPacket.ReadInt(out eyesIdentifier) || !pPacket.ReadInt(out hairIdentifier) || !pPacket.ReadInt(out hairColor) || !pPacket.ReadInt(out skin) || !pPacket.ReadInt(out shirtIdentifier) || !pPacket.ReadInt(out pantsIdentifier) || !pPacket.ReadInt(out shoesIdentifier) || !pPacket.ReadInt(out weaponIdentifier) || !pPacket.ReadByte(out gender)) { pClient.Disconnect(); return; } bool unusable = name.Length < 4 || name.Length > 16 || (long)Database.Scalar("SELECT COUNT(*) FROM player WHERE name=@name", new MySqlParameter("@name", name)) != 0; if (unusable) { SendPlayerNameCheck(pClient, name, true); return; } hairIdentifier += hairColor; int identifier = Database.InsertAndReturnIdentifier("INSERT INTO player(account_identifier,name,gender,skin,eyes_identifier,hair_identifier) " + "VALUES(@account_identifier,@name,@gender,@skin,@eyes_identifier,@hair_identifier)", new MySqlParameter("@account_identifier", pClient.Account.Identifier), new MySqlParameter("@name", name), new MySqlParameter("@gender", gender), new MySqlParameter("@skin", skin), new MySqlParameter("@eyes_identifier", eyesIdentifier), new MySqlParameter("@hair_identifier", hairIdentifier)); Database.Execute("INSERT INTO player_keymap(player_identifier) VALUES(@player_identifier)", new MySqlParameter("@player_identifier", identifier)); Database.Execute("INSERT INTO player_item(player_identifier,inventory_type,inventory_slot,item_identifier,weapon_defense) " + "VALUES(@player_identifier,@inventory_type,-5,@item_identifier,3)", new MySqlParameter("@player_identifier", identifier), new MySqlParameter("@inventory_type", EInventoryType.Equipment), new MySqlParameter("@item_identifier", shirtIdentifier)); Database.Execute("INSERT INTO player_item(player_identifier,inventory_type,inventory_slot,item_identifier,weapon_defense) " + "VALUES(@player_identifier,@inventory_type,-6,@item_identifier,2)", new MySqlParameter("@player_identifier", identifier), new MySqlParameter("@inventory_type", EInventoryType.Equipment), new MySqlParameter("@item_identifier", pantsIdentifier)); Database.Execute("INSERT INTO player_item(player_identifier,inventory_type,inventory_slot,item_identifier,unused_scroll_slots,weapon_defense) " + "VALUES(@player_identifier,@inventory_type,-7,@item_identifier,5,3)", new MySqlParameter("@player_identifier", identifier), new MySqlParameter("@inventory_type", EInventoryType.Equipment), new MySqlParameter("@item_identifier", shoesIdentifier)); Database.Execute("INSERT INTO player_item(player_identifier,inventory_type,inventory_slot,item_identifier,weapon_attack) " + "VALUES(@player_identifier,@inventory_type,-11,@item_identifier,17)", new MySqlParameter("@player_identifier", identifier), new MySqlParameter("@inventory_type", EInventoryType.Equipment), new MySqlParameter("@item_identifier", weaponIdentifier)); Database.Execute("INSERT INTO player_item(player_identifier,inventory_type,inventory_slot,item_identifier) VALUES(@player_identifier,@inventory_type,1,4161001)", new MySqlParameter("@player_identifier", identifier), new MySqlParameter("@inventory_type", EInventoryType.Etc)); using (DatabaseQuery query = Database.Query("SELECT * FROM player WHERE identifier=@identifier", new MySqlParameter("@identifier", identifier))) { query.NextRow(); SendPlayerCreate(pClient, query); } }
internal bool ReadMovement(IMoveable pMoveable, Packet pPacket) { byte movements; Coordinates position = null; ushort foothold = 0; byte stance = 0; if (!pPacket.ReadByte(out movements)) return false; while (movements-- > 0) { byte type; if (!pPacket.ReadByte(out type)) return false; switch (type) { case 0: case 5: if (!pPacket.ReadCoordinates(out position) || !pPacket.ReadSkip(4) || !pPacket.ReadUShort(out foothold) || !pPacket.ReadByte(out stance) || !pPacket.ReadSkip(2)) return false; break; case 1: case 2: case 6: case 13: if (!pPacket.ReadCoordinates(out position) || !pPacket.ReadByte(out stance) || !pPacket.ReadUShort(out foothold)) return false; break; case 3: case 4: case 7: case 8: case 9: if (!pPacket.ReadCoordinates(out position) || !pPacket.ReadSkip(4) || !pPacket.ReadByte(out stance)) return false; break; case 10: if (!pPacket.ReadSkip(1)) return false; break; case 11: if (!pPacket.ReadCoordinates(out position) || !pPacket.ReadUShort(out foothold) || !pPacket.ReadByte(out stance) || !pPacket.ReadSkip(2)) return false; break; case 12: case 16: if (!pPacket.ReadSkip(7)) return false; break; case 14: if (!pPacket.ReadSkip(9)) return false; break; case 15: if (!pPacket.ReadCoordinates(out position) || !pPacket.ReadSkip(6) || !pPacket.ReadUShort(out foothold) || !pPacket.ReadByte(out stance) || !pPacket.ReadSkip(2)) return false; break; case 17: if (!pPacket.ReadCoordinates(out position) || !pPacket.ReadUShort(out foothold) || !pPacket.ReadByte(out stance) || !pPacket.ReadSkip(6)) return false; break; default: return false; } } if (position != null) { pMoveable.Position = position; pMoveable.Foothold = foothold; pMoveable.Stance = stance; } return true; }