Jump to content
Sign in to follow this  
SgtDThompson

Make AI shot at a training target

Recommended Posts

Alright so I am making a training mission and i am wondering how you make the AI shot at a training target while laying down. also how would you make them run an obstacle course, if that is possible?

Share this post


Link to post
Share on other sites

To make a unit shoot at something

Name the object and the unit, and you can use a trigger with these...

unitname dofire objectname;

Some things units will fire at just using that, other times they need to be told to target it first.

unitname dotarget objectname;

or using the units init box

this dofire objectname;
this dotarget objectname;

To make a unit lay down using a trigger

unitname setunitpos "down";

or

this setunitpos "down";

in the units init box if needed from the start of the mission.

Edited by Koni
  • Like 1

Share this post


Link to post
Share on other sites

if doFIre doesnt work (because it has never worked for me on things that are not opfor or w.e

i use:

unit action ["UseWeapon", unit, unit, 0];

this guarentees the unit will fire. make sure to dotarget first

Share this post


Link to post
Share on other sites
if doFIre doesnt work (because it has never worked for me on things that are not opfor or w.e

i use:

unit action ["UseWeapon", unit, unit, 0];

this guarentees the unit will fire. make sure to dotarget first

Doesn't it make the unit place the weapon on the ground first?

Share this post


Link to post
Share on other sites

Sorry to barge in on an A2 thread - but I can't this working in A1 (with a Blufor Soldier and the Electric pop up target)

Also, is there a way to give the soldier unlimited ammo and fire every 30 seconds, just to add rifle range ambience?

Cheers guys

Stew

Share this post


Link to post
Share on other sites

Useweapon works it just has to be used properly....

http://forums.bistudio.com/showthread.php?t=113243&highlight=useweapon

It works everytime even if the weapon is on shoulder. The unit goes to pick up a weapon if useweapon command does not have a gamelogic to run the action on. You cant just tell it to get weapon 0 if that is not the current correct weapon.

The code in the above link works no matter what the weapon is as long as its the current primary. I didnt test on handguns though.

Edited by TJ72
gamelogic not wrong weapon

Share this post


Link to post
Share on other sites
Useweapon works it just has to be used properly....

http://forums.bistudio.com/showthread.php?t=113243&highlight=useweapon

It works everytime even if the weapon is on shoulder. The unit goes to pick up a weapon if useweapon command does not have the right weapon reference in the array. You cant just tell it to get weapon 0 if that is not the current correct weapon.

The code in the above link works no matter what the weapon is as long as its the current primary. I didnt test on handguns though.

The problem seems to be if you use the unit for the action

ie _unit action ect places the weapon on the ground.

Gamelogic action ect does work.

I tried the script you point to but it has problems due to the use of dotarget.

unit dotarget targ will only have the unit raise the weapon for less than half a second so getting it to fire while targeting an object is difficult.

Share this post


Link to post
Share on other sites

You are right but its a "new" bug. In older version/games it would hold the position. It should get fixed but I dont know if it is in the Bug Tracker.

Try dofire instead of or right after dotarget as I remember that seemed to keep the weapon aimed.

Incidentally, dofire should work on certain target objects and enemy units that the AI internally decides it "wants" to shoot. If the target is too far (which seems to be over 50 meters or so) or the object being fired at is not the right type then the above manual method works as a workaround to the issue.

Also the "fire" command (unless recently fixed in betas/patches) does not work for infantry as many allready know, the unit fires up in the air. If a vehicle is given the fire command it usually works as expected. The useweapon method described here is intended for infantry only to work around these issues. I have only used it for rifles and not handguns or launchers...

Edited by TJ72

Share this post


Link to post
Share on other sites

It is in bug tracker http://dev-heaven.net/issues/22724

I've been trying to get them to fix most of the firing commands as they're in a bit of a mess.

Dofire has been improved in current betas.

If a uint couldn't see the target ie behind him he would turn to the target take aim and not fire. This has been fixed now.

Share this post


Link to post
Share on other sites

I will test the latest beta sometime soon and post back....

Edited by TJ72

Share this post


Link to post
Share on other sites
Sorry to barge in on an A2 thread - but I can't this working in A1 (with a Blufor Soldier and the Electric pop up target)

Also, is there a way to give the soldier unlimited ammo and fire every 30 seconds, just to add rifle range ambience?

Cheers guys

Stew

This placed in the units init line will give unlimited ammo

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

I don't know how to make it keep firing at a pop up target, it will fire for a few seconds and stop but even if you re-issue the unit dofire targ command it won't fire again on the target.

Share this post


Link to post
Share on other sites
if doFIre doesnt work (because it has never worked for me on things that are not opfor or w.e

i use:

unit action ["UseWeapon", unit, unit, 0];

this guarentees the unit will fire. make sure to dotarget first

Hi mate i was reading a lot of posts about this and this your is diferent, so it could work, but i really don't know how to use where and how i need to write this.

can you explain to me plz.

Share this post


Link to post
Share on other sites

Place a target on the map name it t1

Place a gamelogic on the map name it gl

place the shooter on the map and place this in the init box

null=this spawn {_this dotarget t1 ;sleep 2;while {alive t1 and alive _this} do {sleep 0.3; gl action ["useweapon",vehicle _this,_this,0]; }};

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  

×