fix #95 & add ADDON = bool

This commit is contained in:
bux578 2015-01-27 09:01:57 +01:00
parent c407553d49
commit f0c06beb23
4 changed files with 56 additions and 42 deletions

View File

@ -1,5 +1,7 @@
#include "script_component.hpp"
ADDON = false;
PREP(addMapFunction);
PREP(handleMapClick);
PREP(initPlayer);
@ -9,3 +11,5 @@ PREP(module);
PREP(nearestPlayers);
PREP(switchBack);
PREP(switchUnit);
ADDON = true;

View File

@ -9,7 +9,7 @@
Parameters:
0: OBJECT - unit
1: ARRAY<OBJECT> - sided
1: ARRAY<OBJECT> - sides
Returns:
VOID
@ -17,9 +17,14 @@
#include "script_component.hpp"
private ["_unit"];
private ["_unit", "_sides"];
_unit = _this select 0;
_sides = _this select 1;
["theMapClick", "onMapSingleClick", {
[_this, _pos, _shift, _alt] call FUNC(handleMapClick);
if (alive ACE_player && {GVAR(OriginalUnit) getVariable ["ACE_CanSwitchUnits", false]}) then {
[_this, _pos, _shift, _alt] call FUNC(handleMapClick);
};
}, [_unit, _sides]] call BIS_fnc_addStackedEventHandler;

View File

@ -9,7 +9,7 @@
Parameters:
0: OBJECT - MapClickEventHandlerArgs
0: OBJECT - unit to switch to
0: OBJECT - unit // useless
1: ARRAY<OBJECT> - sides
Returns:
@ -18,9 +18,11 @@
#include "script_component.hpp"
private ["_args", "_currentPlayerUnit", "_sides", "_pos", "_sideNearest"];
private ["_sides", "_pos", "_sideNearest"];
// that's wrong
//_currentPlayerUnit = (_this select 0) select 0;
_currentPlayerUnit = (_this select 0) select 0;
_sides = (_this select 0) select 1;
_pos = _this select 1;
@ -37,7 +39,7 @@ if (count _sideNearest > 0) then {
private ["_switchUnit"];
_switchUnit = _sideNearest select 0;
[_currentPlayerUnit, _switchUnit] call FUNC(switchUnit);
[ACE_player, _switchUnit] call FUNC(switchUnit);
openMap false;
};

View File

@ -22,45 +22,48 @@ _sidesToShow = _this select 0;
_sidesToShow spawn {
private ["_sides", "_allMarkerNames"];
_sides = _this;
_allMarkerNames = [];
private ["_sides", "_allMarkerNames"];
_sides = _this;
_allMarkerNames = [];
while { true } do {
sleep 1.5;
while { true } do {
sleep 1.5;
// delete markers
{
deleteMarkerLocal _x;
} forEach _allMarkerNames;
// delete markers
{
deleteMarkerLocal _x;
} forEach _allMarkerNames;
// create markers
{
if (([_x] call FUNC(isValidAi) && (side group _x in _sides)) || (_x getVariable [QGVAR(IsPlayerControlled), false])) then {
private ["_markerName", "_marker", "_markerColor"];
if (alive ACE_player && {GVAR(OriginalUnit) getVariable ["ACE_CanSwitchUnits", false]}) then {
//_markerName = format ["%1", [_x] call EFUNC(common,getName)];
_markerName = str _x;
// create markers
{
if (([_x] call FUNC(isValidAi) && (side group _x in _sides)) || (_x getVariable [QGVAR(IsPlayerControlled), false])) then {
private ["_markerName", "_marker", "_markerColor"];
_marker = createMarkerLocal [_markerName, position _x];
_markerName setMarkerTypeLocal "mil_triangle";
_markerName setMarkerShapeLocal "ICON";
_markerName setMarkerSizeLocal [0.5,0.7];
_markerName setMarkerDirLocal getDir _x;
// commy's one liner magic
_markerColor = format ["Color%1", side group _x];
if ((_x getVariable [QGVAR(IsPlayerControlled), false])) then {
_markerName setMarkerColorLocal "ColorOrange";
_markerName setMarkerTextLocal (_x getVariable [QGVAR(PlayerControlledName),""]);
} else {
_markerName setMarkerColorLocal _markerColor;
_markerName setMarkerTextLocal (getText (configFile >> "CfgVehicles" >> typeOf _x >> "displayName"));
//_markerName = format ["%1", [_x] call EFUNC(common,getName)];
_markerName = str _x;
_marker = createMarkerLocal [_markerName, position _x];
_markerName setMarkerTypeLocal "mil_triangle";
_markerName setMarkerShapeLocal "ICON";
_markerName setMarkerSizeLocal [0.5,0.7];
_markerName setMarkerDirLocal getDir _x;
// commy's one liner magic
_markerColor = format ["Color%1", side group _x];
if ((_x getVariable [QGVAR(IsPlayerControlled), false])) then {
_markerName setMarkerColorLocal "ColorOrange";
_markerName setMarkerTextLocal (_x getVariable [QGVAR(PlayerControlledName), ""]);
} else {
_markerName setMarkerColorLocal _markerColor;
_markerName setMarkerTextLocal (getText (configFile >> "CfgVehicles" >> typeOf _x >> "displayName"));
};
_allMarkerNames pushBack _markerName;
};
} forEach allUnits;
};
_allMarkerNames pushBack _markerName;
};
} forEach allUnits;
};
};
};