Automatic Body Removal

From F2 EN
Jump to: navigation, search

Description

In order to reduce lag in large missions a common technique is to remove dead bodies from the battlefield. This is accomplished by adding an event handler to each unit: when the unit is killed, a script is run that will pause for a certain amount of time, then delete the body. F2 includes a component that will automatically add such an event handler to all units in the mission.

Required files

All the code associated with this component is found in:

  • init.sqf
  • f\common\f_setLocalVars.sqf
  • f\common\f_addRemoveBodyEH.sqf
  • f\common\f_removeBody.sqf

How to activate

Open the file init.sqf and look for the code segment entitled:

// F2 - Automatic Body Removal

In the block of code below edit the following lines, removing the // at the start of each:

// f_removeBodyDelay = 180;
// f_doNotRemoveBodies = [];
// [] execVM "f\common\f_addRemoveBodyEH.sqf";

How to use

Default setting

By default, this component is configured to remove all dead bodies 180 seconds (3 minutes) after the unit has been been killed.

Changing the delay

To change delay before a dead body is removed open the file init.sqf and look for the code segment entitled:

// BAS f - Automatic Body Remover

Edit the following line, changing the value of f_removeBodyDelay to the desired number of seconds for the delay before a body is deleted:

f_removeBodyDelay = 180;

Excluding selected groups

Because the gear on a dead body is also deleted, you may not want to apply this feature to some groups of soldiers (such as the players' group). To make a group exempt from this feature, and never delete its units' bodies open the file init.sqf and look for the code segment entitled:

// BAS f - Automatic Body Remover

Edit the following line, changing the value of f_doNotRemoveBodies from [] to include the name of the group(s) you want to exempt.

f_doNotRemoveBodies = [];

For example, to make the group GrpUSMC_1Plt_Charlie exempt from this feature, change the line to:

f_doNotRemoveBodies = [GrpUSMC_1Plt_Charlie];

To make more than one group exempt, use commas to separate the group names:

f_doNotRemoveBodies = [GrpUSMC_1Plt_Charlie,GrpUSMC_1Plt_C1,GrpUSMC_1Plt_C2,GrpUSMC_1Plt_C3];

Tips

  • A key limitation of this component is that it cannot automatically add the event handler to units which are created dynamically during the mission (for example, if you use a script to generate enemies or civilians dynamically). However, you can add the event handler by ensuring that any dynamically-created units have the following code in their INIT line:
this addEventHandler ["killed", {_this execVM "f\common\f_removeBody.sqf"}];

Credits

  • Headspace
  • Raedor
  • Fer