This commit is contained in:
jodav 2015-01-12 10:07:03 +01:00
parent 877fef16be
commit c5a42d1187
18 changed files with 768 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

281
addons/respawn/config.cpp Normal file
View File

@ -0,0 +1,281 @@
class CfgPatches {
class AGM_Respawn {
units[] = {};
weapons[] = {"AGM_Rallypoint_West", "AGM_Rallypoint_East", "AGM_Rallypoint_Independent", "AGM_RallypointExit_West", "AGM_RallypointExit_East", "AGM_RallypointExit_Independent"};
requiredVersion = 0.60;
requiredAddons[] = {AGM_Core};
version = "0.95";
versionStr = "0.95";
versionAr[] = {0,95,0};
author[] = {"bux578", "commy2"};
authorUrl = "https://github.com/bux578/";
};
};
class CfgFunctions {
class AGM_Respawn {
class AGM_Respawn {
file = "AGM_Respawn\functions";
class canMoveRallypoint;
class getAllGear;
class handleKilled;
class handleRespawn;
class initRallypoint;
class module;
class moduleFriendlyFire;
class moduleRallypoint;
class moveRallypoint;
class removeBody;
class removeDisconnectedPlayer;
class restoreGear;
class showFriendlyFireMessage;
class teleportToRallypoint;
};
};
};
class Extended_Killed_EventHandlers {
class CAManBase {
class AGM_Respawn_HandleGear {
killed = "_this call AGM_Respawn_fnc_handleKilled";
};
};
};
class Extended_Respawn_EventHandlers {
class CAManBase {
class AGM_Respawn_HandleGear {
respawn = "_this call AGM_Respawn_fnc_handleRespawn";
};
};
};
class CfgAddons {
class AGM_Respawn_Rallypoints {
list[] = {"AGM_Rallypoint_West", "AGM_Rallypoint_East", "AGM_Rallypoint_Independent", "AGM_RallypointExit_West", "AGM_RallypointExit_East", "AGM_RallypointExit_Independent"};
};
};
class CfgVehicleClasses {
class AGM_Respawn_Rallypoints {
displayName = "AGM Respawn";
};
};
class CfgVehicles {
class Module_F;
class AGM_ModuleRespawn: Module_F {
author = "$STR_AGM_Core_AGMTeam";
category = "AGM";
displayName = "Respawn System";
function = "AGM_Respawn_fnc_module";
scope = 2;
isGlobal = 1;
icon = "\AGM_Respawn\UI\Icon_Module_Respawn_ca.paa";
class Arguments {
class SavePreDeathGear {
displayName = "Save Gear?";
description = "Respawn with the gear a soldier had just before his death?";
typeName = "BOOL";
class values {
class Yes { name = "Yes"; value = 1;};
class No { default = 1; name = "No"; value = 0; };
};
};
class RemoveDeadBodiesDisonncected {
displayName = "Remove bodies?";
description = "Remove player bodies after disconnect?";
typeName = "BOOL";
class values {
class Yes { default = 1; name = "Yes"; value = 1;};
class No { name = "No"; value = 0; };
};
};
/*class BodyRemoveTimer {
displayName = "Time to remove bodies.";
description = "The amount of time (in seconds) after that a unit's body gets removed. Default: 90";
typeName = "NUMBER";
defaultValue = 90;
};*/
};
};
class AGM_ModuleFriendlyFire: Module_F {
author = "$STR_AGM_Core_AGMTeam";
category = "AGM";
displayName = "Friendly Fire Messages";
function = "AGM_Respawn_fnc_moduleFriendlyFire";
scope = 2;
isGlobal = 1;
icon = "\AGM_Respawn\UI\Icon_Module_FriendlyFire_ca.paa";
class Arguments {
};
};
class AGM_ModuleRallypoint: Module_F {
author = "$STR_AGM_Core_AGMTeam";
category = "AGM";
displayName = "Rallypoint System";
function = "AGM_Respawn_fnc_moduleRallypoint";
scope = 2;
isGlobal = 1;
icon = "\AGM_Respawn\UI\Icon_Module_Rallypoint_ca.paa";
class Arguments {
};
};
// rallypoints
class FlagCarrier;
class Flag_NATO_F: FlagCarrier {
class AGM_Actions;
};
class Flag_CSAT_F: FlagCarrier {
class AGM_Actions;
};
class Flag_AAF_F: FlagCarrier {
class AGM_Actions;
};
// static
class AGM_Rallypoint_West: Flag_NATO_F {
author = "$STR_AGM_Core_AGMTeam";
displayName = "Rallypoint West Base";
vehicleClass = "AGM_Respawn_Rallypoints";
class EventHandlers {
init = "(_this select 0) setFlagTexture '\A3\Data_F\Flags\Flag_nato_CO.paa'; _this call AGM_Respawn_fnc_initRallypoint";
};
class AGM_Actions: AGM_Actions {
class AGM_Teleport {
displayName = "Teleport to Rallypoint";
distance = 4;
condition = "side group _player == west";
statement = "[_player, side group _player, false] call AGM_Respawn_fnc_teleportToRallypoint;";
showDisabled = 1;
priority = 1;
};
};
};
class AGM_Rallypoint_East: Flag_CSAT_F {
author = "$STR_AGM_Core_AGMTeam";
displayName = "Rallypoint East Base";
vehicleClass = "AGM_Respawn_Rallypoints";
class EventHandlers {
init = "(_this select 0) setFlagTexture '\A3\Data_F\Flags\Flag_CSAT_CO.paa'; _this call AGM_Respawn_fnc_initRallypoint";
};
class AGM_Actions: AGM_Actions {
class AGM_Teleport {
displayName = "Teleport to Rallypoint";
distance = 4;
condition = "side group _player == east";
statement = "[_player, side group _player, false] call AGM_Respawn_fnc_teleportToRallypoint;";
showDisabled = 1;
priority = 1;
};
};
};
class AGM_Rallypoint_Independent: Flag_AAF_F {
author = "$STR_AGM_Core_AGMTeam";
displayName = "Rallypoint Independent Base";
vehicleClass = "AGM_Respawn_Rallypoints";
class EventHandlers {
init = "(_this select 0) setFlagTexture '\A3\Data_F\Flags\Flag_AAF_CO.paa'; _this call AGM_Respawn_fnc_initRallypoint";
};
class AGM_Actions: AGM_Actions {
class AGM_Teleport {
displayName = "Teleport to Rallypoint";
distance = 4;
condition = "side group _player == independent";
statement = "[_player, side group _player, false] call AGM_Respawn_fnc_teleportToRallypoint;";
showDisabled = 1;
priority = 1;
};
};
};
// moveable
class AGM_RallypointExit_West: Flag_NATO_F {
author = "$STR_AGM_Core_AGMTeam";
displayName = "Rallypoint West";
vehicleClass = "AGM_Respawn_Rallypoints";
class EventHandlers {
init = "(_this select 0) setFlagTexture '\A3\Data_F\Flags\Flag_nato_CO.paa'; _this call AGM_Respawn_fnc_initRallypoint";
};
class AGM_Actions: AGM_Actions {
class AGM_Teleport {
displayName = "Teleport to Base";
distance = 4;
condition = "side group _player == west";
statement = "[_player, side group _player, true] call AGM_Respawn_fnc_teleportToRallypoint;";
showDisabled = 1;
priority = 1;
};
};
};
class AGM_RallypointExit_East: Flag_CSAT_F {
author = "$STR_AGM_Core_AGMTeam";
displayName = "Rallypoint East";
vehicleClass = "AGM_Respawn_Rallypoints";
class EventHandlers {
init = "(_this select 0) setFlagTexture '\A3\Data_F\Flags\Flag_CSAT_CO.paa'; _this call AGM_Respawn_fnc_initRallypoint";
};
class AGM_Actions: AGM_Actions {
class AGM_Teleport {
displayName = "Teleport to Base";
distance = 4;
condition = "side group _player == east";
statement = "[_player, side group _player, true] call AGM_Respawn_fnc_teleportToRallypoint;";
showDisabled = 1;
priority = 1;
};
};
};
class AGM_RallypointExit_Independent: Flag_AAF_F {
author = "$STR_AGM_Core_AGMTeam";
displayName = "Rallypoint Independent";
vehicleClass = "AGM_Respawn_Rallypoints";
class EventHandlers {
init = "(_this select 0) setFlagTexture '\A3\Data_F\Flags\Flag_AAF_CO.paa'; _this call AGM_Respawn_fnc_initRallypoint";
};
class AGM_Actions: AGM_Actions {
class AGM_Teleport {
displayName = "Teleport to Base";
distance = 4;
condition = "side group _player == independent";
statement = "[_player, side group _player, true] call AGM_Respawn_fnc_teleportToRallypoint;";
showDisabled = 1;
priority = 1;
};
};
};
// team leader
class Man;
class CAManBase: Man {
class AGM_SelfActions {
class AGM_MoveRallypoint {
displayName = "Move Rallypoint";
condition = "[_player, side group _player] call AGM_Respawn_fnc_canMoveRallypoint";
statement = "[_player, side group _player] call AGM_Respawn_fnc_moveRallypoint";
showDisabled = 0;
priority = -0.5;
};
};
};
};
class AGM_Parameters_Boolean {
// Boolean Parameters (0/1)
AGM_Respawn_SavePreDeathGear = 0;
AGM_Respawn_RemoveDeadBodiesDisonncected = 1;
};

