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

Fortify: Add map area markers for ACEX Fortify Objects #258

Closed
wants to merge 15 commits into from
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -125,3 +125,4 @@ VyMajoris(W-Cephei)<vycanismajoriscsa@gmail.com>
Winter <simon@agius-muscat.net>
wizpig64
zGuba
Seb <sebsmith90@gmail.com>
1 change: 1 addition & 0 deletions addons/fortify/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,4 @@ PREP(getPlaceableSet);
PREP(modifyAction);
PREP(setupModule);
PREP(buildLocationModule);
PREP(createObjectMarker);
21 changes: 21 additions & 0 deletions addons/fortify/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ if (isServer) then {
TRACE_3("objectPlaced",_unit,_side,_object);
private _jipID = [QGVAR(addActionToObject), [_side, _object]] call CBA_fnc_globalEventJIP;
[_jipID, _object] call CBA_fnc_removeGlobalEventJIP; // idealy this function should be called on the server
if (GVAR(markObjectsOnMap) isNotEqualTo 0 && {_object isKindOf "Static"}) then {
[_object] call FUNC(createObjectMarker)
};
}] call CBA_fnc_addEventHandler;
};

Expand Down Expand Up @@ -63,3 +66,21 @@ GVAR(objectRotationZ) = 0;
[_object, 0, ["ACE_MainActions"], _removeAction] call ACEFUNC(interact_menu,addActionToObject);
};
}] call CBA_fnc_addEventHandler;

[QGVAR(setMarkerVisible), {
params ["_object"];
[
{!isNull player},
{
params ["_object"];
private _objectSide = _object getVariable QGVAR(objectSide);
private _playerSide = side group player;
Seb105 marked this conversation as resolved.
Show resolved Hide resolved
// If enemy placed object, hide marker.
if (GVAR(markObjectsOnMap) isEqualTo 1 && {_objectSide getFriend _playerSide < 0.6}) then {
private _marker = _object getVariable QGVAR(mapMarker);
_marker setMarkerAlpha 0;
};
},
_object
] call CBA_fnc_waitUntilAndExecute;
Seb105 marked this conversation as resolved.
Show resolved Hide resolved
}] call CBA_fnc_addEventHandler;
48 changes: 48 additions & 0 deletions addons/fortify/functions/fnc_createObjectMarker.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
#include "script_component.hpp"

/*
* Author: Seb
* Creates a map marker for a created static object but only for sides friendly to the creator side.
*
* Arguments:
* 0: Created fortify object <OBJECT>
*
* Return Value:
* None
*
* Example:
* _object call acex_fortify_fnc_createObjectMarker
*
* Public: No
*/

params ["_object"];

// Get Object size and direction
private _bbr = 0 boundingBoxReal _object;
private _p1 = _bbr select 0;
private _p2 = _bbr select 1;
private _maxWidth = abs ((_p2 select 0) - (_p1 select 0));
private _maxLength = abs ((_p2 select 1) - (_p1 select 1));
private _direction = getDir _object;

// Marker name unique to this object
private _markerNameStr = format [QGVAR(marker_%1), _object];

// Create marker, set alpha using global event
private _marker = createMarkerLocal [_markerNameStr, _object];
_marker setMarkerShapeLocal "RECTANGLE";
_marker setMarkerBrushLocal "SolidFull";
_marker setMarkerSizeLocal [(_maxWidth / 2),(_maxLength / 2)];
_marker setMarkerDirLocal _direction;
_marker setMarkerColor "ColorGrey";
_object setVariable [QGVAR(mapMarker), _marker, true];
// Marker Alpha set in EH:
private _jipID = [QGVAR(setMarkerVisible), _object] call CBA_fnc_globalEventJIP;
[_jipID, _object] call CBA_fnc_removeGlobalEventJIP;

_object addEventHandler ["Deleted", {
params ["_object"];
private _marker = _object getVariable QGVAR(mapMarker);
deleteMarker _marker;
}];
3 changes: 2 additions & 1 deletion addons/fortify/functions/fnc_deployConfirm.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ private _vectorDir = vectorDir _object;
deleteVehicle _object;

private _newObject = _typeOf createVehicle _posASL;
_newObject setVariable [QGVAR(objectSide), _side, true];
_newObject setPosASL _posASL;
_newObject setVectorDirAndUp [_vectorDir, _vectorUp];

// Server will use this event to run the jip compatible QGVAR(addActionToObject) event
// Server will use this event to run the jip compatible QGVAR(addActionToObject) event and create the related map marker.
[QGVAR(objectPlaced), [_unit, _side, _newObject]] call CBA_fnc_globalEvent;

if (cba_events_control) then {
Expand Down
17 changes: 16 additions & 1 deletion addons/fortify/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,19 @@
[LLSTRING(settingHintNone), LLSTRING(settingHintHasTool), LLSTRING(settingHintEveryone)],
2
]
] call CBA_settings_fnc_init;
] call CBA_fnc_addSetting;

[
Seb105 marked this conversation as resolved.
Show resolved Hide resolved
QGVAR(markObjectsOnMap),
"LIST",
[LLSTRING(markObjectsOnMap), LLSTRING(markObjectsOnMapDesc)],
LLSTRING(settingsCategory),
[
[0, 1, 2],
[LLSTRING(markObjectsOnMapNone), LLSTRING(markObjectsOnMapFriendly), LLSTRING(markObjectsOnMapEveryone)],
1
],
true,
{},
true
] call CBA_fnc_addSetting;
15 changes: 15 additions & 0 deletions addons/fortify/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,21 @@
<Russian>Показывать всегда</Russian>
<Turkish>Her Zaman Göster</Turkish>
</Key>
<Key ID="STR_ACEX_Fortify_markObjectsOnMap">
<English>Create map markers</English>
</Key>
<Key ID="STR_ACEX_Fortify_markObjectsOnMapDesc">
<English>Create map area markers akin to terrain buildings when an ACEX static object is placed.</English>
</Key>
<Key ID="STR_ACEX_Fortify_markObjectsOnMapNone">
<English>Never</English>
</Key>
<Key ID="STR_ACEX_Fortify_markObjectsOnMapFriendly">
<English>For friendlies only</English>
</Key>
<Key ID="STR_ACEX_Fortify_markObjectsOnMapEveryone">
<English>For everyone</English>
</Key>
Seb105 marked this conversation as resolved.
Show resolved Hide resolved
<Key ID="STR_ACEX_Fortify_small">
<English>Small</English>
<Polish>Małe</Polish>
Expand Down