Skip to content

Commit

Permalink
Add Zeus module to convert drone into suicide drone (#116)
Browse files Browse the repository at this point in the history
* Sort

* Ignore debug helper

* Add module to convert drone into suicide drone

* Add dependencies

* Update A3 and CBA required versions
  • Loading branch information
Timi007 authored Nov 20, 2024
1 parent 4a12ba8 commit 48f3bce
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 12 deletions.
4 changes: 4 additions & 0 deletions .hemtt/lints.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[sqf.var_all_caps]
options.ignore = [
"MTS_RECOMPILES", "MTS_PREP_RECOMPILE"
]
4 changes: 2 additions & 2 deletions addons/main/script_mod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#define MTS_TAG MTS

// MINIMAL required version for the Mod. Components can specify others..
#define REQUIRED_VERSION 2.06
#define REQUIRED_CBA_VERSION {3,15,2}
#define REQUIRED_VERSION 2.18
#define REQUIRED_CBA_VERSION {3,18,1}

#ifdef COMPONENT_BEAUTIFIED
#define COMPONENT_NAME QUOTE(PREFIX - COMPONENT_BEAUTIFIED)
Expand Down
20 changes: 11 additions & 9 deletions addons/zeus/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
PREP(add3DENCommentsDrawEH);
PREP(addACEUnconsciousIconDrawEH);
PREP(moduleArtillery);
PREP(artyAirburst);
PREP(artyFireMissionHE);
PREP(artyFireMissionSMOKE);
PREP(artyFireMissionILLUM);
PREP(execArtyStrike);
PREP(artyAirburst);
PREP(contextMeasureDistance);
PREP(drawACEUnconsciousIcon);
PREP(execArtyStrike);
PREP(getModuleDestination);
PREP(getTargetKnowledge);
PREP(makeIntoSuicideDrone);
PREP(moduleArtillery);
PREP(moduleSuicideDrone);
PREP(moduleTargetKnowledge);
PREP(moduleUnflipVehicle);
PREP(on3DENMissionSave);
PREP(onZeusDisplayOpen);
PREP(moduleTargetKnowledge);
PREP(setAIStance);
PREP(switchAIPathBehaviour);
PREP(setAIBehaviour);
PREP(setAICombatMode);
PREP(getModuleDestination);
PREP(contextMeasureDistance);
PREP(setAIStance);
PREP(setTargetKnowledge);
PREP(getTargetKnowledge);
PREP(switchAIPathBehaviour);
1 change: 1 addition & 0 deletions addons/zeus/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ call FUNC(moduleUnflipVehicle);
call FUNC(moduleForgetTarget);
call FUNC(moduleRevealTarget);
call FUNC(moduleTargetKnowledge);
call FUNC(moduleSuicideDrone);

call FUNC(contextMeasureDistance);

Expand Down
15 changes: 15 additions & 0 deletions addons/zeus/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,21 @@ ADDON = true;

#include "initSettings.hpp"

// Cache charges for suicide drone
private _chargeCache = +(uiNamespace getVariable "zen_modules_minesCache");
_chargeCache params ["_configNames", "_displayNames"];

private _cfgVehicles = configFile >> "CfgVehicles";
_configNames = [
"DemoCharge_Remote_Ammo_Scripted",
"SatchelCharge_Remote_Ammo_Scripted"
] + _configNames;
_displayNames = [
getText (_cfgVehicles >> "DemoCharge_F" >> "displayName"),
getText (_cfgVehicles >> "SatchelCharge_F" >> "displayName")
] + _displayNames;
GVAR(chargeCache) = [_configNames, _displayNames];

// For 3DEN comments in Zeus
if (is3DEN) then {
add3DENEventHandler ["OnMissionSave", {[false] call FUNC(on3DENMissionSave)}];
Expand Down
11 changes: 10 additions & 1 deletion addons/zeus/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,16 @@ class CfgPatches {
units[] = {};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
requiredAddons[] = {"mts_main", "zen_custom_modules", "zen_dialog", "zen_common", "ace_medical", "ace_zeus"};
requiredAddons[] = {
"mts_main",
"zen_custom_modules",
"zen_dialog",
"zen_common",
"zen_context_menu",
"zen_modules",
"ace_medical",
"ace_zeus"
};
author = ECSTRING(main,authors);
authors[] = {"PhILoX", "Timi007"};
url = ECSTRING(main,URL);
Expand Down
41 changes: 41 additions & 0 deletions addons/zeus/functions/fnc_makeIntoSuicideDrone.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#include "script_component.hpp"
/**
* Author: Timi007
*
* Description:
* Turns the drone unit into a suicide drone. Must be executed where unit is local.
*
* Parameter(s):
* 0: OBJECT - Unit that should get turned into a suicide drone.
* 1: STRING - Vehicle classname of the charge which explodes when the drone is destroyed.
* 2: NUMBER - Maximum ATL height where the charge does not detonate, even when the drone is destroyed.
* Negative number do not set max height. (Default: No max height.)
*
* Returns:
* Nothing.
*
* Example:
* [_unit, "DemoCharge_Remote_Ammo_Scripted"] call mts_zeus_fnc_makeIntoSuicideDrone
*
*/

params [["_unit", objNull, [objNull]], ["_chargeType", "", [""]], ["_maxTriggerHeight", -1, [0]]];
TRACE_2("makeIntoSuicideDrone",_unit,_chargeType);

if (isNull _unit || _chargeType isEqualTo "") exitWith {};
if (!local _unit) exitWith {};
if (_unit getVariable [QGVAR(isSuicideDrone), false]) exitWith {};

[_unit, "Killed", {
_thisArgs params ["_unit", "_chargeType", "_maxTriggerHeight"];

private _posATL = getPosATLVisual _unit;
if ((_posATL select 2) <= _maxTriggerHeight || _maxTriggerHeight < 0) then {
private _charge = createVehicle [_chargeType, _posATL, [], 0, "CAN_COLLIDE"];
_charge setDamage 1;
};

_unit removeEventHandler [_thisType, _thisId];
}, [_unit, _chargeType, _maxTriggerHeight]] call CBA_fnc_addBISEventHandler;

_unit setVariable [QGVAR(isSuicideDrone), true, true];
96 changes: 96 additions & 0 deletions addons/zeus/functions/fnc_moduleSuicideDrone.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include "script_component.hpp"
/**
* Author: Timi007
*
* Description:
* Adds "Make into suicide drone" as modules and to the context menu.
*
* Parameter(s):
* None.
*
* Returns:
* Nothing.
*
* Example:
* call mts_zeus_fnc_moduleSuicideDrone
*
*/

[
LELSTRING(main,category), LLSTRING(suicideDrone),
{
params ["", ["_unit", objNull, [objNull]]];

if (isNull _unit) exitWith {
[LLSTRING(suicideDrone_noObject)] call zen_common_fnc_showMessage;
};

if (!unitIsUAV _unit || {!alive _unit} || {!isNull objectParent _unit}) exitWith {
[LLSTRING(suicideDrone_notADrone)] call zen_common_fnc_showMessage;
};

if (_unit getVariable [QGVAR(isSuicideDrone), false]) exitWith {
[LLSTRING(suicideDrone_isAlreadySuicideDrone)] call zen_common_fnc_showMessage;
};

GVAR(chargeCache) params ["_configNames", "_displayNames"];

[
LLSTRING(suicideDrone),
[
["COMBO", LLSTRING(suicideDrone_charge), [_configNames, _displayNames, 0]]
],
{
params ["_dialogData", "_unit"];
_dialogData params ["_chargeType"];

[_unit, _chargeType] remoteExecCall [QFUNC(makeIntoSuicideDrone), _unit];

[LLSTRING(suicideDrone_success)] call zen_common_fnc_showMessage;
},
{},
_unit
] call zen_dialog_fnc_create;
},
"a3\drones_f\air_f_gamma\uav_01\data\ui\uav_01_ca.paa"
] call zen_custom_modules_fnc_register;

private _suicideDroneAction = [
QGVAR(suicideDrone),
LLSTRING(suicideDrone),
"a3\drones_f\air_f_gamma\uav_01\data\ui\uav_01_ca.paa",
{
params ["", "_objects"];

GVAR(chargeCache) params ["_configNames", "_displayNames"];

[
LLSTRING(suicideDrone),
[
["COMBO", LLSTRING(suicideDrone_charge), [_configNames, _displayNames, 0]]
],
{
params ["_dialogData", "_objects"];
_dialogData params ["_chargeType"];

{
if (!unitIsUAV _unit || {!isNull objectParent _unit}) then {
continue;
};

[_x, _chargeType] remoteExecCall [QFUNC(makeIntoSuicideDrone), _x];
} forEach _objects;

[LLSTRING(suicideDrone_success)] call zen_common_fnc_showMessage;
},
{},
_objects
] call zen_dialog_fnc_create;
},
{
params ["", "_objects"];
({unitIsUAV _x && {!(_x getVariable [QGVAR(isSuicideDrone), false])} && {alive _x} && {isNull objectParent _x}} count _objects) > 0
}
] call zen_context_menu_fnc_createAction;
[_suicideDroneAction, [], 0] call zen_context_menu_fnc_addAction;

26 changes: 26 additions & 0 deletions addons/zeus/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -309,5 +309,31 @@
<German>Feuereröffnung der Gruppe auf feuerfrei geschaltet</German>
</Key>
</Container>
<Container name="suicideDrone">
<Key ID="STR_mts_zeus_suicideDrone">
<Original>Suicide drone</Original>
<German>Kamikaze-Drohne</German>
</Key>
<Key ID="STR_mts_zeus_suicideDrone_charge">
<Original>Charge</Original>
<German>Ladung</German>
</Key>
<Key ID="STR_mts_zeus_suicideDrone_noObject">
<Original>Place the module on a drone!</Original>
<German>Platziere das Modul auf eine Drohne!</German>
</Key>
<Key ID="STR_mts_zeus_suicideDrone_notADrone">
<Original>Unit is not an active drone!</Original>
<German>Einheit ist keine aktive Drohne!</German>
</Key>
<Key ID="STR_mts_zeus_suicideDrone_isAlreadySuicideDrone">
<Original>Drone is already a suicide drone!</Original>
<German>Drohne ist bereits eine Kamikaze-Drohne!</German>
</Key>
<Key ID="STR_mts_zeus_suicideDrone_success">
<Original>Converted drone into suicide drone.</Original>
<German>Drohne in Kamikaze-Drohne umgewandelt.</German>
</Key>
</Container>
</Package>
</Project>

0 comments on commit 48f3bce

Please sign in to comment.