Skip to content

Commit

Permalink
Merge pull request #1295 from SilentSpike/master
Browse files Browse the repository at this point in the history
New zeus modules (#130)
  • Loading branch information
thojkooi committed Jun 1, 2015
2 parents 47acb0f + e3c09a7 commit 4356b16
Show file tree
Hide file tree
Showing 25 changed files with 339 additions and 101 deletions.
4 changes: 1 addition & 3 deletions addons/captives/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,6 @@ class CfgVehicles {
displayName = "$STR_ACE_Captives_ModuleSurrender_DisplayName"; //Make Unit Surrender
function = QUOTE(DFUNC(moduleSurrender));
scope = 2; //show in editor
scopeCurator = 2; //show in zeus
curatorCost = 0; //???
isGlobal = 1; //run global
isTriggerActivated = 1; //Wait for triggers
icon = QUOTE(PATHTOF(UI\Icon_Module_Make_Unit_Surrender_ca.paa));
Expand All @@ -176,4 +174,4 @@ class CfgVehicles {
sync[] = {"AnyAI"};
};
};
};
};
38 changes: 7 additions & 31 deletions addons/captives/functions/fnc_moduleSurrender.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,37 +23,13 @@ private ["_bisMouseOver", "_mouseOverObject"];
if (!_activated) exitWith {};

if (local _logic) then {
if ((!isnull curatorcamera) && {((count curatorMouseOver) == 2) && {(curatorMouseOver select 1) == _logic}}) then {//in zeus interface and we placed the module
_bisMouseOver = missionNamespace getVariable ["bis_fnc_curatorObjectPlaced_mouseOver", []];//bis caches the previous curatorMouseOver
if ((count _bisMouseOver) == 2) then {//check what mouse was over before the module was placed
_mouseOverObject = _bisMouseOver select 1;
if ((_mouseOverObject isKindOf "CAManBase") && {(vehicle _mouseOverObject) == _mouseOverObject}) then {
TRACE_2("Debug - module surrendering %1",_mouseOverObject,(name _mouseOverObject));
if (alive _mouseOverObject) then {
if (!(_mouseOverObject getVariable [QGVAR(isSurrendering), false])) then {
["SetSurrendered", [_mouseOverObject], [_mouseOverObject, true]] call EFUNC(common,targetEvent);
} else {
["SetSurrendered", [_mouseOverObject], [_mouseOverObject, false]] call EFUNC(common,targetEvent);
};
} else {
["STR_ACE_Captives_Zeus_OnlyAlive"] call EFUNC(common,displayTextStructured);
};
} else {
["STR_ACE_Captives_Zeus_OnlyInfantry"] call EFUNC(common,displayTextStructured);
};
} else {
["STR_ACE_Captives_Zeus_NothingSelected"] call EFUNC(common,displayTextStructured);
};
} else {
//an editor module
//Modules run before postInit can instal the event handler, so we need to wait a little bit
[{
PARAMS_1(_units);
{
["SetSurrendered", [_x], [_x, true]] call EFUNC(common,targetEvent);
} forEach _units;
}, [_units], 0.05, 0.05]call EFUNC(common,waitAndExecute);
};
//Modules run before postInit can instal the event handler, so we need to wait a little bit
[{
PARAMS_1(_units);
{
["SetSurrendered", [_x], [_x, true]] call EFUNC(common,targetEvent);
} forEach _units;
}, [_units], 0.05, 0.05]call EFUNC(common,waitAndExecute);

deleteVehicle _logic;
};
36 changes: 0 additions & 36 deletions addons/captives/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,42 +157,6 @@
<Hungarian>Megadás abbahagyása</Hungarian>
<Italian>Smetti di arrenderti</Italian>
</Key>
<Key ID="STR_ACE_Captives_Zeus_OnlyAlive">
<English>Only use on alive units</English>
<French>Utiliser uniquement sur une unité vivante</French>
<German>Nur bei lebenden Einheiten verwendbar</German>
<Spanish>Utilizar solo en unidades vivas</Spanish>
<Czech>Použitelné jen na živé jednotky</Czech>
<Polish>Używaj tylko na żywych jednostkach</Polish>
<Russian>Применимо только к живым юнитам</Russian>
<Hungarian>Csak élő egységeken használni</Hungarian>
<Italian>Si può fare solo su persone vive</Italian>
<Portuguese>Usar somente em unidades vivas</Portuguese>
</Key>
<Key ID="STR_ACE_Captives_Zeus_OnlyInfantry">
<English>Only use on dismounted inf</English>
<French>Utiliser uniquement sur du personnel à pied</French>
<German>Nur bei abgesessener Infanterie verwendbar</German>
<Spanish>Utilizar solo en infanteria desmontada</Spanish>
<Czech>Použitelné jen na pěsích jednotkách</Czech>
<Polish>Używaj tylko na piechocie poza wszelkimi pojazdami</Polish>
<Russian>Применимо только к пехоте вне техники</Russian>
<Hungarian>Csak járműben kívül lévő egységeken használni</Hungarian>
<Italian>Si può usare solo su fanteria a piedi</Italian>
<Portuguese>Usar somente em infantaria desmontada</Portuguese>
</Key>
<Key ID="STR_ACE_Captives_Zeus_NothingSelected">
<English>Nothing under mouse</English>
<French>Rien sous le curseur</French>
<German>Es wurde nichts ausgewählt</German>
<Spanish>Nada bajo el ratón</Spanish>
<Portuguese>Nada debaixo do mouse</Portuguese>
<Czech>Nic není vybráno</Czech>
<Polish>Nie ma nic pod kursorem</Polish>
<Russian>Ничего не выделено</Russian>
<Hungarian>Semmi sincs az egér alatt</Hungarian>
<Italian>Nessuna selezione</Italian>
</Key>
<Key ID="STR_ACE_Captives_ModuleSurrender_DisplayName">
<English>Make Unit Surrender</English>
<Polish>Poddaj się!</Polish>
Expand Down
6 changes: 0 additions & 6 deletions addons/zeus/CfgFactionClasses.hpp

