Exemplo n.º 1
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;
			}
		}
Exemplo n.º 2
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;
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
		/// <summary>
		/// Calculates the amount of power regeneration for the class at a specific level, Intellect and Spirit.
		/// Changed in 3.1, overrides for casters are redundant.
		/// </summary>
		public static int CalculateManaRegen(Unit unit)
		{
			// default mana generation
			// see: http://www.wowwiki.com/Mana_regeneration
			var regen = (int)((0.001f + unit.Spirit * (float)Math.Sqrt(unit.Intellect) * GameTables.GetBaseRegenForLevel(unit.Level)) * 0.6f + 0.9f);  // rounded up
			return regen * RegenRateFactor;
		}
Exemplo n.º 4
0
		/// <summary>
		/// Method is called before the Unit is actually in the World
		/// to initialize the set of Actions.
		/// </summary>
		/// <param name="owner"></param>
		public override void Init(Unit owner)
		{
			base.Init(owner);

			this[BrainState.Idle] = new AIIdleAction(owner);
			this[BrainState.Dead] = this[BrainState.Idle];

			this[BrainState.Evade] = new AIEvadeAction(owner);
			this[BrainState.Roam] = new AIRoamAction(owner)
			{
				Strategy = new AIWaypointMoveAction(owner, AIMovementType.ForwardThenBack, owner.Waypoints)
			};

			this[BrainState.Follow] = new AIFollowMasterAction(owner);
			this[BrainState.Guard] = new AIGuardMasterAction(owner);

			if (owner is NPC)
			{
				this[BrainState.Combat] = new AICombatAction((NPC)owner)
				{
					Strategy = new AIAttackAction((NPC)owner)
				};

				this[BrainState.FormationMove] = new AIFormationMoveAction((NPC)owner);
			}
		}
Exemplo n.º 5
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;
				}
			}
		}
Exemplo n.º 6
0
 protected internal override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
 {
     if (!(target is Character))
     {
         failReason = SpellFailedReason.TargetNotPlayer;
     }
 }
Exemplo n.º 7
0
		public override void OnProc(Unit triggerer, IUnitAction action)
		{
			if (action is IDamageAction)
			{
				var owner = Owner;
				var dmgAction = ((IDamageAction)action);

				var healSelfAmount = ((dmgAction.Damage * EffectValue) + 50) / 100;	// don't forget rounding
				var healPartyAmount = (healSelfAmount + 3) / 5; // don't forget rounding

				owner.Heal(healSelfAmount, owner, SpellEffect);
				if (owner is Character)
				{
					var chr = (Character)owner;
					var group = chr.Group;
					if (group != null)
					{
						// heal all group members in same context (ie same Map in current implementation)
						group.CallOnAllInSameContext(chr.ContextHandler, (member) =>
						{
							member.Heal(healPartyAmount, owner, SpellEffect);
						});
					}
				}
			}
		}
Exemplo n.º 8
0
		protected SpellCollection(Unit owner, bool initDictionary)
		{
			if (initDictionary)
				m_byId = new Dictionary<uint, Spell>(60);

			Owner = owner;
		}
Exemplo n.º 9
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;
             }
         }
     }
 }
Exemplo n.º 10
0
		public AuraCollection(Unit owner)
		{
			m_auras = new Dictionary<AuraIndexId, Aura>();
			m_AuraArray = Aura.EmptyArray;

			m_owner = owner;
		}
Exemplo n.º 11
0
		protected internal override void CheckInitialize(CasterInfo casterInfo, Unit target, ref SpellFailedReason failReason)
		{
			if (!(target is Character))
			{
				failReason = SpellFailedReason.TargetNotPlayer;
			}
		}
Exemplo n.º 12
0
		public static void SendAllAuras(IPacketReceiver rcv, Unit owner)
		{
			using (var packet = CreateAllAuraPacket(owner))
			{
				rcv.Send(packet);
			}
		}
Exemplo n.º 13
0
		public static void SendAllAuras(Unit owner)
		{
			using (var packet = CreateAllAuraPacket(owner))
			{
				owner.SendPacketToArea(packet);
			}
		}
