Need help with a macro you are writing? Ask here!
Moderator: MacroQuest Developers
-
weezurd
- orc pawn

- Posts: 19
- Joined: Sat Jan 08, 2005 1:38 am
Post
by weezurd » Sun Jan 16, 2005 11:11 pm
ieatacid wrote:Code: Select all
/for Counter 0 to (${QueueSize}-1)
I never tried parentheses in /for loops, but if that doesn't work
Code: Select all
/for Counter 0 to ${Math.Calc[${QueueSize}-1]}
should.
I tried (${QueueSize}-1) and that did not work so i went ahead and tried the math.calc way and that doesnt work either.
i also added the decrementing
code:
Code: Select all
#event Hailed "#1# says, 'Hail, <Your-Name-Here>'"
Sub Main
/echo Raid TL Macro has now started..
/declare transspell string outer
/declare RequestorID int outer
/declare spellgem int outer 9
/declare QueueMaxSize int outer
/declare QueueSize int outer
/declare Num int local 0
/varset QueueMaxSize 10
/varset QueueSize 0
/declare QueueArray[${QueueMaxSize}] string outer
/if (!${Defined[Param0]}) {
/echo Error, You must specify the translocate spell you wish to use.
/echo Syntax: /mac tl Natimbi
/end
} else {
/echo You have chosen to use: Translocate: ${Param0}
/varset transspell Translocate: ${Param0}
/if (!${Me.SpellReady["${transspell}"]}) {
/echo Now meming ${transspell}
/memspell ${spellgem} "${transspell}"
}
}
:loop
/doevents
/delay 2s
/if (${QueueSize}>0) /call DeQueue
/goto :loop
Sub Event_Hailed(string line,string RequestorName)
/varset RequestorID ${Spawn[pc ${RequestorName}].ID}
/squelch /target id ${RequestorID}
/delay 1s ${Target.ID}==${RequestorID}
/echo Adding ${RequestorName} to translocation queue
/call EnQueue ${RequestorName}
/return
Sub Trans(string PersonToTrans)
/if (${Me.SpellReady["${transspell}"]}) {
/if (${FindItemCount[Small Portal Fragments]}>0) {
/echo Now translocating: ${PersonToTrans}
/call cast "${transspell}" ${spellgem} 1s
} else {
/echo Out of portal fragments, ending macro.
/end
}
}
/return
Sub EnQueue(string Element)
/if (${QueueSize}<${QueueMaxSize}) {
/varcalc QueueSize ${QueueSize} + 1
/varset QueueArray[${QueueSize}] ${Element}
/echo Successfully added ${Element} to slot ${QueueSize} of the queue
/varset QueueSize ${QueueSize}
/return 1
} else {
/echo Add to queue failed
/return NULL
}
Sub DeQueue
/declare ReturnValue string local
/declare Counter int local 0
/varset ReturnValue QueueArray[0]
/for Counter 0 to ${Math.Calc[${QueueSize}-1]}
/varset QueueArray[${Counter}] QueueArray[${Counter} + 1]
/next Counter
/varcalc ${QueueSize} (${QueueSize}-1)
/echo Retrieved: ${ReturnValue}
/if (!${Me.SpellReady["${transspell}"]}) /call Trans ${ReturnValue}
/return
still giving me error about being outbound of array for call dequeue
-
weezurd
- orc pawn

- Posts: 19
- Joined: Sat Jan 08, 2005 1:38 am
Post
by weezurd » Sun Jan 16, 2005 11:18 pm
shouldnt
and
return the chars name who hailed?
the macro is echoing "Retrieved: QueueArray[0]"
-
weezurd
- orc pawn

