Macro that builds from MQ2Twist and MQ2MoveUtils plugins

Need help with a macro you are writing? Ask here!

Moderator: MacroQuest Developers

Inusien
Contributing Member
Contributing Member
Posts: 4
Joined: Tue Mar 16, 2004 1:12 am

Macro that builds from MQ2Twist and MQ2MoveUtils plugins

Post by Inusien » Tue Jun 22, 2004 10:40 pm

Hi folks,

Looking for a spot of help. I'm *trying* to write a macro that builds off of functionality present in CyberTech's MQ2Twist plugin, and Tonio's MQ2MoveUtils plugin (specifically the /circle command). My goal is to simply target a new mob when I receive the "You must first select a target for this spell!" message. I also have some other bells and whistles present in the other chant macros.

I believe my problem to be in the "lets run this macro forever department" as I'm trying to get it to continuously check for the specific events. I say this, because when I start 'er up, I get a Macro Ended message.

If you can take a look at my approach, and provide feedback, I'd appreciate it greatly.

Code: Select all

| Target.mac
| 

#event NeedTarget "You must first select a target for this spell!" 
#event Died "You have entered#*#" 
#event Tell "#*#tells you#*#"
#event CampCheck "#*#Camp Check#*#"
#event HPChk "#*#YOU for#*#"

Sub Main(string Cchk)

|------------------Declare & Set Variables-------------------|

/declare intNeedTarget int outer
/varset intNeedTarget 0

/declare intDied int outer
/varset intDied 0

/declare intTell int outer
/varset intTell 0

/declare intCampCheck int outer
/varset intCampCheck 0

/declare intHPChk int outer
/varset intHPChk int 0

/declare intMinHPS int outer
/varset intMinHPS 85

|----------------------NeverEnding Loop----------------------|

