ID:2228121
 
(See the best response by Nadrew.)
Code:
        cycleprio()
src << "Prio cycle"
//Looping until you have 10 names on the list
while(nextattacker.len<10)
//Adding all the priorities and seeing who has more than the highest
for(var/mob/m in fightingmobs)
m.loopprio+=m.reaction/4+8
if(m.loopprio>=highestpriority)
//Enough prio to attack, adding you to the attacker list
nextattacker+=m
m.loopprio-=highestpriority
battlepriorityHUD.maptext+="[m.name] >> "
choicecycle(1)

choicecycle(n)
src << "Choice cycle"
//Remove the person who chose an attack **BUGGY** Currently removes said person at the end of the list, not the front...
if(!n)
nextattacker -= nextattacker[1]
src << "remove"

//check whether 5 different attacks have already been chosen
if(listattacks.len>=5)
attackcycle()
return

//get the next attacker from the list
var/mob/m = nextattacker[1]
src << nextattacker[1]

//look whether it's an npc or has a client
if(!m.client)
var/mob/enemy/m2 = nextattacker[1]
src << "No client"
//if it is an npc, use BattleAI() (can't change parent_type, so use another variable)
m2.BattleAI()


Problem description:

Evening folks. I'm currently making my battle script, and in it, I use lists to keep track of all the attackers.
Problem is when I remove someone that is twice in the list(since his high speed allows him to attack twice in a round, which is like 5 attacks), instead of removing the first person that is in nextattacker, it looks automatically removes the last time the first person attacks, which makes him attack like 3 times in a row instead of once and then letting the other mobs choose their attack.

I want to keep the nextattacker list somewhat larger than what happens in this turn though, so one can think out a strategy depending on the next turn.
Best response
Instead of using the mob as the identifier for the list item, you'd want to use an associative list with unique indexes, you can even use numbers as strings.

var/list/my_list = list()

my_list["1"] = mob_one
my_list["2"] = mob_two
my_list["3"] = mob_one


Now when you want to remove an item you'd do something like

my_list -= "2"

// Or, if you want to retain the structure.

my_list["2"] = null


Then when accessing the player who is currently up

var/turn = 1 // You'd set this accordingly

var/mob/selected = my_list["[turn]"]
if(selected)
// Do stuff


Obviously just an example, you'd want to handle things a bit more gracefully in places like removing things (shifting things upwards on the list, etc).

You don't even need to go numerical on the index, you can use any identifier you want, as long as it's unique. BYOND list indexes must be unique, in non-associative lists like the one you're using you'd need to rely on strictly numerical indexing because looking up the mob using Find() will only give you the first one.