public override void OnAttack(DamageAction action) { if (action.Spell != null) { return; } if ((double)this.Owner.SplinterEffect > 0.0) { foreach (WorldObject objectsInRadiu in (IEnumerable <WorldObject>) this.Owner.GetObjectsInRadius <Unit>( 2.5f, ObjectTypes.Attackable, false, int.MaxValue)) { if (this.Owner.IsHostileWith((IFactionMember)objectsInRadiu) && !object.ReferenceEquals((object)objectsInRadiu, (object)this.Owner) && Utility.Random(0, 100000) <= this.Owner.SplinterEffectChange) { Character targetChr = objectsInRadiu as Character; NPC targetNpc = objectsInRadiu as NPC; DamageAction unusedAction = this.Owner.GetUnusedAction(); unusedAction.Damage = (int)((double)this.Owner.RandomDamage * (double)this.Owner.SplinterEffect); unusedAction.Attacker = objectsInRadiu as Unit; unusedAction.Victim = objectsInRadiu as Unit; int num = (int)unusedAction.DoAttack(); if (this.Owner is Character) { Asda2SpellHandler.SendMonstrTakesDamageSecondaryResponse((Character)null, targetChr, targetNpc, unusedAction.ActualDamage); } action.OnFinished(); } } } base.OnAttack(action); }
/// <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); }