Exemplo n.º 14
0
		protected internal override void CheckInitialize(CasterInfo casterInfo, Unit target, ref SpellFailedReason failReason)
		{
			if (target.MaxPower == 0 || target.PowerType != (PowerType)m_spellEffect.MiscValue)
			{
				failReason = SpellFailedReason.BadTargets;
			}
		}
Exemplo n.º 15
0
		public AIWaypointMoveAction(Unit owner, AIMovementType waypointSequence)
			: base(owner)
		{
			m_waypoints = new LinkedList<WaypointEntry>();

			_waypointSequence = waypointSequence;
		}
Exemplo n.º 16
0
		public AIWaypointMoveAction(Unit owner, AIMovementType wpMovementType)
			: base(owner)
		{
			m_waypoints = new LinkedList<WaypointEntry>();

			m_WPmovementType = wpMovementType;
		}
Exemplo n.º 17
0
		public override void Initialize(ref SpellFailedReason failReason)
		{
			if (m_targets != null && m_targets.Count > 0)
			{
				firstTarget = (Unit)m_targets[0];
			}
		}
Exemplo n.º 18
0
 public static void SendAllAuras(IPacketReceiver rcv, Unit owner)
 {
     if (!owner.IsAreaActive) return;
     using (var packet = CreateAllAuraPacket(owner))
     {
         rcv.Send(packet);
     }
 }
Exemplo n.º 19
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="target"></param>
		/// <remarks>Requires Brain</remarks>
		public void Follow(Unit target)
		{
			if (CheckBrain())
			{
				Target = target;
				m_brain.CurrentAction = new AIFollowTargetAction(this);
			}
		}
Exemplo n.º 20
0
		public void Aggro(Unit unit)
		{
			for (var i = 0; i < m_Mobs.Count; i++)
			{
				var mob = m_Mobs[i];
				mob.ThreatCollection.AddNew(unit);
			}
		}
Exemplo n.º 21
0
 public static void SendAllAuras(Unit owner)
 {
     if (!owner.IsAreaActive) return;
     using (var packet = CreateAllAuraPacket(owner))
     {
         owner.SendPacketToArea(packet);
     }
 }
Exemplo n.º 22
0
 public bool CheckRequirements(Unit enchanter)
 {
     if (enchanter is Character)
     {
         return ((Character)enchanter).Skills.CheckSkill(RequiredSkillId, RequiredSkillAmount);
     }
     return true;
 }
Exemplo n.º 23
0
		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);
			}
		}
Exemplo n.º 24
0
		public override SpellFailedReason Initialize()
		{
			if (m_targets != null && m_targets.Count > 0)
			{
				firstTarget = (Unit)m_targets[0];
			}
			return SpellFailedReason.Ok;
		}
Exemplo n.º 25
0
		protected internal override void CheckInitialize(SpellCast creatingCast, ObjectReference casterReference, Unit target, ref SpellFailedReason failReason)
		{
			if (target.Class != ClassId.Hunter)
			{
				failReason = SpellFailedReason.BadTargets;
				return;
			}
		}
Exemplo n.º 26
0
		public static int GetPowerRegen(Unit unit)
		{
			var calc = PowerRegenCalculators[(int)unit.PowerType];
			if (calc == null)
			{
				return 0;
			}
			return calc(unit);
		}
Exemplo n.º 27
0
        protected internal override void CheckInitialize(CasterInfo casterInfo, Unit target, ref SpellFailedReason failReason)
		{
            if (!(target is Character)) return;
            var chr = (Character)target;
            if (chr.Class != ClassId.Hunter)
            {
                failReason = SpellFailedReason.BadTargets;
            }
		}
Exemplo n.º 28
0
 public override void OnKilled(Unit killerUnit, Unit victimUnit)
 {
     switch (Utility.Random(2))
     {
         case 0: m_owner.PlayTextAndSoundById(-1557011); break;
         case 1: m_owner.PlayTextAndSoundById(-1557012); break;
     }
     base.OnKilled(killerUnit, victimUnit);
 }
Exemplo n.º 29
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;
		}
Exemplo n.º 30
0
		public override bool IsInRange(Unit target)
		{
			var angle = m_owner.GetAngleTowards(target);
			if (angle >= MinAngle && angle <= MaxAngle)
			{
				return base.IsInRange(target);
			}
			return false;
		}