Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Create/Edit Intel module #94

Merged
merged 9 commits into from
Oct 13, 2019
Merged
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/common/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@
[QGVAR(setDate), {setDate _this}] call CBA_fnc_addEventHandler;

[QGVAR(earthquake), LINKFUNC(earthquake)] call CBA_fnc_addEventHandler;
[QGVAR(showMessage), LINKFUNC(showMessage)] call CBA_fnc_addEventHandler;

[QGVAR(setMagazineAmmo), FUNC(setMagazineAmmo)] call CBA_fnc_addEventHandler;
[QGVAR(setTurretAmmo), FUNC(setTurretAmmo)] call CBA_fnc_addEventHandler;
Expand Down
2 changes: 1 addition & 1 deletion addons/main/script_mod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

// MINIMAL required version for the Mod. Components can specify others..
#define REQUIRED_VERSION 1.92
#define REQUIRED_CBA_VERSION {3,10,1}
#define REQUIRED_CBA_VERSION {3,12,0}

#ifdef COMPONENT_BEAUTIFIED
#define COMPONENT_NAME QUOTE(ZEN - COMPONENT_BEAUTIFIED)
Expand Down
16 changes: 11 additions & 5 deletions addons/modules/CfgVehicles.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,12 @@ class CfgVehicles {
function = QFUNC(moduleCreateIED);
icon = QPATHTOF(ui\explosion_ca.paa);
};
class GVAR(moduleCreateIntel): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = CSTRING(ModuleCreateIntel);
function = QFUNC(moduleCreateIntel);
icon = "\a3\ui_f\data\igui\cfg\simpletasks\types\documents_ca.paa";
};
class GVAR(moduleCreateMinefield): GVAR(moduleBase) {
category = QGVAR(Objects);
displayName = CSTRING(ModuleCreateMinefield);
Expand Down Expand Up @@ -218,16 +224,16 @@ class CfgVehicles {
displayName = CSTRING(ModuleGarrison);
function = QFUNC(moduleGarrison);
};
class GVAR(ModuleGroupSide): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = CSTRING(ModuleGroupSide);
function = QFUNC(moduleGroupSide);
};
class GVAR(moduleGlobalHint): GVAR(moduleBase) {
category = "Curator";
displayName = CSTRING(ModuleGlobalHint);
curatorInfoType = QGVAR(RscGlobalHint);
};
class GVAR(moduleGroupSide): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = CSTRING(ModuleGroupSide);
function = QFUNC(moduleGroupSide);
};
class GVAR(moduleHeal): GVAR(moduleBase) {
curatorCanAttach = 1;
displayName = CSTRING(ModuleHeal);
Expand Down
2 changes: 2 additions & 0 deletions addons/modules/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
PREP(addIntelAction);
PREP(addTeleporterAction);
PREP(bi_moduleMine);
PREP(compileAircraft);
Expand Down Expand Up @@ -31,6 +32,7 @@ PREP(moduleChangeHeight);
PREP(moduleChatter);
PREP(moduleConvoyParameters);
PREP(moduleCreateIED);
PREP(moduleCreateIntel);
PREP(moduleCreateMinefield);
PREP(moduleCreateTarget);
PREP(moduleCreateTeleporter);
Expand Down
18 changes: 14 additions & 4 deletions addons/modules/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#include "script_component.hpp"

if (isServer) then {
[QGVAR(moduleAmbientAnimStart), FUNC(moduleAmbientAnimStart)] call CBA_fnc_addEventHandler;
[QGVAR(moduleAmbientFlyby), FUNC(moduleAmbientFlyby)] call CBA_fnc_addEventHandler;
[QGVAR(moduleCAS), FUNC(moduleCAS)] call CBA_fnc_addEventHandler;
[QGVAR(moduleEditableObjects), FUNC(moduleEditableObjects)] call CBA_fnc_addEventHandler;
[QGVAR(moduleAmbientAnimStart), LINKFUNC(moduleAmbientAnimStart)] call CBA_fnc_addEventHandler;
[QGVAR(moduleAmbientFlyby), LINKFUNC(moduleAmbientFlyby)] call CBA_fnc_addEventHandler;
[QGVAR(moduleCAS), LINKFUNC(moduleCAS)] call CBA_fnc_addEventHandler;
[QGVAR(moduleEditableObjects), LINKFUNC(moduleEditableObjects)] call CBA_fnc_addEventHandler;

// Public variable to track created target logics
missionNamespace setVariable [QGVAR(targetLogics), [], true];
Expand All @@ -15,6 +15,7 @@ if (isServer) then {
[QGVAR(moduleCreateTeleporter), LINKFUNC(moduleCreateTeleporterServer)] call CBA_fnc_addEventHandler;
};

[QGVAR(addIntelAction), LINKFUNC(addIntelAction)] call CBA_fnc_addEventHandler;
[QGVAR(addTeleporterAction), LINKFUNC(addTeleporterAction)] call CBA_fnc_addEventHandler;

[QGVAR(sayMessage), BIS_fnc_sayMessage] call CBA_fnc_addEventHandler;
Expand Down Expand Up @@ -50,7 +51,16 @@ if (isServer) then {

forceWeatherChange;
};
}] call CBA_fnc_addEventHandler;

