Welcome, Guest Saturday 19th April 2014, 05:20:52
   Home   Help Search Login Register  

OFPEC Forum

Author Topic: LAGGY Detect Dead Bodies script (ACCEPTED)  (Read 2255 times)
0 Members and 1 Guest are viewing this topic.
laggy
*
Offline Offline


"Behold a pale horse"


« on: 10 Feb 2009, 22:17:57 »

Detect Dead Bodies script by LAGGY v 0.9

Actually gives the "Hide Body" action a reason to exist.
In my opinion a must in any infiltration or stealth mission.

This is a script that can recognize when a dead unit from a certain side or with a certain unitName is found by someone from a certain side, group or with a certain name.
The parameters are important. Through those you can customize the script for your mission purposes and set global effects if the conditions are met. Read the init.sqf and its instructions.

Based on eventhandler "killed"
Should be MP compatible - tested on dedi.
JIP behaviour still unknown.

Unless someone spots bugs or can suggest improvements, I concider this to be ready for submission.


IMPORTANT CHANGES in this version:

-Works also on vehicles like cars etc.
-Included an array called "LAGGY_FoundBodiesList" that contains all units (having the EH) that have been killed AND found under the set script conditions.
-Included the possibility of "Crucial Bodies", which means that you can check if specified units have been killed and found (based on unitName).
-Included the possibility of "Crucial Finders", which means that you can check if specified units have found any of the bodies (based on side,group and unitName).
-Included the possibility of "Crucial Bodies found by Crucial Finders", which means that you can check if the two are combined... defined Body found by defind Finder.
-Structured the init.sqf a little better.
-Updated example mission to be more informative and pedagogical.


Implementation: unit addEventHandler ["killed",{_this execVM "FindBody.sqf"}]


Options and Parameters:

All EH units are when killed and found put in an array that can be called.
An array to include specified units to be killed and found with specified effects.
An array to include specified units that might find bodies and with specified effects.
Check if the specified bodies are found by specified finders and with specified effects.
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.


KNOWN ISSUES:

The dead units side still has to be checked through config, since all dead units become CIVILIAN. Not much I can do about that.
This means that if you change the side somehow on a unit having this eventhandler, when it dies the "original config side" will be active as side of dead unit.
This is a minor issue I think. In those rare occasions, just name the unit and include his name in the array LAGGY_CrucialBodies. He will then be treated as special (see init.sqf).
The array LAGGY_CrucialFinders can help too, as well as putting LAGGY_FindBody_checkaccidents to true.
Just make sure his "side change" doesn't conflict with other interests in your mission.


DISCLAIMER: Use at your own risk, you know the drill.

Hope you find it useful.

Laggy

OFPEC DOWNLOAD

* Detect_Bodies_Script.Intro.rar (5.42 KB - downloaded 86 times.)
« Last Edit: 19 Sep 2011, 10:19:26 by laggy » Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Mandoble
Editors Depot
Administrator
*****
Offline Offline



WWW
« Reply #1 on: 10 Feb 2009, 22:30:45 »

You might try to improve that a bit, as that way (bodyDetected = true) there is no way to know outside that script which unit or side detected a dead body.

You may also add more parameters to allow destroyed vehicles detection.
Logged

laggy
*
Offline Offline


"Behold a pale horse"


« Reply #2 on: 10 Feb 2009, 22:35:00 »

Will do for sure,

Was mainly concerned if this script would be "tough" to run on many units in heavily populated areas.
Read somewhere that checking nearestObjects was quite demanding for your PC.
The possibility to check side of killed unit would also be great.
Do dead units have a side, for a short while before they join grpNull?

Another question is if checking for i.e "soldierWB" would work for any BLUFOR soldier models.
Just like "Man" checks for any man model.

Thanks,

Laggy
« Last Edit: 10 Feb 2009, 22:44:51 by laggy » Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Mandoble
Editors Depot
Administrator
*****
Offline Offline



WWW
« Reply #3 on: 11 Feb 2009, 00:00:16 »

