Home   Help Search Login Register  

Author Topic: Detecting dead bodies  (Read 2122 times)

0 Members and 1 Guest are viewing this topic.

Offline Rellikki

  • Members
  • *
  • Die-hard OFP player
Detecting dead bodies
« on: 08 Apr 2008, 23:18:27 »
I wanted to make a script, which would make it possible for enemy patrols to detect dead bodies and then raise an alarm. I have, however, no idea how would that work and where do I need to start from. :confused: I was wondering if any of you scripting experts could give me a hand?
I want the script to be triggered, when either of the guards actually knows about the dead body and are within a certain distance to it... let's say... 20m. The script shouldn't trigger if the dead body is an enemy. I've also set up a simple alarm trigger on the map, which activates when the player has been detected. No problems with that, but I want the script to stop when that alarm trigger activates.
Thanks.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Detecting dead bodies
« Reply #1 on: 09 Apr 2008, 01:46:56 »
Sadly i have no direct solution at hand but maybe a hint in one direction could lead you further.

Use the nearTargets command to get a list of all targets, check if the searching unit knowsabout each of the targets, if he knows enough, check side and alive status. Once a dead body has recognized, write it in an array and always check if a detected body is already in the array to avoid alarming twice for the same dead unit.

Offline schuler

  • Contributing Member
  • **
Re: Detecting dead bodies
« Reply #2 on: 09 Apr 2008, 16:05:38 »
hi Rellikki, i know you know your way around scripting but,
you have more then likely looked at this ,,, if not it might help in coding. just checking with ya's  ;)
http://www.ofpec.com/ed_depot/index.php?action=details&id=419&page=1&cat=xyz
cheers Schuler
Semper Fi

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Detecting dead bodies
« Reply #3 on: 09 Apr 2008, 16:55:11 »
Good point schuler, in fact I did enjoy a lot that pretty good Taurus implementation. About nearTargets, I assume dead bodies will never be considered targets by any side.

Offline Rellikki

  • Members
  • *
  • Die-hard OFP player
Re: Detecting dead bodies
« Reply #4 on: 09 Apr 2008, 22:51:05 »
Thanks for the tips, but my scripting skills are pretty limited and I've never used those commands which you suggested, so I don't know how would I need to set up that script.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Detecting dead bodies
« Reply #5 on: 09 Apr 2008, 23:51:35 »
Wrote something which i thought it might work but somewhere is a bug inside it.

Code: [Select]
private ["_unit", "_radius", "_deadlist", "_list", "_x"];

_unit = _this select 0;
_radius = _this select 1;
_deadlist = [];

while {alive _unit} do
{
sleep 1;
_list = nearestobjects [position _unit, ["Man"], _radius];
{
if ((side _x) == (side _unit)) then
{
if (_unit == _x) exitwith {};
if ((_unit knowsabout _x) > 1.5) then
{
if (! alive _x) then
{
if (! (_x in _deadlist)) then
{
_deadlist = _deadlist + [_x];
hint format ["%1", _deadlist];
sleep 2;
};
};
};
};
}
foreach _list;
};

I guessed this should work but it doesn't. Maybe one of the scripting gods here may lay an eye on it.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Detecting dead bodies
« Reply #6 on: 10 Apr 2008, 09:50:24 »
IMO you're getting a bit carried away there, if you read again what Rellikki wants there is no need for such a complex script lagging your game with nearestObject searches, at least not in this case. :scratch:

This is just a simple example
init.sqf/sqs
Code: [Select]
your_alarm_control_variable = false;
MYTAG_bodyArr = [];

What you need is a killed eventhandler for each friendly:
Code: [Select]
this addEventHandler ["killed",{MYTAG_bodyArr = MYTAG_bodyArr + [this]}]
Then a script running on all the guards (execVM "script.sqf")
Code: [Select]
private ["_i","_unit"];

_i = 0;

while {alive _this && !(your_alarm_control_variable)}
 do {
_unit = MYTAG_bodyArr select _i;
hint format ["%1\n%2",_this knowsAbout _unit,_unit];
if ((_this knowsAbout _unit)>1.5 && (_this distance _unit) <= 20)
   exitWith {your_alarm_control_variable =  true};

_i = _i + 1;
if (_i > count MYTAG_bodyArr) then {_i = 0};
sleep 2;
    };

At least this way I could get the guards to detect a dead friend and raise an alarm.
Execute on group leader or on a single unit.
This starts to suck though the more bodies there are in the body array... :(

Of course a more complex find dead body script would be usefull..
And I'm guessing within few hours a Mando Detect Body is available ;)  :D
« Last Edit: 10 Apr 2008, 10:13:55 by h- »
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: Detecting dead bodies
« Reply #7 on: 10 Apr 2008, 12:04:49 »
*grml*...indeed....way better and far more efficient.  :D

I always forget that there are EH which could be easily used for such things. I just found the problem interesting so i started a little testing about.

Offline h-

  • OFPEC Site
  • Administrator
  • *****
  • Formerly HateR_Kint
    • OFPEC
Re: Detecting dead bodies
« Reply #8 on: 10 Apr 2008, 21:51:47 »
The EH method comes very cumbersome from the mission designer point of view the second you want to go generic with the script so that any side can detect friendly bodies.

In that case a script like yours would probably be handier..
Project MCAR   ---   Northern Fronts   ---   Emitter 3Ditor
INFORMATIVE THREAD TITLES PLEASE. "PLEASE HELP" IS NOT ONE..
Chuck Norris can divide by zero.

Offline Turk

  • Members
  • *
Re: Detecting dead bodies
« Reply #9 on: 22 Oct 2008, 04:24:36 »
Hi,

Can one of you nice chaps do me a working demo of this dead body detection thing, with myke13021 version I can't get it to work, If I place 2 units on the map and kill the first the second doesn't know about him, but when I kill the remaining unit he detects himself as dead! With h-'s version I'm stuck at the very beginning with the your variable here, I've no idea what to put there.

Has always I'd much appreciate it.

Turk.   

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Detecting dead bodies
« Reply #10 on: 11 Jan 2009, 20:53:00 »
Hi,

Has anyone found an ideal solution for this yet?
In this script I can't see how it wouldn't start automatically if you have more than 1 unit in the group.

I searched but found nothing. What I'm looking for also needs to be MP friendly.

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

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Detecting dead bodies
« Reply #11 on: 11 Jan 2009, 22:54:56 »
I don't know about the efficiency of triggers, but how about creating triggers from the killed EH?
try { return true; } finally { return false; }