diff --git a/addons/respawn/ACE_Settings.hpp b/addons/respawn/ACE_Settings.hpp index 5c947b8670..f704d25412 100644 --- a/addons/respawn/ACE_Settings.hpp +++ b/addons/respawn/ACE_Settings.hpp @@ -1,3 +1,4 @@ + class ACE_Settings { class GVAR(SavePreDeathGear) { value = 0; diff --git a/addons/respawn/CfgAddons.hpp b/addons/respawn/CfgAddons.hpp index 111613615e..50ea187915 100644 --- a/addons/respawn/CfgAddons.hpp +++ b/addons/respawn/CfgAddons.hpp @@ -1,3 +1,4 @@ + class CfgAddons { class GVAR(Rallypoints) { list[] = {"ACE_Rallypoint_West", "ACE_Rallypoint_East", "ACE_Rallypoint_Independent", "ACE_Rallypoint_West_Base", "ACE_Rallypoint_East_Base", "ACE_Rallypoint_Independent_Base"}; diff --git a/addons/respawn/CfgVehicleClasses.hpp b/addons/respawn/CfgVehicleClasses.hpp index ab9c9b6c7e..817ee8150f 100644 --- a/addons/respawn/CfgVehicleClasses.hpp +++ b/addons/respawn/CfgVehicleClasses.hpp @@ -1,3 +1,4 @@ + class CfgVehicleClasses { class GVAR(Rallypoints) { displayName = CSTRING(EditorCategory); diff --git a/addons/respawn/CfgVehicles.hpp b/addons/respawn/CfgVehicles.hpp index aa99b4e942..8fdfb5f0fc 100644 --- a/addons/respawn/CfgVehicles.hpp +++ b/addons/respawn/CfgVehicles.hpp @@ -1,3 +1,4 @@ + class CfgVehicles { class ACE_Module; class ACE_ModuleRespawn: ACE_Module { @@ -6,7 +7,7 @@ class CfgVehicles { displayName = CSTRING(Module_DisplayName); function = QFUNC(module); scope = 2; - isGlobal = 1; + isGlobal = 0; icon = QUOTE(PATHTOF(UI\Icon_Module_Respawn_ca.paa)); class Arguments { @@ -24,6 +25,7 @@ class CfgVehicles { defaultValue = 1; }; }; + class ModuleDescription { description = CSTRING(Module_Description); }; diff --git a/addons/respawn/XEH_postInit.sqf b/addons/respawn/XEH_postInit.sqf index ada5765e86..22be7b86ac 100644 --- a/addons/respawn/XEH_postInit.sqf +++ b/addons/respawn/XEH_postInit.sqf @@ -2,4 +2,4 @@ #include "script_component.hpp" ["rallypointMoved", {_this call FUNC(updateRallypoint)}] call EFUNC(common,addEventhandler); -["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); // hide enemy rallypoint markers +["playerChanged", {_this call FUNC(handlePlayerChanged)}] call EFUNC(common,addEventhandler); // hide enemy rallypoint markers diff --git a/addons/respawn/XEH_preInit.sqf b/addons/respawn/XEH_preInit.sqf index dd116f108c..eda5293876 100644 --- a/addons/respawn/XEH_preInit.sqf +++ b/addons/respawn/XEH_preInit.sqf @@ -13,7 +13,6 @@ PREP(moduleFriendlyFire); PREP(moduleRallypoint); PREP(moveRallypoint); PREP(removeBody); -PREP(removeDisconnectedPlayer); PREP(restoreGear); PREP(showFriendlyFireMessage); PREP(teleportToRallypoint); diff --git a/addons/respawn/functions/fnc_canMoveRallypoint.sqf b/addons/respawn/functions/fnc_canMoveRallypoint.sqf index d5f325c067..174d76c69d 100644 --- a/addons/respawn/functions/fnc_canMoveRallypoint.sqf +++ b/addons/respawn/functions/fnc_canMoveRallypoint.sqf @@ -1,33 +1,30 @@ /* - Name: ACE_Respawn_fnc_canMoveRallypoint - - Author(s): - commy2 - - Description: - checks if a unit can move a rally point - - Parameters: - 0: OBJECT - unit - 1: OBJECT - side - - Returns: - BOOLEAN -*/ - + * Author: commy2 + * Checks if a unit can move a rally point. + * + * Arguments: + * 0: Unit + * 1: Side + * + * Return Value: + * Can move + * + * Example: + * [ACE_Player, side ACE_Player] call ace_respawn_fnc_canMoveRallypoint + * + * Public: No + */ #include "script_component.hpp" -private ["_unit", "_side"]; +params ["_unit", "_side"]; -_unit = _this select 0; -_side = _this select 1; +// player has to be a rallypoint mover. group leader by default +if !(_unit getVariable ["ACE_canMoveRallypoint", false]) exitWith {false}; -// rallypoint names are defined in CfgVehicles.hpp - -_unit getVariable ["ACE_canMoveRallypoint", false] -&& {!isNull ([ +// rallypoint of that side has to exist +!isNull ([ 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) + 1)} +] select ([west, east, independent] find _side) + 1) // return diff --git a/addons/respawn/functions/fnc_handleInitPostServer.sqf b/addons/respawn/functions/fnc_handleInitPostServer.sqf index 914334cc25..a1e46c1caf 100644 --- a/addons/respawn/functions/fnc_handleInitPostServer.sqf +++ b/addons/respawn/functions/fnc_handleInitPostServer.sqf @@ -1,26 +1,39 @@ -// by commy2 -// execute on server only! +/* + * Author: commy2 + * Handle XEH Init Post on Server. + * Execution on server only. + * + * Arguments: + * 0: Unit + * + * Return Value: + * None + * + * Example: + * [ACE_Player] call ace_respawn_fnc_handleInitPostServer + * + * Public: No + */ #include "script_component.hpp" -PARAMS_1(_unit); +params ["_unit"]; -private ["_group0", "_rallypoint"]; +private ["_groupUnit", "_rallypoint", "_leaderVarName"]; -_group0 = group _unit; // _group-is a reserved veriable and shouldn't be used +_groupUnit = 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; +] select ([west, east, independent] find side _groupUnit) + 1; // exit if no moveable rallypoint is placed for that side if (isNull _rallypoint) exitWith {}; // find leader -private "_leaderVarName"; -_leaderVarName = _group0 getVariable [QGVAR(leaderVarName), ""]; +_leaderVarName = _groupUnit getVariable [QGVAR(leaderVarName), ""]; // exit if group already has a playable slot assigned as rallypoint leader if (_leaderVarName != "") exitWith { @@ -31,7 +44,7 @@ if (_leaderVarName != "") exitWith { }; // treat group leader -_unit = leader _group0; +_unit = leader _groupUnit; _leaderVarName = vehicleVarName _unit; @@ -47,6 +60,6 @@ if (_leaderVarName == "") then { }; // prevent group from getting multiple leaders; use this to assign rallypoint moving ability on JIP -_group0 setVariable [QGVAR(leaderVarName), _leaderVarName]; +_groupUnit setVariable [QGVAR(leaderVarName), _leaderVarName]; _unit setVariable ["ACE_canMoveRallypoint", true, true]; diff --git a/addons/respawn/functions/fnc_handleKilled.sqf b/addons/respawn/functions/fnc_handleKilled.sqf index 99ec308c1c..200e3c98c8 100644 --- a/addons/respawn/functions/fnc_handleKilled.sqf +++ b/addons/respawn/functions/fnc_handleKilled.sqf @@ -1,31 +1,30 @@ /* - Name: ACE_Respawn_fnc_handleKilled - - Author(s): - bux578 - - Description: - Handles the XEH Killed event - - Parameters: - 0: OBJECT - Killed unit - 1: OBJECT - Attacker - - Returns: - VOID -*/ - + * Author: bux578 + * Handles the XEH killed event. + * + * Arguments: + * 0: Unit + * 1: Killer + * + * Return Value: + * None + * + * Example: + * [ACE_player, bad_dude] call ace_respawn_fnc_handleKilled + * + * Public: No + */ #include "script_component.hpp" -PARAMS_1(_killedUnit); +params ["_unit"]; // Saves the gear when the player! (and only him) is killed -if (ACE_player == _killedUnit) then { +if (ACE_player == _unit) then { GVAR(unitGear) = []; if (GVAR(SavePreDeathGear)) then { - GVAR(unitGear) = [_killedUnit] call EFUNC(common,getAllGear); - GVAR(unitGear) pushBack [currentWeapon _killedUnit, currentMuzzle _killedUnit, currentWeaponMode _killedUnit]; + GVAR(unitGear) = [_unit] call EFUNC(common,getAllGear); + GVAR(unitGear) pushBack [currentWeapon _unit, currentMuzzle _unit, currentWeaponMode _unit]; }; }; diff --git a/addons/respawn/functions/fnc_handlePlayerChanged.sqf b/addons/respawn/functions/fnc_handlePlayerChanged.sqf index db699066bc..6ea5d7bb53 100644 --- a/addons/respawn/functions/fnc_handlePlayerChanged.sqf +++ b/addons/respawn/functions/fnc_handlePlayerChanged.sqf @@ -1,44 +1,28 @@ -// by commy2 +/* + * Author: commy2 + * Handle player changed event. Updates visibility of Rallypoint markers. + * + * Arguments: + * 0: New Unit + * + * Return Value: + * None + * + * Example: + * [ACE_player] call ace_respawn_fnc_handlePlayerChanged + * + * Public: No + */ #include "script_component.hpp" -private "_newUnit"; +params ["_newUnit"]; -_newUnit = _this select 0; +private "_side"; +_side = side group _newUnit; -switch (side group _newUnit) do { - case (west): { - ((missionNamespace getVariable ["ACE_Rallypoint_West", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 1; - ((missionNamespace getVariable ["ACE_Rallypoint_East", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_West_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 1; - ((missionNamespace getVariable ["ACE_Rallypoint_East_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - }; - - case (east): { - ((missionNamespace getVariable ["ACE_Rallypoint_West", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_East", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 1; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_West_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_East_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 1; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - }; - - case (independent): { - ((missionNamespace getVariable ["ACE_Rallypoint_West", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_East", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 1; - ((missionNamespace getVariable ["ACE_Rallypoint_West_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_East_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 1; - }; - - default { - ((missionNamespace getVariable ["ACE_Rallypoint_West", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_East", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_West_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_East_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - ((missionNamespace getVariable ["ACE_Rallypoint_Independent_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; - }; -}; +((GETGVAR("ACE_Rallypoint_West", objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == west)); +((GETGVAR("ACE_Rallypoint_West_Base", objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == west)); +((GETGVAR("ACE_Rallypoint_East", objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == east)); +((GETGVAR("ACE_Rallypoint_East_Base", objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == east)); +((GETGVAR("ACE_Rallypoint_Independent", objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == independent)); +((GETGVAR("ACE_Rallypoint_Independent_Base", objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == independent)); diff --git a/addons/respawn/functions/fnc_handleRespawn.sqf b/addons/respawn/functions/fnc_handleRespawn.sqf index 33a0ec09e5..ab5ecedbda 100644 --- a/addons/respawn/functions/fnc_handleRespawn.sqf +++ b/addons/respawn/functions/fnc_handleRespawn.sqf @@ -1,32 +1,29 @@ /* - Name: ACE_Respawn_fnc_handleRespawn - - Author(s): - bux578 - - Description: - Handles the XEH Respawn event - - Parameters: - 0: OBJECT - Respawned Unit - 1: ? - - Returns: - VOID -*/ - + * Author: bux578 + * Handles the XEH Respawn event. + * + * Arguments: + * 0: Unit + * 1: Corpse + * + * Return Value: + * None + * + * Example: + * [ACE_Player, old_body_lying_on_floor] call ace_respawn_fnc_handleRespawn + * + * Public: No + */ #include "script_component.hpp" -private ["_respawnedUnit"]; - -_respawnedUnit = _this select 0; +params ["_unit"]; // Restores the gear when the player respawns if (GVAR(SavePreDeathGear)) then { - [_respawnedUnit, GVAR(unitGear)] call FUNC(restoreGear); + [_unit, 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]; +if (_unit getVariable ["ACE_canMoveRallypoint", false]) then { + _unit setVariable ["ACE_canMoveRallypoint", true, true]; }; diff --git a/addons/respawn/functions/fnc_initRallypoint.sqf b/addons/respawn/functions/fnc_initRallypoint.sqf index bb295a1809..dba1ae5d0a 100644 --- a/addons/respawn/functions/fnc_initRallypoint.sqf +++ b/addons/respawn/functions/fnc_initRallypoint.sqf @@ -1,52 +1,51 @@ /* - Name: ACE_Respawn_fnc_initRallypoint - - Author(s): - commy2 - - Description: - init code for rally points - - Parameters: - 0: OBJECT - rally - - Returns: - VOID -*/ - + * Author: commy2 + * Init code for rallypoints. + * + * Arguments: + * 0: Rallypoint Object + * 1: Respawn Marker + * 2: Side + * + * Return Value: + * None + * + * Example: + * [respawn_object, "", west] call ace_respawn_fnc_initRallypoint + * + * Public: No + */ #include "script_component.hpp" -PARAMS_3(_rallypoint,_respawnMarker,_side); +params ["_rallypoint", "_respawnMarker", "_side"]; private "_name"; _name = typeOf _rallypoint; // init visible marker if (hasInterface) then { - // fix init having wrong position, vars etc. - [_rallypoint, _respawnMarker, _side, _name] spawn { - PARAMS_4(_rallypoint,_respawnMarker,_side,_name); + [{ + params ["_rallypoint", "_respawnMarker", "_side", "_name"]; - private ["_marker", "_type"]; + private ["_marker", "_type", "_date"]; _marker = format ["ACE_Marker_%1", _name]; - // exit if it already exist + // exit if marker already exist if (_marker in allMapMarkers) exitWith {}; _marker = createMarkerLocal [_marker, getPosASL _rallypoint]; _type = ["selector_selectedFriendly", "selector_selectedEnemy"] select (_respawnMarker == ""); _marker setMarkerTypeLocal _type; - _marker setMarkerAlphaLocal ([0,1] select (_side == playerSide)); // playerSide to guarantee init + _marker setMarkerAlphaLocal ([0,1] select (_side == playerSide)); // playerSide to guarantee init - private "_markerDate"; - _markerDate = _rallypoint getVariable [QGVAR(markerDate), ""]; + _date = _rallypoint getVariable [QGVAR(markerDate), ""]; - _marker setMarkerTextLocal _markerDate; + _marker setMarkerTextLocal _date; _rallypoint setVariable [QGVAR(marker), _marker]; - }; + }, [_rallypoint, _respawnMarker, _side, _name], 0.1] call EFUNC(common,waitAndExecute); }; if (!isServer) exitWith {}; @@ -62,7 +61,6 @@ if (isNil _name) then { }; ["rallypointMoved", [_rallypoint, _side]] call EFUNC(common,globalEvent); - } else { deleteVehicle _rallypoint; ACE_LOGERROR("Multiple Rallypoints of same type."); diff --git a/addons/respawn/functions/fnc_module.sqf b/addons/respawn/functions/fnc_module.sqf index 8921c75f54..b37a0a8d91 100644 --- a/addons/respawn/functions/fnc_module.sqf +++ b/addons/respawn/functions/fnc_module.sqf @@ -1,26 +1,25 @@ - /* - Name: ACE_Respawn_fnc_module - - Author(s): - KoffeinFlummi, bux578, esteldunedain, commy2 - - Description: - initializes the respawn module - - Parameters: - 0: OBJECT - logic - 1: ARRAY - synced units - 2: BOOLEAN - activated - - Returns: - VOID -*/ - +/* + * Author: KoffeinFlummi, bux578, esteldunedain, commy2 + * Initializes the respawn module. + * + * Arguments: + * 0: Logic + * 1: Synced units + * 2: Activated + * + * Return Value: + * None + * + * Example: + * [logic, [ACE_Player], true] call ace_respawn_fnc_module + * + * Public: No + */ #include "script_component.hpp" -PARAMS_3(_logic,_units,_activated); +if (!isServer) exitWith {}; -if !(isServer) exitWith {}; +params ["_logic", "_units", "_activated"]; if !(_activated) exitWith {}; @@ -29,20 +28,18 @@ GVAR(Module) = true; [_logic, QGVAR(SavePreDeathGear), "SavePreDeathGear"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(RemoveDeadBodiesDisconnected), "RemoveDeadBodiesDisconnected"] call EFUNC(common,readSettingFromModule); -if (isServer) then { - if (GVAR(RemoveDeadBodiesDisconnected)) then { - addMissionEventHandler ["HandleDisconnect", { - [{ - PARAMS_1(_unit); +if (isServer && {GVAR(RemoveDeadBodiesDisconnected)}) then { + addMissionEventHandler ["HandleDisconnect", { + [{ + params ["_unit"]; - if (!alive _unit) then { - deleteVehicle _unit; - }; - }, - _this, 4, 1] call EFUNC(common,waitAndExecute); - false - }]; - }; + if (!alive _unit) then { + deleteVehicle _unit; + }; + }, + _this, 4] call EFUNC(common,waitAndExecute); + false + }]; }; ACE_LOGINFO("Respawn Module Initialized."); diff --git a/addons/respawn/functions/fnc_moduleFriendlyFire.sqf b/addons/respawn/functions/fnc_moduleFriendlyFire.sqf index 2d81372e85..f5b982f0ea 100644 --- a/addons/respawn/functions/fnc_moduleFriendlyFire.sqf +++ b/addons/respawn/functions/fnc_moduleFriendlyFire.sqf @@ -1,32 +1,33 @@ /* - Name: ACE_Respawn_fnc_moduleFriendlyFire - - Author(s): - commy2 - - Description: - initializes the Friendly Fire Messages module - - Parameters: - 0: OBJECT - logic - 1: ARRAY - synced units - 2: BOOLEAN - activated - - Returns: - VOID -*/ - + * Author: commy2 + * Initializes the friendly fire module. + * + * Arguments: + * 0: Logic + * 1: Synced units + * 2: Activated + * + * Return Value: + * None + * + * Example: + * [logic, [ACE_Player], true] call ace_respawn_fnc_moduleFriendlyFire + * + * Public: No + */ #include "script_component.hpp" -_this spawn { - PARAMS_3(_logic,_units,_activated); +params ["_logic", "_units", "_activated"]; - if !(_activated) exitWith {}; +if !(_activated) exitWith {}; - if (isServer) then { +// this is done for JIP compatibility +if (isServer) then { + [{ missionNamespace setVariable [QGVAR(showFriendlyFireMessage), true]; publicVariable QGVAR(showFriendlyFireMessage); - }; - - ACE_LOGINFO("Friendly Fire Messages Module Initialized."); + }, + [], 0.1] call EFUNC(common,waitAndExecute); }; + +ACE_LOGINFO("Friendly Fire Messages Module Initialized."); diff --git a/addons/respawn/functions/fnc_moduleRallypoint.sqf b/addons/respawn/functions/fnc_moduleRallypoint.sqf index 86a83bf061..89baed660f 100644 --- a/addons/respawn/functions/fnc_moduleRallypoint.sqf +++ b/addons/respawn/functions/fnc_moduleRallypoint.sqf @@ -1,29 +1,29 @@ /* - Name: ACE_Respawn_fnc_moduleRallypoint - - Author(s): - commy2 - - Description: - initializes the Rallypoint module - - Parameters: - 0: OBJECT - logic - 1: ARRAY - synced units - 2: BOOLEAN - activated - - Returns: - VOID -*/ - + * Author: commy2 + * Initializes the Rallypoint module. + * + * Arguments: + * 0: Logic + * 1: Synced units + * 2: Activated + * + * Return Value: + * None + * + * Example: + * [logic, [ACE_Player], true] call ace_respawn_fnc_moduleRallypoint + * + * Public: No + */ #include "script_component.hpp" -PARAMS_3(_logic,_units,_activated); +params ["_logic", "_units", "_activated"]; if !(_activated) exitWith {}; { _x setVariable ["ACE_canMoveRallypoint", true]; -} forEach _units; + false +} count _units; ACE_LOGINFO("Rallypoint Module Initialized."); diff --git a/addons/respawn/functions/fnc_moveRallypoint.sqf b/addons/respawn/functions/fnc_moveRallypoint.sqf index d512c23886..bf96905343 100644 --- a/addons/respawn/functions/fnc_moveRallypoint.sqf +++ b/addons/respawn/functions/fnc_moveRallypoint.sqf @@ -1,52 +1,47 @@ /* - Name: ACE_Respawn_fnc_moveRallypoint - - Author(s): - commy2 - - Description: - Moves a rallypoint to the player's location - - Parameters: - 0: OBJECT - unit - 1: OBJECT - side - - Returns: - VOID -*/ - + * Author: commy2 + * Moves a rallypoint to the players location. + * + * Arguments: + * 0: Unit + * 1: Side + * + * Return Value: + * None + * + * Example: + * [ACE_Player, side ACE_Player] call ace_respawn_fnc_moveRallypoint + * + * Public: No + */ #include "script_component.hpp" -PARAMS_2(_unit,_side); +params ["_unit", "_side"]; private ["_rallypoint", "_position"]; -// rallypoint names are defined in CfgVehicles.hpp - _rallypoint = [ - objNull, - missionNamespace getVariable ["ACE_Rallypoint_West", objNull], - missionNamespace getVariable ["ACE_Rallypoint_East", objNull], - missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull] + 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) + 1; -TRACE_3("moving rally",_unit, _rallypoint, (typeOf _rallypoint)); +TRACE_3("moving rally",_unit,_rallypoint,typeOf _rallypoint); if (isNull _rallypoint) exitWith {}; _position = getPosATL _unit; _position = _position findEmptyPosition [0, 2, typeOf _rallypoint]; -if (count _position == 0) then {_position = getPosATL _unit}; + +if (_position isEqualTo []) then {_position = getPosATL _unit}; _position set [2, 0]; [localize LSTRING(Deploy)] call EFUNC(common,displayTextStructured); [{ - _rallypoint = _this select 0; - _unit = _this select 1; - _position = _this select 2; - _rallypoint = _this select 3; + params ["_rallypoint", "_unit", "_position"]; _rallypoint setPosATL _position; _unit reveal _rallypoint; @@ -56,5 +51,4 @@ _position set [2, 0]; ["rallypointMoved", [_rallypoint, _side, _position]] call EFUNC(common,globalEvent); [localize LSTRING(Deployed)] call EFUNC(common,displayTextStructured); -}, -[_rallypoint, _unit, _position, _rallypoint], 5, 1] call EFUNC(common,waitAndExecute); +}, [_rallypoint, _unit, _position], 5] call EFUNC(common,waitAndExecute); diff --git a/addons/respawn/functions/fnc_removeBody.sqf b/addons/respawn/functions/fnc_removeBody.sqf index e00f633e6c..e9676696a1 100644 --- a/addons/respawn/functions/fnc_removeBody.sqf +++ b/addons/respawn/functions/fnc_removeBody.sqf @@ -1,36 +1,27 @@ /* - Name: ACE_Respawn_fnc_removeBody - - Author(s): - bux578 - - Description: - removes a given body - - Parameters: - 0: OBJECT - body - 1: BOOLEAN - forceRemove // not used atm - - Returns: - VOID -*/ - + * Author: bux578, commy2 + * Removes a given body. + * + * Arguments: + * 0: Body + * + * Return Value: + * None + * + * Example: + * [corpse] call ace_respawn_fnc_removeBody + * + * Public: No + */ #include "script_component.hpp" -private ["_body", "_forceRemove", "_bodyRemoveTimer"]; +params ["_body", "_forceRemove"]; -_body = _this select 0; -_forceRemove = _this select 1; - -_bodyRemoveTimer = GVAR(BodyRemoveTimer) max 0; - -// could be used for SpecOps missions. -if (_forceRemove) then { - _bodyRemoveTimer = 2; -}; +private "_bodyRemoveTimer"; +_bodyRemoveTimer = [GVAR(BodyRemoveTimer) max 0, 2] select _forceRemove; // could be used for SpecOps missions. [{ // hideBody takes ~20s till body is fully underground // a better hideBody would make this more aesthetic deleteVehicle _this; -}, _body, _bodyRemoveTimer, 1] call EFUNC(common,waitAndExecute); +}, _body, _bodyRemoveTimer] call EFUNC(common,waitAndExecute); diff --git a/addons/respawn/functions/fnc_removeDisconnectedPlayer.sqf b/addons/respawn/functions/fnc_removeDisconnectedPlayer.sqf deleted file mode 100644 index 7bd0a6707f..0000000000 --- a/addons/respawn/functions/fnc_removeDisconnectedPlayer.sqf +++ /dev/null @@ -1,31 +0,0 @@ -/* - Name: ACE_Respawn_fnc_removeDisconnectedPlayer - - Author(s): - commy2 - - Description: - handles the disconnected event - - Parameters: - 0: BOOLEAN - forceRemove // not used atm - - Returns: - VOID -*/ - -#include "script_component.hpp" - -private ["_forceRemove", "_body", "_uid"]; - -_forceRemove = _this select 0; - -{ - if (getPlayerUID _x == _uid) exitWith { - _body = _x; - }; -} forEach playableUnits; - -if (!isNil "_body" && {!alive _body}) then { - [_body, _forceRemove] call FUNC(removeBody); -}; diff --git a/addons/respawn/functions/fnc_restoreGear.sqf b/addons/respawn/functions/fnc_restoreGear.sqf index fd3f03d7aa..fb430bc400 100644 --- a/addons/respawn/functions/fnc_restoreGear.sqf +++ b/addons/respawn/functions/fnc_restoreGear.sqf @@ -1,34 +1,22 @@ /* - Name: ACE_Respawn_fnc_restoreGear - - Author(s): - bux578 - - Description: - Restores previously saved gear - - Parameters: - 0: OBJECT - unit - 1: ARRAY - Array containing all gear (result of ACE_common_fnc_getAllGear) - - Returns: - VOID -*/ - + * Author: bux578 + * Restores previously saved gear. + * + * Arguments: + * 0: Unit + * 1: All Gear based on return value of ACE_common_fnc_getAllGear + * + * Return Value: + * None + * + * Example: + * [ACE_Player, stored_allGear] call ace_respawn_fnc_restoreGear + * + * Public: No + */ #include "script_component.hpp" -PARAMS_2(_unit,_allGear); - -private ["_unit", "_allGear", "_headgear", "_goggles", -"_uniform", "_uniformitems", -"_vest", "_vestitems", -"_backpack", "_backpackitems", "_backpa", -"_primaryweapon", "_primaryweaponitems", "_primaryweaponmagazine", -"_secondaryweapon", "_secondaryweaponitems", "_secondaryweaponmagazine", -"_handgunweapon", "_handgunweaponitems", "_handgunweaponmagazine", -"_assigneditems", "_binocular", -"_activeWeaponAndMuzzle", "_activeWeapon", "_activeMuzzle", "_activeWeaponMode"]; - +params ["_unit", "_allGear"]; // remove all starting gear of a player removeAllWeapons _unit; @@ -40,77 +28,66 @@ removeAllAssignedItems _unit; clearAllItemsFromBackpack _unit; removeBackpack _unit; -_headgear = _allGear select 0; -_goggles = _allGear select 1; -_uniform = _allGear select 2; -_uniformitems = _allGear select 3; -_vest = _allGear select 4; -_vestitems = _allGear select 5; -_backpack = _allGear select 6; -_backpackitems = _allGear select 7; -_primaryweapon = _allGear select 8; -_primaryweaponitems = _allGear select 9; -_primaryweaponmagazine = _allGear select 10; -_secondaryweapon = _allGear select 11; -_secondaryweaponitems = _allGear select 12; -_secondaryweaponmagazine = _allGear select 13; -_handgunweapon = _allGear select 14; -_handgunweaponitems = _allGear select 15; -_handgunweaponmagazine = _allGear select 16; -_assigneditems = _allGear select 17; -_binocular = _allGear select 18; -_activeWeaponAndMuzzle = _allGear select 19; - +_allGear params [ + "_headgear", "_goggles", + "_uniform", "_uniformitems", + "_vest", "_vestitems", + "_backpack", "_backpackitems", + "_primaryweapon", "_primaryweaponitems", "_primaryweaponmagazine", + "_secondaryweapon", "_secondaryweaponitems", "_secondaryweaponmagazine", + "_handgunweapon", "_handgunweaponitems", "_handgunweaponmagazine", + "_assigneditems", "_binocular", + "_activeWeaponAndMuzzle" +]; // start restoring the items -if (_headgear != "") then { - _unit addHeadgear _headgear; -}; -if (_uniform != "") then { - _unit forceAddUniform _uniform; -}; -if (_vest != "") then { - _unit addVest _vest; -}; -if (_goggles != "") then { - _unit addGoggles _goggles; -}; +if (_headgear != "") then {_unit addHeadgear _headgear}; +if (_goggles != "") then {_unit addGoggles _goggles}; +if (_uniform != "") then {_unit forceAddUniform _uniform}; +if (_vest != "") then {_unit addVest _vest}; { _unit addItemToUniform _x; -} forEach _uniformitems; + false +} count _uniformitems; { _unit addItemToVest _x; -} forEach _vestitems; + false +} count _vestitems; private "_flagRemoveDummyBag"; -_flagRemoveDummyBag = false; -if (format["%1", _backpack] != "") then { +if (format ["%1", _backpack] != "") then { _unit addBackpack _backpack; - _backpa = unitBackpack _unit; - clearMagazineCargoGlobal _backpa; - clearWeaponCargoGlobal _backpa; - clearItemCargoGlobal _backpa; + // make sure the backpack is empty. Some bags are prefilled by config + private "_backpackObject"; + _backpackObject = unitBackpack _unit; + + clearMagazineCargoGlobal _backpackObject; + clearWeaponCargoGlobal _backpackObject; + clearItemCargoGlobal _backpackObject; + { _unit addItemToBackpack _x; - } forEach _backpackitems; + false + } count _backpackitems; + _flagRemoveDummyBag = false; } else { // dummy backpack to ensure mags being loaded - _unit addBackpack "B_Kitbag_Base"; + _unit addBackpack "Bag_Base"; _flagRemoveDummyBag = true; }; - // primaryWeapon if ((_primaryweapon != "") && {_primaryweapon != "ACE_FakePrimaryWeapon"}) then { { _unit addMagazine _x; - } forEach _primaryweaponmagazine; + false + } count _primaryweaponmagazine; _unit addWeapon _primaryweapon; @@ -118,15 +95,16 @@ if ((_primaryweapon != "") && {_primaryweapon != "ACE_FakePrimaryWeapon"}) then if (_x != "") then { _unit addPrimaryWeaponItem _x; }; - } forEach _primaryweaponitems; + false + } count _primaryweaponitems; }; - // secondaryWeapon if (_secondaryweapon != "") then { { _unit addMagazine _x; - } forEach _secondaryweaponmagazine; + false + } count _secondaryweaponmagazine; _unit addWeapon _secondaryweapon; @@ -134,15 +112,16 @@ if (_secondaryweapon != "") then { if (_x != "") then { _unit addSecondaryWeaponItem _x; }; - } forEach _secondaryweaponitems; + false + } count _secondaryweaponitems; }; - // handgun if (_handgunweapon != "") then { { _unit addMagazine _x; - } forEach _handgunweaponmagazine; + false + } count _handgunweaponmagazine; _unit addWeapon _handgunweapon; @@ -150,20 +129,19 @@ if (_handgunweapon != "") then { if (_x != "") then { _unit addHandgunItem _x; }; - } forEach _handgunweaponitems; + false + } count _handgunweaponitems; }; - // remove dummy bagpack if (_flagRemoveDummyBag) then { removeBackpack _unit; }; - -_assignedItems = _assignedItems - [_binocular]; +_assignedItems deleteAt (_assignedItems find _binocular); // items -{_unit linkItem _x} forEach _assignedItems; +{_unit linkItem _x; false} count _assignedItems; _unit addWeapon _binocular; @@ -178,24 +156,24 @@ if ("Laserdesignator" in assignedItems _unit) then { }; // restore the last active weapon, muzzle and weaponMode -_activeWeapon = _activeWeaponAndMuzzle select 0; -_activeMuzzle = _activeWeaponAndMuzzle select 1; -_activeWeaponMode = _activeWeaponAndMuzzle select 2; - -if (!(_activeMuzzle isEqualTo "") and - !(_activeMuzzle isEqualTo _activeWeapon) and - (_activeMuzzle in getArray (configfile >> "CfgWeapons" >> _activeWeapon >> "muzzles"))) then { +_activeWeaponAndMuzzle params ["_activeWeapon", "_activeMuzzle", "_activeWeaponMode"] +if ( + (_activeMuzzle != "") && + {_activeMuzzle != _activeWeapon} && + {_activeMuzzle in getArray (configfile >> "CfgWeapons" >> _activeWeapon >> "muzzles")} +) then { _unit selectWeapon _activeMuzzle; } else { - if (!(_activeWeapon isEqualTo "")) then { + if (_activeWeapon != "") then { _unit selectWeapon _activeWeapon; }; }; -if (!(currentWeapon _unit isEqualTo "")) then { - private ["_index"]; +if (currentWeapon _unit != "") then { + private "_index"; _index = 0; + while { _index < 100 && {currentWeaponMode _unit != _activeWeaponMode} } do { diff --git a/addons/respawn/functions/fnc_showFriendlyFireMessage.sqf b/addons/respawn/functions/fnc_showFriendlyFireMessage.sqf index 1fdd10da4e..1c5a7b7cc2 100644 --- a/addons/respawn/functions/fnc_showFriendlyFireMessage.sqf +++ b/addons/respawn/functions/fnc_showFriendlyFireMessage.sqf @@ -1,28 +1,24 @@ /* - Name: ACE_Respawn_fnc_showFriendlyFireMessages - - Author(s): - commy2 - - Description: - shows a message in system chat of who killed who - - Parameters: - 0: OBJECT - unit - 1: OBJECT - killer - - Returns: - VOID -*/ - + * Author: commy2 + * Shows a message in system chat of who killed whom. + * + * Arguments: + * 0: Unitn + * 1: Killer + * + * Return Value: + * None + * + * Example: + * [ACE_Player, killer] call ace_module_fnc_functionName + * + * Public: No + */ #include "script_component.hpp" -private ["_unit", "_killer"]; +params ["_unit", "_killer"]; -_unit = _this select 0; -_killer = _this select 1; - -if (_unit != _killer && side group _unit in [side group ACE_player, civilian] && {side group _killer == side group ACE_player}) then { +if (_unit != _killer && {side group _unit in [side group ACE_player, civilian]} && {side group _killer == side group ACE_player}) then { systemChat format ["%1 was killed by %2", [_unit] call EFUNC(common,getName), [_killer] call EFUNC(common,getName)]; // Raise ACE globalEvent diff --git a/addons/respawn/functions/fnc_teleportToRallypoint.sqf b/addons/respawn/functions/fnc_teleportToRallypoint.sqf index 59a9766114..88bd0d6d52 100644 --- a/addons/respawn/functions/fnc_teleportToRallypoint.sqf +++ b/addons/respawn/functions/fnc_teleportToRallypoint.sqf @@ -1,29 +1,25 @@ /* * Author: commy2 - * teleports a unit to a rallypoint + * Teleports a unit to a rallypoint * * Arguments: - * 0: unit - * 1: side? - * 2: teleport to base + * 0: Unit + * 1: Side + * 2: Rallypoint name * * Return Value: - * Nothing + * None * * Example: - * [,,] call ACE_Respawn_fnc_teleportToRallypoint; + * [ACE_player, side ACE_Player, rallypoint_name] call ace_respawn_fnc_teleportToRallypoint; * * Public: No */ #include "script_component.hpp" -PARAMS_3(_unit,_side,_rallypoint); +params ["_unit", "_side", "_rallypoint"]; -private ["_toBase"]; - -// rallypoint names are defined in CfgVehicles.hpp - -//IGNORE_PRIVATE_WARNING("_Base") +private "_toBase"; _toBase = _rallypoint find "_Base" != -1; _rallypoint = missionNamespace getVariable [_rallypoint, objNull], @@ -31,4 +27,5 @@ _rallypoint = missionNamespace getVariable [_rallypoint, objNull], if (isNull _rallypoint) exitWith {}; _unit setPosASL getPosASL _rallypoint; + [[localize LSTRING(TeleportedToRallypoint), localize LSTRING(TeleportedToBase)] select _toBase] call EFUNC(common,displayTextStructured); diff --git a/addons/respawn/functions/fnc_updateRallypoint.sqf b/addons/respawn/functions/fnc_updateRallypoint.sqf index 248955155a..8b34f87019 100644 --- a/addons/respawn/functions/fnc_updateRallypoint.sqf +++ b/addons/respawn/functions/fnc_updateRallypoint.sqf @@ -1,11 +1,23 @@ -// by commy2 +/* + * Author: commy2 + * Updates marker position and texts. + * + * Arguments: + * 0: Marker + * 1: Side + * 2: Position + * + * Return Value: + * None + * + * Example: + * [marker_name, side ACE_Player, getPos ACE_Player] call ace_respawn_fnc_updateRallypoint + * + * Public: No + */ #include "script_component.hpp" -private ["_rallypoint", "_side", "_position"]; - -_rallypoint = _this select 0; -_side = _this select 1; -_position = _this select 2; +params ["_rallypoint", "_side", "_position"]; if (!hasInterface) exitWith {};