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

WIP: Add initial port of the cse ied modules #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
};
};
};
130 changes: 130 additions & 0 deletions addons/ieds/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

^ See above. I don't know on what machine this will be executed. Every machine? The Server? The Zeus-Client?

// 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;
19 changes: 19 additions & 0 deletions addons/ieds/config.cpp
Original file line number Diff line number Diff line change
@@ -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"
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"];

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only works on the server
https://community.bistudio.com/wiki/hideObjectGlobal
But it can be called by a zeus dedicated client via the module.

};

_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;
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);
Loading