public void TriggerProc(Unit triggerer, IUnitAction action) { bool flag = false; if (m_spell.ProcTriggerEffects != null) { foreach (AuraEffectHandler handler in m_handlers) { if (handler.SpellEffect.IsProc && handler.CanProcBeTriggeredBy(action) && handler.SpellEffect.CanProcBeTriggeredBy(action.Spell)) { handler.OnProc(triggerer, action); flag = true; } } } else { flag = true; } if (!flag || m_spell.ProcCharges <= 0) { return; } --m_stackCount; if (m_stackCount == 0) { Remove(false); } else { AuraHandler.SendAuraUpdate(m_auras.Owner, this); } }
public bool CanBeTriggeredBy(Unit triggerer, IUnitAction action, bool active) { var hasProcEffects = m_spell.ProcTriggerEffects != null; var canProc = false; if (hasProcEffects) { foreach (var handler in m_handlers) { if (handler.SpellEffect.IsProc) { // only trigger proc effects or all effects, if there arent any proc-specific effects if (handler.CanProcBeTriggeredBy(action) && handler.SpellEffect.CanProcBeTriggeredBy(action.Spell)) { // only trigger if no AffectMask or spell, or the trigger spell matches the affect mask canProc = true; break; } } } } else if (action.Spell == null || action.Spell != Spell) { // Simply count down stack count and remove aura eventually canProc = true; } return(canProc && m_spell.CanProcBeTriggeredBy(m_auras.Owner, action, active)); }
public bool CanBeTriggeredBy(Unit triggerer, IUnitAction action, bool active) { bool flag1 = m_spell.ProcTriggerEffects != null; bool flag2 = false; if (flag1) { foreach (AuraEffectHandler handler in m_handlers) { if (handler.SpellEffect.IsProc && handler.CanProcBeTriggeredBy(action) && handler.SpellEffect.CanProcBeTriggeredBy(action.Spell)) { flag2 = true; break; } } } else if (action.Spell == null || action.Spell != Spell) { flag2 = true; } if (flag2) { return(m_spell.CanProcBeTriggeredBy(m_auras.Owner, action, active)); } return(false); }
public override void OnProc(Unit triggerer, IUnitAction action) { // triggerer is the one being healed SpellId spell; // $48540s1 Energy, $/10;48541s1 Rage, $48542s1% Mana or $/10;48543s1 Runic Power switch (triggerer.PowerType) { case PowerType.Energy: spell = SpellId.Revitalize_3; break; case PowerType.Rage: spell = SpellId.Revitalize_4; break; case PowerType.Mana: spell = SpellId.Revitalize_5; break; case PowerType.RunicPower: spell = SpellId.Revitalize_6; break; default: return; } Owner.SpellCast.TriggerSingle(spell, triggerer); }
public override void OnProc(Unit triggerer, IUnitAction action) { if (action is IDamageAction) { var owner = Owner; var dmgAction = ((IDamageAction)action); var healSelfAmount = ((dmgAction.Damage * EffectValue) + 50) / 100; // don't forget rounding var healPartyAmount = (healSelfAmount + 3) / 5; // don't forget rounding owner.Heal(healSelfAmount, owner, SpellEffect); if (owner is Character) { var chr = (Character)owner; var group = chr.Group; if (group != null) { // heal all group members in same context (ie same Map in current implementation) group.CallOnAllInSameContext(chr.ContextHandler, (member) => { member.Heal(healPartyAmount, owner, SpellEffect); }); } } } }
public override void OnProc(Unit triggerer, IUnitAction action) { SpellId spellId; if (IsWrath(action.Spell)) { // Wrath // "increasing your critical strike chance with Starfire by $48518s1%" spellId = SpellId.EclipseLunar; CurrentlyActiveAura = Owner.Auras.CreateAndStartAura(m_aura.CasterReference, spellId, true); if (CurrentlyActiveAura != null) { // "$s1 sec cooldown" NextWrathProcTime = DateTime.Now.AddMilliseconds(CurrentlyActiveAura.Duration + EffectValue * 1000); } } else { // SF // "chance of increasing damage done by Wrath by $48517s1%" spellId = SpellId.EclipseSolar; CurrentlyActiveAura = Owner.Auras.CreateAndStartAura(m_aura.CasterReference, spellId, true); if (CurrentlyActiveAura != null) { // "$s1 sec cooldown" NextSFProcTime = DateTime.Now.AddMilliseconds(CurrentlyActiveAura.Duration + EffectValue * 1000); } } }
/// <param name="active">Whether the triggerer is the attacker/caster (true), or the victim (false)</param> public bool CanBeTriggeredBy(Unit triggerer, IUnitAction action, bool active) { if (this.Template.Validator != null) { return(this.Template.Validator(triggerer, action)); } return(true); }
/// <summary> /// "launch a free Death Coil at your target" /// </summary> public override void OnProc(Unit triggerer, IUnitAction action) { // get highest level of Death Coil and throw it at the target var line = SpellLineId.DeathKnightDeathCoil.GetLine(); var deathCoil = triggerer.Spells.GetHighestRankOf(line) ?? line.FirstRank; action.Attacker.SpellCast.Trigger(deathCoil, action.Victim); }
public override void OnProc(Unit triggerer, IUnitAction action) { if (action is DamageAction) { // "taking $s1% less damage from a direct damage spell" ((DamageAction)action).ModDamagePercent(-EffectValue); } }
private void Proceed() { Stop(); _currentUnitAction = GenerateUnitAction(); _currentUnitAction.OnComplete += Proceed; _heavyActionDistributor.InvokeDistributed(_currentUnitAction.Start); }
public override bool CanProcBeTriggeredBy(IUnitAction action) { if (action.Spell != null) { return(action.Spell.IsAutoRepeating); } return(true); }
public override void OnProc(Unit triggerer, IUnitAction action) { // add extra damage if (action is DamageAction) { ((DamageAction)action).ModDamagePercent(EffectValue); } }
public override void OnProc(Unit triggerer, IUnitAction action) { if (action is DamageAction) { // "enemies take $s1% more damage" ((DamageAction)action).ModDamagePercent(EffectValue); } }
public override void OnProc(Unit triggerer, IUnitAction action) { if (action is HealAction) { var haction = (HealAction)action; var value = (haction.Value * EffectValue + 50) / 100; Owner.Energize(value, action.Attacker, SpellEffect); } }
private void EnqueueAction(IUnitAction action) { if (actionQueue.Count == MaxActionQueueSize) { return; } actionQueue.Add(action); OnActionEnqueue?.Invoke(action); }
/// <summary> /// Called when a matching proc event triggers this proc handler with the given /// triggerer and action. /// </summary> public override void OnProc(Unit triggerer, IUnitAction action) { if (this.m_spellEffect.TriggerSpell == null) { return; } SpellCast.ValidateAndTriggerNew(this.m_spellEffect.TriggerSpell, this.m_aura.CasterReference, this.Owner, (WorldObject)triggerer, this.m_aura.Controller as SpellChannel, this.m_aura.UsedItem, action, this.m_spellEffect); }
public bool CanBeTriggeredBy(Unit triggerer, IUnitAction action, bool active) { var dAction = action as DamageAction; if (dAction != null) { return(true); } return(false); }
private List <Icon> AddAction(List <Icon> items, IUnitAction action) { var image = Instantiate(queueItemPrefab, energyBar.transform).GetComponent <Icon>(); image.transform.Translate(GetItemOffset(items.Count)); image.Color = action.Color; image.Sprite = action.Sprite; items.Add(image); return(items); }
public override void OnProc(Unit triggerer, IUnitAction action) { // "causes affected targets to heal themselves for $s1% of their total health when they critically hit with a melee or ranged attack." action.Attacker.HealPercent(EffectValue, m_aura.CasterUnit, m_spellEffect); if (action.Attacker == m_aura.CasterUnit) { // "In addition, you gain $s2% of your maximum mana when you benefit from this heal." action.Attacker.EnergizePercent(EffectValue * 2, m_aura.CasterUnit, m_spellEffect); } }
public override void OnProc(Unit triggerer, IUnitAction action) { // "Increases your damage done by your Wrath spell to targets afflicted by your Insect Swarm by $s1%" if (triggerer.Auras.Contains(SpellLineId.DruidBalanceInsectSwarm)) { var daction = action as DamageAction; if (daction != null) { daction.ModDamagePercent(EffectValue); } } }
public void TriggerProc(Unit triggerer, IUnitAction action) { if (trigger) { var dAction = action as DamageAction; if (dAction.CanCrit) { dAction.AddBonusCritChance(modPercentage); trigger = false; } } }
public override void OnProc(Unit target, IUnitAction action) { if (m_spellEffect.TriggerSpell == null) { log.Warn("Tried to trigger invalid Spell \"{0}\" from Aura {1}", SpellEffect.TriggerSpellId, m_spellEffect.Spell); } else { Owner.SpellCast.ValidateAndTrigger(m_spellEffect.TriggerSpell, target); } }
public override void OnProc(Unit triggerer, IUnitAction action) { // "increases the critical strike chance of your Starfire spell by $s2% on targets afflicted by your Moonfire spell." if (triggerer.Auras.Contains(SpellLineId.DruidMoonfire)) { var daction = action as DamageAction; if (daction != null) { daction.AddBonusCritChance(EffectValue); } } }
public override bool CanProcBeTriggeredBy(IUnitAction action) { // only proc if it is a spell that costs Blood runes and if the caster is not already cooling down blood runes return (action.Spell != null && action.Spell.RuneCostEntry != null && action.Spell.RuneCostEntry.GetCost(RuneType.Blood) > 0 && // must cost Blood runes action.Attacker is Character && // only player Characters have runes ((Character)action.Attacker).PlayerSpells.Runes != null && // need runes ((Character)action.Attacker).PlayerSpells.Runes.GetReadyRunes(RuneType.Blood) == SpellConstants.MaxRuneCountPerType && // no blood rune cooling down yet !((Character)action.Attacker).GodMode); // won't cooldown in godmode }
/// <summary> /// Called when a matching proc event triggers this proc handler with the given /// triggerer and action. /// </summary> public override void OnProc(Unit triggerer, IUnitAction action) { if (m_spellEffect.TriggerSpell == null) { //log.Warn("Tried to trigger invalid Spell \"{0}\" from Aura {1}", SpellEffect.TriggerSpellId, m_aura.Spell); } else { SpellCast.ValidateAndTriggerNew(m_spellEffect.TriggerSpell, m_aura.CasterReference, Owner, triggerer, m_aura.Controller as SpellChannel, m_aura.UsedItem, action, m_spellEffect); } }
public override void OnProc(Unit triggerer, IUnitAction action) { if (!(action is HealAction)) { LogManager.GetCurrentClassLogger().Warn("Illumination was proc'ed by non-heal action: {0}, on {1}", action, Owner); return; } var caster = action.Attacker; var cost = (((HealAction)action).Spell.CalcBasePowerCost(caster) * EffectValue + 50) / 100; caster.Energize(cost, caster, SpellEffect); }
private void GoToFlower() { var flower = GetNearFlower(); if (!flower) { Utils.WaitTime(1, GoToFlower); return; } CurrentAction = new MoveAction(_bee.MovingSpeed, _bee.RotateSpeed, flower.ActionTransform, () => CollectFlower(flower), GoToFlower, () => !flower || flower.Honey <= 0); }
public override bool CanProcBeTriggeredBy(IUnitAction action) { if (base.CanProcBeTriggeredBy(action)) { // "there is a chance equal to your melee critical strike chance" var chr = action.Attacker as Character; if (chr != null) { return(Utility.RandomFloat() < chr.CritChanceMeleePct); } } return(false); }
public override void OnProc(Unit target, IUnitAction action) { var val = m_spellEffect.CalcEffectValue(m_aura.CasterInfo); if (action is IDamageAction) { ((IDamageAction)action).Damage += val; } else { m_aura.Auras.Owner.DoSpellDamage(target, m_spellEffect, val); } }
public override void OnProc(Unit target, IUnitAction action) { if (m_spellEffect.TriggerSpell == null) { log.Warn("Tried to trigger invalid Spell \"{0}\" from Aura {1}", SpellEffect.TriggerSpellId, m_spellEffect.Spell); } else { var owner = m_aura.Auras.Owner; //owner.SpellCast.Trigger(m_spellEffect.TriggerSpell, m_spellEffect, target); owner.SpellCast.Trigger(m_spellEffect.TriggerSpell, target); } }
public bool CanProcBeTriggeredBy(Unit owner, IUnitAction action, bool active) { //if (CheckCasterConstraints(owner) != SpellFailedReason.Ok) //{ // return false; //} if (action.Spell != null) { if (active) { // owner == attacker if (CasterProcSpells != null) { return(CasterProcSpells.Contains(action.Spell)); } } else if (TargetProcSpells != null) { // owner == victim return(TargetProcSpells.Contains(action.Spell)); } if (action.Spell == this) { // Proc spell can't trigger itself return(false); } } if (RequiredItemClass != ItemClass.None) { // check for weapon if (!(action is DamageAction)) { return(false); } var aAction = (DamageAction)action; if (aAction.Weapon == null || !(aAction.Weapon is Item)) { return(false); } var weapon = ((Item)aAction.Weapon).Template; return(weapon.Class == RequiredItemClass && (RequiredItemSubClassMask == 0 || weapon.SubClassMask.HasAnyFlag(RequiredItemSubClassMask))); } return(true); }
public void TriggerProc(Unit triggerer, IUnitAction action) { if (!this.CreatorRef.IsAlive) { this.Dispose(); } else { if (!this.Template.ProcAction((Unit)this.CreatorRef, triggerer, action) || this.m_stackCount <= 0) { return; } --this.m_stackCount; } }
public override void OnProc(Unit triggerer, IUnitAction action) { var chr = action.Attacker as Character; if (chr != null) { var runes = chr.PlayerSpells.Runes; if (runes != null) { // convert one of each "From rune" to "To rune" (if not on cooldown) foreach (var rune in From) { runes.Convert(rune, To); } } } }
public override void OnProc(Unit target, IUnitAction action) { var val = m_spellEffect.CalcEffectValue(m_aura.CasterInfo); //if (action is IDamageAction) //{ // ((IDamageAction)action).Damage += val; //} //else { if (Owner.MayAttack(target)) { Owner.DoSpellDamage(target, m_spellEffect, val); } } }
public override void OnProc(Unit triggerer, IUnitAction action) { var val = m_spellEffect.CalcEffectValue(m_aura.CasterReference); //if (action is IDamageAction) //{ // ((IDamageAction)action).Damage += val; //} //else if (Owner.MayAttack(triggerer)) { Owner.DealSpellDamage(triggerer, m_spellEffect, val); } else { LogManager.GetCurrentClassLogger().Warn("Invalid damage effect on Spell {0} was triggered by {1} who cannot be attacked by Aura-Owner {2}.", m_aura.Spell, triggerer, Owner); } }
public override bool CanProcBeTriggeredBy(IUnitAction action) { return action.Spell != null && action.Spell.GeneratesComboPoints; }
public override bool CanProcBeTriggeredBy(IUnitAction action) { // Check whether Improved LotP has been activated yet return EffectValue > 0; }
public override bool CanProcBeTriggeredBy(IUnitAction action) { // only trigger when critical return action.IsCritical; }
public override void OnProc(Unit triggerer, IUnitAction action) { var dmgAction = action as DamageAction; if (dmgAction == null) return; dmgAction.ReferenceCount++; Owner.AddMessage(() => { var nextTarget = Owner.GetRandomVisibleUnit(Owner.MaxAttackRange, unit => Owner.MayAttack(unit) && unit != triggerer); if (nextTarget != null) { dmgAction.Victim = nextTarget; dmgAction.SpellEffect = m_spellEffect; triggerer.DoRawDamage(dmgAction); } // TODO: To ensure correct pooling, must ensure that reference count gets counted down // But object messages don't get executed if the object gets removed before execution dmgAction.ReferenceCount--; }); }
/// <summary> /// /// </summary> public static void ValidateAndTriggerNew(Spell spell, Unit caster, WorldObject target, SpellChannel usedChannel = null, Item usedItem = null, IUnitAction action = null, SpellEffect triggerEffect = null) { ValidateAndTriggerNew(spell, caster.SharedReference, caster, target, usedChannel, usedItem, action, triggerEffect); }
/// <summary> /// Casts the given spell on the given targets within this SpellCast's context. /// Finds targets automatically if the given targets are null. /// </summary> public void Trigger(SpellId spell, SpellEffect triggerEffect, IUnitAction triggerAction = null, params WorldObject[] targets) { Trigger(SpellHandler.Get(spell), triggerEffect, triggerAction, targets); }
public void ValidateAndTrigger(Spell spell, Unit triggerOwner, WorldObject target, IUnitAction action = null, SpellEffect triggerEffect = null) { WorldObject[] targets; if (triggerOwner == null) { LogManager.GetCurrentClassLogger().Warn("triggerOwner is null when trying to proc spell: {0} (target: {1})", spell, target); return; } if (spell.CasterIsTarget || !spell.HasTargets) { targets = new[] { triggerOwner }; } else if (target != null) { if (spell.IsAreaSpell || (spell.IsHarmfulFor(CasterReference, target))) { targets = null; } else { targets = new[] { target }; } } else { targets = null; } if (action != null) { action.ReferenceCount++; TriggerAction = action; } Start(spell, triggerEffect, true, targets); //Dispose(); }
private void DoFinalCleanup(SpellEffectHandler[] handlers) { if (TriggerAction != null) { TriggerAction.ReferenceCount--; TriggerAction = null; } if (handlers != null) { foreach (var handler in handlers) { // can be null if spell is cancelled during initialization if (handler != null) { handler.Cleanup(); } } } if (CasterObject == null || CasterObject.SpellCast != this) { // TODO: Improve dispose strategy Dispose(); } }
public void ValidateAndTrigger(Spell spell, Unit triggerOwner, IUnitAction action = null) { if (action != null) { action.ReferenceCount++; TriggerAction = action; } ValidateAndTrigger(spell, triggerOwner, null, action); }
/// <summary> /// Creates a new SpellCast object to trigger the given spell. /// Validates whether the given target is the correct target /// or if we have to look for the actual targets ourselves. /// Revalidate targets, if it is: /// - an area spell /// - a harmful spell and currently targeting friends /// - not harmful and targeting an enemy /// </summary> /// <param name="spell"></param> /// <param name="target"></param> public void ValidateAndTriggerNew(Spell spell, Unit triggerOwner, WorldObject target, IUnitAction action = null, SpellEffect triggerEffect = null) { var passiveCast = InheritSpellCast(); passiveCast.ValidateAndTrigger(spell, triggerOwner, target, action, triggerEffect); }
/// <summary> /// /// </summary> public static void ValidateAndTriggerNew(Spell spell, ObjectReference caster, Unit triggerOwner, WorldObject target, SpellChannel usedChannel = null, Item usedItem = null, IUnitAction action = null, SpellEffect triggerEffect = null) { var cast = SpellCastPool.Obtain(); cast.SetCaster(caster, target.Map, target.Phase, triggerOwner.Position); cast.Selected = target; if (usedChannel != null && usedChannel.Cast.CasterUnit == triggerOwner) { cast.TargetLoc = triggerOwner.ChannelObject.Position; } else { cast.TargetLoc = target.Position; } cast.TargetItem = cast.CasterItem = usedItem; cast.ValidateAndTrigger(spell, triggerOwner, target, action, triggerEffect); }
/// <summary> /// Whether this proc handler can be triggered by the given action /// </summary> public virtual bool CanProcBeTriggeredBy(IUnitAction action) { return true; }
public override bool CanProcBeTriggeredBy(IUnitAction action) { return action.Spell != null && action.Spell.DispelType == DispelType.Disease && action.Spell != m_spellEffect.TriggerSpell; // prevent infinite loop }
/// <summary> /// Called when a matching proc event triggers this proc handler with the given /// triggerer and action. /// </summary> public virtual void OnProc(Unit triggerer, IUnitAction action) { }
public override void OnProc(Unit triggerer, IUnitAction action) { Owner.Energize(EffectValue, m_aura.CasterUnit, m_spellEffect); }
public bool CanBeTriggeredBy(Unit triggerer, IUnitAction action, bool active) { var dAction = action as DamageAction; if (dAction != null) return true; return false; }
/// <summary> /// Casts the given spell on the given targets within this SpellCast's context. /// Determines targets and hostility, based on the given triggerEffect. /// </summary> public void Trigger(Spell spell, SpellEffect triggerEffect, IUnitAction triggerAction, params WorldObject[] initialTargets) { var cast = InheritSpellCast(); //cast.TriggerEffect = triggerEffect; cast.TriggerAction = triggerAction; ExecuteInContext(() => { cast.Start(spell, triggerEffect, true, initialTargets); //cast.Dispose(); }); }
/// <summary> /// Trigger all procs that can be triggered by the given action /// </summary> /// <param name="active">Whether the triggerer is the attacker/caster (true), or the victim (false)</param> public void Proc(ProcTriggerFlags flags, Unit triggerer, IUnitAction action, bool active) { if (m_brain != null && m_brain.CurrentAction != null && m_brain.CurrentAction.InterruptFlags.HasAnyFlag(flags)) { // check if the current action has been interrupted m_brain.StopCurrentAction(); } if (m_procHandlers == null) { return; } if (flags == ProcTriggerFlags.None) // || !action.CanProc) { return; } if (triggerer == null) { log.Error("triggerer was null when triggering Proc by action: {0} (Flags: {1})", action, flags); return; } var now = DateTime.Now; for (var i = m_procHandlers.Count - 1; i >= 0; i--) // need to reverse iteration because procs can be removed in the process { if (i >= m_procHandlers.Count) { // In case that the list was changed during iteration continue; } var proc = m_procHandlers[i]; if (proc.NextProcTime <= now && proc.ProcTriggerFlags.HasAnyFlag(flags) && proc.CanBeTriggeredBy(triggerer, action, active)) { var chance = (int)proc.ProcChance; if (chance > 0 && this is Character && action.Spell != null) { chance = ((Character)this).PlayerSpells.GetModifiedInt(SpellModifierType.ProcChance, action.Spell, chance); } if (proc.ProcChance <= 0 || Utility.Random(0, 101) <= chance) { var charges = proc.StackCount; proc.TriggerProc(triggerer, action); if (proc.MinProcDelay > 0) { proc.NextProcTime = now.AddMilliseconds(proc.MinProcDelay); } if (charges > 0 && proc.StackCount == 0) { proc.Dispose(); //proc.NextProcTime = DateTime.MaxValue; // won't be proc'ed again } } } } }
public override void OnProc(Unit triggerer, IUnitAction action) { // heal (and dispose automatically, since the single ProcCharge is used up) // "30% of the amount healed" Owner.Heal((damageAmount * 3 + 5) / 10, m_aura.CasterUnit, m_spellEffect); }