Respawn – Arma 3

From Bohemia Interactive Community
Jump to navigation Jump to search
(added respawn related functions)
m (Some wiki formatting)
(36 intermediate revisions by 6 users not shown)
Line 1: Line 1:
[[Category:Arma 3: Editing|Respawn]]
{{TOC|side}}


== Mission Configuration ==
<gallery mode="packed-overlay" heights=200px>
=== Description.ext ===
File:A3 RespawnScreen.jpg|Respawn screen
A wide range of [[Description.ext]] entries lets you to configure respawn settings for your mission.
File:A3 EdenEditor Respawn.jpg|Respawn settings in [[Eden Editor]]
{{codecomment|// Respawn type, see the table below}}
</gallery>
respawn = 2;
{{codecomment|// Delay in seconds before playable unit respawns.}}
respawnDelay = 10;
{{codecomment|// Delay in seconds before vehicle respawns.}}
respawnVehicleDelay = 60;
{{codecomment|// 0 to disable the score table (it can still be opened manually by pressing 'P' key).}}
respawnDialog = 0;
{{codecomment|// Respawn templates from CfgRespawnTemplates. You can combine any number of them together.}}
respawnTemplates[] = {"Counter","Wave"};
{{codecomment|// Side specific respawn templates. When undefined, general respawnTemplates are used instead.}}
respawnTemplatesEast[] = {"Counter"};
{{codecomment|// 1 to respawn player when he joins the game. Available only for INSTANT and BASE respawn types.}}
respawnOnStart = 1;
{{codecomment|// When 1, the score table contains score of all playable units as opposed to players only.}}
aikills = 1;


=== Files ===
When you create files called ''onPlayerKilled.sqf'' and ''onPlayerRespawn.sqf'' in your [[Mission_Editor:_External|mission directory]], they will be automatically executed on player's computer when he dies and respawns.


Following parameters are passed into it in both cases:
== Settings ==


'''onPlayerKilled.sqf'''<br />
* Some basic settings can be set up in [[Eden Editor]]
:''(first 2 params are the same as are passed into [[Arma_3:_Event_Handlers#Killed|Killed]] event handler)''
* The [[Description.ext|description.ext]] allows for full control over all available respawn settings
:<code>[<oldUnit>,<killer>,<respawn>,<respawnDelay>]</code>


'''onPlayerRespawn.sqf'''<br />
:''(first 2 params are the same as are passed into [[Arma_3:_Event_Handlers#Respawn|Respawn]] event handler)''
:<code>[<newUnit>,<oldUnit>,<respawn>,<respawnDelay>]</code>


'''Parameters:'''
== Scripting ==
:*oldUnit: [[Object]] - killed player. [[objNull]] when executed on start.
 
:*newUnit: [[Object]] - newly respawned player.
''' Scripting Commands '''
:*killer: [[Object]] - a unit who killed player. [[objNull]] when executed on start.
* [[playerRespawnTime]]
:*respawnDelay: [[Number]] - respawn delay defined either in respawn type or in Description.ext.
* [[setPlayerRespawnTime]]
* [[respawnVehicle]]
 
''' Scripting Functions '''
* [[:Category:Function Group: Respawn|Respawn Functions]]
 
''' Event Scripts '''
* [[Event Scripts|onPlayerRespawn.sqf]]
* [[Event Scripts|onPlayerKilled.sqf]]
 
 
== Respawn Types ==
 
Type is represented either by respawn ID, or by its name.
<syntaxhighlight lang="cpp">
respawn = "BASE";
respawn = 3;
</syntaxhighlight>


=== Respawn Types ===
Type is represented either by respawn ID
respawn = 3;
Or by its name
respawn = "BASE";
{| class="wikitable"
{| class="wikitable"
! ID
! ID
! Name
! Name
! Description
! Description
! Default Templates
! onPlayerKilled
! onPlayerKilled
! onPlayerRespawn
! onPlayerRespawn
Line 55: Line 47:
| "NONE"
| "NONE"
| Show singleplayer death screen
| Show singleplayer death screen
|style="text-align:center;"| {{task/}}
| {{n/a}}
|style="text-align:center;"| {{task}}
| style="text-align: center" | {{Icon|checked}}
| style="text-align: center" | {{Icon|unchecked}}


|-
|-
Line 62: Line 55:
| "BIRD"
| "BIRD"
| Respawn to a seagull
| Respawn to a seagull
|style="text-align:center;"| {{task}}
| Spectator, EndMission
|style="text-align:center;"| {{task/}}
| style="text-align: center" | {{Icon|unchecked}}
| style="text-align: center" | {{Icon|checked}}


|-
|-
Line 69: Line 63:
| "INSTANT"
| "INSTANT"
| Respawn on spot where player died
| Respawn on spot where player died
|style="text-align:center;"| {{task/}}
| Instant, Counter
|style="text-align:center;"| {{task/}}
| style="text-align: center" | {{Icon|checked}}
| style="text-align: center" | {{Icon|checked}}


|-
|-
Line 76: Line 71:
| "BASE"
| "BASE"
| Respawn on a marker(s) start by following strings:
| Respawn on a marker(s) start by following strings:
*'''Unit respawn'''
'''Unit respawn'''
**''respawn'' (used only when side variant is not found)
* ''respawn'' (used only when side variant is not found)
**''respawn_west''
* ''respawn_west''
**''respawn_east''
* ''respawn_east''
**''respawn_guerrila''
* ''respawn_guerrila''
**''respawn_civilian''
* ''respawn_civilian''
*'''Vehicle respawn'''
'''Vehicle respawn'''
**''respawn'' (used only when side variant is not found)
* ''respawn'' (used only when side variant is not found)
**''respawn_vehicle_west''
* ''respawn_vehicle_west''
**''respawn_vehicle_east''
* ''respawn_vehicle_east''
**''respawn_vehicle_guerrila''
* ''respawn_vehicle_guerrila''
**''respawn_vehicle_civilian''
* ''respawn_vehicle_civilian''
You can have multiple markers simply by adding any text behind the name, e.g. ''respawn_west1'', ''respawn_westBase'' etc. When no markers are defined, player is respawned on position where he started the mission. More about marker respawn can be found [http://killzonekid.com/arma-scripting-tutorials-respawn-on-marker/ here]
You can have multiple markers simply by adding any text behind the name, e.g. ''respawn_west1'', ''respawn_westBase'' etc. When no markers are defined, player is respawned on position where he started the mission. More about marker respawn can be found [http://killzonekid.com/arma-scripting-tutorials-respawn-on-marker/ here]. Alternatively you can also use the ''Respawn Position'' module.
|style="text-align:center;"| {{task/}}
| Base, Counter
|style="text-align:center;"| {{task/}}
| style="text-align: center" | {{Icon|checked}}
| style="text-align: center" | {{Icon|checked}}


|-
|-
Line 96: Line 92:
| "GROUP"
| "GROUP"
| Respawn to the next available playable unit in a group. When none is left, BIRD respawn is used instead.
| Respawn to the next available playable unit in a group. When none is left, BIRD respawn is used instead.
|style="text-align:center;"| {{task}}
| Group, EndMission
|style="text-align:center;"| {{task/}}
| style="text-align: center" | {{Icon|unchecked}}
| style="text-align: center" | {{Icon|checked}}


|-
|-
Line 103: Line 100:
| "SIDE"
| "SIDE"
| Respawn to the next available playable unit of the same side (selected using team switch window). When none is left, BIRD respawn is used instead.
| Respawn to the next available playable unit of the same side (selected using team switch window). When none is left, BIRD respawn is used instead.
|style="text-align:center;"| {{task}}
| Side, EndMission
|style="text-align:center;"| {{task/}}
| style="text-align: center" | {{Icon|unchecked}}
| style="text-align: center" | {{Icon|checked}}
|}
|}




=== Respawn Templates ===
== Respawn Templates ==
 
{{Feature | Warning | Respawn Templates are '''case-sensitive!'''}}
Templates are pre-defined scripts called when player dies and respawns. They are defined in an array and can be combined together.
Templates are pre-defined scripts called when player dies and respawns. They are defined in an array and can be combined together.
respawnTemplates[] = {"MenuInventory","MenuPosition"};
<syntaxhighlight lang="cpp">
respawnTemplates[] = { "MenuInventory", "MenuPosition" };
</syntaxhighlight>
Additionally, you can define side specific templates. When a side has no unique templates, it will use general ''respawnTemplates'' instead.
Additionally, you can define side specific templates. When a side has no unique templates, it will use general ''respawnTemplates'' instead.
  respawnTemplatesWest[] = {"MenuInventory"};
<syntaxhighlight lang="cpp">
  respawnTemplatesEast[] = {"Counter"};
  respawnTemplatesWest[] = { "MenuInventory" };
  respawnTemplatesGuer[] = {"Tickets"};
  respawnTemplatesEast[] = { "Counter" };
  respawnTemplatesCiv[] = {"Spectator"};
  respawnTemplatesGuer[] = { "Tickets" };
  respawnTemplatesVirtual[] = {}; {{codecomment|// Virtual players, used mainly in [[Curator]] missions}}
  respawnTemplatesCiv[] = { "Spectator" };
When the respawnTemplates entry is missing, default templates based on the respawn type are used:
  respawnTemplatesVirtual[] = {}; // Virtual players, used mainly in Curator (Zeus) missions
* '''NONE:''' ''None
</syntaxhighlight>
* '''BIRD:''' ''Spectator, EndMission''
{{Feature | important | When the {{hl|respawnTemplates}} entry is missing, default templates based on the respawn type are used.}}
* '''INSTANT:''' ''Instant, Counter''
* '''BASE:''' ''Base, Counter''
* '''GROUP:''' ''Group, EndMission''
* '''SIDE:''' ''Side, EndMission''


A list of official templates follows:
=== Conflicts ===
 
The respawn templates "MenuPosition" and "Spectator" are '''not''' compatible since MenuPosition will force the map open. Instead you can use the following settings to get access to the full spectator mode:
<syntaxhighlight lang="cpp">
// description.ext
respawn = 3;
respawnTemplates[] = { "MenuPosition", "Spectator" };
</syntaxhighlight>
<sqf>
// initPlayerLocal.sqf
// --- Enable full spectator in respawn screen
{
missionNamespace setVariable [_x, true];
} forEach [
"BIS_respSpecAi", // Allow spectating of AI
"BIS_respSpecAllowFreeCamera", // Allow moving the camera independent from units (players)
"BIS_respSpecAllow3PPCamera", // Allow 3rd person camera
"BIS_respSpecShowFocus", // Show info about the selected unit (dissapears behind the respawn UI)
"BIS_respSpecShowCameraButtons", // Show buttons for switching between free camera, 1st and 3rd person view (partially overlayed by respawn UI)
"BIS_respSpecShowControlsHelper", // Show the controls tutorial box
"BIS_respSpecShowHeader", // Top bar of the spectator UI including mission time
"BIS_respSpecLists" // Show list of available units and locations on the left hand side
];
</sqf>
 
=== Official Templates ===


{| class="wikitable"
{| class="wikitable"
Line 164: Line 187:
|-
|-
| '''Seagull'''
| '''Seagull'''
| OFP-style seagull respawn
| {{ofp}}-style seagull respawn
|
|


|-
|-
| '''Wave'''
| '''Wave'''
| Adjusts respawn counter so players spawns together (wave delay is based on ''respawnDelay'')
| Adjusts respawn counter so players spawns together. Wave delay is based on ''respawnDelay'' and [[playerRespawnTime|Player's respawn time]] is set between 1 and 2 times ''respawnDelay'': if ''respawnDelay'' is set to e.g 10, respawn waves happen every 10 seconds. If a player dies and the next respawn wave is in 3 seconds, the player's respawn time is set to 17 seconds to match the next wave.
|
|


Line 191: Line 214:
|-
|-
| '''MenuPosition'''
| '''MenuPosition'''
| Let player select from available respawn positions defined either by respawn markers (e.g., ''respawn_west'', see [[#Respawn Types|Respawn Types]]) or by [[BIS_fnc_addRespawnPosition]] function.
| Lets players select from available respawn positions defined either by ''respawn markers'', see [[#Respawn Types|Respawn Types]], by [[BIS_fnc_addRespawnPosition]] function or by the ''Respawn Position'' module. A new screen was released with {{GVI|arma3|1.60}} and brings new functionalities together with a new design.


Once countdown reaches 0, player is not respawned immediately, but must confirm selection by clicking on "RESPAWN" button.
'''Item disabling'''
* Respawn positions can be disabled automatically (e.g., unit used as respawn point is dead) or manually by calling [[BIS_fnc_showRespawnMenuDisableItem]]
| [[File:A3 respawnSelectPosition.jpg|200px]]
| [[File:A3 respawnSelectPosition.jpg|200px]]


|-
|-
| '''MenuInventory'''
| '''MenuInventory'''
| Let player pick a respawn loadout defined in CfgRespawnInventory in [[Description.ext]]. Loadouts can be added using [[BIS_fnc_addRespawnInventory]] function.
|
Lets players pick a respawn loadout defined in ''[[Description.ext|CfgRespawnInventory]]''. Loadouts can be added using [[BIS_fnc_addRespawnInventory]] function. A new screen was released with {{GVI|arma3|1.60}} and brings new functionalities together with a new design.


{|class="wikitable mw-collapsible mw-collapsed"
'''Role selection'''
! Example Description.ext&nbsp;
* Respawn inventories are sorted in to Roles which can be defined in [[#Loadouts and Roles|CfgRoles]].
|-
 
|
'''Item disabling'''
class CfgRespawnInventory
* Roles and loadouts can be disabled. This can happen automatically (e.g., Role/loadout limit was reached) or can be manually by calling [[BIS_fnc_showRespawnMenuDisableItem]].
{
 
class WEST1
'''Limits'''
{
* Roles and loadouts can be limited. This way only limited number of player can use given role/loadout in a mission. For details on how to do that see [[BIS_fnc_addRespawnInventory]].
displayName = "Light"; {{codecomment|// Name visible in the menu}}
| [[File:A3 respawnSelectInventory.jpg|200px]]
icon = "\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa"; {{codecomment|// Icon displayed next to the name}}
|}
 
'''Options shared by ''MenuInventory'' and ''MenuPosition'''''<br>
Both templates feature a similar respawn UI and therefore share the following options:
* '''Timeout disabling'''
** Mission designer can disable the timeout used between death of a unit and opening of the respawn screen: <sqf>
missionNamespace setVariable ["BIS_RscRespawnControls_skipBlackOut", true, true]; // disable timout
missionNamespace setVariable ["BIS_RscRespawnControls_skipBlackOut", nil, true]; // reset to original timeout
</sqf>
* '''Autorespawn'''
** A checkbox can be ticket to let the player automatically respawn once the coundown reached 0. If disabled player is not respawned immediately, but must confirm selection by clicking on "RESPAWN" button.
* '''Spectator Camera'''
** The Spectator Camera used in here is slightly modified (no free camera available etc.) version of Spectator Mode. For full documentation see [[EG_Spectator_Mode|Spectator Mode documentation]].
** Mission designer needs to use the '''Spectator''' respawn template, the camera is disabled otherwise.
 
=== Custom Respawn Templates ===
 
New templates can be defined in global [[Config.cpp]] or in mission and campaign [[Description.ext]] files.<br>
'''Example''':
<spoiler>
<syntaxhighlight lang="cpp">
class CfgRespawnTemplates
{
// Class used in respawnTemplates entry
class myTag_beacon
{
// Function or script executed upon death. Parameters passed into it are the same as are passed into onPlayerKilled.sqf file
onPlayerKilled = "\myAddon\scripts\respawnBeacon.sqf";
// Function or script executed upon respawn. Parameters passed into it are the same as are passed into onPlayerRespawn.sqf file
onPlayerRespawn = "\myAddon\scripts\respawnBeacon.sqf";
// Default respawn delay (can be overwitten by description.ext entry of the same name)
respawnDelay = 20;
// 1 to respawn player when he joins the game. Available only for INSTANT and BASE respawn types
// Can be overridden by description.ext attribute of the same name
respawnOnStart = 1;
// By default onPlayerKilled and onPlayerRespawn function are spawned
// set to 1 to run in unscheduled, called functions MUST NOT return an assignment or respawn will break
isCall = 0;
};
class Spectator
{
onPlayerRespawn = "BIS_fnc_respawnSpectator";
};
};
</syntaxhighlight>
</spoiler>
 
 
== Loadouts and Roles ==
 
The main purpose of the roles is to make things more clear and simple for player when selecting loadout. All the loadouts available in a mission are now divided into various roles.<br>
Mission designer can use roles already created in the game config, or custom roles can be defined in ''description.ext'' file. Loadouts with no role assigned are automatically assigned to the ''Default'' role.<br>
'''Loadout config example:'''
<spoiler>
<syntaxhighlight lang="cpp">
class CfgRoles
{
class Assault // Class name used in CfgRespawnInventory
{
displayName = $STR_A3_Role_Assault; // Name of the role, displayed in the respawn menu
icon = "a3\missions_f_exp\data\img\classes\assault_ca.paa"; // Icon shown next to the role name in the respawn screen
};
};
   
   
{{codecomment|// Loadout definition, uses same entries as CfgVehicles classes}}
class CfgRespawnInventory
weapons[] = {
{
"arifle_MXC_F",
class B_SquadLeader // Class of the respawn inventory, used by BIS_fnc_addRespawnInventory
"Binocular"
{
};
displayName = $STR_b_soldier_sl_f0; // Name of the respawn inventory
magazines[] = {
role = "Assault"; // Role the respawn inventory is assigned to
"30Rnd_65x39_caseless_mag",
icon = "\A3\ui_f\data\map\VehicleIcons\iconManLeader_ca.paa"; // Icon shown next to the role
"30Rnd_65x39_caseless_mag",
show = "side group _this == west"; // Condition used to make specific respawn inventories only avaiable for specfic sides, must return [[Boolean]]
"SmokeShell"
weapons[] = { // Weapons
};
"arifle_SPAR_01_khk_F",
items[] = {
"Rangefinder",
"FirstAidKit"
"hgun_P07_khk_F"
};
};
linkedItems[] = {
magazines[] = { // Magazines
"V_Chestrig_khk",
"SmokeShell",
"H_Watchcap_blk",
"SmokeShell",
"optic_Aco",
"16Rnd_9x21_Mag",
"acc_flashlight",
"16Rnd_9x21_Mag",
"ItemMap",
"16Rnd_9x21_Mag",
"ItemCompass",
"30Rnd_556x45_Stanag_Tracer_Red",
"ItemWatch",
"30Rnd_556x45_Stanag_Tracer_Red",
"ItemRadio"
"30Rnd_556x45_Stanag_Tracer_Red",
};
"30Rnd_556x45_Stanag_Tracer_Red",
uniformClass = "U_B_CombatUniform_mcam_tshirt";
"30Rnd_556x45_Stanag_Tracer_Red",
backpack = "B_AssaultPack_mcamo";
"30Rnd_556x45_Stanag_Tracer_Red",
};
"30Rnd_556x45_Stanag_Tracer_Red",
class WEST2
"30Rnd_556x45_Stanag_Tracer_Red",
{
"HandGrenade",
{{codecomment|// Alternative configuration pointing to a CfgVehicles class. Loadout will be copied from it.}}
"HandGrenade"
vehicle = "B_soldier_AR_F"
};
};
items[] = { // Useable items
};
"FirstAidKit"
|}
};
Once countdown reaches 0, player is not respawned immediately, but must confirm selection by clicking on "RESPAWN" button.
linkedItems[] = { // Linked items, also weapon items, helmet etc.
"V_PlateCarrierSpec_tna_F",
"H_HelmetB_Enh_tna_F",
"optic_ERCO_blk_F",
"acc_pointer_IR",
"NVGoggles_tna_F",
"ItemGPS",
"ItemMap",
"ItemCompass",
"ItemWatch",
"ItemRadio"
};
uniformClass = "U_B_T_Soldier_SL_F"; // uniform
};
</syntaxhighlight>
</spoiler>
'''Export Function''':
* The following function will copy a complete respawn inventory to your clipboard, see function header for more information.<br>
'''Author:''' {{User|R3vo}}<br>
<spoiler>
<sqf>
/*
Author: R3vo
 
Description:
Retrieves loadout of unit and formats it for CfgRespawnLoadouts. Content is copied to clipboard and returned by function.
 
Parameter(s):
0: Object - Object to take the loadout from
1: String - Class name of the respawn loadout
2: String - Display name of the respawn loadout
3: String - Icon path displayed next to display name
4: String - Loadouts are assigned to a role, possible values:
"Assistant"
"CombatLifeSaver"
"Crewman"
"Default"
"Grenadier"
"MachineGunner"
"Marksman"
"MissileSpecialist"
"Rifleman"
"Sapper"
"SpecialOperative"
"Unarmed"
5: String - Condition for the respawn loadout to be shown. Code inside string has to return boolean. _this refers to the unit inside the respawn screen
 
Returns:
String - Exports formatted loadout
*/
 
params
[
["_object",player,[objNull]],
["_class","REPLACE",[""]],
["_displayName","REPLACE",[""]],
["_icon","\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa",[""]],
["_role","Default",[""]],
["_conditionShow","true",[""]]
];


| [[File:A3 respawnSelectInventory.jpg|200px]]
private _indent = " ";
private _class = format ["class %1",_class];
private _displayName = format ["displayName = ""%1"";",_displayName];
private _icon = format ["icon = ""%1"";",_icon];
private _role = format ["role = ""%1"";",_role];
private _conditionShow = format ["show = ""%1"";",_conditionShow];
private _uniformClass = format ["uniformClass = ""%1"";",uniform _object];
private _backpack = format ["backpack = ""%1"";",backpack _object];
private _export = _class + endl + "{" + endl + _indent + _displayName + endl + _indent + _icon + endl + _indent + _role + endl + _indent + _conditionShow + endl + _indent + _uniformClass + endl + _indent + _backpack + endl;
private _weapons = weapons _object;
private _primWeaponItems = primaryWeaponItems _object;
private _secWeaponItems = secondaryWeaponItems _object;
private _assignedItems = assigneditems _object;
// From BIS_fnc_exportLoadout START
private _fnc_addArray =
{
params ["_name","_array"];
_export = _export + format [_indent + "%1[] = {",_name];
{
if (_foreachindex > 0) then {_export = _export + ",";};
_export = _export + format ["""%1""",_x];
} foreach _array;
_export = _export + "};" + endl;
};


["weapons",_weapons + ["Throw","Put"]] call _fnc_addArray;
["magazines",magazines _object] call _fnc_addArray;
["items",items _object] call _fnc_addArray;
["linkedItems",[vest _object,headgear _object,goggles _object] + _assignedItems - _weapons + _primWeaponItems + _secWeaponItems] call _fnc_addArray;
// From BIS_fnc_exportLoadout END
_export = _export + "};" + endl + "// Visit https://community.bistudio.com/wiki/Arma_3_Respawn for detailed information";


|-
copyToClipboard _export;
| '''Revive'''
_export
| Enable the revive system introduced in the End Game mission. After player is damaged enough, they will get incapacitated and bleed out unless another player can revive them. <br>
</sqf>
Optional parameters: [[Description.ext#reviveDelay|reviveDelay]], [[Description.ext#reviveForceRespawnDelay|reviveForceRespawnDelay]], [[Description.ext#reviveBleedOutDelay|reviveBleedOutDelay]]
</spoiler>
|
{{Feature|important|Loadouts are only available after they were added with the [[BIS_fnc_addRespawnInventory]] function!}}




|}
== Restore Loadout on Respawn ==


=== Respawn Button ===
In order to let players respawn with the gear they started the mission with, create the following two files in your mission folder and add the code:<br>
Respawn button in the pause menu is automatically now enabled for INSTANT, BASE, GROUP and SIDE respawn types. You can set its availability manually using following description.ext entry:
{{hl|[[Event Scripts|initPlayerLocal.sqf]]}}
respawnButton = 0;
<sqf>
* 1 - enabled
player setVariable ["TAG_LoadoutStart", getUnitLoadout player];
* 0 - disabled
player addEventHandler ["Respawn", { player setUnitLoadout (player getVariable ["TAG_LoadoutStart", []]); }];
</sqf>


=== Scripting Commands ===
Alternatively you can do:<br>
* [[playerRespawnTime]]
{{hl|[[Event Scripts|initPlayerLocal.sqf]]}}
* [[setPlayerRespawnTime]]
<sqf>player setVariable ["TAG_LoadoutStart", getUnitLoadout player];</sqf>
* [[respawnVehicle]]
{{hl|[[Event Scripts|onPlayerRespawn.sqf]]}}
<sqf>player setUnitLoadout (player getVariable ["TAG_LoadoutStart", []]);</sqf>


=== Scripting Functions ===
* [[BIS_fnc_addRespawnPosition]]
* [[BIS_fnc_removeRespawnPosition]]
* [[BIS_fnc_respawnTickets]]


== System Configuration ==
{{GameCategory|arma3|Editing}}
=== Respawn Templates ===
New templates can be defined in global [[Config.cpp]] or in mission and campaign [[Description.ext]] files.
class CfgRespawnTemplates
{
{{codecomment|// Class used in respawnTemplates entry}}
class myTag_beacon
{
{{codecomment|// Function or script executed upon death. Parameters passed into it are the same as are passed into onPlayerKilled.sqf file}}
onPlayerKilled = "\myAddon\scripts\respawnBeacon.sqf";
{{codecomment|// Function or script executed upon respawn. Parameters passed into it are the same as are passed into onPlayerRespawn.sqf file}}
onPlayerRespawn = "\myAddon\scripts\respawnBeacon.sqf";
{{codecomment|// Default respawn delay (can be overwitten by description.ext entry of the same name)}}
respawnDelay = 20;
{{codecomment|// 1 to respawn player when he joins the game. Available only for INSTANT and BASE respawn types}}
{{codecomment|// Can be overridden by description.ext attribute of the same name}}
respawnOnStart = 1;
};
class Spectator
{
onPlayerRespawn = "BIS_fnc_respawnSpectator";
};
};

Revision as of 22:11, 15 April 2022


Settings


Scripting

Scripting Commands

Scripting Functions

Event Scripts


Respawn Types

Type is represented either by respawn ID, or by its name.

respawn = "BASE";
respawn = 3;
ID Name Description Default Templates onPlayerKilled onPlayerRespawn
0 "NONE" Show singleplayer death screen N/A Checked Unchecked
1 "BIRD" Respawn to a seagull Spectator, EndMission Unchecked Checked
2 "INSTANT" Respawn on spot where player died Instant, Counter Checked Checked
3 "BASE" Respawn on a marker(s) start by following strings:

Unit respawn

  • respawn (used only when side variant is not found)
  • respawn_west
  • respawn_east
  • respawn_guerrila
  • respawn_civilian

Vehicle respawn

  • respawn (used only when side variant is not found)
  • respawn_vehicle_west
  • respawn_vehicle_east
  • respawn_vehicle_guerrila
  • respawn_vehicle_civilian

You can have multiple markers simply by adding any text behind the name, e.g. respawn_west1, respawn_westBase etc. When no markers are defined, player is respawned on position where he started the mission. More about marker respawn can be found here. Alternatively you can also use the Respawn Position module.

Base, Counter Checked Checked
4 "GROUP" Respawn to the next available playable unit in a group. When none is left, BIRD respawn is used instead. Group, EndMission Unchecked Checked
5 "SIDE" Respawn to the next available playable unit of the same side (selected using team switch window). When none is left, BIRD respawn is used instead. Side, EndMission Unchecked Checked


Respawn Templates

Respawn Templates are case-sensitive!

Templates are pre-defined scripts called when player dies and respawns. They are defined in an array and can be combined together.

respawnTemplates[] = { "MenuInventory", "MenuPosition" };

Additionally, you can define side specific templates. When a side has no unique templates, it will use general respawnTemplates instead.

 respawnTemplatesWest[] = { "MenuInventory" };
 respawnTemplatesEast[] = { "Counter" };
 respawnTemplatesGuer[] = { "Tickets" };
 respawnTemplatesCiv[] = { "Spectator" };
 respawnTemplatesVirtual[] = {}; // Virtual players, used mainly in Curator (Zeus) missions
When the respawnTemplates entry is missing, default templates based on the respawn type are used.

Conflicts

The respawn templates "MenuPosition" and "Spectator" are not compatible since MenuPosition will force the map open. Instead you can use the following settings to get access to the full spectator mode:

// description.ext
respawn = 3;
respawnTemplates[] = { "MenuPosition", "Spectator" };

// initPlayerLocal.sqf // --- Enable full spectator in respawn screen { missionNamespace setVariable [_x, true]; } forEach [ "BIS_respSpecAi", // Allow spectating of AI "BIS_respSpecAllowFreeCamera", // Allow moving the camera independent from units (players) "BIS_respSpecAllow3PPCamera", // Allow 3rd person camera "BIS_respSpecShowFocus", // Show info about the selected unit (dissapears behind the respawn UI) "BIS_respSpecShowCameraButtons", // Show buttons for switching between free camera, 1st and 3rd person view (partially overlayed by respawn UI) "BIS_respSpecShowControlsHelper", // Show the controls tutorial box "BIS_respSpecShowHeader", // Top bar of the spectator UI including mission time "BIS_respSpecLists" // Show list of available units and locations on the left hand side ];

Official Templates

Class Description Preview
None Singleplayer death screen. Default in singleplayer.
Spectator Spectator Mode.
Instant Currently empty.
Base Currently empty.
Group Cutscene showing a newly controlled unit.
Side Cutscene showing a newly controlled unit.
Seagull Operation Flashpoint-style seagull respawn
Wave Adjusts respawn counter so players spawns together. Wave delay is based on respawnDelay and Player's respawn time is set between 1 and 2 times respawnDelay: if respawnDelay is set to e.g 10, respawn waves happen every 10 seconds. If a player dies and the next respawn wave is in 3 seconds, the player's respawn time is set to 17 seconds to match the next wave.
Tickets Use a limited respawn ticket pool for players. Pool can be applied to everyone, a side, a group or a single unit.

Use BIS_fnc_respawnTickets to update the amount of available tickets. Note that the template will have no effect if this function is never used, meaning players outside of all given pools will have infinite respawns.

Counter Show a simple respawn countdown.
EndMission Automatically fail the mission once all players are dead (for NONE, BIRD, GROUP and SIDE respawn types) or when all respawn tickets are exceeded (for INSTANT and BASE respawn types with Tickets template)
MenuPosition Lets players select from available respawn positions defined either by respawn markers, see Respawn Types, by BIS_fnc_addRespawnPosition function or by the Respawn Position module. A new screen was released with Arma 3 logo black.png1.60 and brings new functionalities together with a new design.

Item disabling

A3 respawnSelectPosition.jpg
MenuInventory

Lets players pick a respawn loadout defined in CfgRespawnInventory. Loadouts can be added using BIS_fnc_addRespawnInventory function. A new screen was released with Arma 3 logo black.png1.60 and brings new functionalities together with a new design.

Role selection

  • Respawn inventories are sorted in to Roles which can be defined in CfgRoles.

Item disabling

  • Roles and loadouts can be disabled. This can happen automatically (e.g., Role/loadout limit was reached) or can be manually by calling BIS_fnc_showRespawnMenuDisableItem.

Limits

  • Roles and loadouts can be limited. This way only limited number of player can use given role/loadout in a mission. For details on how to do that see BIS_fnc_addRespawnInventory.
A3 respawnSelectInventory.jpg

Options shared by MenuInventory and MenuPosition
Both templates feature a similar respawn UI and therefore share the following options:

  • Timeout disabling
  • Autorespawn
    • A checkbox can be ticket to let the player automatically respawn once the coundown reached 0. If disabled player is not respawned immediately, but must confirm selection by clicking on "RESPAWN" button.
  • Spectator Camera
    • The Spectator Camera used in here is slightly modified (no free camera available etc.) version of Spectator Mode. For full documentation see Spectator Mode documentation.
    • Mission designer needs to use the Spectator respawn template, the camera is disabled otherwise.

Custom Respawn Templates

New templates can be defined in global Config.cpp or in mission and campaign Description.ext files.
Example:

class CfgRespawnTemplates
{
	// Class used in respawnTemplates entry
	class myTag_beacon
	{
		// Function or script executed upon death. Parameters passed into it are the same as are passed into onPlayerKilled.sqf file
		onPlayerKilled = "\myAddon\scripts\respawnBeacon.sqf";
		// Function or script executed upon respawn. Parameters passed into it are the same as are passed into onPlayerRespawn.sqf file
		onPlayerRespawn = "\myAddon\scripts\respawnBeacon.sqf";
		// Default respawn delay (can be overwitten by description.ext entry of the same name)
		respawnDelay = 20;
		// 1 to respawn player when he joins the game. Available only for INSTANT and BASE respawn types
		// Can be overridden by description.ext attribute of the same name
		respawnOnStart = 1;
		// By default onPlayerKilled and onPlayerRespawn function are spawned
		// set to 1 to run in unscheduled, called functions MUST NOT return an assignment or respawn will break
		isCall = 0;
	};
	class Spectator
	{
		onPlayerRespawn = "BIS_fnc_respawnSpectator";
	};
};


Loadouts and Roles

The main purpose of the roles is to make things more clear and simple for player when selecting loadout. All the loadouts available in a mission are now divided into various roles.
Mission designer can use roles already created in the game config, or custom roles can be defined in description.ext file. Loadouts with no role assigned are automatically assigned to the Default role.
Loadout config example:

class CfgRoles
{
	class Assault // Class name used in CfgRespawnInventory
	{
		displayName = $STR_A3_Role_Assault; // Name of the role, displayed in the respawn menu
		icon = "a3\missions_f_exp\data\img\classes\assault_ca.paa"; // Icon shown next to the role name in the respawn screen
	};
};
 
class CfgRespawnInventory
{
	class B_SquadLeader // Class of the respawn inventory, used by BIS_fnc_addRespawnInventory
	{
		displayName = $STR_b_soldier_sl_f0; // Name of the respawn inventory
		role = "Assault"; // Role the respawn inventory is assigned to
		icon = "\A3\ui_f\data\map\VehicleIcons\iconManLeader_ca.paa"; // Icon shown next to the role
		show = "side group _this == west"; // Condition used to make specific respawn inventories only avaiable for specfic sides, must return [[Boolean]]
		weapons[] = { // Weapons
			"arifle_SPAR_01_khk_F",
			"Rangefinder",
			"hgun_P07_khk_F"
		};
		magazines[] = { // Magazines
			"SmokeShell",
			"SmokeShell",
			"16Rnd_9x21_Mag",
			"16Rnd_9x21_Mag",
			"16Rnd_9x21_Mag",
			"30Rnd_556x45_Stanag_Tracer_Red",
			"30Rnd_556x45_Stanag_Tracer_Red",
			"30Rnd_556x45_Stanag_Tracer_Red",
			"30Rnd_556x45_Stanag_Tracer_Red",
			"30Rnd_556x45_Stanag_Tracer_Red",
			"30Rnd_556x45_Stanag_Tracer_Red",
			"30Rnd_556x45_Stanag_Tracer_Red",
			"30Rnd_556x45_Stanag_Tracer_Red",
			"HandGrenade",
			"HandGrenade"
		};
		items[] = { // Useable items
			"FirstAidKit"
		};
		linkedItems[] = { // Linked items, also weapon items, helmet etc.
			"V_PlateCarrierSpec_tna_F",
			"H_HelmetB_Enh_tna_F",
			"optic_ERCO_blk_F",
			"acc_pointer_IR",
			"NVGoggles_tna_F",
			"ItemGPS",
			"ItemMap",
			"ItemCompass",
			"ItemWatch",
			"ItemRadio"
		};
		uniformClass = "U_B_T_Soldier_SL_F"; // uniform
	};
↑ Back to spoiler's top

Export Function:

  • The following function will copy a complete respawn inventory to your clipboard, see function header for more information.

Author: R3vo

/* Author: R3vo Description: Retrieves loadout of unit and formats it for CfgRespawnLoadouts. Content is copied to clipboard and returned by function. Parameter(s): 0: Object - Object to take the loadout from 1: String - Class name of the respawn loadout 2: String - Display name of the respawn loadout 3: String - Icon path displayed next to display name 4: String - Loadouts are assigned to a role, possible values: "Assistant" "CombatLifeSaver" "Crewman" "Default" "Grenadier" "MachineGunner" "Marksman" "MissileSpecialist" "Rifleman" "Sapper" "SpecialOperative" "Unarmed" 5: String - Condition for the respawn loadout to be shown. Code inside string has to return boolean. _this refers to the unit inside the respawn screen Returns: String - Exports formatted loadout */ params [ ["_object",player,[objNull]], ["_class","REPLACE",[""]], ["_displayName","REPLACE",[""]], ["_icon","\A3\Ui_f\data\GUI\Cfg\Ranks\sergeant_gs.paa",[""]], ["_role","Default",[""]], ["_conditionShow","true",[""]] ]; private _indent = " "; private _class = format ["class %1",_class]; private _displayName = format ["displayName = ""%1"";",_displayName]; private _icon = format ["icon = ""%1"";",_icon]; private _role = format ["role = ""%1"";",_role]; private _conditionShow = format ["show = ""%1"";",_conditionShow]; private _uniformClass = format ["uniformClass = ""%1"";",uniform _object]; private _backpack = format ["backpack = ""%1"";",backpack _object]; private _export = _class + endl + "{" + endl + _indent + _displayName + endl + _indent + _icon + endl + _indent + _role + endl + _indent + _conditionShow + endl + _indent + _uniformClass + endl + _indent + _backpack + endl; private _weapons = weapons _object; private _primWeaponItems = primaryWeaponItems _object; private _secWeaponItems = secondaryWeaponItems _object; private _assignedItems = assigneditems _object; // From BIS_fnc_exportLoadout START private _fnc_addArray = { params ["_name","_array"]; _export = _export + format [_indent + "%1[] = {",_name]; { if (_foreachindex > 0) then {_export = _export + ",";}; _export = _export + format ["""%1""",_x]; } foreach _array; _export = _export + "};" + endl; }; ["weapons",_weapons + ["Throw","Put"]] call _fnc_addArray; ["magazines",magazines _object] call _fnc_addArray; ["items",items _object] call _fnc_addArray; ["linkedItems",[vest _object,headgear _object,goggles _object] + _assignedItems - _weapons + _primWeaponItems + _secWeaponItems] call _fnc_addArray; // From BIS_fnc_exportLoadout END _export = _export + "};" + endl + "// Visit https://community.bistudio.com/wiki/Arma_3_Respawn for detailed information"; copyToClipboard _export; _export

↑ Back to spoiler's top

Loadouts are only available after they were added with the BIS_fnc_addRespawnInventory function!


Restore Loadout on Respawn

In order to let players respawn with the gear they started the mission with, create the following two files in your mission folder and add the code:
initPlayerLocal.sqf

player setVariable ["TAG_LoadoutStart", getUnitLoadout player]; player addEventHandler ["Respawn", { player setUnitLoadout (player getVariable ["TAG_LoadoutStart", []]); }];

Alternatively you can do:
initPlayerLocal.sqf

player setVariable ["TAG_LoadoutStart", getUnitLoadout player];

onPlayerRespawn.sqf

player setUnitLoadout (player getVariable ["TAG_LoadoutStart", []]);