/// <summary> /// Do a single attack on the target using given weapon, ability and action. /// </summary> public ProcHitFlags Strike(IAsda2Weapon weapon, DamageAction action, Unit target, SpellCast ability) { ProcHitFlags procHitFlags = ProcHitFlags.None; EnsureContext(); if (!IsAlive) { return(procHitFlags); } if (!target.IsInContext || !target.IsAlive) { return(procHitFlags); } if (weapon == null) { log.Info("Trying to strike without weapon: " + this); return(procHitFlags); } //if (IsMovementControlled) //{ // // stop running when landing a hit // m_Movement.Stop(); //} target.IsInCombat = true; action.Victim = target; action.Attacker = this; action.Weapon = weapon; if (ability != null) { action.Schools = ability.Spell.SchoolMask; action.SpellEffect = ability.Spell.Effects[0]; // calc damage GetWeaponDamage(action, weapon, ability); procHitFlags = action.DoAttack(); if (ability.Spell.AttributesExC.HasFlag(SpellAttributesExC.RequiresTwoWeapons) && m_offhandWeapon != null) { // also strike with offhand action.Reset(this, target, m_offhandWeapon); GetWeaponDamage(action, m_offhandWeapon, ability); procHitFlags |= action.DoAttack(); m_lastOffhandStrike = Environment.TickCount; } } else { // no combat ability m_extraAttacks += 1; do { // calc damage GetWeaponDamage(action, weapon, null); action.Schools = weapon.Damages.AllSchools(); if (action.Schools == DamageSchoolMask.None) { action.Schools = DamageSchoolMask.Physical; } // normal attack action.DoAttack(); } while (--m_extraAttacks > 0); } action.OnFinished(); return(procHitFlags); }