Controlled Looping Problem?

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

Moderator: MacroQuest Developers

NewScripter
decaying skeleton
decaying skeleton
Posts: 1
Joined: Sun Jan 12, 2003 7:16 pm

Controlled Looping Problem?

Post by NewScripter » Sun Jan 12, 2003 7:19 pm

Ok, here is what I am trying to do. I dont have the greatest handle on the macro scripting quite yet, but Im learning.

Code: Select all

Sub Event_BuffGone 
:chkevent 

	/varcalc GroupMax $group(count)-1
	/varcalc BuffCounter $group(count)-1
	/for GroupMember 0 to $GroupMax 
		/if "$GroupClass"=="Warrior" /goto :Tank 
		/if "$GroupClass"=="Paladin" /goto :Caster 
		/if "$GroupClass"=="Shadow Knight" /goto :Caster 
		/if "$GroupClass"=="Bard" /goto :Caster  
		/if "$GroupClass"=="Monk" /goto :Tank 
		/if "$GroupClass"=="Rogue" /goto :Tank  
		/if "$GroupClass"=="Ranger" /goto :Caster  
		/if "$GroupClass"=="Beastlord" /goto :Caster 
		/if "$GroupClass"=="Cleric" /goto :Caster  
		/if "$GroupClass"=="Druid" /goto :Caster 
		/if "$GroupClass"=="Shaman" /goto :Caster 
		/if "$GroupClass"=="Enchanter" /goto :Caster 
		/if "$GroupClass"=="Wizard" /goto :Caster 
		/if "$GroupClass"=="Necromancer" /goto :Caster 
		/if "$GroupClass"=="Magician" /goto :Caster 
		/goto :nextmember

:Tank 
	/varsub v89 1
	/goto :nextmember 


:Caster 
	/if n $group($GroupMember)==$char(id)
		/press F1
		/varsub v89 1

	/if n $group($GroupMember)!=$char(id) /target id $group($GroupMember) 
		/varsub v89 1
		/stand 
		/delay 11 
		/face 
		/g -- Buff -- on %t
		/call SpellSub 8 35
		/sit 
		/goto :nextmember 

:nextmember  
	/if n "$BuffCounter"=="0" {
		/goto :Main

      	} else { 
		/next GroupMember 
		/goto :chkevent
		
	}
:Main
	/call Main
	/return 

Now, what I am attepting to do is build a controlled loop, based on the number of people in the group (which may not always be the same). The script is supposed to check how many people are in the group, and store that as a variable.

The script will check the groupmembers class, and if its a correct class, it will cast the buff on them, subtract one from the variable, and then move on to the next member, and do the same thing. If the player is not of the correct class, it will still subtract one from the variable, and continue on to the next member.

Once that variable is set to 0, the next time through the script, it will return to the main loop, and continue from there.


So far, I've managed to get it to do one of two things.
1. Cast the spell on itself, and return to the main loop*.
2. Never return to the main loop*, eternally cycling through groupmembers, and casting the buff on them.

Any thoughts would be appreciated, in the meantime, Im going to tinker with it some more...

~Ake


*By "main loop", I mean Sub Main :Loop