public static void SendUpdateWarManagerScreenDataResponse(IRealmClient client, Asda2Battleground btlgrnd) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.UpdateWarManagerScreenData)) { packet.WriteByte(1); packet.WriteByte(0); packet.WriteInt16(btlgrnd.StartTime.Hour); packet.WriteInt16(btlgrnd.StartTime.Minute); packet.WriteInt16(btlgrnd.EndTime.Hour); packet.WriteInt16(btlgrnd.EndTime.Minute); packet.WriteInt16(btlgrnd.AmountOfBattleGroundsInList); packet.WriteInt16(btlgrnd.LightTeam.Count); packet.WriteInt16(btlgrnd.DarkTeam.Count); packet.WriteByte(0); packet.WriteInt32(0); packet.WriteInt16(btlgrnd.LightWins); packet.WriteInt16(btlgrnd.DarkWins); packet.WriteInt16(btlgrnd.LightLooses); packet.WriteInt16(btlgrnd.DarkLooses); packet.WriteInt16((int)btlgrnd.LightWins + (int)btlgrnd.LightLooses); packet.WriteByte(0); packet.WriteInt16(btlgrnd.MinEntryLevel); packet.WriteInt16(btlgrnd.MaxEntryLevel); packet.WriteByte((byte)btlgrnd.WarType); client.Send(packet, true); } }
public static void SendRaidInfo(Character chr) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_RAID_INSTANCE_INFO)) { if (chr.HasInstanceCollection) { packet.Position += 4; uint count = 0; chr.Instances.ForeachBinding(BindingType.Hard, binding => { var timeLeft = binding.NextResetTime - DateTime.Now; if (timeLeft.Ticks > 0) { count++; packet.Write((uint)binding.MapId); packet.Write(binding.DifficultyIndex); packet.Write(binding.InstanceId); packet.WriteByte(0x1); // expired = 0 packet.WriteByte(0x0); // extended = 1 packet.Write((uint)timeLeft.TotalSeconds); //packet.Write(0); // unk, extended? } }); packet.Position = packet.HeaderSize; packet.Write(count); } else { packet.Write(0); } chr.Client.Send(packet); } }
/// <summary> /// Sends the specified character relation lists to the specified character /// </summary> /// <param name="character">The character to send the list</param> /// <param name="flag">Flag indicating which lists should be sent to the character</param> internal void SendRelationList(Character character, RelationTypeFlag flag) { Dictionary <uint, RelationListEntry> flatRelations = GetFlatRelations(character.EntityId.Low, flag); using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_CONTACT_LIST)) { packet.WriteUInt((uint)flag); packet.WriteUInt((uint)flatRelations.Count); foreach (RelationListEntry relationListEntry in flatRelations.Values) { packet.Write(EntityId.GetPlayerId(relationListEntry.RelatedCharacterId)); packet.WriteUInt((uint)relationListEntry.Flag); packet.WriteCString(relationListEntry.Note); if (relationListEntry.Flag.HasFlag(RelationTypeFlag.Friend)) { Character character1 = World.GetCharacter(relationListEntry.RelatedCharacterId); if (character1 != null) { packet.WriteByte((byte)character1.Status); packet.Write(character1.Zone != null ? (int)character1.Zone.Id : 0); packet.Write(character1.Level); packet.Write((int)character1.Class); } else { packet.WriteByte((byte)0); } } } character.Client.Send(packet, false); } }
public static void SendMonstrTakesDamageSecondaryResponse(Character chr, Character targetChr, NPC targetNpc, int damage) { if (targetChr == null && targetNpc == null) { return; } using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.MonstrTakesDamageSecondary)) { packet.WriteByte(targetNpc != null ? 0 : 1); packet.WriteInt16(targetNpc != null ? (short)targetNpc.UniqIdOnMap : targetChr.SessionId); packet.WriteInt16(160); packet.WriteInt32(damage); packet.WriteInt32(450); packet.WriteByte(1); packet.WriteInt16(66); packet.WriteByte(0); if (targetChr != null) { targetChr.SendPacketToArea(packet, true, true, Locale.Any, new float?()); } else { targetNpc.SendPacketToArea(packet, true, true, Locale.Any, new float?()); } } }
public static void SendInventoryError(RealmClient client, Item item1, Item item2, InventoryError error) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_INVENTORY_CHANGE_FAILURE, error == InventoryError.YOU_MUST_REACH_LEVEL_N ? 22 : 18)) { packet.WriteByte((byte)error); if (error == InventoryError.YOU_MUST_REACH_LEVEL_N) { packet.WriteUInt(item1.Template.RequiredLevel); } if (item1 != null) { packet.Write(item1.EntityId.Full); } else { packet.WriteULong(0); } if (item2 != null) { packet.Write(item2.EntityId.Full); } else { packet.WriteULong(0); } packet.WriteByte(0); client.Send(packet); } }
/// <param name="swingFlag">usually 1</param> /// <returns>The actual damage (all resistances subtracted)</returns> public static uint SendMeleeDamage(WorldObject attacker, WorldObject target, DamageType type, HitInfo hitInfo, uint totalAmount, uint absorbed, uint resisted, uint blocked, VictimState victimState) { uint amount = totalAmount - blocked - absorbed - resisted; using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_ATTACKERSTATEUPDATE, 70)) { packet.WriteUInt((uint)hitInfo); attacker.EntityId.WritePacked(packet); target.EntityId.WritePacked(packet); packet.WriteUInt(totalAmount); packet.WriteByte(1); packet.WriteByte((uint)type); packet.WriteFloat(amount); packet.WriteUInt(amount); packet.WriteUInt(absorbed); packet.WriteUInt(resisted); packet.WriteUInt((uint)victimState); packet.Write(absorbed == 0 ? 0 : -1); packet.WriteUInt(0); packet.WriteUInt(blocked); target.PushPacketToSurroundingArea(packet, true, false); } return(amount); }
public static void SendFaceOrHairChangedResponse(IRealmClient client, bool isHair, bool success = false, Asda2Item usedItem = null) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.FaceOrHairChanged)) { packet.WriteByte(success ? 1 : 0); packet.WriteByte(isHair ? 1 : 2); packet.WriteByte(client.ActiveCharacter.HairStyle); packet.WriteByte(client.ActiveCharacter.HairColor); packet.WriteByte(client.ActiveCharacter.Record.Face); packet.WriteInt32(client.ActiveCharacter.Asda2Inventory.Weight); packet.WriteInt32(client.ActiveCharacter.Money); Asda2InventoryHandler.WriteItemInfoToPacket(packet, usedItem, false); client.Send(packet, true); if (!success) { return; } AchievementProgressRecord progressRecord = client.ActiveCharacter.Achievements.GetOrCreateProgressRecord(9U); switch (++progressRecord.Counter) { case 50: client.ActiveCharacter.DiscoverTitle(Asda2TitleId.Beautiful47); break; case 100: client.ActiveCharacter.GetTitle(Asda2TitleId.Beautiful47); break; } progressRecord.SaveAndFlush(); } }
public static void SendPetResurectedResponse(IRealmClient client, Asda2PetRecord pet, Asda2Item resurectPetItem) { using (var packet = new RealmPacketOut(RealmServerOpCode.PetResurected)) //6109 { packet.WriteInt32(client.ActiveCharacter.AccId); //{accId}default value : 361343 Len : 4 packet.WriteInt32(pet.Guid); //{petGuid}default value : 68412 Len : 4 packet.WriteInt32(resurectPetItem.ItemId); //{itemId}default value : 31981 Len : 4 packet.WriteByte(2); //{inv}default value : 2 Len : 1 packet.WriteInt16(resurectPetItem.Slot); //{slot}default value : 8 Len : 2 packet.WriteInt16(resurectPetItem.IsDeleted ? -1 : 0); //{minusOneIfDelete}default value : -1 Len : 2 packet.WriteInt32(resurectPetItem.Amount); //{amount}default value : 0 Len : 4 packet.WriteByte(0); //value name : stab25 default value : stab25Len : 1 packet.WriteInt16(resurectPetItem.Amount); //{amount0}default value : 0 Len : 2 packet.WriteSkip(stab28); //value name : stab28 default value : stab28Len : 41 packet.WriteByte(1); //value name : unk1 default value : 1Len : 1 packet.WriteByte(pet.HungerPrc); //{HungerPrc}default value : 58 Len : 1 packet.WriteInt32(client.ActiveCharacter.Asda2Inventory.Weight); //{invWeight}default value : 0 Len : 4 packet.WriteInt16((short)pet.Stat1Type); //{stat1Type}default value : 2 Len : 2 packet.WriteInt32(pet.Stat1Value); //{stat1Value}default value : 31 Len : 4 packet.WriteInt16((short)pet.Stat2Type); //{stat1Type}default value : 2 Len : 2 packet.WriteInt32(pet.Stat2Value); //{stat1Value}default value : 31 Len : 4 packet.WriteInt16((short)pet.Stat2Type); //{stat1Type}default value : 2 Len : 2 packet.WriteInt32(pet.Stat2Value); //{stat1Value}default value : 31 Len : 4 client.Send(packet, addEnd: true); } }
public static void SendPartyMemberBuffInfoResponse(Character member) { using (var packet = new RealmPacketOut(RealmServerOpCode.PartyMemberBuffInfo)) //5108 { packet.WriteInt32(member.AccId); //{accId}default value : 340701 Len : 4 var auras = new Aura[28]; var it = 0; foreach (var visibleAura in member.Auras.ActiveAuras) { if (visibleAura.TicksLeft <= 0) { continue; } auras[it++] = visibleAura; if (auras.Length <= it) { break; } } for (int i = 0; i < 28; i += 1) { var aura = auras[i]; packet.WriteByte(aura == null ? 0 : 1); //exist? packet.WriteByte(0); //spadaet? packet.WriteInt32(aura == null ? -1 : aura.Spell.RealId); //{duration}default value : -1 Len : 4 } member.Group.Send(packet, addEnd: false); } }
/// <summary> /// Sends all info about set icons to the client /// </summary> /// <param name="requester">The character requesting the target icon list</param> public virtual void SendTargetIconList(Character requester) { using (var packet = new RealmPacketOut(RealmServerOpCode.MSG_RAID_TARGET_UPDATE)) { packet.WriteByte(1); // flag, meaning that it's full list of target icons for (byte iconId = 0; iconId < TargetIconCount; iconId++) { if (m_targetIcons[iconId] == EntityId.Zero) { continue; } packet.WriteByte(iconId); packet.Write(m_targetIcons[iconId].Full); } if (requester != null) { requester.Client.Send(packet); } else { SendAll(packet); } } }
/// <summary> /// Sends info about change of single target icons info to all the party /// </summary> /// <param name="iconId">what element of array has changed</param> /// <param name="targetId">new value</param> public virtual void SetTargetIcon(byte iconId, EntityId whoId, EntityId targetId) { if (iconId >= TargetIconCount) { return; } bool requiresIconUpdate = ClearTargetIconList(iconId, targetId); m_targetIcons[iconId] = targetId; if (requiresIconUpdate) { SendTargetIconList(); return; } using (var packet = new RealmPacketOut(RealmServerOpCode.MSG_RAID_TARGET_UPDATE)) { packet.WriteByte(0); // flag, meaning that it's single target icon change // (i.e. don't need to reset client-side list before applying it)? packet.Write(whoId); // 3.3.x packet.WriteByte(iconId); packet.Write(targetId.Full); SendAll(packet); } }
public static void SendItemBuyedFromPrivateShopResponse(Character chr, PrivateShopBuyResult status, List <Asda2Item> buyedItems) { Asda2Item[] asda2ItemArray = new Asda2Item[6]; if (buyedItems != null) { for (int index = 0; index < buyedItems.Count; ++index) { asda2ItemArray[index] = buyedItems[index]; } } using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.ItemBuyedFromPrivateShop)) { packet.WriteByte((byte)status); if (status == PrivateShopBuyResult.Ok) { packet.WriteInt16(chr.Asda2Inventory.Weight); packet.WriteInt32(chr.Money); packet.WriteByte(buyedItems.Count <Asda2Item>((Func <Asda2Item, bool>)(i => i != null))); for (int index = 0; index < 6; ++index) { Asda2InventoryHandler.WriteItemInfoToPacket(packet, asda2ItemArray[index], false); } } chr.Send(packet, false); } }
public static void SendMailsListResponse(IRealmClient client, IEnumerable <Asda2MailMessage> mailMsgs) { var msgs = new Asda2MailMessage[10]; var ii = 0; foreach (var m in mailMsgs) { if (m.DeleteTime < DateTime.Now) { client.ActiveCharacter.MailMessages.Remove(m.Guid); m.DeleteLater(); } else { msgs[ii] = m; } ii++; } using (var packet = new RealmPacketOut(RealmServerOpCode.MailsList)) //6619 { packet.WriteByte(0); //{page}default value : 1 Len : 1 for (int i = 0; i < 10; i += 1) { var msg = msgs[i]; packet.WriteInt32((int)(msg == null?-1:msg.Guid)); //{guidRec}default value : 379808 Len : 4 packet.WriteByte(msg == null?0:msg.IsReaded?1:0); //{taked}default value : 0 Len : 1 packet.WriteInt32((int)(msg == null ? 0 : (msg.DeleteTime - DateTime.Now).TotalMinutes)); //{timeTodeletemins}default value : 10061 Len : 4 packet.WriteFixedAsciiString(msg == null?"":msg.SenderName, 20); //{senderName}default value : Len : 20 packet.WriteFixedAsciiString(msg == null ? "" : msg.Subject, 32); //{title}default value : Len : 32 } client.Send(packet, addEnd: true); } }
public static void SendRegularTradeCompleteResponse(IRealmClient client, Asda2Item[] items) { using (var packet = new RealmPacketOut(RealmServerOpCode.RegularTradeComplete)) //5295 { packet.WriteByte(5); //{status}default value : 5 Len : 1 packet.WriteInt32(client.ActiveCharacter.Asda2Inventory.Weight); //{invWeight}default value : 2381 Len : 4 for (int i = 0; i < 5; i += 1) { var item = items[i]; if (item == null) { packet.WriteInt32(-1); //{itemId}default value : 31850 Len : 4 packet.WriteByte(0); //{invNum}default value : 2 Len : 1 packet.WriteInt16(-1); //{slot}default value : 1 Len : 2 packet.WriteInt32(0); //{amount}default value : 5 Len : 4 packet.WriteInt16(0); //{weight}default value : 60 Len : 2 } else { packet.WriteInt32(item.ItemId); //{itemId}default value : 31850 Len : 4 packet.WriteByte((byte)item.InventoryType); //{invNum}default value : 2 Len : 1 packet.WriteInt16(item.Slot); //{slot}default value : 1 Len : 2 packet.WriteInt32(item.Amount); //{amount}default value : 5 Len : 4 packet.WriteInt16(item.Weight); //{weight}default value : 60 Len : 2 } } client.Send(packet, addEnd: false); } }
private static RealmPacketOut CreateArenaTeamRosterResponsePacket(ArenaTeam team) { var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ARENA_TEAM_ROSTER, 100); packet.WriteUInt(team.Id); packet.WriteByte(0); packet.WriteUInt(team.MemberCount); packet.WriteUInt(team.Type); foreach (var member in team.Members.Values) { packet.WriteULong(member.Character.EntityId.Full); var pl = World.GetCharacter(member.Character.EntityId.Low); packet.WriteByte((pl != null) ? 1 : 0); packet.WriteCString(member.Character.Name); packet.WriteByte((team.Leader == member) ? 0 : 1); packet.WriteByte((pl != null) ? pl.Level : 0); packet.WriteUInt((uint)member.Class); packet.WriteUInt(member.GamesWeek); packet.WriteUInt(member.WinsWeek); packet.WriteUInt(member.GamesSeason); packet.WriteUInt(member.WinsSeason); packet.WriteUInt(member.PersonalRating); packet.WriteFloat(0.0f); packet.WriteFloat(0.0f); } return(packet); }
public static void SendQuestsListResponse(IRealmClient client) { using (var packet = new RealmPacketOut(RealmServerOpCode.QuestsList))//5047 { for (int i = 0; i < 12; i += 1) { packet.WriteInt32(-1); //{questId}default value : -1 Len : 4 packet.WriteByte(0); //value name : unk1 default value : 0Len : 1 packet.WriteInt16(-1); //{questSlot}default value : -1 Len : 2 packet.WriteByte(0); //{questStage}default value : 0 Len : 1 2 - in progress 1 - completed packet.WriteInt16(-1); //{oneMoreQuestId}default value : -1 Len : 2 packet.WriteInt16(0); //{IsCompleted}default value : 2 Len : 2 0 or 1 packet.WriteInt16(-1); //value name : unk2 default value : -1Len : 2 packet.WriteInt32(-1); //{questItemId}default value : -1 Len : 4 packet.WriteInt16(0); //{questItemAmount}default value : 0 Len : 2 packet.WriteInt32(-1); //{questItemId}default value : -1 Len : 4 packet.WriteInt16(0); //{questItemAmount}default value : 0 Len : 2 packet.WriteInt32(-1); //{questItemId}default value : -1 Len : 4 packet.WriteInt16(0); //{questItemAmount}default value : 0 Len : 2 packet.WriteInt32(-1); //{questItemId}default value : -1 Len : 4 packet.WriteInt16(0); //{questItemAmount}default value : 0 Len : 2 packet.WriteInt32(-1); //{questItemId}default value : -1 Len : 4 packet.WriteInt16(0); //{questItemAmount}default value : 0 Len : 2*/ } for (int i = 0; i < 1; i++) { packet.WriteByte(254); } for (int i = 0; i < 149; i++) { packet.WriteByte(255); } client.Send(packet, addEnd: false); } }
/// <summary> /// Any spell and ranged damage /// </summary> /// <param name="totalAmount">Total amount</param> /// <returns>The actual amount, with all mali subtracted</returns> public static void SendMagicDamage(EntityId caster, WorldObject target, uint spellId, uint amount, DamageType type, uint absorbed, uint resisted, uint blocked, bool critical) { /*if (victimState == VICTIMSTATE.DEFLECT) // resist * return MagicResist(target,submitter,spellId);*/ // TODO: Magic miss, ranged dodge, etc. using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_SPELLNONMELEEDAMAGELOG, 40)) { target.EntityId.WritePacked(packet); caster.WritePacked(packet); packet.Write(spellId); packet.WriteUInt(amount); packet.WriteByte((byte)type); packet.WriteUInt(absorbed); packet.WriteUInt(resisted); packet.WriteByte(type == DamageType.Physical ? 1 : 0); // pyshical damage? packet.WriteByte(0); packet.WriteUInt(blocked); packet.WriteByte(critical ? 7 : 6); packet.Write(0); target.PushPacketToSurroundingArea(packet, true, false); } }
public static void SendPlayerInfo(IRealmClient client) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_LFG_PARTY_INFO)) { byte num1 = 0; packet.Write(num1); uint num2 = 0; packet.Write(num2); packet.WriteByte(false); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(0); int val = 0; packet.WriteByte(val); for (byte index = 0; (int)index < val; ++index) { packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(0); } uint num3 = 0; packet.Write(num3); for (uint index = 0; index < num3; ++index) { packet.Write(num2); packet.Write(6U); } client.Send(packet, false); } }
/// <summary>Sends a npc text update to the character</summary> /// <param name="character">recieving character</param> /// <param name="text">class holding all info about text</param> public static void SendNPCTextUpdate(Character character, IGossipEntry text) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_NPC_TEXT_UPDATE)) { packet.Write(text.GossipId); int index1; for (index1 = 0; index1 < text.GossipTexts.Length; ++index1) { GossipTextBase gossipText = text.GossipTexts[index1]; packet.WriteFloat(gossipText.Probability); string textMale = gossipText.GetTextMale(character.GossipConversation); string str = !text.IsDynamic ? gossipText.GetTextFemale(character.GossipConversation) : textMale; packet.WriteCString(textMale); packet.WriteCString(str); packet.Write((uint)gossipText.Language); for (int index2 = 0; index2 < 3; ++index2) { packet.Write(0L); } } for (; index1 < 8; ++index1) { packet.WriteFloat(0); packet.WriteByte(0); packet.WriteByte(0); packet.Fill((byte)0, 28); } character.Client.Send(packet, false); } }
public static void SendRegisterItemToAukCancelWindowResponse(IRealmClient client, List <Asda2ItemTradeRef> items = null) { using (var packet = new RealmPacketOut(RealmServerOpCode.RegisterItemToAukCancelWindow))//9902 { if (items != null) { foreach (var item in items) { packet.WriteByte(0); //{status}default value : 0 Len : 1 packet.WriteInt32(item.Item.ItemId); //{itemId}default value : 31855 Len : 4 packet.WriteByte((byte)item.Item.InventoryType); //{invNum}default value : 2 Len : 1 packet.WriteInt16(item.Item.Slot); //{cell}default value : 5 Len : 2 packet.WriteSkip(stab15); //value name : stab15 default value : stab15Len : 12 packet.WriteInt32(item.Amount); //{registeredAmount}default value : 250 Len : 4 packet.WriteInt32(item.Item.Amount); //{beforeAmount}default value : 250 Len : 4 packet.WriteInt16(item.Item.Weight); //{weight}default value : 0 Len : 2 packet.WriteSkip(stab37); //value name : stab37 default value : stab37Len : 21 packet.WriteInt32(client.ActiveCharacter.Asda2Inventory.Weight); //{invWeight}default value : 315 Len : 4 packet.WriteInt32(client.ActiveCharacter.Money); //{money}default value : 8503216 Len : 4 packet.WriteInt64(-1); //value name : unk8 default value : -1Len : 8 } } client.Send(packet); } }
public static void GuildWaveoOnResponse(IRealmClient client, int guildid) { using (var packet = new RealmPacketOut(RealmServerOpCode.GuildWaveoOnResponse)) //4401 { Asda2GuildWave guildWave = Asda2GuildWaveMgr.GetGuildWaveForId(guildid); packet.WriteInt16(guildid); //{GuildId}default value : 3 Len : 2 if (guildWave != null) { packet.WriteByte((byte)GuildWaveOnSRS.Show); //{GuildWaveOnSRS} packet.WriteByte(guildWave.Difficulty); //{GuildWaveOnDifficulty} packet.WriteInt16(guildWave.PlayersRegisteredCount); //{Count Player} } else { packet.WriteByte((byte)GuildWaveOnSRS.Select); //{GuildWaveOnSRS} packet.WriteByte(0); //{GuildWaveOnDifficulty} packet.WriteInt16(0); //{Count Player} } //Asda2GuildWave.GetDiffeclity(guildWave.Difficulty); client.ActiveCharacter.Send(packet, addEnd: true); } }
public static void SendRegisterItemToAukCancelWindowResponse(IRealmClient client, List <Asda2ItemTradeRef> items = null) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.RegisterItemToAukCancelWindow)) { if (items != null) { foreach (Asda2ItemTradeRef asda2ItemTradeRef in items) { packet.WriteByte(0); packet.WriteInt32(asda2ItemTradeRef.Item.ItemId); packet.WriteByte((byte)asda2ItemTradeRef.Item.InventoryType); packet.WriteInt16(asda2ItemTradeRef.Item.Slot); packet.WriteSkip(Asda2AuctionHandler.stab15); packet.WriteInt32(asda2ItemTradeRef.Amount); packet.WriteInt32(asda2ItemTradeRef.Item.Amount); packet.WriteInt16(asda2ItemTradeRef.Item.Weight); packet.WriteSkip(Asda2AuctionHandler.stab37); packet.WriteInt32(client.ActiveCharacter.Asda2Inventory.Weight); packet.WriteInt32(client.ActiveCharacter.Money); packet.WriteInt64(-1L); } } client.Send(packet, false); } }
public static void SendChatRoomVisibleResponse(Character owner, ChatRoomVisibilityStatus status, Asda2Chatroom room, Character character = null) { if (character != null) { using (var packet = new RealmPacketOut(RealmServerOpCode.ChatRoomVisible)) //6248 { packet.WriteByte((byte)status); //{status}default value : 2 Len : 1 packet.WriteInt32(owner.AccId); //{initerAccId}default value : 361343 Len : 4 packet.WriteByte(room == null ? 0 : room.IsPrivate ? 1 : 0); //{zeroPublicOnePrivate}default value : 1 Len : 1 packet.WriteInt16(room == null ? 0 : room.MaxMembersCount); //{maxMemberCount}default value : 15 Len : 1 packet.WriteFixedAsciiString(room == null ? "" : room.Name, 28); //{roomName}default value : Len : 28 packet.WriteInt16(0); //value name : unk11 default value : 0Len : 2 packet.WriteByte(0); //value name : unk1 default value : 0Len : 1 character.Send(packet, addEnd: true); } return; } using (var packet = new RealmPacketOut(RealmServerOpCode.ChatRoomVisible)) //6248 { packet.WriteByte((byte)status); //{status}default value : 2 Len : 1 packet.WriteInt32(owner.AccId); //{initerAccId}default value : 361343 Len : 4 packet.WriteByte(room == null ? 0 : room.IsPrivate ? 1 : 0); //{zeroPublicOnePrivate}default value : 1 Len : 1 packet.WriteInt16(room == null ? 0 : room.MaxMembersCount); //{maxMemberCount}default value : 15 Len : 1 packet.WriteFixedAsciiString(room == null ? "" : room.Name, 28); //{roomName}default value : Len : 28 packet.WriteInt16(0); //value name : unk11 default value : 0Len : 2 packet.WriteByte(0); //value name : unk1 default value : 0Len : 1 owner.SendPacketToArea(packet); } }
/// <summary> /// Sends info about change of single target icons info to all the party /// </summary> /// <param name="iconId">what element of array has changed</param> /// <param name="targetId">new value</param> public virtual void SetTargetIcon(byte iconId, EntityId whoId, EntityId targetId) { if (iconId >= 8) { return; } bool flag = ClearTargetIconList(iconId, targetId); m_targetIcons[iconId] = targetId; if (flag) { SendTargetIconList(); } else { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.MSG_RAID_TARGET_UPDATE)) { packet.WriteByte(0); packet.Write(whoId); packet.WriteByte(iconId); packet.Write(targetId.Full); SendAll(packet); } } }
public static void SendPartyMemberBuffInfoResponse(Character member) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.PartyMemberBuffInfo)) { packet.WriteInt32(member.AccId); Aura[] auraArray = new Aura[28]; int num = 0; foreach (Aura activeAura in member.Auras.ActiveAuras) { if (activeAura.TicksLeft > 0) { auraArray[num++] = activeAura; if (auraArray.Length <= num) { break; } } } for (int index = 0; index < 28; ++index) { Aura aura = auraArray[index]; packet.WriteByte(aura == null ? 0 : 1); packet.WriteByte(0); packet.WriteInt32(aura == null ? -1 : (int)aura.Spell.RealId); } member.Group.Send(packet, false); } }
public static void SendRegularTradeCompleteResponse(IRealmClient client, Asda2Item[] items) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.RegularTradeComplete)) { packet.WriteByte(5); packet.WriteInt32(client.ActiveCharacter.Asda2Inventory.Weight); for (int index = 0; index < 5; ++index) { Asda2Item asda2Item = items[index]; if (asda2Item == null) { packet.WriteInt32(-1); packet.WriteByte(0); packet.WriteInt16(-1); packet.WriteInt32(0); packet.WriteInt16(0); } else { packet.WriteInt32(asda2Item.ItemId); packet.WriteByte((byte)asda2Item.InventoryType); packet.WriteInt16(asda2Item.Slot); packet.WriteInt32(asda2Item.Amount); packet.WriteInt16(asda2Item.Weight); } } client.Send(packet, false); } }
public static void SendPlayerInfo(IRealmClient client) { // SMSG_LFG_PLAYER_INFO using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LFG_PARTY_INFO)) { byte dungeonsCount = 0; packet.Write(dungeonsCount); uint packedDungeonId = 0; packet.Write(packedDungeonId); //something to do with quests! :\ packet.WriteByte(false); // is quest complete? packet.WriteUInt(0); //quest reward/required money packet.WriteUInt(0); //quest reward xp packet.WriteUInt(0); //lfg dungeon reward cash packet.WriteUInt(0); //lfg dungeon reward xp var questItemsCount = 0; packet.WriteByte(questItemsCount); for (byte i = 0; i < questItemsCount; i++) { packet.WriteUInt(0); //item id packet.WriteUInt(0); //display id packet.WriteUInt(0); //count of items } uint lockCount = 0; packet.Write(lockCount); for (uint i = 0; i < lockCount; i++) { packet.Write(packedDungeonId); packet.Write((uint)LFGLockStatusType.RaidLocked); } client.Send(packet, addEnd: false); } }
private static RealmPacketOut CreateArenaTeamRosterResponsePacket(ArenaTeam team) { RealmPacketOut realmPacketOut = new RealmPacketOut(RealmServerOpCode.SMSG_ARENA_TEAM_ROSTER, 100); realmPacketOut.WriteUInt(team.Id); realmPacketOut.WriteByte(0); realmPacketOut.WriteUInt(team.MemberCount); realmPacketOut.WriteUInt(team.Type); foreach (ArenaTeamMember arenaTeamMember in team.Members.Values) { realmPacketOut.WriteULong(arenaTeamMember.Character.EntityId.Full); Character character = World.GetCharacter(arenaTeamMember.Character.EntityId.Low); realmPacketOut.WriteByte(character != null ? 1 : 0); realmPacketOut.WriteCString(arenaTeamMember.Character.Name); realmPacketOut.WriteByte(team.Leader == arenaTeamMember ? 0 : 1); realmPacketOut.WriteByte(character != null ? character.Level : 0); realmPacketOut.WriteUInt((uint)arenaTeamMember.Class); realmPacketOut.WriteUInt(arenaTeamMember.GamesWeek); realmPacketOut.WriteUInt(arenaTeamMember.WinsWeek); realmPacketOut.WriteUInt(arenaTeamMember.GamesSeason); realmPacketOut.WriteUInt(arenaTeamMember.WinsSeason); realmPacketOut.WriteUInt(arenaTeamMember.PersonalRating); realmPacketOut.WriteFloat(0.0f); realmPacketOut.WriteFloat(0.0f); } return(realmPacketOut); }
public static void SendUpdateWarManagerScreenDataResponse(IRealmClient client, Asda2Battleground btlgrnd) { using (var packet = new RealmPacketOut(RealmServerOpCode.UpdateWarManagerScreenData)) //6701 { packet.WriteByte(1); //{status}default value : 1 Len : 1 packet.WriteByte(0); //value name : unk6 default value : 0Len : 1 packet.WriteInt16(btlgrnd.StartTime.Hour); //{startTimeHours}default value : 8 Len : 2 packet.WriteInt16(btlgrnd.StartTime.Minute); //{startTimeMins}default value : 0 Len : 2 packet.WriteInt16(btlgrnd.EndTime.Hour); //{endTimeHours}default value : 8 Len : 2 packet.WriteInt16(btlgrnd.EndTime.Minute); //{endTimeMins}default value : 25 Len : 2 packet.WriteInt16(btlgrnd.AmountOfBattleGroundsInList); //{battlesInListCount}default value : 1 Len : 2 packet.WriteInt16(btlgrnd.LightTeam.Count); //{forLitePeople}default value : 1 Len : 2 packet.WriteInt16(btlgrnd.DarkTeam.Count); //{forDarkPeople}default value : 0 Len : 2 packet.WriteByte(0); //{mustBe0}default value : 0 Len : 1 packet.WriteInt32(0); //{canBe0}default value : 586427422 Len : 4 packet.WriteInt16(btlgrnd.LightWins); //{winWarsLight}default value : 639 Len : 2 packet.WriteInt16(btlgrnd.DarkWins); //{winWarsDark}default value : 548 Len : 2 packet.WriteInt16(btlgrnd.LightLooses); //{lightLoses}default value : 548 Len : 2 packet.WriteInt16(btlgrnd.DarkLooses); //{darkLoses}default value : 639 Len : 2 packet.WriteInt16(btlgrnd.LightWins + btlgrnd.LightLooses); //{totalWars}default value : 1187 Len : 2 packet.WriteByte(0); //{dailyWarsMinusOne}default value : 0 Len : 1 packet.WriteInt16(btlgrnd.MinEntryLevel); //{minEnterLevel}default value : 10 Len : 2 packet.WriteInt16(btlgrnd.MaxEntryLevel); //{maxEnterLevel}default value : 29 Len : 2 packet.WriteByte((byte)btlgrnd.WarType); client.Send(packet, addEnd: true); } }
public static void SendWarPartipicationCanceledResponse(IRealmClient client) { using (var packet = new RealmPacketOut(RealmServerOpCode.WarPartipicationCanceled)) //6709 { packet.WriteByte(1); //value name : unk5 default value : 1Len : 1 packet.WriteByte(client.ActiveCharacter.Asda2FactionId); //value name : unk1 default value : 1Len : 1 client.Send(packet); } }
/// <summary> /// Creates a packet /// </summary> public static RealmPacketOut CreateChatPacket(ChatMsgType type, ChatLanguage language, string msg, ChatTag tag) { var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT, 23 + msg.Length); packet.WriteByte((byte)type); // 1 packet.WriteUInt((uint)language); // 5 packet.WriteUIntPascalString(msg); // 22 + msg.Length packet.WriteByte((byte)tag); // 23 + msg.Length return packet; }
public static void SendSystemStatus(Character chr, VoiceSystemStatus status) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_FEATURE_SYSTEM_STATUS)) { packet.WriteByte(2); // what is this packet.WriteByte((byte)status); chr.Client.Send(packet); } }
public static RealmPacketOut CreateAchievementEarnedToGuild(AchievementEntryId achievementEntryId, Character chr) { // Must be a better way to do this. const string msg = "|Hplayer:$N|h[$N]|h has earned the achievement $a!"; var packet = new RealmPacketOut(RealmServerOpCode.SMSG_MESSAGECHAT); packet.WriteByte((byte) ChatMsgType.Achievment); packet.WriteUInt((uint) ChatLanguage.Universal); packet.Write(chr.EntityId); packet.WriteUInt(5); packet.Write(chr.EntityId); packet.WriteUIntPascalString(msg); packet.WriteByte(0); packet.WriteUInt((uint) achievementEntryId); return packet; }
/// <summary> /// Sends the packet to show the battleground window /// </summary> /// <param name="client"></param> /// <param name="speaker"></param> /// <param name="character"></param> /// <returns></returns> public bool SendBattlegroundWindow(IRealmClient client, NPC speaker, Character character) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_BATTLEFIELD_LIST)) { packet.WriteULong(speaker != null ? speaker.EntityId.Full : 0); packet.WriteUInt((uint)m_bgqueue.Template.BgID); packet.WriteByte(m_battlegroupId); //Battle group // TODO: Add sync'ing? //m_syncLock.EnterReadLock(); try { packet.WriteUInt(m_battlegrounds.Count); //Count foreach (var bg in m_battlegrounds.Values) { packet.WriteUInt(bg.InstanceId); } } finally { //m_syncLock.ExitReadLock(); } client.Send(packet); return true; } }
/// <summary> /// Sends to the specified client the Who List based on the given characters /// </summary> /// <param name="client">The client to send the list</param> /// <param name="characters">The list of characters that matched the Who List search</param> public static void SendWhoList(IPacketReceiver client, ICollection<Character> characters) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_WHO)) { packet.Write(characters.Count); packet.Write(characters.Count); foreach (Character character in characters) { packet.WriteCString(character.Name); packet.WriteCString(character.Guild != null ? character.Guild.Name : string.Empty); //TODO: Add Guild name here packet.Write(character.Level); packet.WriteUInt((byte)character.Class); packet.WriteUInt((byte)character.Race); packet.WriteByte(0); //New in 2.4.x packet.Write(character.Zone != null ? (uint)character.Zone.Id : 0); } client.Send(packet); } }
/// <summary> /// Sent after spell start. Triggers the casting animation /// </summary> public static void SendSpellGo(ObjectBase caster2, SpellCast cast, ICollection<WorldObject> hitTargets, ICollection<CastMiss> missedTargets) { // TODO: Dynamic packet length? if (!cast.IsCasting) { return; } //int len = 200; int len = 24 + (hitTargets != null ? hitTargets.Count * 8 : 0) + (missedTargets != null ? missedTargets.Count * 10 : 0); using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SPELL_GO, len)) { //caster1.EntityId.WritePacked(packet); cast.Caster.EntityId.WritePacked(packet); caster2.EntityId.WritePacked(packet); packet.Write(cast.Id); packet.Write(cast.Spell.Id); var castGoFlags = cast.GoFlags; packet.Write((int)castGoFlags); //packet.Write(Util.Utility.GetEpochTime()); packet.Write(Utility.GetEpochTime()); //packet.Write(cast.CastDelay); packet.WriteByte(hitTargets != null ? hitTargets.Count : 0); if (hitTargets != null) { foreach (var target in hitTargets) { packet.Write(target.EntityId); if (target is Character) { SendCastSuccess(cast.Caster, cast.Spell.Id, target as Character); } } } packet.WriteByte(missedTargets != null ? missedTargets.Count : 0); if (missedTargets != null) { foreach (var miss in missedTargets) { packet.Write(miss.Target.EntityId); packet.Write((byte)miss.Reason); if (miss.Reason == CastMissReason.Reflect) { packet.Write((byte)0);// relfectreason } } } WriteTargets(packet, cast); if ((castGoFlags & CastFlags.Flag_0x800) != 0) { packet.Write(0); } if ((castGoFlags & CastFlags.Flag_0x200000) != 0) { byte b1 = 0; byte b2 = 0; packet.Write(b1); packet.Write(b2); for (int i = 0; i < 6; i++) { byte mask = (byte)(1 << i); if ((mask & b1) != 0) { if (!((mask & b2) != 0)) { packet.WriteByte(0); } } } } if ((castGoFlags & CastFlags.Flag_0x20000) != 0) { packet.WriteFloat(0); packet.Write(0); } if ((cast.StartFlags & CastFlags.Ranged) != 0) { WriteAmmoInfo(cast, packet); } if ((castGoFlags & CastFlags.Flag_0x80000) != 0) { packet.Write(0); packet.Write(0); } if (cast.TargetFlags.Has(SpellTargetFlags.DestinationLocation)) { packet.Write((byte)0); // unk 3.3.x? } cast.Caster.SendPacketToArea(packet, true); } }
public static void SendCastStart(SpellCast cast) { // TODO: can len be dynamic? int len = 150; var spell = cast.Spell; if (spell == null) return; using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SPELL_START, len)) { // Common to start and go packets WriteCaster(cast, packet); packet.Write(cast.Id); packet.Write(spell.Id); packet.Write((int)cast.StartFlags); // start specific stuff packet.Write(cast.CastDelay); WriteTargets(packet, cast); if ((cast.StartFlags & CastFlags.Flag_0x800) != 0) { packet.Write(0); } if ((cast.StartFlags & CastFlags.Flag_0x200000) != 0) { byte b1 = 0; byte b2 = 0; packet.Write(b1); packet.Write(b2); for (int i = 0; i < 6; i++) { byte mask = (byte)(1 << i); if ((mask & b1) != 0) { if (!((mask & b2) != 0)) { packet.WriteByte(0); } } } } if ((cast.StartFlags & CastFlags.Ranged) != 0) { WriteAmmoInfo(cast, packet); } if ((cast.StartFlags & CastFlags.Flag_0x4000000) != 0) { // since 3.2.0 packet.Write(0); packet.Write(0); } if (cast.TargetFlags.Has(SpellTargetFlags.DestinationLocation)) { packet.Write((byte)0); // unk 3.3.x? } cast.Caster.SendPacketToArea(packet, true); } }
public static void SendPetitionQueryResponse(IPacketReceiver client, PetitionCharter charter) { string name = charter.Petition.Name; using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PETITION_QUERY_RESPONSE, 4 + 8 + name.Length + 1 + 1 + 4 * 12 + 2 + 10)) { packet.WriteUInt(charter.EntityId.Low); packet.WriteULong(charter.Owner.EntityId.Full); packet.WriteCString(name); packet.WriteByte(0); var type = (uint)charter.Petition.Type; if(type == (uint)PetitionType.Guild) { packet.WriteUInt(type); packet.WriteUInt(type); packet.WriteUInt(0); } else { packet.WriteUInt(type-1); packet.WriteUInt(type-1); packet.WriteUInt(type); } packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUShort(0); packet.WriteUInt(0); packet.WriteUInt(0); packet.WriteUInt(0); for(int i = 0; i < 10; ++i) packet.WriteByte(0); packet.WriteUInt(0); if(type == (uint)PetitionType.Guild) packet.WriteUInt(0); else packet.WriteUInt(1); client.Send(packet); } }
public static void SendPetitionSignatures(IPacketReceiver client, PetitionCharter charter) { var signs = charter.Petition.SignedIds; using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PETITION_SHOW_SIGNATURES, 8+8+4+1+signs.Count*12)) { packet.WriteULong(charter.EntityId.Full); packet.WriteULong(charter.Owner.EntityId.Full); packet.WriteUInt(charter.EntityId.Low); packet.WriteByte(signs.Count); foreach(var guid in signs) { packet.WriteULong(guid); packet.WriteUInt(0); } client.Send(packet); } }
public static void SendCharacterRename(IPacketReceiver client, EntityId guid, string newName) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_RENAME, 10 + newName.Length)) { packet.WriteByte((byte)LoginErrorCode.RESPONSE_SUCCESS); packet.Write(guid); packet.WriteCString(newName); client.Send(packet); } }
/// <summary> /// Sends a character creation reply to the client. /// </summary> /// <param name="client">the client to send to</param> /// <param name="error">the error code</param> public static void SendCharCreateReply(IPacketReceiver client, LoginErrorCode error) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_CREATE, 1)) { packet.WriteByte((byte)error); client.Send(packet); } }
/// <summary> /// item1 and item2 can be null, but item1 must be set in case of YOU_MUST_REACH_LEVEL_N. /// </summary> /// <param name="client"></param> /// <param name="error"></param> public static void SendInventoryError(IPacketReceiver client, InventoryError error) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_INVENTORY_CHANGE_FAILURE, error == InventoryError.YOU_MUST_REACH_LEVEL_N ? 22 : 18)) { packet.WriteByte((byte)error); packet.WriteULong(0); packet.WriteULong(0); packet.WriteByte(0); client.Send(packet); } }
public static void SendResolveResponse(IPacketReceiver client, Ticket ticket) { ticket.Delete(); using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GMTICKET_RESOLVE_RESPONSE, 4)) { packet.WriteByte(0); client.Send(packet); } #endregion }
/// <summary> /// Sends a character delete reply to the client. /// </summary> /// <param name="client">the client to send to</param> /// <param name="error">the rror code</param> public static void SendCharDeleteReply(IRealmClient client, LoginErrorCode error) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_DELETE, 1)) { packet.WriteByte((byte)error); client.Send(packet); } SendCharEnum(client); }
public void TestParsedSegment() { PacketDefinition def = new PacketDefinition(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT, PacketSender.Client, new PacketSegmentStructure(SimpleType.UInt, "SpellAttributes", typeof(SpellAttributes)), new ListPacketSegmentStructure(SimpleType.Byte, "Members", new PacketSegmentStructure(SimpleType.Guid, "MemberId"), new PacketSegmentStructure(SimpleType.CString, "Name") ), new SwitchPacketSegmentStructure("Attribute Switch", "SpellAttributes", new SwitchCase(ComparisonType.And, SpellAttributes.CannotBeCastInCombat, new PacketSegmentStructure(SimpleType.CString, "NoCombatString") ), new SwitchCase(ComparisonType.And, SpellAttributes.CannotBeCastInCombat | SpellAttributes.CastableWhileMounted, new PacketSegmentStructure(SimpleType.CString, "NoCombatNoDismountString") ) ), new SwitchPacketSegmentStructure("List Switch", "Members", new SwitchCase(ComparisonType.Equal, (byte)0, new PacketSegmentStructure(SimpleType.Byte, "Status", "CharacterStatus"), new SwitchPacketSegmentStructure("Nested Switch", "Status", new SwitchCase(ComparisonType.AndNot, CharacterStatus.OFFLINE, new PacketSegmentStructure(SimpleType.UInt, "NumX") ) ) ), new SwitchCase(ComparisonType.GreaterThan, (byte)0, new PacketSegmentStructure(SimpleType.CString, "Info") ) ), new StaticListPacketSegmentStructure(1, "StaticList1", new PacketSegmentStructure(SimpleType.Int, "Number1") ), new StaticListPacketSegmentStructure(2, "StaticList2", new PacketSegmentStructure(SimpleType.Int, "Number2") ), new PacketSegmentStructure(SimpleType.Byte, "ListLength"), new ListPacketSegmentStructure("SomeList3", "ListLength", new PacketSegmentStructure(SimpleType.Int, "SomeListEle") ) ); def.Init(); using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT)) { packet.WriteUInt((uint)(SpellAttributes.CastableWhileMounted | SpellAttributes.CannotBeCastInCombat)); packet.WriteByte(2); packet.Write(EntityId.Zero); packet.WriteCString("Member1Name"); packet.Write(new EntityId(10)); packet.WriteCString("Member2Name"); packet.WriteCString("NoCombat"); packet.WriteCString("NoCombatNoDismount"); packet.WriteCString("lotsofinfo"); // StaticList1 packet.WriteInt(10); // StaticList2 packet.WriteInt(20); packet.WriteInt(30); // SomeList3's length packet.WriteByte(2); // SomeList3 packet.WriteInt(5); packet.WriteInt(7); var parsedPacket = PacketParser.Parse(packet, PacketSender.Client, def); Assert.AreEqual("NoCombat", parsedPacket["NoCombatString"].StringValue); Assert.AreEqual("NoCombatNoDismount", parsedPacket["NoCombatNoDismountString"].StringValue); var members = parsedPacket["Members"]; Assert.AreEqual(EntityId.Zero, members[0]["MemberId"].EntityIdValue); Assert.AreEqual("Member1Name", members[0]["Name"].StringValue); Assert.AreEqual("Member2Name", members[1]["Name"].StringValue); Assert.AreEqual("lotsofinfo", parsedPacket["Info"].StringValue); CheckRemainder(parsedPacket); } using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT)) { packet.WriteUInt((uint)SpellAttributes.None); packet.WriteByte(0); packet.Write((byte)CharacterStatus.ONLINE); packet.Write((uint)1234); packet.WriteInt(10); packet.WriteInt(20); packet.WriteInt(30); // SomeList3's length packet.WriteByte(2); // SomeList3 packet.WriteInt(5); packet.WriteInt(7); var parsedPacket = PacketParser.Parse(packet, PacketSender.Client, def); Assert.IsNull(parsedPacket.GetByName("Info")); Assert.AreEqual(CharacterStatus.ONLINE, parsedPacket["Status"].Value); Assert.AreEqual((uint)1234, parsedPacket["NumX"].Value); CheckRemainder(parsedPacket); } }
public static void SendPlayedTime(IRealmClient client, byte display) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PLAYED_TIME, 8)) { packet.WriteUInt(client.ActiveCharacter.TotalPlayTime); packet.WriteUInt(client.ActiveCharacter.LevelPlayTime); packet.WriteByte(display); client.Send(packet); } }
/// <summary> /// Send a custom cooldown time to the client /// </summary> public static void SendSpellCooldown(WorldObject caster, IRealmClient client, uint spellId, ushort cooldown) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SPELL_COOLDOWN, 14)) { packet.Write(caster.EntityId.Full); packet.WriteByte(0x00);// 1 = use category cooldown packet.Write(spellId); packet.Write((uint)cooldown); // if > 0, use this. If 0, use spell.RecoveryTime client.Send(packet); } }
public void TestEmptyStructure() { var def = new PacketDefinition(RealmServerOpCode.CMSG_SET_CHANNEL_WATCH, PacketSender.Client, new List<PacketSegmentStructure>()); def.Init(); using (var packet = new RealmPacketOut(RealmServerOpCode.CMSG_PLAYER_AI_CHEAT)) { packet.WriteUInt((uint)SpellAttributes.CannotRemove); packet.WriteByte(0); using (var packetIn = DisposableRealmPacketIn.CreateFromOutPacket(packet)) { var parsedPacket = PacketParser.Parse(packetIn, PacketSender.Client, def); Assert.AreEqual(0, parsedPacket.SubSegments.Count); } } }
public static void SendCharacterRenameError(IPacketReceiver client, LoginErrorCode error) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_RENAME, 1)) { packet.WriteByte((byte)error); client.Send(packet); } }
/// <summary> /// Sends the response of a member to the original ready check requester. /// </summary> /// <param name="member">the responding member</param> /// <param name="status">their ready status</param> public void SendReadyCheckResponse(GroupMember member, ReadyCheckStatus status) { using (var packet = new RealmPacketOut(RealmServerOpCode.MSG_RAID_READY_CHECK_CONFIRM)) { packet.Write(EntityId.GetPlayerId(member.Id)); packet.WriteByte((byte)status); Character checkRequester = World.GetCharacter(m_readyCheckRequester.Id); if (checkRequester != null) checkRequester.Client.Send(packet); } }
/// <summary> /// Sends an auth session error response to the client. /// </summary> /// <param name="client">the client to send to</param> /// <param name="error">the error code</param> public static void SendAuthSessionErrorReply(IPacketReceiver client, LoginErrorCode error) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUTH_RESPONSE, 1)) { packet.WriteByte((byte)error); client.Send(packet); } }
public static void SendNameInvalid(IPacketReceiver receiver, PetNameInvalidReason reason, string name) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_PET_NAME_INVALID)) { packet.Write((uint)reason); packet.WriteCString(name); packet.WriteByte(0); receiver.Send(packet); } }
public static void SendAuthSuccessful(IRealmClient client) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUTH_RESPONSE, 11)) { packet.WriteByte((byte)LoginErrorCode.AUTH_OK); //BillingTimeRemaining packet.Write(0); packet.Write((byte)0x02);// BillingPlan Flags // 0x2, 0x4, 0x10 mutually exclusive. Order of Precedence: 0x2 > 0x4 > 0x10 // 0x2 -> No Time left? // 0x20 // 0x8 // BillingTimeRested packet.Write(0); packet.Write((byte)client.Account.ClientId); client.Send(packet); } ClientAddonHandler.SendAddOnInfoPacket(client); RealmServer.Instance.OnClientAccepted(null, null); }
/// <summary> /// item1 and item2 can be null, but item1 must be set in case of YOU_MUST_REACH_LEVEL_N. /// </summary> /// <param name="client"></param> /// <param name="item1"></param> /// <param name="item2"></param> /// <param name="error"></param> public static void SendInventoryError(IPacketReceiver client, Item item1, Item item2, InventoryError error) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_INVENTORY_CHANGE_FAILURE, error == InventoryError.YOU_MUST_REACH_LEVEL_N ? 22 : 18)) { packet.WriteByte((byte)error); if (item1 != null) { packet.Write(item1.EntityId.Full); } else { packet.Write((long)0); } if (item2 != null) { packet.Write(item2.EntityId.Full); } else { packet.Write((long)0); } packet.Write((byte)0); if (error == InventoryError.YOU_MUST_REACH_LEVEL_N && item1 != null) { packet.WriteUInt(item1.Template.RequiredLevel); } client.Send(packet); } }
/// <summary> /// Sends the number of currently queued clients. /// </summary> /// <param name="client">the client to send to</param> public static void SendAuthQueueStatus(IRealmClient client) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_AUTH_RESPONSE)) { packet.WriteByte((byte)LoginErrorCode.AUTH_WAIT_QUEUE); packet.Write(AuthQueue.QueuedClients + 1); client.Send(packet); } }
/// <summary> /// Offers the reward of the given Quest to the given Character. /// When replying the Quest will be complete. /// </summary> /// <param name="questGiver">The qg.</param> /// <param name="qt">The quest id.</param> /// <param name="chr">The client.</param> public static void SendQuestGiverOfferReward(IEntity questGiver, QuestTemplate qt, Character chr) { //if (questGiver.QuestHolderInfo != null) //var list = qg.QuestHolderInfo.QuestEnds; //if (list != null && list.Contains(qt)) var locale = chr.Locale; using (var pckt = new RealmPacketOut(RealmServerOpCode.SMSG_QUESTGIVER_OFFER_REWARD)) { pckt.Write(questGiver.EntityId); pckt.WriteUInt(qt.Id); pckt.WriteCString(qt.Titles.Localize(locale)); pckt.WriteCString(qt.OfferRewardTexts.Localize(locale)); pckt.WriteByte((byte)(qt.FollowupQuestId > 0 ? 1 : 0)); pckt.WriteUInt((uint)qt.Flags); pckt.WriteUInt(qt.SuggestedPlayers); // Suggested Group Num pckt.Write(qt.OfferRewardEmotes.Length); for (uint i = 0; i < qt.OfferRewardEmotes.Length; i++) { pckt.Write(qt.OfferRewardEmotes[i].Delay); pckt.Write((uint)qt.OfferRewardEmotes[i].Type); } pckt.Write(qt.RewardChoiceItems.Length); for (var i = 0; i < qt.RewardChoiceItems.Length; i++) { pckt.Write((uint)qt.RewardChoiceItems[i].ItemId); pckt.Write(qt.RewardChoiceItems[i].Amount); var template = qt.RewardChoiceItems[i].Template; if (template != null) { pckt.Write(template.DisplayId); } else { pckt.Write(0); } } pckt.Write(qt.RewardItems.Length); for (var i = 0; i < qt.RewardItems.Length; i++) { pckt.Write((uint)qt.RewardItems[i].ItemId); pckt.Write(qt.RewardItems[i].Amount); var template = qt.RewardItems[i].Template; if (template != null) { pckt.WriteUInt(template.DisplayId); } else { pckt.Write(0); } } if (chr.Level >= RealmServerConfiguration.MaxCharacterLevel) { pckt.Write(qt.MoneyAtMaxLevel); } else { pckt.Write(qt.RewMoney); } pckt.Write(qt.CalcRewardXp(chr)); pckt.Write(qt.CalcRewardHonor(chr)); // honor points pckt.Write(qt.RewHonorMultiplier); // since 3.3 pckt.Write((uint)0x08); // unused by client if (qt.RewSpell > 0) { pckt.Write((uint)qt.RewSpell); } else { pckt.Write((uint)qt.RewSpellCast); } pckt.Write((uint)qt.CastSpell); pckt.Write((uint)qt.RewardTitleId); pckt.Write(qt.RewardTalents); // reward talents pckt.Write(0); // since 3.3 pckt.Write(0); // since 3.3 // #### since 3.3 for (uint i = 0; i < QuestConstants.MaxReputations; i++) pckt.Write((uint)qt.RewardReputations[i].Faction); for (uint i = 0; i < QuestConstants.MaxReputations; i++) pckt.Write(qt.RewardReputations[i].ValueId); for (uint i = 0; i < QuestConstants.MaxReputations; i++) pckt.Write(qt.RewardReputations[i].Value); // ###### chr.Client.Send(pckt); } }
/// <summary> /// Sends a "character login failed" error message to the client. /// </summary> /// <param name="client">the client to send to</param> /// <param name="error">the actual login error</param> public static void SendCharacterLoginFail(IPacketReceiver client, LoginErrorCode error) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHARACTER_LOGIN_FAILED, 1)) { packet.WriteByte((byte)error); client.Send(packet); } }
/// <summary> /// Sends the character list to the client. /// </summary> /// <param name="client">the client to send to</param> /// <remarks>They probably meant 'enumeration,' but 'list' would have made so much more sense. :)</remarks> public static void SendCharEnum(IRealmClient client) { CharacterRecord curRecord = null; try { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CHAR_ENUM)) { var chrs = client.Account.Characters; packet.WriteByte(chrs.Count); foreach (var record in chrs) { curRecord = record; packet.Write(EntityId.GetPlayerId(record.EntityLowId)); // 8 packet.WriteCString(record.Name); // 9 + namelength packet.Write((byte)record.Race); // 10 + namelength packet.Write((byte)record.Class); // 11 + namelength packet.Write((byte)record.Gender); // 12 + namelength packet.Write(record.Skin); // 13 + namelength packet.Write(record.Face); // 14 + namelength packet.Write(record.HairStyle); // 15 + namelength packet.Write(record.HairColor); // 16 + namelength packet.Write(record.FacialHair); // 17 + namelength packet.Write((byte)record.Level); // 18 + namelength packet.Write((int)record.Zone); // 22 + namelength packet.Write((int)record.MapId); // 26 + namelength packet.Write(record.PositionX); // 30 + namelength packet.Write(record.PositionY); // 34 + namelength packet.Write(record.PositionZ); // 38 + namelength packet.WriteUInt(record.GuildId); // guild id // 42 + namelength packet.Write((int)record.CharacterFlags); // 46 + namelength packet.Write(0); // TOOD: Customization flags packet.Write((byte)1); // NEW 3.2.0 - first login y/n - set to 1 for now // Deprecated: Rest State // var restState = record.RestXp > 0 ? RestState.Resting : RestState.Normal; // packet.WriteByte((byte)restState); // 47 + namelength // pet info (51 - 63) var petEntry = record.PetEntry; if (petEntry != null) { packet.Write(petEntry.DisplayIds[0]); packet.Write(record.Level); // liars! packet.Write((int)petEntry.FamilyId); } else { packet.Write(0); // 51 + namelength packet.Write(0); // 55 + namelength packet.Write(0); // 59 + namelength } var itemOffset = packet.Position; //packet.TotalLength += CharEnumItemCount * CharEnumItemBytes; // 239 + namelength packet.Zero(CharEnumItemCount * CharEnumItemBytes); packet.Position = itemOffset; if (record.JustCreated) { var archetype = ArchetypeMgr.GetArchetype(record.Race, record.Class); if (archetype != null) { var items = archetype.GetInitialItems(record.Gender); foreach (var item in items) { var template = item.Template; if (template.EquipmentSlots != null) { packet.Position = itemOffset + ((int)template.EquipmentSlots[0] * CharEnumItemBytes); packet.Write(template.DisplayId); packet.Write((byte)template.InventorySlotType); packet.Write(0); } } } else { log.Warn("Invalid Race/Class combination " + "({0} {1}) in CharacterRecord {2}.", record.Race, record.Class, record); } } else { foreach (var item in record.GetOrLoadItems()) { if (!item.IsOwned) { continue; } var template = item.Template; if (item.ContainerSlot == BaseInventory.INVALID_SLOT && item.Slot <= (int)EquipmentSlot.Bag4) { packet.Position = itemOffset + (item.Slot * CharEnumItemBytes); if (template != null) { var enchant = item.GetEnchant(EnchantSlot.Permanent); packet.Write(template.DisplayId); packet.Write((byte)template.InventorySlotType); packet.Write(enchant != null ? enchant.Visual : 0); } else { packet.Write(0); packet.Write((byte)0); packet.Write(0); } } } } packet.Position = itemOffset + (CharEnumItemCount * CharEnumItemBytes); } client.Send(packet); } } catch (Exception e) { if (curRecord == null) { throw e; } LogUtil.ErrorException(e, "Could not create Char-Enum " + "for Character \"{0}\" (Race: {1}, Class: {2}, Level: {3}, Map: {4}{5}).", curRecord, curRecord.Race, curRecord.Class, curRecord.Level, curRecord.MapId, curRecord.IsNew ? ", [New]" : ""); } }
/// <summary> /// Sends the new state of the trading window to other party /// </summary> /// <param name="otherParty">Whether this is sending the own info to the other party (or, if false, to oneself)</param> /// <param name="client">receiving party</param> /// <param name="money">new amount of money</param> /// <param name="items">new items</param> public static void SendTradeUpdate(IPacketReceiver client, bool otherParty, uint money, Item[] items) { using (var pkt = new RealmPacketOut(RealmServerOpCode.SMSG_TRADE_STATUS_EXTENDED, 30 + 18 * 4 * items.Length)) { pkt.Write(otherParty); pkt.Write(0); // Trade id pkt.Write(items.Length); pkt.Write(items.Length); pkt.Write(money); pkt.Write(0); for (var i = 0; i < items.Length; i++) { pkt.WriteByte(i); var item = items[i]; if (item != null) { pkt.Write(item.EntryId); pkt.Write(item.Template.DisplayId); pkt.Write(item.Amount); pkt.Write(0); pkt.Write(item.GiftCreator); var enchant = item.GetEnchantment(EnchantSlot.Permanent); pkt.Write(enchant != null ? enchant.Entry.Id : 0); pkt.Zero(4 * 3); pkt.Write(item.Creator); pkt.Write(item.SpellCharges); pkt.Write(item.Template.RandomSuffixFactor); pkt.Write(item.RandomPropertiesId); var itemLock = item.Lock; pkt.Write(itemLock != null ? itemLock.Id : 0); pkt.Write(item.MaxDurability); pkt.Write(item.Durability); } else { pkt.Zero(18 * 4); } } client.Send(pkt); } }