Below is the scripts I'm trying to work on; you should be able to figure out where I'm going with this, despite not having all the information available to you.
CODE
for (a=0;a<=12;a+=1)
{
compare = min(estemp,pstemp[1],pstemp[2],pstemp[3])
switch (compare)
{
case estemp:
ds_list_add(turnlist,estemp)
ds_grid_set(turnorder,a,0,estemp)
ds_grid_set(turnorder,a,1,'spr_' + ds_grid_get(finfo,0,3))
if enemyspeed = 0 then enemyspeed = enemyagility
if a = 0 then cplay = 9 //Currently 9 = a foe. NEEDS WORK
estemp += enemyagility
;break;
case pstemp[1]:
ds_list_add(turnlist,pstemp[1])
ds_grid_set(turnorder,a,0,pstemp[1])
ds_grid_set(turnorder,a,1,'spr_' + ds_grid_get(cplayer[0],0,0)+ 'Face')
if pspeed[1] = 0 then pspeed[1] = pagility[1]
pstemp[1] += pagility[1]
if activated = 1 then
{
pstemp[1] += pagility[1] + .001
activated = 0
}
if a = 0 then
{
cplay = 0
pstemp[1] += argument0
if submenu = 3 then
{
pstemp[1] = pstemp[(ds_grid_get(catagory,cselect-1,2)+1)]-.001
activated = 1
}
}
;break;
case pstemp[2]:
ds_list_add(turnlist,pstemp[2])
ds_grid_set(turnorder,a,0,pstemp[2])
ds_grid_set(turnorder,a,1,'spr_' + ds_grid_get(cplayer[1],0,0)+ 'Face')
if pspeed[2] = 0 then pspeed[2] = pagility[2]
pstemp[2] += pagility[2]
if activated = 2 then
{
pstemp[2] += pagility[2] + .001
activated = 0
}
if a = 0 then
{
cplay = 1
pstemp[2] += argument0
if submenu = 3 then
{
pstemp[2] = pstemp[(ds_grid_get(catagory,cselect-1,2)+1)]-.001
activated = 2
}
}
;break;
case pstemp[3]:
ds_list_add(turnlist,pstemp[3])
ds_grid_set(turnorder,a,0,pstemp[3])
ds_grid_set(turnorder,a,1,'spr_' + ds_grid_get(cplayer[2],0,0)+ 'Face')
if pspeed[3] = 0 then pspeed[3] = pagility[3]
pstemp[3] += pagility[3]
if activated = 3 then
{
pstemp[3] += pagility[3] + .001
activated = 0
}
if a = 0 then
{
cplay = 2
pstemp[3] += argument0
if submenu = 3 then
{
pstemp[3] = pstemp[(ds_grid_get(catagory,cselect-1,2)+1)]-.001
activated = 3
}
}
;break;
}
}
{
compare = min(estemp,pstemp[1],pstemp[2],pstemp[3])
switch (compare)
{
case estemp:
ds_list_add(turnlist,estemp)
ds_grid_set(turnorder,a,0,estemp)
ds_grid_set(turnorder,a,1,'spr_' + ds_grid_get(finfo,0,3))
if enemyspeed = 0 then enemyspeed = enemyagility
if a = 0 then cplay = 9 //Currently 9 = a foe. NEEDS WORK
estemp += enemyagility
;break;
case pstemp[1]:
ds_list_add(turnlist,pstemp[1])
ds_grid_set(turnorder,a,0,pstemp[1])
ds_grid_set(turnorder,a,1,'spr_' + ds_grid_get(cplayer[0],0,0)+ 'Face')
if pspeed[1] = 0 then pspeed[1] = pagility[1]
pstemp[1] += pagility[1]
if activated = 1 then
{
pstemp[1] += pagility[1] + .001
activated = 0
}
if a = 0 then
{
cplay = 0
pstemp[1] += argument0
if submenu = 3 then
{
pstemp[1] = pstemp[(ds_grid_get(catagory,cselect-1,2)+1)]-.001
activated = 1
}
}
;break;
case pstemp[2]:
ds_list_add(turnlist,pstemp[2])
ds_grid_set(turnorder,a,0,pstemp[2])
ds_grid_set(turnorder,a,1,'spr_' + ds_grid_get(cplayer[1],0,0)+ 'Face')
if pspeed[2] = 0 then pspeed[2] = pagility[2]
pstemp[2] += pagility[2]
if activated = 2 then
{
pstemp[2] += pagility[2] + .001
activated = 0
}
if a = 0 then
{
cplay = 1
pstemp[2] += argument0
if submenu = 3 then
{
pstemp[2] = pstemp[(ds_grid_get(catagory,cselect-1,2)+1)]-.001
activated = 2
}
}
;break;
case pstemp[3]:
ds_list_add(turnlist,pstemp[3])
ds_grid_set(turnorder,a,0,pstemp[3])
ds_grid_set(turnorder,a,1,'spr_' + ds_grid_get(cplayer[2],0,0)+ 'Face')
if pspeed[3] = 0 then pspeed[3] = pagility[3]
pstemp[3] += pagility[3]
if activated = 3 then
{
pstemp[3] += pagility[3] + .001
activated = 0
}
if a = 0 then
{
cplay = 2
pstemp[3] += argument0
if submenu = 3 then
{
pstemp[3] = pstemp[(ds_grid_get(catagory,cselect-1,2)+1)]-.001
activated = 3
}
}
;break;
}
}
CODE
ds_list_sort(turnlist,true)
if redraw = true
draw_rectangle_color(104,8,695,60,c_dkgray,c_dkgray,c_dkgray,c_dkgr
ay,false)
ds_list_sort(turnlist,true)
for (a=0;a<=11;a+=1)
{
if a = 0 then draw_rectangle_color(644,8,694,60,c_yellow,c_yellow,c_yellow,c_yell
ow,false) draw_sprite(execute_string("sprite_index="+string(ds_grid_get(turnorder,ds_grid_value_x(turnorder,0,0,12,0,ds_list_find_value(turnlist,a)),1))),-1,646-(a*49),11)
}
}
draw_rectangle_color(104,8,695,60,c_ltgray,c_ltgray,c_ltgray,c_ltgr
ay,true)
if redraw = true
draw_rectangle_color(104,8,695,60,c_dkgray,c_dkgray,c_dkgray,c_dkgr
ay,false)
ds_list_sort(turnlist,true)
for (a=0;a<=11;a+=1)
{
if a = 0 then draw_rectangle_color(644,8,694,60,c_yellow,c_yellow,c_yellow,c_yell
ow,false) draw_sprite(execute_string("sprite_index="+string(ds_grid_get(turnorder,ds_grid_value_x(turnorder,0,0,12,0,ds_list_find_value(turnlist,a)),1))),-1,646-(a*49),11)
}
}
draw_rectangle_color(104,8,695,60,c_ltgray,c_ltgray,c_ltgray,c_ltgr
ay,true)
The method I tried to whip up works as long as all the values are different. As soon as a value is the same it pulls the first array that satisfies the condition, which won't work for me.
Any other method I could use or a good way to properly sort identical values?
