IRONFRONT FANS FORUM
Register Latest Topics
 
 
 


Reply
  Author   Comment  
BRS

Captain
Registered:
Posts: 197
Reply with quote  #1 
Edit:
I updated the script below. Overlooked a big bug while copy and paste in hurry. Sorry!
Please try out the new version pasted below.
---------------
Download: Remove dead soldiers place their gear on ground

Here is my new script to remove dead soldiers and place their gear on the ground.
Works for me so far in MP- and SP.- missions.
I just changed it so radius and interval is selectable by user. Read the description inside the script header.
Please report bugs, if any, here in this forum.

BTW: I couldn't show up the correct magazine clips, asked about and got the answer that this can't be done.
I had my doubts about and tried a long time but no usable result. So the generic magazine bag is shown.

As the center object I placed an invisble-H and placed this line into it's Init field:
Code:
nul = [this, 1000, 5 ] execVM "search_and_remove_dead_bodiesV2.sqf";

1000 = radius in meter
5 = 5 minutes interval

You should place this line into your Init.sqf :
Code:
 compile preprocessFileLineNumbers "search_and_remove_dead_bodiesV2.sqf";


the script:
Code:

//===================================================================================================================
//     Script for removing dead soldiers and put their gear on the ground
//    by BS 2013
//
//    Usage: nul = ["name", radius, time ] execVM "search_and_remove_dead_bodiesV2.sqf";
//    Usage: nul = [this, radius, time ] execVM "search_and_remove_dead_bodiesV2.sqf";
//    radius in m
//    time in minutes
//    Example: nul = [this, 1000, 5 ] execVM "search_and_remove_dead_bodiesV2.sqf";
//
//    You should place this line into your Init.sqf : compile preprocessFileLineNumbers "search_and_remove_dead_bodiesV2.sqf";
//
//     Note:  You may use this script as it is or change it at your convenience.
//    Would be nice seeing a credit note if you'll use this script for your missions.
//
//======================================================================================================================

if (!isServer) exitWith {};
 
private ["_bodies_found","_k","_center_object","_body_counter","_dead_body_counter","_weapon","_weapons","_mags","_w_name","_m_name","_b_name"];
private ["_i","_j","_k","_items","_test_unit","_radius","_interval"];


_center_object = _this select 0;
if (isnil ("_center_object")) exitWith { hint "no Trigger found"; };

_radius = _this select 1;
if (isnil ("_radius")) then
{
 _radius = 500;
};
if ( _radius < 1 ) then
{
    _radius = 100;
};
_interval = _this select 2;
if (isnil ("_interval")) then
{
 _interval = 10;   
};

if ( _interval < 1 ) then
{
    _interval = 1;
};

_interval = _interval * 60;// i.e.: 10 * 60 secs = 600 secs = 10 mins

//hintSilent format ["Time in secs: %1\n", _interval]; sleep 5;

// Init
_bodies_found = [];
_body_counter = 0;
_dead_body_counter = 0;
_weapons = [];
_mags = [];
_w_name = "";
_m_name = "";
_b_name = "";
_mag_bags_to_change = [];


while { _radius > 0 } do // dummy
{
//    hintSilent format ["Search: %1\n"];

    _bodies_found = nearestObjects [ (position _center_object), ["Man"], _radius];
    _body_counter = count _bodies_found;

    _k = 0;
    while { _k < _body_counter } do
    {
        if ( !(alive  (_bodies_found select _k)) ) then
        {
            _test_unit = ( _bodies_found select _k );
            _pos = getPosATL ( _test_unit );

            _items = items _test_unit;
            _weapons = (weapons _test_unit) - _items;
            _mags = magazines _test_unit;

            if ( !( _weapons select 0 == "") ) then
            {
                _weapon = "WeaponHolder" createVehicle _pos;
               
                if ( !( _mags select 0 == "") ) then
                {               
                    for [{_j = 0}, {_j < count _mags}, {_j = _j + 1}] do
                    {               
                        _m_name =  _mags select _j;
                        _weapon addMagazineCargoGlobal [ _m_name, 1];
                    };
                };
               
                for [{_i = 0}, {_i < count _weapons}, {_i = _i + 1}] do
                {
                    _w_name =  _weapons select _i;
                    _weapon addWeaponCargoGlobal [_w_name,1];
                };               
            };
    //---------------------------------------------------------------------------------       
            _b_name = (typeOf (unitBackPack _test_unit));
           
            if ( !( _b_name == "") ) then
            {
                _weapon addBackpackCargoGlobal [ _b_name,1 ];
                _weapon setPos [ _pos select 0, _pos select 1, (_pos select 2 + 0.05)];
                player reveal _weapon;           
            };
    //---------------------------------------------------------------------------------           
            hideBody _test_unit;
            sleep 5;
            deleteVehicle _test_unit;
           
            _dead_body_counter = _dead_body_counter +1;
        };
        _k = _k +1;
    };
//    hintSilent format ["Sleep now: %1\n"];
    sleep _interval;
};
0
Tayuk

Avatar / Picture

Admin
Registered:
Posts: 455
Reply with quote  #2 
Thanks for this BS, I will put this my current mission and see how it pans out, but to have the gear left there is great. (was a bit annoying to be just about to grab a dead guys gun, for him to sink away just before I got it, lol)
0
BRS

Captain
Registered:
Posts: 197
Reply with quote  #3 
Sorry, I build in some bugs while changing the script using time interval. The 'best thing' was that I forgot the sleep command itself. Shame on me!
So I copy and paste the new version into the above code box and colored the changes.
The old version will run, but without the delay..
0
Tayuk

Avatar / Picture

Admin
Registered:
Posts: 455
Reply with quote  #4 
Finally got round to testing this and it works a treat, nice work mate
0
BRS

Captain
Registered:
Posts: 197
Reply with quote  #5 
thx tay-uk, there are more to come.
0
Gunter Severloh

Avatar / Picture

Admin
Registered:
Posts: 2,749
Reply with quote  #6 
Script is now hosted on the MR, readme included, link for download added to the first post.
__________________
0
Previous Topic | Next Topic
Print
Reply

Quick Navigation:

Easily create a Forum Website with Website Toolbox.