• You've discovered RedGuides 📕 an EverQuest multi-boxing community 🛡️🧙🗡️. We want you to play several EQ characters at once, come join us and say hello! 👋
  • IS THIS SITE UGLY? Click "RG3" at the very bottom-left of this page to change it. To dismiss this notice, click the X --->

Question - Declare your current target as a variable and then re-targeting it after targeting yourself/different target? (1 Viewer)

Hellaciouss

Member
Joined
Jun 21, 2022
RedCents
241¢
Anyone have an example I could go off for a macro?

Do I have to declare the var somewhere first?

/varset PreviousTarget ${Target}
/tar myself
/delay 5
/tar ${Previous_Target}

i know i can use /target ${NearestSpawn[npc]} which works but sometimes the target I want to target is not the nearest, but my previous target that I had prior to switching to myself
 
Last edited:
Solution
Well I would first like to say you can set both of those as hotkeys in EQ itself. But in your case you have a few problems.

In order to "varset" you must first "declare", but it's possible to declare and set the value at the same time. The issue here would be is if this was in a loop you would need to do it slightly different.
I also recommend that you use ${Target.ID} as the ID will be unique where-as the name may not be. The name is the default value when you don't provide a member.
Additionally, when you do /tar ${Previous_Target} you've told the macro to target a value you haven't declared or set above. Because you've added the underscore, it's not the same thing you had varset. You must be consistent.
It's unclear what the delay...

ChatWithThisName

⚔️🛡️🗡️
Moderator
Joined
Dec 29, 2017
RedCents
4,239¢
Well I would first like to say you can set both of those as hotkeys in EQ itself. But in your case you have a few problems.

In order to "varset" you must first "declare", but it's possible to declare and set the value at the same time. The issue here would be is if this was in a loop you would need to do it slightly different.
I also recommend that you use ${Target.ID} as the ID will be unique where-as the name may not be. The name is the default value when you don't provide a member.
Additionally, when you do /tar ${Previous_Target} you've told the macro to target a value you haven't declared or set above. Because you've added the underscore, it's not the same thing you had varset. You must be consistent.
It's unclear what the delay is for, or what you are targeting yourself for. But I recommend using delays with early stop conditions, meaning you want to wait, but only until the reason you started waiting has been accomplished. So below I have it waiting until the target is yourself. You don't do anything once you target yourself, So I'm going to assume you're planning to fill that in.

INI:
/declare PreviousTarget int local ${Target.ID}
/target id ${Me.ID}
/delay 1s ${Target.ID} == ${Me.ID}
|Insert thing to do once you've targeted yourself.
/tar id ${PreviousTarget}
/delay 1s ${Target.ID} == ${PreviousTarget}
|Insert thing to do once you've regained your previous target.

when declaring a variable in a loop, you may want to either declare the variable outside of the loop, or make sure the variable hasn't already been defined. Those two options will be below.

Outside the loop (likely more efficient)
INI:
/declare PreviousTarget int local
/while (1) {
    /varset PreviousTarget ${Target.ID}
    /target id ${Me.ID}
    /delay 1s ${Target.ID} == ${Me.ID}
    |Insert thing to do once you've targeted yourself.
    /tar id ${PreviousTarget}
    /delay 1s ${Target.ID} == ${PreviousTarget}
    |Insert thing to do once you've regained your previous target.
}


Inside the loop
INI:
/while (1) {
    /if (!${Defined[PreviousTarget]}) {
        /declare PreviousTarget int local ${Target.ID}
    } else {
        /varset PreviousTarget ${Target.ID}
    }
 
    /target id ${Me.ID}
    /delay 1s ${Target.ID} == ${Me.ID}
    |Insert thing to do once you've targeted yourself.
    /tar id ${PreviousTarget}
    /delay 1s ${Target.ID} == ${PreviousTarget}
    |Insert thing to do once you've regained your previous target.
}
 
Last edited:
Solution

Hellaciouss

Member
Joined
Jun 21, 2022
RedCents
241¢
First, thank you very much for such a quick and informative reply. I am very new at this and sorry if it shows.

I am just trying to start small. It is just an event watching macro (so far) to cast Fleeting Fury on myself and my pet when it wears off and I am in combat.

When I try either of the above, it goes through but will not re-target the NPC i had targeted and I get the following in the log

INI:
There are no spawns matching (0-200) any whose name is previoustarget.

Here is what I currently have:

INI:
#turbo

/declare PreviousTarget int local

#event FleetingFury "#*#Your fury fades.#*#"
#event FleetingFizzles "#*#Your Fleeting Fury spell fizzles!#*#"

Sub Main
:loop

    /doevents
    
/goto :loop

 
/return

Sub Event_FleetingFury
/if (${Me.Combat}&&!${Me.Casting}&&!${Me.Sitting}) {
    
    /varset PreviousTarget ${Target.ID}
    /target id ${Me.ID}
    /delay 1s ${Target.ID} == ${Me.ID}
    /cast "Fleeting Fury"
    /target PreviousTarget
    /delay 1s ${Target.ID} == ${PreviousTarget}
    
    }
    
/return
 

Sic

[sic]
Moderator
Joined
May 5, 2016
RedCents
25,570¢
First, thank you very much for such a quick and informative reply. I am very new at this and sorry if it shows.

I am just trying to start small. It is just an event watching macro (so far) to cast Fleeting Fury on myself and my pet when it wears off and I am in combat.

