/// <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); } }