#Bomb Script Optimisations

1 messages · Page 1 of 1 (latest)

turbid valley
#

I'll just make a thread.. should've done this before. sowwy

tulip oracle
#

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

turbid valley
#

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 ugly_cry

tulip oracle
#

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

turbid valley
#

That's fine.. I decided I need to take a break for now... and go to bed :p

tulip oracle
#

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.

turbid valley
#

which is from 2014 :p

tulip oracle
#

I'm just writing stuff as I see them. Address them when you want.

turbid valley
#

I should address them! Definitely

#

Updated the git with all the other files as well, in case that's handy

tulip oracle
# turbid valley Are we talking about this? https://cbateam.github.io/CBA_A3/docs/files/common/fn...

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;