mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Merge pull request #1414 from acemod/Explosives_ZeusCompatible
Made explosives Zeus and AI compatible specifically in regards to Dea…
This commit is contained in:
commit
e2970ab40e
@ -9,12 +9,19 @@ class Extended_PostInit_EventHandlers {
|
||||
};
|
||||
};
|
||||
|
||||
/*
|
||||
TODO: Move the addEventHandlers out of PostInit into here or separate eventHandlers,
|
||||
to enable them on all units, so unit switching works for explosives properly.
|
||||
class Extended_Init_EventHandlers {
|
||||
class CAManBase {
|
||||
init = "";
|
||||
}
|
||||
}
|
||||
*/
|
||||
class Extended_Killed_EventHandlers {
|
||||
class CAManBase {
|
||||
GVAR(killedHandler) = QUOTE(_this call FUNC(onKilled));
|
||||
};
|
||||
};
|
||||
|
||||
class Extended_Take_EventHandlers {
|
||||
class CAManBase {
|
||||
GVAR(takeHandler) = QUOTE([ARR_3(_this select 0, _this select 1, _this select 2)] call FUNC(onInventoryChanged));
|
||||
};
|
||||
};
|
||||
class Extended_Put_EventHandlers {
|
||||
class CAManBase {
|
||||
GVAR(takeHandler) = QUOTE([ARR_3(_this select 1, _this select 0, _this select 2)] call FUNC(onInventoryChanged));
|
||||
};
|
||||
};
|
||||
|
@ -50,47 +50,3 @@ GVAR(CurrentSpeedDial) = 0;
|
||||
}] call EFUNC(common,addEventHandler);
|
||||
|
||||
[{(_this select 0) call FUNC(handleScrollWheel);}] call EFUNC(Common,addScrollWheelEventHandler);
|
||||
player addEventHandler ["Killed", {
|
||||
private "_deadman";
|
||||
call FUNC(place_Cancel);
|
||||
_deadman = [(_this select 0), "DeadManSwitch"] call FUNC(getPlacedExplosives);
|
||||
{
|
||||
[(_this select 0), -1, _x, true] call FUNC(detonateExplosive);
|
||||
} count _deadman;
|
||||
}];
|
||||
player addEventHandler ["Take", {
|
||||
private ["_item", "_getter", "_giver", "_config", "_detonators"];
|
||||
_item = _this select 2;
|
||||
_getter = _this select 0;
|
||||
_giver = _this select 1;
|
||||
|
||||
_config = ConfigFile >> "CfgWeapons" >> _item;
|
||||
if (isClass _config && {getNumber(_config >> "ACE_Detonator") == 1}) then {
|
||||
private ["_clackerItems"];
|
||||
_clackerItems = _giver getVariable [QGVAR(Clackers), []];
|
||||
_getter SetVariable [QGVAR(Clackers), (_getter getVariable [QGVAR(Clackers), []]) + _clackerItems, true];
|
||||
|
||||
_detonators = [_giver] call FUNC(getDetonators);
|
||||
if (count _detonators == 0) then {
|
||||
_giver setVariable [QGVAR(Clackers), nil, true];
|
||||
};
|
||||
};
|
||||
}];
|
||||
player addEventHandler ["Put", {
|
||||
private ["_item", "_getter", "_giver", "_config"];
|
||||
_item = _this select 2;
|
||||
_getter = _this select 1;
|
||||
_giver = _this select 0;
|
||||
|
||||
_config = ConfigFile >> "CfgWeapons" >> _item;
|
||||
if (isClass _config && {getNumber(_config >> "ACE_Detonator") == 1}) then {
|
||||
private ["_clackerItems"];
|
||||
_clackerItems = _giver getVariable [QGVAR(Clackers), []];
|
||||
_getter SetVariable [QGVAR(Clackers), (_getter getVariable [QGVAR(Clackers), []]) + _clackerItems, true];
|
||||
|
||||
_detonators = [_giver] call FUNC(getDetonators);
|
||||
if (count _detonators == 0) then {
|
||||
_giver setVariable [QGVAR(Clackers), nil, true];
|
||||
};
|
||||
};
|
||||
}];
|
||||
|
@ -42,6 +42,8 @@ PREP(getSpeedDialExplosive);
|
||||
|
||||
PREP(module);
|
||||
|
||||
PREP(onInventoryChanged);
|
||||
PREP(onKilled);
|
||||
PREP(onLanded);
|
||||
|
||||
PREP(openTimerSetUI);
|
||||
|
35
addons/explosives/functions/fnc_onInventoryChanged.sqf
Normal file
35
addons/explosives/functions/fnc_onInventoryChanged.sqf
Normal file
@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet
|
||||
* When a take/put event handler fires and a detonator is changed hands.
|
||||
* Then take "attached" explosives.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Receiver <OBJECT>
|
||||
* 1: Giver <OBJECT>
|
||||
* 2: Item <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* Handled by CBA
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
private ["_config", "_detonators"];
|
||||
PARAMS_3(_receiver,_giver,_item);
|
||||
|
||||
if (_receiver != ace_player) exitWith {};
|
||||
|
||||
_config = ConfigFile >> "CfgWeapons" >> _item;
|
||||
if (isClass _config && {getNumber(_config >> "ACE_Detonator") == 1}) then {
|
||||
private ["_clackerItems"];
|
||||
_clackerItems = _giver getVariable [QGVAR(Clackers), []];
|
||||
_receiver SetVariable [QGVAR(Clackers), (_receiver getVariable [QGVAR(Clackers), []]) + _clackerItems, true];
|
||||
|
||||
_detonators = [_giver] call FUNC(getDetonators);
|
||||
if (count _detonators == 0) then {
|
||||
_giver setVariable [QGVAR(Clackers), nil, true];
|
||||
};
|
||||
};
|
26
addons/explosives/functions/fnc_onKilled.sqf
Normal file
26
addons/explosives/functions/fnc_onKilled.sqf
Normal file
@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Author: Garth 'L-H' de Wet
|
||||
* Detonates all attached deadman's switched triggered explosives.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* None
|
||||
*
|
||||
* Example:
|
||||
* Handled by CBA
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
private ["_deadman"];
|
||||
_unit = _this select 0;
|
||||
if (_unit == ACE_player) then {
|
||||
call FUNC(place_Cancel);
|
||||
};
|
||||
if (!isServer) exitWith{};
|
||||
_deadman = [_unit, "DeadManSwitch"] call FUNC(getPlacedExplosives);
|
||||
{
|
||||
[_unit, -1, _x, true] call FUNC(detonateExplosive);
|
||||
} foreach _deadman;
|
Loading…
Reference in New Issue
Block a user