Jump to content

Recommended Posts

Hello 

I just want to know if anyone have some code for me for move back if a mob is freezed or rooted. 

How can I add such code in the fight class creator ?

I'm a noob in coding like c#. I know the basics in c# but that's all. 

Thanks for answers .

Link to comment
Share on other sites

Hello,

In fightclass general settings, in option "Additional C# code" add code like:

    static Main()
    {
        wManager.Events.FightEvents.OnFightLoop += (unit, cancelable) => {
            if (unit.IsValid && !ObjectManager.Me.IsCast && (unit.IsStunned || unit.Rooted))
            {
                wManager.Wow.Helpers.Move.Backward(Move.MoveAction.PressKey, 1500);
            }
        };
    }

(code not tested)

Sans titre.png

Link to comment
Share on other sites

Others sample:

    static Main()
    {
        wManager.Events.FightEvents.OnFightStart += (unit, cancelable) =>
        {
            robotManager.Helpful.Var.SetVar("CanBack", true);
        };

        wManager.Events.FightEvents.OnFightLoop += (unit, cancelable) =>
        {
            if (robotManager.Helpful.Var.Exist("CanBack") &&
                robotManager.Helpful.Var.GetVar<bool>("CanBack") &&
                unit.IsValid &&
                !ObjectManager.Me.IsCast &&
                unit.GetDistance < 15 &&
                !TraceLine.TraceLineGo(unit.Position))
            {
                var startPos = new Vector3(ObjectManager.Me.Position);
                var timer = new robotManager.Helpful.Timer(5 * 1000);
                try
                {
                    wManager.Wow.Helpers.Move.Backward(Move.MoveAction.DownKey);
                    while (!timer.IsReady &&
                           Conditions.InGameAndConnectedAndAliveAndProductStartedNotInPause &&
                           !TraceLine.TraceLineGo(unit.Position) &&
                           unit.GetDistance < 30)
                    {
                        Thread.Sleep(10);
                    }
                }
                catch
                {
                }
                finally
                {
                    wManager.Wow.Helpers.Move.Backward(Move.MoveAction.UpKey);
                }
                if (TraceLine.TraceLineGo(unit.Position)) // if your target is now not in line of sight after back, disable this option for current combat
                    robotManager.Helpful.Var.SetVar("CanBack", false);
                if (ObjectManager.Me.Position.DistanceTo(startPos) < 10 && unit.GetDistance < 30 && timer.IsReady) // if seem stuck (wall?)
                    robotManager.Helpful.Var.SetVar("CanBack", false);
            }
        };
    }

(not tested)

Link to comment
Share on other sites

  • 2 months later...
static Main()
    {
        wManager.Events.FightEvents.OnFightLoop += (unit, cancelable) => {
            if (unit.IsValid && ObjectManager.Target.IsTargetingMyPet && ObjectManager.Target.GetDistance <= 5)
            {
                wManager.Wow.Helpers.Move.Backward(Move.MoveAction.PressKey, 1500);
            }
        };
    }

1)not tested, but that doesn't check if they are an obstacle behind you.

2) you could do more properly by using  

MovementManager.Go(PathFinder.FindPath(ObjectManager.Me.Position, new Vector3(ObjectManager.Me.Position.X,
                ObjectManager.Me.Position.Y + 15,
                ObjectManager.Me.Position.Z)));

For example

Link to comment
Share on other sites

  • 5 months later...
  • 2 weeks later...
On 2017/10/14 at 3:01 AM, arkhan said:

static Main()
    {
        wManager.Events.FightEvents.OnFightLoop += (unit, cancelable) => {
            if (unit.IsValid && ObjectManager.Target.IsTargetingMyPet && ObjectManager.Target.GetDistance <= 5)
            {
                wManager.Wow.Helpers.Move.Backward(Move.MoveAction.PressKey, 1500);
            }
        };
    }

1)not tested, but that doesn't check if they are an obstacle behind you.

2) you could do more properly by using  


MovementManager.Go(PathFinder.FindPath(ObjectManager.Me.Position, new Vector3(ObjectManager.Me.Position.X,
                ObjectManager.Me.Position.Y + 15,
                ObjectManager.Me.Position.Z)));

For example

How to use this code?

static Main()
    {
        wManager.Events.FightEvents.OnFightLoop += (unit, cancelable) => {
            if ((ObjectManager.Target.HaveBuff("Frost Nova") || ObjectManager.Target.HaveBuff("Frostbite")) && ObjectManager.Target.HealthPercent >= 10 && ObjectManager.Target.GetDistance <= 8)
            {
                MovementManager.Go(PathFinder.FindPath(ObjectManager.Me.Position, new Vector3(ObjectManager.Me.Position.X,
                ObjectManager.Me.Position.Y + 15,
                ObjectManager.Me.Position.Z)));				
            }
        };
    }

