Jump to content
Sign in to follow this  
domcho

Make AI use binoculars forever and look at different targets

Recommended Posts

Hello everybody. Can someone please tell me how can I do 2 things:

1st - Make AI use binoculars forever with and without having other weapons

2nd - Make AI look at different targets while using the binoculars

I don't remember any OFP campaign missions where an AI would do this. Only binoculars camera vision but that's different. If there was any similar mission I'd extract the pbo files and check. And I am not sure this is really possible. I've searched for quite a while but couldn't find the answer.

What I've tried so far was removing all weapons and then adding the binoculars, disabling AI move, autotarget, target and then using a script with a loop:

_i = 0

#loop1
_i = _i + 1
lead selectWeapon "Binocular"
~1
? _i > 300 : goto "end1"
goto "loop1"
#end1

The loop script doesn't help. All he does is use the binoculars for a few seconds and stop. Then a few seconds later he'll repeat this. Not to mention he doesn't even pull out the binoculars if he has a weapon, he just starts the action and less then a second later stops.

By the way if anyone doesn't know how to do this but remembers a campaign mission where an AI used binoculars please tell me and I will check the mission and try to find the answer there. That's how I usually solve my editing problems :cool:

Thanks in advance!

Share this post


Link to post
Share on other sites

Hi,

i think it is very do able by forcing the AI to play the given animation. I'll do a little search and come back to you.

Share this post


Link to post
Share on other sites

hi,

You can use animation with playMove or switchMove. With playMove smooth transition will be done, with switchMove there is no transition it means the animation will be performed immediatly.

The three animations you are looking for are:

"BinocLying"

"BinocStand"

"BinocCrouch"

I wrote a script very quickly (not tested)

watch_through_binocs.sqs

;**************************************************
;Watch Through Binocs Script By Nikiller v0.9b
;Force unit to watch through his binocs
;NOTE: Don't forget to add binoculars to the unit
;NB: do not delete the delay or it will not work
;[unitName,"animationName"] exec "scriptName.sqs"
;example:[loon1,"BinocStand"] exec "scriptName.sqs"
;**************************************************

_u = _this select 0
_s = _this select 1

if (local _u) then {} else {goto "ende"}

~0.1
? alive _u: _u switchMove _s

#ende

exit

Say me if it wroks since I can't test it.

cya.

Nikiller.

Edited by Nikiller

Share this post


Link to post
Share on other sites

Yep, tested and it does work but the anim is only played once. You'll have to use a loop for constant animation.

Share this post


Link to post
Share on other sites

I'm not sure how to create the loop from Nikiller's method. After a long crazy search I found this script:

binocs = false

#loop
lead playmove "StandtoBinocStand"
~0.01

?(!binocs): goto "loop"

exit 

when binocs = true the loop will end. Also I must set the unit position to be "UP" or he'll sometimes put his binoculars down and put them back on. However with this script I can't make the AI turn and look around. I mean soldier1 doTarget target1 doesn't work. I need the soldier to keep looking through the binoculars all the time and turn to look at different targets. Thanks!

Edited by Domcho

Share this post


Link to post
Share on other sites

Yes, it doesn't work. Got another problem as well. When a unit has setUnitPos "UP" it won't stand with it's gun on back. If I don't use setUnitPos "UP" he'll put his binocular down.

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  

×