The problem is hopefully something simple, i simply want it so that the person with the highest agility goes first. Now, it says its now your turn! to the wrong person, and sometimes the combat simply stops!
var/list/WhichTurn=new()
var/list/ppl=new()
for(var/mob/Aa in view())ppl+=Aa
var/nextturn,PlayerOrder
do
for (var/aa=0;aa<=length(ppl);aa++)
PlayerOrder=0
for(var/mob/ppp in ppl)
if (ppp.Agility>PlayerOrder){nextturn=ppp;PlayerOrder=ppp.Agility}
else if (ppp.Agility==PlayerOrder)nextturn=ppp
WhichTurn+=nextturn
ppl-=nextturn
while (length(ppl)>0)
do
for(var/mob/pp in WhichTurn)
if (pp.Health>0)
if (pp.client)
pp<<"It is now your turn!"
pp.Turn = 1
while(pp.Turn)
sleep(5)
while(1)
~ Kyle