cleanup respawn module, close #2184

This commit is contained in:
commy2 2015-09-26 16:26:41 +02:00
parent 5f7c30dd7c
commit 5425836e47
22 changed files with 371 additions and 444 deletions

View File

@ -1,3 +1,4 @@
class ACE_Settings { class ACE_Settings {
class GVAR(SavePreDeathGear) { class GVAR(SavePreDeathGear) {
value = 0; value = 0;

View File

@ -1,3 +1,4 @@
class CfgAddons { class CfgAddons {
class GVAR(Rallypoints) { 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"}; list[] = {"ACE_Rallypoint_West", "ACE_Rallypoint_East", "ACE_Rallypoint_Independent", "ACE_Rallypoint_West_Base", "ACE_Rallypoint_East_Base", "ACE_Rallypoint_Independent_Base"};

View File

@ -1,3 +1,4 @@
class CfgVehicleClasses { class CfgVehicleClasses {
class GVAR(Rallypoints) { class GVAR(Rallypoints) {
displayName = CSTRING(EditorCategory); displayName = CSTRING(EditorCategory);

View File

@ -1,3 +1,4 @@
class CfgVehicles { class CfgVehicles {
class ACE_Module; class ACE_Module;
class ACE_ModuleRespawn: ACE_Module { class ACE_ModuleRespawn: ACE_Module {
@ -6,7 +7,7 @@ class CfgVehicles {
displayName = CSTRING(Module_DisplayName); displayName = CSTRING(Module_DisplayName);
function = QFUNC(module); function = QFUNC(module);
scope = 2; scope = 2;
isGlobal = 1; isGlobal = 0;
icon = QUOTE(PATHTOF(UI\Icon_Module_Respawn_ca.paa)); icon = QUOTE(PATHTOF(UI\Icon_Module_Respawn_ca.paa));
class Arguments { class Arguments {
@ -24,6 +25,7 @@ class CfgVehicles {
defaultValue = 1; defaultValue = 1;
}; };
}; };
class ModuleDescription { class ModuleDescription {
description = CSTRING(Module_Description); description = CSTRING(Module_Description);
}; };

View File

@ -2,4 +2,4 @@
#include "script_component.hpp" #include "script_component.hpp"
["rallypointMoved", {_this call FUNC(updateRallypoint)}] call EFUNC(common,addEventhandler); ["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

View File

@ -13,7 +13,6 @@ PREP(moduleFriendlyFire);
PREP(moduleRallypoint); PREP(moduleRallypoint);
PREP(moveRallypoint); PREP(moveRallypoint);
PREP(removeBody); PREP(removeBody);
PREP(removeDisconnectedPlayer);
PREP(restoreGear); PREP(restoreGear);
PREP(showFriendlyFireMessage); PREP(showFriendlyFireMessage);
PREP(teleportToRallypoint); PREP(teleportToRallypoint);

View File

@ -1,33 +1,30 @@
/* /*
Name: ACE_Respawn_fnc_canMoveRallypoint * Author: commy2
* Checks if a unit can move a rally point.
Author(s): *
commy2 * Arguments:
* 0: Unit <OBJECT>
Description: * 1: Side <SIDE>
checks if a unit can move a rally point *
* Return Value:
Parameters: * Can move <BOOL>
0: OBJECT - unit *
1: OBJECT - side * Example:
* [ACE_Player, side ACE_Player] call ace_respawn_fnc_canMoveRallypoint
Returns: *
BOOLEAN * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_unit", "_side"]; params ["_unit", "_side"];
_unit = _this select 0; // player has to be a rallypoint mover. group leader by default
_side = _this select 1; if !(_unit getVariable ["ACE_canMoveRallypoint", false]) exitWith {false};
// rallypoint names are defined in CfgVehicles.hpp // rallypoint of that side has to exist
!isNull ([
_unit getVariable ["ACE_canMoveRallypoint", false]
&& {!isNull ([
objNull, objNull,
missionNamespace getVariable ["ACE_Rallypoint_West", objNull], missionNamespace getVariable ["ACE_Rallypoint_West", objNull],
missionNamespace getVariable ["ACE_Rallypoint_East", objNull], missionNamespace getVariable ["ACE_Rallypoint_East", objNull],
missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull] missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull]
] select ([west, east, independent] find _side) + 1)} ] select ([west, east, independent] find _side) + 1) // return

View File

@ -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 <OBJECT>
*
* Return Value:
* None
*
* Example:
* [ACE_Player] call ace_respawn_fnc_handleInitPostServer
*
* Public: No
*/
#include "script_component.hpp" #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 = [ _rallypoint = [
objNull, objNull,
missionNamespace getVariable ["ACE_Rallypoint_West", objNull], missionNamespace getVariable ["ACE_Rallypoint_West", objNull],
missionNamespace getVariable ["ACE_Rallypoint_East", objNull], missionNamespace getVariable ["ACE_Rallypoint_East", objNull],
missionNamespace getVariable ["ACE_Rallypoint_Independent", 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 // exit if no moveable rallypoint is placed for that side
if (isNull _rallypoint) exitWith {}; if (isNull _rallypoint) exitWith {};
// find leader // find leader
private "_leaderVarName"; _leaderVarName = _groupUnit getVariable [QGVAR(leaderVarName), ""];
_leaderVarName = _group0 getVariable [QGVAR(leaderVarName), ""];
// exit if group already has a playable slot assigned as rallypoint leader // exit if group already has a playable slot assigned as rallypoint leader
if (_leaderVarName != "") exitWith { if (_leaderVarName != "") exitWith {
@ -31,7 +44,7 @@ if (_leaderVarName != "") exitWith {
}; };
// treat group leader // treat group leader
_unit = leader _group0; _unit = leader _groupUnit;
_leaderVarName = vehicleVarName _unit; _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 // 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]; _unit setVariable ["ACE_canMoveRallypoint", true, true];

View File

@ -1,31 +1,30 @@
/* /*
Name: ACE_Respawn_fnc_handleKilled * Author: bux578
* Handles the XEH killed event.
Author(s): *
bux578 * Arguments:
* 0: Unit <OBJECT>
Description: * 1: Killer <OBJECT>
Handles the XEH Killed event *
* Return Value:
Parameters: * None
0: OBJECT - Killed unit *
1: OBJECT - Attacker * Example:
* [ACE_player, bad_dude] call ace_respawn_fnc_handleKilled
Returns: *
VOID * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_1(_killedUnit); params ["_unit"];
// Saves the gear when the player! (and only him) is killed // Saves the gear when the player! (and only him) is killed
if (ACE_player == _killedUnit) then { if (ACE_player == _unit) then {
GVAR(unitGear) = []; GVAR(unitGear) = [];
if (GVAR(SavePreDeathGear)) then { if (GVAR(SavePreDeathGear)) then {
GVAR(unitGear) = [_killedUnit] call EFUNC(common,getAllGear); GVAR(unitGear) = [_unit] call EFUNC(common,getAllGear);
GVAR(unitGear) pushBack [currentWeapon _killedUnit, currentMuzzle _killedUnit, currentWeaponMode _killedUnit]; GVAR(unitGear) pushBack [currentWeapon _unit, currentMuzzle _unit, currentWeaponMode _unit];
}; };
}; };

View File

@ -1,44 +1,28 @@
// by commy2 /*
* Author: commy2
* Handle player changed event. Updates visibility of Rallypoint markers.
*
* Arguments:
* 0: New Unit <OBJECT>
*
* Return Value:
* None
*
* Example:
* [ACE_player] call ace_respawn_fnc_handlePlayerChanged
*
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
private "_newUnit"; params ["_newUnit"];
_newUnit = _this select 0; private "_side";
_side = side group _newUnit;
switch (side group _newUnit) do { ((GETGVAR("ACE_Rallypoint_West", objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == west));
case (west): { ((GETGVAR("ACE_Rallypoint_West_Base", objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == west));
((missionNamespace getVariable ["ACE_Rallypoint_West", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 1; ((GETGVAR("ACE_Rallypoint_East", objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == east));
((missionNamespace getVariable ["ACE_Rallypoint_East", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; ((GETGVAR("ACE_Rallypoint_East_Base", objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == east));
((missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 0; ((GETGVAR("ACE_Rallypoint_Independent", objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == independent));
((missionNamespace getVariable ["ACE_Rallypoint_West_Base", objNull]) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal 1; ((GETGVAR("ACE_Rallypoint_Independent_Base", objNull)) getVariable [QGVAR(marker), ""]) setMarkerAlphaLocal ([0, 1] select (_side == independent));
((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;
};
};

View File

@ -1,32 +1,29 @@
/* /*
Name: ACE_Respawn_fnc_handleRespawn * Author: bux578
* Handles the XEH Respawn event.
Author(s): *
bux578 * Arguments:
* 0: Unit <OBJECT>
Description: * 1: Corpse <OBJECT>
Handles the XEH Respawn event *
* Return Value:
Parameters: * None
0: OBJECT - Respawned Unit *
1: ? * Example:
* [ACE_Player, old_body_lying_on_floor] call ace_respawn_fnc_handleRespawn
Returns: *
VOID * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_respawnedUnit"]; params ["_unit"];
_respawnedUnit = _this select 0;
// Restores the gear when the player respawns // Restores the gear when the player respawns
if (GVAR(SavePreDeathGear)) then { 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 // fix for setVariable public being lost on respawn for machines that JIP after the command was broadcasted
if (_respawnedUnit getVariable ["ACE_canMoveRallypoint", false]) then { if (_unit getVariable ["ACE_canMoveRallypoint", false]) then {
_respawnedUnit setVariable ["ACE_canMoveRallypoint", true, true]; _unit setVariable ["ACE_canMoveRallypoint", true, true];
}; };

View File

@ -1,52 +1,51 @@
/* /*
Name: ACE_Respawn_fnc_initRallypoint * Author: commy2
* Init code for rallypoints.
Author(s): *
commy2 * Arguments:
* 0: Rallypoint Object <OBJECT>
Description: * 1: Respawn Marker <STRING>
init code for rally points * 2: Side <SIDE>
*
Parameters: * Return Value:
0: OBJECT - rally * None
*
Returns: * Example:
VOID * [respawn_object, "", west] call ace_respawn_fnc_initRallypoint
*/ *
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_3(_rallypoint,_respawnMarker,_side); params ["_rallypoint", "_respawnMarker", "_side"];
private "_name"; private "_name";
_name = typeOf _rallypoint; _name = typeOf _rallypoint;
// init visible marker // init visible marker
if (hasInterface) then { if (hasInterface) then {
// fix init having wrong position, vars etc. [{
[_rallypoint, _respawnMarker, _side, _name] spawn { params ["_rallypoint", "_respawnMarker", "_side", "_name"];
PARAMS_4(_rallypoint,_respawnMarker,_side,_name);
private ["_marker", "_type"]; private ["_marker", "_type", "_date"];
_marker = format ["ACE_Marker_%1", _name]; _marker = format ["ACE_Marker_%1", _name];
// exit if it already exist // exit if marker already exist
if (_marker in allMapMarkers) exitWith {}; if (_marker in allMapMarkers) exitWith {};
_marker = createMarkerLocal [_marker, getPosASL _rallypoint]; _marker = createMarkerLocal [_marker, getPosASL _rallypoint];
_type = ["selector_selectedFriendly", "selector_selectedEnemy"] select (_respawnMarker == ""); _type = ["selector_selectedFriendly", "selector_selectedEnemy"] select (_respawnMarker == "");
_marker setMarkerTypeLocal _type; _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"; _date = _rallypoint getVariable [QGVAR(markerDate), ""];
_markerDate = _rallypoint getVariable [QGVAR(markerDate), ""];
_marker setMarkerTextLocal _markerDate; _marker setMarkerTextLocal _date;
_rallypoint setVariable [QGVAR(marker), _marker]; _rallypoint setVariable [QGVAR(marker), _marker];
}; }, [_rallypoint, _respawnMarker, _side, _name], 0.1] call EFUNC(common,waitAndExecute);
}; };
if (!isServer) exitWith {}; if (!isServer) exitWith {};
@ -62,7 +61,6 @@ if (isNil _name) then {
}; };
["rallypointMoved", [_rallypoint, _side]] call EFUNC(common,globalEvent); ["rallypointMoved", [_rallypoint, _side]] call EFUNC(common,globalEvent);
} else { } else {
deleteVehicle _rallypoint; deleteVehicle _rallypoint;
ACE_LOGERROR("Multiple Rallypoints of same type."); ACE_LOGERROR("Multiple Rallypoints of same type.");

View File

@ -1,26 +1,25 @@
/* /*
Name: ACE_Respawn_fnc_module * Author: KoffeinFlummi, bux578, esteldunedain, commy2
* Initializes the respawn module.
Author(s): *
KoffeinFlummi, bux578, esteldunedain, commy2 * Arguments:
* 0: Logic <OBJECT>
Description: * 1: Synced units <ARRAY>
initializes the respawn module * 2: Activated <BOOL>
*
Parameters: * Return Value:
0: OBJECT - logic * None
1: ARRAY<OBJECT> - synced units *
2: BOOLEAN - activated * Example:
* [logic, [ACE_Player], true] call ace_respawn_fnc_module
Returns: *
VOID * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_3(_logic,_units,_activated); if (!isServer) exitWith {};
if !(isServer) exitWith {}; params ["_logic", "_units", "_activated"];
if !(_activated) exitWith {}; if !(_activated) exitWith {};
@ -29,20 +28,18 @@ GVAR(Module) = true;
[_logic, QGVAR(SavePreDeathGear), "SavePreDeathGear"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(SavePreDeathGear), "SavePreDeathGear"] call EFUNC(common,readSettingFromModule);
[_logic, QGVAR(RemoveDeadBodiesDisconnected), "RemoveDeadBodiesDisconnected"] call EFUNC(common,readSettingFromModule); [_logic, QGVAR(RemoveDeadBodiesDisconnected), "RemoveDeadBodiesDisconnected"] call EFUNC(common,readSettingFromModule);
if (isServer) then { if (isServer && {GVAR(RemoveDeadBodiesDisconnected)}) then {
if (GVAR(RemoveDeadBodiesDisconnected)) then { addMissionEventHandler ["HandleDisconnect", {
addMissionEventHandler ["HandleDisconnect", { [{
[{ params ["_unit"];
PARAMS_1(_unit);
if (!alive _unit) then { if (!alive _unit) then {
deleteVehicle _unit; deleteVehicle _unit;
}; };
}, },
_this, 4, 1] call EFUNC(common,waitAndExecute); _this, 4] call EFUNC(common,waitAndExecute);
false false
}]; }];
};
}; };
ACE_LOGINFO("Respawn Module Initialized."); ACE_LOGINFO("Respawn Module Initialized.");

View File

@ -1,32 +1,33 @@
/* /*
Name: ACE_Respawn_fnc_moduleFriendlyFire * Author: commy2
* Initializes the friendly fire module.
Author(s): *
commy2 * Arguments:
* 0: Logic <OBJECT>
Description: * 1: Synced units <ARRAY>
initializes the Friendly Fire Messages module * 2: Activated <BOOL>
*
Parameters: * Return Value:
0: OBJECT - logic * None
1: ARRAY<OBJECT> - synced units *
2: BOOLEAN - activated * Example:
* [logic, [ACE_Player], true] call ace_respawn_fnc_moduleFriendlyFire
Returns: *
VOID * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
_this spawn { params ["_logic", "_units", "_activated"];
PARAMS_3(_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]; missionNamespace setVariable [QGVAR(showFriendlyFireMessage), true];
publicVariable QGVAR(showFriendlyFireMessage); publicVariable QGVAR(showFriendlyFireMessage);
}; },
[], 0.1] call EFUNC(common,waitAndExecute);
ACE_LOGINFO("Friendly Fire Messages Module Initialized.");
}; };
ACE_LOGINFO("Friendly Fire Messages Module Initialized.");

View File

@ -1,29 +1,29 @@
/* /*
Name: ACE_Respawn_fnc_moduleRallypoint * Author: commy2
* Initializes the Rallypoint module.
Author(s): *
commy2 * Arguments:
* 0: Logic <OBJECT>
Description: * 1: Synced units <ARRAY>
initializes the Rallypoint module * 2: Activated <BOOL>
*
Parameters: * Return Value:
0: OBJECT - logic * None
1: ARRAY<OBJECT> - synced units *
2: BOOLEAN - activated * Example:
* [logic, [ACE_Player], true] call ace_respawn_fnc_moduleRallypoint
Returns: *
VOID * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_3(_logic,_units,_activated); params ["_logic", "_units", "_activated"];
if !(_activated) exitWith {}; if !(_activated) exitWith {};
{ {
_x setVariable ["ACE_canMoveRallypoint", true]; _x setVariable ["ACE_canMoveRallypoint", true];
} forEach _units; false
} count _units;
ACE_LOGINFO("Rallypoint Module Initialized."); ACE_LOGINFO("Rallypoint Module Initialized.");

View File

@ -1,52 +1,47 @@
/* /*
Name: ACE_Respawn_fnc_moveRallypoint * Author: commy2
* Moves a rallypoint to the players location.
Author(s): *
commy2 * Arguments:
* 0: Unit <OBJECT>
Description: * 1: Side <SIDE>
Moves a rallypoint to the player's location *
* Return Value:
Parameters: * None
0: OBJECT - unit *
1: OBJECT - side * Example:
* [ACE_Player, side ACE_Player] call ace_respawn_fnc_moveRallypoint
Returns: *
VOID * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_unit,_side); params ["_unit", "_side"];
private ["_rallypoint", "_position"]; private ["_rallypoint", "_position"];
// rallypoint names are defined in CfgVehicles.hpp
_rallypoint = [ _rallypoint = [
objNull, objNull,
missionNamespace getVariable ["ACE_Rallypoint_West", objNull], missionNamespace getVariable ["ACE_Rallypoint_West", objNull],
missionNamespace getVariable ["ACE_Rallypoint_East", objNull], missionNamespace getVariable ["ACE_Rallypoint_East", objNull],
missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull] missionNamespace getVariable ["ACE_Rallypoint_Independent", objNull]
] select ([west, east, independent] find _side) + 1; ] 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 {}; if (isNull _rallypoint) exitWith {};
_position = getPosATL _unit; _position = getPosATL _unit;
_position = _position findEmptyPosition [0, 2, typeOf _rallypoint]; _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]; _position set [2, 0];
[localize LSTRING(Deploy)] call EFUNC(common,displayTextStructured); [localize LSTRING(Deploy)] call EFUNC(common,displayTextStructured);
[{ [{
_rallypoint = _this select 0; params ["_rallypoint", "_unit", "_position"];
_unit = _this select 1;
_position = _this select 2;
_rallypoint = _this select 3;
_rallypoint setPosATL _position; _rallypoint setPosATL _position;
_unit reveal _rallypoint; _unit reveal _rallypoint;
@ -56,5 +51,4 @@ _position set [2, 0];
["rallypointMoved", [_rallypoint, _side, _position]] call EFUNC(common,globalEvent); ["rallypointMoved", [_rallypoint, _side, _position]] call EFUNC(common,globalEvent);
[localize LSTRING(Deployed)] call EFUNC(common,displayTextStructured); [localize LSTRING(Deployed)] call EFUNC(common,displayTextStructured);
}, }, [_rallypoint, _unit, _position], 5] call EFUNC(common,waitAndExecute);
[_rallypoint, _unit, _position, _rallypoint], 5, 1] call EFUNC(common,waitAndExecute);

View File

@ -1,36 +1,27 @@
/* /*
Name: ACE_Respawn_fnc_removeBody * Author: bux578, commy2
* Removes a given body.
Author(s): *
bux578 * Arguments:
* 0: Body <OBJECT>
Description: *
removes a given body * Return Value:
* None
Parameters: *
0: OBJECT - body * Example:
1: BOOLEAN - forceRemove // not used atm * [corpse] call ace_respawn_fnc_removeBody
*
Returns: * Public: No
VOID */
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_body", "_forceRemove", "_bodyRemoveTimer"]; params ["_body", "_forceRemove"];
_body = _this select 0; private "_bodyRemoveTimer";
_forceRemove = _this select 1; _bodyRemoveTimer = [GVAR(BodyRemoveTimer) max 0, 2] select _forceRemove; // could be used for SpecOps missions.
_bodyRemoveTimer = GVAR(BodyRemoveTimer) max 0;
// could be used for SpecOps missions.
if (_forceRemove) then {
_bodyRemoveTimer = 2;
};
[{ [{
// hideBody takes ~20s till body is fully underground // hideBody takes ~20s till body is fully underground
// a better hideBody would make this more aesthetic // a better hideBody would make this more aesthetic
deleteVehicle _this; deleteVehicle _this;
}, _body, _bodyRemoveTimer, 1] call EFUNC(common,waitAndExecute); }, _body, _bodyRemoveTimer] call EFUNC(common,waitAndExecute);

View File

@ -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);
};

View File

@ -1,34 +1,22 @@
/* /*
Name: ACE_Respawn_fnc_restoreGear * Author: bux578
* Restores previously saved gear.
Author(s): *
bux578 * Arguments:
* 0: Unit <OBJECT>
Description: * 1: All Gear based on return value of ACE_common_fnc_getAllGear <ARRAY>
Restores previously saved gear *
* Return Value:
Parameters: * None
0: OBJECT - unit *
1: ARRAY<String, Array, ...> - Array containing all gear (result of ACE_common_fnc_getAllGear) * Example:
* [ACE_Player, stored_allGear] call ace_respawn_fnc_restoreGear
Returns: *
VOID * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_2(_unit,_allGear); params ["_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"];
// remove all starting gear of a player // remove all starting gear of a player
removeAllWeapons _unit; removeAllWeapons _unit;
@ -40,77 +28,66 @@ removeAllAssignedItems _unit;
clearAllItemsFromBackpack _unit; clearAllItemsFromBackpack _unit;
removeBackpack _unit; removeBackpack _unit;
_headgear = _allGear select 0; _allGear params [
_goggles = _allGear select 1; "_headgear", "_goggles",
_uniform = _allGear select 2; "_uniform", "_uniformitems",
_uniformitems = _allGear select 3; "_vest", "_vestitems",
_vest = _allGear select 4; "_backpack", "_backpackitems",
_vestitems = _allGear select 5; "_primaryweapon", "_primaryweaponitems", "_primaryweaponmagazine",
_backpack = _allGear select 6; "_secondaryweapon", "_secondaryweaponitems", "_secondaryweaponmagazine",
_backpackitems = _allGear select 7; "_handgunweapon", "_handgunweaponitems", "_handgunweaponmagazine",
_primaryweapon = _allGear select 8; "_assigneditems", "_binocular",
_primaryweaponitems = _allGear select 9; "_activeWeaponAndMuzzle"
_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;
// start restoring the items // start restoring the items
if (_headgear != "") then { if (_headgear != "") then {_unit addHeadgear _headgear};
_unit addHeadgear _headgear; if (_goggles != "") then {_unit addGoggles _goggles};
}; if (_uniform != "") then {_unit forceAddUniform _uniform};
if (_uniform != "") then { if (_vest != "") then {_unit addVest _vest};
_unit forceAddUniform _uniform;
};
if (_vest != "") then {
_unit addVest _vest;
};
if (_goggles != "") then {
_unit addGoggles _goggles;
};
{ {
_unit addItemToUniform _x; _unit addItemToUniform _x;
} forEach _uniformitems; false
} count _uniformitems;
{ {
_unit addItemToVest _x; _unit addItemToVest _x;
} forEach _vestitems; false
} count _vestitems;
private "_flagRemoveDummyBag"; private "_flagRemoveDummyBag";
_flagRemoveDummyBag = false;
if (format["%1", _backpack] != "") then { if (format ["%1", _backpack] != "") then {
_unit addBackpack _backpack; _unit addBackpack _backpack;
_backpa = unitBackpack _unit; // make sure the backpack is empty. Some bags are prefilled by config
clearMagazineCargoGlobal _backpa; private "_backpackObject";
clearWeaponCargoGlobal _backpa; _backpackObject = unitBackpack _unit;
clearItemCargoGlobal _backpa;
clearMagazineCargoGlobal _backpackObject;
clearWeaponCargoGlobal _backpackObject;
clearItemCargoGlobal _backpackObject;
{ {
_unit addItemToBackpack _x; _unit addItemToBackpack _x;
} forEach _backpackitems; false
} count _backpackitems;
_flagRemoveDummyBag = false;
} else { } else {
// dummy backpack to ensure mags being loaded // dummy backpack to ensure mags being loaded
_unit addBackpack "B_Kitbag_Base"; _unit addBackpack "Bag_Base";
_flagRemoveDummyBag = true; _flagRemoveDummyBag = true;
}; };
// primaryWeapon // primaryWeapon
if ((_primaryweapon != "") && {_primaryweapon != "ACE_FakePrimaryWeapon"}) then { if ((_primaryweapon != "") && {_primaryweapon != "ACE_FakePrimaryWeapon"}) then {
{ {
_unit addMagazine _x; _unit addMagazine _x;
} forEach _primaryweaponmagazine; false
} count _primaryweaponmagazine;
_unit addWeapon _primaryweapon; _unit addWeapon _primaryweapon;
@ -118,15 +95,16 @@ if ((_primaryweapon != "") && {_primaryweapon != "ACE_FakePrimaryWeapon"}) then
if (_x != "") then { if (_x != "") then {
_unit addPrimaryWeaponItem _x; _unit addPrimaryWeaponItem _x;
}; };
} forEach _primaryweaponitems; false
} count _primaryweaponitems;
}; };
// secondaryWeapon // secondaryWeapon
if (_secondaryweapon != "") then { if (_secondaryweapon != "") then {
{ {
_unit addMagazine _x; _unit addMagazine _x;
} forEach _secondaryweaponmagazine; false
} count _secondaryweaponmagazine;
_unit addWeapon _secondaryweapon; _unit addWeapon _secondaryweapon;
@ -134,15 +112,16 @@ if (_secondaryweapon != "") then {
if (_x != "") then { if (_x != "") then {
_unit addSecondaryWeaponItem _x; _unit addSecondaryWeaponItem _x;
}; };
} forEach _secondaryweaponitems; false
} count _secondaryweaponitems;
}; };
// handgun // handgun
if (_handgunweapon != "") then { if (_handgunweapon != "") then {
{ {
_unit addMagazine _x; _unit addMagazine _x;
} forEach _handgunweaponmagazine; false
} count _handgunweaponmagazine;
_unit addWeapon _handgunweapon; _unit addWeapon _handgunweapon;
@ -150,20 +129,19 @@ if (_handgunweapon != "") then {
if (_x != "") then { if (_x != "") then {
_unit addHandgunItem _x; _unit addHandgunItem _x;
}; };
} forEach _handgunweaponitems; false
} count _handgunweaponitems;
}; };
// remove dummy bagpack // remove dummy bagpack
if (_flagRemoveDummyBag) then { if (_flagRemoveDummyBag) then {
removeBackpack _unit; removeBackpack _unit;
}; };
_assignedItems deleteAt (_assignedItems find _binocular);
_assignedItems = _assignedItems - [_binocular];
// items // items
{_unit linkItem _x} forEach _assignedItems; {_unit linkItem _x; false} count _assignedItems;
_unit addWeapon _binocular; _unit addWeapon _binocular;
@ -178,24 +156,24 @@ if ("Laserdesignator" in assignedItems _unit) then {
}; };
// restore the last active weapon, muzzle and weaponMode // restore the last active weapon, muzzle and weaponMode
_activeWeapon = _activeWeaponAndMuzzle select 0; _activeWeaponAndMuzzle params ["_activeWeapon", "_activeMuzzle", "_activeWeaponMode"]
_activeMuzzle = _activeWeaponAndMuzzle select 1;
_activeWeaponMode = _activeWeaponAndMuzzle select 2;
if (!(_activeMuzzle isEqualTo "") and
!(_activeMuzzle isEqualTo _activeWeapon) and
(_activeMuzzle in getArray (configfile >> "CfgWeapons" >> _activeWeapon >> "muzzles"))) then {
if (
(_activeMuzzle != "") &&
{_activeMuzzle != _activeWeapon} &&
{_activeMuzzle in getArray (configfile >> "CfgWeapons" >> _activeWeapon >> "muzzles")}
) then {
_unit selectWeapon _activeMuzzle; _unit selectWeapon _activeMuzzle;
} else { } else {
if (!(_activeWeapon isEqualTo "")) then { if (_activeWeapon != "") then {
_unit selectWeapon _activeWeapon; _unit selectWeapon _activeWeapon;
}; };
}; };
if (!(currentWeapon _unit isEqualTo "")) then { if (currentWeapon _unit != "") then {
private ["_index"]; private "_index";
_index = 0; _index = 0;
while { while {
_index < 100 && {currentWeaponMode _unit != _activeWeaponMode} _index < 100 && {currentWeaponMode _unit != _activeWeaponMode}
} do { } do {

View File

@ -1,28 +1,24 @@
/* /*
Name: ACE_Respawn_fnc_showFriendlyFireMessages * Author: commy2
* Shows a message in system chat of who killed whom.
Author(s): *
commy2 * Arguments:
* 0: Unitn <OBJECT>
Description: * 1: Killer <OBJECT>
shows a message in system chat of who killed who *
* Return Value:
Parameters: * None
0: OBJECT - unit *
1: OBJECT - killer * Example:
* [ACE_Player, killer] call ace_module_fnc_functionName
Returns: *
VOID * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
private ["_unit", "_killer"]; params ["_unit", "_killer"];
_unit = _this select 0; if (_unit != _killer && {side group _unit in [side group ACE_player, civilian]} && {side group _killer == side group ACE_player}) then {
_killer = _this select 1;
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)]; systemChat format ["%1 was killed by %2", [_unit] call EFUNC(common,getName), [_killer] call EFUNC(common,getName)];
// Raise ACE globalEvent // Raise ACE globalEvent

View File

@ -1,29 +1,25 @@
/* /*
* Author: commy2 * Author: commy2
* teleports a unit to a rallypoint * Teleports a unit to a rallypoint
* *
* Arguments: * Arguments:
* 0: unit <OBJECT> * 0: Unit <OBJECT>
* 1: side? <OBJECT> * 1: Side <SIDE>
* 2: teleport to base <BOOLEAN> * 2: Rallypoint name <STRING>
* *
* Return Value: * Return Value:
* Nothing * None
* *
* Example: * Example:
* [,,] call ACE_Respawn_fnc_teleportToRallypoint; * [ACE_player, side ACE_Player, rallypoint_name] call ace_respawn_fnc_teleportToRallypoint;
* *
* Public: No * Public: No
*/ */
#include "script_component.hpp" #include "script_component.hpp"
PARAMS_3(_unit,_side,_rallypoint); params ["_unit", "_side", "_rallypoint"];
private ["_toBase"]; private "_toBase";
// rallypoint names are defined in CfgVehicles.hpp
//IGNORE_PRIVATE_WARNING("_Base")
_toBase = _rallypoint find "_Base" != -1; _toBase = _rallypoint find "_Base" != -1;
_rallypoint = missionNamespace getVariable [_rallypoint, objNull], _rallypoint = missionNamespace getVariable [_rallypoint, objNull],
@ -31,4 +27,5 @@ _rallypoint = missionNamespace getVariable [_rallypoint, objNull],
if (isNull _rallypoint) exitWith {}; if (isNull _rallypoint) exitWith {};
_unit setPosASL getPosASL _rallypoint; _unit setPosASL getPosASL _rallypoint;
[[localize LSTRING(TeleportedToRallypoint), localize LSTRING(TeleportedToBase)] select _toBase] call EFUNC(common,displayTextStructured); [[localize LSTRING(TeleportedToRallypoint), localize LSTRING(TeleportedToBase)] select _toBase] call EFUNC(common,displayTextStructured);

View File

@ -1,11 +1,23 @@
// by commy2 /*
* Author: commy2
* Updates marker position and texts.
*
* Arguments:
* 0: Marker <STRING>
* 1: Side <SIDE>
* 2: Position <ARRAY>
*
* Return Value:
* None
*
* Example:
* [marker_name, side ACE_Player, getPos ACE_Player] call ace_respawn_fnc_updateRallypoint
*
* Public: No
*/
#include "script_component.hpp" #include "script_component.hpp"
private ["_rallypoint", "_side", "_position"]; params ["_rallypoint", "_side", "_position"];
_rallypoint = _this select 0;
_side = _this select 1;
_position = _this select 2;
if (!hasInterface) exitWith {}; if (!hasInterface) exitWith {};