- Posts: 19
- Joined: Sat Jan 08, 2005 1:38 am
Post
by weezurd » Sun Jan 16, 2005 11:44 pm
weezurd wrote:shouldnt
and
return the chars name who hailed?
the macro is echoing "Retrieved: QueueArray[0]"
i changed it to /varset ReturnValue ${QueueArray[1] and it seems to work. its at least returning the name of the last person to hail.
but its still erroring as before:
/varset QueueArray[-1] failed, out of bounds for array
-
JJ
- a hill giant

- Posts: 227
- Joined: Thu Nov 11, 2004 5:50 am
Post
by JJ » Sun Jan 16, 2005 11:52 pm
Ok, you posted the ${} fix just as I did, so I removed my answer. The next part, looks like arrays start at 1.
So fix your arrays to go from 1 to whatever instead of 0.
-
weezurd
- orc pawn

- Posts: 19
- Joined: Sat Jan 08, 2005 1:38 am
Post
by weezurd » Sun Jan 16, 2005 11:54 pm
ok i figured it out. the problem its having now is not being able to add people to the queue during the translocating. so it kinda defeats the purpose of this.. is it something im doing wrong?
whats happening now is if someone hails while its translocating someone it misses them and adds the next person that hails to the queue once its done tling.
Code: Select all
#include spell_routines.inc
#event Hailed "#1# says, 'Hail, <Your-Name-Here>'"
Sub Main
/echo Raid TL Macro has now started..
/declare transspell string outer
/declare RequestorID int outer
/declare spellgem int outer 9
/declare QueueMaxSize int outer
/declare QueueSize int outer
/varset QueueMaxSize 10
/varset QueueSize 0
/declare QueueArray[${QueueMaxSize}] string outer
/if (!${Defined[Param0]}) {
/echo Error, You must specify the translocate spell you wish to use.
/echo Syntax: /mac tl Natimbi
/end
} else {
/echo You have chosen to use: Translocate: ${Param0}
/varset transspell Translocate: ${Param0}
/if (!${Me.SpellReady["${transspell}"]}) {
/echo Now meming ${transspell}
/memspell ${spellgem} "${transspell}"
}
}
:loop
/doevents
/if (${QueueSize}>0) /call DeQueue
/goto :loop
Sub Event_Hailed(string line,string RequestorName)
/varset RequestorID ${Spawn[pc ${RequestorName}].ID}
/squelch /target id ${RequestorID}
/delay 1s ${Target.ID}==${RequestorID}
/echo Adding ${RequestorName} to translocation queue
/call EnQueue ${RequestorName}
/return
Sub Trans(string PersonToTrans)
/if (${Me.SpellReady["${transspell}"]}) {
/if (${FindItemCount[Small Portal Fragments]}>0) {
/echo Now translocating: ${PersonToTrans}
/call cast "${transspell}" ${spellgem} 1s
} else {
/echo Out of portal fragments, ending macro.
/end
}
}
/return
Sub EnQueue(string Element)
/if (${QueueSize}<${QueueMaxSize}) {
/varcalc QueueSize ${QueueSize} + 1
/varset QueueArray[${QueueSize}] ${Element}
/echo Successfully added ${Element} to slot ${QueueSize} of the queue
/varset QueueSize ${QueueSize}
/return 1
} else {
/echo Add to queue failed
/return NULL
}
Sub DeQueue
/declare ReturnValue string local
/declare Counter int local 0
/if (${QueueSize}==0) /return
/varset ReturnValue ${QueueArray[1]}
/for Counter 1 to ${Math.Calc[${QueueSize}-1]}
/varset QueueArray[${Counter}] QueueArray[${Counter} + 1]
/next Counter
/echo Retrieved: ${ReturnValue}
/if (${Me.SpellReady["${transspell}"]}) {
/varset QueueSize ${Math.Calc[${QueueSize}-1]}
/call Trans ${ReturnValue}
} else {
/delay 2s
/call DeQueue
}
/return
also as you can see i added a loop in the dequeue sub that checks to make sure the spell is ready to cast and then it will remove the person from the queue and goto the next.
-
JJ
- a hill giant

- Posts: 227
- Joined: Thu Nov 11, 2004 5:50 am
Post
by JJ » Mon Jan 17, 2005 1:15 am
The reason it skips is because you're in a sub still. You're /doevents is not in the sub that you are calling(/call cast "${transspell}" etc, etc). Not sure how I can help you since you're using a .inc for your spell casting. Maybe edit the .inc so that it does /doevents during cast time but I'm not sure that will help because the events of the .inc do not include your Hailed event.
Here's what happened with my macro that I've done with my cleric while I was writing/testing still. The cleric's main sub is in a constant loop with /doevents in it. When my pet got low health, my necro would ask to heal pet. Before I fixed it, the necro would spam the /gsay with "Heal my pet!" and when I looked, the cleric kept casting supernal exlixir over and over again . . . it matched my /gsay commands like crazy. Not sure any got skipped, but the /doevents caught a ton of them, even during casting.
So basically, you need to get repetitious /doevents in wherever you can to cover times like during casting. Even if that means not using the .inc and writing your own (or copy/paste the sub(s) you're calling).
-
weezurd
- orc pawn

- Posts: 19
- Joined: Sat Jan 08, 2005 1:38 am
Post
by weezurd » Mon Jan 17, 2005 1:39 am
i changed it around a bit to try to eliminate being stuck in a sub by removing the spell_routines.inc and by using regular /cast spellname to see if it would help and it seems to take care of the not picking up of names. but im still having a problem with the dequeing it seems.
it seems like the macro doesnt know when its done tling the people in queue or something like that im not sure. it will keep looping after it tls the first person and says "Retrieved: QueueArray[1 + 1]" then after about 3 or 4 loops it will try to translocate "QueueArray[1"
am i missing something?
here is the latest code with all the recent changes:
Code: Select all
#event Hailed "#1# says, 'Hail, <Your-Name-Here>'"
Sub Main
/echo Raid TL Macro has now started..
/declare transspell string outer
/declare spellgem int outer 9
/declare RequestorID int outer
/declare QueueMaxSize int outer
/declare QueueSize int outer
/varset QueueMaxSize 10
/varset QueueSize 0
/declare QueueArray[${QueueMaxSize}] string outer
/if (!${Defined[Param0]}) {
/echo Error, You must specify the translocate spell you wish to use.
/echo Syntax: /mac tl Natimbi
/end
} else {
/echo You have chosen to use: Translocate: ${Param0}
/varset transspell Translocate: ${Param0}
/if (!${Me.SpellReady["${transspell}"]}) {
/echo Now meming ${transspell}
/memspell ${spellgem} "${transspell}"
}
}
:loop
/doevents
/if (${QueueSize}>0) /call DeQueue
/goto :loop
Sub Event_Hailed(string line,string RequestorName)
/echo Adding ${RequestorName} to translocation queue
/call EnQueue ${RequestorName}
/return
Sub Trans(string PersonToTrans)
/if (${Me.SpellReady["${transspell}"]}) {
/if (${FindItemCount[Small Portal Fragments]}>0) {
/varset RequestorID ${Spawn[pc ${RequestorName}].ID}
/squelch /target id ${RequestorID}
/delay 1s ${Target.ID}==${RequestorID}
/echo Now translocating: ${PersonToTrans}
/cast "${transspell}"
} else {
/echo Out of portal fragments, ending macro.
/end
}
}
/return
Sub EnQueue(string Element)
/if (${QueueSize}<${QueueMaxSize}) {
/varcalc QueueSize ${QueueSize} + 1
/varset QueueArray[${QueueSize}] ${Element}
/echo Successfully added ${Element} to slot ${QueueSize} of the queue
/varset QueueSize ${QueueSize}
/return 1
} else {
/echo Add to queue failed
/return NULL
}
Sub DeQueue
/declare ReturnValue string local
/declare Counter int local
/if (${QueueSize}==0) /return
/varset ReturnValue ${QueueArray[1]}
/for Counter 1 to ${Math.Calc[${QueueSize}-1]}
/varset QueueArray[${Counter}] QueueArray[${Counter} + 1]
/next Counter
/echo Retrieved: ${ReturnValue}
/if (${Me.SpellReady["${transspell}"]}) {
/varset QueueSize ${Math.Calc[${QueueSize}-1]}
/call Trans ${ReturnValue}
} else {
/delay 5s
/call DeQueue
}
/return
once i get this straightened out i will add fizzle checks and whatnot but for now i need to fix the dequeue problem
thx again
-
Zeus
- a hill giant

- Posts: 180
- Joined: Wed Feb 19, 2003 10:03 am
-
Contact:
Post
by Zeus » Mon Jan 17, 2005 3:53 am
Sorry for not answering earlier, on a screwed up schedule atm. Anyway try following this logic:
Code: Select all
MainLoop
if queuesize > 0 {
call Dequeue
call TlPerson(macro.return)
}
doevents
goto :MainLoop
Event_Hail
Enqueue Person
return
Sub TLPerson (string person)
tar person
call cast tl
return
Don't hardcode your events on enqueue or dequeue, makes it harder to pinpoint problems later. And if i remember right when an event fires more than once before a doevents they don't get lost. But been a long while since I ran into something like that so not quote me on it.
Edit: Just read your mac again, your version of dequeue is making it recurse when the spell isn't ready, which makes it lose it's first value and this
Code: Select all
/varset QueueArray[${Counter}] QueueArray[${Counter} + 1}
shoudl be
Code: Select all
/varset QueueArray[${Counter}] ${QueueArray[${Counter} + 1]}
Small fuck up on my part I guess hehe
-
weezurd
- orc pawn

- Posts: 19
- Joined: Sat Jan 08, 2005 1:38 am
Post
by weezurd » Mon Jan 17, 2005 5:27 am
thanks much Zeus.
i redid some things and as of now its not missing any hails and is adding all to the queue. but now for some reason it does not tl anyone past the second person added to the queue.
here's an example:
Adding Player1 to the translocation queue.
Successfully added Player1 to slot 1 of the queue.
Adding Player2 to the translocation queue.
Successfully added Player2 to slot 2 of the queue.
Adding Player3 to the translocation queue.
Successfully added Player3 to slot 3 of the queue.
Now translocating: Player1
Now translocating: Player2
Now translocating: Player2
seems as the queueing is working, but it translocates the second player twice rather then the third like it should.
here is the latest macro code:
Code: Select all
#event Hailed "#1# says, 'Hail, <Your-Name-Here>'"
Sub Main
/echo Raid TL Macro has now started..
/declare transspell string outer
/declare spellgem int outer 9
/declare RequestorID int outer
/declare QueueMaxSize int outer
/declare QueueSize int outer
/varset QueueMaxSize 10
/varset QueueSize 0
/declare QueueArray[${QueueMaxSize}] string outer
/if (!${Defined[Param0]}) {
/echo Error, You must specify the translocate spell you wish to use.
/echo Syntax: /mac tl Natimbi
/end
} else {
/echo You have chosen to use: Translocate: ${Param0}
/varset transspell Translocate: ${Param0}
/if (!${Me.SpellReady["${transspell}"]}) {
/echo Now meming ${transspell}
/memspell ${spellgem} "${transspell}"
}
}
:MainLoop
/if (${QueueSize}>0) {
/call DeQueue
}
/doevents
/goto :MainLoop
Sub Event_Hailed(string line,string RequestorName)
/echo Adding ${RequestorName} to translocation queue
/call EnQueue ${RequestorName}
/return
Sub Trans(string PersonToTrans)
/if (${Me.SpellReady["${transspell}"]}) {
/if (${FindItemCount[Small Portal Fragments]}>0) {
/varset RequestorID ${Spawn[pc ${PersonToTrans}].ID}
/squelch /target id ${RequestorID}
/delay 1s ${Target.ID}==${RequestorID}
/echo Now translocating: ${PersonToTrans}
/cast "${transspell}"
} else {
/tell {$PersonToTrans} sorry, out of frags.
/echo Out of portal fragments, ending macro.
/end
}
}
/return
Sub EnQueue(string Element)
/if (${QueueSize}<${QueueMaxSize}) {
/varcalc QueueSize ${QueueSize} + 1
/varset QueueArray[${QueueSize}] ${Element}
/echo Successfully added ${Element} to slot ${QueueSize} of the queue
/varset QueueSize ${QueueSize}
/return 1
} else {
/echo Add to queue failed
/return NULL
}
Sub DeQueue
/declare ReturnValue string local
/declare Counter int local
/if (${QueueSize}==0) /return
/varset ReturnValue ${QueueArray[1]}
/for Counter 1 to ${Math.Calc[${QueueSize}-1]}
/varset QueueArray[${Counter}] ${QueueArray[${Math.Calc[${Counter}+1]}]}
/next Counter
/if (${Me.SpellReady["${transspell}"]}) {
/varset QueueSize ${Math.Calc[${QueueSize}-1]}
/call Trans ${ReturnValue}
} else {
/delay 7s
/call DeQueue
}
/return
any ideas?
-
JJ
- a hill giant

- Posts: 227
- Joined: Thu Nov 11, 2004 5:50 am
Post
by JJ » Mon Jan 17, 2005 12:57 pm
Code: Select all
Sub EnQueue(string Element)
/if (${QueueSize}<${QueueMaxSize}) {
/varcalc QueueSize ${QueueSize} + 1
/varset QueueArray[${QueueSize}] ${Element}
/echo Successfully added ${Element} to slot ${QueueSize} of the queue
/varset QueueSize ${QueueSize}
/return 1
} else {
/echo Add to queue failed
/return NULL
}
Since it doesn't really return anything you could get rid of returns but you also on your first /varcalc should encapsulate or use the math.calc thing again. Try this:
Code: Select all
Sub EnQueue(string Element)
/if (${QueueSize}<${QueueMaxSize}) {
/varcalc QueueSize ${Math.Calc[${QueueSize}+1]}
/varset QueueArray[${QueueSize}] ${Element}
/echo Successfully added ${Element} to slot ${QueueSize} of the queue
} else {
/echo Add to queue failed
}
/return
-
weezurd
- orc pawn

- Posts: 19
- Joined: Sat Jan 08, 2005 1:38 am
Post
by weezurd » Mon Jan 17, 2005 6:08 pm
got it. here is the final code for anyone interested:
Code: Select all
#include spell_routines.inc
#event Hailed "#1# says, 'Hail, <Your-Name-Here>'"
Sub Main
/echo Raid TL Macro has now started..
/declare transspell string outer
/declare spellgem int outer 9
/declare RequestorID int outer
/declare QueueMaxSize int outer
/declare QueueSize int outer
/varset QueueMaxSize 10
/varset QueueSize 0
/declare QueueArray[${QueueMaxSize}] string outer
/if (!${Defined[Param0]}) {
/echo Error, You must specify the translocate spell you wish to use.
/echo Syntax: /mac tl Natimbi
/end
} else {
/echo You have chosen to use: Translocate: ${Param0}
/varset transspell Translocate: ${Param0}
/if (!${Me.SpellReady["${transspell}"]}) {
/echo Now meming ${transspell}
/memspell ${spellgem} "${transspell}"
}
}
:MainLoop
/if (${QueueSize}>0) {
/call DeQueue
}
/doevents
/goto :MainLoop
Sub Event_Hailed(string line,string RequestorName)
/call EnQueue ${RequestorName}
/return
Sub Trans(string PersonToTrans)
/if (${Me.SpellReady["${transspell}"]}) {
/if (${FindItemCount[Small Portal Fragments]}>0) {
/varset RequestorID ${Spawn[pc ${PersonToTrans}].ID}
/squelch /target id ${RequestorID}
/delay 1s ${Target.ID}==${RequestorID}
/call cast "${transspell}" ${spellgem} 7s
} else {
/tell {$PersonToTrans} sorry, out of frags.
/echo Out of portal fragments, ending macro.
/end
}
}
/return
Sub EnQueue(string Element)
/if (${QueueSize}<${QueueMaxSize}) {
/varcalc QueueSize ${Math.Calc[${QueueSize}+1]}
/varset QueueArray[${QueueSize}] ${Element}
/echo Successfully added ${Element} to slot ${QueueSize} of the queue
| /varset QueueSize ${QueueSize}
} else {
/echo Add to queue failed
}
/return
Sub DeQueue
/declare ReturnValue string local
/declare Counter int local
/if (${QueueSize}==0) /return
/if (${Me.SpellReady["${transspell}"]}) {
/varset ReturnValue ${QueueArray[1]}
/for Counter 1 to ${Math.Calc[${QueueSize}-1]}
/varset QueueArray[${Counter}] ${QueueArray[${Math.Calc[${Counter}+1]}]}
/next Counter
/varset QueueSize ${Math.Calc[${QueueSize}-1]}
/call Trans ${ReturnValue}
} else {
/delay 7s
/call DeQueue
}
/return
as you can see i was able to readd the spell_routines cast functions b/c i made it so it wont dequeue unless the trans spell is rdy so that solved the issue regarding skipping people in the queue. im sure there are ways to improve this but its working now and does what i needed it to do.
really appreciate all the help ty guys vm.