Automatic Body Removal (FIFO)

From F2 EN
Jump to: navigation, search

Description

The Automatic Body Removal component uses a technique which adds 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. One drawback to this approach is that bodies can start to disappear in front of players, which is not very sophisticated.

Another method for removing bodies is called FIFO – which stands for "First In, First Out". This approach also adds an event handler to each unit; however, when the unit is killed, it is added to an array containing all the dead bodies. As the array fills up, the first unit to enter it is removed from the mission (imagine a conveyor belt). The FIFO approach means that, hopefully, when a body disappears, it is less likely to be visible to players.

To further ensure that dead bodies do not disappear in front of players, the FIFO approach also lets the mission maker define how far a body must be from the player before it is removed.

Required files

All the code associated with this component is found in:

  • init.sqf
  • f\server\f_abrFIFO.sqf
  • f\common\f_setLocalVars.sqf
  • f\common\f_addRemoveBodyEH.sqf
  • f\common\f_abrAddToFIFO.sqf

How to activate

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

// F2 - Automatic Body Removal (FIFO)

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

// f_abrFIFOlength = 30;
// f_abrDistance = 150;
// f_abrFIFOmaxLength = 50;
// f_doNotRemoveBodies = [];
// ["fifo"] execVM "f\common\f_addRemoveBodyEH.sqf";
// [] execVM "f\server\f_abrFIFO.sqf";

How to use

Default setting

By default, this component is configured to starting removing dead bodies after 30 units have been been killed (30 is the size of the FIFO array). Bodies will also not be removed until they are 150m from the nearest player, unless the FIFO array contains 50 or more dead bodies – in which case the removal will commence regardless. Additionally, all groups (including player groups) will have their bodies removed - there are no exceptions by default.

Changing the size of the FIFO array

To change the desired number of bodies which much be in the FIFO array before a body is deleted open the file init.sqf and look for the code segment entitled:

// F2 - Automatic Body Removal (FIFO)

Edit the following line, changing the value of f_abrFIFOlength = 30; to the desired number of bodies:

f_abrFIFOlength = 30;

Changing the minimum distance

To change the minimum distance a body must be from the nearest player before it is deleted open the file init.sqf and look for the code segment entitled:

// F2 - Automatic Body Removal (FIFO)

Edit the following line, changing the value of f_abrDistance = 150; to the desired distance (in metres):

f_abrDistance = 150;

Changing the maximum size of the FIFO array

To change the desired number of bodies which much be in the FIFO array for bodies to start being removed regardless of distance to the nearest player, open the file init.sqf and look for the code segment entitled:

// F2 - Automatic Body Removal (FIFO)

Edit the following line, changing the value of f_abrFIFOmaxLength = 50; to the desired number of bodies:

f_abrFIFOmaxLength = 50;

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:

// F2 - Automatic Body Removal (FIFO)

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", 
{
if (isServer) then
{
f_abrFIFO = f_abrFIFO + [_this select 0];
} else
{
_this execVM "f\common\f_abrAddToFIFO.sqf"	
};
}];

Credits

  • Headspace
  • Raedor