diff --git a/addons/ieds/$PBOPREFIX$ b/addons/ieds/$PBOPREFIX$ new file mode 100644 index 00000000..5a223709 --- /dev/null +++ b/addons/ieds/$PBOPREFIX$ @@ -0,0 +1 @@ +z\acex\addons\ieds diff --git a/addons/ieds/ACE_Settings.hpp b/addons/ieds/ACE_Settings.hpp new file mode 100644 index 00000000..52c61518 --- /dev/null +++ b/addons/ieds/ACE_Settings.hpp @@ -0,0 +1,8 @@ +class ACE_Settings { + class GVAR(Enabled) { + value = 1; + typeName = "BOOL"; + displayName = ECSTRING(common,Enabled); + description = CSTRING(EnabledDesc); + }; +}; diff --git a/addons/ieds/CfgEventHandlers.hpp b/addons/ieds/CfgEventHandlers.hpp new file mode 100644 index 00000000..86491222 --- /dev/null +++ b/addons/ieds/CfgEventHandlers.hpp @@ -0,0 +1,19 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_FILE(XEH_postInit)); + }; +}; + +class Extended_InitPost_EventHandlers { + class AllVehicles { + class ADDON { + serverInit = QUOTE(_this call FUNC(handleInitPost)); + }; + }; +}; diff --git a/addons/ieds/CfgVehicles.hpp b/addons/ieds/CfgVehicles.hpp new file mode 100644 index 00000000..03e6c2ba --- /dev/null +++ b/addons/ieds/CfgVehicles.hpp @@ -0,0 +1,130 @@ +class CfgVehicles { + class ACE_Module; + class GVAR(createIed): ACE_Module { + author = ACECSTRING(common,ACETeam); + category = "ACE_missionModules"; + displayName = CSTRING(Module); + function = QFUNC(moduleInit); + scope = 2; + isGlobal = 1; // Global + isTriggerActivated = 0; + isDisposable = 0; + // icon = ""; // TODO add module icon + class Arguments { + class typeOfIED { + displayName = CSTRING(Type); + description = CSTRING(Type_Description); + typeName = "NUMBER"; + class values { + class land { + name = CSTRING(Type_Normal); + value = 0; default = 1; + }; + class urban { + name = CSTRING(Type_Urban); + value = 1; + }; + }; + }; + class sizeOfIED { + displayName = CSTRING(Size); + description = CSTRING(Size_Description); + typeName = "NUMBER"; + class values { + class small { + name = CSTRING(Size_Normal); + value = 0; default = 1; + }; + class large { + name = CSTRING(Size_Urban); + value = 1; + }; + }; + }; + + class heightOfIED { + displayName = CSTRING(Height); + description = CSTRING(Height_Description); + typeName = "NUMBER"; + class values { + class Above { + name = CSTRING(Height_AboveGround); + value = 0; + default = 1; + }; + class slightly { + name = CSTRING(Height_SlightlyBurried); + value = 1; + }; + class medium { + name = CSTRING(Height_MediumBurried); + value = 2; + }; + class almost { + name = CSTRING(Height_AlmostBurried); + value = 3; + }; + class fully { + name = CSTRING(Height_FullyBurried); + value = 4; + }; + }; + }; + + class iedActivationType { + displayName = "Activation Type"; + description = "How is the IED activated"; + typeName = "NUMBER"; + class values { + class None {name="None"; value=-1; }; + class PressurePlate {name="Pressure Plate"; value=0; default=1;}; + class Radio {name="Radio"; value=1; }; + }; + }; + + class activatedForTargets { + displayName = "Activated for"; + description = "What types is the IED activated for"; + typeName = "NUMBER"; + class values { + class None {name="None"; value=-1; }; + class All {name="Any type"; value=0; default=1;}; + class Vehicles {name="Any Vehicle"; value=1; }; + class Land {name="Ground Vehicles"; value=2; }; + class Air {name="Airial Vehicles"; value=3; }; + class Man {name="Man"; value=4; }; + }; + }; + + class activatedForSides { + displayName = "What sides activate this IED"; + description = "What types is the IED activated for"; + typeName = "NUMBER"; + class values { + class None {name="None"; value=-1; }; + class All {name="Any side"; value=0; default=1; }; + class West {name="BLUFOR"; value=1; }; + class East {name="OpFOR"; value=2; }; + class Ind {name="Independant"; value=3; }; + class Civ {name="Civilian"; value=4; }; + }; + }; + }; + + class ModuleDescription { + description = CSTRING(ModuleDesc); + }; + }; + + class ace_zeus_moduleBase; + class GVAR(moduleCreateIedZeus): ace_zeus_moduleBase { + curatorCanAttach = 1; + displayName = CSTRING(Module); + function = QFUNC(moduleZeus); + // icon = ""; // TODO icon + class ModuleDescription { + description = "Creates an IED on position"; + sync[] = {}; + }; + }; +}; diff --git a/addons/ieds/PREP.hpp b/addons/ieds/PREP.hpp new file mode 100644 index 00000000..dafb2d7e --- /dev/null +++ b/addons/ieds/PREP.hpp @@ -0,0 +1,3 @@ +PREP(createIEDObject); +PREP(moduleInit); +PREP(onIEDActivated); diff --git a/addons/ieds/README.md b/addons/ieds/README.md new file mode 100644 index 00000000..aaceba9e --- /dev/null +++ b/addons/ieds/README.md @@ -0,0 +1,11 @@ +acex_ieds +============ + +Adds IED mission module framework + + +## Maintainers + +The people responsible for merging changes to this component or answering potential questions. + +- [Glowbal](http://github.com/glowbal) diff --git a/addons/ieds/UI/Icon_Module_Headless_ca.paa b/addons/ieds/UI/Icon_Module_Headless_ca.paa new file mode 100644 index 00000000..a3e23a85 Binary files /dev/null and b/addons/ieds/UI/Icon_Module_Headless_ca.paa differ diff --git a/addons/ieds/XEH_postInit.sqf b/addons/ieds/XEH_postInit.sqf new file mode 100644 index 00000000..421c54b4 --- /dev/null +++ b/addons/ieds/XEH_postInit.sqf @@ -0,0 +1 @@ +#include "script_component.hpp" diff --git a/addons/ieds/XEH_preInit.sqf b/addons/ieds/XEH_preInit.sqf new file mode 100644 index 00000000..eed965cb --- /dev/null +++ b/addons/ieds/XEH_preInit.sqf @@ -0,0 +1,9 @@ +#include "script_component.hpp" + +ADDON = false; + +#include "PREP.hpp" + +GVAR(IED_COLLECTION) = []; + +ADDON = true; diff --git a/addons/ieds/config.cpp b/addons/ieds/config.cpp new file mode 100644 index 00000000..8e9e9208 --- /dev/null +++ b/addons/ieds/config.cpp @@ -0,0 +1,19 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"acex_main", "ace_explosives"}; + author = ACECSTRING(common,ACETeam); + authors[]= {"Glowbal"}; + authorUrl = "https://github.com/glowbal"; + VERSION_CONFIG; + }; +}; + +#include "ACE_Settings.hpp" +#include "CfgEventHandlers.hpp" +#include "CfgVehicles.hpp" diff --git a/addons/ieds/functions/fnc_createIEDObject.sqf b/addons/ieds/functions/fnc_createIEDObject.sqf new file mode 100644 index 00000000..c04d941d --- /dev/null +++ b/addons/ieds/functions/fnc_createIEDObject.sqf @@ -0,0 +1,71 @@ + +#include "script_component.hpp" + +#define LAND_IEDS ["ACE_IEDLandBig_Range", "ACE_IEDLandSmall_Range"] +#define URBAN_IEDS ["ACE_IEDUrbanBig_Range", "ACE_IEDUrbanSmall_Range"] + +params ["_logic"]; + +if (isNull _logic) exitwith {}; + +private _typeOfIED = _logic getvariable ["typeOfIED", 0]; +private _sizeOfIED = _logic getvariable ["sizeOfIED", 0]; +private _heightOfIED = _logic getvariable ["heightOfIED", 0]; + +_heightOfIED = switch (_heightOfIED) do { + case 1: {-0.01}; + case 2: {-0.05}; + case 3: {-0.075}; + case 4: {-0.25}; + default {_heightOfIED}; +}; + +private _iedClass = switch (_typeOfIED) do { + case 0: { LAND_IEDS select _sizeOfIED }; + case 1: { URBAN_IEDS select _sizeOfIED }; +}; + +private _iedCreated = _iedClass createVehicle [0,0,0]; +_iedCreated setPos [getPos _Logic select 0, getPos _Logic select 1, (getPos _Logic select 2) + _heightOfIED]; + +if (_logic getvariable ["iedActivationType", 0] == 0) then { + private _mine = createMine [_iedClass, getPos _iedCreated, [], 0]; + _mine setDir ((getDir _iedCreated) + 90); + _mine setPos _iedCreated; + _iedCreated setvariable [QGVAR(pressurePlate), _mine]; + hideObjectGlobal _mine; +}; + +_logic setvariable [QGVAR(linkedIED), _iedCreated, true]; // TODO do we need a global flag here? +_iedCreated setvariable [QGVAR(linkedIED), _logic, true]; // TODO do we need a global flag here? + +_iedCreated addEventHandler ["Killed", { + params ["_ied", "_killer"]; + + private _logic = _ied getvariable [QGVAR(linkedIED), objNull]; + private _activationType = _logic getvariable ["iedActivationType", 0]; + [_logic] call FUNC(onIEDActivated); + + private _pressurePlate = _ied getvariable [QGVAR(pressurePlate), objNull]; + if (!isNull _pressurePlate) then { + deleteVehicle _pressurePlate; + }; + + if (_activationType == -1) then { + private _iedClass = typeOf _ied; + private _iedPos = getPos _ied; + private _ammoClass = getText(configFile >> "CfgVehicles" >> _iedClass >> "ammo"); + private _dummyIed = _ammoClass createVehicle _iedPos; + _dummyIed setPos _iedPos; + + if (!isNil "ace_frag_fnc_addPfhRound") then { + [objNull, _ammoClass, _dummyIed, true] call ace_frag_fnc_addPfhRound; + }; + _dummyIed setDamage 1; + }; + deleteVehicle _ied; +}]; + +["acex_iedCreated", [_iedCreated, _typeOfIED, _sizeOfIED, _heightOfIED]] call CBA_fnc_localEvent; + +_iedCreated; diff --git a/addons/ieds/functions/fnc_moduleInit.sqf b/addons/ieds/functions/fnc_moduleInit.sqf new file mode 100644 index 00000000..7dc93ee1 --- /dev/null +++ b/addons/ieds/functions/fnc_moduleInit.sqf @@ -0,0 +1,73 @@ +/* + * Author: Glowbal + * + * Arguments: + * 0: + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +params ["_logic", "_units", "_activated"]; + +if (!local _logic) exitwith {}; + +private _collectObjects = { + params ["_logic"]; + + private _collection = synchronizedObjects _logic; + { + if !(_x in _totalCollection) then { + if (typeOf _x == QGVAR(createIed)) then { + if !(_x getvariable [QGVAR(masterIED), false]) then { + _x setvariable [QGVAR(subIED), true]; + _x setvariable [QGVAR(controlledByIED), _logic]; + _totalCollection pushback _x; + [_x] call _collectObjects; + }; + } else { + if (typeOf _x == "cseModule_triggerManLinkIEDS") then { + _list = _x getvariable ["EnableList",""]; + _list = "[" + _list + "]"; + _parsedList = [] call compile _list; + _triggerManList = (_logic getvariable [QGVAR(triggerManUnits), []]) + _parsedList; + _logic setvariable [QGVAR(triggerManUnits), _triggerManList]; + }; + }; + }; + }foreach _collection; +}; + +if !(_logic getvariable [QGVAR(subIED),false]) then { + _logic setvariable [QGVAR(masterIED), true]; + private _totalCollection = [_logic]; + [_logic] call _collectObjects; + _logic setvariable [QGVAR(collection), _totalCollection]; +}; + +[_logic] call FUNC(createIEDObject); + +private _activatedTargets = switch (_logic getvariable ["activatedForTargets", -1]) do { + case 0: {["CaManBase", "Air", "Car", "Motorcycle", "Tank"]}; + case 1: {["Air", "Car", "Motorcycle", "Tank"]}; + case 2: {["Car", "Motorcycle", "Tank"]}; + case 3: {["Air"]}; + case 4: {["CaManBase"]}; + default {[]}; +}; +_logic setvariable ["activatedForTargets", _activatedTargets]; + +private _activatedSides = switch (_logic getvariable ["activatedForSides", -1]) do { + case 0: {[west, east, independent, civilian, sideEnemy, sideFriendly]}; + case 1: {[west, sideEnemy]}; + case 2: {[east, sideEnemy]}; + case 3: {[independent, sideEnemy]}; + case 4: {[civilian, sideEnemy]}; + default {[]}; +}; + +_logic setvariable ["activatedForSides", _activatedSides, true]; +_logic setvariable ["iedActivationType", _logic getvariable ["iedActivationType", 0], true]; diff --git a/addons/ieds/functions/fnc_moduleZeus.sqf b/addons/ieds/functions/fnc_moduleZeus.sqf new file mode 100644 index 00000000..d25dd45a --- /dev/null +++ b/addons/ieds/functions/fnc_moduleZeus.sqf @@ -0,0 +1,18 @@ +/* + * Author: Glowbal + * + * Arguments: + * 0: + * + * Return Value: + * None + * + * Public: No + */ +#include "script_component.hpp" + +params ["_logic", "_units", "_activated"]; + +if (!local _logic) exitwith {}; + +[_logic] call FUNC(createIEDObject); diff --git a/addons/ieds/functions/fnc_onIEDActivated.sqf b/addons/ieds/functions/fnc_onIEDActivated.sqf new file mode 100644 index 00000000..cbc86f40 --- /dev/null +++ b/addons/ieds/functions/fnc_onIEDActivated.sqf @@ -0,0 +1,39 @@ + +#include "script_component.hpp" + +params ["_logic"]; + +private _originalLogic = _logic; + +private _getMasterIED = { + if (_logic getvariable [QGVAR(subIED),false]) then { + _logic = _logic getvariable [QGVAR(controlledByIED), _logic]; + if (_logic getvariable [QGVAR(subIED),false]) then { + call _getMasterIED; + }; + }; +}; +call _getMasterIED; + +private _chain = _logic getvariable [QGVAR(collection), []]; +{ + private _iedLogic = _x; + if (_iedLogic != _originalLogic) then { + _iedLogic setvariable ["iedActivationType", -1]; // disable all other activation methods, we are blowing the entire chain already anway + }; + + private _trigger = _iedLogic getvariable [QGVAR(linkedIED), objNull]; + if (!(isNull _trigger)) then { + ["acex_iedActivated", [_trigger]] call CBA_fnc_localEvent; + + [_iedLogic, _trigger, _logic] spawn { // using a spawn because it doesn't matter to much if an ied isn't detonated at a reliable time + params ["_iedLogic", "_trigger", "_master"]; + if (!isNull _trigger) then { + if ((_iedLogic != _master) && {random(1)>0.1}) then { + uisleep (random(2)); + }; + _trigger setDamage 1; + }; + }; + }; +} forEach _chain; diff --git a/addons/ieds/functions/script_component.hpp b/addons/ieds/functions/script_component.hpp new file mode 100644 index 00000000..75982e07 --- /dev/null +++ b/addons/ieds/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\acex\addons\ieds\script_component.hpp" diff --git a/addons/ieds/script_component.hpp b/addons/ieds/script_component.hpp new file mode 100644 index 00000000..b39c27a2 --- /dev/null +++ b/addons/ieds/script_component.hpp @@ -0,0 +1,20 @@ +#define COMPONENT ieds +#define COMPONENT_BEAUTIFIED IEDs +#include "\z\acex\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define CBA_DEBUG_SYNCHRONOUS +// #define ENABLE_PERFORMANCE_COUNTERS + +#ifdef DEBUG_ENABLED_IEDS + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_IEDS + #define DEBUG_SETTINGS DEBUG_SETTINGS_IEDS +#endif + +#include "\z\acex\addons\main\script_macros.hpp" + +#define DELAY_DEFAULT 15 diff --git a/addons/ieds/stringtable.xml b/addons/ieds/stringtable.xml new file mode 100644 index 00000000..faedf762 --- /dev/null +++ b/addons/ieds/stringtable.xml @@ -0,0 +1,53 @@ + + + + + Create IED + + + Type + + + The Type of the IED + + + Urban + + + Normal + + + Size + + + The Size of the IED + + + Small + + + Large + + + Height + + + The height that the IED is burried + + + Above Ground + + + Slightly burried + + + Medium burried + + + Almost burried + + + Fully burried + + +