Example #1
0
        /// <summary>
        /// Called whenever someone performs a harmful action on this Mob.
        /// </summary>
        /// <param name="action"></param>
        public override void OnDamageReceived(IDamageAction action)
        {
            if (!this.m_IsRunning || action.Attacker == null)
            {
                return;
            }
            NPC owner = this.m_owner as NPC;

            if (owner == null)
            {
                return;
            }
            owner.ThreatCollection[action.Attacker] += action.Attacker.GetGeneratedThreat(action);
            if (owner.Entry.Rank < CreatureRank.Elite || !this.IsFirstDamageReceived)
            {
                return;
            }
            this.IsFirstDamageReceived = false;
            foreach (Unit objectsInRadiu in (IEnumerable <WorldObject>)owner.GetObjectsInRadius <NPC>(
                         CharacterFormulas.EliteMobSocialAggrRange, ObjectTypes.Unit, false, int.MaxValue))
            {
                NPC npc = objectsInRadiu as NPC;
                if (npc != null && npc.Entry.Rank >= CreatureRank.Elite)
                {
                    npc.ThreatCollection[action.Attacker] += action.Attacker.GetGeneratedThreat(action);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Called whenever someone performs a harmful action on this Mob.
        /// </summary>
        /// <param name="action"></param>
        public override void OnDamageReceived(IDamageAction action)
        {
            if (!m_IsRunning)
            {
                return;
            }

            if (action.Attacker == null)
            {
                return;
            }

            var npc = m_owner as NPC;

            if (npc != null)
            {
                npc.ThreatCollection[action.Attacker] += action.Attacker.GetGeneratedThreat(action);
                if (npc.Entry.Rank >= CreatureRank.Elite && IsFirstDamageReceived)
                {
                    IsFirstDamageReceived = false;
                    var npcs = npc.GetObjectsInRadius(CharacterFormulas.EliteMobSocialAggrRange, ObjectTypes.Unit, false);
                    foreach (Unit unit in npcs)
                    {
                        var n = unit as NPC;
                        if (n != null && n.Entry.Rank >= CreatureRank.Elite)
                        {
                            n.ThreatCollection[action.Attacker] += action.Attacker.GetGeneratedThreat(action);
                        }
                    }
                }
            }
        }
Example #3
0
		internal static void NotifyHitDeliver(IDamageAction action)
		{
			var evt = HitDelivered;
			if (evt != null)
			{
				evt(action);
			}
		}
Example #4
0
		internal static void NotifyHitReceive(IDamageAction action)
		{
			var evt = HitReceived;
			if (evt != null)
			{
				evt(action);
			}
		}
Example #5
0
        private void TriggerProcOnKilled(IDamageAction killingAction)
        {
            if (YieldsXpOrHonor && killingAction.Attacker != null)
            {
                killingAction.Attacker.Proc(ProcTriggerFlags.KilledTargetThatYieldsExperienceOrHonor, this, killingAction, true);
            }

            Proc(ProcTriggerFlags.Death, killingAction.Attacker, killingAction, true);
        }
Example #6
0
        public void NotifyPlayerDied(IDamageAction action)
        {
            var evt = PlayerDied;

            if (evt != null)
            {
                evt(action);
            }
            action.Victim.Map.OnPlayerDeath(action);
        }
Example #7
0
        public void NotifyPlayerDied(IDamageAction action)
        {
            Action <IDamageAction> playerDied = PlayerDied;

            if (playerDied != null)
            {
                playerDied(action);
            }
            action.Victim.Map.OnPlayerDeath(action);
        }
Example #8
0
        /// <summary>
        /// Deals damage, cancels damage-sensitive Auras, checks for spell interruption etc
        /// </summary>
        public void DoRawDamage(IDamageAction action)
        {
            // Default on damage stuff
            if (m_FirstAttacker == null && action.Attacker != null)
            {
                FirstAttacker = action.Attacker;
            }

            // damage taken modifiers
            if (m_damageTakenMods != null)
            {
                action.Damage += m_damageTakenMods[(int)action.UsedSchool];
            }
            if (m_damageTakenPctMods != null)
            {
                var val = m_damageTakenPctMods[(int)action.UsedSchool];
                if (val != 0)
                {
                    action.Damage -= (val * action.Damage + 50) / 100;
                }
            }

            // AoE damage reduction
            if (action.Spell != null && action.Spell.IsAreaSpell && AoEDamageModifierPct != 0)
            {
                action.Damage -= (action.Damage * AoEDamageModifierPct + 50) / 100;
            }

            // last change
            action.Victim.OnDamageAction(action);

            // deal damage (no more changes to damage, from here on)
            var dmg = action.ActualDamage;

            if (dmg > 0)
            {
                if (m_brain != null)
                {
                    m_brain.OnDamageReceived(action);
                }

                if (action.Attacker != null && action.Attacker.Brain != null)
                {
                    action.Attacker.m_brain.OnDamageDealt(action);
                }
                LastDamageDelay = (int)(action.Spell == null ? 300 : action.Spell.CastDelay);

                Health -= dmg;

                if (!IsAlive)
                {
                    OnKilled(action);
                }
            }
        }
Example #9
0
        protected internal override void OnDamageAction(IDamageAction action)
        {
            var chr = action.Attacker as Character;

            if (chr != null)
            {
                var group = chr.Group;
                var dmg   = action.ActualDamage;
                if (group != null)
                {
                    if (Map.DefenceTownEvent != null)
                    {
                        if (Map.DefenceTownEvent.Damages.ContainsKey(group))
                        {
                            Map.DefenceTownEvent.Damages[group] += dmg;
                        }
                        else
                        {
                            Map.DefenceTownEvent.Damages.Add(group, dmg);
                        }
                    }
                    if (Damages.ContainsKey(group))
                    {
                        Damages[group] += dmg;
                    }
                    else
                    {
                        Damages.Add(group, dmg);
                    }
                }
                if (Map.DefenceTownEvent != null)
                {
                    if (Map.DefenceTownEvent.Damages.ContainsKey(chr))
                    {
                        Map.DefenceTownEvent.Damages[chr] += dmg;
                    }
                    else
                    {
                        Map.DefenceTownEvent.Damages.Add(chr, dmg);
                    }
                }
                if (Damages.ContainsKey(chr))
                {
                    Damages[chr] += dmg;
                }
                else
                {
                    Damages.Add(chr, dmg);
                }
            }
            base.OnDamageAction(action);
        }
Example #10
0
        void TriggerProcOnDamageReceived(IDamageAction action)
        {
            var procHitFlags    = action.IsCritical ? ProcHitFlags.CriticalHit : ProcHitFlags.None;
            var victimProcFlags = ProcTriggerFlags.ReceivedAnyDamage;

            if (action.IsDot)
            {
                action.Attacker.Proc(ProcTriggerFlags.DonePeriodicDamageOrHeal, this, action, true, procHitFlags);
                victimProcFlags |= ProcTriggerFlags.ReceivedPeriodicDamageOrHeal;
            }

            Proc(victimProcFlags, action.Attacker, action, true, procHitFlags);
        }
Example #11
0
        /// <summary>
        /// Called whenever someone performs a harmful action on this Mob.
        /// </summary>
        /// <param name="action"></param>
        public override void OnDamageReceived(IDamageAction action)
        {
            if (!m_IsRunning)
            {
                return;
            }

            if (action.Attacker == null)
            {
                return;
            }

            if (m_owner is NPC)
            {
                ((NPC)m_owner).ThreatCollection[action.Attacker] += action.Attacker.GetGeneratedThreat(action);
            }
        }
Example #12
0
        /// <summary>
        /// Is called whenever this Unit receives any kind of damage
        ///
        /// TODO: There is a small chance with each hit by your weapon that it will lose 1 durability point.
        /// TODO: There is a small chance with each spell cast that you will lose 1 durability point to your weapon.
        /// TODO: There is a small chance with each hit absorbed by your armor that it will lose 1 durability point.
        /// </summary>
        protected internal virtual void OnDamageAction(IDamageAction action)
        {
            IsSitting = false;
            if (action is DamageAction && action.Attacker != null)
            {
                var aaction = (DamageAction)action;

                if (action.ActualDamage <= 0)
                {
                    return;
                }

                if (!action.IsDot)
                {
                    var attacker     = action.Attacker;
                    var weapon       = action.Weapon;
                    var weaponAttack = weapon != null && !attacker.IsPvPing;

                    // Remove damage-sensitive Auras
                    m_auras.RemoveByFlag(AuraInterruptFlags.OnDamage);
                    attacker.m_lastCombatTime = attacker.m_lastUpdateTime;

                    // stand up when hit
                    StandState = StandState.Stand;

                    if (IsAlive)
                    {
                        // aggro'd -> Enter combat mode and update combat-time
                        IsInCombat       = true;
                        m_lastCombatTime = m_lastUpdateTime;
                    }
                }

                TriggerProcOnDamageReceived(action);
            }
        }
Example #13
0
 public virtual void OnDamageDealt(IDamageAction action)
 {
 }
Example #14
0
 public virtual void OnDamageTaken(IDamageAction action)
 {
 }
Example #15
0
		protected virtual void OnKilled(IDamageAction action)
		{
		}
Example #16
0
		/// <summary>
		/// Deals damage, cancels damage-sensitive Auras, checks for spell interruption etc
		/// </summary>
		public void DoRawDamage(IDamageAction action)
		{
			// Default on damage stuff
			if (m_FirstAttacker == null && action.Attacker != null)
			{
				FirstAttacker = action.Attacker;
			}

			// damage taken modifiers
			if (m_damageTakenMods != null)
			{
				action.Damage += m_damageTakenMods[(int)action.UsedSchool];
			}
			if (m_damageTakenPctMods != null)
			{
				var val = m_damageTakenPctMods[(int)action.UsedSchool];
				if (val != 0)
				{
					action.Damage -= (val * action.Damage + 50) / 100;
				}
			}

			// AoE damage reduction
			if (action.Spell != null && action.Spell.IsAreaSpell && AoEDamageModifierPct != 0)
			{
				action.Damage -= (action.Damage * AoEDamageModifierPct + 50) / 100;
			}

			// last change
			action.Victim.OnDamageAction(action);

			// deal damage (no more changes to damage, from here on)
			var dmg = action.ActualDamage;
			if (dmg > 0)
			{
				if (m_brain != null)
				{
					m_brain.OnDamageReceived(action);
				}

				if (action.Attacker !=null && action.Attacker.Brain != null)
				{
					action.Attacker.m_brain.OnDamageDealt(action);
				}

				var health = Health;

				if (dmg >= health)
				{
					// kill
					LastKiller = action.Attacker;
				}

				Health = health - dmg;

				if (!IsAlive)
				{
					OnKilled(action);
				}
			}
		}
Example #17
0
 public override void OnDamageDealt(IDamageAction action)
 {
     this.CurrentPhase.Value.OnDamageDealt(action);
     base.OnDamageDealt(action);
 }
Example #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="action"></param>
 public virtual void OnDamageReceived(IDamageAction action)
 {
 }
Example #19
0
		/// <summary>
		/// Is called whenever this Unit receives any kind of damage
		/// 
		/// TODO: There is a small chance with each hit by your weapon that it will lose 1 durability point.
		/// TODO: There is a small chance with each spell cast that you will lose 1 durability point to your weapon. 
		/// TODO: There is a small chance with each hit absorbed by your armor that it will lose 1 durability point.
		/// </summary>
		protected internal virtual void OnDamageAction(IDamageAction action)
		{
			if (action is DamageAction && action.Attacker != null)
			{
				var aaction = (DamageAction)action;

				if (IsAlive)
				{
					// aura states
					if (aaction.VictimState == VictimState.Parry)
					{
						AuraState |= AuraStateMask.Parry | AuraStateMask.DodgeOrBlockOrParry;
						if (aaction.Victim.PowerType == PowerType.Rage)
						{
							RageGenerator.GenerateTargetRage(aaction);
						}
					}
					else if (aaction.VictimState == VictimState.Block ||
							 aaction.VictimState == VictimState.Dodge)
					{
						// set
						AuraState |= AuraStateMask.DodgeOrBlockOrParry;
					}
					else
					{
						// Unset
						AuraState &= ~AuraStateMask.Parry | AuraStateMask.DodgeOrBlockOrParry;
					}
				}
				else
				{
					AuraState = AuraStateMask.None;
				}

				if (action.ActualDamage <= 0)
				{
					return;
				}

				if (!action.IsDot)
				{
					var attacker = action.Attacker;
					var weapon = action.Weapon;
					var weaponAttack = weapon != null && !attacker.IsPvPing;

					// Remove damage-sensitive Auras
					m_auras.RemoveByFlag(AuraInterruptFlags.OnDamage);
					attacker.m_lastCombatTime = attacker.m_lastUpdateTime;

					if (attacker is Character && weaponAttack)
					{
						((Character)attacker).Skills.GainWeaponSkill(action.Victim.Level, weapon);
					}

					// stand up when hit
					StandState = StandState.Stand;

					// Generate Rage
					if (attacker.IsAlive && attacker.PowerType == PowerType.Rage)
					{
						RageGenerator.GenerateAttackerRage(aaction);
					}

					if (IsAlive)
					{
						if (PowerType == PowerType.Rage)
						{
							RageGenerator.GenerateTargetRage(aaction);
						}

						// aggro'd -> Enter combat mode and update combat-time
						IsInCombat = true;
						m_lastCombatTime = m_lastUpdateTime;

						// during pvp one does not gain any weapon skill
						if (this is Character)
						{
							if (weaponAttack)
							{
								((Character)this).Skills.GainDefenseSkill(action.Attacker.Level);
							}
						}
					}

					// Pushback SpellCast
					if (IsUsingSpell)
					{
						if (SpellCast.Spell.InterruptFlags.HasFlag(InterruptFlags.OnTakeDamage))
						{
							SpellCast.Cancel();
						}
						else
						{
							SpellCast.Pushback();
						}
					}
				}

				TriggerProcOnDamageReceived(action);
			}
		}
Example #20
0
		protected override void OnKilled(IDamageAction action)
		{
			base.OnKilled(action);

			bool pvp;
			if (action.Attacker != null)
			{
				pvp = action.Attacker.IsPvPing;
				var chr = action.Attacker.CharacterMaster;

				if (pvp)
				{
                    if (chr.IsInBattleground)
                    {
                        // Add BG stats
                        var attackerStats = chr.Battlegrounds.Stats;
                        var victimStats = Battlegrounds.Stats;
                        attackerStats.KillingBlows++;
                        if (victimStats != null)
                        {
                            victimStats.Deaths++;
                        }
                    }
                    Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.KilledByPlayer, (uint)chr.FactionGroup);
				}
			}
			else
			{
				pvp = false;
			}

			if (!pvp)
			{
				// durability loss
				m_inventory.ApplyDurabilityLoss(PlayerInventory.DeathDurabilityLossPct);
                if(action.Attacker != null && action.Attacker is NPC)
                    Achievements.CheckPossibleAchievementUpdates(AchievementCriteriaType.KilledByCreature, (uint)((NPC)action.Attacker).Entry.NPCId);
			}

			m_Map.MapTemplate.NotifyPlayerDied(action);
		}
Example #21
0
		/// <summary>
		/// Is called when the Character kills an Honorable target.
		/// </summary>
		/// <param name="victim">The Honorable character killed.</param>
		internal void OnHonorableKill(IDamageAction action)
		{
			var victim = (Character)action.Victim;
			var ptsForKill = CalcHonorForKill(victim);
			if (ptsForKill == 0) return;

			if (IsInBattleground)
			{
				var team = m_bgInfo.Team;
				var victimStats = victim.Battlegrounds.Stats;

				if (team == victim.Battlegrounds.Team ||
					(victimStats == null || victimStats.Deaths > BattlegroundMgr.MaxHonorableDeaths))
				{
					// don't count kills of town team, visitors or permanent losers
					return;
				}

				var stats = m_bgInfo.Stats;
				++stats.HonorableKills;
				team.DistributeSharedHonor(this, victim, ptsForKill);
			}
			else if (Group != null)
			{
				if (Faction.Group == victim.Faction.Group) return;
				Group.DistributeGroupHonor(this, victim, ptsForKill);
			}
			else
			{
				GiveHonorPoints(ptsForKill);
				KillsToday++;
				LifetimeHonorableKills++;
				HonorHandler.SendPVPCredit(this, ptsForKill * 10, victim);
			}

			if (m_zone != null)
			{
				m_zone.Template.OnHonorableKill(this, victim);
			}
		}
Example #22
0
		/// <summary>
		/// Deals damage, cancels damage-sensitive Auras, checks for spell interruption etc
		/// </summary>
		public void DoRawDamage(IDamageAction action)
		{
			// Default on damage stuff
			if (m_FirstAttacker == null && action.Attacker != null)
			{
				FirstAttacker = action.Attacker;
			}
			action.Victim.OnDamageAction(action);

			// events
			if (action.Attacker is Character)
			{
				Character.NotifyHitDeliver(action);
			}
			else if (action.Attacker is NPC)
			{
				((NPC)action.Attacker).Entry.NotifyHitDeliver(action);
			}

			if (action.Victim is Character)
			{
				Character.NotifyHitReceive(action);
			}
			else if (action.Victim is NPC)
			{
				((NPC)action.Victim).Entry.NotifyHitReceive(action);
			}

			if (action.Attacker != null && action.Attacker.Brain != null)
			{
				action.Attacker.Brain.OnDamageDealt(action);
			}

			if (m_brain != null)
			{
				m_brain.OnDamageReceived(action);
			}

			// deal damage
			var dmg = action.ActualDamage;
			if (dmg > 0)
			{
				if (action.Attacker != null && action.Victim.ManaShieldAmount > 0)
				{
					action.Victim.DrainManaShield(ref dmg);
				}

				var health = action.Victim.Health;

				if (dmg >= health)
				{
					// kill
					LastKiller = action.Attacker;
				}

				action.Victim.Health = health - dmg;
			}
		}
Example #23
0
		private void TriggerProcOnKilled(IDamageAction killingAction)
		{
			if (YieldsXpOrHonor && killingAction.Attacker != null)
			{
				killingAction.Attacker.Proc(ProcTriggerFlags.KilledTargetThatYieldsExperienceOrHonor, this, killingAction, true);
			}

			Proc(ProcTriggerFlags.Death, killingAction.Attacker, killingAction, true);
		}
Example #24
0
		/// <summary>
		/// 
		/// </summary>
		protected internal override void OnDamageAction(IDamageAction action)
		{
			if (m_FirstAttacker == null && action.Attacker != null)
			{
				FirstAttacker = action.Attacker;
			}

			if (!action.Victim.IsAlive && YieldsXpOrHonor && action.Attacker is Character && action.Attacker.YieldsXpOrHonor)
			{
				action.Attacker.Proc(ProcTriggerFlags.GainExperience, this, action, true);
			}

			base.OnDamageAction(action);
		}
Example #25
0
		/// <summary>
		/// Deals damage, cancels damage-sensitive Auras, checks for spell interruption etc
		/// </summary>
		public void DoRawDamage(IDamageAction action)
		{
			// events
			if (action.Attacker is Character)
			{
				Character.NotifyHitDeliver(action);
			}
			else if (action.Attacker is NPC)
			{
				((NPC)action.Attacker).Entry.NotifyHitDeliver(action);
			}

			if (action.Victim is Character)
			{
				Character.NotifyHitReceive(action);
			}
			else if (action.Victim is NPC)
			{
				((NPC)action.Victim).Entry.NotifyHitReceive(action);
			}

			if (action.Attacker != null && action.Attacker.Brain != null)
			{
				action.Attacker.Brain.OnDamageDealt(action);
			}

			if (m_brain != null)
			{
				m_brain.OnDamageReceived(action);
			}

			action.Victim.OnDamageAction(action);

			// deal damage
			var dmg = action.ActualDamage;
			if (dmg > 0)
			{
				if (action.Attacker != null && action.Victim.ManaShieldAmount > 0)
				{
					action.Victim.DrainManaShield(ref dmg);
				}

				action.Victim.Health -= dmg;
			}
		}
Example #26
0
		/// <summary>
		/// Is called whenever this Unit receives any kind of damage
		/// 
		/// TODO: There is a small chance with each hit by your weapon that it will lose 1 durability point.
		/// TODO: There is a small chance with each spell cast that you will lose 1 durability point to your weapon. 
		/// TODO: There is a small chance with each hit absorbed by your armor that it will lose 1 durability point.
		/// </summary>
		protected internal virtual void OnDamageAction(IDamageAction action)
		{
			if (action is DamageAction && action.Attacker != null)
			{
				var aaction = (DamageAction)action;

				// Get the flags now, so they won't be changed by anything that happens afterwards
				var attackerProcTriggerFlags = action.AttackerProcTriggerFlags;
				var targetProcTriggerFlags = action.TargetProcTriggerFlags;

				if (IsAlive)
				{
					// aura states
					if (aaction.VictimState == VictimState.Parry)
					{
						AuraState |= AuraStateMask.Parry | AuraStateMask.DodgeOrBlockOrParry;
						if (aaction.Victim.PowerType == PowerType.Rage)
						{
							RageGenerator.GenerateTargetRage(aaction);
						}
					}
					else if (aaction.VictimState == VictimState.Block ||
							 aaction.VictimState == VictimState.Dodge)
					{
						// set
						AuraState |= AuraStateMask.DodgeOrBlockOrParry;
					}
					else
					{
						// Unset
						AuraState &= ~AuraStateMask.Parry | AuraStateMask.DodgeOrBlockOrParry;
					}
				}
				else
				{
					AuraState = AuraStateMask.None;
				}

				if (action.ActualDamage > 0)
				{
					if (!action.IsDot)
					{
						var attacker = action.Attacker;
						var weapon = action.Weapon;
						var weaponAttack = weapon != null && !attacker.IsPvPing;

						// Remove damage-sensitive Auras
						m_auras.RemoveByFlag(AuraInterruptFlags.OnDamage);
						attacker.m_lastCombatTime = Environment.TickCount;

						if (attacker is Character && weaponAttack)
						{
							((Character)attacker).Skills.GainWeaponSkill(action.Victim.Level, weapon);
						}

						// stand up when hit
						StandState = StandState.Stand;

						// Generate Rage
						if (attacker.IsAlive && attacker.PowerType == PowerType.Rage)
						{
							RageGenerator.GenerateAttackerRage(aaction);
						}

						if (IsAlive)
						{
							if (PowerType == PowerType.Rage)
							{
								RageGenerator.GenerateTargetRage(aaction);
							}

							// aggro'd -> Enter combat mode and update combat-time
							IsInCombat = true;
							m_lastCombatTime = Environment.TickCount;

							// during pvp one does not gain any weapon skill
							if (this is Character)
							{
								if (weaponAttack)
								{
									((Character)this).Skills.GainDefenseSkill(action.Attacker.Level);
								}
							}
						}

						// Pushback SpellCast
						if (IsUsingSpell)
						{
							if (SpellCast.Spell.InterruptFlags.HasFlag(InterruptFlags.OnTakeDamage))
							{
								SpellCast.Cancel();
							}
							else
							{
								SpellCast.Pushback();
							}
						}
					}

					// Procs
					if (action.Weapon == null || action.Weapon != OffHandWeapon)
					{
						var gainExpProc = !IsAlive && YieldsXpOrHonor && action.Attacker is Character && action.Attacker.YieldsXpOrHonor;
						if (gainExpProc)
						{
							attackerProcTriggerFlags |= ProcTriggerFlags.GainExperience;
						}

						action.Attacker.Proc(attackerProcTriggerFlags, this, action, true);
						Proc(targetProcTriggerFlags, action.Attacker, action, false);
					}
				}
			}
		}
Example #27
0
		public int GetGeneratedThreat(IDamageAction action)
		{
			return GetGeneratedThreat(action.ActualDamage, action.UsedSchool, action.SpellEffect);
		}
Example #28
0
		/// <summary>
		/// 
		/// </summary>
		protected internal override void OnDamageAction(IDamageAction action)
		{
			base.OnDamageAction(action);

			var chr = action.Attacker as Character;
			var pvp = IsPvPing && chr != null;
			var killingBlow = !IsAlive;

			if (action.Attacker != null &&
				m_activePet != null &&
				m_activePet.CanBeAggroedBy(action.Attacker))
			{
				m_activePet.ThreatCollection.AddNew(action.Attacker);
			}

			if (pvp && chr.IsInBattleground)
			{
				// Add BG stats
				var attackerStats = chr.Battlegrounds.Stats;
				var victimStats = Battlegrounds.Stats;
				attackerStats.TotalDamage += action.ActualDamage;
				if (killingBlow)
				{
					attackerStats.KillingBlows++;
				}
				if (victimStats != null)
				{
					victimStats.Deaths++;
				}
			}

			if (killingBlow)
			{
				// this Character died in the process
				if (pvp)
				{
					if (YieldsXpOrHonor)
					{
						chr.Proc(ProcTriggerFlags.GainExperience, this, action, true);
						chr.OnHonorableKill(action);
					}
				}
				else
				{
					// durability loss
					m_inventory.ApplyDurabilityLoss(PlayerInventory.DeathDurabilityLossPct);
				}

				m_region.RegionInfo.NotifyPlayerDied(action);
			}
		}
Example #29
0
        /// <summary>
        /// Is called whenever this Unit receives any kind of damage
        ///
        /// TODO: There is a small chance with each hit by your weapon that it will lose 1 durability point.
        /// TODO: There is a small chance with each spell cast that you will lose 1 durability point to your weapon.
        /// TODO: There is a small chance with each hit absorbed by your armor that it will lose 1 durability point.
        /// </summary>
        protected internal virtual void OnDamageAction(IDamageAction action)
        {
            if (action is DamageAction && action.Attacker != null)
            {
                var aaction = (DamageAction)action;

                if (IsAlive)
                {
                    // aura states
                    if (aaction.VictimState == VictimState.Parry)
                    {
                        AuraState |= AuraStateMask.Parry | AuraStateMask.DodgeOrBlockOrParry;
                        if (aaction.Victim.PowerType == PowerType.Rage)
                        {
                            RageGenerator.GenerateTargetRage(aaction);
                        }
                    }
                    else if (aaction.VictimState == VictimState.Block ||
                             aaction.VictimState == VictimState.Dodge)
                    {
                        // set
                        AuraState |= AuraStateMask.DodgeOrBlockOrParry;
                    }
                    else
                    {
                        // Unset
                        AuraState &= ~AuraStateMask.Parry | AuraStateMask.DodgeOrBlockOrParry;
                    }
                }
                else
                {
                    AuraState = AuraStateMask.None;
                }

                if (action.ActualDamage <= 0)
                {
                    return;
                }

                if (!action.IsDot)
                {
                    var attacker     = action.Attacker;
                    var weapon       = action.Weapon;
                    var weaponAttack = weapon != null && !attacker.IsPvPing;

                    // Remove damage-sensitive Auras
                    m_auras.RemoveByFlag(AuraInterruptFlags.OnDamage);
                    attacker.m_lastCombatTime = attacker.m_lastUpdateTime;

                    if (attacker is Character && weaponAttack)
                    {
                        ((Character)attacker).Skills.GainWeaponSkill(action.Victim.Level, weapon);
                    }

                    // stand up when hit
                    StandState = StandState.Stand;

                    // Generate Rage
                    if (attacker.IsAlive && attacker.PowerType == PowerType.Rage)
                    {
                        RageGenerator.GenerateAttackerRage(aaction);
                    }

                    if (IsAlive)
                    {
                        if (PowerType == PowerType.Rage)
                        {
                            RageGenerator.GenerateTargetRage(aaction);
                        }

                        // aggro'd -> Enter combat mode and update combat-time
                        IsInCombat       = true;
                        m_lastCombatTime = m_lastUpdateTime;

                        // during pvp one does not gain any weapon skill
                        if (this is Character)
                        {
                            if (weaponAttack)
                            {
                                ((Character)this).Skills.GainDefenseSkill(action.Attacker.Level);
                            }
                        }
                    }

                    // Pushback SpellCast
                    if (IsUsingSpell)
                    {
                        if (SpellCast.Spell.InterruptFlags.HasFlag(InterruptFlags.OnTakeDamage))
                        {
                            SpellCast.Cancel();
                        }
                        else
                        {
                            SpellCast.Pushback();
                        }
                    }
                }

                TriggerProcOnDamageReceived(action);
            }
        }
Example #30
0
		void TriggerProcOnDamageReceived(IDamageAction action)
		{
			var procHitFlags = action.IsCritical ? ProcHitFlags.CriticalHit : ProcHitFlags.None;
			var victimProcFlags = ProcTriggerFlags.ReceivedAnyDamage;

			if (action.IsDot)
			{
				action.Attacker.Proc(ProcTriggerFlags.DonePeriodicDamageOrHeal, this, action, true, procHitFlags);
				victimProcFlags |= ProcTriggerFlags.ReceivedPeriodicDamageOrHeal;
			}

			Proc(victimProcFlags, action.Attacker, action, true, procHitFlags);
		}
Example #31
0
		/// <summary>
		/// Called after this unit has been killed by damage action
		/// </summary>
		/// <param name="action">Action which killed this unit</param>
		protected virtual void OnKilled(IDamageAction action)
		{
			TriggerProcOnKilled(action);

			LastKiller = action.Attacker;
		}
Example #32
0
 public virtual void OnDamageDealt(IDamageAction action)
 {
 }
Example #33
0
 public override void OnDamageReceived(IDamageAction action)
 {
     this.CurrentPhase.Value.OnDamageTaken(action);
     base.OnDamageReceived(action);
 }
Example #34
0
		/// <summary>
		/// 
		/// </summary>
		protected internal override void OnDamageAction(IDamageAction action)
		{
			base.OnDamageAction(action);

			if (action.Attacker != null)
			{
				// aggro pet and minions
				if (m_activePet != null)
				{
					m_activePet.ThreatCollection.AddNewIfNotExisted(action.Attacker);
				}
				if (m_minions != null)
				{
					foreach (var minion in m_minions)
					{
						minion.ThreatCollection.AddNewIfNotExisted(action.Attacker);
					}
				}

				var pvp = action.Attacker.IsPvPing;
				var chr = action.Attacker.CharacterMaster;

				if (pvp && chr.IsInBattleground)
				{
					// Add BG stats
					var attackerStats = chr.Battlegrounds.Stats;
					attackerStats.TotalDamage += action.ActualDamage;
				}
			}
		}
Example #35
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="action"></param>
 public virtual void OnDamageReceived(IDamageAction action)
 {
 }
Example #36
0
		/// <summary>
		/// Called whenever someone performs a harmful action on this Mob.
		/// </summary>
		/// <param name="action"></param>
		public override void OnDamageReceived(IDamageAction action)
		{
			if (!m_IsRunning)
				return;

			if (action.Attacker == null)
			{
				return;
			}

			if (m_owner is NPC)
			{
				((NPC)m_owner).ThreatCollection[action.Attacker] += action.Attacker.GetGeneratedThreat(action);
			}
		}
Example #37
0
		protected override void OnKilled(IDamageAction action)
		{
			base.OnKilled(action);

			bool pvp;
			if (action.Attacker != null)
			{
				pvp = action.Attacker.IsPvPing;
				var chr = action.Attacker.CharacterMaster;

				if (pvp && chr.IsInBattleground)
				{
					// Add BG stats
					var attackerStats = chr.Battlegrounds.Stats;
					var victimStats = Battlegrounds.Stats;
					attackerStats.KillingBlows++;
					if (victimStats != null)
					{
						victimStats.Deaths++;
					}
				}
			}
			else
			{
				pvp = false;
			}

			if (!pvp)
			{
				// durability loss
				m_inventory.ApplyDurabilityLoss(PlayerInventory.DeathDurabilityLossPct);
			}

			m_Map.MapTemplate.NotifyPlayerDied(action);
		}
Example #38
0
		public void NotifyPlayerDied(IDamageAction action)
		{
			var evt = PlayerDied;
			if (evt != null)
			{
				evt(action);
			}
			action.Victim.Region.OnPlayerDeath(action);
		}
Example #39
0
        /// <summary>
        /// Called after this unit has been killed by damage action
        /// </summary>
        /// <param name="action">Action which killed this unit</param>
        protected virtual void OnKilled(IDamageAction action)
        {
            TriggerProcOnKilled(action);

            LastKiller = action.Attacker;
        }