Question about Sub_Event . . .

Need some help with that macro you're working on or aren't quite sure how to get your macro to do something? Ask here!

Moderator: MacroQuest Developers

User avatar
a_troll_01
a lesser mummy
a lesser mummy
Posts: 46
Joined: Sat Dec 06, 2003 6:06 am
Location: Memphis, TN
Contact:

Question about Sub_Event . . .

Post by a_troll_01 » Wed Dec 17, 2003 7:27 am

This is a Sub-section of my personal "Hunting.mac" ... It's called to when I'm at 35% health (a check that's run before aquiring a new target). The point is to stop hunting, Hide myself, if I fail to hide, keep trying until it works, Bind Wound to 48% health, sit down and regen up to 100 percent, then resume the hunt:

Code: Select all


#turbo
#event HideFail "You failed to hide yourself."
#event HideSuccess "You have hidden yourself from view."
~~~~

Sub Rest

   /doability "Hide" | Obviously, attempt to Hide.
   /delay 2s |Delay to allow the Hide chat-window text to pop up for /doevent
   /doevents | Run check on result of attempted Hide and act accordingly

   /press ` | Target myself (I use ` instead of the customary F1 key)
   /delay 1s | Wait a second to make sure I am targetted around lag.
   :BindWound
   /doability "Bind Wound" | Obviously, attempt to Bind Wound
   /delay 2.5s | I was too lazy to make anything fancy, so I just dropped in a delay
   /if n $char(hp,pct)>="48" /goto :Rest | If I'm at 48% health, stop and move on to Rest.
   /if n $char(hp,pct)<="48" /goto :BindWound | If I'm still under 48% health, keep Binding Wounds.
   
   :Rest
   /delay 8s | Delay in place to make sure Bind Wound cleans up, otherwise the message "You have moved and your attempt to bandage has failed" flashes and the /sit command below is skipped, and I stay standing.
   /sit | Sit down
   /press esc | Make sure I have nothing targetted
   /press esc
   /press esc

   :Healthcheck
   /if n $target(id)!=0 /return | In case I somehow get agro'ed while sitting, I'll hop up and take care of it.
   /if $target()!="NULL" /return | See above.

   /if n $char(hp,pct)=="100" { | Check health status
      /sit off | If I'm at 100 percent health, hop up, and resume the hunt
      /return
   } else {
      /delay 8s  | Delay 8 seconds per HealthCheck
      /goto :HealthCheck
   {
/return

Sub Event_HideFail
   /doability "Hide"
   /delay 9s
   /call Main
/return

Sub Event_HideSuccess
   /return

What I can't get functioning is mainly the Sub_Events ... sometimes I get stuck in everlasting Hide loops ... for every Hide I fail, I have to have 1 successful hide to make up for. So, if I fail Hide 3 times, the script won't get back to normal until 3 successful Hides are accomplished right after. Now, that's not really a problem. I can look at the code, and see why that's happening. But I'm not sure how to work around it, and I was hoping someone would have a better idea. I've kind'a just 'patched' the Sub_Events together to be semi-functional. The rest (Bind wound, Rest, etc) works great. I just can't get past the Hide part flawlessly in all cases. Any ideas or feedback would be greatly appreciated.
-- a_troll_01

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Post by wassup » Wed Dec 17, 2003 10:01 am

1. Where is Sub Main?
2. Using /return without having a /call?
3. You can use /doevents HideFail. No reason for HideSuccess if you do nothing in it
4. I highlighted some things in red, and also pointed some things out in your macro.

Code: Select all

#turbo 
#event HideFail "You failed to hide yourself." 
#event HideSuccess "You have hidden yourself from view." 

[color=red]Sub Rest[/color]
   | Obviously, attempt to Hide. 
   /doability "Hide"
   |Delay to allow the Hide chat-window text to pop up for /doevent 
   /delay 2s
   | Run check on result of attempted Hide and act accordingly 
   /doevents [color=red]HideFail[/color]  <--- You can use /doevents with a specific event
   | Target myself (I use ` instead of the customary F1 key) 
   [color=red]/target myself[/color]  <--- Better way of targetting yourself
   | Wait a second to make sure I am targetted around lag. 
   /delay 1s 
   :BindWound
   | Obviously, attempt to Bind Wound  
   /doability "Bind Wound"
   | I was too lazy to make anything fancy, so I just dropped in a delay 
   /delay 2.5s
   | If I'm at 48% health, stop and move on to Rest. 
   /if n $char(hp,pct)>="48" /goto :Rest
   | If I'm still under 48% health, keep Binding Wounds.  
   /if n $char(hp,pct)<="48" /goto :BindWound 
    
   :Rest
   | Delay in place to make sure Bind Wound cleans up, otherwise the message 
   | "You have moved and your attempt to bandage has failed" flashes and the /sit
   | command below is skipped, and I stay standing. 
   /delay 8s
   /sit
   | Make sure I have nothing targetted 
   /press esc 
   /press esc 
   /press esc 

   :Healthcheck
   | In case I somehow get agro'ed while sitting, I'll hop up and take care of it. 
   /if n $target(id)!=0 /return  <----- Return to where? I think you want a /goto
   | See above. 
   /if $target()!="NULL" /return  <----- Return to where? I think you want a /goto
   | Check health status 
   /if n $char(hp,pct)=="100" {
      | If I'm at 100 percent health, hop up, and resume the hunt
      /sit off  
      /return  <----- Return to where? I think you want a /goto
   } else { 
      /delay 8s  | Delay 8 seconds per HealthCheck 
      /goto :HealthCheck 
   { 
/return 

Sub Event_HideFail 
   /doability "Hide" 
   /delay 9s 
   /call Main  <----- Where is Sub Main? And why call Main when it will return to the line after the call when /return is done
/return 

Sub Event_HideSuccess <--- If this does nothing, why have it?
/return
[/code]

User avatar
a_troll_01
a lesser mummy
a lesser mummy
Posts: 46
Joined: Sat Dec 06, 2003 6:06 am
Location: Memphis, TN
Contact:

Post by a_troll_01 » Wed Dec 17, 2003 4:29 pm

Thanks, Wassup :) Much appreciated. I'm still pretty novice at this, but learning fast.
-- a_troll_01