Beispiel #1
0
		/// <summary>
		/// For all things that depend on info of all spells from first Init-round and other things
		/// </summary>
		internal void Init2()
		{
			if (inited)
			{
				return;
			}
			inited = true;

            IsChanneled = AttributesEx.HasAnyFlag(SpellAttributesEx.Channeled_1 | SpellAttributesEx.Channeled_2) ||	// don't use Enum.HasFlag!
				ChannelInterruptFlags > 0;

            IsPassive = (!IsChanneled && Attributes.HasFlag(SpellAttributes.Passive)) ||
				// tracking spells are also passive		     
						HasEffectWith(effect => effect.AuraType == AuraType.TrackCreatures) ||
						HasEffectWith(effect => effect.AuraType == AuraType.TrackResources) ||
						HasEffectWith(effect => effect.AuraType == AuraType.TrackStealthed);

			foreach (var effect in Effects)
			{
				effect.Init2();
				if (effect.IsHealEffect)
				{
					IsHealSpell = true;
				}
				if (effect.EffectType == SpellEffectType.NormalizedWeaponDamagePlus)
				{
					IsDualWieldAbility = true;
				}
			}

			InitAura();

			if (IsChanneled)
			{
				if (Durations.Min == 0)
				{
					Durations.Min = Durations.Max = 1000;
				}

				foreach (var effect in Effects)
				{
					if (effect.IsPeriodic)
					{
						ChannelAmplitude = effect.Amplitude;
						break;
					}
				}
			}

			IsOnNextStrike = Attributes.HasAnyFlag(SpellAttributes.OnNextMelee | SpellAttributes.OnNextMelee_2);	// don't use Enum.HasFlag!

			IsRangedAbility = !IsTriggeredSpell &&
				(Attributes.HasAnyFlag(SpellAttributes.Ranged) ||
					   AttributesExC.HasFlag(SpellAttributesExC.ShootRangedWeapon));

			IsStrikeSpell = HasEffectWith(effect => effect.IsStrikeEffect);

			IsWeaponAbility = IsRangedAbility || IsOnNextStrike || IsStrikeSpell;

			DamageIncreasedByAP = DamageIncreasedByAP || (PowerType == PowerType.Rage && SchoolMask == DamageSchoolMask.Physical);

			IsFinishingMove =
				AttributesEx.HasAnyFlag(SpellAttributesEx.FinishingMove) ||
				HasEffectWith(effect => effect.PointsPerComboPoint > 0 && effect.EffectType != SpellEffectType.Dummy);

			TotemEffect = GetFirstEffectWith(effect => effect.HasTarget(
				ImplicitTargetType.TotemAir, ImplicitTargetType.TotemEarth, ImplicitTargetType.TotemFire, ImplicitTargetType.TotemWater));

			// Required Item slot for weapon abilities
			if (RequiredItemClass == ItemClass.Armor && RequiredItemSubClassMask == ItemSubClassMask.Shield)
			{
				EquipmentSlot = EquipmentSlot.OffHand;
			}
			else
			{
				EquipmentSlot =
                    (IsRangedAbility || AttributesExC.HasFlag(SpellAttributesExC.RequiresWand)) ? EquipmentSlot.ExtraWeapon :
                    (AttributesExC.HasFlag(SpellAttributesExC.RequiresOffHandWeapon) ? EquipmentSlot.OffHand :
                    (AttributesExC.HasFlag(SpellAttributesExC.RequiresMainHandWeapon) ? EquipmentSlot.MainHand : EquipmentSlot.End));
			}

			HasIndividualCooldown = CooldownTime > 0 ||
				(IsWeaponAbility && !IsOnNextStrike && EquipmentSlot != EquipmentSlot.End);

			//IsAoe = HasEffectWith((effect) => {
			//    if (effect.ImplicitTargetA == ImplicitTargetType.)
			//        effect.ImplicitTargetA = ImplicitTargetType.None;
			//    if (effect.ImplicitTargetB == ImplicitTargetType.Unused_EnemiesInAreaChanneledWithExceptions)
			//        effect.ImplicitTargetB = ImplicitTargetType.None;
			//    return false;
			//});

			var profEffect = GetEffect(SpellEffectType.SkillStep);
			if (profEffect != null)
			{
				TeachesApprenticeAbility = profEffect.BasePoints == 0;
			}

			IsProfession = !IsRangedAbility && Ability != null && Ability.Skill.Category == SkillCategory.Profession;

			IsEnhancer = SpellClassSet != 0 && !SpellClassMask.Contains(val => val != 0) &&
				HasEffectWith(effect => effect.AffectMask.Contains(val => val != 0));

			IsFishing = HasEffectWith(effect => effect.HasTarget(ImplicitTargetType.SelfFishing));

			IsSkinning = HasEffectWith(effect => effect.EffectType == SpellEffectType.Skinning);

			IsTameEffect = HasEffectWith(effect => effect.EffectType == SpellEffectType.TameCreature);

			if (Id == 18425)
			{
				ToString();
			}
			if (IsPreventionDebuff || Mechanic.IsNegative())
			{
				HasHarmfulEffects = true;
				HasBeneficialEffects = false;
				HarmType = HarmType.Harmful;
			}
			else
			{
				HasHarmfulEffects = HasEffectWith(effect => effect.HarmType == HarmType.Harmful);
				HasBeneficialEffects = HasEffectWith(effect => effect.HarmType == HarmType.Beneficial);
				if (HasHarmfulEffects != HasBeneficialEffects && !HasEffectWith(effect => effect.HarmType == HarmType.Neutral))
				{
					HarmType = HasHarmfulEffects ? HarmType.Harmful : HarmType.Beneficial;
				}
				else
				{
					HarmType = HarmType.Neutral;
				}
			}

            ReqDeadTarget = TargetFlags.HasAnyFlag(SpellTargetFlags.Corpse | SpellTargetFlags.PvPCorpse | SpellTargetFlags.UnitCorpse);

			CostsMana = PowerCost > 0 || PowerCostPercentage > 0;

			HasTargets = !HasEffectWith(effect => effect.HasTargets);

			CasterIsTarget = HasTargets && HasEffectWith(effect => effect.HasTarget(ImplicitTargetType.Self));

			//HasSingleNotSelfTarget = 

			IsAreaSpell = HasEffectWith(effect => effect.IsAreaEffect);

			IsDamageSpell = HasHarmfulEffects && !HasBeneficialEffects && HasEffectWith(effect =>
					effect.EffectType == SpellEffectType.Attack ||
					effect.EffectType == SpellEffectType.EnvironmentalDamage ||
					effect.EffectType == SpellEffectType.InstantKill ||
					effect.EffectType == SpellEffectType.SchoolDamage ||
					effect.IsStrikeEffect);

			if (DamageMultipliers[0] <= 0)
			{
				DamageMultipliers[0] = 1;
			}

			IsHearthStoneSpell = HasEffectWith(effect => effect.HasTarget(ImplicitTargetType.HeartstoneLocation));

			ForeachEffect(effect =>
			{
				if (effect.EffectType == SpellEffectType.Skill)
				{
					SkillId = (SkillId)effect.MiscValue;
				}
			});

			Schools = Utility.GetSetIndices<DamageSchool>((uint)SchoolMask);
			if (Schools.Length == 0)
			{
				Schools = new[] { DamageSchool.Physical };
			}

			RequiresCasterOutOfCombat = !HasHarmfulEffects && CastDelay > 0 &&
                (Attributes.HasFlag(SpellAttributes.CannotBeCastInCombat) ||
                                        AttributesEx.HasFlag(SpellAttributesEx.RemainOutOfCombat) ||
                                        AuraInterruptFlags.HasFlag(AuraInterruptFlags.OnStartAttack));

			if (RequiresCasterOutOfCombat)
			{
				// We fail if being attacked (among others)
				InterruptFlags |= InterruptFlags.OnTakeDamage;
			}

            IsThrow = AttributesExC.HasFlag(SpellAttributesExC.ShootRangedWeapon) &&
                       Attributes.HasFlag(SpellAttributes.Ranged) && Ability != null && Ability.Skill.Id == SkillId.Thrown;

			HasModifierEffects = HasEffectWith(effect => effect.AuraType == AuraType.AddModifierFlat || effect.AuraType == AuraType.AddModifierPercent);
			ForeachEffect(effect =>
			{
				for (var i = 0; i < 3; i++)
				{
					AllAffectingMasks[i] |= effect.AffectMask[i];
				}
			});

			if (Range.MaxDist == 0)
			{
				Range.MaxDist = 5;
			}

			if (RequiredToolIds == null)
			{
				RequiredToolIds = new uint[0];
			}
			else
			{
				if (RequiredToolIds.Length > 0 && (RequiredToolIds[0] > 0 || RequiredToolIds[1] > 0))
				{
					SpellHandler.SpellsRequiringTools.Add(this);
				}
				ArrayUtil.PruneVals(ref RequiredToolIds);
			}

			ArrayUtil.PruneVals(ref RequiredTotemCategories);

			ForeachEffect(effect =>
			{
				if (effect.SpellEffectHandlerCreator != null)
				{
					EffectHandlerCount++;
				}
			});
			//IsHealSpell = HasEffectWith((effect) => effect.IsHealEffect);
		}
