示例#1
0
 protected internal override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
 {
     if (!(target is Character))
     {
         failReason = SpellFailedReason.TargetNotPlayer;
     }
 }
示例#2
0
		protected internal override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
		{
			Caster = casterReference.Object as Unit;
			if (Caster == null || Caster is Vehicle)
			{
				log.Warn("Invalid SpellCaster \"{0}\" for Spell: {1}", Caster, SpellEffect.Spell);
				failReason = SpellFailedReason.Error;
				return;
			}

			Vehicle = target as Vehicle;
			if (Vehicle == null)
			{
				failReason = SpellFailedReason.BadTargets;
			}
			else
			{
				Seat = Vehicle.GetSeatFor(Caster);
				if (Seat == null)
				{
					// must never happen since Vehicle is unclickable when full
					failReason = SpellFailedReason.BadTargets;
				}
			}
		}
示例#3
0
 protected internal override void CheckInitialize(SpellCast creatingCast, ObjectReference casterRef, Unit target, ref SpellFailedReason failReason)
 {
     var caster = creatingCast.CasterReference.Object as Unit;
     if (caster == null)
     {
         failReason = SpellFailedReason.BadTargets;
     }
     else
     {
         if (caster.Charm != null)
         {
             failReason = SpellFailedReason.AlreadyHaveCharm;
         }
         else if (target.HasMaster)
         {
             failReason = SpellFailedReason.CantDoThatRightNow;
         }
         else if (caster.HasMaster)
         {
             failReason = SpellFailedReason.Possessed;
         }
         else if (caster is Character)
         {
             if (((Character)caster).ActivePet != null)
             {
                 failReason = SpellFailedReason.AlreadyHaveSummon;
             }
         }
     }
 }
示例#4
0
		protected internal override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
		{
			if (target.MaxPower == 0 || target.PowerType != (PowerType)m_spellEffect.MiscValue)
			{
				failReason = SpellFailedReason.BadTargets;
			}
		}
示例#5
0
        protected internal override void CheckInitialize(SpellCast creatingCast, ObjectReference casterRef, Unit target, ref SpellFailedReason failReason)
        {
            if (!(target is NPC))
            {
                failReason = SpellFailedReason.BadTargets;
            }

            if (casterRef != null && casterRef.Object is Unit)
            {
                var caster = (Unit)casterRef.Object;
                //if (target.Target == caster)
                //{
                //    failReason = SpellFailedReason.NoValidTargets;
                //}
                //else
                {
                    var spell = m_aura.Spell;
                    var hasSingleFriendTarget = spell.HasBeneficialEffects && !spell.IsAreaSpell && spell.HasTargets;
                    if (hasSingleFriendTarget && caster.Target != null && caster.IsFriendlyWith(caster.Target))
                    {
                        // taunting a friend, means we want to taunt his attackers
                        // needed for Righteous defense, amongst others
                        if (target.Target != caster.Target)
                        {
                            failReason = SpellFailedReason.NoValidTargets;
                        }
                    }
                }
            }
        }
		protected internal override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
		{
			if (m_spellEffect.TriggerSpell == null)
			{
				failReason = SpellFailedReason.Error;
				log.Warn("Tried to cast Spell \"{0}\" which has invalid TriggerSpellId {1}", m_spellEffect.Spell, m_spellEffect.TriggerSpellId);
			}
		}
		protected internal override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
		{
			if (target.Class != ClassId.Hunter)
			{
				failReason = SpellFailedReason.BadTargets;
				return;
			}
		}
示例#8
0
 protected internal override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
 {
     if (!(target is Character)) return;
     var chr = (Character)target;
     if (chr.Class != ClassId.Hunter)
     {
         failReason = SpellFailedReason.BadTargets;
     }
 }
示例#9
0
文件: Fly.cs 项目: ebakkedahl/WCell
 protected internal override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
 {
     if (target is Character)
     {
         var chr = (Character)target;
         if (!chr.CanFly)
         {
             failReason = SpellFailedReason.NotHere;
         }
     }
 }
示例#10
0
        /// <summary>
        /// Ensure that the constraints are correct for the Flag aura to be applied
        /// </summary>
        protected override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
        {
			if (!(target is Character))
			{
				failReason = SpellFailedReason.BadTargets;
			}
			else
			{
				Instance = target.Region as WarsongGulch;
				if (Instance == null)
				{
					failReason = SpellFailedReason.IncorrectArea;
				}
			}
        }
示例#11
0
		protected internal override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
		{
			form = (ShapeshiftForm)SpellEffect.MiscValue;
			if (target.ShapeshiftForm == form)
			{
				// stances can't be undone:
				if (form != ShapeshiftForm.BattleStance &&
					form != ShapeshiftForm.BerserkerStance &&
					form != ShapeshiftForm.DefensiveStance)
				{
					target.Auras.RemoveWhere(aura => aura.Spell.Id == m_aura.Spell.Id);
					failReason = SpellFailedReason.DontReport;
				}
			}
		}
