My favorite Archery macro, gone! :(

For questions regarding conversion of scripts from the old, parm style to the new MQ2Data format. Conversion questions only!

Moderator: MacroQuest Developers

Scary_Penguin
a lesser mummy
a lesser mummy
Posts: 76
Joined: Sun Nov 16, 2003 11:45 am

My favorite Archery macro, gone! :(

Post by Scary_Penguin » Tue Jun 22, 2004 12:26 am

I have tried and tried to convert this macro to the new format but I just have not had the time to re-learn all of the things that MQ2Data changed. I am sure I am probably missing simple things here and there, but I will give you the code that I have so far, and maybe someone can convert it correctly or at least give me pointers (Its very short)

Thanks!

Code: Select all

Sub Main
/echo Simple Auto-Archery macro with DCOS Support, 1 for On, 0 for Off.

/declare CloakToggle global


/varset CloakToggle == "@Param0"

     /if (n @CloakToggle == 1) {
          /echo **Auto-Haste with DCOS is ON**
     }    /else {
          /echo **Auto-Haste with DCOS is OFF**
     }
     
     /goto :ArchLoop

     :ArchLoop
          /if ((${Me.Casting.ID} <= 0) && (${String[${Target.Type}].Equal[NPC]}) && (!${Me.Combat})) {
               /keypress ranged
	       /delay 0.5s
	       //if (@CloakToggle == 1 && $!{Me.Buff[Haste]}) /call Cloak
	       /else
	  {
          /else /goto :ArchLoop
End Sub

Sub Cloak

     /if (${Me.Casting.ID} > 0) /goto :WaitLoop
     /else /cast Item "Dark Cloak of the Sky"

     :WaitLoop
	/delay 0.5s
	/call Sub Cloak
/return
Scary:.

No, Really.

Oid
a snow griffon
a snow griffon
Posts: 416
Joined: Thu Oct 17, 2002 3:26 am
Contact:

Post by Oid » Tue Jun 22, 2004 12:59 am

Code: Select all

Sub Main 
/echo Simple Auto-Archery macro with DCOS Support, 1 for On, 0 for Off. 

/declare CloakToggle global 


/varset CloakToggle ${Param0}

     /if (${CloakToggle}== 1) { 
          /echo **Auto-Haste with DCOS is ON** 
     }    /else { 
          /echo **Auto-Haste with DCOS is OFF** 
     } 
      
     /goto :ArchLoop 

     :ArchLoop 
          /if ((${Me.Casting.ID} <= 0) && (${String[${Target.Type}].Equal[NPC]}) && (!${Me.Combat})) { 
               /keypress ranged 
          /delay 5 
          /if ((${CloakToggle}==1}) && (!${Me.Buff[Haste]})) /call Cloak 
          /else 
     { 
          /else /goto :ArchLoop 
End Sub 

Sub Cloak 

     /if (${Me.Casting.ID} > 0) /goto :WaitLoop 
     /else /cast Item "Dark Cloak of the Sky" 

     :WaitLoop 
   /delay 5 
   /call Sub Cloak 
/return
Sure why not, untested, cleaned up a little last few mq2data errors fixed, good luck.
Smokey the Lax says only you can prevent reproduction.

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Tue Jun 22, 2004 5:13 am

The line in red needs to be removed..

Code: Select all

Sub Main 
/echo Simple Auto-Archery macro with DCOS Support, 1 for On, 0 for Off. 

/declare CloakToggle global 


/varset CloakToggle ${Param0} 

     /if (${CloakToggle}== 1) { 
          /echo **Auto-Haste with DCOS is ON** 
     }    /else { 
          /echo **Auto-Haste with DCOS is OFF** 
     } 
      
     /goto :ArchLoop 

     :ArchLoop 
          /if ((${Me.Casting.ID} <= 0) && (${String[${Target.Type}].Equal[NPC]}) && (!${Me.Combat})) { 
               /keypress ranged 
          /delay 5 
          /if ((${CloakToggle}==1}) && (!${Me.Buff[Haste]})) /call Cloak 
          /else 
     { 
          /else /goto :ArchLoop 
End Sub 

Sub Cloak 

     /if (${Me.Casting.ID} > 0) /goto :WaitLoop 
     /else /cast Item "Dark Cloak of the Sky" 

     :WaitLoop 
   /delay 5 
   [color=red]/call Sub Cloak [/color]
/return 

s16z
a ghoul
a ghoul
Posts: 97
Joined: Thu Apr 01, 2004 12:03 pm

Post by s16z » Tue Jun 22, 2004 7:42 am

Also, every /else should be just else

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Tue Jun 22, 2004 10:06 am

Ok try this. Fixed a few things that Oid must've overlooked. Cleaned some other stuff up. Untested so I might have missed something too.

Changes I made (from Oid's):
changed the declaration of CloakToggle. Set type to int and scope to outer instead of global (outer is global to the macro, global is accessible outside the macro too).

ArchLoop stuff. Removed the first /goto :ArchLoop since the label is the next line making the /goto do nothing. Removed the unused else and fixed two open braces. Added the check if you are casting a spell to the cloak/haste /if (since you have a delay of 5 before it, you could very well start casting in that time).

General. Changed pretty much every condition in /if statements to not use ==XX. That was not needed, if the variable is null or zero it will evaluate to false.

Sub Cloak. Rearranged a few lines. Changed the /call Cloak to /goto. Calling the sub from itself lots of times is bound to lead to stack overflow problems. In the version you posted it would call itself infinitely until you crash.

Code: Select all

Sub Main 
/echo Simple Auto-Archery macro with DCOS Support, 1 for On, 0 for Off. 

/declare CloakToggle int outer


/varset CloakToggle ${Param0} 

     /if (${CloakToggle}) { 
          /echo **Auto-Haste with DCOS is ON** 
     } else { 
          /echo **Auto-Haste with DCOS is OFF** 
     }
      
     :ArchLoop 
          /if ((!${Me.Casting.ID}) && (${String[${Target.Type}].Equal[NPC]}) && (!${Me.Combat})) { 
              /keypress ranged 
          		/delay 5 
          		/if ((!${Me.Casting.ID}) && (${CloakToggle}}) && (!${Me.Buff[Haste]})) /call Cloak 
					}
			/goto :ArchLoop
End Sub 

Sub Cloak 
     :WaitLoop 
     /if (${Me.Casting.ID}) {
			  /delay 5 
     		/goto :WaitLoop 
     } else {
     		/cast Item "Dark Cloak of the Sky"
     }
/return 


Scary_Penguin
a lesser mummy
a lesser mummy
Posts: 76
Joined: Sun Nov 16, 2003 11:45 am

Post by Scary_Penguin » Tue Jun 22, 2004 9:20 pm

Thanks :) If I can manage to get MQ Compiled right again, Ill give it a try.
Scary:.

No, Really.

Scary_Penguin
a lesser mummy
a lesser mummy
Posts: 76
Joined: Sun Nov 16, 2003 11:45 am

Post by Scary_Penguin » Thu Jun 24, 2004 10:16 pm

The check for the buff that was in from blueninja didnt parse because && is for numerical comparisons and that var only returned the spell name if it was present. Now it checks to see if it has a value (1-15 depending on which buff slot it is in) and if it is < 0 (i.e NULL) it casts the cloak. Got rid of the already casting check since it is an instant cast spell and chain clicking something does not spam me if the spell cannot be cast. Cut timers down since it is only an 18 second buff, two 5 second pauses is too long.

Thanks for all the help, works great now!

Code: Select all

Sub Main 
/echo Simple Auto-Archery macro with DCOS Support, 1 for On, 0 for Off. 

/declare CloakToggle int outer 


/varset CloakToggle ${Param0} 

     /if (${CloakToggle}) { 
          /echo **Auto-Haste with DCOS is ON** 
     } else { 
          /echo **Auto-Haste with DCOS is OFF** 
     } 
      
     :ArchLoop 
          /if ((!${Me.Casting.ID}) && (${String[${Target.Type}].Equal[NPC]}) && (!${Me.Combat})) { 
              /keypress ranged 
                /delay 1 
                /if (((${CloakToggle}) == 1) && ((${Me.Buff[Haste].ID}) < 0)) /call Cloak 
               } 
         /goto :ArchLoop 
End Sub 

Sub Cloak 
     :WaitLoop 
     /if (${Me.Casting.ID}) { 
           /delay 1 
           /goto :WaitLoop 
     } else { 
           /cast Item "Dark Cloak of the Sky" 
     } 
/return
Scary:.

No, Really.