From 6c4e50a98de7a6186ef2d82c5ac0aa07b9e71359 Mon Sep 17 00:00:00 2001 From: commy2 Date: Wed, 15 Apr 2015 08:31:40 +0200 Subject: [PATCH] localized names for rallypoints, auto assign slot of group leader at the start of the mission as JIP persistant rallypoint mover slot --- addons/respawn/CfgEventHandlers.hpp | 9 ++++ addons/respawn/CfgVehicles.hpp | 12 ++--- addons/respawn/XEH_preInit.sqf | 1 + .../functions/fnc_handleInitPostServer.sqf | 54 +++++++++++++++++++ .../respawn/functions/fnc_handleRespawn.sqf | 5 ++ addons/respawn/stringtable.xml | 24 +++++++++ 6 files changed, 99 insertions(+), 6 deletions(-) create mode 100644 addons/respawn/functions/fnc_handleInitPostServer.sqf diff --git a/addons/respawn/CfgEventHandlers.hpp b/addons/respawn/CfgEventHandlers.hpp index 9ff7a2bae8..6d7356a607 100644 --- a/addons/respawn/CfgEventHandlers.hpp +++ b/addons/respawn/CfgEventHandlers.hpp @@ -59,3 +59,12 @@ class Extended_Init_EventHandlers { //respawn_civilian }; + +// auto assign rallypoint leader +class Extended_InitPost_EventHandlers { + class CAManBase { + class ADDON { + init = QUOTE(_this call FUNC(handleInitPostServer)); + }; + }; +}; diff --git a/addons/respawn/CfgVehicles.hpp b/addons/respawn/CfgVehicles.hpp index c8ca4f9216..28e33c6b3e 100644 --- a/addons/respawn/CfgVehicles.hpp +++ b/addons/respawn/CfgVehicles.hpp @@ -91,7 +91,7 @@ class CfgVehicles { XEH_ENABLED; author = "$STR_ACE_Common_ACETeam"; - displayName = "Rallypoint West Base"; + displayName = "$STR_ACE_Respawn_RallypointWestBase"; vehicleClass = QGVAR(Rallypoints); class ACE_Actions: ACE_Actions { @@ -111,7 +111,7 @@ class CfgVehicles { XEH_ENABLED; author = "$STR_ACE_Common_ACETeam"; - displayName = "Rallypoint East Base"; + displayName = "$STR_ACE_Respawn_RallypointEastBase"; vehicleClass = QGVAR(Rallypoints); class ACE_Actions: ACE_Actions { @@ -131,7 +131,7 @@ class CfgVehicles { XEH_ENABLED; author = "$STR_ACE_Common_ACETeam"; - displayName = "Rallypoint Independent Base"; + displayName = "$STR_ACE_Respawn_RallypointIndependentBase"; vehicleClass = QGVAR(Rallypoints); class ACE_Actions: ACE_Actions { @@ -152,7 +152,7 @@ class CfgVehicles { XEH_ENABLED; author = "$STR_ACE_Common_ACETeam"; - displayName = "Rallypoint West"; + displayName = "STR_ACE_Respawn_RallypointWest"; vehicleClass = QGVAR(Rallypoints); class ACE_Actions: ACE_Actions { @@ -172,7 +172,7 @@ class CfgVehicles { XEH_ENABLED; author = "$STR_ACE_Common_ACETeam"; - displayName = "Rallypoint East"; + displayName = "STR_ACE_Respawn_RallypointEast"; vehicleClass = QGVAR(Rallypoints); class ACE_Actions: ACE_Actions { @@ -192,7 +192,7 @@ class CfgVehicles { XEH_ENABLED; author = "$STR_ACE_Common_ACETeam"; - displayName = "Rallypoint Independent"; + displayName = "STR_ACE_Respawn_RallypointIndependent"; vehicleClass = QGVAR(Rallypoints); class ACE_Actions: ACE_Actions { diff --git a/addons/respawn/XEH_preInit.sqf b/addons/respawn/XEH_preInit.sqf index f57e1f3714..8b3f309126 100644 --- a/addons/respawn/XEH_preInit.sqf +++ b/addons/respawn/XEH_preInit.sqf @@ -5,6 +5,7 @@ ADDON = false; PREP(canMoveRallypoint); PREP(handleKilled); PREP(handleRespawn); +PREP(handleInitPostServer); PREP(initRallypoint); PREP(module); PREP(moduleFriendlyFire); diff --git a/addons/respawn/functions/fnc_handleInitPostServer.sqf b/addons/respawn/functions/fnc_handleInitPostServer.sqf new file mode 100644 index 0000000000..c83354b24e --- /dev/null +++ b/addons/respawn/functions/fnc_handleInitPostServer.sqf @@ -0,0 +1,54 @@ +// by commy2 +// execute on server only! +#include "script_component.hpp" + +private "_unit"; + +_unit = _this select 0; + +private ["_group0", "_rallypoint"]; + +_group0 = group _unit; // _group is a reserved veriable and shouldn't be used + +_rallypoint = [ + objNull, + missionNamespace getVariable ["ACE_Rallypoint_West", objNull], + missionNamespace getVariable ["ACE_Rallypoint_East", objNull], + missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull] +] select ([west, east, independent] find side _group0) + 1; + +// exit if no moveable rallypoint is placed for that side +if (isNull _rallypoint) exitWith {}; + +// find leader +private "_leaderVarName"; +_leaderVarName = _group0 getVariable [QGVAR(leaderVarName), ""]; + +// exit if group already has a playable slot assigned as rallypoint leader +if (_leaderVarName != "") exitWith { + // assign JIP unit as rallypoint leader + if (str _unit == _leaderVarName) then { + _unit setVariable ["ACE_canMoveRallypoint", true, true]; + }; +}; + +// treat group leader +_unit = leader _group0; + +_leaderVarName = vehicleVarName _unit; + +if (_leaderVarName == "") then { + private "_leaderID"; + _leaderID = GETGVAR(NextLeaderID,0); + + _leaderVarName = format [QGVAR(Rallypoint_Leader_%1), _leaderID]; + + _unit setVehicleVarName _leaderVarName; + + GVAR(NextLeaderID) = _leaderID + 1; +}; + +// prevent group from getting multiple leaders; use this to assign rallypoint moving ability on JIP +_group0 setVariable [QGVAR(leaderVarName), _leaderVarName]; + +_unit setVariable ["ACE_canMoveRallypoint", true, true]; diff --git a/addons/respawn/functions/fnc_handleRespawn.sqf b/addons/respawn/functions/fnc_handleRespawn.sqf index a9fe3293ac..33a0ec09e5 100644 --- a/addons/respawn/functions/fnc_handleRespawn.sqf +++ b/addons/respawn/functions/fnc_handleRespawn.sqf @@ -25,3 +25,8 @@ _respawnedUnit = _this select 0; if (GVAR(SavePreDeathGear)) then { [_respawnedUnit, GVAR(unitGear)] call FUNC(restoreGear); }; + +// fix for setVariable public being lost on respawn for machines that JIP after the command was broadcasted +if (_respawnedUnit getVariable ["ACE_canMoveRallypoint", false]) then { + _respawnedUnit setVariable ["ACE_canMoveRallypoint", true, true]; +}; diff --git a/addons/respawn/stringtable.xml b/addons/respawn/stringtable.xml index 2aa4360275..958bc9b56f 100644 --- a/addons/respawn/stringtable.xml +++ b/addons/respawn/stringtable.xml @@ -37,5 +37,29 @@ Przeteleportowano do punktu zbiórki Odteleportován na rallypoint + + Rallypoint West (Base) + Sammelpunkt West (Basis) + + + Rallypoint East (Base) + Sammelpunkt Ost (Basis) + + + Rallypoint Independent (Base) + Sammelpunkt Widerstand (Basis) + + + Rallypoint West + Sammelpunkt West + + + Rallypoint East + Sammelpunkt Ost + + + Rallypoint Independent + Sammelpunkt Widerstand +