What I want is that every time I create a work order, it searches for idle workers and then assigns one to that work order.
Since workers and work orders can be inaccessible, I put in an event so if the worker can’t pathfind to the work order, they get unassigned and then stores the ID of that work order in an array.
My assignment event is supposed to take these failed IDs into account when finding available workers, but it fails. I can see in the debugger that the same worker just keeps getting assigned, fails, adds that workorderID to its FailedWorkOrders and gets unassigned, and then immediately gets assigned again.
I’m using the extension Array Tools to check if the worker’s FailedWorkOrders array has the same value somewhere as the work order’s WorkOrderID. I think the error might be here somewhere?
I tried it this morning. I thought about a cooldown period, a structure of availability based on IDs but I settled on a while event with scene and object variables. It needs more testing. As always, there’s infinite ways of doing something.
Whenever I use a while event, I always add a counter as a fail safe to prevent infinite loops. A variable check could be just as effective.
It really should be checking if there are any available and non-blocked monsters and then set an abort or other boolean to exit the while before the counter reaches the limit. The events inside the while event would need to be moved to a subevent.
Oh this is interesting. I never really use While events because it tends to crash the whole engine whenever there’s an issue and I just can’t be assed to keep restarting everything. Maybe its worth it to start using it.