Loop issues

ACiDXiAN

Active Member
Hey all tryign to get a buff loop runnign but it seems I have somehtign really really messed up.

It look at the BuffGroupset no prolem and i knwo it worked as I have it click buff, then click again it cast the next buff so, in my horrible wisdom decided it would be better if I coudl one click it and have it run through the whole set. Well this is where my problem is now it just casts the first one over and over looping oforeever and it wont stop, even on pausing the script.

All it is essentially is a button on my script GUI that will buff the defensive target I have targetted witht he list of buffs I have set up in my buffs sections.

Code:
function BuffPlayer(string target2buff)
{
	Pawn[${target2buff}]:Target
	wait 10

	do
	{	
	variable iterator anIter
   
	setConfig.FindSet[BuffGroup]:GetSettingIterator[anIter]
	anIter:First

		if ${Me.Ability[${anIter.Key}].IsReady} && !${Me.TargetDebuff[${anIter.Key}](exists)} && !${Me.Effect[${anIter.Key}](exists)}
			{
				call DebugIt "Casting Buff: ${anIter.Key}"
				Me.Ability[${anIter.Key}]:Use
				call MeCasting
			}
			anInter:Next
	}
	while ( ${anIter.Key(exists)} )
}
I am kinda lost on why I messed it up here, or at least its look sliek it shoudl work.. the only catch is the buff list wont always be the same length so using a statci run thorugh X times woudlnt work, I thought the iterator woudl start at the first and go till there was no more and at that time stop this loop.

Any suggestion or help would be appreciated.
 
Last edited:

Amadeus

The Maestro
Staff member
I really don't use iterators; however, try moving this OUT of the loop and put it before the "do" line:
Code:
 variable iterator anIter
   
	setConfig.FindSet[BuffGroup]:GetSettingIterator[anIter]
	anIter:First
 

ACiDXiAN

Active Member
Okay tried a few variations of that and nada... it cast the fir one and locks it all up.

this however works but not loops. Thsi will make it so each time I click the buff button it goes to the next one and once the list is done it wont cast anymore.

Code:
function BuffPlayer(string Player2Buff)
{
	variable iterator anIter

	setConfig.FindSet[BuffGroup]:GetSettingIterator[anIter]
	anIter:First

	while ( ${anIter.Key(exists)} )
	{
		if ${Me.Ability[${anIter.Key}].IsReady} && !${Me.Effect[${anIter.Key}](exists)} && ${Me.Effect[${anIter.Key}].TimeRemaining} <= 60
		{
			Pawn[${Player2Buff}]:Target
			Me.Ability[${anIter.Key}]:Use
			call DebugIt "Casting Buff: ${Me.Ability[${anIter.Key}]}"
			call MeCasting
			wait 5
		}
		anIter:Next
	}
}
now if I coudl just get it to loop instead of being on button press it woudl be perfect.
 

Zandros

Script Author: VGA
You can't check Buffs on other characters. If someone knows then please post it.

Its better to create two routines, one for constantly checking yourself, the other to call only once to force casting the spell.

What I can see is your routine does these two things:

1) Targets a player to buff
2) Compares what buffs are on you and if not then tries buffing the Target

This can create an endless loop if the targeted character is not in your party and the buff is not on you.

A possible fix is as long as you call the routine with a target:

Code:
if ${Me.Ability[${anIter.Key}].IsReady} && ((!${Me.Effect[${anIter.Key}](exists)} && ${Me.Effect[${anIter.Key}].TimeRemaining} <= 60) || !${Me.DTarget.Name.Equal[${Me.FName}]})
What this does is if the Buff is ready and the Defensive Target is not you, then it will cast the Buff. Otherwise, if the target is you then it will cast as long as the Buff is about to expire or not up.

Hope this helps or give you ideas :)
 
Top Bottom