Use like this has not work.

Link to comment
Share on other sites

@Droidz

I thought it would be better to necro this thread, than making a new one

Is there a way to check if there is any viable spots available?
Instead of using backtrack I have tried using the pathfinder with
 

var xvector = (ObjectManager.Me.Position.X) - (ObjectManager.Target.Position.X);
var yvector = (ObjectManager.Me.Position.Y) - (ObjectManager.Target.Position.Y);

Vector3 newpos = new Vector3()
{
  	X = ObjectManager.Me.Position.X + (float)((xvector * (25 / ObjectManager.Target.GetDistance) - xvector)),
	Y = ObjectManager.Me.Position.Y + (float)((yvector * (25 / ObjectManager.Target.GetDistance) - yvector)),
	Z = ObjectManager.Me.Position.Z
};
	MovementManager.Go(PathFinder.FindPath(newpos), false);
	Thread.Sleep(1700);

This is ofc. in a loop.
Now this will move my char 8-9 yards from the target walking in a straight line backwards using the pathfinder. However the issue remains the same, that if i hit a wall it will keep going. Here i can use your code written above to stop moving.

Instead of this, is there a way that i can, using the pathfinder: Find a place where there is 9 yards free from the target instead?

Link to comment
Share on other sites

PathFinder.FindPath has an API for checking if the path it made is valid. You can also use !TraceLine.Go(vector3) to check that LoS is available to the vector from your position.
Using those tools, you should be able to find a vector where no enemy is in sight (by periodicially checking LoS and enemy positions in ObjectManager) around your character. 

You can also use PathFinder.ReportDangerArea(vector3, radius) to tell the pathfinder to avoid this area (e.g. mob + aggro radius) while running away. But in my experience this is iffy and you should do your own "pathfinding" for small paths when not runnign very far away.

Link to comment
Share on other sites

12 minutes ago, Matenia said:

PathFinder.FindPath has an API for checking if the path it made is valid. You can also use !TraceLine.Go(vector3) to check that LoS is available to the vector from your position.
Using those tools, you should be able to find a vector where no enemy is in sight (by periodicially checking LoS and enemy positions in ObjectManager) around your character. 

You can also use PathFinder.ReportDangerArea(vector3, radius) to tell the pathfinder to avoid this area (e.g. mob + aggro radius) while running away. But in my experience this is iffy and you should do your own "pathfinding" for small paths when not runnign very far away.

Cheers @Matenia

I will try see if i can get something to work with this. :)
Vector3 to, out bool resultSucess is what i'd use to see if it can go to Vector3 right?

Edited by Ordush
Link to comment
Share on other sites

I say you do it the LoS way with TraceLine, you wouldn't want to walk around a wall and then not be able to shoot your target right? Because the result success would give you a true if it can make a path even if that means going around a wall.

Then if you don't have LoS adjust your vector either direction until you do, sort of how I explained here: https://wrobot.eu/forums/topic/7507-solved-move-after-frost-nova-is-it-really-that-hard/?do=findComment&comment=34304

THEN to make it even better check if there are hostiles where your path will go and adjust again. Maybe also add a failsafe so that if it cannot find a path, stay in melee? It's what a legitimate user would do too rather than run into other mobs.

Link to comment
Share on other sites

9 minutes ago, Marsbar said:

I say you do it the LoS way with TraceLine, you wouldn't want to walk around a wall and then not be able to shoot your target right? Because the result success would give you a true if it can make a path even if that means going around a wall.

Then if you don't have LoS adjust your vector either direction until you do, sort of how I explained here: https://wrobot.eu/forums/topic/7507-solved-move-after-frost-nova-is-it-really-that-hard/?do=findComment&comment=34304

THEN to make it even better check if there are hostiles where your path will go and adjust again. Maybe also add a failsafe so that if it cannot find a path, stay in melee? It's what a legitimate user would do too rather than run into other mobs.

Mine is checking for both, so if it can't find a path, but it is in LoS then it won't try.
I gave it 4 seconds to find it's way to a spot it thinks it can go to (failsafe). :)

Link to comment
Share on other sites

//Checks if there's available LoS between your target and the new spot too.
!TraceLine.TraceLineGo(ObjectManager.Target.Position, newPos)

//check if there's LoS between you and the new Pos  
!TraceLine.TraceLineGo(newPos)

//Then you can use:
bool isValid = false;
var path = PathFinder.FindPath(newpos, out isValid);

if(isValid)
{
    MovementManager.Go(path, false);
}

This prevents a CPU/memory hog, but only using pathfinding once you confirmed LoS. Also check that no NPC is near newPos.
 

Edited by Matenia
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...