Jump to content
Sign in to follow this  
ChrisDRob

Code for?: When Unit A is detected Unit B fire at Unit A?

Recommended Posts

Code for?: When a unit is detected fire at unit?

If a Bluefor unit/group is detected by a Guerilla unit/group have the guerilla unit/group will fire at the civillians?

How can I put this in code, and in what field?

I'm pretty new with the editor...:confused:

Share this post


Link to post
Share on other sites

Useweapon makes you select a weapon index. In the example they use 16.

I have no way of knowing what weapon index value the desired weapon is using.

Why couldnt they have attached to command to the cfg name of the weapon itself instead of convoluting what should be a simple process.

dofire is not reliable

fire makes the unit aim away from the desired direction

useweapon is not a user friendly method.

Share this post


Link to post
Share on other sites
Useweapon makes you select a weapon index. In the example they use 16.

I have no way of knowing what weapon index value the desired weapon is using.

TCP added a brute force solution to this problem on the action discussion page recently. I haven't tested it, but it looks quite clever.

Share this post


Link to post
Share on other sites

Pretty cool but when I try it the unit just crouches down and then stands up again. He does not in fact use his weapon. Tried it with a few different units.

EDIT:OK I fixed it by running the action on an editor placed game logic object. Why you cant run it on the unit as a local variable in a scipt I dont know but Ill take it.

Thanks for your help.

So the code I have is:

_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]

Created a gamelogic Object called gamelogic1 for this to work.

Holy crap you guys have no idea how useful this code is and how long it took me to get the AI to simply fire at a dotargeted object no matter how far away and what object type.

This code could be used for ranged suppression fire. Of course the unit just squeezes off single shot so more work would be needed to make it a full auto or burst mode but its a good start.

Its things like this that will improve the Arma2 missions and its a shame it takes so much research and testing to get some basic but useful tools created with scripting.

Edited by TJ72

Share this post


Link to post
Share on other sites

On detection, create a group west and join the civs to it. Making sure 'guerilla' is hostile to west, of course.

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  

×