Skip to content
This repository has been archived by the owner on May 24, 2022. It is now read-only.

Commit

Permalink
Add initial port of the cse ied modules
Browse files Browse the repository at this point in the history
  • Loading branch information
thojkooi committed Oct 3, 2016
1 parent eb3ed4c commit ca24582
Show file tree
Hide file tree
Showing 17 changed files with 394 additions and 0 deletions.
1 change: 1 addition & 0 deletions addons/ieds/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z\acex\addons\ieds
8 changes: 8 additions & 0 deletions addons/ieds/ACE_Settings.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class ACE_Settings {
class GVAR(Enabled) {
value = 1;
typeName = "BOOL";
displayName = ECSTRING(common,Enabled);
description = CSTRING(EnabledDesc);
};
};
19 changes: 19 additions & 0 deletions addons/ieds/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -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));
};
};
};
103 changes: 103 additions & 0 deletions addons/ieds/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
class CfgVehicles {
class ACE_Module;
class GVAR(createIed): ACE_Module {
author = "STR_ACE_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 = "Type";
description = "The Type of the IED";
typeName = "NUMBER";
class values {
class land {name="Normal"; value=0; default=1; };
class urban {name="Urban"; value=1; };
};
};

class sizeOfIED {
displayName = "Size";
description = "The size of the IED";
typeName = "NUMBER";
class values {
class small {name="Small"; value=1; default=1; };
class large {name="Large"; value=0; };
};
};

class heightOfIED {
displayName = "Height";
description = "The height that the IED is burried";
typeName = "NUMBER";
class values {
class Above {name="Above Ground"; value=0; default=1; };
class slightly {name="Slightly burried"; value=1; };
class medium {name="Medium burried"; value=2; };
class almost {name="Almost burried"; value=3; };
class fully {name="Fully burried"; 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[] = {};
};
};
};
3 changes: 3 additions & 0 deletions addons/ieds/PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
PREP(createIEDObject);
PREP(moduleInit);
PREP(onIEDActivated);
11 changes: 11 additions & 0 deletions addons/ieds/README.md
Original file line number Diff line number Diff line change
@@ -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)
Binary file added addons/ieds/UI/Icon_Module_Headless_ca.paa
Binary file not shown.
1 change: 1 addition & 0 deletions addons/ieds/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "script_component.hpp"
9 changes: 9 additions & 0 deletions addons/ieds/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "script_component.hpp"

ADDON = false;

#include "PREP.hpp"

GVAR(IED_COLLECTION) = [];

ADDON = true;
17 changes: 17 additions & 0 deletions addons/ieds/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "script_component.hpp"

class CfgPatches {
class ADDON {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"acex_main", "ace_explosives"};
author[]= {"Glowbal"};
authorUrl = "https://github.com/glowbal";
VERSION_CONFIG;
};
};

#include "ACE_Settings.hpp"
#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
71 changes: 71 additions & 0 deletions addons/ieds/functions/fnc_createIEDObject.sqf
Original file line number Diff line number Diff line change
@@ -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"];

private ["_logic","_typeOfIED", "_sizeOfIED", "_heightOfIED", "_iedClass", "_iedCreated"];

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 (getPos _logic);

_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);
_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;
}];

_iedCreated;
73 changes: 73 additions & 0 deletions addons/ieds/functions/fnc_moduleInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Author: Glowbal
*
* Arguments:
* 0: <BOOL>
*
* 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];
18 changes: 18 additions & 0 deletions addons/ieds/functions/fnc_moduleZeus.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
/*
* Author: Glowbal
*
* Arguments:
* 0: <BOOL>
*
* Return Value:
* None
*
* Public: No
*/
#include "script_component.hpp"

params ["_logic", "_units", "_activated"];

if (!local _logic) exitwith {};

[_logic] call FUNC(createIEDObject);
37 changes: 37 additions & 0 deletions addons/ieds/functions/fnc_onIEDActivated.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

#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 {
[_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;
1 change: 1 addition & 0 deletions addons/ieds/functions/script_component.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "\z\acex\addons\ieds\script_component.hpp"
Loading

0 comments on commit ca24582

Please sign in to comment.