Page 1 of 1

Can't find the cause of "flow ran into another subrouti

Posted: Wed Sep 15, 2004 9:39 pm
by sianyde
Could someone please help find the problem causing the above error? I've combed over the macro for any sub /return out of order, or bracket issues, but I must be missing it.

mage.mac

Code: Select all

#include common.mac

#define cstsNukeSpell "burst of flame"

#event March "|${sCdr}| says, 'March'"
#event Halt "|${sCdr}| says, 'Halt'"
#event Park "|${sCdr}| says, 'Park'"
#event Nuke "|${sCdr}| says, 'Nuke #1#'"
#event BackOff "|${sCdr}| says, 'Back Off'"
#event ManaCheck "|${sCdr}| says, 'Mana Check'"
#event Melee "|${sCdr}| says, 'Melee'"

sub Main 

/declare bMarchingFlag bool outer FALSE
/declare sCdr string outer Chon
/declare sMainAssist string outer Mehzin
/declare iParkX int outer
/declare iParkY int outer 
/declare bStopNukingFlag bool outer FALSE

	/assist off

	:MainLoop

	|if not marching and health or mana is under 90, sit down
	/if ((!${bMarchingFlag}) && ((${Me.PctMana}<90) || (${Me.PctHPs}<90)) && (!${Me.Sitting})) /sit
	/doevents

	/goto :MainLoop

/return

sub Event_March

               /call March

/return

sub Event_Halt

	/call Halt

/return

sub Event_Park

	/call Park
	/pet guard me
| line 50
/return

sub Event_ManaCheck

	/gsay ${Me.PctMana}

/return

