Skip to content

Commit

Permalink
Fortify - Add map area markers for Fortify objects (acemod#8525)
Browse files Browse the repository at this point in the history
Co-authored-by: Seb <65898127+Seb105@users.noreply.github.com>
Co-authored-by: PabstMirror <pabstmirror@gmail.com>
  • Loading branch information
3 people authored and AndreasBrostrom committed Dec 3, 2021
1 parent 00e0980 commit 67b857f
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 1 deletion.
1 change: 1 addition & 0 deletions AUTHORS.txt
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ ruPaladin <happyworm24@rambler.ru>
Rutger "RedBery" Meijering <c.redbery@gmail.com>
sancron
Schwaggot <tom.ryan@posteo.de>
Seb <sebsmith90@gmail.com>
shukari
simon84 <badguy360th@gmail.com>
Skengman2
Expand Down
1 change: 1 addition & 0 deletions addons/fortify/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,4 @@ ACEX_PREP(getPlaceableSet);
ACEX_PREP(modifyAction);
ACEX_PREP(setupModule);
ACEX_PREP(buildLocationModule);
ACEX_PREP(createObjectMarker);
9 changes: 9 additions & 0 deletions addons/fortify/XEH_postInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@ 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 {
// Wait ensures correct marker pos/rot as object is moved into position after creation
[
FUNC(createObjectMarker),
[_unit, _object],
1
] call CBA_fnc_waitAndExecute;
};
}] call CBA_fnc_addEventHandler;
};

Expand Down
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: Unit placing <OBJECT>
* 1: Created fortify object <OBJECT>
*
* Return Value:
* None
*
* Example:
* [player, cursorObject] call ace_fortify_fnc_createObjectMarker
*
* Public: No
*/

params ["_unit", "_object"];
TRACE_2("createObjectMarker",_unit,_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), hashValue _object];
private _channel = if (GVAR(markObjectsOnMap) == 2) then { 0 } else { 1 };

private _marker = createMarkerLocal [_markerNameStr, _object, _channel, _unit];
TRACE_2("created",_marker,_channel);
_marker setMarkerShapeLocal "RECTANGLE";
_marker setMarkerBrushLocal "SolidFull";
_marker setMarkerSizeLocal [(_maxWidth / 2),(_maxLength / 2)];
_marker setMarkerDirLocal _direction;
_marker setMarkerColor "ColorGrey";
_object setVariable [QGVAR(mapMarker), _marker, false];

_object addEventHandler ["Deleted", {
params ["_object"];
private _marker = _object getVariable QGVAR(mapMarker);
TRACE_2("cleaning up marker",_object,_marker);
deleteMarker _marker
}];
2 changes: 1 addition & 1 deletion addons/fortify/functions/fnc_deployConfirm.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private _newObject = _typeOf createVehicle _posASL;
_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.
[QXGVAR(objectPlaced), [_unit, _side, _newObject]] call CBA_fnc_globalEvent;

if (cba_events_control) then {
Expand Down
15 changes: 15 additions & 0 deletions addons/fortify/initSettings.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,18 @@
2
]
] call CBA_fnc_addSetting;

[
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;
41 changes: 41 additions & 0 deletions addons/fortify/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,47 @@
<Russian>Показывать всегда</Russian>
<Turkish>Her Zaman Göster</Turkish>
</Key>
<Key ID="STR_ACE_Fortify_markObjectsOnMap">
<English>Create map markers</English>
</Key>
<Key ID="STR_ACE_Fortify_markObjectsOnMapDesc">
<English>Create map markers that look like terrain buildings when static fortifications are placed</English>
</Key>
<Key ID="STR_ACE_Fortify_markObjectsOnMapNone">
<English>Never</English>
<Czech>Nikdy</Czech>
<German>Nie</German>
<Russian>Никогда</Russian>
<Polish>Nigdy</Polish>
<Italian>Mai</Italian>
<Spanish>Nunca</Spanish>
<French>Jamais</French>
<Chinese>永不</Chinese>
<Japanese>なし</Japanese>
<Korean>항상 안 함</Korean>
<Portuguese>Nunca</Portuguese>
<Chinesesimp>永不</Chinesesimp>
<Turkish>Asla</Turkish>
</Key>
<Key ID="STR_ACE_Fortify_markObjectsOnMapFriendly">
<English>For units friendly to the placer</English>
</Key>
<Key ID="STR_ACE_Fortify_markObjectsOnMapEveryone">
<English>For everyone</English>
<Chinese>所有人</Chinese>
<French>Pour tous</French>
<Spanish>Para todos</Spanish>
<Italian>Per tutti</Italian>
<Polish>Dla wszystkich</Polish>
<Russian>Для всех</Russian>
<German>Für alle</German>
<Czech>Pro všechny</Czech>
<Portuguese>Para todos</Portuguese>
<Korean>모든 사람</Korean>
<Chinesesimp>针对每一个人</Chinesesimp>
<Japanese>全員に</Japanese>
<Turkish>Herkes için</Turkish>
</Key>
<Key ID="STR_ACE_Fortify_small">
<English>Small</English>
<Polish>Małe</Polish>
Expand Down

0 comments on commit 67b857f

Please sign in to comment.