When I try either of the above, it goes through but will not re-target the NPC i had targeted and I get the following in the log

INI:
There are no spawns matching (0-200) any whose name is previoustarget.

Here is what I currently have:

INI:
#turbo

/declare PreviousTarget int local

#event FleetingFury "#*#Your fury fades.#*#"
#event FleetingFizzles "#*#Your Fleeting Fury spell fizzles!#*#"

Sub Main
:loop

    /doevents
  
/goto :loop

 
/return

Sub Event_FleetingFury
/if (${Me.Combat}&&!${Me.Casting}&&!${Me.Sitting}) {
  
    /varset PreviousTarget ${Target.ID}
    /target id ${Me.ID}
    /delay 1s ${Target.ID} == ${Me.ID}
    /cast "Fleeting Fury"
    /target PreviousTarget
    /delay 1s ${Target.ID} == ${PreviousTarget}
  
    }
  
/return
that isn't a valid event


you would just want that to be a sub, and then call the sub in your loop
 

Hellaciouss

Member
Joined
Jun 21, 2022
RedCents
241¢
Hello again,

I simply could not get the above to work unfortunetly, so I set up some echo to try and help troubleshoot.

INI:
/declare PreviousTarget int local

Would only set the ${PreviousTarget} as 0 and would come back as "There are no spawns matching". Changing to
INI:
/declare PreviousTarget outer
allowed the storage of the full name string.

I took your advice and had the event call a sub. Completed and working the code looks as follows:

INI:
#turbo

#event FleetingFury "#*#Your fury fades.#*#"
#event FleetingFizzles "#*#Your Fleeting Fury spell fizzles!#*#"

Sub Main

/declare PreviousTarget outer

:loop

    /if (${Me.Sitting}) {
        /endmacro
    }
        
    /doevents
    
/goto :loop

 
/return

Sub Event_FleetingFury
/call FleetingFury
/return

Sub FleetingFury

/if (${Me.Combat}&&!${Me.Casting}&&!${Me.Sitting}) {

    /varset PreviousTarget ${Target}
    /echo My Previous Target is set as ${PreviousTarget}
    /target id ${Me.ID}
    /cast "Fleeting Fury"
    /target ${PreviousTarget}
    
    }
    
/return

Now I just need to add in recasting if it fizzles (which eventually it should never fizzle) and casting on warder, but also detecting if the spell is on cooldown and to try again after a second. Thank you very much for your responses!
 

ChatWithThisName

⚔️🛡️🗡️
Moderator
Joined
Dec 29, 2017
RedCents
4,239¢
I see. I made a mistake.
Even veterans of macro coding can do that on occasion.

/target id ${PreviousTarget}

I failed to wrap the variable in the ${}
in some of that I didn't specify "id" when giving the target command.
Kinda wrote that stuff from the hip and didn't at all check any of it to ensure it worked. So that's my bad.
I edited my original response to correct the deficiency.
 
Last edited:

ChatWithThisName

⚔️🛡️🗡️
Moderator
Joined
Dec 29, 2017
RedCents
4,239¢
Also real quick if you haven't seen them. I have a couple of guides.

This first one explains conditions and how they work.

This second one gets you started with macros, explaining subs, the difference in "outer" variable, and "local" variable. etc.

Both are good reads for starting users and I highly recommend them.

Also, I noticed you are level 1, meaning you don't have an upgraded account with redguides. So I'm curious where you've obtained your existing macroquest and if you were interested in trying out level 2 redguides. There's tons of existing macros, luas, plugins, and tools available at redguides that may help you in this journey you are taking.
 

ChatWithThisName

⚔️🛡️🗡️
Moderator
Joined
Dec 29, 2017
RedCents
4,239¢
INI:
    /cast "Fleeting Fury"
    /target ${PreviousTarget}

I would also like to point out that when you're doing things in macros you need to consider all things. If you start casting and targeting basically at the same time it could cause an issue. You'll want to /cast "Fleeting Fury" and then give it a delay to allow it an opportunity to do the casting. I believe fleeting fury is a really fast cast time. So it may not present as big an issue in this case, but you may run into issues with this later with other spells.
 

Hellaciouss

Member
Joined
Jun 21, 2022
RedCents
241¢
I would also like to point out that when you're doing things in macros you need to consider all things. If you start casting and targeting basically at the same time it could cause an issue. You'll want to /cast "Fleeting Fury" and then give it a delay to allow it an opportunity to do the casting. I believe fleeting fury is a really fast cast time. So it may not present as big an issue in this case, but you may run into issues with this later with other spells.
Hi,

Yes, I started realizing doing what I was doing with just events was going to get a bit out of control, so I messed around with it and made this:

INI:
#turbo

Sub Main

/declare PreviousTarget outer

/while (1>0) {

    /if (!${Me.Buff[Fleeting Fury].Duration}&&${Me.Combat}) {
       
        /delay 10
        |/echo Fleeting Fury not detected.
        /varset PreviousTarget ${Target}
        |/echo My Previous Target is set as ${PreviousTarget}
        /target id ${Me.ID}
        /cast "Fleeting Fury"
        /delay 10
        /target ${PreviousTarget}
   
    }
}
/return

There is still a lot I want to do, like spell switching if I don't have a certain spell on my spell bar. And yes, when I did not have a small delay it would bounce back between the target and I a couple times before I even finished casting, which made it awkward, so I added more slight delays throughout. I will take a look at those guides for sure! Thank you very much for your help!
 

Users who are viewing this thread

Top