Jesus, that was like the 2nd script i wrote. There are many reasons why it may not work now, the primary one being the fact that OFP was version 1.0 when I wrote that script (it is now of course at 1.75).
you can try yourself to see if the Z pos of the body is updating correctly.
have a dude named 'deaddude' and kill him as soon as the mission starts. have the following script running:
#loop
hint format["%1",(GetPos deaddude select 2)]
~0.1
goto "loop"
when you bury the dead guy you'll see the Z position of the dude drop down below zero, and this is the basis of the script.
the actual full script is as follows:
;-----SCRIPT STARTS-----
_patroldude = _this select 0
_deaddude = _this select 1
_closedis = _this select 2
;start the loop which will run forever
#loop
;exit condition for the loop - are both _deaddude and _patroldude killed?
? NOT(alive _deaddude) AND NOT(alive _patroldude) : goto "end"
;another exit condition is activated here if the alarm has already been raised
? alarmRaised : goto "end"
;is the _deaddude dead, not fully hidden and closer than _closedis from
;_patroldude?
? NOT(alive _deaddude) AND (_deaddude Distance _patroldude) < _closedis AND (GetPos _deaddude select 2) > 0.5 : goto "alarm"
;wait a second
~1
;loop again
goto "loop"
;the alarm has been raised
#alarm
;flip the global "alarmRaised" variable
alarmRaised = true;
;end script
#end
;-----SCRIPT ENDS-----
following is straight out of the snippets section of the old site:
ever wondered how to tell if a body has been hidden or not? i did, so i did some experimenting to see what actuall happens to a body when it is hidden.
suprise, suprise... the body simply drops below ground level. (as it appears to do... so what???)
well, suppose you wanted to know if a body is discovered by an enemy. we are going to do this using a small script, the GetPos function and the Distance function. sorry if u hate scripting, but it is really the only way to do this....
suppose we have 2 enemies, named enemy1 and enemy2. we want to know if enemy1 discovers the dead body of enemy2. if he does, then an alarm will sound. if, however, the player has hidden the body deep enough enemy1 will not be able to detect the dead enemy2 and hence no alarm will be raised.
we will detect the distance below the ground that enemy2 is hidden via the following command:
GetPos enemy2 select 2
if enemy2 is dead and unhidden, the value returned will be close to 0 (by close I mean really close, between -10 cm and +10cm).
as the enemy is hidden, the longer the player hides the body the deeper the enemy will sink. at about -0.5 the body is gone completely (half a meter down)
so, if the other enemy comes close to the dead enemy2 (we'll say 10 meters) and enemy2 is less that half a meter below the ground, an alarm will sound.
we will call this short script "isbodyhidden.sqs". it would be activated by the following call:
[enemy1, enemy2,10] exec "isbodyhidden.sqs"
enemy1 is the enemy on patrol, and enemy2 is the soldier who will be killed and buried. '10' is the distance we will allow enemy1 to come to an unhidden enemy2 before sounding the alarm.
this script uses the global variable "alarmRaised" to control the alarm. the best way to determine if an alarm has been raised is to have a trigger in your mission with a condition field of "alarmRaised". Ensure "alarmRaised = false" BEFORE calling a script such as the one below.
;-----SCRIPT STARTS-----
_patroldude = _this select 0
_deaddude = _this select 1
_closedis = _this select 2
;start the loop which will run forever
#loop
;exit condition for the loop - are both _deaddude and _patroldude killed?
? NOT(alive _deaddude) AND NOT(alive _patroldude) : goto "end"
;another exit condition is activated here if the alarm has already been raised
? alarmRaised : goto "end"
;is the _deaddude dead, not fully hidden and closer than _closedis from
;_patroldude?
? NOT(alive _deaddude) AND (_deaddude Distance _patroldude) < _closedis AND (GetPos _deaddude select 2) > -0.5 : goto "alarm"
;wait a second
~1
;loop again
goto "loop"
;the alarm has been raised
#alarm
;flip the global "alarmRaised" variable
alarmRaised = true;
;end script
#end
;-----SCRIPT ENDS-----
you could call the same script like this:
[enemy2, enemy1,10] exec "isbodyhidden.sqs"
to reverse the soldier being tested for death and the soldier on patrol. if you have more than two guys patrolling, you could insert more tests in the script or just call this script a heap of times
ADVANCED: i have not done it here, but you could write the script so that the detection distance is dependant on the depth of the hidden body.
If you do write a better version of this script plz up it to us and we will post it here. A script like this will add heaps of depth to a black op mission.
hope all this helps