Jump to content
Sign in to follow this  
ConanOfOz

SimpleScan

Recommended Posts

An example has arisen that illustrates what (I believe) is an error in the logic of the Detection criteria of Triggers.  Essentially, a soldier who has just been shot in the head is capable of Activating a Detection condition.

If you think some other soldier is tripping the alarm, create a mission, you West as Sniper, 1 East soldier, 1 Trigger West Detected by East.  Set the East Soldier looking away from you.  Start the mission, and he doesn't know about you.  Shoot him in the head (instant death) and the Trigger still activates.

For those who agree that this is wrong, try my script.

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

;SimpleScan.sqs

;This script makes up for the fact that the OFP Mission Trigger will return a TRUE

;condition for detection even though the 'detecting' unit has just died.

;Requirements...

;init.sqs must set -

;   NeedToScan = False

;   ICU = False

;   KAThreshold = a number between 0 and 4 (recommend 1.0)

;

;Trigger

;   Name - EastPresent

;   Activation - East Present, Repeatedly

;   Condition - This

;

;Trigger

;   Name - Busted

;   Activation - None

;   Condition - ICU (Boolean set by this script)

;   Note - This is the actual 'alarm' per se.  Set your Effect (e.g. sound alarm)

;          or whatever action you wish to take here, or as On Activation, or both

;

;Trigger

;   Name - Detected

;   Activation - West Detected by East, Repeatedly

;   Condition - This

;   On Activation - NeedToScan = True; [] Exec "SimpleScan.sqs"

;   On Deactivation - NeedToScan = False

;   Note - We are using this mainly because we can avoid running our SimpleScan script

;          all the time.  NeedToScan = False will tell this script to exit.  ICU = False

;          will deactivate Trigger "Busted", our true 'alarm' Trigger.

#StartHere

;Get list of potential enemy 'detectors'

;'EastPresent' is a trigger activated by 'East - Present'.

_Enemies = List EastPresent

;Initialise our index pointer

_Index = 0

;Discover size of _Enemies array

_MaxEnemies = Count _Enemies

?_MaxEnemies == 0 :Exit

;Start by assuming there is no true detection

_ThisICU = False

#LivingDetect

;Enemy must have a KnowsAbout (KA) value greater than KAThreshold

;KAThreshold is defined in init.sqs.  Values are 0 - 4 (decimals permitted)

;This enemy must be alive!

;If in ANY case an Enemy has KA > KAThreshold AND is alive, trigger the Busted

_ThisGuy = _Enemies Select _Index

_ThisICU = _ThisICU or (((_ThisGuy KnowsAbout Player) >= KAThreshold) and (Alive _ThisGuy))

;Move to next unit.

_Index = _Index + 1

;If there is a 'next unit', go get him.

?(_Index < _MaxEnemies): Goto "LivingDetect"

;_ThisICU will now be true if ANY of the above iterations was true

ICU = _ThisICU

;If ICU is true, we can wait a few seconds before repeating this script

?!ICU: Goto "DontWait"

~2

#DontWait

;Whether ICU is true or not, we don't need to scan every microsecond.

;4 times per second is ample, so...

~0.25

?NeedToScan : Goto "StartHere"

;If Trigger "Detect" has deactivated and set NeedToScan to false, then we can assume

;that ICU can also be false, and thereby deactivate Trigger "Busted"

ICU = False

<span id='postcolor'>

Important Notes about Trigger Placement

Trigger EastPresent

For an enemy to qualify as a potential "detector", he must be within the area covered by this trigger.  If you don't care where the enemy is, then ensure this trigger encompasses the entire map.

Trigger Detected

For Player to be "detected", Player must be within the area covered by trigger.  If you don't care where the player is, then ensure this trigger encompasses the entire map.

Trigger Busted

The only significance about where you place this trigger is where you want the "source" of the alarm to appear to be.  Therefore, you will probably place this trigger in the middle of an enemy objective/camp/base.

This trigger need not be unique either.  You can have several triggers whose condition is ICU that can all be set off by the Player getting busted.  It's up to you.

Assumptions Made by this Script

It will be obvious to most that this script is designed for a Player on the West side, on his own, who must not be detected by the East.  The result of Trigger Busted activating is entirely up to you and your imagination.

Deactivation

ICU will be set false, and thereby deactivating Trigger Busted, immediately there is no living enemy who is able to detect you.  If you would prefer the "Busted" status to persist for a while, even if the detecting soldier has since died, then change the following two lines...

Find:-

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_ThisICU = _ThisICU or (((_ThisGuy KnowsAbout Player) > KAThreshold) and (Alive _ThisGuy))

<span id='postcolor'>

and change it to...

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">ICU = ICU or (((_ThisGuy KnowsAbout Player) > KAThreshold) and (Alive _ThisGuy))

<span id='postcolor'>

Now find the line...

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">ICU = _ThisICU

<span id='postcolor'>

...and remove it.  You can also remove the preceding comment, and also the line which sets "_ThisICU = False" since both have become redundant.

The code as is will deactivate the Trigger Busted immediately that there is no living soldier detecting you.  With these modifications, once ICU has been set true, it will remain true until the Trigger detected deactivates, which can take quite some time even after no one is around to "detect" you.  I think what actually happens is the trigger retains the highest KA (KnowsAbout) value of all the "detecting" soldiers, and a dead soldier does not remove his effect on this situation.  KA drops at very approximately 1 per 20 seconds.  Further, I think a Trigger's detection threshold is a KA of 1 (or greater).  When you shoot a guy in the head, he's gonna throw a KA of 4.  Even though he's now dead, and no other sodlier is detecting you, it will be something like 60 seconds before the Trigger's "remembered" KA drops below threshold (1?) and deactivates.

*phew* In short, making those two changes will cause a considerable delay between "No one detects you anymore" and deactivation of the alarm.

Closing Comments

This script was tested against v1.42, and seems to follow intended behaviour as far as I can tell.  If you find it doesn't work, I'm happy to try to help and/or fix the problem if I can.

Oh yeah, This script is provided AS IS biggrin.gif

Share this post


Link to post
Share on other sites

Ok, already I've got a change to make.  Find the line

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

?_MaxEnemies == 0: Exit

<span id='postcolor'>

and replace it with...

</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">

?_MaxEnemies == 0: Goto "NoEnemies"

Goto "CarryOn"

#NoEnemies

~1

Goto "StartHere"

#CarryOn

<span id='postcolor'>

It occured to me that if a designer has a trigger Detected with at least part of it's area outside of the area defined by trigger EastPresent, then we might start this script with no one in the _Enemies array.  I believe trying to Select out of an empty array will throw an error, so having _Enemies array empty would have caused an error at the line _ThisGuy = _Enemies Select _Index.

However, having the script exit if _MaxEnemies -- 0 was not the correct response, because then this script would not execute again until trigger Detected deactivated, then Reactivated... and no checking would be done during this time.

About Trigger Placement

This issue reminded of a comment I meant to make about the relative positions of Triggers Detected and EastPresent.  My recommendation is that they are both centred at the same location, and that the radii of EastPresent exceed those of Detected by about 500 metres.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×