dead units are civilian side. Anyway I was meaning to know the side of the unit that detected the dead one. For example, in a MP game you publish the variable indicating that someone detected a dead unit, but then nobody knows which side detected the dead one, for example, to trigger the corresponding alarm, etc. Just as an example, you are in a group which infiltrating an enemy base, your group leader and the leaders of enemy groups use your script, then one of your AI mates detects the corpse of your last victim and the enemy triggers an alarm because everything is depending on a single global variable.

And nearobjects is not quite demanding as long as the selected scanning radious is short.
Logged

laggy
*
Offline Offline


"Behold a pale horse"


« Reply #4 on: 11 Feb 2009, 17:15:54 »

Thanks again.

Edit:

Just tried my new failing eventhandler + trigger solution.
Don't think the above nearestObjects solution is good, since it will care about units that got killed by "accidents", like a car hitting them... not uncommon in ArmA.
With an eventhandler you can exit the script if the unit was not killed by enemies.

In this early draft script I probably made a stupid mistake (or more) but...

Okay, I tried this:

INIT.SQF
Code:
LAGGY_deadCount = 0;

In units init:
this addEventHandler ["killed",{_this execVM "LAGGY_Friend_Kill_Det.sqf"}]
Code:
_unit = _this select 0;

LAGGY_deadCount = LAGGY_deadCount + 1;
publicVariable "LAGGY_deadCount";

_unit SetVehicleVarName format ["LAGGY_deadGuy%1", LAGGY_deadCount];
LAGGY_deadGuysName = vehicleVarName _unit;
publicVariable "LAGGY_deadGuysName";

_trigger = createTrigger ["EmptyDetector", position _unit];
_trigger setTriggerActivation ["ANY", "EAST D", false];
_trigger setTriggerArea [50, 50, 0, false];
_trigger setTriggerStatements ["LAGGY_deadGuysName in thislist", "LAGGY_eastAlarm = true; publicVariable ""LAGGY_eastAlarm""", ""];
_trigger setTriggerText "";

LAGGY_deadGuysName = Null;
publicVariable "LAGGY_deadGuysName";


It doesn't work, even though I get no error message.

Mu humble guess is that I don't understand how to put the "unitname" of the detected unit in the trigger correctly. Don't even know if this is a dead end solution.

The eventhandler is executed correctly, cause I have checked it with other solutions. An editor placed trigger now reacts to: LAGGY_eastAlarm and an OPFOR unit is "finding" the dead body.

Laggy
« Last Edit: 12 Feb 2009, 00:02:34 by laggy » Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Mandoble
Editors Depot
Administrator
*****
Offline Offline



WWW
« Reply #5 on: 12 Feb 2009, 00:05:02 »

Well, if a patrol discovers a corpse, might be the death cause would be of little importance (they will not proceed with an on-the-fly autopsy  Tongue ).
Logged

laggy
*
Offline Offline


"Behold a pale horse"


« Reply #6 on: 12 Feb 2009, 00:15:05 »

HaHa!!!  Smiley

I guess you are right... Hm...
So do you think the nearestObjects solution would be better?
What I really was after with the trigger workaround was to detect the "side" of the unit before it was killed.
The eventhandler + trigger could possibly do that, if you dynamically change the triggers "detected by" depending on which eventhandler type you put in the init + the chance to exit if killed by friendlyFire.
« Last Edit: 12 Feb 2009, 00:19:05 by laggy » Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Mandoble
Editors Depot
Administrator
*****
Offline Offline



WWW
« Reply #7 on: 12 Feb 2009, 00:40:39 »

For standard BIS missions probably you can detect the side of the corpse checking the typeOf, might be even with isKindOf:
Code:
if (_corpse isKindOf "SoldierWB") then {WEST SIDE};
Logged

i0n0s
Moderator
*****
Offline Offline



« Reply #8 on: 12 Feb 2009, 01:00:57 »

You can read the side from the config:
Code:
getNumber(configFile >> "CfgVehicles" >> typeOf _unit  >> "side")
1 = west, 0 = east, 2 = resistance
« Last Edit: 12 Feb 2009, 02:09:20 by i0n0s » Logged
laggy
*
Offline Offline


"Behold a pale horse"


« Reply #9 on: 12 Feb 2009, 01:45:35 »

Thanks all,

Think I might have found another good and "PC powersaving" solution.  Cheesy Cheesy Cheesy
Looks very promising in editor.