View File

@ -0,0 +1,14 @@
// by commy2
private ["_unit", "_side"];
_unit = _this select 0;
_side = _this select 1;
_unit getVariable ["AGM_canMoveRallypoint", false]
&& {!isNull ([
objNull,
missionNamespace getVariable ["AGM_Rallypoint_West", objNull],
missionNamespace getVariable ["AGM_Rallypoint_East", objNull],
missionNamespace getVariable ["AGM_Rallypoint_Independent", objNull]
] select ([west, east, independent] find _side) + 1)}

View File

@ -0,0 +1,40 @@
/*
Author: bux578
Description:
Returns an array containing all items of a given unit
Arguments:
A player object
Return value:
An array containing all inventory items
*/
private ["_unit", "_allGear"];
_unit = _this select 0;
_allGear = [
(headgear _unit),
(goggles _unit),
(uniform _unit),
(uniformItems _unit),
(vest _unit),
(vestItems _unit),
(backpack _unit),
(backpackItems _unit),
(primaryWeapon _unit),
(primaryWeaponItems _unit),
(primaryWeaponMagazine _unit),
(secondaryWeapon _unit),
(secondaryWeaponItems _unit),
(secondaryWeaponMagazine _unit),
(handgunWeapon _unit),
(handgunItems _unit),
(handgunMagazine _unit),
(assignedItems _unit),
(binocular _unit)
];
_allGear

