コード例 #1
0
ファイル: MobBrain.cs プロジェクト: uvbs/Asda2-Server
        /// <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);
                }
            }
        }
コード例 #2
0
ファイル: MobBrain.cs プロジェクト: 0xFh/Asda2-Project
        /// <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);
                        }
                    }
                }
            }
        }
コード例 #3
0
ファイル: CharacterEvents.cs プロジェクト: pallmall/WCell
		internal static void NotifyHitDeliver(IDamageAction action)
		{
			var evt = HitDelivered;
			if (evt != null)
			{
				evt(action);
			}
		}
コード例 #4
0
ファイル: CharacterEvents.cs プロジェクト: pallmall/WCell
		internal static void NotifyHitReceive(IDamageAction action)
		{
			var evt = HitReceived;
			if (evt != null)
			{
				evt(action);
			}
		}
コード例 #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);
        }
コード例 #6
0
ファイル: MapTemplate.cs プロジェクト: 0xFh/Asda2-Project
        public void NotifyPlayerDied(IDamageAction action)
        {
            var evt = PlayerDied;

            if (evt != null)
            {
                evt(action);
            }
            action.Victim.Map.OnPlayerDeath(action);
        }
コード例 #7
0
ファイル: MapTemplate.cs プロジェクト: 0xFh/Asda2-Project
        public void NotifyPlayerDied(IDamageAction action)
        {
            Action <IDamageAction> playerDied = PlayerDied;

            if (playerDied != null)
            {
                playerDied(action);
            }
            action.Victim.Map.OnPlayerDeath(action);
        }
コード例 #8
0
ファイル: Unit.Damage.cs プロジェクト: 0xFh/Asda2-Project
        /// <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);
                }
            }
        }
コード例 #9
0
ファイル: NPC.cs プロジェクト: 0xFh/Asda2-Project
        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);
        }
コード例 #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);
        }
コード例 #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);
            }
        }
コード例 #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);
            }
        }
コード例 #13
0
ファイル: BossPhase.cs プロジェクト: 0xFh/Asda2-Project
 public virtual void OnDamageDealt(IDamageAction action)
 {
 }
コード例 #14
0
ファイル: BossPhase.cs プロジェクト: 0xFh/Asda2-Project
 public virtual void OnDamageTaken(IDamageAction action)
 {
 }
コード例 #15
0
ファイル: Unit.Damage.cs プロジェクト: remixod/netServer
		protected virtual void OnKilled(IDamageAction action)
		{
		}
コード例 #16
0
ファイル: Unit.Damage.cs プロジェクト: remixod/netServer
		/// <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);
				}
			}
		}
コード例 #17
0
ファイル: BossBrain.cs プロジェクト: uvbs/Asda2-Server
 public override void OnDamageDealt(IDamageAction action)
 {
     this.CurrentPhase.Value.OnDamageDealt(action);
     base.OnDamageDealt(action);
 }
コード例 #18
0
ファイル: BaseBrain.cs プロジェクト: ebakkedahl/WCell
 /// <summary>
 ///
 /// </summary>
 /// <param name="action"></param>
 public virtual void OnDamageReceived(IDamageAction action)
 {
 }
コード例 #19
0
ファイル: Unit.Combat.cs プロジェクト: KroneckerX/WCell
		/// <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);
			}
		}
コード例 #20
0
ファイル: Character.cs プロジェクト: remixod/netServer
		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);
		}
コード例 #21
0
ファイル: Character.cs プロジェクト: remixod/netServer
		/// <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);
			}
		}
コード例 #22
0
ファイル: Unit.Damage.cs プロジェクト: ray2006/WCell
		/// <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;
			}
		}
コード例 #23
0
ファイル: Unit.Damage.cs プロジェクト: KroneckerX/WCell
		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);
		}
コード例 #24
0
ファイル: NPC.cs プロジェクト: WCellFR/WCellFR
		/// <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);
		}
コード例 #25
0
ファイル: Unit.Damage.cs プロジェクト: pallmall/WCell
		/// <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;
			}
		}
コード例 #26
0
ファイル: Unit.Combat.cs プロジェクト: NVN/WCell
		/// <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);
					}
				}
			}
		}
コード例 #27
0
ファイル: Unit.Mechanics.cs プロジェクト: enjoii/WCell
		public int GetGeneratedThreat(IDamageAction action)
		{
			return GetGeneratedThreat(action.ActualDamage, action.UsedSchool, action.SpellEffect);
		}
コード例 #28
0
ファイル: Character.cs プロジェクト: Skizot/WCell
		/// <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);
			}
		}
コード例 #29
0
ファイル: Unit.Combat.cs プロジェクト: NecroSharper/WCell
        /// <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);
            }
        }
コード例 #30
0
ファイル: Unit.Combat.cs プロジェクト: KroneckerX/WCell
		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);
		}
コード例 #31
0
ファイル: Unit.Damage.cs プロジェクト: KroneckerX/WCell
		/// <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;
		}
コード例 #32
0
ファイル: BaseBrain.cs プロジェクト: ebakkedahl/WCell
 public virtual void OnDamageDealt(IDamageAction action)
 {
 }
コード例 #33
0
ファイル: BossBrain.cs プロジェクト: uvbs/Asda2-Server
 public override void OnDamageReceived(IDamageAction action)
 {
     this.CurrentPhase.Value.OnDamageTaken(action);
     base.OnDamageReceived(action);
 }
コード例 #34
0
ファイル: Character.cs プロジェクト: remixod/netServer
		/// <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;
				}
			}
		}
コード例 #35
0
ファイル: BaseBrain.cs プロジェクト: 0xFh/Asda2-Project
 /// <summary>
 ///
 /// </summary>
 /// <param name="action"></param>
 public virtual void OnDamageReceived(IDamageAction action)
 {
 }
コード例 #36
0
ファイル: MobBrain.cs プロジェクト: remixod/netServer
		/// <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);
			}
		}
コード例 #37
0
ファイル: Character.cs プロジェクト: MeaNone/WCell
		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);
		}
コード例 #38
0
ファイル: RegionTemplate.cs プロジェクト: NVN/WCell
		public void NotifyPlayerDied(IDamageAction action)
		{
			var evt = PlayerDied;
			if (evt != null)
			{
				evt(action);
			}
			action.Victim.Region.OnPlayerDeath(action);
		}
コード例 #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;
        }