ID:160631
 
If anyone has played my game ZAS, then they'll know that there's a statpanel with a list of weapons that have been found. To spruce up the battles a bit, I made it so that the game randomly picks from the list of weapons and adds them to a "[survivor] uses [a weapon] to do [x] damage" message.

This all worked nicely but the obvious error with this is since it loops through all the survivors, situations can arise where the program picks the same weapon twice or more, leading to strange situations where two people are apparently using the same baseball bat at the same time. What I hit upon was creating a temporary list of all the weapons available, and when a weapon is picked, remove it from the temporary list. The problem is, using

var/list/available_weapons = weapons_inv


and then removing an item from the available weapons list using the -= operator, it removes the item from the weapons_inv list as well. Can anyone suggest a way around this happening?
You can use the Copy() proc, which creates a duplicate. Since lists are objects, you'll have to use this proc if you intend on modifying the contents for stuff like processing.

var/list/available_weapons = weapons_inv.Copy()
In response to Unknown Person
Cheers.