How come only one event is working in this script?

Help section from before the user variable changes that broke all macros

Moderator: MacroQuest Developers

merkzu
a ghoul
a ghoul
Posts: 99
Joined: Wed May 14, 2003 2:08 pm

How come only one event is working in this script?

Post by merkzu » Tue Aug 12, 2003 11:35 pm

For some reason only the "attacked" event works. None of the others do. Is there something wrong with the "Fighting" Sub (where the events would occur), the #event tags themselves, or the event subs? I can't figure it out. All of the events that dont work are spell messages.

Code: Select all

#include spellsub.inc

#event aebolt "Your Envenomed Bolt spell has worn off."
#event avos "Your Venom of the Snake spell has worn off."
#event aroot "Your Immobilize spell has worn off."
#event aslow "Your Turgur's Insects spell has worn off."
#event ahaste "Your pet's Alacrity spell has worn off."
#event attacked "YOU for"

#define fighting v1
#define ebolt v2
#define vos v3
#define root v4
#define slow v5
#define haste v6

Sub Main
  /zapvars
  :mainloop
    /varset ebolt 0
    /varset vos 0
    /varset root 0
    /varset slow 0
    /call Downtime
    /call Fighting
    /goto :mainloop
/return

Sub Downtime
  /sit off
  /sit on
  :downloop
  /doevents
  /if n $fighting==1 /return
  /if $char(buff,"Chloroplast")==0 {
    /sit off
    /target myself
    /call SpellSub "Chloroplast"
    /sit on
    /press Esc
    /goto :downloop
  }
  /if $char(buff,"Talisman of Altuna")==0 {
    /sit off
    /target myself
    /call SpellSub "Talisman of Altuna"
    /sit on
    /press Esc
    /goto :downloop
  }
  /if $char(buff,"Alacrity")==0 {
    /sit off
    /target myself
    /call SpellSub "Alacrity"
    /sit on
    /press Esc
    /goto :downloop
  }
  /if n $haste==0 {
    /sit off
    /target myself
    /press F1
    /call SpellSub "Alacrity"
    /varset haste 1
    /sit on
    /press Esc
    /goto :downloop
  }
  /goto :downloop
/return