View File

@ -0,0 +1,31 @@
/*
Name: AGM_Respawn_fnc_handleKilled
Author(s):
bux578
Description:
Handles the XEH Killed event
Parameters:
0: OBJECT - Killed unit
1: OBJECT - Attacker
Returns:
VOID
*/
private ["_killedUnit"];
_killedUnit = _this select 0;
// Saves the gear when the player is killed
AGM_Respawn_unitGear = [];
if (AGM_Respawn_SavePreDeathGear) then {
AGM_Respawn_unitGear = [_killedUnit] call AGM_Respawn_fnc_getAllGear;
};
if (missionNamespace getVariable ["AGM_showFriendlyFireMessage", false]) then {
[_this, "AGM_Respawn_fnc_showFriendlyFireMessage", 2] call AGM_Core_fnc_execRemoteFnc;
};

View File

@ -0,0 +1,25 @@
/*
Name: AGM_Respawn_fnc_handleRespawn
Author(s):
bux578
Description:
Handles the XEH Respawn event
Parameters:
0: OBJECT - Respawned Unit
1: ?
Returns:
VOID
*/
private ["_respawnedUnit"];
_respawnedUnit = _this select 0;
// Restores the gear when the player respawns
if (AGM_Respawn_SavePreDeathGear) then {
[_respawnedUnit, AGM_Respawn_unitGear] call AGM_Respawn_fnc_restoreGear;
};

View File

@ -0,0 +1,17 @@
// by commy2
private ["_rallypoint", "_name"];
_rallypoint = _this select 0;
if (!local _rallypoint) exitWith {};
_name = typeOf _rallypoint;
if (isNil _name) then {
missionNamespace setVariable [_name, _rallypoint];
publicVariable _name;
} else {
deleteVehicle _rallypoint;
diag_log text "[AGM] Respawn: ERROR Multiple Rallypoints of same type.";
};

View File

