mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #50 from KoffeinFlummi/waitAndExecute
Added waitAndExecute function
This commit is contained in:
commit
e89d098727
@ -119,6 +119,7 @@ PREP(toBitmask);
|
||||
PREP(toHex);
|
||||
PREP(toNumber);
|
||||
PREP(unmuteUnit);
|
||||
PREP(waitAndExecute);
|
||||
|
||||
// ACE_Debug
|
||||
PREP(exportConfig);
|
||||
|
36
addons/common/functions/fnc_waitAndExecute.sqf
Normal file
36
addons/common/functions/fnc_waitAndExecute.sqf
Normal file
@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Author: CAA-Picard
|
||||
*
|
||||
* Executes a code once with a given game time delay, using a PFH
|
||||
*
|
||||
* Argument:
|
||||
* 0: Code to execute (Code)
|
||||
* 1: Parameters to run the code with (Array)
|
||||
* 2: Delay in seconds before executing the code (Number)
|
||||
* 3: Interval of time in which the execution is evaluated, 0 means every frame (Number)
|
||||
*
|
||||
* Return value:
|
||||
* PFH handler ID
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_4_PVT(_this,_func,_params,_delay,_interval);
|
||||
|
||||
[
|
||||
{
|
||||
EXPLODE_2_PVT(_this,_params,_pfhId);
|
||||
EXPLODE_2_PVT(_params,_delayedExecParams,_startTime);
|
||||
EXPLODE_3_PVT(_delayedExecParams,_func,_funcParams,_delay);
|
||||
|
||||
// Exit if the time was not reached yet
|
||||
if (time < _startTime + _delay) exitWith {};
|
||||
|
||||
// Remove the PFH
|
||||
[_pfhId] call cba_fnc_removePerFrameHandler;
|
||||
|
||||
// Execute the function
|
||||
_funcParams call _func;
|
||||
},
|
||||
_interval,
|
||||
[_this, time]
|
||||
] call CBA_fnc_addPerFrameHandler
|
@ -16,22 +16,12 @@
|
||||
[_explosive, 10] call ACE_Explosives_fnc_startTimer;
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
EXPLODE_2_PVT(_this,_explosive,_delay);
|
||||
|
||||
[{
|
||||
EXPLODE_2_PVT(_this,_params,_pfhId);
|
||||
|
||||
private ["_placeTime", "_fuseTime", "_explosive"];
|
||||
_placeTime = _params select 1;
|
||||
_fuseTime = _params select 0 select 1;
|
||||
|
||||
// Exit if it's not time to detonate yet
|
||||
if (time < _placeTime + _fuseTime) exitWith {};
|
||||
|
||||
// Remove the PFH
|
||||
[_pfhId] call cba_fnc_removePerFrameHandler;
|
||||
|
||||
_explosive = (_params select 0) select 0;
|
||||
_explosive = _this;
|
||||
if (!isNull _explosive) then {
|
||||
[_explosive, -1, [_explosive, 0], true] call FUNC(detonateExplosive);
|
||||
};
|
||||
|
||||
},0, [_this, time]] call CBA_fnc_addPerFrameHandler;
|
||||
}, _explosive, _delay, 0] call EFUNC(common,waitAndExecute);
|
@ -24,31 +24,28 @@ GVAR(newStrength) = GVAR(newStrength) max _strength;
|
||||
|
||||
if (missionNamespace getVariable [QGVAR(isEarRingingPlaying), false]) exitWith {};
|
||||
|
||||
_fnc_removeEarRinging = {
|
||||
EXPLODE_2_PVT(_this,_params,_pfhId);
|
||||
EXPLODE_2_PVT(_params,_startTime,_duration);
|
||||
|
||||
// Exit if the delay is not met yet
|
||||
if (time < _startTime + _duration) exitWith {};
|
||||
|
||||
GVAR(isEarRingingPlaying) = false;
|
||||
[_pfhId] call cba_fnc_removePerFrameHandler;
|
||||
};
|
||||
|
||||
if (profileNamespace getVariable [QGVAR(DisableEarRinging), false]) exitWith {};
|
||||
|
||||
if (_strength > 0.75) exitWith {
|
||||
playSound "ACE_EarRinging_Heavy";
|
||||
GVAR(isEarRingingPlaying) = true;
|
||||
[_fnc_removeEarRinging, 0.25, [time, 7.0] ] call CBA_fnc_addPerFrameHandler;
|
||||
[
|
||||
{GVAR(isEarRingingPlaying) = false;}, [], 7.0, 0.25
|
||||
] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
if (_strength > 0.5) exitWith {
|
||||
playSound "ACE_EarRinging_Medium";
|
||||
GVAR(isEarRingingPlaying) = true;
|
||||
[_fnc_removeEarRinging, 0.25, [time, 5.0] ] call CBA_fnc_addPerFrameHandler;
|
||||
[
|
||||
{GVAR(isEarRingingPlaying) = false;}, [], 5.0, 0.25
|
||||
] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
if (_strength > 0.2) exitWith {
|
||||
playSound "ACE_EarRinging_Weak";
|
||||
GVAR(isEarRingingPlaying) = true;
|
||||
[_fnc_removeEarRinging, 0.25, [time, 3.0] ] call CBA_fnc_addPerFrameHandler;
|
||||
GVAR(isEarRingingPlaying) = true;
|
||||
[
|
||||
{GVAR(isEarRingingPlaying) = false;}, [], 3.0, 0.25
|
||||
] call EFUNC(common,waitAndExecute);
|
||||
};
|
||||
|
@ -3,8 +3,8 @@
|
||||
PREP(checkTemperature);
|
||||
PREP(clearJam);
|
||||
PREP(cooldown);
|
||||
PREP(displayTemperature);
|
||||
PREP(jamWeapon);
|
||||
PREP(overheat);
|
||||
PREP(pfhDisplayTemperature);
|
||||
PREP(swapBarrel);
|
||||
PREP(swapBarrelCallback);
|
||||
|
@ -25,4 +25,4 @@ if (_action == "") then {
|
||||
_player playActionNow _action;
|
||||
|
||||
// Launch a PFH that waits a sec before displaying the temperature
|
||||
[FUNC(pfhDisplayTemperature), 1.0, [_player, _weapon, diag_tickTime]] call CBA_fnc_addPerFrameHandler;
|
||||
[FUNC(displayTemperature), [_player, _weapon], 1.0, 0] call EFUNC(common,waitAndExecute);
|
@ -1,7 +1,7 @@
|
||||
/*
|
||||
* Author: Commy2 and CAA-Picard
|
||||
*
|
||||
* PFH that displays the weapon temperature after a slight delay
|
||||
* Displays the weapon temperature
|
||||
*
|
||||
* Arguments:
|
||||
* 0: _player
|
||||
@ -13,14 +13,7 @@
|
||||
*/
|
||||
#include "\z\ace\addons\overheating\script_component.hpp"
|
||||
|
||||
EXPLODE_2_PVT(_this,_params,_pfhId);
|
||||
EXPLODE_3_PVT(_params,_player,_weapon,_startTime);
|
||||
|
||||
// Skip the first execution of the PFH
|
||||
if (diag_tickTime < _startTime + 0.5) exitWith {};
|
||||
|
||||
// Remove the PFH on the second execution
|
||||
[_pfhId] call cba_fnc_removePerFrameHandler;
|
||||
EXPLODE_2_PVT(_this,_player,_weapon);
|
||||
|
||||
// Calculate cool down of weapon since last shot
|
||||
private ["_string", "_overheat", "_temperature", "_time", "_barrelMass"];
|
Loading…
Reference in New Issue
Block a user