[QGVAR(addIntel), {
params ["_title", "_text"];

if !(player diarySubjectExists QGVAR(intel)) then {
player createDiarySubject [QGVAR(intel), localize "str_disp_intel_title"];
};

player createDiaryRecord [QGVAR(intel), [_title, _text]];
}] call CBA_fnc_addEventHandler;

[QGVAR(teleportOutOfVehicle), {
Expand Down
3 changes: 2 additions & 1 deletion addons/modules/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ class CfgPatches {
QGVAR(moduleChatter),
QGVAR(moduleConvoyParameters),
QGVAR(moduleCreateIED),
QGVAR(moduleCreateIntel),
QGVAR(moduleCreateMinefield),
QGVAR(moduleCreateTarget),
QGVAR(moduleCreateTeleporter),
Expand All @@ -33,8 +34,8 @@ class CfgPatches {
QGVAR(moduleFlyHeight),
QGVAR(moduleFunctionsViewer),
QGVAR(moduleGarrison),
QGVAR(ModuleGroupSide),
QGVAR(moduleGlobalHint),
QGVAR(moduleGroupSide),
QGVAR(moduleHeal),
QGVAR(moduleHideZeus),
QGVAR(moduleLightSource),
Expand Down
127 changes: 127 additions & 0 deletions addons/modules/functions/fnc_addIntelAction.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,127 @@
#include "script_component.hpp"
/*
* Author: mharis001
* Add an intel action to the given object.
*
* Arguments:
* 0: Object <OBJECT>
* 1: Share With (0 - Side, 1 - Group, 2 - Nobody) <NUMBER>
* 2: Delete On Completion <BOOL>
* 3: Action Text <STRING>
* 4: Action Duration <NUMBER>
* 5: Intel Title <STRING>
* 6: Intel Text <STRING>
*
* Return Value:
* None
*
* Example:
* [notebook, 0, true, "Pick Up Intel", 1, "Intel!", "Notes..."] call zen_modules_fnc_addIntelAction
*
* Public: No
*/

#define MAX_DISTANCE 3

params ["_object", "_share", "_delete", "_actionText", "_duration", "_title", "_text"];

private _fnc_addIntel = {
private _targets = switch (_share) do {
case 0: {
call CBA_fnc_players select {side group _x == side _unit}
};
case 1: {
units _unit select {isPlayer _x}
};
case 2: {
[_unit]
};
};

// Send to message to curators that a player has found intel
[
QEGVAR(common,showMessage),
[format [localize LSTRING(ModuleCreateIntel_PlayerFoundIntel), name _unit, _title]],
allCurators
] call CBA_fnc_targetEvent;

[
["\a3\ui_f\data\igui\cfg\simpletasks\types\documents_ca.paa", 1.25],
[localize LSTRING(ModuleCreateIntel_IntelFound)],
true
] call CBA_fnc_notify;

[QGVAR(addIntel), [_title, _text], _targets] call CBA_fnc_targetEvent;
};

if (isClass (configFile >> "CfgPatches" >> "ace_interact_menu")) then {
[_object, 0, ["ACE_MainActions", QGVAR(intelAction)]] call ace_interact_menu_fnc_removeActionFromObject;

private _action = [
QGVAR(intelAction),
_actionText,
"\a3\ui_f\data\igui\cfg\simpletasks\types\documents_ca.paa",
{
params ["_object", "_unit", "_args"];
_args params ["_title", "_text", "_share", "_delete", "_actionText", "_duration"];

[
_duration,
[_object, _unit, _title, _text, _share, _delete],
{
(_this select 0) params ["_object", "_unit", "_title", "_text", "_share", "_delete", "_fnc_addIntel"];

call _fnc_addIntel;

if (_delete) then {
deleteVehicle _object;
} else {
[_object, 0, ["ACE_MainActions", QGVAR(intelAction)]] call ace_interact_menu_fnc_removeActionFromObject;
};
},
{},
_actionText
] call ace_common_fnc_progressBar;
},
{true},
{},
[_title, _text, _share, _delete, _actionText, _duration, _fnc_addIntel]
] call ace_interact_menu_fnc_createAction;

[_object, 0, ["ACE_MainActions"], _action] call ace_interact_menu_fnc_addActionToObject;
} else {
private _actionID = _object getVariable QGVAR(intelActionID);

if (!isNil "_actionID") then {
[_object, _actionID] call BIS_fnc_holdActionRemove;
};

_actionID = [
_object,
_actionText,
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_search_ca.paa",
QUOTE(_target distance _this < MAX_DISTANCE),
QUOTE(_target distance _caller < MAX_DISTANCE),
{},
{},
{
params ["_object", "_unit", "", "_args"];
_args params ["_title", "_text", "_share", "_delete", "_fnc_addIntel"];

call _fnc_addIntel;

if (_delete) then {
deleteVehicle _object;
};
},
{},
[_title, _text, _share, _delete, _fnc_addIntel],
_duration,
100,
true,
false
] call BIS_fnc_holdActionAdd;

_object setVariable [QGVAR(intelActionID), _actionID];
};
68 changes: 68 additions & 0 deletions addons/modules/functions/fnc_moduleCreateIntel.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
#include "script_component.hpp"
/*
* Author: mharis001
* Zeus module function to create an intel object.
*
* Arguments:
* 0: Logic <OBJECT>
*
* Return Value:
* None
*
* Example:
* [LOGIC] call zen_modules_fnc_moduleCreateIntel
*
* Public: No
*/

#define INTEL_CLASSES ["Land_File1_F", "Land_File2_F", "Land_FilePhotos_F", "Land_File_research_F", "Land_Document_01_F", "Land_Map_F", "Land_Map_unfolded_F", "Land_Laptop_unfolded_F", "Land_Laptop_F", "Land_Laptop_device_F", "Land_MobilePhone_smart_F", "Land_Tablet_02_F", "Land_Tablet_01_F"]

params ["_logic"];

private _object = attachedTo _logic;

private _intelParams = _object getVariable [QGVAR(intelParams), []];
_intelParams params [["_share", 0], ["_delete", true], ["_actionText", localize LSTRING(ModuleCreateIntel_PickUpIntel)], ["_duration", 1], ["_title", ""], ["_text", ""]];

private _options = [
["TOOLBOX", LSTRING(ModuleCreateIntel_ShareWith), [_share, 1, 3, ["str_eval_typeside", "str_word_allgroup", "str_disp_intel_none_friendly"]]],
["TOOLBOX:YESNO", LSTRING(ModuleCreateIntel_DeleteOnCompletion), _delete],
["EDIT", LSTRING(ModuleCreateIntel_ActionText), _actionText],
["SLIDER", LSTRING(ModuleCreateIntel_ActionDuration), [0, 60, _duration, 0]],
["EDIT", LSTRING(ModuleCreateIntel_IntelTitle), _title],
["EDIT:MULTI", LSTRING(ModuleCreateIntel_IntelText), _text]
];

if (isNull _object) then {
private _names = INTEL_CLASSES apply {getText (configFile >> "CfgVehicles" >> _x >> "displayName")};

// Push front
reverse _options;
_options pushBack ["COMBO", LSTRING(ModuleCreateIntel_ObjectType), [INTEL_CLASSES, _names, 0]];
reverse _options;

_object = getPosATL _logic;
} else {
{
_x set [3, true];
} forEach _options;
};

[LSTRING(ModuleCreateIntel), _options, {
params ["_values", "_object"];

if (_object isEqualType []) then {
_object = createVehicle [_values deleteAt 0, _object, [], 0, "NONE"];
[QEGVAR(common,addObjects), [[_object]]] call CBA_fnc_serverEvent;
};

_object setVariable [QGVAR(intelParams), _values, true];

_values params ["_share", "_delete", "_actionText", "_duration", "_title", "_text"];
_text = _text splitString endl joinString "<br />";

private _jipID = [QGVAR(addIntelAction), [_object, _share, _delete, _actionText, _duration, _title, _text]] call CBA_fnc_globalEventJIP;
[_jipID, _object] call CBA_fnc_removeGlobalEventJIP;
}, {}, _object] call EFUNC(dialog,create);

deleteVehicle _logic;
33 changes: 33 additions & 0 deletions addons/modules/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1345,6 +1345,39 @@
<Chinesesimp>移除军火库</Chinesesimp>
<Chinese>移除軍火庫</Chinese>
</Key>
<Key ID="STR_ZEN_Modules_ModuleCreateIntel">
<English>Create/Edit Intel</English>
</Key>
<Key ID="STR_ZEN_Modules_ModuleCreateIntel_ObjectType">
<English>Object Type</English>
</Key>
<Key ID="STR_ZEN_Modules_ModuleCreateIntel_ShareWith">
<English>Share With</English>
</Key>
<Key ID="STR_ZEN_Modules_ModuleCreateIntel_DeleteOnCompletion">
<English>Delete On Completion</English>
</Key>
<Key ID="STR_ZEN_Modules_ModuleCreateIntel_ActionText">
<English>Action Text</English>
</Key>
<Key ID="STR_ZEN_Modules_ModuleCreateIntel_ActionDuration">
<English>Action Duration</English>
</Key>
<Key ID="STR_ZEN_Modules_ModuleCreateIntel_IntelTitle">
<English>Intel Title</English>
</Key>
<Key ID="STR_ZEN_Modules_ModuleCreateIntel_IntelText">
<English>Intel Text</English>
</Key>
<Key ID="STR_ZEN_Modules_ModuleCreateIntel_PickUpIntel">
<English>Pick Up Intel</English>
</Key>
<Key ID="STR_ZEN_Modules_ModuleCreateIntel_IntelFound">
<English>Intel Found</English>
</Key>
<Key ID="STR_ZEN_Modules_ModuleCreateIntel_PlayerFoundIntel">
<English>%1 found intel: "%2"</English>
</Key>
<!-- Module Categories -->
<Key ID="STR_ZEN_Modules_Buildings">
<English>Buildings</English>
Expand Down
6 changes: 6 additions & 0 deletions docs/modules_list.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,12 @@ This should be used on all vehicles in a convoy which are ideally in the same gr
Creates an [area marker](/area_markers.md) at the module's position.
This module must be placed on the map.

## Create/Edit Intel

Creates an object of the selected type and adds action to collect its intel.
The intel is added as a diary record with the given title and text (under the "Intel" subject).
Additionally, the module can be attached to an existing object to add (or edit) an intel action.

## Create IED

Makes the attached object act as an IED that is activated by the selected side within the selected radius.
Expand Down