Sub Fighting
  /press F8
  /press F8
  /press `
  :fightloop
  /doevents
  /if $target(id)==0 {
    /varset fighting 0
    /return
  }
  /face fast nopredict
  /if n $char(hp,pct)<65 /if n $char(buff,"Stoicism")==0 {
    /press Tab
    /call SpellSub Stoicism
    /press Tab
    /goto :fightloop
  }
  /if n $slow==0 {
    /call SpellSub "Turgur's Insects"
    /varset slow 1
    /goto :fightloop
  }
  /if n $vos==0 {
    /call SpellSub "Venom of the Snake"
    /varset vos 1
    /goto :fightloop
  }
  /if n $ebolt==0 {
    /call SpellSub "Envenomed Bolt"
    /varset ebolt 1
    /goto :fightloop
  }
  /if n $target(distance)>20 /if n $root==0 {
    /call SpellSub "Immobilize"
    /varset root 1
    /goto :fightloop
  }
  /goto :fightloop
/return

Sub Event_attacked
  /varset fighting 1
/return

Sub Event_aslow
  /echo slow expired
  /varset slow 0
/return

Sub Event_aebolt
  /echo ebolt expired
  /varset ebolt 0
/return

Sub Event_avos
  /echo vos expired
  /varset vos 0
/return

Sub Event_aroot
  /echo root expired
  /varset root 0
/return

Sub Event_ahaste
  /varset haste 0
/return

YKW-28983
a hill giant
a hill giant
Posts: 252
Joined: Sun Dec 01, 2002 11:37 pm

Post by YKW-28983 » Wed Aug 13, 2003 12:53 am

Try putting /doevents in your checks for the spells themselves..

Code: Select all

/if n $slow==0 { 
    /doevents
    /call SpellSub "Turgur's Insects" 
    /varset slow 1 
    /goto :fightloop 
  } 
I found that to help with my shammy macro.

Shin Noir
a ghoul
a ghoul
Posts: 90
Joined: Tue Aug 05, 2003 8:18 pm

Post by Shin Noir » Fri Aug 15, 2003 8:00 am

I don't know the entirety of this script, but some common problems I have had with events not catching is...

1) BE SURE the event matches the actual one word to word. Capitlization, Lower case, every thing identical.

2) Ensure that you are giving the program time to call outside events.

Code: Select all

Sub Main 
  /zapvars 
  :mainloop 
    /varset ebolt 0 
    /varset vos 0 
    /varset root 0 
    /varset slow 0 
    /call Downtime 
    /call Fighting
    [b]/doevents[/b] |<-- will allow a gap in loop to do other stuff.
    /goto :mainloop 
/return 
Bah, I'm bored. Here maybe try this..

Mainly I made everything into one big loop, less code to process every single turn.. Easier to read too right?

Tell me if it works (Never got to test it.)

Code: Select all

#include spellsub.inc 

|#turbo |I don't know if spellsub has preset delays.. if it does turbo should work

#event aebolt "Your Envenomed Bolt spell has worn off." 
#event avos "Your Venom of the Snake spell has worn off." 
#event aroot "Your Immobilize spell has worn off." 
#event aslow "Your Turgur's Insects spell has worn off." 
#event ahaste "Your pet's Alacrity spell has worn off." 
#event attacked "YOU for" 

#define fighting v1 
#define ebolt v2 
#define vos v3 
#define root v4 
#define slow v5 
#define haste v6 

|Variable Sets
|
|
|

Sub Main 
    /varset ebolt 0 
    /varset vos 0 
    /varset root 0 
    /varset slow 0 
    /varset fighting 0

  :mainloop
   /if $fighting==1 {
    /call Fighting 
   } else {
    /call Downtime 
   }
    /doevents
    /goto :mainloop 

/return 

|Time to rest. Sleepy.
Sub Downtime 
 /if $char(state)=="STAND" /sit on
  /doevents  
  /if $char(buff,"Chloroplast")==0 { 
    /sit off 
    /doevents
    /target myself 
    /call SpellSub "Chloroplast" 
    /sit on 
    /press Esc 
  } 
  /if $char(buff,"Talisman of Altuna")==0 { 
    /sit off
    /doevents 
    /target myself 
    /call SpellSub "Talisman of Altuna" 
    /sit on 
    /press Esc 
  } 
  /if $char(buff,"Alacrity")==0 { 
    /sit off 
    /doevents
    /target myself 
    /call SpellSub "Alacrity" 
    /sit on 
    /press Esc 
  } 
  /if n $haste==0 { 
    /sit off 
    /doevents
    /target myself 
    /press F1 
    /call SpellSub "Alacrity" 
    /varset haste 1 
    /sit on 
    /press Esc 
  } 
/return 

Sub Fighting 
 |/press F8  |if you just got smacked chances are you'll have em targetted
 |/press F8 
  /press `  |What's this for?

  /if $target(id)==0 {
  /varset fighting 0 
  } else {
  /face fast nopredict 
  /if n $char(hp,pct)<65 /if n $char(buff,"Stoicism")==0 { 
    /press Tab 
    /call SpellSub Stoicism 
    /press Tab 
  } 
  /if n $slow==0 { 
    /call SpellSub "Turgur's Insects" 
    /varset slow 1 
  } 
  /if n $vos==0 { 
    /call SpellSub "Venom of the Snake" 
    /varset vos 1 
  } 
  /if n $ebolt==0 { 
    /call SpellSub "Envenomed Bolt" 
    /varset ebolt 1 
  } 
  /if n $target(distance)>20 /if n $root==0 { 
    /call SpellSub "Immobilize" 
    /varset root 1 
  } 
 /doevents
/return 

Sub Event_attacked 
  /varset fighting 1 
/return 

Sub Event_aslow 
  /echo slow expired 
  /varset slow 0 
/return 

Sub Event_aebolt 
  /echo ebolt expired 
  /varset ebolt 0 
/return 

Sub Event_avos 
  /echo vos expired 
  /varset vos 0 
/return 

Sub Event_aroot 
  /echo root expired 
  /varset root 0 
/return 

Sub Event_ahaste 
  /varset haste 0 
/return