mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
cleanup SwitchUnits
This commit is contained in:
parent
0397b3f9f4
commit
09e4a6a76e
@ -1,53 +1,53 @@
|
|||||||
class CfgVehicles {
|
class CfgVehicles {
|
||||||
class ACE_Module;
|
class ACE_Module;
|
||||||
class ACE_ModuleSwitchUnits: ACE_Module {
|
class ACE_ModuleSwitchUnits: ACE_Module {
|
||||||
author = ECSTRING(common,ACETeam);
|
author = ECSTRING(common,ACETeam);
|
||||||
category = "ACE";
|
category = "ACE";
|
||||||
displayName = CSTRING(Module_DisplayName);
|
displayName = CSTRING(Module_DisplayName);
|
||||||
function = FUNC(module);
|
function = FUNC(module);
|
||||||
scope = 2;
|
scope = 2;
|
||||||
isGlobal = 1;
|
isGlobal = 1;
|
||||||
icon = QUOTE(PATHTOF(UI\Icon_Module_SwitchUnits_ca.paa));
|
icon = QUOTE(PATHTOF(UI\Icon_Module_SwitchUnits_ca.paa));
|
||||||
class Arguments {
|
class Arguments {
|
||||||
class SwitchToWest {
|
class SwitchToWest {
|
||||||
displayName = CSTRING(SwitchToWest_DisplayName);
|
displayName = CSTRING(SwitchToWest_DisplayName);
|
||||||
description = CSTRING(SwitchToWest_Description);
|
description = CSTRING(SwitchToWest_Description);
|
||||||
typeName = "BOOL";
|
typeName = "BOOL";
|
||||||
defaultValue = 0;
|
defaultValue = 0;
|
||||||
};
|
};
|
||||||
class SwitchToEast {
|
class SwitchToEast {
|
||||||
displayName = CSTRING(SwitchToEast_DisplayName);
|
displayName = CSTRING(SwitchToEast_DisplayName);
|
||||||
description = CSTRING(SwitchToEast_Description);
|
description = CSTRING(SwitchToEast_Description);
|
||||||
typeName = "BOOL";
|
typeName = "BOOL";
|
||||||
defaultValue = 0;
|
defaultValue = 0;
|
||||||
};
|
};
|
||||||
class SwitchToIndependent {
|
class SwitchToIndependent {
|
||||||
displayName = CSTRING(SwitchToIndependent_DisplayName);
|
displayName = CSTRING(SwitchToIndependent_DisplayName);
|
||||||
description = CSTRING(SwitchToIndependent_Description);
|
description = CSTRING(SwitchToIndependent_Description);
|
||||||
typeName = "BOOL";
|
typeName = "BOOL";
|
||||||
defaultValue = 0;
|
defaultValue = 0;
|
||||||
};
|
};
|
||||||
class SwitchToCivilian {
|
class SwitchToCivilian {
|
||||||
displayName = CSTRING(SwitchToCivilian_DisplayName);
|
displayName = CSTRING(SwitchToCivilian_DisplayName);
|
||||||
description = CSTRING(SwitchToCivilian_Description);
|
description = CSTRING(SwitchToCivilian_Description);
|
||||||
typeName = "BOOL";
|
typeName = "BOOL";
|
||||||
defaultValue = 0;
|
defaultValue = 0;
|
||||||
};
|
};
|
||||||
class EnableSafeZone {
|
class EnableSafeZone {
|
||||||
displayName = CSTRING(EnableSafeZone_DisplayName);
|
displayName = CSTRING(EnableSafeZone_DisplayName);
|
||||||
description = CSTRING(EnableSafeZone_Description);
|
description = CSTRING(EnableSafeZone_Description);
|
||||||
typeName = "BOOL";
|
typeName = "BOOL";
|
||||||
defaultValue = 1;
|
defaultValue = 1;
|
||||||
};
|
};
|
||||||
class SafeZoneRadius {
|
class SafeZoneRadius {
|
||||||
displayName = CSTRING(SafeZoneRadius_DisplayName);
|
displayName = CSTRING(SafeZoneRadius_DisplayName);
|
||||||
description = CSTRING(SafeZoneRadius_Description);
|
description = CSTRING(SafeZoneRadius_Description);
|
||||||
typeName = "NUMBER";
|
typeName = "NUMBER";
|
||||||
defaultValue = 100;
|
defaultValue = 100;
|
||||||
};
|
};
|
||||||
|
};
|
||||||
|
class ModuleDescription {
|
||||||
|
description = CSTRING(Module_Description);
|
||||||
|
};
|
||||||
};
|
};
|
||||||
class ModuleDescription {
|
|
||||||
description = CSTRING(Module_Description);
|
|
||||||
};
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
class CfgPatches {
|
class CfgPatches {
|
||||||
class ADDON {
|
class ADDON {
|
||||||
units[] = {};
|
units[] = {};
|
||||||
weapons[] = {};
|
weapons[] = {};
|
||||||
requiredVersion = REQUIRED_VERSION;
|
requiredVersion = REQUIRED_VERSION;
|
||||||
requiredAddons[] = {"ace_common"};
|
requiredAddons[] = {"ace_common"};
|
||||||
author[] = {"bux578"};
|
author[] = {"bux578"};
|
||||||
authorUrl = "https://github.com/bux578/";
|
authorUrl = "https://github.com/bux578/";
|
||||||
VERSION_CONFIG;
|
VERSION_CONFIG;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
#include "CfgEventHandlers.hpp"
|
#include "CfgEventHandlers.hpp"
|
||||||
|
@ -18,12 +18,10 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_sideNearest"];
|
|
||||||
|
|
||||||
params ["_faction", "_pos"];
|
params ["_faction", "_pos"];
|
||||||
_faction params ["", "_sides"];
|
_faction params ["", "_sides"];
|
||||||
|
|
||||||
_sideNearest = [];
|
private _sideNearest = [];
|
||||||
|
|
||||||
{
|
{
|
||||||
if ([_x] call FUNC(isValidAi) && (side group _x in _sides)) then {
|
if ([_x] call FUNC(isValidAi) && (side group _x in _sides)) then {
|
||||||
|
@ -37,18 +37,17 @@ GVAR(AllMarkerNames) = [];
|
|||||||
// create markers
|
// create markers
|
||||||
{
|
{
|
||||||
if (([_x] call FUNC(isValidAi) && (side group _x in _sides)) || (_x getVariable [QGVAR(IsPlayerControlled), false])) then {
|
if (([_x] call FUNC(isValidAi) && (side group _x in _sides)) || (_x getVariable [QGVAR(IsPlayerControlled), false])) then {
|
||||||
private ["_markerName", "_marker", "_markerColor"];
|
|
||||||
|
private _markerName = str _x;
|
||||||
|
|
||||||
_markerName = str _x;
|
private _marker = createMarkerLocal [_markerName, position _x];
|
||||||
|
|
||||||
_marker = createMarkerLocal [_markerName, position _x];
|
|
||||||
_markerName setMarkerTypeLocal "mil_triangle";
|
_markerName setMarkerTypeLocal "mil_triangle";
|
||||||
_markerName setMarkerShapeLocal "ICON";
|
_markerName setMarkerShapeLocal "ICON";
|
||||||
_markerName setMarkerSizeLocal [0.5, 0.7];
|
_markerName setMarkerSizeLocal [0.5, 0.7];
|
||||||
_markerName setMarkerDirLocal getDir _x;
|
_markerName setMarkerDirLocal getDir _x;
|
||||||
|
|
||||||
// commy's one liner magic
|
// commy's one liner magic
|
||||||
_markerColor = format ["Color%1", side group _x];
|
private _markerColor = format ["Color%1", side group _x];
|
||||||
|
|
||||||
if ((_x getVariable [QGVAR(IsPlayerControlled), false])) then {
|
if ((_x getVariable [QGVAR(IsPlayerControlled), false])) then {
|
||||||
_markerName setMarkerColorLocal "ColorOrange";
|
_markerName setMarkerColorLocal "ColorOrange";
|
||||||
|
@ -35,4 +35,4 @@ GVAR(Module) = true;
|
|||||||
|
|
||||||
[QGVAR(EnableSwitchUnits), true, false, true] call EFUNC(common,setSetting);
|
[QGVAR(EnableSwitchUnits), true, false, true] call EFUNC(common,setSetting);
|
||||||
|
|
||||||
ACE_LOGINFO("Switch Unit Module Initialized.");
|
ACE_LOGINFO("SwitchUnits Module Initialized.");
|
||||||
|
@ -16,11 +16,9 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_nearestPlayers"];
|
|
||||||
|
|
||||||
params ["_position", "_radius"];
|
params ["_position", "_radius"];
|
||||||
|
|
||||||
_nearestPlayers = [];
|
private _nearestPlayers = [];
|
||||||
|
|
||||||
{
|
{
|
||||||
if ([_x] call EFUNC(common,isPlayer) && {alive _x}) then {
|
if ([_x] call EFUNC(common,isPlayer) && {alive _x}) then {
|
||||||
|
@ -19,8 +19,7 @@
|
|||||||
params ["_player"];
|
params ["_player"];
|
||||||
|
|
||||||
if (GVAR(EnableSwitchUnits)) then {
|
if (GVAR(EnableSwitchUnits)) then {
|
||||||
private "_sides";
|
private _sides = [];
|
||||||
_sides = [];
|
|
||||||
|
|
||||||
if(GVAR(SwitchToWest)) then {_sides pushBack west;};
|
if(GVAR(SwitchToWest)) then {_sides pushBack west;};
|
||||||
if(GVAR(SwitchToEast)) then {_sides pushBack east;};
|
if(GVAR(SwitchToEast)) then {_sides pushBack east;};
|
||||||
|
@ -28,8 +28,7 @@ params ["_originalPlayerUnit"];
|
|||||||
selectPlayer _originalPlayerUnit;
|
selectPlayer _originalPlayerUnit;
|
||||||
deleteVehicle _currentUnit;
|
deleteVehicle _currentUnit;
|
||||||
|
|
||||||
private "_layer";
|
private _layer = "BIS_fnc_respawnCounter" call bis_fnc_rscLayer;
|
||||||
_layer = "BIS_fnc_respawnCounter" call bis_fnc_rscLayer;
|
|
||||||
_layer cuttext ["","plain"];
|
_layer cuttext ["","plain"];
|
||||||
|
|
||||||
[_pfhId] call CBA_fnc_removePerFrameHandler;
|
[_pfhId] call CBA_fnc_removePerFrameHandler;
|
||||||
|
@ -15,19 +15,17 @@
|
|||||||
*/
|
*/
|
||||||
#include "script_component.hpp"
|
#include "script_component.hpp"
|
||||||
|
|
||||||
private ["_nearestEnemyPlayers", "_allNearestPlayers", "_oldUnit", "_leave"];
|
|
||||||
|
|
||||||
params ["_unit"];
|
params ["_unit"];
|
||||||
|
|
||||||
// don't switch to original player units
|
// don't switch to original player units
|
||||||
if (!([_unit] call FUNC(isValidAi))) exitWith {};
|
if (!([_unit] call FUNC(isValidAi))) exitWith {};
|
||||||
|
|
||||||
// exit var
|
// exit var
|
||||||
_leave = false;
|
private _leave = false;
|
||||||
|
|
||||||
if (GVAR(EnableSafeZone)) then {
|
if (GVAR(EnableSafeZone)) then {
|
||||||
_allNearestPlayers = [position _unit, GVAR(SafeZoneRadius)] call FUNC(nearestPlayers);
|
private _allNearestPlayers = [position _unit, GVAR(SafeZoneRadius)] call FUNC(nearestPlayers);
|
||||||
_nearestEnemyPlayers = [_allNearestPlayers, {((side GVAR(OriginalGroup)) getFriend (side _this) < 0.6) && !(_this getVariable [QGVAR(IsPlayerControlled), false])}] call EFUNC(common,filter);
|
private _nearestEnemyPlayers = [_allNearestPlayers, {((side GVAR(OriginalGroup)) getFriend (side _this) < 0.6) && !(_this getVariable [QGVAR(IsPlayerControlled), false])}] call EFUNC(common,filter);
|
||||||
|
|
||||||
if (count _nearestEnemyPlayers > 0) exitWith {
|
if (count _nearestEnemyPlayers > 0) exitWith {
|
||||||
_leave = true;
|
_leave = true;
|
||||||
@ -45,7 +43,6 @@ if (_leave) exitWith {
|
|||||||
[[_unit, player], QUOTE({(_this select 0) setVariable [ARR_3(QUOTE(QGVAR(OriginalOwner)), owner (_this select 0), true)]; (_this select 0) setOwner owner (_this select 1)}), 1] call EFUNC(common,execRemoteFnc);
|
[[_unit, player], QUOTE({(_this select 0) setVariable [ARR_3(QUOTE(QGVAR(OriginalOwner)), owner (_this select 0), true)]; (_this select 0) setOwner owner (_this select 1)}), 1] call EFUNC(common,execRemoteFnc);
|
||||||
|
|
||||||
[{
|
[{
|
||||||
private ["_respawnEhId", "_oldOwner"];
|
|
||||||
params ["_args", "_pfhId"];
|
params ["_args", "_pfhId"];
|
||||||
_args params ["_unit", "_oldUnit"];
|
_args params ["_unit", "_oldUnit"];
|
||||||
|
|
||||||
@ -53,7 +50,7 @@ if (_leave) exitWith {
|
|||||||
_oldUnit setVariable [QGVAR(IsPlayerControlled), false, true];
|
_oldUnit setVariable [QGVAR(IsPlayerControlled), false, true];
|
||||||
_oldUnit setVariable [QGVAR(PlayerControlledName), "", true];
|
_oldUnit setVariable [QGVAR(PlayerControlledName), "", true];
|
||||||
|
|
||||||
_respawnEhId = _unit getVariable [QGVAR(RespawnEhId), -1];
|
private _respawnEhId = _unit getVariable [QGVAR(RespawnEhId), -1];
|
||||||
if (_respawnEhId != -1) then {
|
if (_respawnEhId != -1) then {
|
||||||
_oldUnit removeEventHandler ["Respawn", _respawnEhId];
|
_oldUnit removeEventHandler ["Respawn", _respawnEhId];
|
||||||
};
|
};
|
||||||
@ -69,7 +66,7 @@ if (_leave) exitWith {
|
|||||||
_unit setVariable [QGVAR(RespawnEhId), _respawnEhId, true];
|
_unit setVariable [QGVAR(RespawnEhId), _respawnEhId, true];
|
||||||
|
|
||||||
// set owner back to original owner
|
// set owner back to original owner
|
||||||
_oldOwner = _oldUnit getVariable[QGVAR(OriginalOwner), -1];
|
private _oldOwner = _oldUnit getVariable[QGVAR(OriginalOwner), -1];
|
||||||
if (_oldOwner > -1) then {
|
if (_oldOwner > -1) then {
|
||||||
[[_oldUnit, _oldOwner], QUOTE({(_this select 0) setOwner (_this select 1)}), 1] call EFUNC(common,execRemoteFnc);
|
[[_oldUnit, _oldOwner], QUOTE({(_this select 0) setOwner (_this select 1)}), 1] call EFUNC(common,execRemoteFnc);
|
||||||
};
|
};
|
||||||
|
@ -1 +1 @@
|
|||||||
#include "\z\ace\addons\switchunits\script_component.hpp"
|
#include "\z\ace\addons\switchunits\script_component.hpp"
|
||||||
|
Loading…
Reference in New Issue
Block a user