Jump to content
Sign in to follow this  
[aps]gnat

Scan horizon

Recommended Posts

Found a couple of threads on the issue but none seem to provide a proper answer.

Anyone found the solution? sad_o.gif

I find it hard to believe this "Scan Horizon" command to AI cant be executed via the ACTION command ..... seems just about everything else can !!! rock.gif

Worst case ... I'd be interested in a script that simulates it ... BUT allows AI to engage enmy .... not just force them into a spin forever. (... for an M2 gunner ...)

Cheers.

Share this post


Link to post
Share on other sites

You'll find that many commands that are on the menu cannot be executed using the action command - like RELOAD crazy_o.gifcrazy_o.gif

For Scan Horizon, you can do it with a script, but you would have to figure out a way to make them stop.

Here is a function that emulates the 'Watch Direction' you can give yo your soldier int he game. It could be used to make a scan horizon script.

http://www.ofpec.com/editors/funcref.php?letter=W#WatchDirection

Share this post


Link to post
Share on other sites

thanks toad ...... real shame about the missing commands sad_o.gif

I'll use your function and see if I can add some scriptin to get these M2's to intelligently scan and engage ...

Cheers!

Share this post


Link to post
Share on other sites

the combination works surprisingly well !

using toads 'Watch Direction' + this script.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0

_wmax = _this select 1

_unit SetCombatMode "RED"

_unit SetBehaviour "COMBAT"

#A

_ww = random _wmax

~ _ww

_wd = random 360

[units _unit, _wd] call WatchDirection

goto "A"

Call it in a units INIT field like this. (Like M2 MG)

[this, 12] exec "scan.sqs"

>12< is the max random time (secs) the unit will wait between changing to face a new random direction.

Doesnt effect them engaging enmy ..... they may flinch for a fraction of a sec when the script issues a new direction but they immediately re-engage any existing targets.

Hint: For M2 static MG's anyway .... make the skill higher and up the rank ..... they are more likely to engage targets.

Share this post


Link to post
Share on other sites

smile_o.gif well ... I would consider those nice addon's ... cept its for an MP missions and I dont control the Server addons ....

Thanks anyways unnamed.

Share this post


Link to post
Share on other sites

No worries, thats why I mentioned it. Addons can be a double edged sword in MP smile_o.gif

Share this post


Link to post
Share on other sites

ooops!

Forgot a;

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? _unit !alive : exit

inside the "A" loop for tidyup purposes .....

.

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_unit = _this select 0

_wmax = _this select 1

_unit SetCombatMode "RED"

_unit SetBehaviour "COMBAT"

#A

?!alive _unit : exit

_ww = random _wmax

~ _ww

_wd = random 360

[units _unit, _wd] call WatchDirection

goto "A"

smile_o.gif

.

Share this post


Link to post
Share on other sites

You do realize there is a scan horizon feature within the squad command. Just select a man from your squad then go to either Target or Engage (can't remember which one) and it should have an option, scan horizon.

Share this post


Link to post
Share on other sites

But do you realize that he knows that?

Quote[/b] ] find it hard to believe this "Scan Horizon" command to AI cant be executed via the ACTION command ..... seems just about everything else can !!!

He wants to make lookout ai scan horizon that are not in his group.

Share this post


Link to post
Share on other sites

It's hard to believe that there isn't a way to execute all of the squad commands through an action in a unit's init line...hope someone eventually figures it out. sad_o.gif

Share this post


Link to post
Share on other sites

FYI: Over at OFPEC there is a thread that lists all of the actions people have figured out. There are quite a few.

Share this post


Link to post
Share on other sites
Cool...I might try this solution for my watchtower lookout. smile_o.gif

I've used this for sentrys in all of my missions. It makes guards *much* more effective. smile_o.gif

Share this post


Link to post
Share on other sites

small problem ... the ALIVE test is only testing M2 gun itself .......... not the soldier who was manning it.

Any idea how to ALIVE test just the soldier manning the M2 ... not the M2 itself ?

"this select 1" or something ?

One side effect is that if you man the MG after you shot the gunner, you and your group is issued Change Facing commands LOL ...

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?!(Alive) gunner m2 : hint "The gunner of the m2 is dead"

Share this post


Link to post
Share on other sites

Thanks Zig!

** All New and Improved AI Scan Horizon script ** smile_o.gif

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; AI Scan Horizon by Gnat

; USE, eg in INIT

; [this, 12] exec "scan.sqs"

; >12< is number of secs between a facing change

; uses toadlife's WatchDirection function: See OFPEC.com

_unit = _this select 0

_wmax = _this select 1

; set the behaviour (your choice, manual)

_unit SetCombatMode "RED"

_unit SetBehaviour "COMBAT"

_unitX = _unit

; is there a gunner in the object ... then select just him.

?alive(gunner _unit) :  _unitX = (gunner _unit)

; if this is not a "man" and there is no gunner ..... exit

?("Man" counttype [_unit] != 1) AND (!alive(gunner _unit)) :  exit

; main loop ... exit when the man/gunner dies

#A

?!alive _unitX : exit

_ww = random _wmax

; wait a random time

~ _ww

; Select a random direction

_wd = random 360

[units _unitX, _wd] call WatchDirection

goto "A"

- Now works on AI manned vehicles (with gunners only)

- Also works on men or groups.

One note, script is terminated when the man/gunner dies, if an AI runs up and re-mans a gun (as they do from time to time) the script wont re-initiate. Probably a simple change (prob an @alive) but didnt think it was worth it.

Share this post


Link to post
Share on other sites
Quote[/b] ]One note, script is terminated when the man/gunner dies, if an AI runs up and re-mans a gun (as they do from time to time) the script wont re-initiate. Probably a simple change (prob an @alive) but didnt think it was worth it.

Could always use a get-in eventhandler smile_o.gif

Share this post


Link to post
Share on other sites

neat script, this give me some ideas...  tounge_o.gif

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

_unit = _this select 0

_wmax = _this select 1

_unit SetBehaviour "SAFE"

? !(_unit hasweapon "binocular") : _unit addweapon "binocular"

#A

?!alive _unit : exit

? behaviour _unit != "SAFE" : goto "alarmed"

_ww = random _wmax

~ _ww

_wd = random 360

[units _unit, _wd] call WatchDirection

? behaviour _unit == "SAFE" : _unit selectweapon "binocular"

goto "A"

#alarmed

hint "alaaaaaarm!!!"

;;... whatever you need...

...

exit

Not for AI gunners...

This way the lookout uses his binocular everytime he watches a new direction biggrin_o.gif

Not tested yet, but it should work.

** edited**

thx Zig

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? !(_unit hasweapon 'binocular") : _unit addweapon "binocular"

In the first 'binocular", you have a ', not a ".

So it should be

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? !(_unit hasweapon "binocular") : _unit addweapon "binocular"

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  

×