ID:170891
 
I need to queue 4 players and 8 monsters in a battle by agility... is there a built-in proc I can use instead of making 1200 lines of if() procs? ^_^
Had the same problem once :P
Make a var the reprisents each mob of the 12 mobs, and give that var a value that is like 1000 times they're agility.
Then just make a loop, considering the mobs are in a list called "mobs" and that the new var would be named "number" and the agility var is just called "agility"
var/list/l = new
var/i
for(i = 0, i < 25, i++) //we will loop 24 times
var/mob/n_m = null
for(var/mob/m in mobs)
if(!n_m) n_m = m
else if(m.number > n_m.number)
n_m = m
n_m.number -= n_m.agility
l.Add(n_m)

Now L sould contain a list with all the mobs queued in teh right order. I think :P cuz i kinda wrote it fast AND i gotta catch my train now! U can probably use the cut() proc to get the mobs outa the list in teh right order.
Hope it helped a bit. Bai bai

Greetz Fint *runs off*
In response to Fint
First of all no it didn't take 6 months for me to figure out this doesn't work.

Second of all, you lost me at
for(i = 0, i < 25, i++)


Anywho, if anyone can explain better how that works or post something else, that'll work. I actually now that I think of it could really use this if I knew what it did =P so either someone could explain this better, post a differant code that would do the same thing, or just post a code that'll give me what I asked for (just pull the mob with the most agility out of the list and delete it from the list) even though this will actually work better; that'd be cool.

(I realized that instead of sorting them every turn, I can sort them at the beginning and I can just use "boblist[1]", "boblist[2]", "boblist[3]", etc ^^ yays