Okay here it goes.
Detect Dead Bodies Script.Actually gives the "Hide Body" action a reason to exist.
In my opinion a must in any infiltration or stealth mission.
It now works with checking the "current" side of a searching unit instead of config.
The dead units side
has to be checked through config, since all dead units become CIVILIAN.
EDIT: Found one problem that is now fixed
If corpse was hidden with hideBody action an error message occurred. Guess bodies that get hidden disappear, so the script had no elements to start the checking.
Code is now changed to consider also AND ! (isNull _deadguy), and it works as it should now.
Example mission updated as well.
Based on eventhandler "killed"
MP compatible - tested on dedi.
JIP behaviour still unknown.
Parameters:
Possibility to check for different combinations of "corpse side" and "finder side".
Possibility to change the "searched" radius around the corpses.
Possibility to choose "awareness level" of the searchers (based on knowsAbout command).
Possibility to limit the search to bodies that are killed by enemy fire, not by collisions or friendly fire.
One last thing I would like to implement, is to put all the "found" corpses in a global array, that can be searched anytime by anyone. Haven't succeeded so far... any ideas?
init.sqf// Set LAGGY_BodyAndFinderCombo as Nil.
LAGGY_BodyAndFinderCombo = Nil;
// Set the wanted search area radius around the units that you want to be found after being killed.
LAGGY_FindBody_searchradius = 50;
// Set awareness level of the "searchers". Number can be 0-4. The lower number the HIGHER awareness.
LAGGY_FindBody_awareness = 0;
// Set the parameter if you want to check ALSO units killed by accidents, falls, colissions etc. Set true or false.
LAGGY_FindBody_checkaccidents = false;
// Set the combinations of "bodyside" and "finderside", and the desired effect. Delete any parts that are unnecessary.
while { true } do
{
if ((LAGGY_BodyAndFinderCombo select 0 == EAST) AND (LAGGY_BodyAndFinderCombo select 1 == EAST)) then
{
hint "OPFOR corpse detected by OPFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == EAST) AND (LAGGY_BodyAndFinderCombo select 1 == WEST)) then
{
hint "OPFOR corpse detected by BLUFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == EAST) AND (LAGGY_BodyAndFinderCombo select 1 == RESISTANCE)) then
{
hint "OPFOR corpse detected by INDEPENDENT unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == EAST) AND (LAGGY_BodyAndFinderCombo select 1 == CIVILIAN)) then
{
hint "OPFOR corpse detected by CIVILIAN unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == WEST) AND (LAGGY_BodyAndFinderCombo select 1 == EAST)) then
{
hint "BLUFOR corpse detected by OPFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == WEST) AND (LAGGY_BodyAndFinderCombo select 1 == WEST)) then
{
hint "BLUFOR corpse detected by BLUFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == WEST) AND (LAGGY_BodyAndFinderCombo select 1 == RESISTANCE)) then
{
hint "BLUFOR corpse detected by INDEPENDENT unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == WEST) AND (LAGGY_BodyAndFinderCombo select 1 == CIVILIAN)) then
{
hint "BLUFOR corpse detected by CIVILIAN unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == RESISTANCE) AND (LAGGY_BodyAndFinderCombo select 1 == EAST)) then
{
hint "INDEPENDENT corpse detected by OPFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == RESISTANCE) AND (LAGGY_BodyAndFinderCombo select 1 == WEST)) then
{
hint "INDEPENDENT corpse detected by BLUFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == RESISTANCE) AND (LAGGY_BodyAndFinderCombo select 1 == RESISTANCE)) then
{
hint "INDEPENDENT corpse detected by INDEPENDENT unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == RESISTANCE) AND (LAGGY_BodyAndFinderCombo select 1 == CIVILIAN)) then
{
hint "INDEPENDENT corpse detected by CIVILIAN unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == CIVILIAN) AND (LAGGY_BodyAndFinderCombo select 1 == EAST)) then
{
hint "CIVILIAN corpse detected by OPFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == CIVILIAN) AND (LAGGY_BodyAndFinderCombo select 1 == WEST)) then
{
hint "CIVILIAN corpse detected by BLUFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == CIVILIAN) AND (LAGGY_BodyAndFinderCombo select 1 == RESISTANCE)) then
{
hint "CIVILIAN corpse detected by INDEPENDENT unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == CIVILIAN) AND (LAGGY_BodyAndFinderCombo select 1 == CIVILIAN)) then
{
hint "CIVILIAN corpse detected by CIVILIAN unit";
};
sleep 0.1;
};
Eventhandler "killed" - FindBody.sqf_deadguy = _this select 0;
_killer = _this select 1;
_numsidedeadguy = getNumber (configFile >> "CfgVehicles" >> typeOf _deadguy >> "side");
_deadguyside = [EAST,WEST,RESISTANCE,CIVILIAN] select _numsidedeadguy;
_killerside = side _killer;
sleep 1;
while { (_deadguyside != _killerside AND ! (alive _deadguy) AND ! (isNull _deadguy)) OR (LAGGY_FindBody_checkaccidents AND ! (alive _deadguy) AND ! (isNull _deadguy)) } do
{
_finders = nearestObjects [vehicle _deadguy, ["AllVehicles"], LAGGY_FindBody_searchradius];
if (count _finders > 1) then
{
{
if (_x != vehicle _deadguy AND (alive _x)) then
{
if ((_x knowsAbout vehicle _deadguy > 0) AND (_x knowsAbout vehicle _deadguy >= LAGGY_FindBody_awareness)) then
{
_searcherside = side _x; LAGGY_BodyAndFinderCombo = [_deadguyside,_searcherside]; publicVariable "LAGGY_BodyAndFinderCombo"; sleep 5;
};
};
} forEach _finders;
};
sleep 2;
};
Mission Example Included
Thanks to Mandoble, Worldeater, I0N0s and everyone else for your help so far.
Laggy