public static void IsFriendly(SpellEffectHandler effectHandler, WorldObject target, ref SpellFailedReason failedReason) { if (effectHandler.Cast.CasterObject.MayAttack(target)) { failedReason = SpellFailedReason.TargetEnemy; } }
protected override void Apply(WorldObject target) { var chr = (Character)target; if (Effect.Spell.RequiredItemClass == ItemClass.Weapon && !chr.Skills.WeaponProficiency.HasAnyFlag(Effect.Spell.RequiredItemSubClassMask)) { chr.Skills.WeaponProficiency |= Effect.Spell.RequiredItemSubClassMask; CharacterHandler.SendProficiency(chr, ItemClass.Weapon, chr.Skills.WeaponProficiency); } else if (Effect.Spell.RequiredItemClass == ItemClass.Armor && !chr.Skills.ArmorProficiency.HasAnyFlag(Effect.Spell.RequiredItemSubClassMask)) { chr.Skills.ArmorProficiency |= Effect.Spell.RequiredItemSubClassMask; CharacterHandler.SendProficiency(chr, ItemClass.Armor, chr.Skills.ArmorProficiency); } if (Effect.Spell.Ability == null) { log.Warn("Spell {0} had Handler for Proficiency but Spell has no Skill associated with it.", Effect.Spell); } else if (!chr.Skills.Contains(Effect.Spell.Ability.Skill.Id)) { chr.Skills.Add(Effect.Spell.Ability.Skill, false); } }
public override SpellFailedReason InitializeTarget(WorldObject target) { //if (((Unit)target).Health >= ((Unit)target).MaxHealth) { // return SpellFailedReason.AlreadyAtFullHealth; //} return SpellFailedReason.Ok; }
protected override void Apply(WorldObject target) { if (Effect.Spell.IsHearthStoneSpell && m_cast.CasterChar != null) { // teleport back home var pos = m_cast.CasterChar.BindLocation; target.AddMessage(() => ((Unit)target).TeleportTo(pos)); } else { if (Effect.ImplicitTargetB == ImplicitSpellTargetType.BehindTargetLocation) { var unit = (Unit)target; if (unit != null) { var o = unit.Orientation; var newx = unit.Position.X - (unit.BoundingRadius + 0.5f) * (float)Math.Cos(o); var newy = unit.Position.Y - (unit.BoundingRadius + 0.5f) * (float)Math.Sin(o); var newpos = new Util.Graphics.Vector3(newx, newy, unit.Position.Z); m_cast.CasterChar.TeleportTo(newpos, o); } } else { // teleport to given target location var map = m_cast.TargetMap; var pos = m_cast.TargetLoc; var ori = m_cast.TargetOrientation; target.AddMessage(() => ((Unit)target).TeleportTo(map, pos, ori)); } } }
protected override void Apply(WorldObject target) { var npc = (NPC)target; npc.ThreatCollection[(Unit)m_cast.Caster] += ((Unit)m_cast.Caster).GetGeneratedThreat(CalcEffectValue(), Effect.Spell.Schools[0], Effect); }
/// <summary> /// Duel target type /// </summary> /// <param name="targets"></param> /// <param name="target"></param> /// <param name="failedReason"></param> public static void IsHostileOrHealable(SpellEffectHandler effectHandler, WorldObject target, ref SpellFailedReason failedReason) { var caster = effectHandler.Cast.CasterObject; var spell = effectHandler.Cast.Spell; var isHarmful = spell.HasHarmfulEffects; var isHarmfulAndBeneficial = spell.HasHarmfulEffects == spell.HasBeneficialEffects; if (!isHarmfulAndBeneficial) { if (isHarmful != caster.MayAttack(target)) { if (isHarmful) { failedReason = SpellFailedReason.TargetFriendly; } else { failedReason = SpellFailedReason.TargetEnemy; } } else if (isHarmful && !target.CanBeHarmed) { failedReason = SpellFailedReason.NotHere; } } }
protected override void Apply(WorldObject target) { Unit unit; if (target is Unit) { unit = (Unit) target; } else if (target is Corpse) { unit = ((Corpse)target).Owner; if (unit == null || unit.IsAlive) { return; } } else { return; } unit.Health = CalcEffectValue(); if (((Unit)target).PowerType == PowerType.Mana) { ((Unit)target).Energize(Effect.MiscValue, m_cast.CasterUnit, Effect); } }
protected override void Apply(WorldObject target) { var chr = target as Character; chr.TaxiNodes.Activate((uint)Effect.MiscValue); TaxiHandler.SendTaxiPathActivated(chr.Client); TaxiHandler.SendTaxiPathUpdate(chr.Client, Cast.CasterUnit.EntityId, true); }
protected override void Apply(WorldObject target) { if (!target.IsPlayer) { base.Apply(target); } }
/// <summary> /// Creates gossip conversation by its fields /// </summary> /// <param name="menu">starting menu</param> /// <param name="chr">character which started the conversation</param> /// <param name="speaker">respondent</param> public GossipConversation(GossipMenu menu, Character chr, WorldObject speaker, bool keepOpen) { CurrentMenu = menu; Character = chr; Speaker = speaker; StayOpen = keepOpen; }
protected override void Apply(WorldObject target) { var chr = target as Character; if (chr != null) { if (target.IsFriendlyWith(Cast.CasterChar)) { chr.Auras.RemoveFirstVisibleAura(aura => aura.Spell.HasHarmfulEffects); if (Cast.Spell.Id == (int)SpellId.ClassSkillDispelMagicRank2) { chr.Auras.RemoveFirstVisibleAura(aura => aura.Spell.HasHarmfulEffects); } if (Cast.CasterChar.Spells.Contains(SpellId.GlyphOfDispelMagic) || Cast.CasterChar.Spells.Contains(SpellId.GlyphOfDispelMagic_2)) { int amountToHeal = (chr.Health * 3) / 100; chr.Target.Heal(amountToHeal, Cast.CasterChar, Effect); } } else { chr.Auras.RemoveFirstVisibleAura(aura => aura.Spell.HasBeneficialEffects); if (Cast.Spell.Id == (int)SpellId.ClassSkillDispelMagicRank2) { chr.Auras.RemoveFirstVisibleAura(aura => aura.Spell.HasHarmfulEffects); } } } }
protected override void Apply(WorldObject target) { if (target.IsUsingSpell) { target.SpellCast.Cancel(SpellFailedReason.Interrupted); } }
public CasterInfo(WorldObject caster) { CasterId = caster.EntityId; Level = caster.CasterLevel; m_caster = caster; //Faction = caster.Faction; //ObjectType = caster.Type; }
protected override void Apply(WorldObject target) { var chr = target as Character; if (m_cast.CasterUnit != null && m_cast.CasterUnit is NPC) { chr.QuestLog.OnNPCInteraction((NPC)m_cast.CasterUnit); } }
public bool MatchesRequiredTargetType(WorldObject obj) { if (RequiredTargetType == RequiredSpellTargetType.GameObject) { return obj is GameObject; } return obj is NPC && ((NPC) obj).IsAlive == (RequiredTargetType == RequiredSpellTargetType.NPCAlive); }
protected override void Apply(WorldObject target) { if (((Unit)target).PowerType == PowerType.Mana) { var manavalue = ((((Unit)target).MaxPower * Effect.MiscValue) / 100); ((Unit)target).Energize(m_cast.Caster, manavalue, Effect); } }
public override SpellFailedReason InitializeTarget(WorldObject target) { //if (!target.IsUsingSpell) //{ // return SpellFailedReason. //} return base.InitializeTarget(target); }
public override SpellFailedReason InitializeTarget(WorldObject target) { if (((Unit)target).Power == ((Unit)target).MaxPower) { return ((Unit)target).PowerType == PowerType.Mana ? SpellFailedReason.AlreadyAtFullMana : SpellFailedReason.AlreadyAtFullPower; } return base.InitializeTarget(target); }
public override SpellFailedReason InitializeTarget(WorldObject target) { if (!((Unit)target).MayTeleport) { return SpellFailedReason.TargetAurastate; } return SpellFailedReason.Ok; }
public ObjectReference(WorldObject obj) { EntityId = obj.EntityId; Level = obj.CasterLevel; m_Object = obj; //Faction = caster.Faction; //ObjectType = caster.Type; }
public override SpellFailedReason InitializeTarget(WorldObject target) { if (((Unit)target).Spells.Contains(toLearn.Id)) { return SpellFailedReason.SpellLearned; } return SpellFailedReason.Ok; }
public override SpellFailedReason CheckValidTarget(WorldObject target) { //if (!target.IsUsingSpell) //{ // return SpellFailedReason. //} return base.CheckValidTarget(target); }
protected override void Apply(WorldObject target) { if (((Unit)target).PowerType == PowerType.Mana) { var manavalue = (int)((((Unit)target).MaxPower * CalcEffectValue()) / 100f); ((Unit)target).Energize(manavalue, m_cast.CasterUnit, Effect); } }
public void Spawn() { if (TeleporterObject == null || !TeleporterObject.IsInWorld) { var go = TeleporterObject = ObjectCreator(this); Region.AddObject(go, ref m_Position); } }
protected override void Apply(WorldObject target) { var chr = target as Character; if (chr != null) { chr.Auras.RemoveWhere(aura => SpellConstants.MoveMechanics[(int)aura.Spell.Mechanic] || aura.Handlers.Any(handler => SpellConstants.MoveMechanics[(int)handler.SpellEffect.Mechanic])); } }
public override SpellFailedReason InitializeTarget(WorldObject target) { if (!(target is NPC)) { return SpellFailedReason.DontReport; } return SpellFailedReason.Ok; }
public override SpellFailedReason InitializeTarget(WorldObject target) { if (((Unit)target).MaxPower == 0 || ((Unit)target).PowerType != (PowerType)Effect.MiscValue) { return SpellFailedReason.BadTargets; } return SpellFailedReason.Ok; }
public static void IsSameClass(SpellEffectHandler effectHandler, WorldObject target, ref SpellFailedReason failedReason) { var caster = effectHandler.Cast.CasterUnit; if (caster == null || !(target is Unit) || caster.Class != ((Unit)target).Class) { failedReason = SpellFailedReason.BadTargets; } }
protected override void Apply(WorldObject target) { var whelp = NPCMgr.GetEntry(NPCId.RookeryWhelp); whelp.AllianceFactionId = FactionTemplateId.Enemy; whelp.HordeFactionId = FactionTemplateId.Enemy; whelp.UnitFlags = UnitFlags.Combat; whelp.SpawnAt(target.Map, target.Position); }
protected override void Apply(WorldObject target) { var cast = m_cast; if (cast != null) { var caster = cast.Caster; //((Unit)caster).EmoteState } }