Beispiel #2
0
 public void injure(int value, CharacterInfo pOwner, HarmType pHarmType)
 {
     _characterInfo = pOwner;
     _harmType = pHarmType;
     injure(value);
     _harmType = HarmType.none;
     _characterInfo = null;
 }
Beispiel #3
0
 //public void injure(int value, WMPurse pAttackerPurse)
 //{
 //    _attackerPurse = pAttackerPurse;
 //    injure(value);
 //    _attackerPurse = null;
 //}
 //public void injure(int value, Hashtable pInjureInfo, WMPurse pAttackerPurse)
 //{
 //    attackerPurse = pAttackerPurse;
 //    injure(value, pInjureInfo);
 //    attackerPurse = null;
 //}
 public void injure(int value, HarmType pHarmType)
 {
     _harmType = pHarmType;
     injure(value);
     _harmType = HarmType.none;
 }
Beispiel #4
0
		internal void Init2()
		{
			// see http://www.wowhead.com/spell=25269 for comparison
			ValueMin = BasePoints + 1;
			ValueMax = BasePoints + DiceSides; // TODO: check this!

			IsTargetAreaEffect = TargetAreaEffects.Contains(ImplicitTargetA) || TargetAreaEffects.Contains(ImplicitTargetB);

			// prevent aoe and non-aoe effects from mixing together
			if (AreaEffects.Contains(ImplicitTargetA))
			{
				IsAreaEffect = true;
				if (ImplicitTargetB != ImplicitTargetType.None && AreaEffects.Contains(ImplicitTargetB))
				{
					ImplicitTargetB = ImplicitTargetType.None;
				}
			}
			else if (ImplicitTargetB != ImplicitTargetType.None && AreaEffects.Contains(ImplicitTargetB))
			{
				IsAreaEffect = true;
				ImplicitTargetA = ImplicitTargetType.None;
			}

			if (IsPeriodic = Amplitude > 0)
			{
				_IsPeriodicAura = (AuraType == AuraType.PeriodicDamage ||
								  AuraType == AuraType.PeriodicDamagePercent ||
								  AuraType == AuraType.PeriodicEnergize ||
								  AuraType == AuraType.PeriodicHeal ||
								  AuraType == AuraType.PeriodicHealthFunnel ||
								  AuraType == AuraType.PeriodicLeech ||
								  AuraType == AuraType.PeriodicManaLeech ||
								  AuraType == AuraType.PeriodicTriggerSpell);
			}

			if (Spell.IsPassive)
			{
				// proc effect etc
				HarmType = HarmType.Beneficial;
			}
			else if ((HasTarget(ImplicitTargetType.AllEnemiesAroundCaster,
				ImplicitTargetType.AllEnemiesInArea,
				ImplicitTargetType.AllEnemiesInAreaChanneled,
				ImplicitTargetType.AllEnemiesInAreaInstant,
				ImplicitTargetType.CurrentSelection) ||

				HasTarget(ImplicitTargetType.InFrontOfCaster,
						ImplicitTargetType.InvisibleOrHiddenEnemiesAtLocationRadius,
						ImplicitTargetType.LocationInFrontCaster,
						ImplicitTargetType.NetherDrakeSummonLocation,
						ImplicitTargetType.SelectedEnemyChanneled,
						ImplicitTargetType.SelectedEnemyDeadlyPoison,
						ImplicitTargetType.SingleEnemy,
						ImplicitTargetType.SpreadableDesease,
						ImplicitTargetType.TargetAtOrientationOfCaster)) &&

				(!HasTarget(
				ImplicitTargetType.Self,
				ImplicitTargetType.AllFriendlyInAura,
				ImplicitTargetType.AllParty,
				ImplicitTargetType.AllPartyAroundCaster,
				ImplicitTargetType.AllPartyInArea,
				ImplicitTargetType.PartyAroundCaster,
				ImplicitTargetType.AllPartyInAreaChanneled) ||

				Spell.Mechanic.IsNegative()))
			{
				HarmType = HarmType.Harmful;
			}
			else if (!HasTarget(ImplicitTargetType.Duel) && 
				(ImplicitTargetA != ImplicitTargetType.None || ImplicitTargetB != ImplicitTargetType.None))
			{
				HarmType = HarmType.Beneficial;
			}

			if (Spell.IsPassive)
			{
				// do some correction for ModManaRegen
				if (AuraType == AuraType.ModManaRegen && Amplitude == 0)
				{
					// 5000 ms if not specified otherwise
					Amplitude = ModManaRegenHandler.DefaultAmplitude;
				}
			}

			HasTargets = !NoTargetTypes.Contains(ImplicitTargetA) || !NoTargetTypes.Contains(ImplicitTargetB);

			HasSingleTarget = HasTargets && !IsAreaEffect;

			IsAreaAuraEffect = (EffectType == SpellEffectType.PersistantAreaAura ||
					EffectType == SpellEffectType.ApplyAreaAura ||
					EffectType == SpellEffectType.ApplyGroupAura);

			if (EffectType == SpellEffectType.ApplyGroupAura)
			{
				if (Radius > 0)
				{
					ImplicitTargetA = ImplicitTargetType.AllPartyInArea;
				}
				else
				{
					ImplicitTargetA = ImplicitTargetType.AllParty;
				}
			}

			IsAuraEffect = IsAreaAuraEffect ||
						   EffectType == SpellEffectType.ApplyAura ||
						   EffectType == SpellEffectType.ApplyAuraToMaster ||
						   EffectType == SpellEffectType.ApplyPetAura ||
						   EffectType == SpellEffectType.ApplyStatAura ||
						   EffectType == SpellEffectType.ApplyStatAuraPercent;

			IsEnhancer = IsAuraEffect && (AuraType == AuraType.AddModifierFlat || AuraType == AuraType.AddModifierPercent);

			MiscBitSet = MiscValue > 0 ? Utility.GetSetIndices((uint)MiscValue) : new uint[0];

            MinValue = BasePoints;// + DiceCount; TODO: check this!

			IsStrikeEffectFlat = EffectType == SpellEffectType.WeaponDamage ||
								 EffectType == SpellEffectType.WeaponDamageNoSchool ||
								 EffectType == SpellEffectType.NormalizedWeaponDamagePlus;

			IsStrikeEffectPct = EffectType == SpellEffectType.WeaponPercentDamage;

			IsTotem = HasTarget(ImplicitTargetType.TotemAir) ||
				HasTarget(ImplicitTargetType.TotemEarth) ||
				HasTarget(ImplicitTargetType.TotemFire) ||
				HasTarget(ImplicitTargetType.TotemWater);

			IsProc = IsProc || (AuraType == AuraType.ProcTriggerSpell && TriggerSpell != null) || AuraType == AuraType.ProcTriggerDamage;

			IsHealEffect = EffectType == SpellEffectType.Heal ||
				EffectType == SpellEffectType.HealMaxHealth ||
				AuraType == AuraType.PeriodicHeal ||
				(TriggerSpell != null && TriggerSpell.IsHealSpell);

			IsModifierEffect = AuraType == AuraType.AddModifierFlat || AuraType == AuraType.AddModifierPercent;

			foreach (var mask in AffectMask)
			{
				if (mask != 0)
				{
					HasAffectMask = true;
					break;
				}
			}

			if (HasAffectMask)
			{
				AffectMaskBitSet = Utility.GetSetIndices(AffectMask);
			}

			if (SpellEffectHandlerCreator == null && !IsUsed)
			{
				SpellEffectHandlerCreator = SpellHandler.SpellEffectCreators[(int)EffectType];
			}
			if (IsAuraEffect && AuraEffectHandlerCreator == null)
			{
				AuraEffectHandlerCreator = AuraHandler.EffectHandlers[(int)AuraType];
				if (AuraEffectHandlerCreator == null)
				{
					AuraEffectHandlerCreator = AuraHandler.EffectHandlers[0];
				}
			}

			RepairBrokenTargetPairs();
		}