internal void WriteUpdate(Packet pPacket, EBuddyUpdateType pType) { pPacket.WriteByte((byte)pType); pPacket.WriteByte((byte)mBuddies.Count); foreach (PlayerBuddy buddy in mBuddies) buddy.WriteGeneral(pPacket); foreach (PlayerBuddy buddy in mBuddies) pPacket.WriteUInt(0); }
internal void WriteInitial(Packet pPacket) { pPacket.WriteUInt(0); pPacket.WriteByte(0x00); pPacket.WriteUShort((ushort)mCards.Count); foreach (PlayerCard card in mCards.Values) { pPacket.WriteUShort(ItemData.ReduceCardIdentifier(card.CardIdentifier)); pPacket.WriteByte(card.Level); } }
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) { for (byte index = 0; index < MAX_KEYS; ++index) { pPacket.WriteByte(mTypes[index]); pPacket.WriteUInt(mActions[index]); } }
internal void WriteGeneral(Packet pPacket) { pPacket.WriteInt(mBuddyIdentifier); pPacket.WritePaddedString(mName, 13); pPacket.WriteByte(mStatus); pPacket.WriteInt(0); pPacket.WritePaddedString("Default Group", 17); }
internal void WriteEquipment(Packet pPacket) { for (byte index = 0; index < (byte)EEquipmentSlot.Count; ++index) { if (mEquipped[index] == null && mCashEquipped[index] == null) continue; if (index == (byte)EEquipmentSlot.Weapon && mEquipped[index] != null) pPacket.WriteInt(mEquipped[index].ItemIdentifier); else if (mCashEquipped[index] != null) pPacket.WriteInt(mCashEquipped[index].ItemIdentifier); else if (mEquipped[index] != null) pPacket.WriteInt(mEquipped[index].ItemIdentifier); } pPacket.WriteByte(0xFF); for (byte index = 0; index < (byte)EEquipmentSlot.Count; ++index) { if (index == (byte)EEquipmentSlot.Weapon || mEquipped[index] == null || mCashEquipped[index] == null) continue; pPacket.WriteInt(mEquipped[index].ItemIdentifier); } pPacket.WriteByte(0xFF); pPacket.WriteInt(mCashEquipped[(byte)EEquipmentSlot.Weapon] == null ? 0 : mCashEquipped[(byte)EEquipmentSlot.Weapon].ItemIdentifier); }
internal void WriteInitial(Packet pPacket) { pPacket.WriteInt(mMesos); Array.ForEach(mItems, a => pPacket.WriteByte((byte)a.Length)); Array.ForEach(mEquipped, i => { if (i != null) i.WriteGeneral(pPacket, false); }); pPacket.WriteByte(0x00); Array.ForEach(mCashEquipped, i => { if (i != null) i.WriteGeneral(pPacket, false); }); pPacket.WriteByte(0x00); Array.ForEach(mItems[(byte)EInventoryType.Equipment], i => { if (i != null) i.WriteGeneral(pPacket, false); }); pPacket.WriteByte(0x00); Array.ForEach(mItems[(byte)EInventoryType.Use], i => { if (i != null) i.WriteGeneral(pPacket, false); }); pPacket.WriteByte(0x00); Array.ForEach(mItems[(byte)EInventoryType.Setup], i => { if (i != null) i.WriteGeneral(pPacket, false); }); pPacket.WriteByte(0x00); Array.ForEach(mItems[(byte)EInventoryType.Etc], i => { if (i != null) i.WriteGeneral(pPacket, false); }); pPacket.WriteByte(0x00); Array.ForEach(mItems[(byte)EInventoryType.Cash], i => { if (i != null) i.WriteGeneral(pPacket, false); }); pPacket.WriteByte(0x00); }
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); } }); }
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 SendWorldList(Client pClient) { Packet packet = new Packet(EOpcode.SMSG_WORLD_LIST); packet.WriteByte(0); packet.WriteString("Scania"); packet.WriteByte(Config.Instance.World.Ribbon); packet.WriteString(Config.Instance.World.EventMessage); packet.WriteByte(Config.Instance.World.ExperienceModifier); packet.WriteByte(0); packet.WriteByte(Config.Instance.World.DropModifier); packet.WriteByte(0); packet.WriteByte(0); packet.WriteByte(1); packet.WriteString("Scania-1"); packet.WriteInt(Server.Population); packet.WriteByte(0); packet.WriteByte(0); packet.WriteByte(0); packet.WriteShort(0); pClient.SendPacket(packet); packet = new Packet(EOpcode.SMSG_WORLD_LIST); packet.WriteByte(0xFF); pClient.SendPacket(packet); }
private static void SendWorldStatus(Client pClient) { int population = Server.Population; Packet packet = new Packet(EOpcode.SMSG_WORLD_STATUS); if (population >= Config.Instance.Channel.MaxPopulation) packet.WriteByte(0x02); else if (population >= (Config.Instance.Channel.MaxPopulation * 0.9)) packet.WriteByte(0x01); else packet.WriteByte(0x00); packet.WriteByte(0); pClient.SendPacket(packet); }
private static void SendPlayerDelete(Client pClient, int pPlayerIdentifier) { Packet packet = new Packet(EOpcode.SMSG_PLAYER_DELETE); packet.WriteInt(pPlayerIdentifier); packet.WriteByte(0x00); pClient.SendPacket(packet); }
private static void SendPlayerList(Client pClient) { Packet packet = new Packet(EOpcode.SMSG_PLAYER_LIST); packet.WriteByte(0x00); byte playerCount = (byte)(long)Database.Scalar("SELECT COUNT(*) FROM player WHERE account_identifier=@account_identifier", new MySqlParameter("@account_identifier", pClient.Account.Identifier)); packet.WriteByte(playerCount); if (playerCount > 0) { using (DatabaseQuery query = Database.Query("SELECT * FROM player WHERE account_identifier=@account_identifier", new MySqlParameter("@account_identifier", pClient.Account.Identifier))) { while (query.NextRow()) WritePlayer(packet, query); } } packet.WriteInt(Config.Instance.Login.MaxPlayersPerAccount); pClient.SendPacket(packet); }
internal void SendMapChange() { Packet packet = new Packet(EOpcode.SMSG_MAP_CHANGE); packet.WriteInt(0); packet.WriteInt(2); packet.WriteInt(mMap.Data.Identifier); packet.WriteByte(mSpawn); packet.WriteUShort(mHealth); packet.WriteByte(0x00); packet.WriteLong(DateTime.Now.Ticks); mClient.SendPacket(packet); }
private static void SendPlayerCreate(Client pClient, DatabaseQuery pQuery) { Packet packet = new Packet(EOpcode.SMSG_PLAYER_CREATE); packet.WriteByte(0x00); WritePlayer(packet, pQuery); pClient.SendPacket(packet); }
internal Packet GetPlayerDetails() { Packet packet = new Packet(EOpcode.SMSG_PLAYER_DETAILS); packet.WriteInt(mIdentifier); packet.WriteString(mName); packet.WriteString(""); packet.WriteUShort(0); packet.WriteByte(0x00); packet.WriteUShort(0); packet.WriteByte(0x00); packet.WriteUInt(0); packet.WriteByte(0xF8); packet.WriteByte(0x03); packet.WriteUShort(0); byte[] types = mBuffs.MapTypes; packet.WriteBytes(types, PlayerBuffs.BUFF_BYTE_5, 4); packet.WriteBytes(types, PlayerBuffs.BUFF_BYTE_1, 4); for (byte index = 0; index < PlayerBuffs.BUFF_ENTRY_ORDER.Length; ++index) { byte entryIndex = PlayerBuffs.BUFF_ENTRY_ORDER[index]; if (types[entryIndex] != 0) { foreach (KeyValuePair<byte, PlayerBuffs.MapValue> kv in mBuffs.MapValues[entryIndex]) { if (kv.Value.Debuff) { if (!(kv.Key == 0x01 && entryIndex == PlayerBuffs.BUFF_BYTE_5)) { packet.WriteUShort(kv.Value.SkillIdentifier); packet.WriteShort(kv.Value.Value); } } else if (kv.Value.Use) { if (entryIndex == PlayerBuffs.BUFF_BYTE_3) { if (kv.Key == 0x20) packet.WriteByte((byte)(mBuffs.Combo + 1)); else if (kv.Key == 0x40) packet.WriteInt(mBuffs.ChargeSkillIdentifier); } else if (entryIndex == PlayerBuffs.BUFF_BYTE_5) packet.WriteShort(kv.Value.Value); else packet.WriteByte((byte)kv.Value.Value); } } } } packet.WriteUShort(0); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(1065638850); packet.WriteUShort(0); packet.WriteByte(0x00); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(1065638850); packet.WriteUShort(0); packet.WriteByte(0x00); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(1065638850); packet.WriteUShort(0); packet.WriteByte(0x00); packet.WriteInt(mBuffs.MountIdentifier); packet.WriteInt(mBuffs.MountSkillIdentifier); packet.WriteUInt(1065638850); packet.WriteByte(0x00); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(1065638850); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(1065638850); packet.WriteUInt(0); packet.WriteByte(0x00); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(1065638850); packet.WriteUShort(0); packet.WriteByte(0x00); packet.WriteUShort(mJob); WriteAppearance(packet); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteCoordinates(mPosition); packet.WriteByte(0x00); packet.WriteUShort(0); packet.WriteByte(0x00); packet.WriteByte(0x00); packet.WriteUShort(1); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUShort(0); return packet; }
internal void EnterMap() { Log.WriteLine(ELogLevel.Info, "[{0}] Entered Map {1}", mClient.Host, mMap.Data.Identifier); if (mMap.Data.Music.Length > 0) { Packet packet = new Packet(EOpcode.SMSG_MAP_EFFECT); packet.WriteByte(0x06); packet.WriteString(mMap.Data.Music); mClient.SendPacket(packet); } if (mMap.Data.FieldTypes == MapData.EMapFieldType.ForceMapEquip) mClient.SendPacket(new Packet(EOpcode.SMSG_MAP_FORCE_EQUIPMENT)); mMap.SendPlayerDetails(this); mMap.SendNPCDetails(this); mMap.SendReactorDetails(this); mMap.SendMobDetails(this); mMap.UpdateMobControllers(false); }
public void WriteGeneral(Packet pPacket, bool pRealSlot) { if (mInventorySlot != 0) { if (pRealSlot) pPacket.WriteShort(mInventorySlot); else { byte slot = (byte)Math.Abs(mInventorySlot); if (slot > 100) slot -= 100; pPacket.WriteByte(slot); } } pPacket.WriteByte((byte)(mInventoryType == EInventoryType.Equipment ? 0x01 : 0x02)); pPacket.WriteInt(mItemIdentifier); pPacket.WriteByte(0x00); pPacket.WriteLong(0); if (mInventoryType == EInventoryType.Equipment) { pPacket.WriteByte(mUnusedScrollSlots); pPacket.WriteByte(mUsedScrollSlots); pPacket.WriteUShort(mStrength); pPacket.WriteUShort(mDexterity); pPacket.WriteUShort(mIntellect); pPacket.WriteUShort(mLuck); pPacket.WriteUShort(mHealth); pPacket.WriteUShort(mMana); pPacket.WriteUShort(mWeaponAttack); pPacket.WriteUShort(mMagicAttack); pPacket.WriteUShort(mWeaponDefense); pPacket.WriteUShort(mMagicDefense); pPacket.WriteUShort(mAccuracy); pPacket.WriteUShort(mAvoidance); pPacket.WriteUShort(mHands); pPacket.WriteUShort(mSpeed); pPacket.WriteUShort(mJump); pPacket.WriteString(mOwner); pPacket.WriteUShort(mFlags); pPacket.WriteByte(0x00); pPacket.WriteByte(0x00); pPacket.WriteUShort(0); pPacket.WriteUShort(0); pPacket.WriteUInt(0); pPacket.WriteLong(-1); pPacket.WriteLong(0); // 0040E0FD3B374F01 pPacket.WriteInt(-1); } else { pPacket.WriteUShort(mQuantity); pPacket.WriteString(mOwner); pPacket.WriteUShort(mFlags); if (ItemData.IsRechargeable(ItemData.GetType(mItemIdentifier))) pPacket.WriteLong(0); } }
internal void SendInitialMapChange() { Packet packet = new Packet(EOpcode.SMSG_MAP_CHANGE); packet.WriteUInt(0); packet.WriteByte(0x01); packet.WriteByte(0x01); packet.WriteUShort(0); packet.WriteInt(mRandom.Next()); packet.WriteInt(mRandom.Next()); packet.WriteInt(mRandom.Next()); packet.WriteInt(-1); packet.WriteInt(-1); packet.WriteInt(mIdentifier); packet.WritePaddedString(mName, 13); packet.WriteByte(mGender); packet.WriteByte(mSkin); packet.WriteInt(mEyesIdentifier); packet.WriteInt(mHairIdentifier); packet.WriteSkip(24); packet.WriteByte(mLevel); packet.WriteUShort(mJob); packet.WriteUShort(mStrength); packet.WriteUShort(mDexterity); packet.WriteUShort(mIntellect); packet.WriteUShort(mLuck); packet.WriteUShort(mHealth); packet.WriteUShort(mMaxHealth); packet.WriteUShort(mMana); packet.WriteUShort(mMaxMana); packet.WriteUShort(mAbilityPoints); packet.WriteUShort(mSkillPoints); packet.WriteInt(mExperience); packet.WriteUShort(mFame); packet.WriteUInt(0); packet.WriteInt(mMap.Data.Identifier); packet.WriteByte(mSpawn); packet.WriteUInt(0); packet.WriteByte(mBuddies.MaxBuddies); mItems.WriteInitial(packet); mSkills.WriteInitial(packet); mQuests.WriteInitial(packet); packet.WriteUInt(0); packet.WriteUInt(0); mTeleports.WriteInitial(packet); mCards.WriteInitial(packet); packet.WriteUInt(0); packet.WriteUShort(0); packet.WriteLong(DateTime.Now.ToBinary()); mClient.SendPacket(packet); }
internal void SendReactorDetails(Player pPlayer) { int slot = 0; foreach (Reactor reactor in mReactors) { Packet packet = new Packet(EOpcode.SMSG_REACTOR_DETAILS); packet.WriteInt(slot++); packet.WriteInt(reactor.Data.ReactorIdentifier); packet.WriteByte(reactor.State); packet.WriteShort(reactor.Data.X); packet.WriteShort(reactor.Data.Y); packet.WriteByte(0x00); pPlayer.SendPacket(packet); } }
internal void SendMobDetails(Player pPlayer) { foreach (Mob mob in mMobs) { Packet packet = new Packet(EOpcode.SMSG_MOB_DETAILS); packet.WriteInt(mob.UniqueIdentifier); packet.WriteByte(0x00); packet.WriteInt(mob.Data.MobIdentifier); mob.WriteStatus(packet); packet.WriteCoordinates(mob.Position); byte bits = 0x02; if (mob.FacingLeft) bits |= 0x01; packet.WriteByte(bits); packet.WriteUShort(mob.Foothold); packet.WriteUShort(mob.Data.Foothold); packet.WriteSByte(-1); packet.WriteSByte(0); packet.WriteInt(0); pPlayer.SendPacket(packet); } }
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); }
public void SendMessage(EMessageType pType, string pMessage, params object[] pArgs) { Packet packet = new Packet(EOpcode.SMSG_MESSAGE); packet.WriteByte((byte)pType); packet.WriteString(string.Format(pMessage, pArgs)); if (pType == EMessageType.GMText) packet.WriteInt(0); mClient.SendPacket(packet); }
private static void SendPin(Client pClient) { Packet packet = new Packet(EOpcode.SMSG_PIN); packet.WriteByte(0x00); pClient.SendPacket(packet); }
private static void SendChannelConnect(Client pClient, int pPlayerIdentifier) { Packet packet = new Packet(EOpcode.SMSG_CHANNEL_CONNECT); packet.WriteByte(0x00); packet.WriteByte(0x00); packet.WriteBytes(IPAddress.Parse(Config.Instance.Channel.ExternalAddress).GetAddressBytes()); packet.WriteUShort(Config.Instance.Channel.Listener.Port); packet.WriteInt(pPlayerIdentifier); packet.WriteSkip(5); pClient.SendPacket(packet); }
internal void SendKeymap() { Packet packet = new Packet(EOpcode.SMSG_KEYMAP); packet.WriteByte(0x00); mKeymap.WriteInitial(packet); mClient.SendPacket(packet); }
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); } }
public void SendPortalBlocked() { Packet packet = new Packet(EOpcode.SMSG_PLAYER_UPDATE); packet.WriteByte(0x01); packet.WriteUInt(0); SendPacket(packet); }