R3vo/Sandbox – User

From Bohemia Interactive Community
Jump to navigation Jump to search
mNo edit summary
 
(458 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{SideTOC}}
{{TOC|side}}
[[File:A3 RespawnScreen.jpg|400px]]
If you have ever wondered why you scenario is running so badly, performance profiling is the way to find it out. It allows you to find bottlenecks and slow code by capturing a "slow" frame.
== Description.ext ==
The captured data can then be viewed and analysed.
A wide range of [[Description.ext]] entries let you configure respawn settings for your mission. See [https://community.bistudio.com/wiki/Description.ext#Respawn.2FRevive Description.ext - Respawn] for a detailed documentation


== Eden Editor ==
== Getting the correct Version ==
[[Eden Editor]] offers alot of settings to customise your respawn system, however not all functionalities are available. Furthermore settings made in the description.ext will overwrite settings made in [[Eden Editor]].
Profiling is enabled in the following {{arma3}} versions
[[File:A3 EdenEditor Respawn.jpg|400px]]
* arma3profiling_x64.exe - '''Part of the Performance Profiling Build'''
== Scripting ==
* arma3diag_x64.exe - '''Part of the Development Build'''
''' Scripting Commands '''
* [[playerRespawnTime]]
* [[setPlayerRespawnTime]]
* [[respawnVehicle]]


''' Scripting Functions '''
Read [[Arma_3: Steam Branches]] for a guide on how to access these branches.
* [[:Category:Function Group: Respawn|Respawn Functions]]


''' Event Scripts '''
{{Feature|informative|It is recommended to use the '''Performance Profiling Build''' (arma3profiling_x64.exe) for performance profiling because:
* [[Event Scripts|onPlayerRespawn.sqf]]
* Has tools that might not make it into development build
* [[Event Scripts|onPlayerKilled.sqf]]
* Has all the profiling related commands that ''arma3diag_x64.exe'' has
* Its performance is closer to the default ''arma3_x64.exe''}}


== Respawn Types ==
== Frame Capturing ==
Type is represented either by respawn ID, or by its name.
There are several commands that allow you to capture a frame.
<code>respawn = "BASE";
* [[diag_captureFrame]]
respawn = 3;</code>
* [[diag_captureSlowFrame]]
{| class="wikitable"
* [[diag_logSlowFrame]] - not available in Arma 3 :(
! ID
* [[diag_captureFrameToFile]]
! Name
In most cases you do not want to capture any or all frames, you just want to capture "slow" frames. A slow frame is a frame that takes longer than the average frame and slows down the game.
! Description
 
! Default Templates
== How to Use ==
! onPlayerKilled
# Run a mission
! onPlayerRespawn
# Execute a scripted command <sqf inline>diag_captureSlowFrame ["total", 0.3];</sqf> using any means ([[Arma 3: Debug Console|Debug Console]], mission radio trigger...)
|-
# Once a slow frame is detected, a window will open
| 0
# In the window you will be able to browse a lot of performance-related data, which can be interesting
| "NONE"
# To export the gathered information for sharing with others:
| Show singleplayer death screen
## Select Main Thread (if not selected yet)
| -
## Press the Copy button
|style="text-align:center;"| {{task/}}
## Open an external text editor
|style="text-align:center;"| {{task}}
## Paste the text into a new file
## Save the file
 
== Capture Frame UI ==
[[File: arma3-capture frame ui overview.png]]
 
# {{Wiki|TODO}}
# {{Wiki|TODO}}
# {{Wiki|TODO}}
# {{Wiki|TODO}}
# {{Wiki|TODO}}
# {{Wiki|TODO}}
# {{Wiki|TODO}}
# {{Wiki|TODO}}
# {{Wiki|TODO}}


|-
== External Viewer ==
| 1
* chrome://tracing
| "BIRD"
* https://ui.perfetto.dev/
| Respawn to a seagull
| Spectator, EndMission
|style="text-align:center;"| {{task}}
|style="text-align:center;"| {{task/}}


|-
[[File:Performance_Profiling_04.png|thumb|diag_captureFrame sample output with custom subtree]]
| 2
== Creating Your Own Subtree ==
| "INSTANT"
| Respawn on spot where player died
| Instant, Counter
|style="text-align:center;"| {{task/}}
|style="text-align:center;"| {{task/}}


|-
When Profiling Per-Frame Eventhandlers (PFH), [[diag_captureFrame]] only shows one blob called siFEH that contains all PFH's so you can't see what part of that is caused by your PFH.<br>
| 3
You can create your own subtree inside siFEH by wrapping your function call inside a [[isNil]] CODE statement like this:<br>
| "BASE"
Turn your old call which may look like this:
| Respawn on a marker(s) start by following strings:
<sqf>
'''Unit respawn'''
addMissionEventHandler ["EachFrame", {
*''respawn'' (used only when side variant is not found)
call myPFHFunction
*''respawn_west''
}];
*''respawn_east''
</sqf>
*''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 [http://killzonekid.com/arma-scripting-tutorials-respawn-on-marker/ here]. Alternatively you can also use the ''Respawn Position'' module.
| Base, Counter
|style="text-align:center;"| {{task/}}
|style="text-align:center;"| {{task/}}


|-
Into something like this:
| 4
<sqf>
| "GROUP"
addMissionEventHandler ["EachFrame", {
| Respawn to the next available playable unit in a group. When none is left, BIRD respawn is used instead.
isNil { call myPFHFunction } // isNil creates the subtree
| Group, EndMission
}];
|style="text-align:center;"| {{task}}
</sqf>
|style="text-align:center;"| {{task/}}


|-
Now when you run [[diag_captureFrame]] inside of siPFH you will have a subtree called gsEva and behind that you can see the first line of code inside the isNil statement.<br>
| 5
It will only show a part of the first line of that code so you should put something descriptive into the [[isNil]] statement.<br>
| "SIDE"
You can use the same to create a subtree for any function you like. This will also work inside [[Scheduler#Scheduled_Environment|Scheduled]] ([[spawn]]ed) scripts. <br>
| 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.
But using this method to "subtree" a function with return values requires a little bit of trickery to get the return value out.
| Side, EndMission
|style="text-align:center;"| {{task}}
|style="text-align:center;"| {{task/}}
|}


== Respawn Templates ==
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[] = {}; {{codecomment|// Virtual players, used mainly in [[Curator]] missions}}
{{Important|When the respawnTemplates entry is missing, default templates based on the respawn type are used}}


== Notes ==


==Official Templates==
* 0.3 is a time in second used to determine what duration of a frame you consider abnormal, and first such frame will be captured.
{| class="wikitable"
* 0.3 is definitely something you should not see in a normal game.
! Class
* If you do not capture any frames with 0.3, try lowering it to 0.2 or 0.1.
! Description
* If it triggers too early, before the main slowdown happens, increase it to a higher value, e.g. 1.0.
! Preview


== Scopes ==
{| class="wikitable sortable"
|-
! Technical Name !! Descriptive Name !! Description
|-
| Main
|
|
|-
| total
|
|
|-
| fsPHa
|
|
|-
| winMs
|
|
|-
| dlcSim
|
|
|-
| steamCbk
|
|
|-
| input
|
|
|-
| wSimu
|
|
|-
| docSim
|
|
|-
| wSimDisp
|
|
|-
| MFDManager
|
|
|-
| wDisp
|
|
|-
| EventPrcs
|
|
|-
| gsEva
|
|
|-
| gbFrm
|
|
|-
| memLo
|
|
|-
| siScr
|
|
|-
| scrVM
|
|
|-
| wsSet
|
|
|-
| sLand
|
|
|-
| simSW
|
|
|-
| cLWObj
|
|
|-
| oTemp
|
|
|-
| FPres
|
|
|-
| waitSnd
|
|
|-
| job
|
|
|-
| sound
|
|
|-
| ssAdv
|
|
|-
| snCmt
|
|
|-
| play
|
|
|-
| ARTCpl
|
|
|-
| rendr
|
|
|-
| drwVi
|
|
|-
| txHLi
|
|
|-
| txPMM
|
|
|-
| dsr2t
|
|
|-
| wPrep
|
|
|-
| dPr
|
|
|-
| fmiRun
|
|
|-
| fmiWait
|
|
|-
| fmiMDrw
|
|
|-
| fmiSIns
|
|
|-
| wPrepFtr
|
|
|-
| clPrp
|
|
|-
| oPrep
|
|
|-
| sceAC
|
|
|-
| oSplt
|
|
|-
| sceACTA
|
|
|-
| sceACPrx
|
|
|-
| lodUL
|
|
|-
| PrxObj
|
|
|-
| manAn
|
|
|-
|-
| '''None'''
| ppdOT
| Singleplayer death screen. Default in singleplayer.
|  
|
|  
 
|-
| flProx
|
|
|-
| PrxObjTransport
|
|
|-
| oSoSL
|
|
|-
| oSoJE
|
|
|-
| oSoJE1
|
|
|-
| oSoJE2
|
|
|-
| oSo1OFOv
|
|
|-
| oSo1ON
|
|
|-
| sceCLsHSH
|
|
|-
| prpAMCt
|
|
|-
| oSoJEw
|
|
|-
| pDrwFNP
|
|
|-
| oSoSLu
|
|
|-
| lPGCl
|
|
|-
| pdDrw
|
|
|-
| lDGnd
|
|
|-
| lGSMM
|
|
|-
| recCB
|
|
|-
| mtPmj
|
|
|-
| cuDrw
|
|
|-
| prepT
|
|
|-
| drwCB
|
|
|-
| oPasD
|
|
|-
| o1Drw
|
|
|-
| lckDnBf
|
|
|-
| prpTx
|
|
|-
| inst
|
|
|-
| stpSctnTL
|
|
|-
| o1ShV
|
|
|-
| scSVI
|
|
|-
| oPas3
|
|
|-
| sssmC
|
|
|-
| sbDrw
|
|
|-
| aniMt
|
|
|-
| ppSSSM
|
|
|-
| drwROM
|
|
|-
| drwIn
|
|
|-
| wDraw
|
|
|-
| lDPGT
|
|
|-
| oSDrw
|
|
|-
| oPasO
|
|
|-
| lDSky
|
|
|-
| swRdr
|
|
|-
| ppSWDD
|
|
|-
| swRdGeom
|
|
|-
| swRdGeomVB
|
|
|-
| swFillV
|
|
|-
| oPasA
|
|
|-
| ppShrpn
|
|
|-
| lDWat
|
|
|-
| oPas2
|
|
|-
| o2Drw
|
|
|-
| oPas5
|
|
|-
| o5Drw
|
|
|-
| EDraw3D
|
|
|-
| MEventPrcs
|
|
|-
| cLGSY
|
|
|-
| stpAll
|
|
|-
| stpCB
|
|
|-
| stpTxtCS
|
|
|-
| stpUAVsCS
|
|
|-
| ppHDRCL
|
|
|-
| ppGSB
|
|
|-
| ppDOF
|
|
|-
| ppGlwNw
|
|
|-
| ppGLu
|
|
|-
| stpCBUpd
|
|
|-
| ppQWt
|
|
|-
| ppCMAA
|
|
|-
| hudDr
|
|
|-
| 3DEN_UI_OnDraw
|
|
|-
| 3DEN_PrepareDraw
|
|
|-
| clObL
|
|
|-
| 3DEN_Drawing
|
|
|-
| stpTxtGS
|
|
|-
| txt2D
|
|
|-
| mapDr
|
|
|-
| mapSeaAndNormal
|
|
|-
| mapPM
|
|
|-
| lndPM
|
|
|-
| MapObjectsPrepTask
|
|
|-
| mapSeaAndNormalDraw
|
|
|-
| mapCntDraw
|
|
|-
| mapObjectsDraw
|
|
|-
| mapForestShape
|
|
|-
| mapGrid
|
|
|-
| drwFn
|
|
|-
| dtTot
|
|
|-
| wFram
|
|
|-
| 3dSwp
|
|
|-
| preLd
|
|
|-
| preLV
|
|
|-
| actObjPrld
|
|
|-
| hashChk
|
|
|-
| sSim
|
|
|-
| enfWorkShort
|
|
|-
| updAttPos
|
|
|-
| oSo1AN
|
|
|-
| prpAMCf
|
|
|-
| prpAMCSlt
|
|
|-
| prpSDM
|
|
|-
| locL
|
|
|-
| mapSeaAndNormalWork
|
|
|-
| mapObjectsPrepWork
|
|
|-
| drwIdxPrm
|
|
|-
| oSo3
|
|
|-
| lsCVB
|
|
|-
| oSo5
|
|
|-
| oSo2CL
|
|
|-
|-
| '''Spectator'''
| oSo1AF
| [[Spectator Mode]].
|  
|
|  
 
|-
|-
| '''Instant'''
| Visualize
| Currently empty.
|  
|
|  
 
|-
|-
| '''Base'''
| visul
| Currently empty.
|  
|
|  
 
|-
|-
| '''Group'''
| txMLo
| Cutscene showing a newly controlled unit.
|  
|
|  
 
|-
|-
| '''Side'''
| oSo2Srt
| Cutscene showing a newly controlled unit.
|  
|
|  
 
|-
|-
| '''Seagull'''
| oSoSdw
| OFP-style seagull respawn
|  
|
|  
 
|-
|-
| '''Wave'''
| prpAMCbsi
| Adjusts respawn counter so players spawns together (wave delay is based on ''respawnDelay'')
|  
|
|  
 
|-
|-
| '''Tickets'''
| prpAMCp
| 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'''
| Render
| Show a simple respawn countdown.
|  
|
|  
 
|-
|-
| '''EndMission'''
| bgD3D
| 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'''
| stpTxtVS
| 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.
|  
 
|  
'''Item disabling'''
*Respawn positions can be disabled automatically (e.g., unit used as respawn point is dead) or manually by calling [[BIS_fnc_showRespawnMenuDisableItem]]<br>
| [[File:A3 respawnSelectPosition.jpg|200px]]
 
|-
|-
| '''MenuInventory'''
| ppHBAOPlus
|
|  
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.
|  
 
'''Role selection'''
*Respawn inventories are sorted in to Roles which can be defined in ''CfgRole'', see (ADD LINK TO EXAMPLE).
 
'''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]].<br>
 
'''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]].
| [[File:A3 respawnSelectInventory.jpg|200px]]
|}
|}


'''Options shared by ''MenuInventory'' and ''MenuPosition'''''<br>
<sqf>
Both templates feature a similar respawn UI and therefore share the following options:
private _ctrlTV = ctrlparent (_this select 0) displayCtrl 101;


*'''Timeout disabling'''
private _export = "{| class=""wikitable sortable"""  + endl + "|-" + endl;
**Mission designer can disable the timeout used between death of a unit and opening of the respawn screen.<br>
_export = _export + "! Technical Name !! Descriptive Name !! Description";
{{Inline code|[[missionNamespace]] [[setVariable]] [ "BIS_RscRespawnControls_skipBlackOut", [[true]], [[true]] ];//Disable timout }}<br>
{{Inline code|[[missionNamespace]] [[setVariable]] [ "BIS_RscRespawnControls_skipBlackOut", [[nil]], [[true]] ];//Reset to original timeout}}


*'''Autorespawn'''
private _fnc_logChilden =
**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.
{
    params ["_path"];


*'''Spectator Camera'''
    for "_i" from 0 to ((_ctrlTV tvCount _path) - 1) do
**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.
        private _text = _ctrlTV tvText (_path + [_i]);
        _text = _text splitString " " select 0;


        if !(_text in _export) then
        {
            _export = _export + endl + "|-" + endl + "| " + _text + endl + "| " + endl + "| ";
        };


 
        if (_ctrlTV tvCount (_path + [_i]) > 0 ) then
== Custom Respawn Templates ==
        {
New templates can be defined in global [[Config.cpp]] or in mission and campaign [[Description.ext]] files.<br>
            [_path + [_i]] call _fnc_logChilden;
'''Example''':<br>
        };
<spoiler>
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";
};
};
</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:'''<br>
<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
     };
     };
};
};
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
    };
</syntaxhighlight>
</spoiler>
'''Export Function''':
*The following function will copy a complete respawn inventory to your clipboard, see function header for more information, contact [[User:R3vo]] if you have questions.<br>
<spoiler>
<syntaxhighlight lang="cpp">
/*
Author: Revo


Description:
[[]] call _fnc_logChilden;
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
 
Can also be custom one, needs to be defined in CfgRoles, visit https://community.bistudio.com/wiki/Arma_3_Respawn:_New_Respawn_Screen for more information
 
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;
copyToClipboard (_export + endl + "|}" + endl);
["magazines",magazines _object] call _fnc_addArray;
</sqf>
["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;
== See Also ==
_export
</syntaxhighlight>
</spoiler>
{{Important|To add any loadout as available in your mission, you need to use the [[BIS_fnc_addRespawnInventory]] function!}}


* [[Code Optimisation]]
* [[Mission Optimisation]]




<br>
[[Category:Arma Scripting Tutorials]]
[[Category:Arma 3: Editing|Respawn]]

Latest revision as of 18:23, 4 November 2024

If you have ever wondered why you scenario is running so badly, performance profiling is the way to find it out. It allows you to find bottlenecks and slow code by capturing a "slow" frame. The captured data can then be viewed and analysed.

Getting the correct Version

Profiling is enabled in the following Arma 3 versions

  • arma3profiling_x64.exe - Part of the Performance Profiling Build
  • arma3diag_x64.exe - Part of the Development Build

Read Arma_3: Steam Branches for a guide on how to access these branches.

It is recommended to use the Performance Profiling Build (arma3profiling_x64.exe) for performance profiling because:
  • Has tools that might not make it into development build
  • Has all the profiling related commands that arma3diag_x64.exe has
  • Its performance is closer to the default arma3_x64.exe

Frame Capturing

There are several commands that allow you to capture a frame.

In most cases you do not want to capture any or all frames, you just want to capture "slow" frames. A slow frame is a frame that takes longer than the average frame and slows down the game.

How to Use

  1. Run a mission
  2. Execute a scripted command diag_captureSlowFrame ["total", 0.3]; using any means (Debug Console, mission radio trigger...)
  3. Once a slow frame is detected, a window will open
  4. In the window you will be able to browse a lot of performance-related data, which can be interesting
  5. To export the gathered information for sharing with others:
    1. Select Main Thread (if not selected yet)
    2. Press the Copy button
    3. Open an external text editor
    4. Paste the text into a new file
    5. Save the file

Capture Frame UI

arma3-capture frame ui overview.png

  1. 🚧
    TODO: this must be updated.
  2. 🚧
    TODO: this must be updated.
  3. 🚧
    TODO: this must be updated.
  4. 🚧
    TODO: this must be updated.
  5. 🚧
    TODO: this must be updated.
  6. 🚧
    TODO: this must be updated.
  7. 🚧
    TODO: this must be updated.
  8. 🚧
    TODO: this must be updated.
  9. 🚧
    TODO: this must be updated.

External Viewer

diag_captureFrame sample output with custom subtree

Creating Your Own Subtree

When Profiling Per-Frame Eventhandlers (PFH), diag_captureFrame only shows one blob called siFEH that contains all PFH's so you can't see what part of that is caused by your PFH.
You can create your own subtree inside siFEH by wrapping your function call inside a isNil CODE statement like this:
Turn your old call which may look like this:

addMissionEventHandler ["EachFrame", { call myPFHFunction }];

Into something like this:

addMissionEventHandler ["EachFrame", { isNil { call myPFHFunction } // isNil creates the subtree }];

Now when you run diag_captureFrame inside of siPFH you will have a subtree called gsEva and behind that you can see the first line of code inside the isNil statement.
It will only show a part of the first line of that code so you should put something descriptive into the isNil statement.
You can use the same to create a subtree for any function you like. This will also work inside Scheduled (spawned) scripts.
But using this method to "subtree" a function with return values requires a little bit of trickery to get the return value out.


Notes

  • 0.3 is a time in second used to determine what duration of a frame you consider abnormal, and first such frame will be captured.
  • 0.3 is definitely something you should not see in a normal game.
  • If you do not capture any frames with 0.3, try lowering it to 0.2 or 0.1.
  • If it triggers too early, before the main slowdown happens, increase it to a higher value, e.g. 1.0.

Scopes

Technical Name Descriptive Name Description
Main
total
fsPHa
winMs
dlcSim
steamCbk
input
wSimu
docSim
wSimDisp
MFDManager
wDisp
EventPrcs
gsEva
gbFrm
memLo
siScr
scrVM
wsSet
sLand
simSW
cLWObj
oTemp
FPres
waitSnd
job
sound
ssAdv
snCmt
play
ARTCpl
rendr
drwVi
txHLi
txPMM
dsr2t
wPrep
dPr
fmiRun
fmiWait
fmiMDrw
fmiSIns
wPrepFtr
clPrp
oPrep
sceAC
oSplt
sceACTA
sceACPrx
lodUL
PrxObj
manAn
ppdOT
flProx
PrxObjTransport
oSoSL
oSoJE
oSoJE1
oSoJE2
oSo1OFOv
oSo1ON
sceCLsHSH
prpAMCt
oSoJEw
pDrwFNP
oSoSLu
lPGCl
pdDrw
lDGnd
lGSMM
recCB
mtPmj
cuDrw
prepT
drwCB
oPasD
o1Drw
lckDnBf
prpTx
inst
stpSctnTL
o1ShV
scSVI
oPas3
sssmC
sbDrw
aniMt
ppSSSM
drwROM
drwIn
wDraw
lDPGT
oSDrw
oPasO
lDSky
swRdr
ppSWDD
swRdGeom
swRdGeomVB
swFillV
oPasA
ppShrpn
lDWat
oPas2
o2Drw
oPas5
o5Drw
EDraw3D
MEventPrcs
cLGSY
stpAll
stpCB
stpTxtCS
stpUAVsCS
ppHDRCL
ppGSB
ppDOF
ppGlwNw
ppGLu
stpCBUpd
ppQWt
ppCMAA
hudDr
3DEN_UI_OnDraw
3DEN_PrepareDraw
clObL
3DEN_Drawing
stpTxtGS
txt2D
mapDr
mapSeaAndNormal
mapPM
lndPM
MapObjectsPrepTask
mapSeaAndNormalDraw
mapCntDraw
mapObjectsDraw
mapForestShape
mapGrid
drwFn
dtTot
wFram
3dSwp
preLd
preLV
actObjPrld
hashChk
sSim
enfWorkShort
updAttPos
oSo1AN
prpAMCf
prpAMCSlt
prpSDM
locL
mapSeaAndNormalWork
mapObjectsPrepWork
drwIdxPrm
oSo3
lsCVB
oSo5
oSo2CL
oSo1AF
Visualize
visul
txMLo
oSo2Srt
oSoSdw
prpAMCbsi
prpAMCp
Render
bgD3D
stpTxtVS
ppHBAOPlus

private _ctrlTV = ctrlparent (_this select 0) displayCtrl 101; private _export = "{| class=""wikitable sortable""" + endl + "|-" + endl; _export = _export + "! Technical Name !! Descriptive Name !! Description"; private _fnc_logChilden = { params ["_path"]; for "_i" from 0 to ((_ctrlTV tvCount _path) - 1) do { private _text = _ctrlTV tvText (_path + [_i]); _text = _text splitString " " select 0; if !(_text in _export) then { _export = _export + endl + "|-" + endl + "| " + _text + endl + "| " + endl + "| "; }; if (_ctrlTV tvCount (_path + [_i]) > 0 ) then { [_path + [_i]] call _fnc_logChilden; }; }; }; [[]] call _fnc_logChilden; copyToClipboard (_export + endl + "|}" + endl);

See Also