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); }
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); }
/// <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); } }
/// <summary>Sends ping to the group, except pinger</summary> /// <param name="pinger">The group member who pingged the minimap</param> /// <param name="x">x coordinate of ping</param> /// <param name="y">y coordinate of ping</param> public virtual void SendPing(GroupMember pinger, float x, float y) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.MSG_MINIMAP_PING)) { packet.Write(EntityId.GetPlayerId(pinger.Id)); packet.WriteFloat(x); packet.WriteFloat(y); SendAll(packet, pinger); } }
public static void SendStartAtackCharacterResponseResponse(Character atacker, Character victim) { using (var packet = new RealmPacketOut(RealmServerOpCode.StartAtackCharacterResponse)) //4202 { packet.WriteByte(1); //{status}default value : 1 Len : 1 packet.WriteInt16(atacker.SessionId); //{atackerSessId}default value : 11 Len : 2 packet.WriteInt16(victim.SessionId); //{victimSessId}default value : 105 Len : 2 packet.WriteFloat(victim.Asda2X); //{x}default value : 0 Len : 4 packet.WriteFloat(victim.Asda2Y); //{y}default value : 0 Len : 4 atacker.SendPacketToArea(packet, true, true); } }
public static void SendStartAtackCharacterResponseResponse(Character atacker, Character victim) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.StartAtackCharacterResponse)) { packet.WriteByte(1); packet.WriteInt16(atacker.SessionId); packet.WriteInt16(victim.SessionId); packet.WriteFloat(victim.Asda2X); packet.WriteFloat(victim.Asda2Y); atacker.SendPacketToArea(packet, true, true, Locale.Any, new float?()); } }
public static void SendSetSpellMissilePosition(IPacketReceiver client, EntityId casterId, byte castCount, Vector3 position) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SET_PROJECTILE_POSITION, 21)) { casterId.WritePacked(packet); packet.WriteByte(castCount); packet.WriteFloat(position.X); packet.WriteFloat(position.Y); packet.WriteFloat(position.Z); client.Send(packet, addEnd: false); } }
public static void SendStartAtackCharacterError(Character atacker, Character victim, Asda2CharacterAtackStatus status) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.StartAtackCharacterResponse)) { packet.WriteByte((byte)status); packet.WriteInt16(atacker.SessionId); packet.WriteInt16(victim.SessionId); packet.WriteFloat(victim.Asda2X); packet.WriteFloat(victim.Asda2Y); atacker.Send(packet, true); } }
/// <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 (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_NPC_TEXT_UPDATE)) { packet.Write(text.GossipId); var i = 0; for (; i < text.GossipTexts.Length; i++) { var entry = text.GossipTexts[i]; packet.WriteFloat(entry.Probability); var maleText = entry.GetTextMale(character.GossipConversation); string femaleText; if (text.IsDynamic) { // generated dynamically anyway femaleText = maleText; } else { femaleText = entry.GetTextFemale(character.GossipConversation); } packet.WriteCString(maleText); packet.WriteCString(femaleText); packet.Write((uint)entry.Language); for (int emoteIndex = 0; emoteIndex < 3; emoteIndex++) { // TODO: Emotes //packet.Write((uint)entry.Emotes[emoteIndex]); //packet.Write(entry.EmoteDelays[emoteIndex]); packet.Write(0L); } } for (; i < 8; i++) { packet.WriteFloat(0); packet.WriteByte(0); packet.WriteByte(0); packet.Fill(0, 4 * 7); } character.Client.Send(packet, addEnd: false); } }
public static void SendSkillLearnedResponse(SkillLearnStatus status, Character ownerChar, uint id, int level) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SkillLearned)) { packet.WriteByte((byte)status); packet.WriteInt16(ownerChar.Spells.AvalibleSkillPoints); packet.WriteInt32(ownerChar.Money); packet.WriteInt16(id); packet.WriteByte(level); packet.WriteSkip(stab16); packet.WriteInt16(ownerChar.Asda2Strength); packet.WriteInt16(ownerChar.Asda2Agility); packet.WriteInt16(ownerChar.Asda2Stamina); packet.WriteInt16(ownerChar.Asda2Spirit); packet.WriteInt16(ownerChar.Asda2Intellect); packet.WriteInt16(ownerChar.Asda2Luck); packet.WriteInt16(0); packet.WriteInt16(0); packet.WriteInt16(0); packet.WriteInt16(0); packet.WriteInt16(0); packet.WriteInt16(0); packet.WriteInt16(ownerChar.Asda2Strength); packet.WriteInt16(ownerChar.Asda2Agility); packet.WriteInt16(ownerChar.Asda2Stamina); packet.WriteInt16(ownerChar.Asda2Spirit); packet.WriteInt16(ownerChar.Asda2Intellect); packet.WriteInt16(ownerChar.Asda2Luck); packet.WriteInt32(ownerChar.MaxHealth); packet.WriteInt16(ownerChar.MaxPower); packet.WriteInt32(ownerChar.Health); packet.WriteInt16(ownerChar.Power); packet.WriteInt16((short)ownerChar.MinDamage); packet.WriteInt16((short)ownerChar.MaxDamage); packet.WriteInt16(ownerChar.MinMagicDamage); packet.WriteInt16(ownerChar.MaxMagicDamage); packet.WriteInt16((short)ownerChar.Asda2MagicDefence); packet.WriteInt16((short)ownerChar.Asda2Defence); packet.WriteInt16((short)ownerChar.Asda2Defence); packet.WriteFloat(ownerChar.BlockChance); packet.WriteFloat(ownerChar.BlockValue); packet.WriteInt16(15); packet.WriteInt16(7); packet.WriteInt16(4); packet.WriteSkip(stub87); ownerChar.Send(packet, false); } }
/// <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 SendEndMoveByFastInstantRegularMoveResponse(Character chr) { using (var packet = new RealmPacketOut(RealmServerOpCode.StartMoveCommon)) //4007 { packet.WriteByte(1); //value name : _ packet.WriteInt16(chr.SessionId); //default value : 0 packet.WriteInt32(chr.Account.AccountId); //{accId}default value : 0 Len : 4 packet.WriteInt16(2); //value name : _ packet.WriteFloat(chr.Asda2X * 100); //default value : 1 packet.WriteFloat(chr.Asda2Y * 100); //default value : 1 packet.WriteFloat(chr.Asda2X * 100); //default value : 1 packet.WriteFloat(chr.Asda2Y * 100); //default value : 1 packet.WriteFloat(5); //default value : 1 packet.WriteInt16(-1); chr.SendPacketToArea(packet, true, true); } }
public static void SendEndMoveByFastInstantRegularMoveResponse(Character chr) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.StartMoveCommon)) { packet.WriteByte(1); packet.WriteInt16(chr.SessionId); packet.WriteInt32(chr.Account.AccountId); packet.WriteInt16(2); packet.WriteFloat(chr.Asda2X * 100f); packet.WriteFloat(chr.Asda2Y * 100f); packet.WriteFloat(chr.Asda2X * 100f); packet.WriteFloat(chr.Asda2Y * 100f); packet.WriteFloat(5); packet.WriteInt16(-1); chr.SendPacketToArea(packet, true, true, Locale.Any, new float?()); } }
public static void SendEndMoveCommonResponse(IRealmClient client, float x, float y, float x1, float y1, short target) { using (var packet = new RealmPacketOut(RealmServerOpCode.EndMoveCommon)) //4009 { packet.WriteByte(0); //{status}default value : 0 Len : 1 packet.WriteInt16(client.ActiveCharacter.SessionId); //{sessId}default value : 4 Len : 2 packet.WriteInt32(client.ActiveCharacter.AccId); //{accId}default value : -968818636 Len : 4 packet.WriteInt16(0); //value name : unk2 default value : 0Len : 2 packet.WriteFloat(x); //{x}default value : 9195,591 Len : 4 packet.WriteFloat(y); //{y}default value : 39978,21 Len : 4 packet.WriteFloat(x1); //{x1}default value : 9195,591 Len : 4 packet.WriteFloat(y1); //{y1}default value : 39978,21 Len : 4 packet.WriteInt32(0); //value name : unk13 default value : 0Len : 4 packet.WriteInt16(target); client.Send(packet); } }
public static RealmPacketOut CreateStartComonMovePacket(Character chr, bool instant) { RealmPacketOut realmPacketOut = new RealmPacketOut(RealmServerOpCode.StartMoveCommon); realmPacketOut.WriteByte(1); realmPacketOut.WriteInt16(chr.SessionId); realmPacketOut.WriteInt32(chr.Account.AccountId); realmPacketOut.WriteInt16(2); realmPacketOut.WriteFloat(chr.Asda2X * 100f); realmPacketOut.WriteFloat(chr.Asda2Y * 100f); realmPacketOut.WriteFloat(instant ? chr.Asda2X * 100f : chr.LastNewPosition.X * 100f); realmPacketOut.WriteFloat(instant ? chr.Asda2Y * 100f : chr.LastNewPosition.Y * 100f); realmPacketOut.WriteFloat(instant ? 5f : chr.RunSpeed); NPC target = chr.Target as NPC; realmPacketOut.WriteInt16(target == null ? -1 : (int)target.UniqIdOnMap); return(realmPacketOut); }
public static void SendStartComonMovePacketError(Character chr, bool instant, Asda2StartMovementStatus status) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.StartMoveCommon)) { packet.WriteByte((byte)status); packet.WriteInt16(chr.SessionId); packet.WriteInt32(chr.Account.AccountId); packet.WriteInt16(2); packet.WriteFloat(chr.Asda2X * 100f); packet.WriteFloat(chr.Asda2Y * 100f); packet.WriteFloat(instant ? chr.Asda2X * 100f : chr.LastNewPosition.X * 100f); packet.WriteFloat(instant ? chr.Asda2Y * 100f : chr.LastNewPosition.Y * 100f); packet.WriteFloat(instant ? 5f : chr.RunSpeed); NPC target = chr.Target as NPC; packet.WriteInt16(target == null ? 0 : (int)target.UniqIdOnMap); chr.Send(packet, true); } }
public static RealmPacketOut CreateStartComonMovePacket(Character chr, bool instant) { var packet = new RealmPacketOut(RealmServerOpCode.StartMoveCommon); //4007 packet.WriteByte(1); //value name : _ packet.WriteInt16(chr.SessionId); //default value : 0 packet.WriteInt32(chr.Account.AccountId); //{accId}default value : 0 Len : 4 packet.WriteInt16(2); //value name : _ packet.WriteFloat(chr.Asda2X * 100); //default value : 1 packet.WriteFloat(chr.Asda2Y * 100); //default value : 1 packet.WriteFloat(instant?chr.Asda2X * 100:chr.LastNewPosition.X * 100); //default value : 1 packet.WriteFloat(instant ? chr.Asda2Y * 100 : chr.LastNewPosition.Y * 100); //default value : 1 packet.WriteFloat(instant?5 : chr.RunSpeed); //default value : 1 var target = chr.Target as NPC; packet.WriteInt16(target == null?-1:target.UniqIdOnMap); return(packet); }
public static void SendEndMoveCommonResponse(IRealmClient client, float x, float y, float x1, float y1, short target) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.EndMoveCommon)) { packet.WriteByte(0); packet.WriteInt16(client.ActiveCharacter.SessionId); packet.WriteInt32(client.ActiveCharacter.AccId); packet.WriteInt16(0); packet.WriteFloat(x); packet.WriteFloat(y); packet.WriteFloat(x1); packet.WriteFloat(y1); packet.WriteInt32(0); packet.WriteInt16(target); client.Send(packet, false); } }
public static void SendStartComonMovePacketError(Character chr, bool instant, Asda2StartMovementStatus status) { using (var packet = new RealmPacketOut(RealmServerOpCode.StartMoveCommon)) //4007 { packet.WriteByte((byte)status); //value name : _ packet.WriteInt16(chr.SessionId); //default value : 0 packet.WriteInt32((int)chr.Account.AccountId); //{accId}default value : 0 Len : 4 packet.WriteInt16(2); //value name : _ packet.WriteFloat(chr.Asda2X * 100); //default value : 1 packet.WriteFloat(chr.Asda2Y * 100); //default value : 1 packet.WriteFloat(instant ? chr.Asda2X * 100 : chr.LastNewPosition.X * 100); //default value : 1 packet.WriteFloat(instant ? chr.Asda2Y * 100 : chr.LastNewPosition.Y * 100); //default value : 1 packet.WriteFloat(instant ? 5 : chr.RunSpeed); //default value : 1 var target = chr.Target as NPC; packet.WriteInt16(target == null ? 0 : target.UniqIdOnMap); chr.Send(packet, addEnd: true); } }
/// <summary>Sends a simple npc text update to the character</summary> /// <param name="character">recieving character</param> /// <param name="id">id of text to update</param> /// <param name="title">gossip window's title</param> /// <param name="text">gossip window's text</param> public static void SendNPCTextUpdateSimple(Character character, uint id, string title, string text) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_NPC_TEXT_UPDATE)) { packet.Write(id); packet.WriteFloat(1); packet.WriteCString(title); packet.WriteCString(text); packet.Fill((byte)0, 28); for (int index = 1; index < 8; ++index) { packet.WriteFloat(0); packet.WriteByte(0); packet.WriteByte(0); packet.Fill((byte)0, 28); } character.Client.Send(packet, false); } }
/// <summary> /// Sends a simple npc text update to the character /// </summary> /// <param name="character">recieving character</param> /// <param name="id">id of text to update</param> /// <param name="title">gossip window's title</param> /// <param name="text">gossip window's text</param> public static void SendNPCTextUpdateSimple(Character character, uint id, string title, string text) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_NPC_TEXT_UPDATE)) { packet.Write(id); packet.WriteFloat(1); packet.WriteCString(title); packet.WriteCString(text); packet.Fill(0, 4 * 7); for (var i = 1; i < 8; i++) { packet.WriteFloat(0); packet.WriteByte(0); packet.WriteByte(0); packet.Fill(0, 4 * 7); } character.Client.Send(packet, addEnd: false); } }
public static void SendSetFlightBackSpeed(Unit unit) { if (!unit.IsAreaActive) { return; } using (var packet = new RealmPacketOut(RealmServerOpCode.MSG_MOVE_SET_FLIGHT_BACK_SPEED, 43)) { unit.EntityId.WritePacked(packet); unit.WriteMovementPacketInfo(packet); packet.WriteFloat(unit.FlightBackSpeed); unit.SendPacketToArea(packet, true); } }
public static void SendSetTurnRate(Unit unit) { if (!unit.IsAreaActive) { return; } using (var packet = new RealmPacketOut(RealmServerOpCode.MSG_MOVE_SET_TURN_RATE, 43)) { unit.EntityId.WritePacked(packet); unit.WriteMovementPacketInfo(packet); packet.WriteFloat(unit.TurnSpeed); unit.SendPacketToArea(packet, true); } }
public static void HandleAuctionListPendingSales(IRealmClient client, RealmPacketIn packet) { client.ActiveCharacter.Map.GetObject(packet.ReadEntityId()); uint num = 1; using (RealmPacketOut packet1 = new RealmPacketOut(RealmServerOpCode.SMSG_AUCTION_LIST_PENDING_SALES, 14 * (int)num)) { packet1.Write(num); for (int index = 0; (long)index < (long)num; ++index) { packet1.Write(""); packet1.Write(""); packet1.WriteUInt(0); packet1.WriteUInt(0); packet1.WriteFloat(0.0f); client.Send(packet1, false); } } }
public static void HandleAuctionListPendingSales(IRealmClient client, RealmPacketIn packet) { var chr = client.ActiveCharacter; var auctioneerId = packet.ReadEntityId(); var auctioneer = chr.Map.GetObject(auctioneerId) as NPC; var count = 1u; using (var packetOut = new RealmPacketOut(RealmServerOpCode.SMSG_AUCTION_LIST_PENDING_SALES, 14 * (int)count)) { packetOut.Write(count); for (var i = 0; i < count; ++i) { packetOut.Write(""); packetOut.Write(""); packetOut.WriteUInt(0); packetOut.WriteUInt(0); packetOut.WriteFloat(0f); client.Send(packetOut); } } }
//[ClientPacketHandler((RealmServerOpCode.CMSG_AUCTION_LIST_PENDING_SALES)] public static void HandleAuctionListPendingSales(IRealmClient client, RealmPacketIn packet) { var chr = client.ActiveCharacter; var auctioneerId = packet.ReadEntityId(); var auctioneer = chr.Map.GetObject(auctioneerId) as NPC; var count = 1u; using (var packetOut = new RealmPacketOut(RealmServerOpCode.SMSG_AUCTION_LIST_PENDING_SALES, 14 * (int)count)) { packetOut.Write(count); for (var i = 0; i < count; ++i) { packetOut.Write(""); packetOut.Write(""); packetOut.WriteUInt(0); packetOut.WriteUInt(0); packetOut.WriteFloat(0f); client.Send(packetOut, addEnd: false); } } }
public static void SendNewWorld(IRealmClient client, MapId map, ref Vector3 pos, float orientation) { var chr = client.ActiveCharacter; var trans = chr.Transport; // opens loading screen using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_TRANSFER_PENDING, 4)) { packet.WriteUInt((uint)map); if (trans != null) { packet.Write((uint)trans.Entry.Id); packet.Write((uint)chr.MapId); } client.Send(packet); } // sends new world info using (var outPacket = new RealmPacketOut(RealmServerOpCode.SMSG_NEW_WORLD, 20)) { outPacket.WriteUInt((uint)map); if (trans != null) { outPacket.Write(chr.TransportPosition); outPacket.Write(chr.TransportOrientation); } else { outPacket.Write(pos); outPacket.WriteFloat(orientation); } client.Send(outPacket); } // client will ask for re-initialization afterwards }
public static void SendItemQueryResponse(IRealmClient client, ItemTemplate item) { ClientLocale locale = client.Info.Locale; using (RealmPacketOut packet = new RealmPacketOut((PacketId)RealmServerOpCode.SMSG_ITEM_QUERY_SINGLE_RESPONSE, 630)) { packet.Write(item.Id); packet.Write((uint)item.Class); packet.Write((uint)item.SubClass); packet.Write(item.Unk0); packet.WriteCString(item.Names.Localize(locale)); packet.Write((byte)0); packet.Write((byte)0); packet.Write((byte)0); packet.Write(item.DisplayId); packet.Write((uint)item.Quality); packet.Write((uint)item.Flags); packet.Write((uint)item.Flags2); packet.Write(item.BuyPrice); packet.Write(item.SellPrice); packet.Write((uint)item.InventorySlotType); packet.Write((uint)item.RequiredClassMask); packet.Write((uint)item.RequiredRaceMask); packet.Write(item.Level); packet.Write(item.RequiredLevel); packet.Write(item.RequiredSkill != null ? (int)item.RequiredSkill.Id : 0); packet.Write(item.RequiredSkillValue); packet.Write(item.RequiredProfession != null ? item.RequiredProfession.Id : 0U); packet.Write(item.RequiredPvPRank); packet.Write(item.UnknownRank); packet.Write(item.RequiredFaction != null ? (int)item.RequiredFaction.Id : 0); packet.Write((uint)item.RequiredFactionStanding); packet.Write(item.UniqueCount); packet.Write(item.MaxAmount); packet.Write(item.ContainerSlots); packet.Write(item.Mods.Length); for (int index = 0; index < item.Mods.Length; ++index) { packet.Write((uint)item.Mods[index].Type); packet.Write(item.Mods[index].Value); } packet.Write(item.ScalingStatDistributionId); packet.Write(item.ScalingStatValueFlags); for (int index = 0; index < 2; ++index) { if (index >= item.Damages.Length) { packet.WriteFloat(0.0f); packet.WriteFloat(0.0f); packet.WriteUInt(0U); } else { DamageInfo damage = item.Damages[index]; packet.Write(damage.Minimum); packet.Write(damage.Maximum); packet.Write((uint)damage.School); } } for (int index = 0; index < 7; ++index) { int resistance = item.Resistances[index]; packet.Write(resistance); } packet.Write(item.AttackTime); packet.Write((uint)item.ProjectileType); packet.Write(item.RangeModifier); for (int index = 0; index < 5; ++index) { ItemSpell spell; if (index < item.Spells.Length && (spell = item.Spells[index]) != null) { packet.Write((uint)spell.Id); packet.Write((uint)spell.Trigger); packet.Write((uint)Math.Abs(spell.Charges)); packet.Write(spell.Cooldown); packet.Write(spell.CategoryId); packet.Write(spell.CategoryCooldown); } else { packet.WriteUInt(0U); packet.WriteUInt(0U); packet.WriteUInt(0U); packet.Write(-1); packet.WriteUInt(0U); packet.Write(-1); } } packet.Write((uint)item.BondType); packet.WriteCString(item.Descriptions.Localize(locale)); packet.Write(item.PageTextId); packet.Write((uint)item.LanguageId); packet.Write((uint)item.PageMaterial); packet.Write(item.QuestId); packet.Write(item.LockId); packet.Write((int)item.Material); packet.Write((uint)item.SheathType); packet.Write(item.RandomPropertiesId); packet.Write(item.RandomSuffixId); packet.Write(item.BlockValue); packet.Write((uint)item.SetId); packet.Write(item.MaxDurability); packet.Write((uint)item.ZoneId); packet.Write((uint)item.MapId); packet.Write((uint)item.BagFamily); packet.Write((uint)item.ToolCategory); for (int index = 0; index < 3; ++index) { packet.Write((uint)item.Sockets[index].Color); packet.Write(item.Sockets[index].Content); } packet.Write(item.SocketBonusEnchantId); packet.Write(item.GemPropertiesId); packet.Write(item.RequiredDisenchantingLevel); packet.Write(item.ArmorModifier); packet.Write(item.Duration); packet.Write(item.ItemLimitCategoryId); packet.Write(item.HolidayId); client.Send(packet, false); } }
/// <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); } }
/// <summary> /// Sends experience gained notifications to the character /// OPCODE: SMS_LOG_XPGAIN /// </summary> /// <param name="client">the client to send to</param> /// <param name="xpReceived">the amout of experience gained</param> /// <param name="victim">the xp resource, NPC if the experience is gained through combat, otherwise null (quests etc.)</param> /// <param name="xpRestBonus">the rest bonus experience amount (default 0)</param> public static void SendXpReceivedNotification(IPacketReceiver client, int xpReceived, INamed victim = null, int xpRestBonus = 0) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOG_XPGAIN)) { var xpSourceEntity = victim as NPC; packet.Write(xpSourceEntity != null ? xpSourceEntity.EntityId : EntityId.Zero); packet.Write(xpReceived + xpRestBonus); packet.WriteByte(xpSourceEntity != null ? 0 : 1); if (xpSourceEntity != null) { packet.Write(xpReceived); packet.WriteFloat(1); } packet.WriteByte(0); client.Send(packet); } }
public static void SendItemQueryResponse(RealmClient client, ItemTemplate item) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_QUERY_SINGLE_RESPONSE, 630)) { packet.Write(item.Id); packet.WriteInt((int)item.ItemClass); packet.WriteInt((int)item.ItemSubClass); packet.WriteInt(-1); // unknown packet.WriteCString(item.Name); packet.WriteByte(0);// name2 packet.WriteByte(0);// name3 packet.WriteByte(0);// name4 packet.WriteInt(item.DisplayId); packet.WriteInt((int)item.Quality); packet.WriteInt((int)item.Flags); packet.WriteInt(item.BuyPrice); packet.WriteInt(item.SellPrice); packet.WriteInt((int)item.InventorySlot); packet.WriteInt((int)item.RequiredClassMask); packet.WriteInt((int)item.RequiredRaceMask); packet.WriteInt(item.Level); packet.WriteInt(item.RequiredLevel); packet.WriteInt(item.RequiredSkill != null ? (int)item.RequiredSkill.Id : 0); packet.WriteInt(item.RequiredSkillLevel); packet.WriteInt(item.RequiredProfession != null ? (int)item.RequiredProfession.Id : 0); packet.WriteInt(item.RequiredPvPRank); packet.WriteInt(item.UnknownRank);// city rank? packet.WriteInt(item.RequiredFaction != null ? (int)item.RequiredFaction.Id : 0); packet.WriteInt((int)item.RequiredFactionStanding); packet.WriteInt(item.UniqueCount); packet.WriteInt(item.MaxAmount); packet.WriteInt(item.ContainerSlots); foreach (var stat in item.Mods) { packet.WriteUInt((uint)stat.Type); packet.WriteInt(stat.Value); } foreach (var dmg in item.Damages) { packet.WriteFloat(dmg.Minimum); packet.WriteFloat(dmg.Maximum); packet.WriteUInt((uint)dmg.DamageSchool); } foreach (var res in item.Resistances) { packet.WriteUInt(res); } packet.WriteUInt(item.WeaponSpeed); packet.WriteUInt((uint)item.ProjectileType); packet.WriteFloat(item.RangeModifier); for (int i = 0; i < 5; i++) { packet.WriteUInt(item.Spells[i].Id); packet.WriteUInt((int)item.Spells[i].Trigger); packet.WriteUInt(item.Spells[i].Charges); packet.WriteInt(item.Spells[i].Cooldown); packet.WriteUInt(item.Spells[i].CategoryId); packet.WriteInt(item.Spells[i].CategoryCooldown); } packet.WriteUInt((int)item.BondType); packet.WriteCString(item.Description); packet.Write(item.PageTextId); packet.Write(item.PageCount); packet.Write(item.PageMaterial); packet.Write(item.QuestId); packet.Write(item.RequiredLockpickSkill); packet.Write(item.Material); packet.Write((uint)item.SheathType); packet.Write(item.RandomPropertyId); packet.Write(item.RandomSuffixId); packet.Write(item.BlockValue); packet.Write(item.SetId); packet.Write(item.MaxDurability); packet.Write((uint)item.ZoneId); packet.Write((uint)item.MapId); packet.Write((uint)item.BagFamily); packet.Write(item.TotemCategory); for (int i = 0; i < ItemTemplate.MaxSocketCount; i++) { packet.WriteInt(item.Sockets[i].SocketColor); packet.WriteInt(item.Sockets[i].Unknown); } packet.WriteInt(item.SocketBonusId); packet.WriteInt(item.GemProperties); packet.WriteInt(item.ExtendedCost); packet.WriteInt(item.RequiredArenaRanking); packet.WriteInt(item.RequiredDisenchantingLevel); packet.WriteFloat(item.ArmorModifier); client.Send(packet); } }
/// <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 (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_NPC_TEXT_UPDATE)) { packet.Write(text.GossipId); var i = 0; for (; i < text.GossipEntries.Length; i++) { var entry = text.GossipEntries[i]; packet.WriteFloat(entry.Probability); var isMaleTextEmpty = string.IsNullOrEmpty(entry.TextMale); var isFemaleTextEmpty = string.IsNullOrEmpty(entry.TextFemale); if (isMaleTextEmpty && isFemaleTextEmpty) { packet.WriteCString(" "); packet.WriteCString(" "); } else if (isMaleTextEmpty) { packet.WriteCString(entry.TextFemale); packet.WriteCString(entry.TextFemale); } else if (isFemaleTextEmpty) { packet.WriteCString(entry.TextMale); packet.WriteCString(entry.TextMale); } else { packet.WriteCString(entry.TextMale); packet.WriteCString(entry.TextFemale); } packet.Write((uint)entry.Language); for (int emoteIndex = 0; emoteIndex < 3; emoteIndex++) { // TODO: Emotes //packet.Write((uint)entry.Emotes[emoteIndex]); //packet.Write(entry.EmoteDelays[emoteIndex]); packet.Write(0L); } } for (; i < 8; i++) { packet.WriteFloat(0); packet.WriteByte(0); packet.WriteByte(0); packet.Fill(0, 4 * 7); } character.Client.Send(packet); } }
public static void SendSetSpellMissilePosition(IPacketReceiver client, EntityId casterId, byte castCount, Vector3 position) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_SET_PROJECTILE_POSITION, 21)) { casterId.WritePacked(packet); packet.WriteByte(castCount); packet.WriteFloat(position.X); packet.WriteFloat(position.Y); packet.WriteFloat(position.Z); client.Send(packet); } }
/// <summary>Sends the quest query response.</summary> /// <param name="qt">The quest id.</param> /// <param name="chr">The client.</param> public static void SendQuestQueryResponse(QuestTemplate qt, Character chr) { ClientLocale locale = chr.Client.Info.Locale; using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_QUEST_QUERY_RESPONSE)) { packet.Write(qt.Id); packet.Write((uint)qt.IsActive); packet.Write(qt.Level); packet.Write(qt.MinLevel); packet.Write(qt.Category); packet.Write((uint)qt.QuestType); packet.Write(qt.SuggestedPlayers); packet.Write((uint)qt.ObjectiveMinReputation.ReputationIndex); packet.Write(qt.ObjectiveMinReputation.Value); packet.Write((uint)qt.ObjectiveMaxReputation.ReputationIndex); packet.Write(qt.ObjectiveMaxReputation.Value); packet.Write(qt.FollowupQuestId); packet.Write(qt.CalcRewardXp(chr)); if (qt.Flags.HasFlag(QuestFlags.HiddenRewards)) { packet.Write(0); } else { packet.Write(qt.RewMoney); } packet.Write(qt.MoneyAtMaxLevel); packet.Write((uint)qt.CastSpell); packet.Write((uint)qt.RewSpell); packet.Write(qt.RewHonorAddition); packet.WriteFloat(qt.RewHonorMultiplier); packet.Write((uint)qt.SrcItemId); packet.Write((uint)qt.Flags); packet.Write((uint)qt.RewardTitleId); packet.Write(qt.PlayersSlain); packet.Write(qt.RewardTalents); packet.Write(0); packet.Write(0); if (qt.Flags.HasFlag(QuestFlags.HiddenRewards)) { for (int index = 0; index < 4; ++index) { packet.WriteUInt(0U); packet.WriteUInt(0U); } for (int index = 0; index < 6; ++index) { packet.WriteUInt(0U); packet.WriteUInt(0U); } } else { for (int index = 0; index < 4; ++index) { if (index < qt.RewardItems.Length) { packet.Write((uint)qt.RewardItems[index].ItemId); packet.Write(qt.RewardItems[index].Amount); } else { packet.WriteUInt(0U); packet.WriteUInt(0U); } } for (int index = 0; index < 6; ++index) { if (index < qt.RewardChoiceItems.Length) { packet.Write((uint)qt.RewardChoiceItems[index].ItemId); packet.Write(qt.RewardChoiceItems[index].Amount); } else { packet.WriteUInt(0U); packet.WriteUInt(0U); } } } for (int index = 0; index < 5; ++index) { packet.Write((uint)qt.RewardReputations[index].Faction); } for (int index = 0; index < 5; ++index) { packet.Write(qt.RewardReputations[index].ValueId); } for (int index = 0; index < 5; ++index) { packet.Write(qt.RewardReputations[index].Value); } packet.Write((uint)qt.MapId); packet.Write(qt.PointX); packet.Write(qt.PointY); packet.Write(qt.PointOpt); packet.WriteCString(qt.Titles.Localize(locale)); packet.WriteCString(qt.Instructions.Localize(locale)); packet.WriteCString(qt.Details.Localize(locale)); packet.WriteCString(qt.EndTexts.Localize(locale)); packet.WriteCString(qt.CompletedTexts.Localize(locale)); for (int index = 0; index < 4; ++index) { packet.Write(qt.ObjectOrSpellInteractions[index].RawId); packet.Write(qt.ObjectOrSpellInteractions[index].Amount); packet.Write((uint)qt.CollectableSourceItems[index].ItemId); packet.Write(qt.CollectableSourceItems[index].Amount); } for (int index = 0; index < 6; ++index) { if (index < qt.CollectableItems.Length) { packet.Write((uint)qt.CollectableItems[index].ItemId); packet.Write(qt.CollectableItems[index].Amount); } else { packet.WriteUInt(0U); packet.WriteUInt(0U); } } for (int index = 0; index < 4; ++index) { QuestObjectiveSet objectiveText = qt.ObjectiveTexts[(int)locale]; if (objectiveText != null) { packet.Write(objectiveText.Texts[index]); } else { packet.Write(""); } } chr.Client.Send(packet, false); } }
/// <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 SendTimeSpeed(IPacketReceiver client, DateTime time, float timeSpeed) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOGIN_SETTIMESPEED, 8)) { packet.WriteDateTime(time); packet.WriteFloat(timeSpeed); packet.WriteInt(0); // new, unknown client.Send(packet); } }
/// <summary> /// Sends ping to the group, except pinger /// </summary> /// <param name="pinger">The group member who pingged the minimap</param> /// <param name="x">x coordinate of ping</param> /// <param name="y">y coordinate of ping</param> public virtual void SendPing(GroupMember pinger, float x, float y) { using (var packet = new RealmPacketOut(RealmServerOpCode.MSG_MINIMAP_PING)) { packet.Write(EntityId.GetPlayerId(pinger.Id)); packet.WriteFloat(x); packet.WriteFloat(y); SendAll(packet, pinger); } }
public static void SendItemQueryResponse(IRealmClient client, ItemTemplate item) { var locale = client.Info.Locale; using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_QUERY_SINGLE_RESPONSE, 630)) { packet.Write(item.Id); packet.Write((uint)item.Class); packet.Write((uint)item.SubClass); packet.Write(item.Unk0); // unknown packet.WriteCString(item.Names.Localize(locale)); packet.Write((byte)0);// name2 packet.Write((byte)0);// name3 packet.Write((byte)0);// name4 packet.Write(item.DisplayId); packet.Write((uint)item.Quality); packet.Write((uint)item.Flags); packet.Write((uint)item.Flags2); // new 3.2.0 packet.Write(item.BuyPrice); packet.Write(item.SellPrice); packet.Write((uint)item.InventorySlotType); packet.Write((uint)item.RequiredClassMask); packet.Write((uint)item.RequiredRaceMask); packet.Write(item.Level); packet.Write(item.RequiredLevel); packet.Write(item.RequiredSkill != null ? (int)item.RequiredSkill.Id : 0); packet.Write(item.RequiredSkillValue); packet.Write(item.RequiredProfession != null ? item.RequiredProfession.Id : 0); packet.Write(item.RequiredPvPRank); packet.Write(item.UnknownRank);// PVP Medal packet.Write(item.RequiredFaction != null ? (int)item.RequiredFaction.Id : 0); packet.Write((uint)item.RequiredFactionStanding); packet.Write(item.UniqueCount); packet.Write(item.MaxAmount); packet.Write(item.ContainerSlots); packet.Write(item.Mods.Length); for (var m = 0; m < item.Mods.Length; m++) { packet.Write((uint)item.Mods[m].Type); packet.Write(item.Mods[m].Value); } packet.Write(item.ScalingStatDistributionId);// NEW 3.0.2 ScalingStatDistribution.dbc packet.Write(item.ScalingStatValueFlags);// NEW 3.0.2 ScalingStatFlags // In 3.1 there are only 2 damages instead of 5 for (var i = 0; i < ItemConstants.MaxDmgCount; i++) { if(i >= item.Damages.Length) { packet.WriteFloat(0f); packet.WriteFloat(0f); packet.WriteUInt(0u); continue; } var dmg = item.Damages[i]; packet.Write(dmg.Minimum); packet.Write(dmg.Maximum); packet.Write((uint)dmg.School); } for (var i = 0; i < ItemConstants.MaxResCount; i++) { var res = item.Resistances[i]; packet.Write(res); } packet.Write(item.AttackTime); packet.Write((uint)item.ProjectileType); packet.Write(item.RangeModifier); for (var s = 0; s < ItemConstants.MaxSpellCount; s++) { ItemSpell spell; if(s < item.Spells.Length && (spell = item.Spells[s]) != null) { packet.Write((uint)spell.Id); packet.Write((uint)spell.Trigger); packet.Write((uint)Math.Abs(spell.Charges)); packet.Write(spell.Cooldown); packet.Write(spell.CategoryId); packet.Write(spell.CategoryCooldown); } else { packet.WriteUInt(0u); packet.WriteUInt(0u); packet.WriteUInt(0u); packet.Write(-1); packet.WriteUInt(0u); packet.Write(-1); } } packet.Write((uint)item.BondType); packet.WriteCString(item.Descriptions.Localize(locale)); packet.Write(item.PageTextId); packet.Write((uint)item.LanguageId); packet.Write((uint)item.PageMaterial); packet.Write(item.QuestId); packet.Write(item.LockId); packet.Write((int)item.Material); packet.Write((uint)item.SheathType); packet.Write(item.RandomPropertiesId); packet.Write(item.RandomSuffixId); packet.Write(item.BlockValue); packet.Write((uint)item.SetId); packet.Write(item.MaxDurability); packet.Write((uint)item.ZoneId); packet.Write((uint)item.MapId); packet.Write((uint)item.BagFamily); packet.Write((uint)item.ToolCategory); for (var i = 0; i < ItemConstants.MaxSocketCount; i++) { packet.Write((uint)item.Sockets[i].Color); packet.Write(item.Sockets[i].Content); } packet.Write(item.SocketBonusEnchantId); packet.Write(item.GemPropertiesId); packet.Write(item.RequiredDisenchantingLevel); packet.Write(item.ArmorModifier); packet.Write(item.Duration);// Exisiting duration in seconds packet.Write(item.ItemLimitCategoryId);// NEW 3.0.2 ItemLimitCategory.dbc packet.Write(item.HolidayId); // NEW 3.1.0 Holidays.dbc client.Send(packet); } }
/// <summary> /// Sent after spell start. Triggers the casting animation. /// </summary> public static void SendSpellGo(IEntity caster2, SpellCast cast, ICollection<WorldObject> hitTargets, ICollection<MissedTarget> missedTargets, byte previousRuneMask) { if (cast.CasterObject != null && !cast.CasterObject.IsAreaActive) return; // 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.CasterReference.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 && cast.CasterObject != null) { foreach (var target in hitTargets) { packet.Write(target.EntityId); if (target is Character) { SendCastSuccess(cast.CasterObject, 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); // runes if (castGoFlags.HasFlag(CastFlags.RunicPowerGain)) { packet.Write(0); } if (castGoFlags.HasFlag(CastFlags.RuneCooldownList)) { var chr = cast.CasterChar; var newRuneMask = chr.PlayerSpells.Runes.GetActiveRuneMask(); packet.Write(previousRuneMask); packet.Write(newRuneMask); for (int i = 0; i < SpellConstants.MaxRuneCount; i++) { var mask = (byte)(1 << i); if ((mask & previousRuneMask) != 0) { if ((mask & newRuneMask) == 0) { packet.WriteByte(0); } } } } if (castGoFlags.HasFlag(CastFlags.Flag_0x20000)) { packet.WriteFloat(0); packet.Write(0); } if (cast.StartFlags.HasFlag(CastFlags.Ranged)) { WriteAmmoInfo(cast, packet); } if (castGoFlags.HasFlag(CastFlags.Flag_0x80000)) { packet.Write(0); packet.Write(0); } if (cast.TargetFlags.HasAnyFlag(SpellTargetFlags.DestinationLocation)) { packet.Write((byte)0); // unk 3.3.x? } cast.SendPacketToArea(packet); } }
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; }
/// <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 (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_NPC_TEXT_UPDATE)) { packet.Write(text.GossipId); var i = 0; for (; i < text.GossipTexts.Length; i++) { var entry = text.GossipTexts[i]; packet.WriteFloat(entry.Probability); var maleText = entry.GetTextMale(character.GossipConversation); string femaleText; if (text.IsDynamic) { // generated dynamically anyway femaleText = maleText; } else { femaleText = entry.GetTextFemale(character.GossipConversation); } packet.WriteCString(maleText); packet.WriteCString(femaleText); packet.Write((uint)entry.Language); for (int emoteIndex = 0; emoteIndex < 3; emoteIndex++) { // TODO: Emotes //packet.Write((uint)entry.Emotes[emoteIndex]); //packet.Write(entry.EmoteDelays[emoteIndex]); packet.Write(0L); } } for (; i < 8; i++) { packet.WriteFloat(0); packet.WriteByte(0); packet.WriteByte(0); packet.Fill(0, 4 * 7); } character.Client.Send(packet); } }
public static void SendItemQueryResponse(IRealmClient client, ItemTemplate item) { var locale = client.Info.Locale; using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_ITEM_QUERY_SINGLE_RESPONSE, 630)) { packet.Write(item.Id); packet.Write((uint)item.Class); packet.Write((uint)item.SubClass); packet.Write(item.Unk0); // unknown packet.WriteCString(item.Names.Localize(locale)); packet.Write((byte)0); // name2 packet.Write((byte)0); // name3 packet.Write((byte)0); // name4 packet.Write(item.DisplayId); packet.Write((uint)item.Quality); packet.Write((uint)item.Flags); packet.Write((uint)item.Flags2); // new 3.2.0 packet.Write(item.BuyPrice); packet.Write(item.SellPrice); packet.Write((uint)item.InventorySlotType); packet.Write((uint)item.RequiredClassMask); packet.Write((uint)item.RequiredRaceMask); packet.Write(item.Level); packet.Write(item.RequiredLevel); packet.Write(item.RequiredSkill != null ? (int)item.RequiredSkill.Id : 0); packet.Write(item.RequiredSkillValue); packet.Write(item.RequiredProfession != null ? item.RequiredProfession.Id : 0); packet.Write(item.RequiredPvPRank); packet.Write(item.UnknownRank); // PVP Medal packet.Write(item.RequiredFaction != null ? (int)item.RequiredFaction.Id : 0); packet.Write((uint)item.RequiredFactionStanding); packet.Write(item.UniqueCount); packet.Write(item.MaxAmount); packet.Write(item.ContainerSlots); packet.Write(item.Mods.Length); for (var m = 0; m < item.Mods.Length; m++) { packet.Write((uint)item.Mods[m].Type); packet.Write(item.Mods[m].Value); } packet.Write(item.ScalingStatDistributionId); // NEW 3.0.2 ScalingStatDistribution.dbc packet.Write(item.ScalingStatValueFlags); // NEW 3.0.2 ScalingStatFlags // In 3.1 there are only 2 damages instead of 5 for (var i = 0; i < ItemConstants.MaxDmgCount; i++) { if (i >= item.Damages.Length) { packet.WriteFloat(0f); packet.WriteFloat(0f); packet.WriteUInt(0u); continue; } var dmg = item.Damages[i]; packet.Write(dmg.Minimum); packet.Write(dmg.Maximum); packet.Write((uint)dmg.School); } for (var i = 0; i < ItemConstants.MaxResCount; i++) { var res = item.Resistances[i]; packet.Write(res); } packet.Write(item.AttackTime); packet.Write((uint)item.ProjectileType); packet.Write(item.RangeModifier); for (var s = 0; s < ItemConstants.MaxSpellCount; s++) { ItemSpell spell; if (s < item.Spells.Length && (spell = item.Spells[s]) != null) { packet.Write((uint)spell.Id); packet.Write((uint)spell.Trigger); packet.Write((uint)Math.Abs(spell.Charges)); packet.Write(spell.Cooldown); packet.Write(spell.CategoryId); packet.Write(spell.CategoryCooldown); } else { packet.WriteUInt(0u); packet.WriteUInt(0u); packet.WriteUInt(0u); packet.Write(-1); packet.WriteUInt(0u); packet.Write(-1); } } packet.Write((uint)item.BondType); packet.WriteCString(item.Descriptions.Localize(locale)); packet.Write(item.PageTextId); packet.Write((uint)item.LanguageId); packet.Write((uint)item.PageMaterial); packet.Write(item.QuestId); packet.Write(item.LockId); packet.Write((int)item.Material); packet.Write((uint)item.SheathType); packet.Write(item.RandomPropertiesId); packet.Write(item.RandomSuffixId); packet.Write(item.BlockValue); packet.Write((uint)item.SetId); packet.Write(item.MaxDurability); packet.Write((uint)item.ZoneId); packet.Write((uint)item.MapId); packet.Write((uint)item.BagFamily); packet.Write((uint)item.ToolCategory); for (var i = 0; i < ItemConstants.MaxSocketCount; i++) { packet.Write((uint)item.Sockets[i].Color); packet.Write(item.Sockets[i].Content); } packet.Write(item.SocketBonusEnchantId); packet.Write(item.GemPropertiesId); packet.Write(item.RequiredDisenchantingLevel); packet.Write(item.ArmorModifier); packet.Write(item.Duration); // Exisiting duration in seconds packet.Write(item.ItemLimitCategoryId); // NEW 3.0.2 ItemLimitCategory.dbc packet.Write(item.HolidayId); // NEW 3.1.0 Holidays.dbc client.Send(packet, addEnd: false); } }
public static void SendCorpseMapQueryResponse(IRealmClient client) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_CORPSE_MAP_POSITION_QUERY_RESPONSE, 16)) { for (var i = 0; i < 4; i++) packet.WriteFloat(0.0f); // unk client.Send(packet); } }
/// <summary> /// Sends SMSG_LOGIN_VERIFY_WORLD (first ingame packet, sends char-location: Seems unnecessary?) /// </summary> /// <param name="chr"></param> public static void SendVerifyWorld(Character chr) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOGIN_VERIFY_WORLD, 20)) { packet.Write((int)chr.Map.Id); packet.Write(chr.Position); packet.WriteFloat(chr.Orientation); chr.Client.Send(packet); } }
/// <summary> /// Sends a simple npc text update to the character /// </summary> /// <param name="character">recieving character</param> /// <param name="id">id of text to update</param> /// <param name="title">gossip window's title</param> /// <param name="text">gossip window's text</param> public static void SendNPCTextUpdateSimple(Character character, uint id, string title, string text) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_NPC_TEXT_UPDATE)) { packet.Write(id); packet.WriteFloat(1); packet.WriteCString(title); packet.WriteCString(text); packet.Fill(0, 4 * 7); for (var i = 1; i < 8; i++) { packet.WriteFloat(0); packet.WriteByte(0); packet.WriteByte(0); packet.Fill(0, 4 * 7); } character.Client.Send(packet); } }
/// <summary> /// Sends the quest query response. /// </summary> /// <param name="qt">The quest id.</param> /// <param name="chr">The client.</param> public static void SendQuestQueryResponse(QuestTemplate qt, Character chr) { var locale = chr.Client.Info.Locale; using (var pckt = new RealmPacketOut(RealmServerOpCode.SMSG_QUEST_QUERY_RESPONSE)) { pckt.Write(qt.Id); pckt.Write((uint)qt.IsActive); pckt.Write(qt.Level); pckt.Write(qt.MinLevel); // since 3.3 pckt.Write(qt.Category); // questsort pckt.Write((uint)qt.QuestType); pckt.Write(qt.SuggestedPlayers); pckt.Write((uint)qt.ObjectiveMinReputation.ReputationIndex); pckt.Write(qt.ObjectiveMinReputation.Value); pckt.Write((uint)qt.ObjectiveMaxReputation.ReputationIndex); pckt.Write(qt.ObjectiveMaxReputation.Value); // (#10) pckt.Write(qt.FollowupQuestId); pckt.Write(qt.CalcRewardXp(chr)); // since 3.3 if (qt.Flags.HasFlag(QuestFlags.HiddenRewards)) { pckt.Write(0); } else { pckt.Write(qt.RewMoney); } pckt.Write(qt.MoneyAtMaxLevel); pckt.Write((uint)qt.CastSpell); if (qt.RewSpell > 0) { pckt.Write((uint)qt.RewSpell); } else { pckt.Write((uint)qt.RewSpellCast); } pckt.Write(qt.RewHonorAddition); pckt.WriteFloat(qt.RewHonorMultiplier); // since 3.3 pckt.Write((uint)qt.SrcItemId); pckt.Write((uint)qt.Flags); pckt.Write((uint)qt.RewardTitleId); pckt.Write(qt.PlayersSlain); pckt.Write(qt.RewardTalents);// NEW 3.0.2 RewardTalentCount (#21) pckt.Write(0); // since 3.3: bonus arena points pckt.Write(0); // since 3.3 int i; if (qt.Flags.HasFlag(QuestFlags.HiddenRewards)) { for (i = 0; i < QuestConstants.MaxRewardItems; ++i) { pckt.WriteUInt(0u); pckt.WriteUInt(0u); } for (i = 0; i < QuestConstants.MaxRewardChoiceItems; ++i) { pckt.WriteUInt(0u); pckt.WriteUInt(0u); } } else { for (i = 0; i < QuestConstants.MaxRewardItems; i++) { if (i < qt.RewardItems.Length) { pckt.Write((uint)qt.RewardItems[i].ItemId); pckt.Write(qt.RewardItems[i].Amount); } else { pckt.WriteUInt(0u); pckt.WriteUInt(0u); } } for (i = 0; i < QuestConstants.MaxRewardChoiceItems; i++) { if (i < qt.RewardChoiceItems.Length) { pckt.Write((uint)qt.RewardChoiceItems[i].ItemId); pckt.Write(qt.RewardChoiceItems[i].Amount); } else { pckt.WriteUInt(0u); pckt.WriteUInt(0u); } } } // #### since 3.3 for (i = 0; i < QuestConstants.MaxReputations; i++) pckt.Write((uint)qt.RewardReputations[i].Faction); for (i = 0; i < QuestConstants.MaxReputations; i++) pckt.Write(qt.RewardReputations[i].ValueId); for (i = 0; i < QuestConstants.MaxReputations; i++) pckt.Write(qt.RewardReputations[i].Value); // ###### pckt.Write((uint)qt.MapId); pckt.Write(qt.PointX); pckt.Write(qt.PointY); pckt.Write(qt.PointOpt); pckt.WriteCString(qt.Titles.Localize(locale)); pckt.WriteCString(qt.Instructions.Localize(locale)); pckt.WriteCString(qt.Details.Localize(locale)); pckt.WriteCString(qt.EndTexts.Localize(locale)); pckt.WriteCString(qt.CompletedTexts.Localize(locale)); // since 3.3 for (i = 0; i < QuestConstants.MaxObjectInteractions; i++) { pckt.Write(qt.ObjectOrSpellInteractions[i].RawId); // Mob or GO entry ID [i] pckt.Write(qt.ObjectOrSpellInteractions[i].Amount); // amount [i], pckt.Write((uint)qt.CollectableSourceItems[i].ItemId); pckt.Write(qt.CollectableSourceItems[i].Amount); } for (i = 0; i < QuestConstants.MaxCollectableItems; i++) { if (i < qt.CollectableItems.Length) { pckt.Write((uint)qt.CollectableItems[i].ItemId); pckt.Write(qt.CollectableItems[i].Amount); } else { pckt.WriteUInt(0u); pckt.WriteUInt(0u); } } for (i = 0; i < QuestConstants.MaxObjectiveTexts; i++) { var set = qt.ObjectiveTexts[(int)locale]; if (set != null) { pckt.Write(set.Texts[i]); } else { pckt.Write(""); } } chr.Client.Send(pckt); } }
/// <summary> /// Sent after spell start. Triggers the casting animation. /// </summary> public static void SendSpellGo(IEntity caster2, SpellCast cast, ICollection <WorldObject> hitTargets, ICollection <MissedTarget> missedTargets, byte previousRuneMask) { if (cast.CasterObject != null && !cast.CasterObject.IsAreaActive) { return; } // 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.CasterReference.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 && cast.CasterObject != null) { foreach (var target in hitTargets) { packet.Write(target.EntityId); if (target is Character) { SendCastSuccess(cast.CasterObject, 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); // runes if (castGoFlags.HasFlag(CastFlags.RunicPowerGain)) { packet.Write(0); } if (castGoFlags.HasFlag(CastFlags.RuneCooldownList)) { var chr = cast.CasterChar; var newRuneMask = chr.PlayerSpells.Runes.GetActiveRuneMask(); packet.Write(previousRuneMask); packet.Write(newRuneMask); for (int i = 0; i < SpellConstants.MaxRuneCount; i++) { var mask = (byte)(1 << i); if ((mask & previousRuneMask) != 0) { if ((mask & newRuneMask) == 0) { packet.WriteByte(0); } } } } if (castGoFlags.HasFlag(CastFlags.Flag_0x20000)) { packet.WriteFloat(0); packet.Write(0); } if (cast.StartFlags.HasFlag(CastFlags.Ranged)) { WriteAmmoInfo(cast, packet); } if (castGoFlags.HasFlag(CastFlags.Flag_0x80000)) { packet.Write(0); packet.Write(0); } if (cast.TargetFlags.HasAnyFlag(SpellTargetFlags.DestinationLocation)) { packet.Write((byte)0); // unk 3.3.x? } cast.SendPacketToArea(packet); } }