@ -0,0 +1,43 @@
/*
* Author: KoffeinFlummi, bux578, CAA-Picard, commy2
*
* Initializes the respawn module.
*
* Arguments:
* Whatever the module provides. (I dunno.)
*
* Return Value:
* None
*/
if !(isServer) exitWith {};
_logic = _this select 0;
_activated = _this select 2;
if !(_activated) exitWith {};
AGM_Respawn_Module = true;
[_logic, "AGM_Respawn_SavePreDeathGear", "SavePreDeathGear"] call AGM_Core_fnc_readBooleanParameterFromModule;
[_logic, "AGM_Respawn_RemoveDeadBodiesDisonncected", "RemoveDeadBodiesDisonncected"] call AGM_Core_fnc_readBooleanParameterFromModule;
if (isServer) then {
if (AGM_Respawn_RemoveDeadBodiesDisonncected) then {
_fnc_deleteDisconnected = {
_this spawn {
_unit = _this select 0;
sleep 4;
if (!alive _unit) then {
deleteVehicle _unit;
};
};
false
};
addMissionEventHandler ["HandleDisconnect", _fnc_deleteDisconnected];
};
};
diag_log text "[AGM]: Respawn Module Initialized.";

View File

@ -0,0 +1,28 @@
/*
* Author: commy2
*
* Initializes the Friendly Fire Messages module.
*
* Arguments:
* Whatever the module provides. (I dunno.)
*
* Return Value:
* None
*/
_this spawn {
_logic = _this select 0;
_units = _this select 1;
_activated = _this select 2;
if !(_activated) exitWith {};
if (isServer) then {
_varName = "AGM_showFriendlyFireMessage";
missionNamespace setVariable [_varName, true];
publicVariable _varName;
};
diag_log text "[AGM]: Friendly Fire Messages Module Initialized.";
};

View File

@ -0,0 +1,25 @@
/*
* Author: commy2
*
* Initializes the Rallypoint module.
*
* Arguments:
* Whatever the module provides. (I dunno.)
*
* Return Value:
* None
*/
_logic = _this select 0;
_units = _this select 1;
_activated = _this select 2;
if !(_activated) exitWith {};
//_mode = parseNumber (_logic getVariable "Action");
{
_x setVariable ["AGM_canMoveRallypoint", true];
} forEach _units;
diag_log text "[AGM]: Rallypoint Module Initialized.";

View File

@ -0,0 +1,35 @@
// by commy2
_this spawn {
_unit = _this select 0;
_side = _this select 1;
_rallypoint = [
objNull,
missionNamespace getVariable ["AGM_RallypointExit_West", objNull],
missionNamespace getVariable ["AGM_RallypointExit_East", objNull],
missionNamespace getVariable ["AGM_RallypointExit_Independent", objNull]
] select ([west, east, independent] find _side) + 1;
if (isNull _rallypoint) exitWith {};
_position = getPosATL _unit;
_position = _position findEmptyPosition [0, 2, typeOf _rallypoint];
if (count _position == 0) then {_position = getPosATL _unit};
_position set [2, 0];
["Deploy in 5 seconds ..."] call AGM_Core_fnc_displayTextStructured;
sleep 5;
_rallypoint setPosATL _position;
_unit reveal _rallypoint;
/*
_marker = format ["AGM_RallyPoint_%1", _side];
_marker setMarkerPos _position;
_marker setMarkerTextLocal format ["%1:%2", [date select 3, 2, 0] call CBA_fnc_FORMATNumber, [date select 4, 2, 0] call CBA_fnc_FORMATNumber];
*/
["Rallypoint deployed"] call AGM_Core_fnc_displayTextStructured;
};

View File

@ -0,0 +1,30 @@
/*
* Author: bux578
*
* removes the body
*
* Arguments:
* The body
*
* Return Value:
* None
*/
private ["_body", "_forceRemove", "_bodyRemoveTimer"];
_body = _this select 0;
_forceRemove = _this select 1;
_bodyRemoveTimer = AGM_Respawn_BodyRemoveTimer max 0;
// could be used for SpecOps missions.
if (_forceRemove) then {
_bodyRemoveTimer = 2;
};
[_body, _bodyRemoveTimer] spawn {
sleep (_this select 1);
// hideBody takes ~20s till body is fully underground
// a better hideBody would make this more aesthetic
deleteVehicle (_this select 0);
};

View File

