public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (apply) { if (IsReplacementValid(auraApplication.Target.TransformSpellInfo, Aura.SpellInfo)) { auraApplication.Target.UpdateTransformSpell(this); } } else { auraApplication.Target.ResetTransformSpell(); IReadOnlyList <AuraEffect> transformEffects = auraApplication.Target.Auras.GetAuraEffects(AuraEffectType.ChangeDisplayModel); if (transformEffects != null) { for (int i = 0; i < transformEffects.Count; i++) { if (IsReplacementValid(auraApplication.Target.TransformSpellInfo, transformEffects[i].Aura.SpellInfo)) { auraApplication.Target.UpdateTransformSpell((AuraEffectChangeDisplayModel)transformEffects[i]); } } } } }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode != AuraEffectHandleMode.Normal) { return; } auraApplication.Target.Spells.ModifySchoolImmunity(Aura.SpellInfo, EffectInfo.SchoolMask, apply); if (apply && Aura.SpellInfo.HasAttribute(SpellAttributes.DispelAurasOnImmunity)) { var applicaionsToRemove = new List <AuraApplication>(); for (var index = 0; index < auraApplication.Target.AuraApplications.Count; index++) { AuraApplication otherApplication = auraApplication.Target.AuraApplications[index]; if (!otherApplication.Aura.SpellInfo.SchoolMask.HasAnyFlag(EffectInfo.SchoolMask)) { continue; } // check for auras that ignore immunities and can't be dispelled if (!Aura.SpellInfo.CanDispelAura(otherApplication.Aura.SpellInfo)) { continue; } // don't dispel self if (Aura == otherApplication.Aura) { continue; } // don't dispel passives if (otherApplication.Aura.SpellInfo.IsPassive) { continue; } // don't dispel same positivity effects if (otherApplication.Aura.AuraInfo.IsPositive == Aura.AuraInfo.IsPositive) { continue; } applicaionsToRemove.Add(otherApplication); } foreach (AuraApplication applicationToRemove in applicaionsToRemove) { if (applicationToRemove.RemoveMode == AuraRemoveMode.None) { auraApplication.Target.Auras.RemoveAuraWithApplication(applicationToRemove, AuraRemoveMode.Immunity); } } } }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (apply) { PreparePeriodic(Aura.Caster, mode == AuraEffectHandleMode.Refresh); } }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode == AuraEffectHandleMode.Normal) { auraApplication.Target.Attributes.HandleStatPercentModifier(modifierType, StatModifierType.BaseValue, Value, apply); } }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode == AuraEffectHandleMode.Normal) { auraApplication.Target.Attributes.UpdateSpeed(UnitMoveType.Run); } }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode == AuraEffectHandleMode.Normal) { auraApplication.Target.Spells.HandleSpellTrigger(this, apply); } }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode == AuraEffectHandleMode.Normal) { auraApplication.Target.UpdateControlState(UnitControlState.Stunned, apply); } }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode == AuraEffectHandleMode.Normal) { auraApplication.Target.Attributes.ModHaste.ModifyPercentage(Value, apply); } }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (apply && mode == AuraEffectHandleMode.Refresh) { CalculateValue(); } }
private void HandleTickOnApplications() { for (int i = Aura.Applications.Count - 1; i >= 0; i--) { AuraApplication application = Aura.Applications[i]; if (application.AppliedEffectMask.HasBit(Index)) { HandlePeriodic(application.Target, Aura.Caster); } } }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode != AuraEffectHandleMode.Normal) { return; } auraApplication.Target.UpdateVisibility(true); }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode != AuraEffectHandleMode.Normal) { return; } int slowFallSpeed = (int)auraApplication.Target.Auras.MinPositiveAuraModifier(AuraEffectType.SlowFall); auraApplication.Target.SlowFallSpeed = slowFallSpeed; }
static bool HandleListAurasCommand(StringArguments args, CommandHandler handler) { Unit unit = handler.GetSelectedUnit(); if (!unit) { handler.SendSysMessage(CypherStrings.SelectCharOrCreature); return(false); } string talentStr = handler.GetCypherString(CypherStrings.Talent); string passiveStr = handler.GetCypherString(CypherStrings.Passive); var auras = unit.GetAppliedAuras(); handler.SendSysMessage(CypherStrings.CommandTargetListauras, auras.Count); foreach (var pair in auras) { AuraApplication aurApp = pair.Value; Aura aura = aurApp.GetBase(); string name = aura.GetSpellInfo().SpellName[handler.GetSessionDbcLocale()]; bool talent = aura.GetSpellInfo().HasAttribute(SpellCustomAttributes.IsTalent); string ss_name = "|cffffffff|Hspell:" + aura.GetId() + "|h[" + name + "]|h|r"; handler.SendSysMessage(CypherStrings.CommandTargetAuradetail, aura.GetId(), (handler.GetSession() != null ? ss_name : name), aurApp.GetEffectMask(), aura.GetCharges(), aura.GetStackAmount(), aurApp.GetSlot(), aura.GetDuration(), aura.GetMaxDuration(), (aura.IsPassive() ? passiveStr : ""), (talent ? talentStr : ""), aura.GetCasterGUID().IsPlayer() ? "player" : "creature", aura.GetCasterGUID().ToString()); } for (ushort i = 0; i < (int)AuraType.Total; ++i) { var auraList = unit.GetAuraEffectsByType((AuraType)i); if (auraList.Empty()) { continue; } handler.SendSysMessage(CypherStrings.CommandTargetListauratype, auraList.Count, i); foreach (var eff in auraList) { handler.SendSysMessage(CypherStrings.CommandTargetAurasimple, eff.GetId(), eff.GetEffIndex(), eff.GetAmount()); } } return(true); }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode == AuraEffectHandleMode.Normal) { auraApplication.Target.Spells.HandleSpellModifier(SpellModifier, apply); } if (apply && mode == AuraEffectHandleMode.Refresh) { CalculateValue(); } }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode != AuraEffectHandleMode.Normal) { return; } SpellMechanicsFlags immuneMechanics = 0; for (int i = 0; i < EffectInfo.ImmuneMechanics.Count; i++) { auraApplication.Target.Spells.ModifyMechanicsImmunity(Aura.SpellInfo, EffectInfo.ImmuneMechanics[i], apply); immuneMechanics |= EffectInfo.ImmuneMechanics[i].AsFlag(); } if (apply && Aura.SpellInfo.HasAttribute(SpellAttributes.DispelAurasOnImmunity)) { var applicaionsToRemove = new List <AuraApplication>(); for (var index = 0; index < auraApplication.Target.AuraApplications.Count; index++) { AuraApplication otherApplication = auraApplication.Target.AuraApplications[index]; if (!otherApplication.Aura.AuraInfo.HasAnyMechanics(immuneMechanics)) { continue; } if (!Aura.CanDispel(otherApplication.Aura)) { continue; } applicaionsToRemove.Add(otherApplication); } foreach (AuraApplication applicationToRemove in applicaionsToRemove) { if (applicationToRemove.RemoveMode == AuraRemoveMode.None) { auraApplication.Target.Auras.RemoveAuraWithApplication(applicationToRemove, AuraRemoveMode.Immunity); } } } }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode != AuraEffectHandleMode.Normal) { return; } Vehicle vehicle = auraApplication.Target.Vehicle; if (vehicle == null) { return; } Unit passenger = auraApplication.Aura.Caster; if (passenger == null) { return; } if (passenger == vehicle.Unit) { return; } if (apply) { if (!passenger.IsAlive || passenger.Vehicle == vehicle || vehicle.Unit.IsOnVehicle(passenger)) { passenger.HandleVehicleApplicationEnter(vehicle, (int)Value, Aura); } } else { if (vehicle == passenger.Vehicle) { passenger.HandleVehicleApplicationExit(); } } }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode != AuraEffectHandleMode.Normal) { return; } Unit target = auraApplication.Target; bool hasSilence = EffectInfo.PreventionType.HasTargetFlag(SpellPreventionType.Silence); bool hasPacify = EffectInfo.PreventionType.HasTargetFlag(SpellPreventionType.Pacify); if (apply) { if (hasSilence) { target.SetFlag(UnitFlags.Silenced); } if (hasPacify) { target.SetFlag(UnitFlags.Pacified); } if (target.SpellCast.IsCasting && target.SpellCast.Spell.SpellInfo.PreventionType.HasAnyFlag(EffectInfo.PreventionType)) { target.SpellCast.Cancel(); } } else { if (hasSilence && !target.HasAuraType(AuraEffectType.Silence) && !target.HasAuraType(AuraEffectType.SilencePacify)) { target.RemoveFlag(UnitFlags.Silenced); } if (hasPacify && !target.HasAuraType(AuraEffectType.Pacify) && !target.HasAuraType(AuraEffectType.SilencePacify)) { target.RemoveFlag(UnitFlags.Pacified); } } }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode != AuraEffectHandleMode.Normal) { return; } if (apply) { auraApplication.Target.InvisibilityDetection += (int)EffectInfo.Value; } else { auraApplication.Target.InvisibilityDetection -= (int)EffectInfo.Value; } auraApplication.Target.UpdateVisibility(true); }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode != AuraEffectHandleMode.Normal && mode != AuraEffectHandleMode.Refresh) { return; } if (apply) { auraApplication.Target.Auras.RemoveAurasWithEffect(AuraEffectType.ShapeShift, this); auraApplication.Target.UpdateShapeShiftForm(this); } else { auraApplication.Target.ResetShapeShiftForm(); } auraApplication.Target.Attributes.UpdateDisplayPower(); }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); if (mode != AuraEffectHandleMode.Normal) { return; } if (apply) { auraApplication.Target.StealthSubtlety += (int)EffectInfo.Value; } else { auraApplication.Target.StealthSubtlety -= (int)EffectInfo.Value; } bool hasStealthAura = auraApplication.Target.Auras.HasAuraType(AuraEffectType.Stealth); UnitVisualEffectFlags visualEffectFlags = auraApplication.Target.Attributes.VisualEffectFlags; auraApplication.Target.Attributes.VisualEffectFlags = visualEffectFlags.SetFlag(UnitVisualEffectFlags.StealthTransparency, hasStealthAura); auraApplication.Target.UpdateVisibility(true); }
public bool SetCharmedBy(Unit charmer, CharmType type, AuraApplication aurApp = null) { if (!charmer) { return(false); } // dismount players when charmed if (IsTypeId(TypeId.Player)) { RemoveAurasByType(AuraType.Mounted); } if (charmer.IsTypeId(TypeId.Player)) { charmer.RemoveAurasByType(AuraType.Mounted); } Contract.Assert(type != CharmType.Possess || charmer.IsTypeId(TypeId.Player)); Contract.Assert((type == CharmType.Vehicle) == IsVehicle()); Log.outDebug(LogFilter.Unit, "SetCharmedBy: charmer {0} (GUID {1}), charmed {2} (GUID {3}), type {4}.", charmer.GetEntry(), charmer.GetGUID().ToString(), GetEntry(), GetGUID().ToString(), type); if (this == charmer) { Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: Unit {0} (GUID {1}) is trying to charm itself!", GetEntry(), GetGUID().ToString()); return(false); } if (IsTypeId(TypeId.Player) && ToPlayer().GetTransport()) { Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: Player on transport is trying to charm {0} (GUID {1})", GetEntry(), GetGUID().ToString()); return(false); } // Already charmed if (!GetCharmerGUID().IsEmpty()) { Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: {0} (GUID {1}) has already been charmed but {2} (GUID {3}) is trying to charm it!", GetEntry(), GetGUID().ToString(), charmer.GetEntry(), charmer.GetGUID().ToString()); return(false); } CastStop(); CombatStop(); // @todo CombatStop(true) may cause crash (interrupt spells) DeleteThreatList(); Player playerCharmer = charmer.ToPlayer(); // Charmer stop charming if (playerCharmer) { playerCharmer.StopCastingCharm(); playerCharmer.StopCastingBindSight(); } // Charmed stop charming if (IsTypeId(TypeId.Player)) { ToPlayer().StopCastingCharm(); ToPlayer().StopCastingBindSight(); } // StopCastingCharm may remove a possessed pet? if (!IsInWorld) { Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: {0} (GUID {1}) is not in world but {2} (GUID {3}) is trying to charm it!", GetEntry(), GetGUID().ToString(), charmer.GetEntry(), charmer.GetGUID().ToString()); return(false); } // charm is set by aura, and aura effect remove handler was called during apply handler execution // prevent undefined behaviour if (aurApp != null && aurApp.GetRemoveMode() != 0) { return(false); } _oldFactionId = getFaction(); SetFaction(charmer.getFaction()); // Set charmed charmer.SetCharm(this, true); Player player; if (IsTypeId(TypeId.Unit)) { ToCreature().GetAI().OnCharmed(true); GetMotionMaster().MoveIdle(); } else if (player = ToPlayer()) { if (player.isAFK()) { player.ToggleAFK(); } Creature creatureCharmer = charmer.ToCreature(); if (charmer.IsTypeId(TypeId.Unit)) // we are charmed by a creature { // change AI to charmed AI on next Update tick NeedChangeAI = true; if (IsAIEnabled) { IsAIEnabled = false; player.GetAI().OnCharmed(true); } } player.SetClientControl(this, false); } // charm is set by aura, and aura effect remove handler was called during apply handler execution // prevent undefined behaviour if (aurApp != null && aurApp.GetRemoveMode() != 0) { return(false); } // Pets already have a properly initialized CharmInfo, don't overwrite it. if (type != CharmType.Vehicle && GetCharmInfo() == null) { InitCharmInfo(); if (type == CharmType.Possess) { GetCharmInfo().InitPossessCreateSpells(); } else { GetCharmInfo().InitCharmCreateSpells(); } } if (playerCharmer) { switch (type) { case CharmType.Vehicle: SetFlag(UnitFields.Flags, UnitFlags.PlayerControlled); playerCharmer.SetClientControl(this, true); playerCharmer.VehicleSpellInitialize(); break; case CharmType.Possess: AddUnitState(UnitState.Possessed); SetFlag(UnitFields.Flags, UnitFlags.PlayerControlled); charmer.SetFlag(UnitFields.Flags, UnitFlags.RemoveClientControl); playerCharmer.SetClientControl(this, true); playerCharmer.PossessSpellInitialize(); break; case CharmType.Charm: if (IsTypeId(TypeId.Unit) && charmer.GetClass() == Class.Warlock) { CreatureTemplate cinfo = ToCreature().GetCreatureTemplate(); if (cinfo != null && cinfo.CreatureType == CreatureType.Demon) { // to prevent client crash SetByteValue(UnitFields.Bytes0, 1, (byte)Class.Mage); // just to enable stat window if (GetCharmInfo() != null) { GetCharmInfo().SetPetNumber(Global.ObjectMgr.GeneratePetNumber(), true); } // if charmed two demons the same session, the 2nd gets the 1st one's name SetUInt32Value(UnitFields.PetNameTimestamp, (uint)Time.UnixTime); // cast can't be helped } } playerCharmer.CharmSpellInitialize(); break; default: case CharmType.Convert: break; } } return(true); }
public override void HandleEffect(AuraApplication auraApplication, AuraEffectHandleMode mode, bool apply) { base.HandleEffect(auraApplication, mode, apply); auraApplication.Target.UpdateControlState(UnitControlState.Root, apply); }
public bool SetCharmedBy(Unit charmer, CharmType type, AuraApplication aurApp = null) { if (!charmer) { return(false); } // dismount players when charmed if (IsTypeId(TypeId.Player)) { RemoveAurasByType(AuraType.Mounted); } if (charmer.IsTypeId(TypeId.Player)) { charmer.RemoveAurasByType(AuraType.Mounted); } Cypher.Assert(type != CharmType.Possess || charmer.IsTypeId(TypeId.Player)); Cypher.Assert((type == CharmType.Vehicle) == (GetVehicleKit() && GetVehicleKit().IsControllableVehicle())); Log.outDebug(LogFilter.Unit, "SetCharmedBy: charmer {0} (GUID {1}), charmed {2} (GUID {3}), type {4}.", charmer.GetEntry(), charmer.GetGUID().ToString(), GetEntry(), GetGUID().ToString(), type); if (this == charmer) { Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: Unit {0} (GUID {1}) is trying to charm itself!", GetEntry(), GetGUID().ToString()); return(false); } if (IsTypeId(TypeId.Player) && ToPlayer().GetTransport()) { Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: Player on transport is trying to charm {0} (GUID {1})", GetEntry(), GetGUID().ToString()); return(false); } // Already charmed if (!GetCharmerGUID().IsEmpty()) { Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: {0} (GUID {1}) has already been charmed but {2} (GUID {3}) is trying to charm it!", GetEntry(), GetGUID().ToString(), charmer.GetEntry(), charmer.GetGUID().ToString()); return(false); } CastStop(); CombatStop(); // @todo CombatStop(true) may cause crash (interrupt spells) Player playerCharmer = charmer.ToPlayer(); // Charmer stop charming if (playerCharmer) { playerCharmer.StopCastingCharm(); playerCharmer.StopCastingBindSight(); } // Charmed stop charming if (IsTypeId(TypeId.Player)) { ToPlayer().StopCastingCharm(); ToPlayer().StopCastingBindSight(); } // StopCastingCharm may remove a possessed pet? if (!IsInWorld) { Log.outFatal(LogFilter.Unit, "Unit:SetCharmedBy: {0} (GUID {1}) is not in world but {2} (GUID {3}) is trying to charm it!", GetEntry(), GetGUID().ToString(), charmer.GetEntry(), charmer.GetGUID().ToString()); return(false); } // charm is set by aura, and aura effect remove handler was called during apply handler execution // prevent undefined behaviour if (aurApp != null && aurApp.GetRemoveMode() != 0) { return(false); } _oldFactionId = GetFaction(); SetFaction(charmer.GetFaction()); // Pause any Idle movement PauseMovement(0, 0, false); // Remove any active voluntary movement GetMotionMaster().Clear(MovementGeneratorPriority.Normal); // Stop any remaining spline, if no involuntary movement is found Func <MovementGenerator, bool> criteria = movement => movement.Priority == MovementGeneratorPriority.Highest; if (!GetMotionMaster().HasMovementGenerator(criteria)) { StopMoving(); } // Set charmed charmer.SetCharm(this, true); Player player = ToPlayer(); if (player) { if (player.IsAFK()) { player.ToggleAFK(); } player.SetClientControl(this, false); } // charm is set by aura, and aura effect remove handler was called during apply handler execution // prevent undefined behaviour if (aurApp != null && aurApp.GetRemoveMode() != 0) { return(false); } // Pets already have a properly initialized CharmInfo, don't overwrite it. if (type != CharmType.Vehicle && GetCharmInfo() == null) { InitCharmInfo(); if (type == CharmType.Possess) { GetCharmInfo().InitPossessCreateSpells(); } else { GetCharmInfo().InitCharmCreateSpells(); } } if (playerCharmer) { switch (type) { case CharmType.Vehicle: AddUnitFlag(UnitFlags.Possessed); playerCharmer.SetClientControl(this, true); playerCharmer.VehicleSpellInitialize(); break; case CharmType.Possess: AddUnitFlag(UnitFlags.Possessed); charmer.AddUnitFlag(UnitFlags.RemoveClientControl); playerCharmer.SetClientControl(this, true); playerCharmer.PossessSpellInitialize(); AddUnitState(UnitState.Possessed); break; case CharmType.Charm: if (IsTypeId(TypeId.Unit) && charmer.GetClass() == Class.Warlock) { CreatureTemplate cinfo = ToCreature().GetCreatureTemplate(); if (cinfo != null && cinfo.CreatureType == CreatureType.Demon) { // to prevent client crash SetClass(Class.Mage); // just to enable stat window if (GetCharmInfo() != null) { GetCharmInfo().SetPetNumber(Global.ObjectMgr.GeneratePetNumber(), true); } // if charmed two demons the same session, the 2nd gets the 1st one's name SetPetNameTimestamp((uint)GameTime.GetGameTime()); // cast can't be helped } } playerCharmer.CharmSpellInitialize(); break; default: case CharmType.Convert: break; } } AddUnitState(UnitState.Charmed); if (!IsPlayer() || !charmer.IsPlayer()) { // AI will schedule its own change if appropriate UnitAI ai = GetAI(); if (ai != null) { ai.OnCharmed(false); } else { ScheduleAIChange(); } } return(true); }