ID:148777
 
Well, i'm working on the player vs player system for Final Fantasy Online. Well, i'm having a little problem and hope someone can help me out here.

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
I'm not sure whats wrong with the codes but the same thing happened to me and i changed the agility of the NPC/Player around and it seemed to fix the problem.
In response to Soori-99
Soori-99 wrote:
I'm not sure whats wrong with the codes but the same thing happened to me and i changed the agility of the NPC/Player around and it seemed to fix the problem.

That won't help.

~ Kyle
In response to Alatar
You're setting PlayerOrder to 0, then checking if the person's agility is higher than it. Take the line PlayerOrder = 0 out of the loop.
In response to Garthor
Garthor wrote:
You're setting PlayerOrder to 0, then checking if the person's agility is higher than it. Take the line PlayerOrder = 0 out of the loop.

Ouch, such a small problem as so easily fixed, Why thankyou Garthor, that was very much appreciated =)

~ Kyle