Home   Help Search Login Register  

Author Topic: An old snYpir script doesn't work  (Read 1335 times)

0 Members and 1 Guest are viewing this topic.

GothicOne

  • Guest
An old snYpir script doesn't work
« on: 31 Aug 2002, 14:58:42 »
Page 251 of the .pdf "OFP mission editor uber reference guide" compiled by Merciless Creations there is a script written by snYpir entitled "has that body been hidden?".  The script checks whether a dead body has been hidden or not.  
hidden = yes (not detected by patroller) so no alarm
hidden = no (detected by patroller) so causes alarm.  

[patroller, buddy, 10] exec isdead.sqs

Here is the code.

; start
_patroller = _this select 0
_buddy = _this select 1
_closedis = _this select 2

#loop

? NOT(alive _buddy) AND NOT(alive _patroller) : goto "end"

? alarmraised : goto "end"

?NOT(alive _buddy) AND (_patroller Distance _aa1) < _closedis AND (GetPos _buddy select 2) > 0.5 : goto "alarm"

~1

goto "loop"

#alarm

alarmRaised = true;

#end

I have a trigger with "alarmRaised" in the condition field and anonymous sound Play Alarm selected in the effects.  

The script looks logical to me but doesn't work at all.  

Any thoughts or have another solution to checking if dead body is found or not if it is hidden.

Offline snYpir

  • BIS Team
  • ****
  • OFPEC Jedi Master
    • OFPEC
Re:An old snYpir script doesn't work
« Reply #1 on: 31 Aug 2002, 15:43:27 »
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:

Code: [Select]
;-----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:

Quote
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 ;)
Bohemia Interactive Simulations

GothicOne

  • Guest
Re:An old snYpir script doesn't work
« Reply #2 on: 01 Sep 2002, 04:09:08 »
Ah ha!  The original script was missing the negative number -0.5.  No wonder that line wasn't completing.  

It works now!

Cheers