// PUBLIC MODIFIERS public SpellCastResult TryCast(Mage caster, string spellcode_uppercase, ref int crystals) { SpellCastResult result = new SpellCastResult(); Spell spell = null; if (spellcode_dict.ContainsKey(spellcode_uppercase)) { spell = spellcode_dict[spellcode_uppercase]; // check prerequisites result.on_cooldown = spell.IsOnCooldown(); result.not_enough_resources = spell.cost > crystals; result.not_enough_free_slots = spell.GetFreeSlotsRequired() > caster.NumFreeSlots(); if (!result.on_cooldown && !result.not_enough_free_slots && !result.not_enough_resources) { // successful cast crystals -= spell.cost; spell.Cast(caster); result.success = true; } } else { // bad spell code result.invalid_spell_code = true; } // return and events result.spell = spell; if (event_spell_cast != null) event_spell_cast(result); return result; }
// Handle SMSG_SPELL_CAST_RESULT packet private static void HandleSpellCastResult(Packet packet, ClientGame game) { SpellCastResult result = (SpellCastResult)packet.ReadByte(); if (result != SpellCastResult.Success) { game.SetActiveCardActionGrid(true); game.Chat.Write(result.GetDescription(), ChatTypes.Info); return; } var guid = new PacketGuid(); packet.ReadGuidBitStreamInOrder(guid, 5, 7, 0, 1, 4, 3, 2, 6); var mana = packet.ReadByte(); packet.ReadGuidByteStreamInOrder(guid, 7, 2); var manaCost = packet.ReadByte(); packet.ReadGuidByteStreamInOrder(guid, 4, 0, 1); var player = game.GetPlayer(packet.ReadUInt32()); var spellId = packet.ReadUInt32(); packet.ReadGuidByteStreamInOrder(guid, 3, 6, 5); player.HandleSuccessfulSpellCast(guid, spellId, mana, manaCost); }
internal SpellCastResult CastSpell(SpellInfo spellInfo, SpellCastingOptions castOptions) { Spell spell = new Spell(unit, spellInfo, castOptions); ApplySpellModifier(spell, SpellModifierType.SpellValue, 1.0f); SpellCastResult castResult = spell.Prepare(); if (castResult != SpellCastResult.Success) { unit.World.SpellManager.Remove(spell); return(castResult); } switch (spell.ExecutionState) { case SpellExecutionState.Casting: unit.SpellCast.HandleSpellCast(spell, SpellCast.HandleMode.Started); break; case SpellExecutionState.Processing: return(castResult); case SpellExecutionState.Completed: return(castResult); } unit.ModifyEmoteState(EmoteType.None); return(SpellCastResult.Success); }
public override void OnEvent(SpellCastRequestEvent spellCastRequest) { base.OnEvent(spellCastRequest); Player caster = World.FindPlayer(spellCastRequest.RaisedBy); SpellCastRequestAnswerEvent spellCastAnswer = spellCastRequest.FromSelf ? SpellCastRequestAnswerEvent.Create(GlobalTargets.OnlyServer) : SpellCastRequestAnswerEvent.Create(spellCastRequest.RaisedBy); spellCastAnswer.SpellId = spellCastRequest.SpellId; if (caster == null) { spellCastAnswer.Result = (int)SpellCastResult.CasterNotExists; spellCastAnswer.Send(); return; } if (!balance.SpellInfosById.TryGetValue(spellCastRequest.SpellId, out SpellInfo spellInfo)) { spellCastAnswer.Result = (int)SpellCastResult.SpellUnavailable; spellCastAnswer.Send(); return; } SpellCastResult castResult = caster.Spells.CastSpell(spellInfo, new SpellCastingOptions(movementFlags: (MovementFlags)spellCastRequest.MovementFlags)); if (castResult != SpellCastResult.Success) { spellCastAnswer.Result = (int)castResult; spellCastAnswer.Send(); } }
public void SetErrorText(SpellCastResult spellCastResult) { CastResult = spellCastResult; errorLabel.SetString(LocalizationReference.Localize(spellCastResult)); errorLabel.TextMeshPro.fontSize = displaySettings.FontSize; targetLifeTime = displaySettings.LifeTime; transform.localScale = Vector3.one; currentLifeTime = 0; }
public static LocalizedString Localize(SpellCastResult castResult) { Assert.IsTrue(StringsBySpellCastResult.ContainsKey(castResult), $"Missing localization for SpellCastResult: {castResult}"); if (StringsBySpellCastResult.TryGetValue(castResult, out LocalizedString localizedString)) { return(localizedString); } return(MissingString); }
public SpellCastResult CheckCast(bool strict) { // check death state if (!Caster.IsAlive() && !SpellInfo.IsPassive()) { return(SpellCastResult.CASTER_DEAD); } // check cooldowns to prevent cheating if (!SpellInfo.IsPassive()) { if (!Caster.Character.SpellHistory.IsReady(SpellInfo, IsIgnoringCooldowns())) { if (TriggeredByAuraSpell != null) { return(SpellCastResult.DONT_REPORT); } else { return(SpellCastResult.NOT_READY); } } } // Check global cooldown if (strict && !(TriggerCastFlags.HasFlag(TriggerCastFlags.IGNORE_GCD) && HasGlobalCooldown())) { return(SpellCastResult.NOT_READY); } // Check for line of sight for spells with dest /*if (m_targets.HasDst()) * { * float x, y, z; * m_targets.GetDstPos()->GetPosition(x, y, z); * * if (!m_spellInfo->HasAttribute(SPELL_ATTR2_CAN_TARGET_NOT_IN_LOS) && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, NULL, SPELL_DISABLE_LOS) && !m_caster->IsWithinLOS(x, y, z)) * return SPELL_FAILED_LINE_OF_SIGHT; * }*/ SpellCastResult castResult = SpellCastResult.SPELL_CAST_OK; // Triggered spells also have range check /// @todo determine if there is some flag to enable/disable the check castResult = CheckRange(strict); if (castResult != SpellCastResult.SPELL_CAST_OK) { return(castResult); } return(SpellCastResult.SUCCESS); }
internal SpellCastResult Prepare() { ExecutionState = SpellExecutionState.Preparing; PrepareExplicitTarget(); SpellCastResult result = ValidateCast(); if (result != SpellCastResult.Success) { return(result); } return(Cast()); }
public SpellCastFailedMessage(SpellCastResult result, int spellId) { if (!Enum.IsDefined(typeof(SpellCastResult), result)) { throw new InvalidEnumArgumentException(nameof(result), (int)result, typeof(SpellCastResult)); } if (spellId <= 0) { throw new ArgumentOutOfRangeException(nameof(spellId)); } Result = result; SpellId = spellId; }
SpellCastResult DoCheckCast() { Pet pet = GetCaster().ToPlayer().GetPet(); if (pet == null || !pet.IsAlive()) { return(SpellCastResult.CantDoThatRightNow); } // Do a mini Spell::CheckCasterAuras on the pet, no other way of doing this SpellCastResult result = SpellCastResult.SpellCastOk; UnitFlags unitflag = (UnitFlags)pet.GetUInt32Value(UnitFields.Flags); if (!pet.GetCharmerGUID().IsEmpty()) { result = SpellCastResult.Charmed; } else if (unitflag.HasAnyFlag(UnitFlags.Stunned)) { result = SpellCastResult.Stunned; } else if (unitflag.HasAnyFlag(UnitFlags.Fleeing)) { result = SpellCastResult.Fleeing; } else if (unitflag.HasAnyFlag(UnitFlags.Confused)) { result = SpellCastResult.Confused; } if (result != SpellCastResult.SpellCastOk) { return(result); } Unit target = GetExplTargetUnit(); if (!target) { return(SpellCastResult.BadTargets); } if (!pet.IsWithinLOSInMap(target)) { return(SpellCastResult.LineOfSight); } return(SpellCastResult.SpellCastOk); }
SpellCastResult DoCheckCast() { Guardian pet = GetCaster().ToPlayer().GetGuardianPet(); if (pet == null || !pet.IsPet() || !pet.IsAlive()) { return(SpellCastResult.NoPet); } // Do a mini Spell::CheckCasterAuras on the pet, no other way of doing this SpellCastResult result = SpellCastResult.SpellCastOk; UnitFlags unitflag = (UnitFlags)(uint)pet.m_unitData.Flags; if (!pet.GetCharmerGUID().IsEmpty()) { result = SpellCastResult.Charmed; } else if (unitflag.HasAnyFlag(UnitFlags.Stunned)) { result = SpellCastResult.Stunned; } else if (unitflag.HasAnyFlag(UnitFlags.Fleeing)) { result = SpellCastResult.Fleeing; } else if (unitflag.HasAnyFlag(UnitFlags.Confused)) { result = SpellCastResult.Confused; } if (result != SpellCastResult.SpellCastOk) { return(result); } Unit target = GetExplTargetUnit(); if (!target) { return(SpellCastResult.BadTargets); } if (!pet.IsWithinLOSInMap(target)) { return(SpellCastResult.LineOfSight); } return(SpellCastResult.SpellCastOk); }
internal SpellCastResult Prepare() { ExecutionState = SpellExecutionState.Preparing; PrepareExplicitTarget(); SpellInfo.CalculatePowerCosts(Caster, powerCosts, this); SpellCastResult result = ValidateCast(); if (result != SpellCastResult.Success) { return(result); } return(Cast()); }
public SpellCastResult ValidateSpellCast(DefaultEntityActorStateContainer actorState, int spellId) { foreach (var validator in Validators) { SpellCastResult result = validator.ValidateSpellCast(actorState, spellId); //If not successful we failed and no longer need to validate. We know something is wrong. if (result != SpellCastResult.SPELL_FAILED_SUCCESS) { return(result); } } return(SpellCastResult.SPELL_FAILED_SUCCESS); }
private void OnSpellCast(SpellCastResult result) { // start cooldown icon if (result.success && result.spell.IsOnCooldown()) { SpellUIRow row = rows[result.spell]; if (row != null) row.cd_icon.Enable(result.spell); } else if (result.on_cooldown) { SpellUIRow row = rows[result.spell]; if (row.flash_cd_icon != null) StopCoroutine(row.flash_cd_icon); row.flash_cd_icon = FlashCDIcon(row.cd_icon); StartCoroutine(row.flash_cd_icon); } }
SpellCastResult CheckExplicitTarget() { if (GetExplTargetUnit().GetEntry() != BlackOxStatusEntry) { SpellInfo singleTarget = Global.SpellMgr.GetSpellInfo(SpellIds.ProvokeSingleTarget); SpellCastResult singleTargetExplicitResult = singleTarget.CheckExplicitTarget(GetCaster(), GetExplTargetUnit()); if (singleTargetExplicitResult != SpellCastResult.SpellCastOk) { return(singleTargetExplicitResult); } } else if (GetExplTargetUnit().GetOwnerGUID() != GetCaster().GetGUID()) { return(SpellCastResult.BadTargets); } return(SpellCastResult.SpellCastOk); }
private void CombatLogEventUnfilteredHandler(object sender, LuaEventArgs args) { if (HasResult) { return; } var sourceGuid = ArgToGuid(args.Args[3]); if (sourceGuid != StyxWoW.Me.Guid) { return; } if (SpellId.HasValue) { var spellId = (int)(double)args.Args[11]; if (spellId != SpellId.Value) { return; } } var eventName = args.Args[1].ToString(); if (eventName == "SPELL_MISSED") { Result = SpellCastResult.Missed; HasResult = true; return; } if (eventName != "SPELL_CAST_FAILED") { return; } FailReason = args.Args[14].ToString(); Result = GetResultFromError(FailReason); HasResult = true; }
private void OnClientSpellFailed(SpellCastResult castResult) { if (!settings.AllowRepeating) { foreach (var item in activeErrors) { if (item.CastResult == castResult) { return; } } } errorAppearSound?.Play(); ActionErrorItem newError = GameObjectPool.Take(errorItemPrototype, errorContainer.position, errorContainer.rotation, errorContainer); newError.SetErrorText(castResult); newError.RectTransform.SetAsFirstSibling(); activeErrors.Add(newError); }
public void Prepare(SpellCastTargets targets, AuraEffect triggeredByAura = null) { InitiateExplicitTargets(targets); if (triggeredByAura != null) { TriggeredByAuraSpell = triggeredByAura.SpellInfo; } SpellState = SpellState.PREPARING; SpellCastResult result = CheckCast(true); CastTime = SpellInfo.CastTime != null ? SpellInfo.CastTime.CastTime : 0; CastTimer = CastTime; if (CastTime == 0) { Cast(true); } }
public override SpellCastResult CanCastSpell(Spell spell, Cell cell) { SpellCastResult spellCastResult = base.CanCastSpell(spell, cell); SpellCastResult result; if (spellCastResult == SpellCastResult.OK) { result = spellCastResult; } else { switch (spellCastResult) { case SpellCastResult.NO_LOS: this.Character.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 174, new object[0]); goto IL_111; case SpellCastResult.CELL_NOT_FREE: case SpellCastResult.UNWALKABLE_CELL: this.Character.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 172, new object[0]); goto IL_111; case SpellCastResult.NOT_ENOUGH_AP: this.Character.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 170, new object[] { base.AP, spell.CurrentSpellLevel.ApCost }); goto IL_111; case SpellCastResult.HAS_NOT_SPELL: this.Character.SendInformationMessage(TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 169, new object[0]); goto IL_111; } BasicHandler.SendTextInformationMessage(this.Character.Client, TextInformationTypeEnum.TEXT_INFORMATION_ERROR, 175); this.Character.SendServerMessage("(" + spellCastResult + ")", Color.Red); IL_111: result = spellCastResult; } return(result); }
protected override void HandleMessage(EntityActorMessageContext messageContext, DefaultEntityActorStateContainer state, TryCastSpellMessage message) { //Validate the cast before we starer it at all. SpellCastResult spellCastAttemptValidationResult = SpellCastValidator.ValidateSpellCast(state, message.SpellId); if (spellCastAttemptValidationResult != SpellCastResult.SPELL_FAILED_SUCCESS) { messageContext.Entity.TellSelf(new SpellCastFailedMessage(spellCastAttemptValidationResult, message.SpellId)); return; } //We also need to check if we're moving. If the generator isn't finished then that means we're actually moving. if (state.EntityGuid.EntityType == EntityType.Player) //only players should get successful callbacks { messageContext.Entity.TellSelf(new SpellCastFailedMessage(SpellCastResult.SPELL_FAILED_SUCCESS, message.SpellId)); } PendingSpellCastData castData = CreatePendingSpellData(state, message); SetCastingEntityState(state, message); DispatchPendingSpellCast(messageContext, castData); }
private void HandleSpellCast(Event request, int spellId, MovementFlags movementFlags, Vector3?destination = null) { Player caster = World.FindPlayer(request.RaisedBy); SpellCastRequestAnswerEvent spellCastAnswer = request.FromSelf ? SpellCastRequestAnswerEvent.Create(GlobalTargets.OnlyServer) : SpellCastRequestAnswerEvent.Create(request.RaisedBy); spellCastAnswer.SpellId = spellId; if (caster == null) { spellCastAnswer.Result = (int)SpellCastResult.CasterNotExists; spellCastAnswer.Send(); return; } if (!balance.SpellInfosById.TryGetValue(spellId, out SpellInfo spellInfo)) { spellCastAnswer.Result = (int)SpellCastResult.SpellUnavailable; spellCastAnswer.Send(); return; } SpellCastingOptions options = destination.HasValue ? new SpellCastingOptions(new SpellExplicitTargets { Destination = destination.Value }) : new SpellCastingOptions(movementFlags: movementFlags); SpellCastResult castResult = caster.Spells.CastSpell(spellInfo, options); if (castResult != SpellCastResult.Success) { spellCastAnswer.Result = (int)castResult; spellCastAnswer.Send(); } }
private void UnitSpellcastHandler(LuaEventArgs args, SpellCastResult result) { if (HasResult) { return; } if (args.Args[0].ToString() != "player") { return; } if (SpellId.HasValue) { var spellId = (int)(double)args.Args[4]; if (spellId != SpellId.Value) { return; } } Result = result; HasResult = true; }
private void CompleteCast(SpellCastResult result) { GD.Print(result.Spell.name + " Cast"); ToggleCasting(false); result.Spell.Cast(wizardNode); }
private SpellCastResult ValidateAuras() { if (spellCastFlags.HasTargetFlag(SpellCastFlags.IgnoreCasterAuras)) { return(SpellCastResult.Success); } bool usableWhileStunned = SpellInfo.HasAttribute(SpellExtraAttributes.UsableWhileStunned); bool usableWhileConfused = SpellInfo.HasAttribute(SpellExtraAttributes.UsableWhileConfused); bool usableWhileFeared = SpellInfo.HasAttribute(SpellExtraAttributes.UsableWhileFeared); if (Caster.HasFlag(UnitFlags.Stunned)) { if (usableWhileStunned) { SpellCastResult result = ValidateMechanics(AuraEffectType.StunState); if (result != SpellCastResult.Success) { return(result); } } else if (!WillCancelStun()) { return(SpellCastResult.Stunned); } } if (SpellInfo.PreventionType != 0) { if (SpellInfo.PreventionType.HasTargetFlag(SpellPreventionType.Pacify) && Caster.HasFlag(UnitFlags.Pacified) && !WillCancelPacify()) { return(SpellCastResult.Pacified); } if (SpellInfo.PreventionType.HasTargetFlag(SpellPreventionType.Silence) && Caster.HasFlag(UnitFlags.Silenced) && !WillCancelSilence()) { return(SpellCastResult.Silenced); } } if (Caster.HasFlag(UnitFlags.Fleeing)) { if (usableWhileFeared) { SpellCastResult result = ValidateMechanics(AuraEffectType.ModFear); if (result != SpellCastResult.Success) { return(result); } } else if (!WillCancelFear()) { return(SpellCastResult.Fleeing); } } if (Caster.HasFlag(UnitFlags.Confused)) { if (usableWhileConfused) { SpellCastResult result = ValidateMechanics(AuraEffectType.ConfusionState); if (result != SpellCastResult.Success) { return(result); } } else if (!WillCancelConfuse()) { return(SpellCastResult.Confused); } } return(SpellCastResult.Success); bool WillCancelStun() { return(SpellInfo.CanCancelAuraType(AuraEffectType.StunState, Caster) && SpellInfo.CanCancelAuraType(AuraEffectType.Strangulate, Caster)); } bool WillCancelSilence() { return(SpellInfo.CanCancelAuraType(AuraEffectType.Silence, Caster) && SpellInfo.CanCancelAuraType(AuraEffectType.SilencePacify, Caster)); } bool WillCancelPacify() { return(SpellInfo.CanCancelAuraType(AuraEffectType.Pacify, Caster) && SpellInfo.CanCancelAuraType(AuraEffectType.SilencePacify, Caster)); } bool WillCancelFear() { return(SpellInfo.CanCancelAuraType(AuraEffectType.ModFear, Caster)); } bool WillCancelConfuse() { return(SpellInfo.CanCancelAuraType(AuraEffectType.ConfusionState, Caster)); } }
private string BuildSpellErrorCode(UInt32 spellID, SpellCastResult errorCode) { NSpellInfo info = NSpellInfo.FindInfo(spellID); string errorMessageTips = string.Empty; switch (errorCode) { case SpellCastResult.Success: break; case SpellCastResult.Failed_NoSpell: errorMessageTips = string.Format(GUISystem.Instance.StringDictionary.GetValue("C_NoSpell"), info.Name); break; case SpellCastResult.Failed_InvalidSpell: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_InvalidSpell"); break; case SpellCastResult.Failed_SpellInProgress: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_SpellInProgress"); break; case SpellCastResult.Failed_CoolDown: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_CoolDown"); break; case SpellCastResult.Failed_TooClose: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_TooClose"); break; case SpellCastResult.Failed_OutofRange: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_OutofRange"); break; case SpellCastResult.Failed_CasterDead: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_CasterDead"); break; case SpellCastResult.Failed_Interrupted: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_Interrupted"); break; case SpellCastResult.Failed_NoMana: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_NoMana"); break; case SpellCastResult.Failed_NoEnergy: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_NoEnergy"); break; case SpellCastResult.Failed_LineofSight: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_LineofSight"); break; case SpellCastResult.Failed_InvalidTargets: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_InvalidTargets"); break; case SpellCastResult.Failed_InCombat: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_InCombat"); break; case SpellCastResult.Failed_InFear: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_InFear"); break; case SpellCastResult.Failed_InSilence: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_InSilence"); break; case SpellCastResult.Failed_InRoot: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_InRoot"); break; case SpellCastResult.Failed_CantRepeat: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_CantRepeat"); break; case SpellCastResult.Failed_Cancel: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_Cancel"); break; case SpellCastResult.Failed_Move: errorMessageTips = GUISystem.Instance.StringDictionary.GetValue("C_Move"); break; } if (!String.IsNullOrEmpty(errorMessageTips)) { GamingMainFrame.MessageTips.Add(new MessageElement(errorMessageTips)); } return(errorMessageTips); }
void HandleAcceptTrade(AcceptTrade acceptTrade) { TradeData my_trade = GetPlayer().GetTradeData(); if (my_trade == null) { return; } Player trader = my_trade.GetTrader(); TradeData his_trade = trader.GetTradeData(); if (his_trade == null) { return; } Item[] myItems = new Item[(int)TradeSlots.Count]; Item[] hisItems = new Item[(int)TradeSlots.Count]; // set before checks for propertly undo at problems (it already set in to client) my_trade.SetAccepted(true); TradeStatusPkt info = new TradeStatusPkt(); if (his_trade.GetServerStateIndex() != acceptTrade.StateIndex) { info.Status = TradeStatus.StateChanged; SendTradeStatus(info); my_trade.SetAccepted(false); return; } if (!GetPlayer().IsWithinDistInMap(trader, 11.11f, false)) { info.Status = TradeStatus.TooFarAway; SendTradeStatus(info); my_trade.SetAccepted(false); return; } // not accept case incorrect money amount if (!GetPlayer().HasEnoughMoney(my_trade.GetMoney())) { info.Status = TradeStatus.Failed; info.BagResult = InventoryResult.NotEnoughMoney; SendTradeStatus(info); my_trade.SetAccepted(false, true); return; } // not accept case incorrect money amount if (!trader.HasEnoughMoney(his_trade.GetMoney())) { info.Status = TradeStatus.Failed; info.BagResult = InventoryResult.NotEnoughMoney; trader.GetSession().SendTradeStatus(info); his_trade.SetAccepted(false, true); return; } if (GetPlayer().GetMoney() >= PlayerConst.MaxMoneyAmount - his_trade.GetMoney()) { info.Status = TradeStatus.Failed; info.BagResult = InventoryResult.TooMuchGold; SendTradeStatus(info); my_trade.SetAccepted(false, true); return; } if (trader.GetMoney() >= PlayerConst.MaxMoneyAmount - my_trade.GetMoney()) { info.Status = TradeStatus.Failed; info.BagResult = InventoryResult.TooMuchGold; trader.GetSession().SendTradeStatus(info); his_trade.SetAccepted(false, true); return; } // not accept if some items now can't be trade (cheating) for (byte i = 0; i < (byte)TradeSlots.Count; ++i) { Item item = my_trade.GetItem((TradeSlots)i); if (item) { if (!item.CanBeTraded(false, true)) { info.Status = TradeStatus.Cancelled; SendTradeStatus(info); return; } if (item.IsBindedNotWith(trader)) { info.Status = TradeStatus.Failed; info.BagResult = InventoryResult.TradeBoundItem; SendTradeStatus(info); return; } } item = his_trade.GetItem((TradeSlots)i); if (item) { if (!item.CanBeTraded(false, true)) { info.Status = TradeStatus.Cancelled; SendTradeStatus(info); return; } } } if (his_trade.IsAccepted()) { SetAcceptTradeMode(my_trade, his_trade, myItems, hisItems); Spell my_spell = null; SpellCastTargets my_targets = new SpellCastTargets(); Spell his_spell = null; SpellCastTargets his_targets = new SpellCastTargets(); // not accept if spell can't be casted now (cheating) uint my_spell_id = my_trade.GetSpell(); if (my_spell_id != 0) { SpellInfo spellEntry = Global.SpellMgr.GetSpellInfo(my_spell_id); Item castItem = my_trade.GetSpellCastItem(); if (spellEntry == null || !his_trade.GetItem(TradeSlots.NonTraded) || (my_trade.HasSpellCastItem() && !castItem)) { ClearAcceptTradeMode(my_trade, his_trade); ClearAcceptTradeMode(myItems, hisItems); my_trade.SetSpell(0); return; } my_spell = new Spell(GetPlayer(), spellEntry, TriggerCastFlags.FullMask); my_spell.m_CastItem = castItem; my_targets.SetTradeItemTarget(GetPlayer()); my_spell.m_targets = my_targets; SpellCastResult res = my_spell.CheckCast(true); if (res != SpellCastResult.SpellCastOk) { my_spell.SendCastResult(res); ClearAcceptTradeMode(my_trade, his_trade); ClearAcceptTradeMode(myItems, hisItems); my_spell.Dispose(); my_trade.SetSpell(0); return; } } // not accept if spell can't be casted now (cheating) uint his_spell_id = his_trade.GetSpell(); if (his_spell_id != 0) { SpellInfo spellEntry = Global.SpellMgr.GetSpellInfo(his_spell_id); Item castItem = his_trade.GetSpellCastItem(); if (spellEntry == null || !my_trade.GetItem(TradeSlots.NonTraded) || (his_trade.HasSpellCastItem() && !castItem)) { his_trade.SetSpell(0); ClearAcceptTradeMode(my_trade, his_trade); ClearAcceptTradeMode(myItems, hisItems); return; } his_spell = new Spell(trader, spellEntry, TriggerCastFlags.FullMask); his_spell.m_CastItem = castItem; his_targets.SetTradeItemTarget(trader); his_spell.m_targets = his_targets; SpellCastResult res = his_spell.CheckCast(true); if (res != SpellCastResult.SpellCastOk) { his_spell.SendCastResult(res); ClearAcceptTradeMode(my_trade, his_trade); ClearAcceptTradeMode(myItems, hisItems); my_spell.Dispose(); his_spell.Dispose(); his_trade.SetSpell(0); return; } } // inform partner client info.Status = TradeStatus.Accepted; trader.GetSession().SendTradeStatus(info); // test if item will fit in each inventory TradeStatusPkt myCanCompleteInfo = new TradeStatusPkt(); TradeStatusPkt hisCanCompleteInfo = new TradeStatusPkt(); hisCanCompleteInfo.BagResult = trader.CanStoreItems(myItems, (int)TradeSlots.TradedCount, ref hisCanCompleteInfo.ItemID); myCanCompleteInfo.BagResult = GetPlayer().CanStoreItems(hisItems, (int)TradeSlots.TradedCount, ref myCanCompleteInfo.ItemID); ClearAcceptTradeMode(myItems, hisItems); // in case of missing space report error if (myCanCompleteInfo.BagResult != InventoryResult.Ok) { ClearAcceptTradeMode(my_trade, his_trade); myCanCompleteInfo.Status = TradeStatus.Failed; trader.GetSession().SendTradeStatus(myCanCompleteInfo); myCanCompleteInfo.FailureForYou = true; SendTradeStatus(myCanCompleteInfo); my_trade.SetAccepted(false); his_trade.SetAccepted(false); return; } else if (hisCanCompleteInfo.BagResult != InventoryResult.Ok) { ClearAcceptTradeMode(my_trade, his_trade); hisCanCompleteInfo.Status = TradeStatus.Failed; SendTradeStatus(hisCanCompleteInfo); hisCanCompleteInfo.FailureForYou = true; trader.GetSession().SendTradeStatus(hisCanCompleteInfo); my_trade.SetAccepted(false); his_trade.SetAccepted(false); return; } // execute trade: 1. remove for (byte i = 0; i < (int)TradeSlots.TradedCount; ++i) { if (myItems[i]) { myItems[i].SetGiftCreator(GetPlayer().GetGUID()); GetPlayer().MoveItemFromInventory(myItems[i].GetBagSlot(), myItems[i].GetSlot(), true); } if (hisItems[i]) { hisItems[i].SetGiftCreator(trader.GetGUID()); trader.MoveItemFromInventory(hisItems[i].GetBagSlot(), hisItems[i].GetSlot(), true); } } // execute trade: 2. store MoveItems(myItems, hisItems); // logging money if (HasPermission(RBACPermissions.LogGmTrade)) { if (my_trade.GetMoney() > 0) { Log.outCommand(GetPlayer().GetSession().GetAccountId(), "GM {0} (Account: {1}) give money (Amount: {2}) to player: {3} (Account: {4})", GetPlayer().GetName(), GetPlayer().GetSession().GetAccountId(), my_trade.GetMoney(), trader.GetName(), trader.GetSession().GetAccountId()); } if (his_trade.GetMoney() > 0) { Log.outCommand(GetPlayer().GetSession().GetAccountId(), "GM {0} (Account: {1}) give money (Amount: {2}) to player: {3} (Account: {4})", trader.GetName(), trader.GetSession().GetAccountId(), his_trade.GetMoney(), GetPlayer().GetName(), GetPlayer().GetSession().GetAccountId()); } } // update money GetPlayer().ModifyMoney(-(long)my_trade.GetMoney()); GetPlayer().ModifyMoney((long)his_trade.GetMoney()); trader.ModifyMoney(-(long)his_trade.GetMoney()); trader.ModifyMoney((long)my_trade.GetMoney()); if (my_spell) { my_spell.Prepare(my_targets); } if (his_spell) { his_spell.Prepare(his_targets); } // cleanup ClearAcceptTradeMode(my_trade, his_trade); GetPlayer().SetTradeData(null); trader.SetTradeData(null); // desynchronized with the other saves here (SaveInventoryAndGoldToDB() not have own transaction guards) SQLTransaction trans = new SQLTransaction(); GetPlayer().SaveInventoryAndGoldToDB(trans); trader.SaveInventoryAndGoldToDB(trans); DB.Characters.CommitTransaction(trans); info.Status = TradeStatus.Complete; trader.GetSession().SendTradeStatus(info); SendTradeStatus(info); } else { info.Status = TradeStatus.Accepted; trader.GetSession().SendTradeStatus(info); } }
private SpellCastResult ValidateCast() { if (spellCastFlags.HasTargetFlag(SpellCastFlags.TriggeredByAura)) { return(SpellCastResult.Success); } if (Caster.HasState(UnitControlState.Stunned) && !SpellInfo.HasAttribute(SpellExtraAttributes.UsableWhileStunned)) { return(SpellCastResult.Stunned); } if (Caster.HasState(UnitControlState.Confused) && !SpellInfo.HasAttribute(SpellExtraAttributes.UsableWhileConfused)) { return(SpellCastResult.Confused); } if (Caster.HasState(UnitControlState.Fleeing) && !SpellInfo.HasAttribute(SpellExtraAttributes.UsableWhileFeared)) { return(SpellCastResult.Fleeing); } if (SpellInfo.PreventionType != 0) { if (SpellInfo.PreventionType.HasTargetFlag(SpellPreventionType.Pacify) && Caster.HasFlag(UnitFlags.Pacified)) { return(SpellCastResult.Silenced); } if (SpellInfo.PreventionType.HasTargetFlag(SpellPreventionType.Silence) && Caster.HasFlag(UnitFlags.Silenced)) { return(SpellCastResult.Pacified); } } // check death state if (!Caster.IsAlive && !SpellInfo.IsPassive() && !SpellInfo.HasAttribute(SpellAttributes.CastableWhileDead)) { return(SpellCastResult.CasterDead); } // check cooldowns to prevent cheating if (!SpellInfo.IsPassive() && !Caster.SpellHistory.IsReady(SpellInfo)) { return(SpellCastResult.NotReady); } // check global cooldown if (!spellCastFlags.HasTargetFlag(SpellCastFlags.IgnoreGcd) && Caster.SpellHistory.HasGlobalCooldown) { return(SpellCastResult.NotReady); } // check if already casting if (Caster.SpellCast.IsCasting && !SpellInfo.HasAttribute(SpellExtraAttributes.CanCastWhileCasting)) { return(SpellCastResult.NotReady); } SpellCastResult castResult = ValidateRange(); if (castResult != SpellCastResult.Success) { return(castResult); } if (!spellCastFlags.HasTargetFlag(SpellCastFlags.IgnoreTargetCheck)) { castResult = SpellInfo.CheckExplicitTarget(Caster, ExplicitTargets.Target); if (castResult != SpellCastResult.Success) { return(castResult); } if (ExplicitTargets.Target != null) { castResult = SpellInfo.CheckTarget(Caster, ExplicitTargets.Target, this, false); if (castResult != SpellCastResult.Success) { return(castResult); } } } return(SpellCastResult.Success); }
void HandlePetCastSpell(PetCastSpell petCastSpell) { SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(petCastSpell.Cast.SpellID); if (spellInfo == null) { Log.outError(LogFilter.Network, "WorldSession.HandlePetCastSpell: unknown spell id {0} tried to cast by {1}", petCastSpell.Cast.SpellID, petCastSpell.PetGUID.ToString()); return; } Unit caster = Global.ObjAccessor.GetUnit(GetPlayer(), petCastSpell.PetGUID); if (!caster) { Log.outError(LogFilter.Network, "WorldSession.HandlePetCastSpell: Caster {0} not found.", petCastSpell.PetGUID.ToString()); return; } // This opcode is also sent from charmed and possessed units (players and creatures) if (caster != GetPlayer().GetGuardianPet() && caster != GetPlayer().GetCharm()) { Log.outError(LogFilter.Network, "WorldSession.HandlePetCastSpell: {0} isn't pet of player {1} ({2}).", petCastSpell.PetGUID.ToString(), GetPlayer().GetName(), GetPlayer().GetGUID().ToString()); return; } // do not cast not learned spells if (!caster.HasSpell(spellInfo.Id) || spellInfo.IsPassive()) { return; } SpellCastTargets targets = new SpellCastTargets(caster, petCastSpell.Cast); caster.ClearUnitState(UnitState.Follow); Spell spell = new Spell(caster, spellInfo, TriggerCastFlags.None); spell.m_fromClient = true; spell.m_misc.Data0 = petCastSpell.Cast.Misc[0]; spell.m_misc.Data1 = petCastSpell.Cast.Misc[1]; spell.m_targets = targets; SpellCastResult result = spell.CheckPetCast(null); if (result == SpellCastResult.SpellCastOk) { Creature creature = caster.ToCreature(); if (creature) { Pet pet = creature.ToPet(); if (pet) { // 10% chance to play special pet attack talk, else growl // actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell if (pet.getPetType() == PetType.Summon && (RandomHelper.IRand(0, 100) < 10)) { pet.SendPetTalk(PetTalk.SpecialSpell); } else { pet.SendPetAIReaction(petCastSpell.PetGUID); } } } SpellPrepare spellPrepare = new SpellPrepare(); spellPrepare.ClientCastID = petCastSpell.Cast.CastID; spellPrepare.ServerCastID = spell.m_castId; SendPacket(spellPrepare); spell.prepare(targets); } else { spell.SendPetCastResult(result); if (!caster.GetSpellHistory().HasCooldown(spellInfo.Id)) { caster.GetSpellHistory().ResetCooldown(spellInfo.Id, true); } spell.finish(false); spell.Dispose(); } }
void HandlePetActionHelper(Unit pet, ObjectGuid guid1, uint spellid, ActiveStates flag, ObjectGuid guid2, float x, float y, float z) { CharmInfo charmInfo = pet.GetCharmInfo(); if (charmInfo == null) { Log.outError(LogFilter.Network, "WorldSession.HandlePetAction(petGuid: {0}, tagGuid: {1}, spellId: {2}, flag: {3}): object (GUID: {4} Entry: {5} TypeId: {6}) is considered pet-like but doesn't have a charminfo!", guid1, guid2, spellid, flag, pet.GetGUID().ToString(), pet.GetEntry(), pet.GetTypeId()); return; } switch (flag) { case ActiveStates.Command: //0x07 switch ((CommandStates)spellid) { case CommandStates.Stay: //flat=1792 //STAY pet.StopMoving(); pet.GetMotionMaster().Clear(false); pet.GetMotionMaster().MoveIdle(); charmInfo.SetCommandState(CommandStates.Stay); charmInfo.SetIsCommandAttack(false); charmInfo.SetIsAtStay(true); charmInfo.SetIsCommandFollow(false); charmInfo.SetIsFollowing(false); charmInfo.SetIsReturning(false); charmInfo.SaveStayPosition(); break; case CommandStates.Follow: //spellid=1792 //FOLLOW pet.AttackStop(); pet.InterruptNonMeleeSpells(false); pet.GetMotionMaster().MoveFollow(GetPlayer(), SharedConst.PetFollowDist, pet.GetFollowAngle()); charmInfo.SetCommandState(CommandStates.Follow); charmInfo.SetIsCommandAttack(false); charmInfo.SetIsAtStay(false); charmInfo.SetIsReturning(true); charmInfo.SetIsCommandFollow(true); charmInfo.SetIsFollowing(false); break; case CommandStates.Attack: //spellid=1792 //ATTACK { // Can't attack if owner is pacified if (GetPlayer().HasAuraType(AuraType.ModPacify)) { // @todo Send proper error message to client return; } // only place where pet can be player Unit TargetUnit = Global.ObjAccessor.GetUnit(GetPlayer(), guid2); if (!TargetUnit) { return; } Unit owner = pet.GetOwner(); if (owner) { if (!owner.IsValidAttackTarget(TargetUnit)) { return; } } pet.ClearUnitState(UnitState.Follow); // This is true if pet has no target or has target but targets differs. if (pet.GetVictim() != TargetUnit || (pet.GetVictim() == TargetUnit && !pet.GetCharmInfo().IsCommandAttack())) { if (pet.GetVictim()) { pet.AttackStop(); } if (!pet.IsTypeId(TypeId.Player) && pet.ToCreature().IsAIEnabled) { charmInfo.SetIsCommandAttack(true); charmInfo.SetIsAtStay(false); charmInfo.SetIsFollowing(false); charmInfo.SetIsCommandFollow(false); charmInfo.SetIsReturning(false); pet.ToCreature().GetAI().AttackStart(TargetUnit); //10% chance to play special pet attack talk, else growl if (pet.IsPet() && pet.ToPet().getPetType() == PetType.Summon && pet != TargetUnit && RandomHelper.IRand(0, 100) < 10) { pet.SendPetTalk(PetTalk.Attack); } else { // 90% chance for pet and 100% chance for charmed creature pet.SendPetAIReaction(guid1); } } else // charmed player { if (pet.GetVictim() && pet.GetVictim() != TargetUnit) { pet.AttackStop(); } charmInfo.SetIsCommandAttack(true); charmInfo.SetIsAtStay(false); charmInfo.SetIsFollowing(false); charmInfo.SetIsCommandFollow(false); charmInfo.SetIsReturning(false); pet.Attack(TargetUnit, true); pet.SendPetAIReaction(guid1); } } break; } case CommandStates.Abandon: // abandon (hunter pet) or dismiss (summoned pet) if (pet.GetCharmerGUID() == GetPlayer().GetGUID()) { GetPlayer().StopCastingCharm(); } else if (pet.GetOwnerGUID() == GetPlayer().GetGUID()) { Cypher.Assert(pet.IsTypeId(TypeId.Unit)); if (pet.IsPet()) { if (pet.ToPet().getPetType() == PetType.Hunter) { GetPlayer().RemovePet(pet.ToPet(), PetSaveMode.AsDeleted); } else { //dismissing a summoned pet is like killing them (this prevents returning a soulshard...) pet.setDeathState(DeathState.Corpse); } } else if (pet.HasUnitTypeMask(UnitTypeMask.Minion)) { ((Minion)pet).UnSummon(); } } break; case CommandStates.MoveTo: pet.StopMoving(); pet.GetMotionMaster().Clear(false); pet.GetMotionMaster().MovePoint(0, x, y, z); charmInfo.SetCommandState(CommandStates.MoveTo); charmInfo.SetIsCommandAttack(false); charmInfo.SetIsAtStay(true); charmInfo.SetIsFollowing(false); charmInfo.SetIsReturning(false); charmInfo.SaveStayPosition(); break; default: Log.outError(LogFilter.Network, "WORLD: unknown PET flag Action {0} and spellid {1}.", flag, spellid); break; } break; case ActiveStates.Reaction: // 0x6 switch ((ReactStates)spellid) { case ReactStates.Passive: //passive pet.AttackStop(); goto case ReactStates.Defensive; case ReactStates.Defensive: //recovery case ReactStates.Aggressive: //activete if (pet.IsTypeId(TypeId.Unit)) { pet.ToCreature().SetReactState((ReactStates)spellid); } break; } break; case ActiveStates.Disabled: // 0x81 spell (disabled), ignore case ActiveStates.Passive: // 0x01 case ActiveStates.Enabled: // 0xC1 spell { Unit unit_target = null; if (!guid2.IsEmpty()) { unit_target = Global.ObjAccessor.GetUnit(GetPlayer(), guid2); } // do not cast unknown spells SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(spellid); if (spellInfo == null) { Log.outError(LogFilter.Network, "WORLD: unknown PET spell id {0}", spellid); return; } foreach (SpellEffectInfo effect in spellInfo.GetEffectsForDifficulty(Difficulty.None)) { if (effect != null && (effect.TargetA.GetTarget() == Targets.UnitSrcAreaEnemy || effect.TargetA.GetTarget() == Targets.UnitDestAreaEnemy || effect.TargetA.GetTarget() == Targets.DestDynobjEnemy)) { return; } } // do not cast not learned spells if (!pet.HasSpell(spellid) || spellInfo.IsPassive()) { return; } // Clear the flags as if owner clicked 'attack'. AI will reset them // after AttackStart, even if spell failed if (pet.GetCharmInfo() != null) { pet.GetCharmInfo().SetIsAtStay(false); pet.GetCharmInfo().SetIsCommandAttack(true); pet.GetCharmInfo().SetIsReturning(false); pet.GetCharmInfo().SetIsFollowing(false); } Spell spell = new Spell(pet, spellInfo, TriggerCastFlags.None); SpellCastResult result = spell.CheckPetCast(unit_target); //auto turn to target unless possessed if (result == SpellCastResult.UnitNotInfront && !pet.isPossessed() && !pet.IsVehicle()) { Unit unit_target2 = spell.m_targets.GetUnitTarget(); if (unit_target) { pet.SetInFront(unit_target); Player player = unit_target.ToPlayer(); if (player) { pet.SendUpdateToPlayer(player); } } else if (unit_target2) { pet.SetInFront(unit_target2); Player player = unit_target2.ToPlayer(); if (player) { pet.SendUpdateToPlayer(player); } } Unit powner = pet.GetCharmerOrOwner(); if (powner) { Player player = powner.ToPlayer(); if (player) { pet.SendUpdateToPlayer(player); } } result = SpellCastResult.SpellCastOk; } if (result == SpellCastResult.SpellCastOk) { unit_target = spell.m_targets.GetUnitTarget(); //10% chance to play special pet attack talk, else growl //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell if (pet.IsPet() && (pet.ToPet().getPetType() == PetType.Summon) && (pet != unit_target) && (RandomHelper.IRand(0, 100) < 10)) { pet.SendPetTalk(PetTalk.SpecialSpell); } else { pet.SendPetAIReaction(guid1); } if (unit_target && !GetPlayer().IsFriendlyTo(unit_target) && !pet.isPossessed() && !pet.IsVehicle()) { // This is true if pet has no target or has target but targets differs. if (pet.GetVictim() != unit_target) { if (pet.GetVictim()) { pet.AttackStop(); } pet.GetMotionMaster().Clear(); if (pet.ToCreature().IsAIEnabled) { pet.ToCreature().GetAI().AttackStart(unit_target); } } } spell.prepare(spell.m_targets); } else { if (pet.isPossessed() || pet.IsVehicle()) // @todo: confirm this check { Spell.SendCastResult(GetPlayer(), spellInfo, spell.m_SpellVisual, spell.m_castId, result); } else { spell.SendPetCastResult(result); } if (!pet.GetSpellHistory().HasCooldown(spellid)) { pet.GetSpellHistory().ResetCooldown(spellid, true); } spell.finish(false); spell.Dispose(); // reset specific flags in case of spell fail. AI will reset other flags if (pet.GetCharmInfo() != null) { pet.GetCharmInfo().SetIsCommandAttack(false); } } break; } default: Log.outError(LogFilter.Network, "WORLD: unknown PET flag Action {0} and spellid {1}.", flag, spellid); break; } }
private void OnSpellCast(SpellCastResult result) { // not enough free slots alert if (result.not_enough_free_slots) { if (flash_slot_icons != null) StopCoroutine(flash_slot_icons); flash_slot_icons = FlashSlotIcons(); StartCoroutine(flash_slot_icons); } // not enough resources alert if (result.not_enough_resources) { if (flash_crystal_count != null) StopCoroutine(flash_crystal_count); flash_crystal_count = FlashCrystalCount(); StartCoroutine(flash_crystal_count); } }
public void Prepare(SpellCastTargets targets, AuraEffect triggeredByAura) { if (m_CastItem != null) { m_castItemGUID = m_CastItem.GetGUID(); } else { m_castItemGUID = 0; } //InitExplicitTargets(*targets); // Fill aura scaling information /*if (m_caster.IsControlledByPlayer() && !m_spellInfo.IsPassive() && m_spellInfo.SpellLevel && !m_spellInfo.IsChanneled() && !(_triggeredCastFlags & TRIGGERED_IGNORE_AURA_SCALING)) * { * for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i) * { * if (m_spellInfo->Effects[i].Effect == SPELL_EFFECT_APPLY_AURA) * { * // Change aura with ranks only if basepoints are taken from spellInfo and aura is positive * if (m_spellInfo->IsPositiveEffect(i)) * { * m_auraScaleMask |= (1 << i); * if (m_spellValue->EffectBasePoints[i] != m_spellInfo->Effects[i].BasePoints) * { * m_auraScaleMask = 0; * break; * } * } * } * } * }*/ m_spellState = SpellState.Preparing; //if (triggeredByAura) //m_triggeredByAuraSpell = triggeredByAura->GetSpellInfo(); // create and add update event for this spell //SpellEvent* Event = new SpellEvent(this); //m_caster->m_Events.AddEvent(Event, m_caster->m_Events.CalculateTime(1)); //Prevent casting at cast another spell (ServerSide check) //if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CAST_IN_PROGRESS) && m_caster->IsNonMeleeSpellCasted(false, true, true) && m_cast_count) { //SendCastResult(SPELL_FAILED_SPELL_IN_PROGRESS); //finish(false); //return; } //if (DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, m_caster)) { //SendCastResult(SPELL_FAILED_SPELL_UNAVAILABLE); //finish(false); //return; } //LoadScripts(); //if (m_caster is Player) //m_caster.ToPlayer().SetSpellModTakingSpell(this, true); // Fill cost data (not use power for item casts //m_powerCost = m_CastItem != null ? 0 : m_spellInfo.CalcPowerCost(m_caster, m_spellSchoolMask); //if (m_caster->GetTypeId() == TYPEID_PLAYER) //m_caster->ToPlayer()->SetSpellModTakingSpell(this, false); // Set combo point requirement //if ((_triggeredCastFlags & TRIGGERED_IGNORE_COMBO_POINTS) || m_CastItem || !m_caster->m_movedPlayer) //m_needComboPoints = false; SpellCastResult result = SpellCastResult.SpellCastOk; // CheckCast(true); if (result != SpellCastResult.SpellCastOk && !m_autoRepeat) //always cast autorepeat dummy for triggering { // Periodic auras should be interrupted when aura triggers a spell which can't be cast // for example bladestorm aura should be removed on disarm as of patch 3.3.5 // channeled periodic spells should be affected by this (arcane missiles, penance, etc) // a possible alternative sollution for those would be validating aura target on unit state change //if (triggeredByAura && triggeredByAura->IsPeriodic() && !triggeredByAura->GetBase()->IsPassive()) { //SendChannelUpdate(0); //triggeredByAura->GetBase()->SetDuration(0); } //SendCastResult(result); //finish(false); //return; } // Prepare data for triggers //prepareDataForTriggerSystem(triggeredByAura); //if (m_caster->GetTypeId() == TYPEID_PLAYER) //m_caster->ToPlayer()->SetSpellModTakingSpell(this, true); // calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail) m_casttime = m_spellInfo.CalcCastTime(m_caster, this); if (m_caster is Player) { //m_caster.ToPlayer().SetSpellModTakingSpell(this, false); // Set casttime to 0 if .cheat casttime is enabled. //if (m_caster.ToPlayer().GetCommandStatus(CHEAT_CASTTIME)) //m_casttime = 0; } // don't allow channeled spells / spells with cast time to be casted while moving // (even if they are interrupted on moving, spells with almost immediate effect get to have their effect processed before movement interrupter kicks in) // don't cancel spells which are affected by a SPELL_AURA_CAST_WHILE_WALKING effect //if (((m_spellInfo.IsChanneled() || m_casttime) && (m_caster is Player) && m_caster.isMoving() && //m_spellInfo.InterruptFlags & SPELL_INTERRUPT_FLAG_MOVEMENT) && !m_caster.HasAuraTypeWithAffectMask(SPELL_AURA_CAST_WHILE_WALKING, m_spellInfo)) { //SendCastResult(SPELL_FAILED_MOVING); //finish(false); //return; } // set timer base at cast time //ReSetTimer(); Log.outDebug("Spell::prepare: spell id {0} source {1} caster {2} customCastFlags {3} mask {4}", m_spellInfo.Id, m_caster.GetEntry(), m_originalCaster != null ? m_originalCaster.GetEntry() : 0, 0, 0);//_triggeredCastFlags, m_targets.GetTargetMask()); //Containers for channeled spells have to be set //TODO:Apply this to all casted spells if needed // Why check duration? 29350: channelled triggers channelled if (Convert.ToBoolean(_triggeredCastFlags & TriggerCastFlags.CastDirectly) && (!m_spellInfo.IsChanneled() || m_spellInfo.GetMaxDuration() == 0)) { Cast(true); } else { // stealth must be removed at cast starting (at show channel bar) // skip triggered spell (item equip spell casting and other not explicit character casts/item uses) if (!Convert.ToBoolean(_triggeredCastFlags & TriggerCastFlags.IgnoreAuraInterruptFlags) && m_spellInfo.IsBreakingStealth()) { //m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_CAST); for (var i = 0; i < SharedConst.MaxSpellEffects; ++i) { //if (m_spellInfo.Effects[i].GetUsedTargetObjectType() == TARGET_OBJECT_TYPE_UNIT) { //m_caster->RemoveAurasWithInterruptFlags(AURA_INTERRUPT_FLAG_SPELL_ATTACK); //break; } } } //m_caster->SetCurrentCastedSpell(this); SendSpellStart(); // set target for proper facing //if (m_casttime != 0 || m_spellInfo.IsChanneled() && !_triggeredCastFlags & (TriggerCastFlags.IgnoreSetFacing)) //if (m_caster.GetGUID() != m_targets.GetObjectTargetGUID() && (m_caster is Unit)) //m_caster.FocusTarget(this, m_targets.GetObjectTargetGUID()); //if (!_triggeredCastFlags & (TriggerCastFlags.IgnoreGcd)) //TriggerGlobalCooldown(); //item: first cast may destroy item and second cast causes crash //if (m_casttime == 0 && !m_spellInfo.StartRecoveryTime && m_castItemGUID == 0 && GetCurrentContainer() == CURRENT_GENERIC_SPELL) //cast(true); } }
public bool IsConditionBypassed(SpellCastResult result) => BypassedConditions != null && (BypassedConditions.Contains(result) || BypassedConditions.Contains(SpellCastResult.OK));