Back tomorrow with update.

Laggy

EDIT:

Okay here it goes...

To save your PC some headache, I decided to go with an eventhandler "killed" to avoid running the script on all units that "might" find the body.

Instead I switched the role of _x so that the dead units body now checks for "finders" nearby.
The script checks for "same sided" units finding the dead body. BLUFOR looking for dead BLUFOR etc.

I also tried to avoid the script kicking in if the unit was not killed by enemy fire. I know this can be enhanced with maybe different parameters... checking sides finding other sides etc. This script is really easy to use though. My main worry is if it will have problems in Multiplayer.

In any units init or other wanted way:

this addEventHandler ["killed",{_this execVM "DetectFriendlyBody.sqf"}]

Code:
_deadguy = _this select 0;
_killer = _this select 1;
_deadguyside = getNumber (configFile >> "CfgVehicles" >> typeOf _deadguy  >> "side");
_killerside = getNumber (configFile >> "CfgVehicles" >> typeOf _killer  >> "side");

while { _deadguyside != _killerside } do
{
_finders = nearestObjects [vehicle _deadguy, ["AllVehicles"], 100];
   if (count _finders > 1) then
   {
      {
         if (_x != vehicle _deadguy) then
         {
            if ((_x knowsAbout vehicle _deadguy > 1) AND (getNumber (configFile >> "CfgVehicles" >> typeOf _x  >> "side") == _deadguyside)) then
            {
               FriendlyBodyDetected = true; publicVariable "FriendlyBodyDetected"
            };
         };
      } forEach _finders;
   };
sleep 2;
};


What do you think?

Laggy
« Last Edit: 12 Feb 2009, 11:41:36 by laggy » Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Mandoble
Editors Depot
Administrator
*****
Offline Offline



WWW
« Reply #10 on: 12 Feb 2009, 11:30:40 »

The script is still not indicating detecting side or detected side.
Code:
call compile format ["FriendlyBodyDetected%1 = true", _deadguyside];
publicVariable format ["FriendlyBodyDetected%1", _deadguyside];
Logged

laggy
*
Offline Offline


"Behold a pale horse"


« Reply #11 on: 12 Feb 2009, 11:46:51 »

Okay guys... I think I have something special. Either I'm ignorant or clever  Tongue

I have this eventhandler "killed".

Code:
_deadguy = _this select 0;
_killer = _this select 1;
_deadguyside = getNumber (configFile >> "CfgVehicles" >> typeOf _deadguy  >> "side");
_killerside = getNumber (configFile >> "CfgVehicles" >> typeOf _killer  >> "side");

while { _deadguyside != _killerside } 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 = getNumber (configFile >> "CfgVehicles" >> typeOf _x  >> "side"); call compile format ["LAGGY_BodySide%1 = true", _deadguyside]; call compile format ["LAGGY_FinderSide%1 = true", _searcherside]; LAGGY_BodyAndFinderCombo = call compile format ["[LAGGY_BodySide%1,LAGGY_FinderSide%2]",_deadguyside,_searcherside]; publicVariable "LAGGY_BodyAndFinderCombo";
            };
         };
      } forEach _finders;
   };
sleep 2;
};

I then have this quite extensive init.sqf to check ALL possible bodySide/finderSide combinations.
You can also set parameters regarding radius and awareness.

Code:
// 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 combinations of "bodyside" and "finderside", and the desired effect.


