Home   Help Search Login Register  

Author Topic: Set a guard to scan horizon  (Read 1147 times)

0 Members and 1 Guest are viewing this topic.

Olle Stolpe

  • Guest
Set a guard to scan horizon
« on: 22 Feb 2005, 15:18:13 »
I've put a guard in a tower, how do I get him to scan horizon?

Offline macguba

  • Former Staff
  • ****
    • macguba's operation flashpoint page
Re:Set a guard to scan horizon
« Reply #1 on: 22 Feb 2005, 16:29:44 »
You'd need to give him a slow looping script with doWatch commands making him watch gamelogics placed in the appropriate places.  Something like:-

#loop
? not (alive loon1) : exit
? enemyDetected : whatever consequences you want; exit
loon1 doWatch gl1
~(random 12)
loon1 doWatch gl2
~(random 12)
goto "loop"

Not guaranteed.   Note that the doWatch command is satisfied if the target object is anywhere in the loon's field of view, including the very edge of it.
Plenty of reviewed ArmA missions for you to play

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Set a guard to scan horizon
« Reply #2 on: 22 Feb 2005, 19:06:23 »
I wrote a sequntial dowatch script that I can shoot to you as soon as I get home (I'm at work on break right not).  Anyway, the script allows you to adjust the increments of the watch direction, the min and max arc (in case you do not want him scaning all the way around a full 360 and it allows you to also do random direction changes (this makes if tougher for the player to "time the scaning" in order to sneak into the base.

Offline Wadmann

  • OFPEC Patron
  • ****
  • I'm the next evolutionary step after a llama!
Re:Set a guard to scan horizon
« Reply #3 on: 23 Feb 2005, 01:01:59 »
@Raptorsaurus

I was just looking for a script such as yours so if you do not post it for all, please send me a copy of your script. Thanks in advance!

                                                             Wadmann
Check out my Camouflage Collection! New items added 31 July 2005.

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Set a guard to scan horizon
« Reply #4 on: 23 Feb 2005, 06:57:08 »
Here is a scan script.  I will also make a demo mission and put it in the editor depot.  This version is specialized for units in guard towers, it resets their positions because as guys in towers turn to look in different directions they will start to get out of place and eventually fall!  I added an explaination of how to use the script at the begining.  Also this script requires my RandNum function which is also attached.

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Set a guard to scan horizon
« Reply #5 on: 23 Feb 2005, 06:58:43 »
I could not put the RandNum function that goes with that on the same post, here is the RandNum function that goes with the dowatch script.

Here is an example of how to call the dowatch script:

Code: [Select]
[unit, 5, 10, true,[0, 45, 90, 135, 180, 225, 270, 315]] exec "dowatch.sqs"
In this example the unit will watch each direction in the array [0, 45, 90, 135, 180, 225, 270, 315] for a minimum of 5 seconds and a maximum of 10 seconds (random amount of time in this range). Since the 4th parameter is <true> he will NOT watch the listed directions in sequence, he will instead randomly choose a direction from the list to watch.  If instead of the <true> you put <false> in the 4th parameter, then he will follow the sequence in order.  But the time that he watches any direction will still be random in the range of 5 to 10 seconds.  You can make these numbers higher or lower, but the first number must always be less than or equal to the second.  If you want him to watch each direction for the same amount of time without random time, just make the two numbers the same.
« Last Edit: 23 Feb 2005, 07:15:06 by Raptorsaurus »

Olle Stolpe

  • Guest
Re:Set a guard to scan horizon
« Reply #6 on: 23 Feb 2005, 17:02:17 »
Thanks alot guys!

Offline Wadmann

  • OFPEC Patron
  • ****
  • I'm the next evolutionary step after a llama!
Re:Set a guard to scan horizon
« Reply #7 on: 23 Feb 2005, 19:50:03 »
Thanks Raptorsaurus!

My intent was for a guard in a tower so this should work just fine.


                                                         Wadmann  
Check out my Camouflage Collection! New items added 31 July 2005.

Olle Stolpe

  • Guest
Re:Set a guard to scan horizon
« Reply #8 on: 23 Feb 2005, 19:55:28 »
I didn't get the tower script to work though...
My tower was a bit to high I guess...

I'll alter it..

But my soldiers only stood there, and then every few seconds they stepped a little and
continued to look in the same direction.

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Set a guard to scan horizon
« Reply #9 on: 23 Feb 2005, 21:42:06 »
Quote
My tower was a bit to high I guess...
The dowatch script does not care about the height of your tower because at the start of the script it finds the position of your guy regardless of the tower, so if you set him in a 20 m tower (before executing the script) then the script gets that position.  If you put him in a 10 M tower, then it will maintain that position.

Quote
But my soldiers only stood there, and then every few seconds they stepped a little and
continued to look in the same direction.
All I can think of here is that he is "stuck".  If you setPos him a bit too high, then start the script to soon (before he falls to a true standable platform), he may be unable to turn because his feet are above the platform.

Maybe if you can attach your mission.sqm file and I can see what might be wrong with this guy.

Actually, the script could not make him stuck at a height above the platform unless you have the watch time set to zero.  Make sure your minimum watch time is not zero.
« Last Edit: 23 Feb 2005, 21:51:50 by Raptorsaurus »

AK-Chester

  • Guest
Re:Set a guard to scan horizon
« Reply #10 on: 24 Feb 2005, 00:53:48 »
Here's a script I wrote quiet a while ago. Makes a unit move to a tower, get up there and then watch random directions. It'll also send the unit back up there in case the idiot falls down (due to "too much turning"). The unit will still engage enemies, indeed. Works with the default (BIS) towers and with the ones by mapfact.

ak_towerguy.sqs
Code: [Select]
; Script by AK-Chester
; --------------------------------------------------
; Tower already on map (default by BIS)
; [unitName,(object towerID)] exec "ak_towerguy.sqs"
; --------------------------------------------------
; Tower added in editor (editorupdate102 & mapfact)
; [unitName,towerName] exec "ak_towerguy.sqs"
; --------------------------------------------------
; Requires a game logic unit (name: Server)

? !(local Server) : exit

_who = _this select 0
_tower = _this select 1
_tpos = getPos _tower
_tposX = _tpos select 0
_tposY = _tpos select 1
_tdir = getDir _tower
_tdirW = _tdir + 180
_ttype = typeOf _tower
_delay = 0.005
_distance = 0
_height = 0
_toofar = 0
_wait = 0
? (_ttype == "Dum06") || (_ttype == "KEGres_Dum06") : _distance = 2.5; _height = 3; _toofar = 2; _wait = 7; goto "OKAY"
? (_ttype == "Dum08") || (_ttype == "KEGres_Dum08") : _distance = 2; _height = 15; _toofar = 7.5; _wait = 19; goto "OKAY"
? (_ttype == "Dum16") || (_ttype == "KEGres_Tree024") : _distance = 0.5; _height = 4; _toofar = 3.5; _wait = 7.5; _tdir = _tdir - 95; _tdirW = _tdir + 180; goto "OKAY"
? (_ttype == "ViewTower") || (_ttype == "CCC001") : _distance = 3.5; _height = 6; _toofar = 3.5; _wait = 11; goto "OKAY"
? (_ttype == "ViewTower2") || (_ttype == "CCC002") : _distance = 2; _height = 5; _toofar = 2; _wait = 10; goto "OKAY"
? (_ttype == "Brown_Turm") || (_ttype == "Green_Turm") || (_ttype == "Grey_Turm") : _distance = 4; _height = 6; _toofar = 3.5; _wait = 10.5; goto "OKAY"
Server globalChat format ["DEBUG: ak_towerguy.sqs NOT running for %1",_who]
exit

#OKAY
_ladderX = _tposX + (sin _tdirW * _distance)
_ladderY = _tposY + (cos _tdirW * _distance)
? (_ttype == "Dum16") || (_ttype == "KEGres_Tree024") : _tposX = _tposX + (sin _tdir * 1.5); _tposY = _tposY + (cos _tdir * 1.5)
_who setUnitPos "Up"

#START
_who doMove [_ladderX,_ladderY]
~1
@ (unitReady _who)
? !(canStand _who) : exit
_who doMove [_ladderX,_ladderY]
~1
@ (unitReady _who)
_who setFormDir _tdir
~0.25
_who setPos [_ladderX,_ladderY]
_who setDir _tdir
_who action ["LadderUp",_tower]
~_wait
_who setPos [_tposX,_tposY,_height]
_newdir = 0

#LOOP
? !(alive _who) || !(canStand _who) || !(alive _tower) : exit
? (_who distance _tower >= _toofar) : goto "START"
if (_newdir == _tdir) then {_newdir = random 360} else {_newdir = _tdir}
_who setFormDir _newdir
_next = daytime + _delay + ((random 1)/500)
@ (daytime >= _next)
goto "LOOP"

The file below comes with some examples (the one on Desert Island requires the Baracken.pbo and EditorUpdate102.pbo, the other two don't). Maybe it helps.
« Last Edit: 24 Feb 2005, 00:59:22 by AK-Chester »

Offline Blanco

  • Former Staff
  • ****
Re:Set a guard to scan horizon
« Reply #11 on: 24 Feb 2005, 07:17:48 »
This is very good  :)

I always liked your scriptdemo's AKChester, I remember that funny soundtutorial...

Why don't you summit this at in the editor depot?
Good job!

« Last Edit: 24 Feb 2005, 07:18:05 by Blanco »
Search or search or search before you ask.

AK-Chester

  • Guest
Re:Set a guard to scan horizon
« Reply #12 on: 24 Feb 2005, 18:07:19 »
Thanks, Blanco!
:)
Yup, guess you're right. I might as well submit this thingy.

[edit]
Script submitted to the Editors Depot (pending). ;)
[/edit]
« Last Edit: 24 Feb 2005, 21:00:41 by AK-Chester »

Olle Stolpe

  • Guest
Re:Set a guard to scan horizon
« Reply #13 on: 25 Feb 2005, 12:12:32 »
Shouldn't there be an easy way of just sending the order "Scan Horizon?"

Even if these scripts are much cooler.

AK-Chester

  • Guest
Re:Set a guard to scan horizon
« Reply #14 on: 25 Feb 2005, 14:13:55 »
Shouldn't there be an easy way of just sending the order "Scan Horizon?"
Yeah, should be, but there doesn't seem to be a (scripting) command in OFP that does that, at least none I have heard of.