示例#12
0
			protected override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
			{
				if (target is Character)
				{
					var chr = (Character)target;
					var ap = target.TotalMeleeAP;
					var sp = chr.GetDamageDoneMod(DamageSchool.Holy);
					if (ap > sp)
					{
						totalBonus = ap;
					}
					else
					{
						totalBonus = sp;
					}
				}
			}
示例#13
0
		/// <summary>
		/// Creates a new AreaAura which applies its effects to everyone in its radius of influence
		/// </summary>
		protected void Init(WorldObject holder, Spell spell)
		{
			m_holder = holder;
			if (holder is DynamicObject)
			{
				m_CasterReference = holder.Master.SharedReference;
			}
			else
			{
				m_CasterReference = holder.SharedReference;
			}

			m_spell = spell;
			if (spell.IsAreaAura)
			{
				m_targets = new Dictionary<Unit, Aura>();
			}

			holder.AddAreaAura(this);
		}
示例#14
0
		protected internal override void CheckInitialize(SpellCast creatingCast, ObjectReference casterRef, Unit target, ref SpellFailedReason failReason)
		{
			var caster = creatingCast.CasterReference.Object as Unit;
			if (caster == null)
			{
				failReason = SpellFailedReason.BadTargets;
			}
			else
			{
				if (!(target is NPC))
				{
					LogManager.GetCurrentClassLogger().Warn("{0} tried to Charm {1} which is not an NPC, but Player charming is not yet supported.", caster, target);
					failReason = SpellFailedReason.BadTargets;
				}
				if (caster.Charm != null)
				{
					failReason = SpellFailedReason.AlreadyHaveCharm;
				}
				else if (target.HasMaster)
				{
					failReason = SpellFailedReason.CantBeCharmed;
				}
				//else if (caster.Level < EffectValue)
				//{
				//    failReason = SpellFailedReason.Highlevel;
				//}
				else if (caster.HasMaster)
				{
					failReason = SpellFailedReason.Charmed;
				}
				else if (caster is Character)
				{
					if (((Character)caster).ActivePet != null)
					{
						failReason = SpellFailedReason.AlreadyHaveSummon;
					}
				}
			}
		}
示例#15
0
		public float GetRadius(ObjectReference caster)
		{
			var radius = Radius;
			var chr = caster.UnitMaster;
			if (chr != null)
			{
				radius = chr.Auras.GetModifiedFloat(SpellModifierType.Radius, Spell, radius);
			}
			if (radius < 5)
			{
				return 5;
			}
			return radius;
		}
示例#16
0
		public int CalcEffectValue(ObjectReference casterReference)
		{
			var caster = casterReference.UnitMaster;
			if (caster != null)
			{
				return CalcEffectValue(caster);
			}
			else
			{
				return CalcEffectValue(casterReference.Level, 0, false);
			}
		}
示例#17
0
		internal AuraEffectHandler CreateAuraEffectHandler(ObjectReference caster,
			Unit target, ref SpellFailedReason failedReason, SpellCast triggeringCast)
		{
			var handler = AuraEffectHandlerCreator();

			if (triggeringCast != null &&
				triggeringCast.TriggerEffect != null &&
				triggeringCast.TriggerEffect.OverrideEffectValue)
			{
				if (Spell.Effects.Length > 1)
				{
					// it does not make sense to override multiple effects with a single effect...
					log.Warn("Spell {0} had overriding SpellEffect although the spell that was triggered had {2} (> 1) effects",
						Spell, Spell.Effects.Length);
				}
				handler.m_spellEffect = triggeringCast.TriggerEffect;
			}
			else
			{
				handler.m_spellEffect = this;
			}

			handler.BaseEffectValue = CalcEffectValue(caster);
			handler.CheckInitialize(triggeringCast, caster, target, ref failedReason);
			return handler;
		}
示例#18
0
		public AuraEffectHandler CreateAuraEffectHandler(ObjectReference caster,
															  Unit target, ref SpellFailedReason failedReason)
		{
			return CreateAuraEffectHandler(caster, target, ref failedReason, null);
		}
示例#19
0
		/// <summary>		
		/// Check whether this handler can be applied to the given target.
		/// m_aura, as well as some other fields are not set when this method gets called.
		/// </summary>
		protected internal virtual void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
		{
		}
示例#20
0
文件: Spell.Aura.cs 项目: Jeroz/WCell
		public AuraIndexId GetAuraUID(ObjectReference caster, WorldObject target)
		{
			return GetAuraUID(IsBeneficialFor(caster, target));
		}
示例#21
0
        public static void WriteChanneledSpells()
        {
            List<Spell> spells = new List<Spell>(1000);
            foreach (Spell spell in SpellHandler.ById)
            {
                if (spell == null)
                    continue;

                if (spell.IsChanneled)
                {
                    spells.Add(spell);
                }
            }

            using (var writer = new StreamWriter(ToolConfig.OutputDir + "ChanneledSpells.txt", false))
            {
                var caster = new ObjectReference();
                foreach (var spell in spells)
                {
                    writer.WriteLine("Spell: " + spell);
                    bool hasAmpl = false;
                    bool hasCustomScript = false;
                    foreach (SpellEffect effect in spell.Effects)
                    {
                        effect.DumpInfo(writer, "\t");
                        hasAmpl = hasAmpl || effect.Amplitude > 0;
                        hasCustomScript = hasCustomScript || effect.IsScripted;
                    }
                    if (spell.GetDuration(caster, null) < 1)
                    {
                        Console.WriteLine(spell);
                    }
                    writer.WriteLine();
                    writer.WriteLine();
                }
            }
        }
示例#22
0
文件: SpellCast.cs 项目: primax/WCell
		public static SpellCast ObtainPooledCast(ObjectReference caster, Map map, uint phase, ref Vector3 sourceLoc)
		{
			var cast = SpellCastPool.Obtain();
			cast.SetCaster(caster, map, phase, sourceLoc);
			return cast;
		}
示例#23
0
文件: Spell.cs 项目: ebakkedahl/WCell
 /// <summary>
 /// Returns the max duration for this Spell in milliseconds,
 /// including all modifiers.
 /// </summary>
 public int GetDuration(ObjectReference caster)
 {
     return GetDuration(caster, null);
 }
示例#24
0
文件: Spell.cs 项目: ebakkedahl/WCell
 public bool IsBeneficialFor(ObjectReference casterReference, WorldObject target)
 {
     return IsBeneficial || (IsNeutral && (casterReference.Object == null || !casterReference.Object.MayAttack(target)));
 }
示例#25
0
		protected override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
		{
			// remember the damageAmount from the TriggerAction
			if (creatingCast != null && creatingCast.TriggerAction is HealAction)
			{
				damageAmount = ((HealAction)creatingCast.TriggerAction).Value;
			}
			else
			{
				failReason = SpellFailedReason.Error;
			}
		}
示例#26
0
		protected internal override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
		{
			//if (target.PowerType != WCell.Core.PowerType.Mana) {
			//    failReason = SpellFailedReason.AlreadyAtFullPower;
			//}
		}
示例#27
0
文件: Spell.cs 项目: ebakkedahl/WCell
 public bool IsHarmfulFor(ObjectReference casterReference, WorldObject target)
 {
     return IsHarmful || (IsNeutral && casterReference.Object != null && casterReference.Object.MayAttack(target));
 }
示例#28
0
文件: SpellCast.cs 项目: primax/WCell
		private void SetCaster(ObjectReference caster, Map map, uint phase, Vector3 sourceLoc)
		{
			CasterReference = caster;
			if (caster == null)
			{
				throw new ArgumentNullException("caster");
			}
			CasterObject = caster.Object;
			CasterUnit = caster.UnitMaster;
			Map = map;
			Phase = phase;
			SourceLoc = sourceLoc;
		}
示例#29
0
文件: Spell.cs 项目: ebakkedahl/WCell
        /// <summary>
        /// Returns the max duration for this Spell in milliseconds,
        /// including all modifiers.
        /// </summary>
        public int GetDuration(ObjectReference caster, Unit target)
        {
            var millis = Durations.Min;
            //if (Durations.LevelDelta > 0)
            //{
            //	millis += (int)caster.Level * Durations.LevelDelta;
            //	if (Durations.Max > 0 && millis > Durations.Max)
            //	{
            //		millis = Durations.Max;
            //	}
            //}

            if (Durations.Max > Durations.Min && IsFinishingMove && caster.UnitMaster != null)
            {
                // For some finishing moves, Duration depends on Combopoints
                millis += caster.UnitMaster.ComboPoints * ((Durations.Max - Durations.Min) / 5);
            }

            if (target != null && Mechanic != SpellMechanic.None)
            {
                var mod = target.GetMechanicDurationMod(Mechanic);
                if (mod != 0)
                {
                    millis = UnitUpdates.GetMultiMod(mod / 100f, millis);
                }
            }

            var unit = caster.UnitMaster;
            if (unit != null)
            {
                millis = unit.Auras.GetModifiedInt(SpellModifierType.Duration, this, millis);
            }
            return millis;
        }
示例#30
0
文件: SpellCast.cs 项目: primax/WCell
		/// <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);
		}