:Main

 :NeedTarget

 /If (${intNeedTarget}>=1) {
  /keypress F8
  /echo Kiting ${Target.CleanName}
  /varset intNeedTarget 0
  /goto :Main
 }

 :Died

 /If (${intDied}>=1) {
  /delay 10 
  /sit
  /echo Camping to desktop.
  /delay 10 
  /camp desktop 
  /endmacro
 }

 :Tell

 /If (${intTell}>=1) {
  /beep 
  /delay 10
  /beep
  /delay 40
  /goto :Main
 }

 :CampCheck

 /If (${intCampCheck}>=1) {
  /beep
  /delay 4s
  /beep
  /ooc I'm kiting ${Cchk}
  /varset intCampCheck 0
  /goto :Main
 }

 /If (${Me.PctHPs}<${MinHPs}) {
  /twist 8 12
  /echo Healing to ${Me.MaxHPs} hitpoints.
  /delay ${Math.Calc[${[${Math.Calc[${Math.Calc[${Me.MaxHPs}-${Me.CurrentHPs}]}/100]}*6.02]}
  /twist 4 5 6 7 8 11
  /varset intHPChk 0
  /goto :Main
 }

/goto :Main

|---------------------------Events---------------------------|

Sub Event_NeedTarget 
  /varset intNeedTarget ${Math.Calc[${intNeedTarget}+1]}
  /goto :NeedTarget
/return 

Sub Event_Died 
  /varset intDied ${Math.Calc[${intDied}+1]}
  /goto :Died
/return 

Sub Event_Tell 
  /varset intTell ${Math.Calc[${intTell}+1]}
  /goto :Tell
/return 

Sub Event_CampCheck
  /varset intCampCheck ${Math.Calc[${intCampCheck}+1]}
  /goto :CampCheck
/return

Again, any assistance would be greatly appreciated. Thanks~

User avatar
Fuergrissa
a grimling bloodguard
a grimling bloodguard
Posts: 607
Joined: Mon Dec 08, 2003 3:46 pm
Location: UK

Re: Macro that builds from MQ2Twist and MQ2MoveUtils plugins

Post by Fuergrissa » Wed Jun 23, 2004 2:13 am

Inusien wrote:

Code: Select all

    :Main
    [color=red]   /delay 1s
       /doevents [/color]
    :NeedTarget
A quick glance shows me your never checking for your events, add the stuff in red first and when i get home tonight ill have a nother look.
[quote]"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."[/quote]

dok
a ghoul
a ghoul
Posts: 127
Joined: Mon Mar 15, 2004 3:38 pm

Post by dok » Wed Jun 23, 2004 4:07 am

few quick problems I see, besides whats already been mentioned. You're trying to /goto across Functions. thats a no go I'm 99% sure, even though I've never tried it myself. I believe it might still work if you fixed your loop and /goto lines are ignored if they cant process, but so much unnecessary stuff in there.

this is what I think I'd do for what you have posted...

you might want to use #chat tell instead of #event Tell.
Also, unsure how delays are going to effect the /twist plugin, but becareful with that healing loop
I've had a few issues with nested ifs kinda like I have for the healing, but left it that way for readability. you have have to combine the ifs a little bit to get it to work as intended.

Code: Select all

| Target.mac 
| 

#event NeedTarget "You must first select a target for this spell!" 
#event Died "You have entered#*#" 
#event Tell "#*#tells you#*#" 
#event CampCheck "#*#Camp Check#*#" 
#event HPChk "#*#YOU for#*#" 

Sub Main(string Cchk) 

|------------------Declare & Set Variables-------------------| 

/declare MinHPs int outer 85

/declare healing string outer FALSE

|----------------------NeverEnding Loop----------------------| 

:Main 
    /if (${healing}) {
        /If (${Me.PctHPs}>${MinHPs}) { 
            /varset healing FALSE
            /twist 4 5 6 7 8 11 
        }
    } else {
        /If (${Me.PctHPs}<=${MinHPs}) { 
            /varset healing TRUE
            /twist 8 12 
            /echo HEALING....
        }
    }

   /doevents
   /delay 1
/goto :Main

/endmac  


|---------------------------Events---------------------------| 

Sub Event_NeedTarget 
  /keypress F8 
  /echo Kiting ${Target.CleanName} 
  /varset intNeedTarget 0 
/return 

Sub Event_Died 
  /delay 10 
  /sit 
  /echo Camping to desktop. 
  /delay 10 
  /camp desktop 
  /endmacro 
/return 

Sub Event_Tell 
  /beep 
  /delay 10 
  /beep 
  /delay 40 
/return 

Sub Event_CampCheck 
  /beep 
  /delay 4s 
  /beep 
  /ooc I'm kiting ${Cchk} 
/return 

Inusien
Contributing Member
Contributing Member
Posts: 4
Joined: Tue Mar 16, 2004 1:12 am

Post by Inusien » Wed Jun 23, 2004 5:54 am

Fuergrissa -

I added the lines you suggested and it started to work! Woot!

dok -

I took out the /goto references as you suggested. I agree, there's probably a way to make this slimmer. However, I am trying to avoid issuing a /twist command every time the macro loops. I believe that will restart the twist lineup and therefore keep trying to twist the first song repeatedly - at least, that was the mindset I was in when I pieced this together from some of the other twist macros (props to the original creators).

I made some notes in the macro text. Mainly, I'm scratching my head about the Health Monitoring system. I took a bit different approach here, but I still can't get it to start the healing lineup.

Also, I added a check to see if the Cchk string had something in it (ala having a .Length > 1). Replying to /ooc Camp check with "I'm camping NULL." = Bad

Code: Select all


| Target.mac
| 

#event NeedTarget "You must first select a target for this spell!" 
#event OutofRange "Your target is out of range, get closer!"
#event Died "You have entered#*#" 
#event Tell "#*#tells you#*#"
#event CampCheck "#*#Camp Check#*#"
#event HPChk "#*#points of damage#*#"

Sub Main(string Cchk)

 /If (${Cchk.Length}>1) {
  /echo Responding to /ooc Camp check with ${Cchk}.
 } else {
  /echo Not responding to /ooc Camp check. Response set to ${Cchk}. 
 }

|------------------Declare & Set Variables-------------------|

/declare intNeedTarget int outer
/varset intNeedTarget 0

/declare intOOR int outer
/varset intOOR 0

/declare intDied int outer
/varset intDied 0

/declare intTell int outer
/varset intTell 0

/declare intCampCheck int outer
/varset intCampCheck 0

/declare intHPChk int outer
/varset intHPChk int 0

/declare intMinHPs int outer
/varset intMinHPs 95

|----------------------NeverEnding Loop----------------------|

:Main

 /delay 1s
 /doevents

|Target Acquisition - Tested, working great

  /If (${intNeedTarget}>=1) {
   /keypress F8
   /echo Kiting ${Target.CleanName}
   /varset intNeedTarget 0
  }

|Out of Range - Tested, working great
 
  /If (${intOOR}>=1) {
   /keypress F8
   /echo Kiting ${Target.CleanName}
   /varset intOOR 0
  }

|Camp ala Zone - Tested, working great

  /If (${intDied}>=1) {
   /delay 10 
   /sit
   /echo Camping to desktop.
   /delay 10 
   /camp desktop 
   /endmacro
  }

|Tell Notification - Untested

  /If (${intTell}>=1) {
   /beep 
   /delay 10
   /beep
   /delay 40
  }

|Camp check response - Untested

  /If (${intCampCheck}>=1) {
   /beep
   /delay 4s
   /beep
   /ooc I'm kiting ${Cchk}
   /varset intCampCheck 0
  }

|Health Monitoring - Broken

  /If (${intCampCheck}>=1) {
   /twist 8 12
   /echo Healing to ${Me.MaxHPs} hitpoints.
   /delay ${Math.Calc[${[${Math.Calc[${Math.Calc[${Me.MaxHPs}-${Me.CurrentHPs}]}/100]}*6.02]}
   /twist 4 5 6 7 8 11
   /varset intHPChk 0
  }

 /goto :Main

|---------------------------Events---------------------------|

Sub Event_NeedTarget 
  /varset intNeedTarget ${Math.Calc[${intNeedTarget}+1]}
/return 

Sub Event_OutofRange
  /varset intOOR ${Math.Calc[${intOOR}+1]}
/return

Sub Event_Died 
  /varset intDied ${Math.Calc[${intDied}+1]}
/return 

Sub Event_Tell 
  /varset intTell ${Math.Calc[${intTell}+1]}
/return 

Sub Event_CampCheck
  /If (${Cchk.Length}>1) {
   /varset intCampCheck ${Math.Calc[${intCampCheck}+1]}
  }
/return

Sub Event_HPChk
  /If (${Me.PctHPs}<${intMinHPs}) {
   /varset intHPChk ${Math.Calc[${intCampCheck}+1]}
  }
/return
As always, feedback is appreciated.

Inu

**EDIT**

After I posted, I noticed the difference in the declaration:

/declare intMinHPS int outer

and usage:

/If (${Me.CurrentHPs}<${MinHPs}) {

which I have since changed in the above code block. I'll test it manana and post back.

Inu

User avatar
Fuergrissa
a grimling bloodguard
a grimling bloodguard
Posts: 607
Joined: Mon Dec 08, 2003 3:46 pm
Location: UK

Post by Fuergrissa » Wed Jun 23, 2004 6:59 am

why not use a check to see if your already singing and then if not /twist

Code: Select all

/if (${Me.Casting.ID})
[quote]"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."[/quote]

dok
a ghoul
a ghoul
Posts: 127
Joined: Mon Mar 15, 2004 3:38 pm

Post by dok » Wed Jun 23, 2004 12:34 pm

my example wouldn't call the /twist command every loop.

checks if you're currently healing. if you are, it checks your hps to see if they are > MinHPs. If that passes, it sets healing == FALSE and plays your normal /twist.

now if healing == FALSE, it checks to see if your hps drop below MinHPs, if it does, it sets healing == TRUE, and plays your healing set.

if either of the HP checks fail (no change in singing required), it should just skip the /twist commands all together.

I left the loops broken up like I did so it'd be easier for you to read, but in reality, you should change it to be...

/if (${healing}&&${Me.PctHPs}>${MinHPs}) {
etc.

Your loop is doing quite a lot of wasted comparisons. it works, yes. but theres absolutly no reason to have all those extra declared variables and all those checks in your main loop. the /doevents routine covers what you're attempting to do manually.


These 2 examples are exactly the same result, yet in the long run, mine will end up running faster and taking less memory, and in 6 months when you decide to make a change... mine will be 10x easier to do so.

Code: Select all

#event myevent "testing"
Sub Main
  /declare varname int outer 0
  :loop
    /doevents
    /if (${varname}>0) {
      /echo triggered
      /varset varname 0
    }
  /goto :loop
/endmac

Sub Event_myevent
  /varset varname 1
/return

Code: Select all

#event myevent "testing"
Sub Main
  :loop
    /doevents
  /goto :loop
/endmac

Sub Event_myevent
  /echo triggered
/return

Inusien
Contributing Member
Contributing Member
Posts: 4
Joined: Tue Mar 16, 2004 1:12 am

Post by Inusien » Wed Jun 23, 2004 3:01 pm

And your healing works too! Thanks for both of your assistance. Quick question on this line:

Code: Select all

/if ($healing})
Does this check to see if healing is true, and if it is, the if statement passes?

Also added some of the /ooc checks, and the out of range check to dok's macro, and it works like a charm:

Code: Select all

| Target.mac 
| 

#event NeedTarget "You must first select a target for this spell!" 
#event OutofRange "Your target is out of range, get closer!"
#event Died "You have entered#*#" 
#event Tell "#*#tells you#*#" 
#event CampCheck "#*#Camp Check#*#" 
#event HPChk "#*#YOU for#*#" 

Sub Main(string Cchk) 

 /If (${Cchk.Length}>1) {
  /echo Responding to /ooc Camp check with ${Cchk}.
 } else {
  /echo An /ooc Camp Check response was not declared. A response of ${Cchk} will not be provided.
 }

|------------------Declare & Set Variables-------------------| 

/declare MinHPs int outer 90 

/declare healing string outer FALSE 

|----------------------NeverEnding Loop----------------------| 

:Main 
    /if (${healing}) { 
        /If (${Me.PctHPs}>${MinHPs}) { 
            /varset healing FALSE 
            /twist 4 5 6 7 8 11 
        } 
    } else { 
        /If (${Me.PctHPs}<=${MinHPs}) { 
            /varset healing TRUE 
            /twist 8 12 
            /echo HEALING.... 
        } 
    } 

   /doevents 
   /delay 1 
/goto :Main 

/endmac  


|---------------------------Events---------------------------| 

Sub Event_NeedTarget 
  /keypress F8 
  /echo Kiting ${Target.CleanName}  
/return 

Sub Event_OutofRange
  /keypress F8 
  /echo Kiting ${Target.CleanName}
/return

Sub Event_Died 
  /delay 10 
  /sit 
  /echo Camping to desktop. 
  /delay 10 
  /camp desktop 
  /endmacro 
/return 

Sub Event_Tell 
  /beep 
  /delay 10 
  /beep 
  /delay 40 
/return 

Sub Event_CampCheck 
  /If (${Cchk.Length}>1) {
   /beep 
   /delay 4s 
   /beep 
   /ooc I'm kiting ${Cchk}
  }
/return
Thanks,

Inu

User avatar
Fuergrissa
a grimling bloodguard
a grimling bloodguard
Posts: 607
Joined: Mon Dec 08, 2003 3:46 pm
Location: UK

Post by Fuergrissa » Wed Jun 23, 2004 5:47 pm

Inusien wrote:And your healing works too! Thanks for both of your assistance. Quick question on this line:

Code: Select all

/if ($healing})
Does this check to see if healing is true, and if it is, the if statement passes?
Yes.
[quote]"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning."[/quote]