When the game reaches a certain point (call it the "Firing phase"), all the players simultaneously decide if they're going to pass or take a shot at another player.
My idea was that each player would make this decision at the same time and when they put in this order, it will call a macro to see if everyone has set their firing actions (if you pass, it still counts as setting a firing action). The macro looks like this
Code: Select all
<!--See if each car has set the firing orders--!>
[h : allPCs = getPC()]
[h, FOREACH(pc, allPCs, ""), code : {
[h : ordersIn = getProperty("FiringOrdersSet", pc)]
[h, if(ordersIn == 0), code : {
[broadcast("...Waiting on firing orders...")]
[abort(0)]
}]
}]
[broadcast("<b>All firing orders are in!!!</b>")]
[h, FOREACH(pc, AllPcs, ""), code : {
[h : weaponsToFire = getProperty("CurrentWeaponsToFire", pc)]
[h : wpnsFiring = listCount(weaponsToFire)]
[h, if(wpnsFiring > 0), code : {
[h, MACRO("CheckAndProcessFiringOrders_ForCar@lib:Math"):pc]
}]
}]
[h, MACRO("FiringOrdersDone@lib:Math"):0]
This works flawlessly in testing but once I have another player connected to the server, it becomes unreliable. If the two players coordinate with each other ("Okay, I'm going to set my firing orders, don't do yours right now"), then it works. But, it shouldn't work that way, the players should be able to all just click on whether or not they're firing and it should get through that initial loop.
Is there a way to achieve this that I'm not thinking of? Thanks