Skip to content

Commit

Permalink
add exclusion zone via zeus module
Browse files Browse the repository at this point in the history
depends on ZEN which lets you add area markers as Zeus
  • Loading branch information
Fusselwurm committed Mar 21, 2020
1 parent 5f0aec8 commit 7e19c66
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 9 deletions.
1 change: 1 addition & 0 deletions cfgFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ class grad_civs {
class isPlayerHonking {};
class playerLoop {};
class registerAceInteractionHandler {};
class setupZeusModules {};
class showCivHint {};
};

Expand Down
12 changes: 3 additions & 9 deletions functions/api/fn_addExclusionZone.sqf
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
#include "..\..\component.hpp"

_this params [
["_trigger", objNull]
];
params ["_area"];

if (isNull _trigger) exitWith {
ERROR("got NULL instead of a trigger as parameter");
};
GVAR(EXCLUSION_ZONES) pushBack _area;

GVAR(EXCLUSION_ZONES) pushBack _trigger;

INFO_2("added exclusion zone %1 at %2", triggerArea _trigger, getPos _trigger);
INFO_1("added exclusion zone %1", _area);
1 change: 1 addition & 0 deletions functions/init/fn_initPlayer.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ if (hasInterface) then {
[] call grad_civs_fnc_registerAceInteractionHandler;
if (GRAD_CIVS_DEBUG_CIVSTATE) then {
[] call grad_civs_fnc_showWhatTheyThink;
[] call FUNC(setupZeusModules);
[{!isNull (findDisplay 12)}, {[] call grad_civs_fnc_mapMarkers}, []] call CBA_fnc_waitUntilAndExecute;
};
};
24 changes: 24 additions & 0 deletions functions/player/fn_setupZeusModules.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#include "..\..\component.hpp"

["GRAD-CIVS","ADD EXCLUSION ZONE (click within existing area marker!)",
{
params [
["_clickPos", [0, 0, 0]]
];
private _areaMarkersAtPos = allMapMarkers select {
(["RECTANGLE", "ELLIPSE"] find (markerShape _x)) > -1
} select {
_clickPos inArea _x
};

private _distances = _areaMarkersAtPos apply { (markerPos _x) distance _clickPos };
private _minDistanceAndIndex = _distances call CBA_fnc_findMin;

if (isNil "_minValueAndIndex") exitWith {
[format["no area marker at position %1", _clickPos]] call grad_civs_fnc_showCivHint;
};
private _marker = _areaMarkersAtPos select (_minDistanceAndIndex#1);

[_marker] call FUNC(addExclusionZone)
}
] call zen_custom_modules_fnc_register;

0 comments on commit 7e19c66

Please sign in to comment.