Jump to content

Use certain spell when a certain number of mobs are in range?


Sleepwalker

Recommended Posts

2 hours ago, Sleepwalker said:

It looks more related to non C# profiles but I'm unsure exactly how I'd implement that code into my fight class

ObjectManager.GetWoWUnitHostile......
Link to comment
Share on other sites

12 hours ago, Zan said:

ObjectManager.GetWoWUnitHostile......

Implementing this code into the fight class base I'm using doesn't appear to work, wrobot just throws up errors. I've attached the fight class below and an image with said error, thanks again for your help. 4161b03a1b.png

dRotation -feral2.cs

Link to comment
Share on other sites

Here's what I use to check attackers in range:

public static int GetAttackerCountInRange(float yards)
{
    int EnemyCountInRange = ObjectManager.GetUnitAttackPlayer().Count(t => t.IsAlive && t.IsValid && t.IsAttackable && t.InCombat && t.GetDistance <= yards);
    if (EnemyCountInRange > 0)
        {
            Logging.WriteDebug($"Enemy attacking count = {EnemyCountInRange}");
            return EnemyCountInRange;
        }
    return 0;
}

 

Edited by Apexx
Link to comment
Share on other sites

3 hours ago, Apexx said:

Here's what I use to check attackers in range:


public static int GetAttackerCountInRange(float yards)
{
    int EnemyCountInRange = ObjectManager.GetUnitAttackPlayer().Count(t => t.IsAlive && t.IsValid && t.IsAttackable && t.InCombat && t.IsTargetingMeOrMyPetOrPartyMember && t.GetDistance <= yards);
    if (EnemyCountInRange > 0)
        {
            Logging.WriteDebug($"Enemy attacking count = {EnemyCountInRange}");
            return EnemyCountInRange;
        }
    return 0;
}

 

Can you show how you've implemented this? I'm pretty nooby when it comes to c#. I've tried putting the code in its own spot then calling GetAttackerCountInRange in the swipe spell however I run into an error saying this: a8a22229ba.png in reference to your third line.

Link to comment
Share on other sites

This should be enough as your if statement:

if (Swipe.KnownSpell && Swipe.IsSpellUsable && Swipe.IsDistanceGood && ObjectManager.Me.ComboPoint <= 3 && ObjectManager.GetWoWUnitAttackables().Count(u => u.Position.DistanceTo(ObjectManager.Target.Position) <= 8 && u.Guid != ObjectManager.Pet.Guid) >= 3)
Link to comment
Share on other sites

20 minutes ago, Marsbar said:

This should be enough as your if statement:

if (Swipe.KnownSpell && Swipe.IsSpellUsable && Swipe.IsDistanceGood && ObjectManager.Me.ComboPoint <= 3 && ObjectManager.GetWoWUnitAttackables().Count(u => u.Position.DistanceTo(ObjectManager.Target.Position) <= 8 && u.Guid != ObjectManager.Pet.Guid) >= 3)

I get the same error every time, I really appreciate all the help I'm receiving. The error looks the same as everyone elses suggestion though, .Count cannot be used like a method. 8aac85be73.png

Link to comment
Share on other sites

12 minutes ago, Sleepwalker said:

I get the same error every time, I really appreciate all the help I'm receiving. The error looks the same as everyone elses suggestion though, .Count cannot be used like a method. 8aac85be73.png

Go download VS Community Edition and add WRobot references while writing in C#

Link to comment
Share on other sites

20 minutes ago, Marsbar said:

Oh lol dude, add a 

using System.Linq;

to the usings at the top of the file

I can't believe it was something so simple hahah! I can tweak around with more things now at least thanks so much! I just gotta figure out how to stop the other spells casting now instead of swipe but I'm sure I can figure that out.

Edit:

I just used an else if statement in the swipe spell and it works perfectly, so now it'll cast swipe if 3 targets and shred if it's less than that. Thanks so much!

9 minutes ago, Zan said:

Go download VS Community Edition and add WRobot references while writing in C#

Yeah makes a lot of sense, I've just been a bit of a fool and stuck to using NP++ for a while now, I'll swap over to that thank you again also.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...