@ -0,0 +1,15 @@
// by commy2
private ["_forceRemove", "_body"];
_forceRemove = _this select 0;
{
if (getPlayerUID _x == _uid) exitWith {
_body = _x;
};
} forEach playableUnits;
if (!isNil "_body" && {!alive _body}) then {
[_body, _forceRemove] call AGM_Respawn_fnc_removeBody;
};

View File

@ -0,0 +1,145 @@
/*
Author: bux578
Description:
Restores previously saved gear
Arguments:
A player object, an array containing all gear
Return value:
An array containing all inventory items
*/
private ["_unit", "_allGear", "_headgear", "_goggles", "_uniform", "_uniformitems", "_vest", "_vestitems", "_backpack", "_backpackitems", "_primaryweapon", "_primaryweaponitems", "_primaryweaponmagazine", "_handgunweapon", "_handgunweaponitems", "_handgunweaponmagazine", "_assigneditems", "_binocular"];
_unit = _this select 0;
_allGear = _this select 1;
// remove all starting gear of a player
removeAllWeapons _unit;
removeGoggles _unit;
removeHeadgear _unit;
removeVest _unit;
removeUniform _unit;
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;
// 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;
};
{
_unit addItemToUniform _x;
}forEach _uniformitems;
{
_unit addItemToVest _x;
}forEach _vestitems;
if(format["%1", _backpack] != "") then {
_unit addBackpack _backpack;
_backpa = unitBackpack _unit;
clearMagazineCargoGlobal _backpa;
clearWeaponCargoGlobal _backpa;
clearItemCargoGlobal _backpa;
{
_unit addItemToBackpack _x;
} forEach _backpackitems;
};
// primaryWeapon
if (_primaryweapon != "") then {
{
_unit addMagazine _x;
} forEach _primaryweaponmagazine;
_unit addWeapon _primaryweapon;
{
if (_x != "") then {
_unit addPrimaryWeaponItem _x;
};
} forEach _primaryweaponitems;
};
// secondaryWeapon
if (_secondaryweapon != "") then {
{
_unit addMagazine _x;
} forEach _secondaryweaponmagazine;
_unit addWeapon _secondaryweapon;
{
if (_x != "") then {
_unit addSecondaryWeaponItem _x;
};
} forEach _secondaryweaponitems;
};
// handgun
if (_handgunweapon != "") then {
{
_unit addMagazine _x;
} forEach _handgunweaponmagazine;
_unit addWeapon _handgunweapon;
{
if (_x != "") then {
_unit addHandgunItem _x;
};
} forEach _handgunweaponitems;
};
_assignedItems = _assignedItems - [_binocular];
// items
{_unit linkItem _x} forEach _assignedItems;
_unit addWeapon _binocular;
if ("Laserdesignator" in assignedItems _unit) then {
_unit selectWeapon "Laserdesignator";
if (currentMagazine _unit == "") then {_unit addMagazine "Laserbatteries";};
};

View File

@ -0,0 +1,12 @@
// by commy2
private ["_unit", "_killer"];
_unit = _this select 0;
_killer = _this select 1;
if (_unit != _killer && side group _unit in [side group AGM_player, civilian] && {side group _killer == side group AGM_player}) then {
systemChat format ["%1 was killed by %2", [_unit] call AGM_Core_fnc_getName, [_killer] call AGM_Core_fnc_getName];
[_unit, "killedByFriendly", [_unit, _killer]] call AGM_Core_fnc_callCustomEventHandlers;
};

View File

@ -0,0 +1,27 @@
// by commy2
private ["_unit", "_side", "_toBase", "_rallypoint"];
_unit = _this select 0;
_side = _this select 1;
_toBase = _this select 2;
_rallypoint = ([
[
objNull,
missionNamespace getVariable ["AGM_RallypointExit_West", objNull],
missionNamespace getVariable ["AGM_RallypointExit_East", objNull],
missionNamespace getVariable ["AGM_RallypointExit_Independent", objNull]
],
[
objNull,
missionNamespace getVariable ["AGM_Rallypoint_West", objNull],
missionNamespace getVariable ["AGM_Rallypoint_East", objNull],
missionNamespace getVariable ["AGM_Rallypoint_Independent", objNull]
]
] select _toBase) select ([west, east, independent] find _side) + 1;
if (isNull _rallypoint) exitWith {};
_unit setPosASL (getPosASL _rallypoint);
[["Teleported to Rallypoint", "Teleported to Base"] select _toBase] call AGM_Core_fnc_displayTextStructured;