This file was deleted.

60 changes: 47 additions & 13 deletions addons/zeus/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,24 @@ class CfgVehicles {
class ModuleEmpty_F;
class ACE_Module;

class GVAR(moduleZeusSettings): ACE_Module {
class ModuleCurator_F: Module_F {
function = QFUNC(bi_moduleCurator);
};
class ModuleMine_F: ModuleEmpty_F {
function = QFUNC(bi_moduleMine);
};
class ModuleOrdnance_F: Module_F {
function = QFUNC(bi_moduleProjectile);
};
class ModuleRemoteControl_F: Module_F {
function = QFUNC(bi_moduleRemoteControl);
};
class GVAR(moduleSettings): ACE_Module {
scope = 2;
displayName = "$STR_ACE_Zeus_Module_DisplayName";
//icon = QUOTE(PATHTOF(iconGoesHere));
category = "ACE_zeus";
function = QUOTE(DFUNC(moduleZeusSettings));
icon = QUOTE(PATHTOF(UI\Icon_Module_Zeus_Settings_ca.paa));
category = "ACE";
function = QFUNC(moduleZeusSettings);
functionPriority = 1;
isGlobal = 1;
isTriggerActivated = 0;
Expand Down Expand Up @@ -64,17 +76,39 @@ class CfgVehicles {
sync[] = {};
};
};

class ModuleCurator_F: Module_F {
function = QUOTE(DFUNC(bi_moduleCurator));
class GVAR(moduleBase): Module_F {
author = "SilentSpike";
category = "ACE";
scopeCurator = 2;
};
class ModuleMine_F: ModuleEmpty_F {
function = QUOTE(DFUNC(bi_moduleMine));
class GVAR(moduleCaptive): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = "$STR_ACE_Zeus_ModuleCaptive_DisplayName";
function = QFUNC(moduleCaptive);
icon = QUOTE(PATHTOF(UI\Icon_Module_Zeus_Captive_ca.paa));
class ModuleDescription {
description = "Flips the capture state of the specified unit.";
sync[] = {};
};
};
class ModuleOrdnance_F: Module_F {
function = QUOTE(DFUNC(bi_moduleProjectile));
class GVAR(moduleSurrender): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = "$STR_ACE_Zeus_ModuleSurrender_DisplayName";
function = QFUNC(moduleSurrender);
icon = QUOTE(PATHTOF(UI\Icon_Module_Zeus_Surrender_ca.paa));
class ModuleDescription {
description = "Flips the surrender state of the specified unit.";
sync[] = {};
};
};
class ModuleRemoteControl_F: Module_F {
function = QUOTE(DFUNC(bi_moduleRemoteControl));
class GVAR(moduleUnconscious): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = "$STR_ACE_Zeus_ModuleUnconscious_DisplayName";
function = QFUNC(moduleUnconscious);
icon = QUOTE(PATHTOF(UI\Icon_Module_Zeus_Unconscious_ca.paa));
class ModuleDescription {
description = "Flips the unconscious state of the specified unit.";
sync[] = {};
};
};
};
8 changes: 8 additions & 0 deletions addons/zeus/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@ PREP(bi_moduleCurator);
PREP(bi_moduleMine);
PREP(bi_moduleProjectile);
PREP(bi_moduleRemoteControl);
PREP(handleZeusUnitAssigned);
PREP(moduleCaptive);
PREP(moduleSurrender);
PREP(moduleUnconscious);
PREP(moduleZeusSettings);

if (isServer) then {
["zeusUnitAssigned", FUNC(handleZeusUnitAssigned)] call EFUNC(common,addEventHandler);
};

ADDON = true;
18 changes: 17 additions & 1 deletion addons/zeus/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,25 @@ class CfgPatches {
authorUrl = "https://github.com/SilentSpike";
VERSION_CONFIG;
};
// Use additional cfgPatches to contextually remove modules from zeus
class GVAR(captives): ADDON {
units[] = {
QGVAR(moduleCaptive),
QGVAR(moduleSurrender)
};
};
class GVAR(medical): ADDON {
units[] = {
QGVAR(moduleUnconscious)
};
};
};

class ACE_Curator {
GVAR(captives) = "ace_captives";
GVAR(medical) = "ace_medical";
};

#include "CfgEventHandlers.hpp"
#include "CfgFactionClasses.hpp"
#include "CfgVehicles.hpp"
#include "ACE_Settings.hpp"
8 changes: 7 additions & 1 deletion addons/zeus/functions/fnc_bi_moduleCurator.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,12 @@
* Author: Bohemia Interactive
* Module function for initalizing zeus
* Edited to remove eagle and global ascension message
* Added "zeusUnitAssigned" event call
*
* Arguments:
* 0: The logic object <OBJECT>
* 0: The module logic <LOGIC>
* 1: units <ARRAY>
* 2: activated <BOOL>
*
* Return Value:
* nil
Expand Down Expand Up @@ -169,6 +172,9 @@ if (_activated) then {

[_logic,"curatorUnitAssigned",[_logic,_player]] call bis_fnc_callscriptedeventhandler;

// Added by ACE_zeus
["zeusUnitAssigned", [_logic,_player]] call EFUNC(common,globalEvent);

//--- Forced interface
//if (_forced) then {
// [[true,true],"bis_fnc_forceCuratorInterface",_player] call bis_fnc_mp;
Expand Down
4 changes: 3 additions & 1 deletion addons/zeus/functions/fnc_bi_moduleMine.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* Edited to remove forced map markers and mines being revealed to players
*
* Arguments:
* 0: The logic object <OBJECT>
* 0: The module logic <LOGIC>
* 1: units <ARRAY>
* 2: activated <BOOL>
*
* Return Value:
* nil
Expand Down
4 changes: 3 additions & 1 deletion addons/zeus/functions/fnc_bi_moduleProjectile.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
* Edited to remove radio warning and add ballistics support
*
* Arguments:
* 0: The logic object <OBJECT>
* 0: The module logic <LOGIC>
* 1: units <ARRAY>
* 2: activated <BOOL>
*
* Return Value:
* nil
Expand Down
4 changes: 3 additions & 1 deletion addons/zeus/functions/fnc_bi_moduleRemoteControl.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* Edited to remove global wind sound
*
* Arguments:
* 0: The logic object <OBJECT>
* 0: The module logic <LOGIC>
* 1: units <ARRAY>
* 2: activated <BOOL>
*
* Return Value:
* nil
Expand Down
50 changes: 50 additions & 0 deletions addons/zeus/functions/fnc_handleZeusUnitAssigned.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* Author: SilentSpike
* Contextually removes addons (given in ACE_Curator) from zeus based on their required addon(s)
*
* ACE_Curator format:
* ModuleAddon = "RequiredAddon";
* OR
* ModuleAddon[] = {"RequiredAddon1","RequiredAddon2",...}
*
* Arguments:
* 0: The zeus logic <LOGIC>
* 1: The zeus player <UNIT>
*
* Return Value:
* nil
*
* Public: No
*/

#include "script_component.hpp"

private ["_logic","_removeAddons","_numCfgs","_cfg","_requiredAddon"];

if !(isClass (configFile >> "ACE_Curator")) exitWith { ERROR("The ACE_Curator class does not exist") };

_logic = _this select 0;
_removeAddons = [];

_numCfgs = count (configFile >> "ACE_Curator");
for "_n" from 0 to (_numCfgs - 1) do {
_cfg = (configFile >> "ACE_Curator") select _n;

if (isArray _cfg) then {
_requiredAddon = getArray _cfg;
{
if !(isClass (configFile >> "CfgPatches" >> _x)) exitWith {
_removeAddons pushBack (configName _cfg);
};
} forEach _requiredAddon;
};

if (isText _cfg) then {
_requiredAddon = getText _cfg;
if !(isClass (configFile >> "CfgPatches" >> _requiredAddon)) then {
_removeAddons pushBack (configName _cfg);
};
};
};

_logic removeCuratorAddons _removeAddons;
45 changes: 45 additions & 0 deletions addons/zeus/functions/fnc_moduleCaptive.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Author: SilentSpike
* Flips the capture state of the unit the module is attached to.
*
* Arguments:
* 0: The module logic <LOGIC>
* 1: units <ARRAY>
* 2: activated <BOOL>
*
* ReturnValue:
* nil
*
* Public: no
*/

#include "script_component.hpp"

PARAMS_3(_logic,_units,_activated);
private ["_unit","_captive"];

if (!_activated) exitWith {};

if (isNil QEFUNC(captives,setHandcuffed)) then {
["STR_ACE_Zeus_RequiresAddon"] call EFUNC(common,displayTextStructured);
} else {
_unit = attachedTo _logic;

if (isNull _unit) then {
["STR_ACE_Zeus_NothingSelected"] call EFUNC(common,displayTextStructured);
} else {
if !(_unit isKindOf "CAManBase") then {
["STR_ACE_Zeus_OnlyInfantry"] call EFUNC(common,displayTextStructured);
} else {
if !(alive _unit) then {
["STR_ACE_Zeus_OnlyAlive"] call EFUNC(common,displayTextStructured);
} else {
_captive = GETVAR(_unit,EGVAR(captives,isHandcuffed),false);
// Event initalized by ACE_Captives
["SetHandcuffed", _unit, [_unit, !_captive]] call EFUNC(common,targetEvent);
};
};
};
};

deleteVehicle _logic;
Loading

0 comments on commit 4356b16

Please sign in to comment.