mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Explosives - Local Defuse Helpers
This commit is contained in:
@ -15,26 +15,45 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
//Start up a PFEH that scans all mines/explosives without defuseObjects attached and adds them
|
//Event system to add the defuse object to all explosive devices (defuse is local)
|
||||||
//Handles Editor Placed / Zeus / Scripted
|
GVAR(explosivesHelped) = [];
|
||||||
if (isServer) then {
|
GVAR(defuseOjbects) = [];
|
||||||
[{
|
|
||||||
private ["_explosive", "_helpers", "_defuseHelper"];
|
|
||||||
{
|
|
||||||
_explosive = _x;
|
|
||||||
_helpers = {
|
|
||||||
((typeOf _x) == "ACE_DefuseObject") && {(_x getVariable [QGVAR(Explosive), objNull]) == _explosive}
|
|
||||||
} count (attachedObjects _explosive);
|
|
||||||
|
|
||||||
if (_helpers == 0) then {
|
["explosive_placed", {
|
||||||
TRACE_3("Explosive without helper",_explosive,(getPosAsl _explosive),(typeOf _explosive));
|
PARAMS_1(_explosive);
|
||||||
_defuseHelper = createVehicle ["ACE_DefuseObject", (getPos _explosive), [], 0, "NONE"];
|
if (_explosive in GVAR(explosivesHelped)) exitWith {};
|
||||||
_defuseHelper attachTo [_explosive, [0,0,0], ""];
|
private ["_defuseHelper"];
|
||||||
_defuseHelper setVariable [QGVAR(Explosive),_explosive,true];
|
_defuseHelper = "ACE_DefuseObject" createVehicleLocal (getPos _explosive);
|
||||||
|
_defuseHelper attachTo [_explosive, [0,0,0]];
|
||||||
|
_defuseHelper setVariable [QGVAR(Explosive),_explosive];
|
||||||
|
TRACE_3("Added local defuse to helper",_explosive,(typeOf _explosive),_defuseHelper);
|
||||||
|
GVAR(explosivesHelped) pushBack _explosive;
|
||||||
|
GVAR(defuseOjbects) pushBack _defuseHelper;
|
||||||
|
}] call EFUNC(common,addEventHandler);
|
||||||
|
|
||||||
|
//Start up a PFEH that scans all mines/explosives without defuseObjects attached and adds them
|
||||||
|
//Handles Editor Placed / Zeus / Scripted / JIP
|
||||||
|
[{
|
||||||
|
private ["_modeAdd"];
|
||||||
|
_modeAdd = (_this select 0) select 0;
|
||||||
|
if (_modeAdd) then {
|
||||||
|
TRACE_2("Adding Helpers",(count allMines),(count GVAR(explosivesHelped)));
|
||||||
|
{
|
||||||
|
TRACE_2("Explosive without helper",_explosive,(typeOf _explosive));
|
||||||
|
["explosive_placed", [_x]] call EFUNC(common,localEvent);
|
||||||
|
} forEach (allMines - GVAR(explosivesHelped));
|
||||||
|
} else {
|
||||||
|
TRACE_2("Cleaning Helpers",(count allMines),(count GVAR(explosivesHelped)));
|
||||||
|
{
|
||||||
|
if (isNull _x) then {
|
||||||
|
deleteVehicle (GVAR(defuseObjects) select _forEachIndex);
|
||||||
};
|
};
|
||||||
} forEach allMines;
|
} forEach GVAR(explosivesHelped);
|
||||||
}, 5, []] call CBA_fnc_addPerFrameHandler;
|
GVAR(explosivesHelped) = GVAR(explosivesHelped) - [objNull];
|
||||||
};
|
GVAR(defuseOjbects) = GVAR(defuseOjbects) - [objNull];
|
||||||
|
};
|
||||||
|
(_this select 0) set [0, !_modeAdd];
|
||||||
|
}, 5, [true]] call CBA_fnc_addPerFrameHandler;
|
||||||
|
|
||||||
if !(hasInterface) exitWith {};
|
if !(hasInterface) exitWith {};
|
||||||
GVAR(PlacedCount) = 0;
|
GVAR(PlacedCount) = 0;
|
||||||
|
@ -51,18 +51,12 @@ if (isText(_magazineTrigger >> "ammo")) then {
|
|||||||
_ammo = getText (_magazineTrigger >> "ammo");
|
_ammo = getText (_magazineTrigger >> "ammo");
|
||||||
};
|
};
|
||||||
_triggerSpecificVars pushBack _triggerConfig;
|
_triggerSpecificVars pushBack _triggerConfig;
|
||||||
private ["_defuseHelper"];
|
|
||||||
_defuseHelper = createVehicle ["ACE_DefuseObject", _pos, [], 0, "NONE"];
|
|
||||||
_defuseHelper setPosATL _pos;
|
|
||||||
|
|
||||||
_explosive = createVehicle [_ammo, _pos, [], 0, "NONE"];
|
_explosive = createVehicle [_ammo, _pos, [], 0, "NONE"];
|
||||||
_defuseHelper attachTo [_explosive, [0,0,0], ""];
|
|
||||||
_defuseHelper setVariable [QGVAR(Explosive),_explosive,true];
|
|
||||||
|
|
||||||
_expPos = getPosATL _explosive;
|
|
||||||
_defuseHelper setPosATL (((getPosATL _defuseHelper) vectorAdd (_pos vectorDiff _expPos)));
|
|
||||||
_explosive setPosATL _pos;
|
_explosive setPosATL _pos;
|
||||||
|
|
||||||
|
["explosive_placed", [_explosive]] call EFUNC(common,globalEvent);
|
||||||
|
|
||||||
if (!isNull _attachedTo) then {
|
if (!isNull _attachedTo) then {
|
||||||
TRACE_1("Attaching Live Explosive",_attachedTo);
|
TRACE_1("Attaching Live Explosive",_attachedTo);
|
||||||
_explosive attachTo [_attachedTo];
|
_explosive attachTo [_attachedTo];
|
||||||
|
@ -37,7 +37,7 @@ if (_dir > 180) then {
|
|||||||
} else {
|
} else {
|
||||||
_dir = 180 + _dir;
|
_dir = 180 + _dir;
|
||||||
};
|
};
|
||||||
_setup setVariable [QGVAR(Direction), _dir];
|
_setup setVariable [QGVAR(Direction), _dir, true];
|
||||||
_player setVariable [QGVAR(PlantingExplosive), true];
|
_player setVariable [QGVAR(PlantingExplosive), true];
|
||||||
[{_this setVariable [QGVAR(PlantingExplosive), false]}, _player, 1.5, 0.5] call EFUNC(common,waitAndExecute);
|
[{_this setVariable [QGVAR(PlantingExplosive), false]}, _player, 1.5, 0.5] call EFUNC(common,waitAndExecute);
|
||||||
_setup addEventHandler ["EpeContactStart", FUNC(onLanded)];
|
_setup addEventHandler ["EpeContactStart", FUNC(onLanded)];
|
||||||
|
Reference in New Issue
Block a user