Welcome, Guest Friday 18th April 2014, 04:08:24
   Home   Help Search Login Register  

OFPEC Forum

Author Topic: LAGGY Detect Dead Bodies script (ACCEPTED)  (Read 2249 times)
0 Members and 1 Guest are viewing this topic.
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: