public static void Accept(IRealmClient client, RealmPacketIn packet) { var invitee = client.ActiveCharacter; var listInviters = RelationMgr.Instance.GetPassiveRelations(invitee.EntityId.Low, CharacterRelationType.GuildInvite); var invite = listInviters.FirstOrDefault(); if (invite == null) return; Character inviter = World.GetCharacter(invite.CharacterId); if (inviter == null) return; //Removes the guild invite relation between the inviter and invitee RelationMgr.Instance.RemoveRelation(invite); var guildMember = inviter.GuildMember; if (guildMember == null) return; var guild = guildMember.Guild; //Add the invitee to the guild guild.AddMember(invitee); }
public static void HandleGossipSelectOption(IRealmClient client, RealmPacketIn packet) { var targetEntityId = packet.ReadEntityId(); var unknown = packet.ReadUInt32(); // usually Zero, sometimes in the thousands for quest givers, Same as the first int sent in SMSG_GOSSIP_MESSAGE var selectedOption = packet.ReadUInt32(); string extra = string.Empty; if (packet.Position < packet.Length) { extra = packet.ReadCString(); } var chr = client.ActiveCharacter; var worldObject = chr.Region.GetObject(targetEntityId); if (worldObject == null) return; var conversation = chr.GossipConversation; if (conversation == null || conversation.Speaker != worldObject) return; conversation.HandleSelectedItem(selectedOption, extra); }
public static void GroupInviteRequest(IRealmClient client, RealmPacketIn packet) { var inviteeName = packet.ReadCString(); var inviter = client.ActiveCharacter; var group = inviter.Group; Character invitee; if (Group.CheckInvite(inviter, out invitee, inviteeName) == GroupResult.NoError) { var listInvitees = Singleton<RelationMgr>.Instance.GetRelations(inviter.EntityId.Low, CharacterRelationType.GroupInvite); if (group == null || listInvitees.Count < group.InvitesLeft) { BaseRelation inviteRelation = RelationMgr.CreateRelation(inviter.EntityId.Low, invitee.EntityId.Low, CharacterRelationType.GroupInvite); Singleton<RelationMgr>.Instance.AddRelation(inviteRelation); // Target has been invited Group.SendResult(inviter.Client, GroupResult.NoError, inviteeName); SendGroupInvite(invitee.Client, inviter.Name); } } }
public static void HandleLoot(IRealmClient client, RealmPacketIn packet) { var objId = packet.ReadEntityId(); var chr = client.ActiveCharacter; var looter = chr.LooterEntry; var looted = chr.Region.GetObject(objId); if (looted != null) { looter.Release(); // make sure that the Character is not still looting something else var loot = looted.Loot; if (loot == null) { SendLootFail(chr, looted); // TODO: Kneel and unkneel? } else if (looter.MayLoot(loot)) { // we are either already a looter or become a new one chr.CancelAllActions(); looter.Loot = loot; SendLootResponse(chr, loot); } else { SendLootFail(chr, looted); } } }
public static void WhoListRequest(IRealmClient client, RealmPacketIn packet) { var search = new WhoSearch { MaxResultCount = WhoList.MaxResultCount, Faction = client.ActiveCharacter.Faction.Group, MinLevel = (byte)packet.ReadUInt32(), MaxLevel = (byte)packet.ReadUInt32(), Name = packet.ReadCString(), GuildName = packet.ReadCString(), RaceMask = (RaceMask2)packet.ReadUInt32(), ClassMask = (ClassMask2)packet.ReadUInt32() }; uint zoneCount = packet.ReadUInt32(); if (zoneCount > 0 && zoneCount <= 10) { for (int i = 0; i < zoneCount; i++) search.Zones.Add((ZoneId)packet.ReadUInt32()); } uint nameCount = packet.ReadUInt32(); if (nameCount > 0 && nameCount <= 10) { for (int i = 0; i < nameCount; i++) search.Names.Add(packet.ReadCString().ToLower()); } //Performs the search and retrieves matching characters var characters = search.RetrieveMatchedCharacters(); //Send the character list to the client SendWhoList(client, characters); }
public static void HandleDungeonDifficulty(IRealmClient client, RealmPacketIn packet) { var chr = client.ActiveCharacter; if (chr.Map.IsInstance) { // Cannot change difficulty while in instance return; } var difficultyIndex = packet.ReadUInt32(); var group = chr.Group; if (group != null) { if (group.Leader.Character != chr) { // Only leader can change difficulty return; } } var instances = chr.Instances; if (instances.TryResetInstances()) { if (group != null) { group.DungeonDifficulty = difficultyIndex; } else { chr.DungeonDifficulty = (DungeonDifficulty)difficultyIndex; } } }
public static void RemoveFriendRequest(IRealmClient client, RealmPacketIn packet) { var relCharId = packet.ReadEntityId(); RelationMgr.Instance.RemoveRelation(client.ActiveCharacter.EntityId.Low, relCharId.Low, CharacterRelationType.Friend); }
public static void HandleCreateTicketPacket(IRealmClient client, RealmPacketIn packet) { var chr = client.ActiveCharacter; if (chr.Ticket == null) { var map = (MapId)packet.ReadUInt32(); var x = packet.ReadFloat(); var y = packet.ReadFloat(); var z = packet.ReadFloat(); var msg = packet.ReadCString(); var type = (TicketType)packet.ReadUInt32(); // prev. unk0 var unk1 = packet.ReadByte(); // unk1, 1 var unk2 = packet.ReadUInt32(); // unk2, 0 var unk3 = packet.ReadUInt32(); // unk3, 0 var ticket = new Ticket(chr, msg, type); TicketMgr.Instance.AddTicket(ticket); chr.Ticket = ticket; SendCreateResponse(client, TicketInfoResponse.Saved); } else { SendCreateResponse(client, TicketInfoResponse.Fail); } }
public static void HandleAction(IRealmClient client, RealmPacketIn packet) { var entityId = packet.ReadEntityId(); var chr = client.ActiveCharacter; var pet = chr.Map.GetObject(entityId) as NPC; if (pet != null && pet == chr.ActivePet && pet.IsAlive) { var record = pet.PetRecord; if (record != null) { var data = (PetActionEntry)packet.ReadUInt32(); switch (data.Type) { case PetActionType.SetMode: // mode pet.SetPetAttackMode(data.AttackMode); break; case PetActionType.SetAction: // action var targetAction = data.Action; pet.SetPetAction(targetAction); break; default: // spell cast var target = chr.Map.GetObject(packet.ReadEntityId()); pet.CastPetSpell(data.SpellId, target); break; } } } }
/// <summary> /// Adds a client to the queue. /// </summary> /// <param name="client">the client to add to the queue</param> public static void EnqueueClient(IRealmClient client) { client.Account.IsEnqueued = true; s_queuedClients.Enqueue(client); LoginHandler.SendAuthQueueStatus(client); }
public static void HandleRemoveGlyph(IRealmClient client, RealmPacketIn packet) { var slot = packet.ReadUInt32(); var chr = client.ActiveCharacter; chr.RemoveGlyph((byte)slot); SendTalentGroupList(chr.Talents); }
public static void HandleJoin(IRealmClient client, RealmPacketIn packet) { var roles = packet.ReadUInt32(); packet.SkipBytes(2); var dungeonsCount = packet.ReadByte(); if (dungeonsCount == 0) return; for (byte i = 0; i < dungeonsCount; ++i) { // dungeons id/type var packedDungeon = packet.ReadUInt32(); var id = packedDungeon & 0x00FFFFFF; var type = packedDungeon & 0xFF000000; } byte counter2 = packet.ReadByte(); packet.SkipBytes(counter2); // lua: GetLFGInfoLocal string comment = packet.ReadCString(); //SendLfgJoinResult(); //SendLfgUpdate(); }
public static void RepairItem(IRealmClient client, NPC armorer, EntityId itemId, bool useGuildFunds) { var curChar = client.ActiveCharacter; uint totalCost = 0; if (itemId.Low != 0) { // Repairing an individual item. var item = GetItemByEntityId(curChar, itemId); if (item == null) return; if (!ArmorerCheatChecks(curChar, armorer, item)) return; totalCost += RepairItem(curChar, armorer, item, useGuildFunds); } else { // Case Repair all if (!ArmorerCheatChecks(curChar, armorer)) return; totalCost += RepairAllItems(curChar, armorer, useGuildFunds); } if (useGuildFunds) { /**************************** * TODO: record the funds usage in the guild log ****************************/ } }
public static void HandleCancel(IRealmClient client, RealmPacketIn packet) { if (client.ActiveCharacter.Duel != null) { client.ActiveCharacter.Duel.Finish(DuelWin.Knockout, client.ActiveCharacter); } }
public static void AddIgnoreRequest(IRealmClient client, RealmPacketIn packet) { string relCharacterName = packet.ReadCString(); RelationMgr.Instance.AddRelation(client.ActiveCharacter, relCharacterName, string.Empty, CharacterRelationType.Ignored); }
public static void HandleTextEmote(IRealmClient client, RealmPacketIn packet) { var chr = client.ActiveCharacter; if (!chr.CanMove || !chr.CanInteract) return; var emote = (TextEmote)packet.ReadUInt32(); packet.SkipBytes(4); var targetId = packet.ReadEntityId(); var target = chr.Map.GetObject(targetId) as INamed; if (target != null) { SendTextEmote(chr, emote, target); } EmoteType animation; EmoteDBC.EmoteRelationReader.Entries.TryGetValue((int)emote, out animation); switch (animation) { //The client seems to handle these on its own. case EmoteType.StateSleep: case EmoteType.StateSit: case EmoteType.StateKneel: case EmoteType.StateDance: chr.EmoteState = animation; break; default: chr.Emote(animation); break; } //todo: Achievement and scripting hooks/events. }
public static void HandleGossipHello(IRealmClient client, RealmPacketIn packet) { var targetEntityId = packet.ReadEntityId(); var chr = client.ActiveCharacter; var target = chr.Region.GetObject(targetEntityId) as Unit; if (target == null) return; if (chr.GossipConversation != null) { chr.GossipConversation = null; } var menu = target.GossipMenu; if (menu == null) return; if (target is NPC) { if (!((NPC)target).CanInteractWith(chr)) { return; } } else if (!chr.Role.IsStaff) { return; } chr.OnInteract(target); var conversation = new GossipConversation(menu, chr, target, menu.KeepOpen); client.ActiveCharacter.GossipConversation = conversation; conversation.DisplayCurrentMenu(); }
public static void GroupAccept(IRealmClient client, RealmPacketIn packet) { var invitee = client.ActiveCharacter; var listInviters = Singleton<RelationMgr>.Instance.GetPassiveRelations(invitee.EntityId.Low, CharacterRelationType.GroupInvite); var invite = listInviters.FirstOrDefault(); //Check if we got invited if (invite == null) return; //Removes the group invite relation between the inviter and invitee RelationMgr.Instance.RemoveRelation(invite); var inviter = World.GetCharacter(invite.CharacterId); if (inviter == null) return; //If the inviter isnt in a group already we create a new one var inviterGroup = inviter.Group ?? new PartyGroup(inviter); //Add the invitee to the group inviterGroup.AddMember(invitee, true); }
public static void NameQueryRequest(IRealmClient client, RealmPacketIn packet) { var id = packet.ReadEntityId(); ILivingEntity entity = client.ActiveCharacter; if (entity.EntityId.Low != id.Low) { entity = World.GetNamedEntity(id.Low) as ILivingEntity; } if (entity != null) { SendNameQueryReply(client, entity); } else { RealmServer.IOQueue.AddMessage(new Message(() => { var record = CharacterRecord.LoadRecordByEntityId(id.Low); if (record == null) { s_log.Warn("{0} queried name of non-existing Character: " + id, client); } else { SendNameQueryReply(client, record); } })); } }
public static void HandleInstanceReset(IRealmClient client, RealmPacketIn packet) { if (client.ActiveCharacter != null && client.ActiveCharacter.HasInstanceCollection) { client.ActiveCharacter.Instances.TryResetInstances(); } }
/// <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; } }
public static void HandleStopWatchingFaction(IRealmClient client, RealmPacketIn packet) { var reputationIndex = (FactionReputationIndex)packet.ReadInt32(); bool isInactive = packet.ReadBoolean(); client.ActiveCharacter.Reputations.SetInactive(reputationIndex, isInactive); }
public static void HandleAccept(IRealmClient client, RealmPacketIn packet) { // var flagId = packet.ReadEntityId(); if (client.ActiveCharacter.Duel != null) { client.ActiveCharacter.Duel.Accept(client.ActiveCharacter); } }
public static void SetRelationNoteRequest(IRealmClient client, RealmPacketIn packet) { EntityId characterId = packet.ReadEntityId(); string note = packet.ReadCString(); RelationMgr.Instance.SetRelationNote(client.ActiveCharacter.EntityId.Low, characterId.Low, note, CharacterRelationType.Friend); }
public static void HandleDeleteEquipmentSet(IRealmClient client, RealmPacketIn packet) { var setGuid = packet.ReadPackedEntityId(); var chr = client.ActiveCharacter; chr.Inventory.DeleteEquipmentSet(setGuid); }
public static void AddFriendRequest(IRealmClient client, RealmPacketIn packet) { string relCharacterName = packet.ReadCString(); string note = packet.ReadCString(); RelationMgr.Instance.AddRelation(client.ActiveCharacter, relCharacterName, note, CharacterRelationType.Friend); }
public static void HandleQuestPOIQuery(IRealmClient client, RealmPacketIn packet) { uint count = packet.ReadUInt32(); var questIds = new List<uint>(); for (var i = 0; i < count; i++) questIds.Add(packet.ReadUInt32()); SendQuestPOIResponse(client, count, questIds); }
public static void HandleAttackStop(IRealmClient client, RealmPacketIn packet) { if (client.ActiveCharacter.AutorepeatSpell == null) { // ignore when using ranged client.ActiveCharacter.IsFighting = false; } }
public static void HandleProposeTrade(IRealmClient client, RealmPacketIn packet) { var targetGuid = packet.ReadEntityId(); var targetChr = World.GetCharacter(targetGuid.Low); if (TradeInfo.CheckRequirements(client.ActiveCharacter, targetChr)) TradeInfo.Propose(client.ActiveCharacter, targetChr); }
public static void HandleReportLagTicket(IRealmClient client, RealmPacketIn packet) { var type = (TicketReportLagType)packet.ReadUInt32(); var unk0 = packet.ReadUInt32(); // Seems to be always 0 var posX = packet.ReadFloat(); var posY = packet.ReadFloat(); var posZ = packet.ReadFloat(); }
public static void HandleJoin(IRealmClient client, RealmPacketIn packet) { int num1 = (int)packet.ReadUInt32(); packet.SkipBytes(2); byte num2 = packet.ReadByte(); if (num2 == 0) { return; } for (byte index = 0; (int)index < (int)num2; ++index) { packet.ReadUInt32(); } byte num3 = packet.ReadByte(); packet.SkipBytes(num3); packet.ReadCString(); }
/// <summary> /// The client sends this after map-change (when the loading screen finished) /// </summary> public static void HandleWorldPortAck(IRealmClient client, RealmPacketIn packet) { client.TickCount = 0U; Character activeCharacter = client.ActiveCharacter; if (activeCharacter == null || activeCharacter.Map == null) { return; } Zone zone = activeCharacter.Map.GetZone(activeCharacter.Position.X, activeCharacter.Position.Y); if (zone != null) { activeCharacter.SetZone(zone); } else { activeCharacter.SetZone(activeCharacter.Map.DefaultZone); } }
public static void ViewCharacterTradeShopRequest(IRealmClient client, RealmPacketIn packet) { RealmAccount loggedInAccount = ServerApp <WCell.RealmServer.RealmServer> .Instance.GetLoggedInAccount(packet.ReadUInt32()); if (loggedInAccount == null || loggedInAccount.ActiveCharacter == null) { Asda2PrivateShopHandler.SendCharacterPrivateShopInfoResponse(client, Asda2ViewTradeShopInfoStatus.TheCapacityHasExided, (Asda2PrivateShop)null); } else { Character activeCharacter = loggedInAccount.ActiveCharacter; if (activeCharacter.PrivateShop == null || !activeCharacter.PrivateShop.Trading) { return; } activeCharacter.PrivateShop.Join(client.ActiveCharacter); } }
/// <summary> /// Handles a request of getting the number of members in a channel /// </summary> /// <param name="client">the client the incoming packet belongs to</param> /// <param name="packet">the full packet</param> public static void HandleMemberCountRequest(IRealmClient client, RealmPacketIn packet) { string channelName = packet.ReadCString(); Character activeCharacter = client.ActiveCharacter; if (activeCharacter == null) { SendMemberCountReply(client, channelName, 0, 0U); } else { ChatChannel chatChannel = ChatChannelGroup.RetrieveChannel(client.ActiveCharacter, channelName); if (chatChannel == null) { return; } SendMemberCountReply(activeCharacter, chatChannel.Name, (byte)chatChannel.Flags, (uint)chatChannel.MemberCount); } }
/// <summary> /// Handles the quest giver accept quest. /// </summary> /// <param name="client">The client.</param> /// <param name="packet">The packet.</param> //[ClientPacketHandler((RealmServerOpCode.CMSG_QUESTGIVER_ACCEPT_QUEST)] public static void HandleQuestGiverAcceptQuest(IRealmClient client, RealmPacketIn packet) { var guid = packet.ReadEntityId(); var chr = client.ActiveCharacter; var qGiver = chr.QuestLog.GetQuestGiver(guid); var questid = packet.ReadUInt32(); var qt = QuestMgr.GetTemplate(questid); //if it's item then check if has associated //character - has the quest and it is shareable //gameobject - has the quest, has all the requirements if (qt != null && qGiver != null) { if (qGiver.QuestHolderInfo.QuestStarts.Contains(qt)) { chr.QuestLog.TryAddQuest(qt, qGiver); } } }
public static void HandleAuctionListItems(IRealmClient client, RealmPacketIn packet) { Character activeCharacter = client.ActiveCharacter; EntityId id = packet.ReadEntityId(); NPC auctioneer = activeCharacter.Map.GetObject(id) as NPC; AuctionSearch searcher = new AuctionSearch() { StartIndex = packet.ReadUInt32(), Name = packet.ReadCString(), LevelRange1 = (uint)packet.ReadByte(), LevelRange2 = (uint)packet.ReadByte(), InventoryType = (InventorySlotType)packet.ReadUInt32(), ItemClass = (ItemClass)packet.ReadUInt32(), ItemSubClass = (ItemSubClass)packet.ReadUInt32(), Quality = packet.ReadInt32(), IsUsable = packet.ReadBoolean() }; Singleton <AuctionMgr> .Instance.AuctionListItems(activeCharacter, auctioneer, searcher); }
public static void HandleAuctionListPendingSales(IRealmClient client, RealmPacketIn packet) { client.ActiveCharacter.Map.GetObject(packet.ReadEntityId()); uint num = 1; using (RealmPacketOut packet1 = new RealmPacketOut((PacketId)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 SendSavedLocationsInitResponse(IRealmClient client) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SavedLocationsInit)) { packet.WriteByte(1); for (int index = 0; index < client.ActiveCharacter.TeleportPoints.Length; ++index) { Asda2TeleportingPointRecord teleportPoint = client.ActiveCharacter.TeleportPoints[index]; packet.WriteFixedAsciiString(teleportPoint == null ? "" : teleportPoint.Name, 32, Locale.Start); packet.WriteByte(0); byte val = teleportPoint == null ? (byte)0 : (byte)teleportPoint.MapId; packet.WriteByte(val); packet.WriteInt16(teleportPoint == null ? -1 : index); packet.WriteInt16(teleportPoint == null ? 0 : (int)teleportPoint.X - 1000 * (int)val); packet.WriteInt16(teleportPoint == null ? 0 : (int)teleportPoint.Y - 1000 * (int)val); } client.Send(packet, true); } }
public static void HandleNPCTextQuery(IRealmClient client, RealmPacketIn packet) { var textId = packet.ReadUInt32(); var entityId = packet.ReadEntityId(); //var obj = client.ActiveCharacter.Map.GetObject(entityId) as IGossipEntry; //if (obj != null) //{ // SendNPCTextUpdate(client.ActiveCharacter, obj); //} //else var text = GossipMgr.GetEntry(textId); if (text != null) { SendNPCTextUpdate(client.ActiveCharacter, text); } }
public static void ShowMailMsgRequest(IRealmClient client, RealmPacketIn packet) { int num = packet.ReadInt32(); if (!client.ActiveCharacter.MailMessages.ContainsKey((long)num)) { client.ActiveCharacter.YouAreFuckingCheater("Try to view not existing mail message.", 30); Asda2MailHandler.SendMailMessageInfoResponse(client, ShowMailMessageStatus.Fail, (Asda2MailMessage)null); } else { Asda2MailMessage mailMessage = client.ActiveCharacter.MailMessages[(long)num]; if (mailMessage != null) { mailMessage.IsReaded = true; } Asda2MailHandler.SendMailMessageInfoResponse(client, ShowMailMessageStatus.Ok, mailMessage); } }
public static void RemovePetRequest(IRealmClient client, RealmPacketIn packet) { int key = packet.ReadInt32(); if (!client.ActiveCharacter.OwnedPets.ContainsKey(key)) { client.ActiveCharacter.YouAreFuckingCheater("Trying delete not existing pet.", 10); } else if (client.ActiveCharacter.Asda2Pet != null && client.ActiveCharacter.Asda2Pet.Guid == key) { client.ActiveCharacter.SendInfoMsg("You can't delete summoned pet."); } else { Asda2PetRecord ownedPet = client.ActiveCharacter.OwnedPets[key]; client.ActiveCharacter.OwnedPets.Remove(key); Asda2PetHandler.SendPetRemovedResponse(client, ownedPet.Guid); ownedPet.DeleteLater(); } }
[PacketHandler(RealmServerOpCode.PartyInvireAnswer)]//5092 public static void PartyInvireAnswerRequest(IRealmClient client, RealmPacketIn packet) { packet.Position -= 12; var status = packet.ReadByte();//default : 0Len : 1 //var destSessId0 = packet.ReadInt16();//default : -1Len : 2 // var srcAccId = packet.ReadInt32();//default : 340701Len : 4 var invitee = client.ActiveCharacter; var listInviters = Singleton <RelationMgr> .Instance.GetPassiveRelations(invitee.EntityId.Low, CharacterRelationType.GroupInvite); var invite = listInviters.FirstOrDefault(); //Check if we got invited if (invite == null) { return; } //Removes the group invite relation between the inviter and invitee RelationMgr.Instance.RemoveRelation(invite); var inviter = World.GetCharacter(invite.CharacterId); if (inviter == null) { return; } if (status == 1)//accept { //If the inviter isnt in a group already we create a new one var inviterGroup = inviter.Group ?? new PartyGroup(inviter); //Add the invitee to the group inviterGroup.AddMember(invitee, true); SendPartyIniteResponseResponse(inviter.Client, inviter, invitee, PartyInviteStatusResponse.TheInvitionRequestHasBeenAccepted); SendPartyIniteResponseResponse(invitee.Client, inviter, invitee, PartyInviteStatusResponse.TheInvitionRequestHasBeenAccepted); } else { SendPartyIniteResponseResponse(inviter.Client, inviter, invitee, PartyInviteStatusResponse.TheInvitionRequestHasBeenDeclined); } }
//[ClientPacketHandler((RealmServerOpCode.CMSG_TEXT_EMOTE)] public static void HandleTextEmote(IRealmClient client, RealmPacketIn packet) { var chr = client.ActiveCharacter; if (!chr.CanMove || !chr.CanInteract) { return; } var emote = (TextEmote)packet.ReadUInt32(); packet.SkipBytes(4); var targetId = packet.ReadEntityId(); var target = chr.Map.GetObject(targetId) as INamed; if (target != null) { SendTextEmote(chr, emote, target); } EmoteType animation; EmoteDBC.EmoteRelationReader.Entries.TryGetValue((int)emote, out animation); switch (animation) { //The client seems to handle these on its own. case EmoteType.StateSleep: case EmoteType.StateSit: case EmoteType.StateKneel: case EmoteType.StateDance: chr.EmoteState = animation; break; default: chr.Emote(animation); break; } //todo: Achievement and scripting hooks/events. }
public static void SendGameObjectInfo(IRealmClient client, GOEntry entry) { var name = entry.Names.Localize(client); using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_GAMEOBJECT_QUERY_RESPONSE, 13 + 6 + name.Length + (24 * 4))) { packet.Write(entry.Id); packet.Write((uint)entry.Type); packet.Write(entry.DisplayId); packet.Write(name); packet.Write((byte)0); // Name2 packet.Write((byte)0); // Name3 packet.Write((byte)0); // Name4 packet.Write((byte)0); // string IconName packet.Write((byte)0); // string. Casting bar text packet.Write((byte)0); // string int i = 0; for (; i < entry.Fields.Length; i++) { packet.Write(entry.Fields[i]); } // must be 24 fields while (i < GOConstants.EntryFieldCount) { packet.Write(0); i++; } packet.Write(entry.Scale); // size for (i = 0; i < 4; i++) { packet.Write(0); // new 3.1 } client.Send(packet, addEnd: false); } }
public static void SendPrivateShopOpenedResponse(IRealmClient client, PrivateShopOpenedResult status, Asda2ItemTradeRef[] items) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.PrivateShopOpened)) { packet.WriteByte((byte)status); if (status == PrivateShopOpenedResult.Ok) { packet.WriteByte(items.Length); for (int index = 0; index < 10; ++index) { Asda2Item asda2Item = items == null || items[index] == null || items[index].Item == null ? (Asda2Item)null : items[index].Item; packet.WriteInt32(asda2Item == null ? 0 : asda2Item.ItemId); packet.WriteByte(asda2Item == null ? (byte)0 : (byte)asda2Item.InventoryType); packet.WriteInt16(asda2Item == null ? -1 : (int)asda2Item.Slot); packet.WriteInt32(items == null || items[index] == null ? 0 : items[index].Amount); packet.WriteByte(asda2Item == null ? 0 : (int)asda2Item.Durability); packet.WriteByte(asda2Item == null ? 0 : (int)asda2Item.Enchant); packet.WriteInt32(items == null || items[index] == null ? 0 : items[index].Price); packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Soul1Id); packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Soul2Id); packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Soul3Id); packet.WriteInt16(asda2Item == null ? -1 : asda2Item.Soul4Id); packet.WriteInt16(asda2Item == null ? -1 : (int)(short)asda2Item.Parametr1Type); packet.WriteInt16(asda2Item == null ? -1 : (int)asda2Item.Parametr1Value); packet.WriteInt16(asda2Item == null ? -1 : (int)(short)asda2Item.Parametr2Type); packet.WriteInt16(asda2Item == null ? -1 : (int)asda2Item.Parametr2Value); packet.WriteInt16(asda2Item == null ? -1 : (int)(short)asda2Item.Parametr3Type); packet.WriteInt16(asda2Item == null ? -1 : (int)asda2Item.Parametr3Value); packet.WriteInt16(asda2Item == null ? -1 : (int)(short)asda2Item.Parametr4Type); packet.WriteInt16(asda2Item == null ? -1 : (int)asda2Item.Parametr4Value); packet.WriteInt16(asda2Item == null ? -1 : (int)(short)asda2Item.Parametr5Type); packet.WriteInt16(asda2Item == null ? -1 : (int)asda2Item.Parametr5Value); } } client.Send(packet, false); } }
public static void HandleAbandon(IRealmClient client, RealmPacketIn packet) { var petId = packet.ReadEntityId(); var chr = client.ActiveCharacter; var pet = chr.Map.GetObject(petId) as NPC; if (pet != null && pet.IsAlive && pet.IsInContext) { if (pet == chr.ActivePet || chr.GodMode) { chr.AbandonActivePet(); } } #if DEBUG else { chr.SendSystemMessage("You sent CMSG_PET_ABANDON for a pet that does not exist in the same Map."); } #endif }
public static void HandleAutocast(IRealmClient client, RealmPacketIn packet) { var petId = packet.ReadEntityId(); var chr = client.ActiveCharacter; var pet = chr.Map.GetObject(petId) as NPC; if (pet != null) { if (pet == chr.ActivePet || chr.GodMode) { // TODO: Autocast } } #if DEBUG else { chr.SendSystemMessage("You sent CMSG_PET_SPELL_AUTOCAST for a pet that does not exist in the same Map."); } #endif }
public static void HandleStopAttack(IRealmClient client, RealmPacketIn packet) { var petId = packet.ReadEntityId(); var chr = client.ActiveCharacter; var pet = chr.Map.GetObject(petId) as NPC; if (pet != null && pet.IsAlive) { if (pet == chr.ActivePet) { pet.Brain.EnterDefaultState(); } } #if DEBUG else { chr.SendSystemMessage("You sent CMSG_PET_STOP_ATTACK for a pet that does not exist in the same Map."); } #endif }
/// <summary>Handles an incoming request on random roll</summary> /// <param name="client">the Session the incoming packet belongs to</param> /// <param name="packet">the full packet</param> public static void RandomRollRequest(IRealmClient client, RealmPacketIn packet) { int num1 = packet.ReadInt32(); int num2 = packet.ReadInt32(); if (num1 > num2 || num2 > 10000) { return; } int roll = new Random().Next(num1, num2); Group group = client.ActiveCharacter.Group; if (group == null) { SendRoll(client, num1, num2, roll, client.ActiveCharacter.EntityId); } else { group.SendRoll(num1, num2, roll, client.ActiveCharacter.EntityId); } }
//[ClientPacketHandler((RealmServerOpCode.CMSG_AUCTION_LIST_ITEMS)] public static void HandleAuctionListItems(IRealmClient client, RealmPacketIn packet) { var chr = client.ActiveCharacter; var auctioneerId = packet.ReadEntityId(); var auctioneer = chr.Map.GetObject(auctioneerId) as NPC; var searcher = new AuctionSearch() { StartIndex = packet.ReadUInt32(), Name = packet.ReadCString(), LevelRange1 = packet.ReadByte(), LevelRange2 = packet.ReadByte(), InventoryType = (InventorySlotType)packet.ReadUInt32(), ItemClass = (ItemClass)packet.ReadUInt32(), ItemSubClass = (ItemSubClass)packet.ReadUInt32(), Quality = packet.ReadInt32(), IsUsable = packet.ReadBoolean() }; AuctionMgr.Instance.AuctionListItems(chr, auctioneer, searcher); }
public static void HandlePetCastSpell(IRealmClient client, RealmPacketIn packet) { EntityId id = packet.ReadEntityId(); Character activeCharacter = client.ActiveCharacter; NPC npc = activeCharacter.Map.GetObject(id) as NPC; if (npc == null || npc != activeCharacter.ActivePet && activeCharacter.Vehicle != npc && (activeCharacter.Charm != npc && !activeCharacter.GodMode)) { return; } int num1 = packet.ReadByte(); uint spellId = packet.ReadUInt32(); int num2 = packet.ReadByte(); if (SpellHandler.Get(spellId) == null) { return; } SpellCast spellCast = npc.SpellCast; }
public static void SendWingsInfoResponse(Character chr, IRealmClient reciever) { if (chr.Asda2WingsItemId == -1) { return; } using (var packet = new RealmPacketOut(RealmServerOpCode.WingsInfo)) //6585 { packet.WriteInt32(chr.AccId); //{accId}default value : 361343 Len : 4 packet.WriteInt16(chr.Asda2WingsItemId); //value name : unk6 default value : 58Len : 2 packet.WriteSkip(stub6); //{stub6}default value : stub6 Len : 5 if (reciever == null) { chr.SendPacketToArea(packet, true, true); } else { reciever.Send(packet, addEnd: true); } } }
/// <summary> /// Handles gossip hello packet (client requests Gossip Menu) /// </summary> /// <param name="client">realm client</param> /// <param name="packet">packet incoming</param> public static void HandleGossipHello(IRealmClient client, RealmPacketIn packet) { EntityId id = packet.ReadEntityId(); Character activeCharacter = client.ActiveCharacter; Unit unit = activeCharacter.Map.GetObject(id) as Unit; if (unit == null) { return; } activeCharacter.GossipConversation = null; GossipMenu gossipMenu = unit.GossipMenu; if (gossipMenu == null || unit is NPC && !((NPC)unit).CheckVendorInteraction(activeCharacter) && !activeCharacter.Role.IsStaff) { return; } activeCharacter.OnInteract(unit); activeCharacter.StartGossip(gossipMenu, unit); }
/// <summary>Handles an incoming decline on group invite request</summary> /// <param name="client">the Session the incoming packet belongs to</param> /// <param name="packet">the full packet</param> public static void GroupDecline(IRealmClient client, RealmPacketIn packet) { Character activeCharacter = client.ActiveCharacter; IBaseRelation relation = Singleton <RelationMgr> .Instance .GetPassiveRelations(activeCharacter.EntityId.Low, CharacterRelationType.GroupInvite) .FirstOrDefault(); if (relation == null) { return; } Singleton <RelationMgr> .Instance.RemoveRelation(relation); Character character = World.GetCharacter(relation.CharacterId); if (character == null) { return; } SendGroupDecline(character.Client, activeCharacter.Name); }
/// <summary>Handles an incoming accept on group invite request</summary> /// <param name="client">the Session the incoming packet belongs to</param> /// <param name="packet">the full packet</param> public static void GroupAccept(IRealmClient client, RealmPacketIn packet) { Character activeCharacter = client.ActiveCharacter; IBaseRelation relation = Singleton <RelationMgr> .Instance .GetPassiveRelations(activeCharacter.EntityId.Low, CharacterRelationType.GroupInvite) .FirstOrDefault(); if (relation == null) { return; } Singleton <RelationMgr> .Instance.RemoveRelation(relation); Character character = World.GetCharacter(relation.CharacterId); if (character == null) { return; } (character.Group ?? new PartyGroup(character)).AddMember(activeCharacter, true); }
public static void HandleBattlefieldList(IRealmClient client, RealmPacketIn packet) { BattlegroundId bgid = (BattlegroundId)packet.ReadUInt32(); packet.ReadBoolean(); int num = packet.ReadByte(); BattlegroundTemplate template = BattlegroundMgr.GetTemplate(bgid); Character activeCharacter = client.ActiveCharacter; if (template == null) { return; } GlobalBattlegroundQueue queue = template.GetQueue(activeCharacter.Level); if (queue == null) { return; } SendBattlefieldList(activeCharacter, queue); }
/// <summary> /// Handles an incoming request on leader change /// </summary> /// <param name="client">the Session the incoming packet belongs to</param> /// <param name="packet">the full packet</param> //[ClientPacketHandler((RealmServerOpCode.CMSG_GROUP_SET_LEADER)] public static void GroupSetLeader(IRealmClient client, RealmPacketIn packet) { EntityId guid = packet.ReadEntityId(); GroupMember member = client.ActiveCharacter.GroupMember; if (member == null) { return; } var group = member.Group; var targetMember = group[guid.Low]; if (group.CheckAction(member, targetMember, targetMember != null ? targetMember.Name : String.Empty, GroupPrivs.Leader) == GroupResult.NoError) { group.Leader = targetMember; group.SendUpdate(); } }
[PacketHandler(RealmServerOpCode.SendRoomChatMessage)]//6246 public static void SendRoomChatMessageRequest(IRealmClient client, RealmPacketIn packet) { var color = packet.ReadInt32(); //default : -10240Len : 4 packet.Position += 4; //nk9 default : 0Len : 4 var message = packet.ReadAsciiString(client.Locale); //default : Len : 0 if (client.ActiveCharacter.ChatRoom == null) { client.ActiveCharacter.SendInfoMsg("You are not in chat room."); return; } if (client.ActiveCharacter.ChatBanned) { client.ActiveCharacter.SendInfoMsg("you are banned"); return; } var locale = Asda2EncodingHelper.MinimumAvailableLocale(client.Locale, message); SendRoomChatMsgResponse(client, client.ActiveCharacter.AccId, color, message, locale); }
[PacketHandler(RealmServerOpCode.StartOcupyPoint)]//6723 public static void StartOcupyPointRequest(IRealmClient client, RealmPacketIn packet) { packet.Position += 2; var occupationPoint = packet.ReadByte();//default : 3Len : 1 if (!client.ActiveCharacter.IsAsda2BattlegroundInProgress || client.ActiveCharacter.MapId != MapId.BatleField) { client.ActiveCharacter.YouAreFuckingCheater("Trying to occupy point while not in war.", 20); return; } var bgrnd = client.ActiveCharacter.CurrentBattleGround; if (occupationPoint >= bgrnd.Points.Count) { client.ActiveCharacter.YouAreFuckingCheater("Trying to occupy unknown war point.", 20); return; } var point = bgrnd.Points[occupationPoint]; point.TryCapture(client.ActiveCharacter); }
public static void HandleAttackSwing(IRealmClient client, RealmPacketIn packet) { Character activeCharacter = client.ActiveCharacter; if (!activeCharacter.CanDoPhysicalActivity) { return; } EntityId id = packet.ReadEntityId(); Unit opponent = activeCharacter.Map.GetObject(id) as Unit; if (opponent == null || !activeCharacter.CanHarm(opponent) || !activeCharacter.CanSee(opponent)) { return; } activeCharacter.Target = opponent; activeCharacter.IsFighting = true; SendCombatStart(activeCharacter, opponent, true); SendAIReaction(client, opponent.EntityId, AIReaction.Hostile); }