Jump to content
Sign in to follow this  
xMobiusTyrx

How to get AI to shoot during an animation?

Recommended Posts

Hello!

I'm wonder if there is a scripting command for an AI to fire his weapon while during an animation. Any help would be greatly appreciated!

-CoBros

Share this post


Link to post
Share on other sites

I use this...

Make the AI target something out of view and in the direction you want the AI unit to be firing, like another unit for example.

Name both units obviously, man1, man2 or whatever

For the unit you want to fire use...

man1 dotarget man2

either in a trigger or simple script, then when you want it to fire do...

man1 dofire man2

to keep the unit firing constantly, set the man2 who's been shot so it cannot be killed, ie

man2 allowdamage false

you can basically use any object for the unit to shoot at really.

Share this post


Link to post
Share on other sites

Try this code regarding the useweapon action:

_unit = _this select 0
_target = _this select 1

#WEAP1
_weapon = currentWeapon _unit

;Get Weapon Index
_wepIdx = 0
_unit action ["SWITCHWEAPON", _unit, _unit, _wepIdx]
? (currentweapon _unit) != _weapon:_wepIdx = _wepIdx + 1
_unit action ["SWITCHWEAPON", _unit, _unit, _wepIdx]
? (currentweapon _unit) == _weapon:goto "Done"
goto "Weap1"

#DONE
_unit dotarget _target
~3
hint "fire!"
gamelogic1 action ["USEWEAPON",_unit,_unit,_wepIdx]

sqf version:

_unit = player;
_veh = vehicle _unit;
_weapon = currentWeapon _unit;
//Get Weapon Index
_wepIdx = 0;
_unit action ["SWITCHWEAPON", _veh, _veh, _wepIdx];
while{(currentWeapon _unit) != _weapon} do {_wepIdx = _wepIdx + 1; _unit action ["SWITCHWEAPON", _veh, _veh, _wepIdx];};

http://community.bistudio.com/wiki/Talk:ArmA:_Actions

Its absolute, this will make the unit pull the trigger every time. Its way better than dofire. The code in the tread is self adapting and will use whatever weapon the unit has so you dont have to specify the weapon type each time.... NICE!

Only catch is that the unit will fire even if the weapon is on back so you have to make sure its aimed at target. Usually you can issue the dotarget command and wait a couple of seconds and the ai should be aimed as dotarget seems reliable enough....

:)

Edited by TJ72

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  

×