Timed Command

A forum for macro code snippets to be used in writing other macros. Post routines or .inc files here only, completed macros go to the Macro Depot. MQ2Data format only!

Moderator: MacroQuest Developers

s0rcier
a grimling bloodguard
a grimling bloodguard
Posts: 876
Joined: Mon Aug 02, 2004 10:49 pm

Timed Command

Post by s0rcier » Wed Sep 22, 2004 5:47 am

I was trying to make an outer variable that last for x duration to let me know that current target got that spell effects on, when i stumble on a bug with the /timed fuction that doesnt allow me to pass a variable with the timed delay in example like below: (in this example variable ${MyVar} will last for about 1secs then get automatically deleted what ever time i have in ${MyDur}.

Code: Select all

    /declare HotSpl string local Supernal Elixir
    /declare MyVar  string local nohotforyou${Target.ID}
    /declare MyDur     int local ${Math.Calc[10*${Spell[${HotSpl}].Duration.TotalSeconds}].Int}
    /declare ${MyVar}  int outer ${MyDur}
    /timed ${MyDur} /deletevar ${MyVar}
So i end up making a small fuction to handle my problems.

Code: Select all

Sub TimedCmd(int duration,string command)
    /if (${command.Equal[NULL]}) /return 0
    /declare cmd string local /${command}
    /declare str string local /timed ${duration} ${cmd}
    /docommand ${If[${duration},${str},${cmd}]}
/return 1
here is my final example calling the sub ...

Code: Select all

    /declare HotSpl string local Supernal Elixir
    /declare MyVar  string local nohotforyou${Target.ID}
    /declare MyDur     int local ${Math.Calc[10*${Spell[${HotSpl}].Duration.TotalSeconds}].Int}
    /declare ${MyVar}  int outer ${MyDur}
    /call TimedCmd ${MyDur} "deletevar ${MyVar}"
Well hope people could find some nice use of this and that could help out some making more easy coding!

s0rCieR

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Wed Sep 22, 2004 6:45 am

or you could just declare a timer when you want to use a timer, instead of trying to make /timed do something it wasn't meant to.

Also

Code: Select all

/declare MyVar  string local nohotforyou${Target.ID}
/declare ${MyVar}  int outer ${MyDur} 
is somewhat questionable practice. Are you sure this is what you want to do here?

s0rcier
a grimling bloodguard
a grimling bloodguard
Posts: 876
Joined: Mon Aug 02, 2004 10:49 pm

Post by s0rcier » Wed Sep 22, 2004 7:47 am

Well i did that, cause i wanted to setup a variable on to indicate me that this person is on HOT for the duration of the HOT spell if the cast was successful. All my healing subs working with ID, and i wanted an easy way in my find worst target to skip people that are actually under effect of a hot spells ... so having a variable nohotforID with a defined check was real easy to setup. Since my worst sub also could be called to check health of my watchlist "close friends" or called also to watch health for pets or raid members...

i didnt want to make an array of timer on person i heal and then find person in array that match id to check if timer is expired for him, or check list of person id to get last time i cast on him, to calc elapsed time, and didnt want to have to check every 2secs if i still checking good id in list cause person die or zone, so end up with that small idea

So idea of using this variable was just for a check, contant of it have no real importance, i just plain check if variable exist or not with ${Defined[]} so didnt find any more easy way to do that ...


/if ${Defined[nohotforyou${lookID}]} /goto :checknext

and when u actually cast on him and the casting was successfull to

/declare nohotforyou${Target.ID} int ouer 999
/call timedCmd ${PreCalcTime} "deletevar nohotforyou${Target.ID}"

Well i'm sure in other case doing regular timer type are more easy to implements, but well for that case, tough it was the easiest way

Thx for the feedback :)

Sure well code posted i optimize it to 2 lines ... 1 for the declare and 1 for the call subroutines itself :) hehe

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Wed Sep 22, 2004 8:31 am

I still don't see what you're gaining above and beyond

Code: Select all

/declare ${MyVar} timer outer ${MyDur}
It counts down all by itself and triggers automatically with /doevents so you don't need any code to "check" it. If you *did* for some reason want to check the time remaining you have that option, which seems to be a win over your way of doing things.

s0rcier
a grimling bloodguard
a grimling bloodguard
Posts: 876
Joined: Mon Aug 02, 2004 10:49 pm

Post by s0rcier » Wed Sep 22, 2004 11:02 am

Did u see that myvar is construct with target id# if u heal a whole raid u will finish up with 72 + all pets variable ... all all timers, with more then 50 expired one that u might never reuse, counting that probably all ld people when come back will create a new timer, or person that zone out / in ... didnt want to finish with 150 timers running ...

If variable was based on charactername instead of id, witch varies from zone to zone, etc, i will have agree with ya that was the pretty easy solution!

s0rCieR

User avatar
Cr4zyb4rd
Plugins Czar
Posts: 1449
Joined: Tue Jul 20, 2004 11:46 am

Post by Cr4zyb4rd » Wed Sep 22, 2004 5:43 pm

How does your way prevent the same problem? By deleting the variables? So delete the timers as they expire..

Timers allow you to do the *exact* same thing without using timed (which you insist is "bugged") and enhance functionallity. I can only rephrase it so many ways, and since I don't feel like switching to caps in hopes you'll pay more attention if I scream louder, have a nice thread/life.

s0rcier
a grimling bloodguard
a grimling bloodguard
Posts: 876
Joined: Mon Aug 02, 2004 10:49 pm

Post by s0rcier » Thu Sep 23, 2004 10:24 am

Maybe sub was bugged in the past, but on near 100tst i did it always timed right everything, only reason i see atm that will make me change my code is the fact that when i end the macro, i got some errors popping out that variable no longer exist ....(cause i defined variable outer not globals) i dont want to switch variable to globals for that ...

i beleive in your experience when u say it was buggy, and well i will have to find a way to implement that using timers, just dont hope that 72+ timers or more wont slow down to much my codes! i never see some nice events like your talking about i always remember when u start a timer that u have to test it with a if a few times to check if it have reaches 0 to know if it haves expired or not, i never heard about driven events like you are talking about ... maybe it's an area i need to explore more!

Just wish i wont end up adding 50 lines of codes just to implements those timers! I must admit also, that using a timed function to delete a var is a little ugly when you have possibility to have directly timers variables.

Idea behind my orginal post is i was proud to see that i was able to done it with /timed, found a way to pass parameters and have him to accept it ... now i will really need to find a crash course on timers i think :P since u tells me that they are so powerfuls and flexibles!

s0rCieR

PS:

it was 1 line to do my declare ... 1 line to call the timed subs ... and a few place to test if defined[variable] ...

just dont hope i will end up having to test at each spot if timer exist, if timer have expired, and if i should deletevar or write down a 2 pages long subs just to handle them events styles! or if i dont delete var, make sure var not existing when i try to create it, and if it was existing to have to reset it ...

[TESTED my codes last nite during a 2 hours raid works pretty pretty fine, was happy to see him going and going ... till i hit the end button] Got 2-3 msg popping in the next 30 secs or so saying that variable nohotforyou#### was no longer exist :P