while { true } do
{
            if (LAGGY_BodySide0 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide0 in LAGGY_BodyAndFinderCombo) then
            {
               hint "An OPFOR body was found by OPFOR"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide0 = false; LAGGY_FinderSide0 = false
    };
            if (LAGGY_BodySide0 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide1 in LAGGY_BodyAndFinderCombo) then
            {
               hint "An OPFOR body was found by BLUFOR"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide0 = false; LAGGY_FinderSide1 = false
    };
            if (LAGGY_BodySide0 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide2 in LAGGY_BodyAndFinderCombo) then
            {
               hint "An OPFOR body was found by INDEPENDENT"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide0 = false; LAGGY_FinderSide2 = false
    };
            if (LAGGY_BodySide0 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide3 in LAGGY_BodyAndFinderCombo) then
            {
               hint "An OPFOR body was found by CIVILIAN"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide0 = false; LAGGY_FinderSide3 = false
    };
            if (LAGGY_BodySide1 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide0 in LAGGY_BodyAndFinderCombo) then
            {
               hint "A BLUFOR body was found by OPFOR"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide1 = false; LAGGY_FinderSide0 = false
    };
            if (LAGGY_BodySide1 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide1 in LAGGY_BodyAndFinderCombo) then
            {
               hint "A BLUFOR body was found by BLUFOR"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide1 = false; LAGGY_FinderSide1 = false
    };
            if (LAGGY_BodySide1 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide2 in LAGGY_BodyAndFinderCombo) then
            {
               hint "A BLUFOR body was found by INDEPENDENT"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide1 = false; LAGGY_FinderSide2 = false
    };
            if (LAGGY_BodySide1 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide3 in LAGGY_BodyAndFinderCombo) then
            {
               hint "A BLUFOR body was found by CIVILIAN"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide1 = false; LAGGY_FinderSide3 = false
    };
            if (LAGGY_BodySide2 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide0 in LAGGY_BodyAndFinderCombo) then
            {
               hint "An INDEPENDENT body was found by OPFOR"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide2 = false; LAGGY_FinderSide0 = false
    };
            if (LAGGY_BodySide2 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide1 in LAGGY_BodyAndFinderCombo) then
            {
               hint "An INDEPENDENT body was found by BLUFOR"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide2 = false; LAGGY_FinderSide1 = false
    };
            if (LAGGY_BodySide2 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide2 in LAGGY_BodyAndFinderCombo) then
            {
               hint "An INDEPENDENT body was found by INDEPENDENT"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide2 = false; LAGGY_FinderSide2 = false
    };
            if (LAGGY_BodySide2 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide3 in LAGGY_BodyAndFinderCombo) then
            {
               hint "An INDEPENDENT body was found by CIVILIAN"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide2 = false; LAGGY_FinderSide3 = false
    };
            if (LAGGY_BodySide3 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide0 in LAGGY_BodyAndFinderCombo) then
            {
               hint "A CIVILIAN body was found by OPFOR"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide3 = false; LAGGY_FinderSide0 = false
    };
            if (LAGGY_BodySide3 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide1 in LAGGY_BodyAndFinderCombo) then
            {
               hint "A CIVILIAN body was found by BLUFOR"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide3 = false; LAGGY_FinderSide1 = false
    };
            if (LAGGY_BodySide3 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide2 in LAGGY_BodyAndFinderCombo) then
            {
               hint "A CIVILIAN body was found by INDEPENDENT"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide3 = false; LAGGY_FinderSide2 = false
    };
            if (LAGGY_BodySide3 in LAGGY_BodyAndFinderCombo AND LAGGY_FinderSide3 in LAGGY_BodyAndFinderCombo) then
            {
               hint "A CIVILIAN body was found by CIVILIAN"; LAGGY_BodyAndFinderCombo = Nil; LAGGY_BodySide3 = false; LAGGY_FinderSide3 = false
    };
sleep 0.1;
};

Longing for feedback.
Thanks Mandoble, I0N0S and Worldeater for all the help.

Laggy
« Last Edit: 14 Feb 2009, 15:07:12 by laggy » Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Mandoble
Editors Depot
Administrator
*****
Offline Offline



WWW
« Reply #12 on: 14 Feb 2009, 00:20:19 »

Still not sure about the killed EH. EHs are supposed to be persistent, so, after respawn, the EH is still there and then the respawned unit is killed again but the while of the previous EH is still active and now you execute a new one. So probably you will need a different way to exit that loop instead of just while { _deadguyside != _killerside }, might be:
Code:
while { (_deadguyside != _killerside) && (!alive _deadguy) }  do

Also, once someone detects a dead guy, the script will keep publishing the global all the time while the finder is close to the dead guy and knows something about him. So, might be a good idea to add a long sleep just after _searcherside = blah blah blah. Or wait there until the finder doesnt know anything about the dead guy, or the fider is killer or the dead guy respawns.
Logged

