AsYetUntitled / Framework

Altis Life RPG mission framework for Arma 3 originally made by @TAWTonic.
Other
247 stars 309 forks source link

fed bank need some rework #690

Closed ghost closed 4 years ago

ghost commented 4 years ago

branch: master commit: 86f766e

Sorry for not follow issue template this time, but it's to follow for this topic.

So I continued testing with my friends and we tested robbing the bank (I set required cops to 1 for testing). As I also wanted to test the bomb defusal one of us planted the bomb, I defused it, and the bomb was replanted. While the timer still had about 2m to go suddenly the explosion triggered and the safe was opened. After digging through the involved files I suspect this to be the issue: File: life_server/Functions/Systems/fn_handleBlastingCharge.sqf

private ["_bomb","_time"];
_time = time + (5 * 60);
waitUntil{(round(_time - time) < 1)};
sleep 0.9;
if (!(fed_bank getVariable["chargeplaced",false])) exitWith {};

_bomb = "Bo_GBU12_LGB_MI10" createVehicle [getPosATL fed_bank select 0, getPosATL fed_bank select 1, (getPosATL fed_bank select 2)+0.5];
fed_bank setVariable ["chargeplaced",false,true];
fed_bank setVariable ["safe_open",true,true];

The issue is this: The timer gets started when the first bomb is planted. It ticks down for the full 5m no matter what else happen on the server. After the 5m is done then it's checked again if in that very moment any bomb is planted, no matter if it's the same or another as the original was defused. If at least some bomb is planted when the first timer hits 0 the explosion is triggered, any other bomb is "disarmed" (so their timers just run out without anything else happening) and the vault is opened. We didn't tested it, but I suspect that with good timing and a bit of the help of at least one of the cops the bank maybe can be looted twice within that 5m timer interval; although it would require some precise timing and planing. Maybe subject for another test.

How can this be fixed: I'm not sure how well the ArmA3 engine can be manipulated while waiting for something to happen in a not-so-resource-impacting-style, but if possible the timer should be somehow "aborted" when the bomb is defused. Maybe extending the condition to something like this: waitUntil{(round(_time - time) < 1)||(fed_bank getVariable["chargeplaced",false])};

BoGuu commented 4 years ago

Haha. I don't think I've ever seen a defuse before.

Your suggestion is correct - and checking chargeplaced again after the loop to void further actions 👍

ghost commented 4 years ago

Aside from our test I've only seen it once on a server which does not have one of the common rules in place that a fed bank heist has to be announced at least 1h before it starts and that there has to be some equal number of players on both sides. It was just a few rebels managed to successfully break through the gate and the door and already planted the bomb when there were overwhelmed but so many cops at once they just didn't knew who to fire back to first. Most often a fed bank heist either ends up the rebels not even break through the inner door or successfully detonate the bomb, escape and die on the chase to the gold dealer (although I once played on a server where the fed bank was moved to the small island on the beach of Pyrgos and there was a bridge connecting the south "rebel island" to the eastern part so there was an alternate route).

Anyway, would it be enough just to add the second check if the charge got defused? And does anyone know what the sleep is for between the waitUntil and the additional if()?