I copied the Whirlwind special ability class and reversed the logic so that it acts like Axe's special "Counter Helix" move (every time the axe wielding player is hit there is a chance to counter attack nearby mobs). The code works perfectly when I paste the following in the "OnGaveMeleeAttack" method in BaseCreature.cs:

Code:
public virtual void OnGaveMeleeAttack(Mobile defender)
        {
            #region Counter Helix        
           
            Skill skill = defender.Skills[SkillName.Lumberjacking];        
       
   if (defender.Weapon is BaseAxe && Utility.Random(120) <= ((int)(skill.Value)))
            {
                ArrayList list = new ArrayList();

                BaseWeapon weapon = defender.Weapon as BaseWeapon;

                foreach (Mobile m in defender.GetMobilesInRange(1))
                    list.Add(m);

                ArrayList targets = new ArrayList();           

                for (int i = 0; i < list.Count; ++i)
                {
                    Mobile m = (Mobile)list[i];

                    if (m != defender && m != defender && SpellHelper.ValidIndirectTarget(defender, m))
                    {

                        if (m == null || m.Deleted || m.Map != defender.Map || !m.Alive || !defender.CanSee(m) || !defender.CanBeHarmful(m))
                            continue;

                        if (!defender.InRange(m, weapon.MaxRange))
                            continue;

                        if (defender.InLOS(m))
                            targets.Add(m);
                    }
                }

                if (targets.Count > 0)
                {
                                   
                    defender.RevealingAction();

                    for (int i = 0; i < targets.Count; ++i)
                    {
                        Mobile m = (Mobile)targets[i];

                        m.FixedEffect(0xf49, 10, 15);
                        defender.PlaySound(0x2A1);

                        weapon.OnHit(defender, m);                  
                    }
                }
            }
            #endregion

            Poison p = HitPoison;
	 ...

I separated the above code into its own script (1st code below in CounterHelix.cs) to keep the BaseCreature file as clean as possible; however, I am having trouble calling on the method (2nd code posted below). Visual studio says I need overloads. I researched online and I believe this is calling on method when the signatures are different (correct me if I am wrong) and it hasn't taken a number of combinations of overloads. Thanks in advance.

CounterHelix.cs
Code:
using System;
using System.Collections;
using Server.Spells;

namespace Server.Items
{
    /// <summary>
    /// A godsend to a warrior surrounded, the Whirlwind Attack allows the fighter to strike at all nearby targets in one mighty spinning swing.
    /// </summary>
    public class CounterHelix : WeaponAbility
    {
        public CounterHelix()
        {
        }

        public override int BaseMana
        {
            get
            {
                return 0;
            }
        }
       
        public override void OnHit(Mobile attacker, Mobile defender, int damage)
        {
       
            ArrayList list = new ArrayList();

            BaseWeapon weapon = defender.Weapon as BaseWeapon;

            attacker.FixedEffect(0x3728, 10, 15);
            defender.PlaySound(0x2A1);
            //Effects.SendMovingEffect(defender, m, 0xf49, 7, 0, false, false,1,0);

            foreach (Mobile m in defender.GetMobilesInRange(1))
                list.Add(m);

            ArrayList targets = new ArrayList();

            for (int i = 0; i < list.Count; ++i)
            {
                Mobile m = (Mobile)list[i];

                if (m != defender && m != defender && SpellHelper.ValidIndirectTarget(defender, m))
                {

                    if (m == null || m.Deleted || m.Map != defender.Map || !m.Alive || !defender.CanSee(m) || !defender.CanBeHarmful(m))
                        continue;

                    if (!defender.InRange(m, weapon.MaxRange))
                        continue;

                    if (defender.InLOS(m))
                        targets.Add(m);
                }
            }

           if (targets.Count > 0)
            {            
               int CounterHelixDamage = defender.Str / 2;
               
               defender.RevealingAction();

               for (int i = 0; i < targets.Count; ++i)
               {
                   Mobile m = (Mobile)targets[i];

                   defender.SendMessage("Counter Helix Damage:" + CounterHelixDamage.ToString());
                   m.SendMessage("Hit with Counter Helix for:" + CounterHelixDamage.ToString());               

                   AOS.Damage(m, CounterHelixDamage, 100, 0, 0, 0, 0);
            }
               
            }
        }
    }
}

OnGaveMeleeAttack in base creature
Code:
public virtual void OnGaveMeleeAttack(Mobile defender)
        {
            #region Counter Helix        
           
            Skill skill = defender.Skills[SkillName.Lumberjacking];        

            if (defender.Weapon is BaseAxe && Utility.Random(120) <= ((int)(skill.Value)))
            {
                CounterHelix CH = new CounterHelix();
                CH.OnHit();
            }
...
 
You don't need an overload: you only need to change the method call.

The method definition is
Code:
public override void OnHit(Mobile attacker, Mobile defender, int damage)
So, it needs an attacker, a defender and a damage amount.

If you don't provide those informations, how can your script apply the damage? from who? against who?

You need to modify the call as follow:
Code:
public virtual void OnGaveMeleeAttack(Mobile defender)
{
           #region Counter Helix       
          
           Skill skill = defender.Skills[SkillName.Lumberjacking];      

           if (defender.Weapon is BaseAxe && Utility.Random(120) <= ((int)(skill.Value)))
           {
                CounterHelix CH = new CounterHelix();
                CH.OnHit(attacker, defender, 0);
           }
...

The amount of damage taken by the defender isn't used by your script, but you need to provide it to match the method signature.
I don't know if what are you trying to do is correct (CounterHelix isn't used as weapon ability in this context...).
Maybe is better to define the custom logic into a separate script and call that wherever you need it.
 

Active Shards

Donations

Total amount
$0.00
Goal
$1,000.00
Back