laggy
*
Offline Offline


"Behold a pale horse"


« Reply #13 on: 14 Feb 2009, 00:26:39 »

Thanks Mandoble,

Will definetly look into that tomorrow.
Too tired and maybe too tipsy to script right now. Friday night after all.
Thanks for all the feedback so far.

EDIT:
1. How do you detect respawns? Player respawns I presume?
2. Where and how would the "sleep" function affect my Eventhandler script in a "PC_PowerSavingWay"?

What I'm looking for is a script that detects if "effectWanted" combinations are "true".
The init.sqf running on a ~ 0.1 loop shouldn't be that demanding on your system. Right?

Laggy
« Last Edit: 14 Feb 2009, 02:19:07 by laggy » Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Mandoble
Editors Depot
Administrator
*****
Offline Offline



WWW
« Reply #14 on: 14 Feb 2009, 09:34:16 »

And a note, as this is unreadable:
Code:
_searcherside = getNumber (configFile >> "CfgVehicles" >> typeOf _x  >> "side"); call compile format ["LAGGY_BodySide%1 = true", _deadguyside]; call compile format ["LAGGY_FinderSide%1 = true", _searcherside]; LAGGY_BodyAndFinderCombo = call compile format ["[LAGGY_BodySide%1,LAGGY_FinderSide%2]",_deadguyside,_searcherside]; publicVariable "LAGGY_BodyAndFinderCombo";

Code:
_searcherside = getNumber (configFile >> "CfgVehicles" >> typeOf _x  >> "side");
call compile format ["LAGGY_BodyAndFinderCombo = [%1, %2]",  _deadguyside,_searcherside];
publicVariable "LAGGY_BodyAndFinderCombo";

So, what you have inside LAGGY_BodyAndFinderCombo is, for example ["WEST", "EAST"] or ["GUER", "CIV]";
Logged

laggy
*
Offline Offline


"Behold a pale horse"


« Reply #15 on: 14 Feb 2009, 13:34:26 »

Okay.. I see  Embarrassed

But in this case it would be ["0","1"] if _deadguyside == east and _searcherside == west... right?

How do I check for ["0","1"] in the checking script?

Just:

Like this: 0 in LAGGY_BodyAndFinderCombo AND 1 in LAGGY_BodyAndFinderCombo?
Or this: LAGGY_BodyAndFinderCombo == ["0","1"]?

Thanks again.
Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Mandoble
Editors Depot
Administrator
*****
Offline Offline



WWW
« Reply #16 on: 14 Feb 2009, 14:04:04 »

It is not "0" "1" but "WEST", "CIV", "EAST" or "GUER".

Code:
if ((LAGGY_BodyAndFinderCombo select 0) == "EAST") &&
   ((LAGGY_BodyAndFinderCombo select 1) == "WEST")) then
{
   hint "EAST corpse detected by WEST unit";
};
Logged

laggy
*
Offline Offline


"Behold a pale horse"


« Reply #17 on: 14 Feb 2009, 14:46:31 »

Here we go again  Scratch Chin

I have to stick with the "0" instead of "EAST", because it reduces the script complexity.
_deadguyside != _killerside is easier than combining multiple variations of numbers and strings.

_deadguyside = getNumber (configFile >> "CfgVehicles" >> typeOf _deadguy  >> "side");

This has to be used since that is the only way to check the "side" of a dead unit a.f.a.i.k.

Changes:

Added ! (alive _deadguy) as condition in While loop. Hopefully helps for respawn issues.
Increased length of sleep to avoid massive amounts of messages being sent continously.
Redid the whole init.sqf.

My worries is how this would risk to fail in MP with all the different messages being sent, quite rapidly.
Could there be a weak link in MP terms that can be fixed?
Would it help if i lengthened the loop in the eventhandler and shortened the loop in init.sqf?


This is the latest solution:

Eventhandler "killed"

Code:
_deadguy = _this select 0;
_killer = _this select 1;
_deadguyside = getNumber (configFile >> "CfgVehicles" >> typeOf _deadguy  >> "side");
_killerside = getNumber (configFile >> "CfgVehicles" >> typeOf _killer  >> "side");

