#Bomb Script Optimisations
1 messages · Page 1 of 1 (latest)
I'll just make a thread.. should've done this before. sowwy
I took the advise and uploaded it to Github. Thanks for the advise. https://github.com/TacticalBeary/BEAR_bomb
Just looking through this on my phone, your init needs some serious organization. You are using waits on the main init thread. You should spawn a separate thread for those. The init should be just that, an init
I think I'm biting more than I can chew to be honest. I've just been trying to mess around with it for the past 5 hours not going anywhere. I've lost a bit of hope 
Stop using bis_fnc_param, and just use params. Engine command > function + it also has better readability
It's gonna take me a sec to get through the code you have atm
That's fine.. I decided I need to take a break for now... and go to bed :p
Since you are using CBA, a bomb timer is something that should be exact in its timing. You should use per frame handlers instead of a scheduled thread as sleeps and waits in scheduled threads are not guaranteed to be exactly that time. Unscheduled it is.
I think these are still leftovers from old code.
which is from 2014 :p
I'm just writing stuff as I see them. Address them when you want.
I should address them! Definitely
Updated the git with all the other files as well, in case that's handy
Are we talking about this? https://cbateam.github.io/CBA_A3/docs/files/common/fnc_addPerFrameHandler-sqf.html
yes, an example of this would be something like:
if (!isServer) exitWith {};
missionNamespace setVariable ["Bear_Bomb_Timer", 30];
[{
params ["_args", "_handle"];
private _bomb = missionNamespace getVariable ["Bear_Bomb", objNull];
private _timer = missionNamespace getVariable ["Bear_Bomb_Timer", 30];
// Early exits
if (!alive _bomb) exitWith {_handle call CBA_fnc_removePerFrameHandler};
// Defuses bomb
if (_bomb getVariable ["Bear_Bomb_Defused", false]) exitWith {
// do something
_handle call CBA_fnc_removePerFrameHandler;
};
// Bomb explodes
if (_timer <= 0) exitWith {
// do something
_handle call CBA_fnc_removePerFrameHandler;
};
// Notify
[format["Bomb Detonation: \n %1", _timer]] remoteExec ["hintSilent"];
// Increment timer
_timer = (_timer - 1) max 0;
missionNamespace setVariable ["Bear_Bomb_Timer", _timer];
},
1, // runs every 1 second exactly
[] // arguments to pass to _args
] call CBA_fnc_addPerFrameHandler;