//The actual individual engagement
obj/engagement
var/list/combatants
var/turn1
var/turn2
density = 0
icon = 'Engagement Flag.dmi'
proc
Turn_Order()
var/hi_spd = 0
var/hi_spd2 = 0
world << "Debug 1"
//Runs through each of the combatants and determines if their speed will allow them into the order.
for(var/mob/player/C in combatants)
world << "Debug 2"
if(C.spd > hi_spd)
world << "Debug 3"
hi_spd = C.spd
turn1 = C
C << "You will take the next turn."
if(C.spd < hi_spd && C.spd > hi_spd2)
world << "Debug 4"
hi_spd2 = C.spd
turn2 = C
C << "You will take the turn after next."
else
return
proc
Start_Engagement()
var/obj/engagement/E = new(locate(13,13,1))
for(var/mob/player/C in view(30))
E.combatants += C
view() << "[C] will be participating in this engagment."
E.Turn_Order()
Problem description: I'm getting started on a combat system that will add nearby users to it's list of combatants then compare their speed to determine their turn order. The issue is when the Turn_Order proc is called, it doesn't seem to be recognizing anyone in the list of combatants, and thus executes none of the coding below the for(). Could someone point me in the right direction?
The only thing particularly dangerous about Start_Engagement() is that you're implicitly using usr in each of your view() calls. If you aren't 100% sure that usr is what you need there, you should pass something else instead. This is a global proc, so it's possible that usr is null, view(30) is an empty list, and the loop does nothing.