mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #1417 from acemod/localDefuseObjects
Explosives - Local defuse objects
This commit is contained in:
commit
23d300df52
@ -15,28 +15,10 @@
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
//Start up a PFEH that scans all mines/explosives without defuseObjects attached and adds them
|
||||
//Handles Editor Placed / Zeus / Scripted
|
||||
if (isServer) then {
|
||||
[{
|
||||
private ["_explosive", "_helpers", "_defuseHelper"];
|
||||
{
|
||||
_explosive = _x;
|
||||
_helpers = {
|
||||
((typeOf _x) == "ACE_DefuseObject") && {(_x getVariable [QGVAR(Explosive), objNull]) == _explosive}
|
||||
} count (attachedObjects _explosive);
|
||||
|
||||
if (_helpers == 0) then {
|
||||
TRACE_3("Explosive without helper",_explosive,(getPosAsl _explosive),(typeOf _explosive));
|
||||
_defuseHelper = createVehicle ["ACE_DefuseObject", (getPos _explosive), [], 0, "NONE"];
|
||||
_defuseHelper attachTo [_explosive, [0,0,0], ""];
|
||||
_defuseHelper setVariable [QGVAR(Explosive),_explosive,true];
|
||||
};
|
||||
} forEach allMines;
|
||||
}, 5, []] call CBA_fnc_addPerFrameHandler;
|
||||
};
|
||||
|
||||
if !(hasInterface) exitWith {};
|
||||
|
||||
["interactMenuOpened", {_this call FUNC(interactEH)}] call EFUNC(common,addEventHandler);
|
||||
|
||||
GVAR(PlacedCount) = 0;
|
||||
GVAR(Setup) = objNull;
|
||||
GVAR(pfeh_running) = false;
|
||||
|
@ -36,6 +36,8 @@ PREP(handleScrollWheel);
|
||||
PREP(hasExplosives);
|
||||
PREP(hasPlacedExplosives);
|
||||
|
||||
PREP(interactEH);
|
||||
|
||||
PREP(getDetonators);
|
||||
PREP(getPlacedExplosives);
|
||||
PREP(getSpeedDialExplosive);
|
||||
|
@ -21,10 +21,4 @@ if (getNumber (ConfigFile >> "CfgAmmo" >> typeof _explosive >> "ACE_explodeOnDef
|
||||
[_unit, -1, [_explosive, 1], true] call FUNC(detonateExplosive);
|
||||
};
|
||||
|
||||
{
|
||||
detach _x;
|
||||
deleteVehicle _x;
|
||||
false
|
||||
} count (attachedObjects (_explosive));
|
||||
|
||||
_unit action ["Deactivate", _unit, _explosive];
|
||||
|
@ -26,12 +26,6 @@ _result = true;
|
||||
|
||||
if (!_ignoreRange && {(_unit distance (_item select 0)) > _range}) exitWith {false};
|
||||
|
||||
_helpers = attachedObjects (_item select 0);
|
||||
{
|
||||
detach _x;
|
||||
deleteVehicle _x;
|
||||
} forEach _helpers;
|
||||
|
||||
if (getNumber (ConfigFile >> "CfgAmmo" >> typeof (_item select 0) >> "TriggerWhenDestroyed") == 0) then {
|
||||
private ["_exp", "_previousExp"];
|
||||
_previousExp = _item select 0;
|
||||
|
56
addons/explosives/functions/fnc_interactEH.sqf
Normal file
56
addons/explosives/functions/fnc_interactEH.sqf
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
* Author: PabstMirror
|
||||
* When interact_menu starts rendering (from "interact_keyDown" event)
|
||||
* Add defuse helpers to all nearby mines
|
||||
*
|
||||
* Arguments:
|
||||
* Interact Menu Type (0 - world, 1 - self) <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [0] call ace_explosives_fnc_interactEH
|
||||
*
|
||||
* Public: Yes
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
PARAMS_1(_interactionType);
|
||||
|
||||
//Ignore self-interaction menu
|
||||
if (_interactionType != 0) exitWith {};
|
||||
//Ignore while mounted:
|
||||
if ((vehicle ACE_player) != ACE_player) exitWith {};
|
||||
//Ignore if we don't have defuse kit
|
||||
if (!("ACE_DefusalKit" in (items ACE_player))) exitWith {};
|
||||
|
||||
[{
|
||||
PARAMS_2(_args,_pfID);
|
||||
EXPLODE_3_PVT(_args,_setPosition,_addedDefuseHelpers,_minesHelped);
|
||||
|
||||
if (!EGVAR(interact_menu,keyDown)) then {
|
||||
TRACE_1("Cleaning Defuse Helpers",(count _addedDefuseHelpers));
|
||||
{deleteVehicle _x;} forEach _addedDefuseHelpers;
|
||||
[_pfID] call CBA_fnc_removePerFrameHandler;
|
||||
} else {
|
||||
private ["_defuseHelper"];
|
||||
// Prevent Rare Error when ending mission with interact key down:
|
||||
if (isNull ace_player) exitWith {};
|
||||
|
||||
//If player moved >5 meters from last pos, then rescan
|
||||
if (((getPosASL ace_player) distance _setPosition) > 5) then {
|
||||
{
|
||||
if (((_x distance ACE_player) < 15) && {!(_x in _minesHelped)}) then {
|
||||
TRACE_2("Making Defuse Helper",(_x),(typeOf _x));
|
||||
_defuseHelper = "ACE_DefuseObject" createVehicleLocal (getPos _x);
|
||||
_defuseHelper attachTo [_x, [0,0,0]];
|
||||
_defuseHelper setVariable [QGVAR(Explosive),_x];
|
||||
_addedDefuseHelpers pushBack _defuseHelper;
|
||||
_minesHelped pushBack _x;
|
||||
};
|
||||
} forEach allMines;
|
||||
_args set [0, (getPosASL ace_player)];
|
||||
};
|
||||
};
|
||||
}, 0.5, [((getPosASL ace_player) vectorAdd [-100,0,0]), [], []]] call CBA_fnc_addPerFrameHandler;
|
@ -51,16 +51,8 @@ if (isText(_magazineTrigger >> "ammo")) then {
|
||||
_ammo = getText (_magazineTrigger >> "ammo");
|
||||
};
|
||||
_triggerSpecificVars pushBack _triggerConfig;
|
||||
private ["_defuseHelper"];
|
||||
_defuseHelper = createVehicle ["ACE_DefuseObject", _pos, [], 0, "NONE"];
|
||||
_defuseHelper setPosATL _pos;
|
||||
|
||||
_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;
|
||||
|
||||
if (!isNull _attachedTo) then {
|
||||
|
@ -37,7 +37,7 @@ if (_dir > 180) then {
|
||||
} else {
|
||||
_dir = 180 + _dir;
|
||||
};
|
||||
_setup setVariable [QGVAR(Direction), _dir];
|
||||
_setup setVariable [QGVAR(Direction), _dir, true];
|
||||
_player setVariable [QGVAR(PlantingExplosive), true];
|
||||
[{_this setVariable [QGVAR(PlantingExplosive), false]}, _player, 1.5, 0.5] call EFUNC(common,waitAndExecute);
|
||||
_setup addEventHandler ["EpeContactStart", FUNC(onLanded)];
|
||||
|
Loading…
Reference in New Issue
Block a user