private void SendSpellGo() { var serverSpellGo = new ServerSpellGo { ServerUniqueId = castingId, PrimaryDestination = new Position(caster.Position), Phase = -1 }; foreach (SpellTargetInfo targetInfo in targets .Where(t => t.Effects.Count > 0)) { var networkTargetInfo = new ServerSpellGo.TargetInfo { UnitId = targetInfo.Entity.Guid, TargetFlags = 1, InstanceCount = 1, CombatResult = CombatResult.Hit }; foreach (SpellTargetInfo.SpellTargetEffectInfo targetEffectInfo in targetInfo.Effects) { var networkTargetEffectInfo = new ServerSpellGo.TargetInfo.EffectInfo { Spell4EffectId = targetEffectInfo.Entry.Id, EffectUniqueId = targetEffectInfo.EffectId, TimeRemaining = -1 }; if (targetEffectInfo.Damage != null) { networkTargetEffectInfo.InfoType = 1; networkTargetEffectInfo.DamageDescriptionData = new ServerSpellGo.TargetInfo.EffectInfo.DamageDescription { RawDamage = targetEffectInfo.Damage.RawDamage, RawScaledDamage = targetEffectInfo.Damage.RawScaledDamage, AbsorbedAmount = targetEffectInfo.Damage.AbsorbedAmount, ShieldAbsorbAmount = targetEffectInfo.Damage.ShieldAbsorbAmount, AdjustedDamage = targetEffectInfo.Damage.AdjustedDamage, OverkillAmount = targetEffectInfo.Damage.OverkillAmount, KilledTarget = targetEffectInfo.Damage.KilledTarget, CombatResult = CombatResult.Hit, DamageType = targetEffectInfo.Damage.DamageType }; } networkTargetInfo.EffectInfoData.Add(networkTargetEffectInfo); } serverSpellGo.TargetInfoData.Add(networkTargetInfo); } caster.EnqueueToVisible(serverSpellGo, true); }
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); }