sub Event_Nuke(Line,sType)
	
	:NukeLoop
	
	|acquire and validate the target	
	/assist ${sMainAssist}
	/delay 2
	/face fast predict
	/if ((!${Target.ID}) || (${String[${Target.Type}].NotEqual[NPC]})) {
		/gsay Invalid Target
		/return
	}
	
	|cast
	/call CastSpell(${cstsNukeSpell})
	/doevents

	|check the flag
	/if (${bStopNukingFlag) {
		/varset bStopNukingFlag FALSE
		/return
	}

	|if mana is low, sit
	/if (${Macro.Return}==1) /sit

	/goto :NukeLoop

/return	

sub Event_BackOff
	
	|/pet back off
	/varset bStopNukingFlag TRUE

/return

sub Event_Melee

	| acquire and validate the target	
	/assist ${sMainAssist}
|line 100
	/delay 2
	/face fast predict
	/if ((!${Target.ID} || (${String[Target.Type].NotEqual[NPC])) {
		/gsay Invalid Target
		/return
	}

	|send in the pet
	/pet attack

/return
common.mac

Code: Select all

sub March

	/target ${sCdr}
	/delay 2
	/follow
	/varset bMarchingFlag TRUE
	/echo common found

/return

sub Halt

	/keypress back hold
	/delay 2
	/keypress back

	/varset iParkX ${Me.X}
	/varset iParkY ${Me.Y}
	/varset bMarchingFlag FALSE

/return

sub BrokenFollow

	/gsay Hold up I'm stuck
	/varset bMarchingFlag FALSE
	
/return

Sub Park
	
	:AmIThere
	/if (${Math.Distance[y,x:${iParkY},${iParkX}]}>5) {
		/stand 
		/face fast look loc iParkY,iParkX
		/keypress forward
		/doevents
		/goto :AmIThere
	}
	
/return

sub CastSpell(string sThisSpell)
	|returns 1:not enuff mana, 2: didn't take hold, 3:too many resists

	/declare iResistCount int	

	|verify Mana
	:Verifymana
	/if (${Me.Mana}<${Spell[${sThisSpell}].Mana}) {
		/gsay Insufficient Mana to cast ${sThisSpell}
		/return 1
	}

	|verify target
		/if ((!${Target.ID}) || (${String[Target.Type].NotEqual[NPC])) {
			/echo Invalid Target
			/return
		}
		
	|verify range to target
	:VerifyRangeToTarget
	/if (${Me.TargetMaxRangeTo}>${Spell[${sThisSpell}].Range}) {
		
		|Get closer
		/stand
		/face fast predict
		/keypress forward 
		/doevents
		/goto :VerifyRangeToTarget
	}
	
	|cast
	/cast sThisSpell
	/delay ${Spell[${sThisSpell}].MyCastTime}
	/doevents
	/if (${String[${Window[ChatWindow].Text}].Equal[Your spell fizzles!]}) /goto :VerifyMana
	/if (${String[${Window[ChatWindow].Text}].Equal[Your spell did not take hold]}) /return 2
	/if (${String[${Window[ChatWindow].Text}].Equal[Your target resisted the]}) {
		/varset iResistCount ${Math.Calc[${iResistCount} + 1]}
		/if (${iResistCount}==3) {
			/gsay ${Target.Name} resisted ${sThisSpell} 3 times... aborting
			/return 3
		}
		/gsay ${Target.Name} resisted ${sThisSpell}... recasting
		/goto :VerifyMana
	}
/return 0

Posted: Wed Sep 15, 2004 10:04 pm
by Night Hawk
I believe your problem lies here:

Code: Select all

   |check the flag 
   /if (${bStopNukingFlag) { 
      /varset bStopNukingFlag FALSE 
      /return 
   } 
:cool:

Posted: Wed Sep 15, 2004 10:13 pm
by sianyde
Night Hawk wrote:I believe your problem lies here:

Code: Select all

   |check the flag 
   /if (${bStopNukingFlag) { 
      /varset bStopNukingFlag FALSE 
      /return 
   } 
:cool:
That was one, but there must be more. I fixed that, and still get the same error when trying to call >any< sub from either file. :evil:

Edit: I also found two instances of this:

Code: Select all

/if ((!${Target.ID}) || (${String[Target.Type].NotEqual[NPC]))
I rechecked all the other /if statements... still can't find it

Posted: Wed Sep 15, 2004 11:06 pm
by TheAFKBard
I had his happening last night. It was due to a typo in my /goto :loop line. Basically, the script execution dropped out of the bottom os sub main into the other subs. Perhaps you have a condition that isn't being met and causing a /return to not be seen, thus dropping you into the next sub.

Posted: Wed Sep 15, 2004 11:15 pm
by Cr4zyb4rd
You're doing /doevents from inside of events, and inside of subs called by events.

Posted: Wed Sep 15, 2004 11:30 pm
by sianyde
Cr4zyb4rd wrote:You're doing /doevents from inside of events, and inside of subs called by events.
I've done that before without issue, though.

Posted: Wed Sep 15, 2004 11:54 pm
by Cr4zyb4rd
Well, it matches up with the error that you're getting...you're in sub DoStuff when you decide to check events which just happens to call DoThings which calls DoStuff, which checks events...

Even if it's not what's causing your error, it's still bad practice.

Posted: Wed Sep 15, 2004 11:59 pm
by sianyde
Cr4zyb4rd wrote:Well, it matches up with the error that you're getting...you're in sub DoStuff when you decide to check events which just happens to call DoThings which calls DoStuff, which checks events...

Even if it's not what's causing your error, it's still bad practice.
True, I can see how it is bad practice. It could cause endless recursion.

Posted: Thu Sep 16, 2004 12:48 am
by Night Hawk
Cr4zyb4rd wrote:Well, it matches up with the error that you're getting...you're in sub DoStuff when you decide to check events which just happens to call DoThings which calls DoStuff, which checks events...

Even if it's not what's causing your error, it's still bad practice.
THAT's what's wrong with one of my macros. Thanx for pointing that out. I never thought about that happening, hehe.

Posted: Thu Sep 16, 2004 9:37 pm
by sianyde
The error has been solved.

The incorrect bracketing was the actual error.

The reason the macro wouldn't work is that, instead of testing it by having the main character issue the commands, I was trying to test the subs by running the macro on the slave char, and typing /call.

Now, I've left the /doevents in the subs, and am issuing commands from the main, and the macro is functioning.

Thanks all who gave their insights.