while { _deadguyside != _killerside AND ! (alive _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 = getNumber (configFile >> "CfgVehicles" >> typeOf _x  >> "side"); call compile format ["LAGGY_BodyAndFinderCombo = [%1, %2]",  _deadguyside,_searcherside]; publicVariable "LAGGY_BodyAndFinderCombo"; sleep 5;
            };
         };
      } forEach _finders;
   };
sleep 2;
};

Init.SQF

Code:
// 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 combinations of "bodyside" and "finderside", and the desired effect. Delete any parts that are unnecessary.


while { true } do
{
if ((LAGGY_BodyAndFinderCombo select 0 == 0) AND (LAGGY_BodyAndFinderCombo select 1 == 0)) then
{
   hint "OPFOR corpse detected by OPFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 0) AND (LAGGY_BodyAndFinderCombo select 1 == 1)) then
{
   hint "OPFOR corpse detected by BLUFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 0) AND (LAGGY_BodyAndFinderCombo select 1 == 2)) then
{
   hint "OPFOR corpse detected by INDEPENDENT unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 0) AND (LAGGY_BodyAndFinderCombo select 1 == 3)) then
{
   hint "OPFOR corpse detected by CIVILIAN unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 1) AND (LAGGY_BodyAndFinderCombo select 1 == 0)) then
{
   hint "BLUFOR corpse detected by OPFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 1) AND (LAGGY_BodyAndFinderCombo select 1 == 1)) then
{
   hint "BLUFOR corpse detected by BLUFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 1) AND (LAGGY_BodyAndFinderCombo select 1 == 2)) then
{
   hint "BLUFOR corpse detected by INDEPENDENT unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 1) AND (LAGGY_BodyAndFinderCombo select 1 == 3)) then
{
   hint "BLUFOR corpse detected by CIVILIAN unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 2) AND (LAGGY_BodyAndFinderCombo select 1 == 0)) then
{
   hint "INDEPENDENT corpse detected by OPFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 2) AND (LAGGY_BodyAndFinderCombo select 1 == 1)) then
{
   hint "INDEPENDENT corpse detected by BLUFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 2) AND (LAGGY_BodyAndFinderCombo select 1 == 2)) then
{
   hint "INDEPENDENT corpse detected by INDEPENDENT unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 2) AND (LAGGY_BodyAndFinderCombo select 1 == 3)) then
{
   hint "INDEPENDENT corpse detected by CIVILIAN unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 3) AND (LAGGY_BodyAndFinderCombo select 1 == 0)) then
{
   hint "CIVILIAN corpse detected by OPFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 3) AND (LAGGY_BodyAndFinderCombo select 1 == 1)) then
{
   hint "CIVILIAN corpse detected by BLUFOR unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 3) AND (LAGGY_BodyAndFinderCombo select 1 == 2)) then
{
   hint "CIVILIAN corpse detected by INDEPENDENT unit";
};
if ((LAGGY_BodyAndFinderCombo select 0 == 3) AND (LAGGY_BodyAndFinderCombo select 1 == 3)) then
{
   hint "CIVILIAN corpse detected by CIVILIAN unit";
};
sleep 0.1;
};

« Last Edit: 14 Feb 2009, 15:23:56 by laggy » Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Mandoble
Editors Depot
Administrator
*****
Offline Offline



WWW
« Reply #18 on: 14 Feb 2009, 14:49:21 »

I did miss the detail that you are getting the side from config as a number.
Logged

laggy
*
Offline Offline


"Behold a pale horse"


« Reply #19 on: 14 Feb 2009, 14:58:35 »

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  Embarrassed 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
Code:
// 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
Code:
_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  Cheesy

Thanks to Mandoble, Worldeater, I0N0s and everyone else for your help so far.

Laggy
« Last Edit: 22 Mar 2009, 16:07:14 by laggy » Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
laggy
*
Offline Offline


"Behold a pale horse"


« Reply #20 on: 22 Mar 2009, 16:06:43 »

Everything updated in first post, should be done  Scratch Chin
« Last Edit: 22 Mar 2009, 16:16:48 by laggy » Logged

And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.
Pages: 1 2 [All]   Go Up
  Send this topicPrint  
 
Jump to: