Beispiel #1
0
		/// <summary>
		/// Checks whether the given target resisted the debuff, represented through the given spell
		/// </summary>
		public static CastMissReason CheckDebuffResist(Unit target, Spell spell, int casterLevel, bool hostile)
		{
			var missReason = CastMissReason.None;
			if (hostile && target.CheckDebuffResist(casterLevel, target.GetLeastResistantSchool(spell)))
			{
				missReason = CastMissReason.Resist;
			}
			return missReason;
		}
Beispiel #2
0
		/// <summary>
		/// Get's Basepoints for a spell after applying DamageMods.
		/// </summary>
		public int GetModifiedDamage(Unit caster)
		{
			if (IsPeriodic)
			{
				return caster.Auras.GetModifiedInt(SpellModifierType.PeriodicEffectValue, this.Spell, CalcEffectValue());
			}
			else
			{
				return caster.GetFinalDamage(caster.GetLeastResistantSchool(this.Spell), CalcEffectValue(), this.Spell);
			}
		}
Beispiel #3
0
		/// <summary>
		/// Indicates whether a spell hit a target or not
		/// TODO: Actually check whether a spell 'Misses' (CastMissReason.Miss)
		/// </summary>
		public CastMissReason CheckCastHit(Unit target, Spell spell)
		{
			if (CasterObject != null && CasterObject.MayAttack(target))
			{
				var school = target.GetLeastResistantSchool(spell);
				// evasion
				if (target.IsEvading)
				{
					return CastMissReason.Evade;
				}
				// immune & invul
				if (!spell.Attributes.HasFlag(SpellAttributes.UnaffectedByInvulnerability) ||
					(target is Character && ((Character)target).Role.IsStaff))
				{
					if (target.IsInvulnerable)
					{
						return CastMissReason.Immune_2;
					}

					if (spell.Schools.All(target.IsImmune))
					{
						return CastMissReason.Immune;
					}
				}

				//// avoid/miss
				//var avoidance = target.GetSpellAvoidancePct(school);
				//if (avoidance > 0 && Utility.Random(1, 101) < avoidance)
				//{
				//    return CastMissReason.Miss;
				//}


				// resist
				if (target.CheckResist(CasterUnit, school, spell.Mechanic) && !spell.AttributesExB.HasFlag(SpellAttributesExB.CannotBeResisted))
				{
					return CastMissReason.Resist;
				}
			}

			return CastMissReason.None;
		}