private IEnumerable <ChatFormat> ParseChatLinks(WorldSession session, ClientChat chat) { foreach (ChatFormat format in chat.Formats) { switch (format.FormatModel) { case ChatFormatItemGuid chatFormatItemGuid: { Item item = session.Player.Inventory.GetItem(chatFormatItemGuid.Guid); // TODO: this probably needs to be a full item response yield return(new ChatFormat { Type = ChatFormatType.ItemItemId, StartIndex = 0, StopIndex = 0, FormatModel = new ChatFormatItemId { ItemId = item.Entry.Id } }); break; } default: yield return(format); break; } } }
/// <summary> /// Parses a <see cref="ChatFormat"/> to return a formatted <see cref="ChatFormat"/> /// </summary> private ChatFormat ParseChatFormat(WorldSession session, ChatFormat format) { switch (format.FormatModel) { case ChatFormatItemGuid chatFormatItemGuid: { Item item = session.Player.Inventory.GetItem(chatFormatItemGuid.Guid); return(GetChatFormatForItem(format, item)); } default: return(format); } }
/// <summary> /// Returns formatted <see cref="ChatFormat"/> for an Item Link /// </summary> private static ChatFormat GetChatFormatForItem(ChatFormat chatFormat, Item item) { // TODO: this probably needs to be a full item response return(new ChatFormat { Type = ChatFormatType.ItemItemId, StartIndex = chatFormat.StartIndex, StopIndex = chatFormat.StopIndex, FormatModel = new ChatFormatItemId { ItemId = item.Entry.Id } }); }
public static void HandlePlayerCastSpell(WorldSession session, ClientCastSpell castSpell) { // the code in the function is temporary and just for a bit of fun, it will be replaced when the underlying spell system is implemented Item item = session.Player.Inventory.GetItem(InventoryLocation.Ability, castSpell.BagIndex); if (item == null) { throw new InvalidPacketValueException(); } UnlockedSpell spell = session.Player.SpellManager.GetSpell(item.Id); if (spell == null) { throw new InvalidPacketValueException(); } // true is probably "begin casting" if (!castSpell.Unknown48) { return; } uint castingId = GlobalSpellManager.NextCastingId; Spell4Entry spell4Entry = GameTableManager.Spell4.Entries .SingleOrDefault(x => x.Spell4BaseIdBaseSpell == spell.Entry.Id && x.TierIndex == spell.Tier); session.Player.EnqueueToVisible(new ServerSpellStart { CastingId = castingId, CasterId = session.Player.Guid, PrimaryTargetId = session.Player.Guid, Spell4Id = spell4Entry.Id, RootSpell4Id = spell4Entry.Id, ParentSpell4Id = 0, FieldPosition = new Position(session.Player.Position), UserInitiatedSpellCast = true }, true); var targetInfo = new ServerSpellGo.TargetInfo { UnitId = session.Player.Guid, // FIXME: insert target TargetFlags = 1, InstanceCount = 1, CombatResult = 2 }; foreach (Spell4EffectsEntry spell4EffectEntry in GameTableManager.Spell4Effects.Entries .Where(x => x.SpellId == spell4Entry.Id)) { targetInfo.EffectInfoData.Add(new ServerSpellGo.TargetInfo.EffectInfo { Spell4EffectId = spell4EffectEntry.Id, EffectUniqueId = 4722, TimeRemaining = -1 }); } session.Player.EnqueueToVisible(new ServerSpellGo { ServerUniqueId = castingId, PrimaryDestination = new Position(session.Player.Position), Phase = 255, TargetInfoData = new List <ServerSpellGo.TargetInfo> { targetInfo } }, true); }