mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Split out the EPEContactStart code into its own function since it was quite long.
This commit is contained in:
parent
455d682706
commit
910a6a16ab
@ -36,6 +36,8 @@ PREP(getDetonators);
|
||||
PREP(getPlacedExplosives);
|
||||
PREP(getSpeedDialExplosive);
|
||||
|
||||
PREP(onLanded);
|
||||
|
||||
PREP(openDetonateUI);
|
||||
PREP(openPlaceUI);
|
||||
PREP(openTransmitterUI);
|
||||
|
52
addons/explosives/functions/fnc_onLanded.sqf
Normal file
52
addons/explosives/functions/fnc_onLanded.sqf
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet
|
||||
*
|
||||
* Arguments:
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* object addEventHandler ["EpeContactStart", ACE_explosive_fnc_onLanded];
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
if (!((_this select 0) getVariable [QGVAR(Handled), false])) then {
|
||||
private ["_player", "_pos", "_attachTo"];
|
||||
_player = ACE_player;
|
||||
_player setVariable [QGVAR(PlantingExplosive), false];
|
||||
_pos = getPosATL (_this select 0);
|
||||
(_this select 0) enableSimulationGlobal false;
|
||||
if (surfaceIsWater _pos) then {
|
||||
_pos = getPosASL (_this select 0);
|
||||
(_this select 0) setPosASL _pos;
|
||||
}else{
|
||||
(_this select 0) setPosATL _pos;
|
||||
};
|
||||
(_this select 0) setVariable [QGVAR(Handled), true];
|
||||
_attachTo = objNull;
|
||||
if (!isNull (_this select 1) && {(_this select 1) isKindOf "AllVehicles"}) then {
|
||||
_attachTo = (_this select 1);
|
||||
};
|
||||
private "_delay";
|
||||
_delay = getNumber(ConfigFile >> "CfgMagazines" >> ((_this select 0) getVariable [QGVAR(Class), ""]) >> "ACE_DelayTime");
|
||||
[{
|
||||
private ["_mag", "_setup", "_dir", "_player"];
|
||||
_setup = _this select 0;
|
||||
_player = ACE_player;
|
||||
_mag = _setup getVariable [QGVAR(Class), ""];
|
||||
_dir = _setup getVariable [QGVAR(Direction), 0];
|
||||
_explosive = [_player, _this select 2, _dir, _mag, _setup getVariable QGVAR(Trigger),
|
||||
[_setup getVariable QGVAR(Timer)], isNull (_this select 1)] call FUNC(placeExplosive);
|
||||
deleteVehicle _setup;
|
||||
if (!isNull(_explosive)) then {
|
||||
_player RemoveMagazine _mag;
|
||||
if (!isNull (_this select 1)) then {
|
||||
_explosive attachTo [(_this select 1)];
|
||||
_dir = _dir - (getDir (_this select 1));
|
||||
[[_explosive, _dir, 0], QFUNC(setPosition)] call EFUNC(common,execRemoteFnc);
|
||||
};
|
||||
};
|
||||
}, [(_this select 0),_attachTo, _pos], _delay, 0.1] call EFUNC(common,waitAndExecute);
|
||||
};
|
@ -39,67 +39,27 @@ if (_dir > 180) then {
|
||||
};
|
||||
_setup setVariable [QGVAR(Direction), _dir];
|
||||
_player setVariable [QGVAR(PlantingExplosive), true];
|
||||
_setup addEventHandler ["EpeContactStart", {
|
||||
if (!((_this select 0) getVariable [QGVAR(Handled), false])) then {
|
||||
private ["_player", "_pos", "_attachTo"];
|
||||
_player = ACE_player;
|
||||
_player setVariable [QGVAR(PlantingExplosive), false];
|
||||
_pos = getPosATL (_this select 0);
|
||||
(_this select 0) enableSimulationGlobal false;
|
||||
if (surfaceIsWater _pos) then {
|
||||
_pos = getPosASL (_this select 0);
|
||||
(_this select 0) setPosASL _pos;
|
||||
}else{
|
||||
(_this select 0) setPosATL _pos;
|
||||
};
|
||||
(_this select 0) setVariable [QGVAR(Handled), true];
|
||||
_attachTo = objNull;
|
||||
if (!isNull (_this select 1) && {(_this select 1) isKindOf "AllVehicles"}) then {
|
||||
_attachTo = (_this select 1);
|
||||
};
|
||||
[(_this select 0),_attachTo, _pos] spawn { // TODO: Change to scheduled delay execution
|
||||
private ["_mag", "_setup", "_dir", "_player"];
|
||||
_setup = _this select 0;
|
||||
_player = ACE_player;
|
||||
_mag = _setup getVariable [QGVAR(Class), ""];
|
||||
_dir = _setup getVariable [QGVAR(Direction), 0];
|
||||
|
||||
sleep getNumber(ConfigFile >> "CfgMagazines" >> _mag >> "ACE_DelayTime");
|
||||
_explosive = [_player, _this select 2, _dir, _mag, _setup getVariable QGVAR(Trigger),
|
||||
[_setup getVariable QGVAR(Timer)], isNull (_this select 1)] call FUNC(placeExplosive);
|
||||
deleteVehicle _setup;
|
||||
if (!isNull(_explosive)) then {
|
||||
_player RemoveMagazine _mag;
|
||||
if (!isNull (_this select 1)) then {
|
||||
_explosive attachTo [(_this select 1)];
|
||||
_dir = _dir - (getDir (_this select 1));
|
||||
[[_explosive, _dir, 0], QFUNC(setPosition)] call EFUNC(common,execRemoteFnc);
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}];
|
||||
_setup addEventHandler ["EpeContactStart", FUNC(onLanded)];
|
||||
_setup enableSimulationGlobal true;
|
||||
_player playActionNow "MedicOther";
|
||||
[_setup] spawn { // TODO: Change to scheduled delay execution
|
||||
|
||||
[{
|
||||
private ["_setup", "_player"];
|
||||
_setup = _this select 0;
|
||||
_setup = _this;
|
||||
_player = ACE_player;
|
||||
sleep 5;
|
||||
_player setVariable [QGVAR(PlantingExplosive), false];
|
||||
if (!isNull _setup) then {
|
||||
private ["_mag", "_dir", "_delayTime"];
|
||||
_mag = _setup getVariable [QGVAR(Class), ""];
|
||||
_dir = _setup getVariable [QGVAR(Direction), 0];
|
||||
_delayTime = (getNumber(ConfigFile >> "CfgMagazines" >> _mag >> "ACE_DelayTime")) - 5;
|
||||
if (_delayTime > 0) then {
|
||||
sleep _delayTime;
|
||||
};
|
||||
if (!isNull _setup) then {
|
||||
[_player, GetPosATL _setup, _dir, _mag, _setup getVariable QGVAR(Trigger),
|
||||
[_setup getVariable QGVAR(Timer)], true] call FUNC(placeExplosive);
|
||||
deleteVehicle _setup;
|
||||
_player RemoveMagazine _mag;
|
||||
};
|
||||
// TODO: Might need to handle this at some point?
|
||||
//_delayTime = (getNumber(ConfigFile >> "CfgMagazines" >> _mag >> "ACE_DelayTime")) - 5;
|
||||
//if (_delayTime > 0) then {
|
||||
// sleep _delayTime;
|
||||
//};
|
||||
[_player, GetPosATL _setup, _dir, _mag, _setup getVariable QGVAR(Trigger),
|
||||
[_setup getVariable QGVAR(Timer)], true] call FUNC(placeExplosive);
|
||||
deleteVehicle _setup;
|
||||
_player RemoveMagazine _mag;
|
||||
};
|
||||
};
|
||||
}, _setup, 5, 0.5] call EFUNC(common,waitAndExecute);
|
||||
|
Loading…
Reference in New Issue
Block a user