Jump to content
Sign in to follow this  
domcho

Making AI shoot targets for target practice

Recommended Posts

Hello people. I am trying to make a mission where a soldier shoots at targets. The targets are under Empty->Targets->Simple Target in the mission editor. I have 4 targets each target is named targetX where "X" is a number from 1 to 4. The soldier's init contains

this setUnitPos "Middle";
this setBehaviour "COMBAT"

I want the unit to be crouching so I use setUnitPos "Middle". I want the unit to be aiming through his weapon the whole time so I use setBehaviour "COMBAT". I use 8 triggers because I don't know how to use conditions in .sqf files. Soldier name is Soldier1. So it goes like this:

1st trigger On activation: Soldier1 doTarget target1; Soldier1 doFire target1
2nd trigger Condition: not (canMove target1) On activation: tar2 = true
3rd trigger Condition: tar2 On activation: Soldier1 doTarget target2; Soldier1 doFire target2
4th trigger Condition: not (canMove target2) On activation: tar3 = true
5th trigger Condition: tar3 On activation: Soldier1 doTarget target3; Soldier1 doFire target3

and goes like this for 4 targets in total. However the problem is he always stops shooting after he drops the 3rd target. Always reloads after killing the 3rd target. Then he just aims at the 4th and does nothing. If I shoot the 4th target he starts shooting at it as well until it drops. The problem is not in the reloading. I tested it without using setUnitPos "Middle" and setBehaviour "Combat". The soldier starts shooting, crouches while shooting, when he kills the target stands up and starts shooting at the next one again crouching. He keeps crouching and standing up when there is no setUnitPos and setBehavour however he shoots all targets even after he reloads. I've searched for my problem in the forums and people would usually say "Give him infinite ammo so he doesn't reload". The problem is in the setUnitPos "Middle" so

["fired", {(_this select 0) setvehicleammo 1}]

will not help. The reason I use the setUnitPos and setBehaviour is because I want him to be

1 - crouching

2 - aiming (not holding his gun down)

How can I make the soldier shoot all the targets while he's crouching and aiming? Thanks.

PS using destroy waypoints doesn't work either. He doesn't even shoot at the targets.

Share this post


Link to post
Share on other sites

I used the same commanda as you have above.

And like you I used triggers.

I set the 3 triggers so he fires at target 1 then at target 2 then at target 1 again.

He will never fire at target 1 a second time. Why is that?

Share this post


Link to post
Share on other sites
I used the same commanda as you have above.

And like you I used triggers.

I set the 3 triggers so he fires at target 1 then at target 2 then at target 1 again.

He will never fire at target 1 a second time. Why is that?

No idea if event handlers are set on targets but if so then a "killed" event handler would likely result in the AI subsequently ignoring the target. Try adding in

target1 removeallEventHandlers "killed";

for example after the line that follows the 'kill target 1' instruction (or the AI may keep shooting at the same target, perhaps).

Share this post


Link to post
Share on other sites

So what? It's another game bug, 1 of the million others, that prevents me from creating my missions? It's not fixable?

Share this post


Link to post
Share on other sites

The wiki say doFiring and doTarget doesn't work this obejct ? I don't see other way. help please !

Share this post


Link to post
Share on other sites

don't know if you are still looking for the awnser but you can d it with 1 accuracy target (static one), the unit wil keep firing on it till magazine is empty.

Share this post


Link to post
Share on other sites

No offence, but did you try to rething the whole structure of this code? Using X triggers is rather sub- optimal.

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  

×