Jump to content
Sign in to follow this  
Windwalking

Individual AI hold fire command

Recommended Posts

Hi all,

I need to make individual AI units in a group to hold fire so they would obey doMove command. I tried setCombat, but it works on the entire group. It's not what I need at all, I need individual units to stop firing. Any ideas?

Would disableAI command help me? Not sure if disableAI "Target" will stop the unit from firing.

If at all possible, I want it to be a silent command with no radio.

Share this post


Link to post
Share on other sites

Take the units out of the group if they aren't going to be working as part of the group. Then no worries.

Share this post


Link to post
Share on other sites

Played around a little

First, trying to put the unit in a civ group and put him back

oldGrp = group tester; 
tmp = createGroup CIVILIAN; 
[tester] joinSilent tmp;

// later on
[tester] joinSilent oldGrp;

This caused the unit to kill his group mates.

Below gave some results

{tester removeMagazine _x} foreach magazines tester; 
tester setAmmo [currentWeapon tester,0];
tester removeWeapon (handgunWeapon tester);

I removed the pistol because I didn't find a way to delete the loaded magazine in the unit's pistol.

Note that the unit will try to flee as he runs out of ammo, issuing a doStop command seemed to work.

Guess you could save all the magazines and stuff as a setVariable and give it back to him. Might cause a reload.

Share this post


Link to post
Share on other sites
Played around a little

First, trying to put the unit in a civ group and put him back

oldGrp = group tester; 
tmp = createGroup CIVILIAN; 
[tester] joinSilent tmp;

// later on
[tester] joinSilent oldGrp;

This caused the unit to kill his group mates.

Below gave some results

{tester removeMagazine _x} foreach magazines tester; 
tester setAmmo [currentWeapon tester,0];
tester removeWeapon (handgunWeapon tester);

I removed the pistol because I didn't find a way to delete the loaded magazine in the unit's pistol.

Note that the unit will try to flee as he runs out of ammo, issuing a doStop command seemed to work.

Guess you could save all the magazines and stuff as a setVariable and give it back to him. Might cause a reload.

That's actually quite brilliant. Too bad there is no straight way to do it, I will try this method and let you know.

Share this post


Link to post
Share on other sites
Take the units out of the group
it won't work that way :D
[tester] joinSilent tmp;
That's actually quite brilliant.

Wat? :)

Share this post


Link to post
Share on other sites

Guess this was worrying :D

This caused the unit to kill his group mates.

Share this post


Link to post
Share on other sites

_unit joinSilent grpNull; // should remove the unit from the group without messing the faction
_unit setCombatMode "GREEN"; // or "BLUE" should not mess with the rest of the group mode

disableAI "Target" would limit the target assignment from the leader

disableAI "Autotarget" would limit unit self assigning targets

instead of doMove you may also try moveTo (it is of lower level, i have used it with some success)

Edited by gammadust
  • Like 1

Share this post


Link to post
Share on other sites

I tried grpNull first but he was still firing at me, I guess the combatmode fixes that?

Share this post


Link to post
Share on other sites

^^ yep its is totaly supposed to... Afaik _group1 setCombatMode "BLUE" should suspend any fire reaction from the units even when fired upon, maybe add a setBehaviour "careless" to make sure.

Share this post


Link to post
Share on other sites

I just tried out moveTo. It doesn't seem to do anything at all. Did something change in Arma 3?

Share this post


Link to post
Share on other sites

afaik doMove act as orders and unit in a group will get this as an order which once complete will make him regroup. moveTo is supposed to work in doFSM's at the least... i'm nebulous right now but i think i was able to use it in the normal scripting context.

I have just tested them in current Beta branch, and doMove should work in a normal script. The situations i believe it does not respond is when the unit has already been ordered to do something. An attack/support orders by an AI leader so far i haven't been able to disrupt, hopefully that would not be your case.

Share this post


Link to post
Share on other sites
afaik doMove act as orders and unit in a group will get this as an order which once complete will make him regroup. moveTo is supposed to work in doFSM's at the least... i'm nebulous right now but i think i was able to use it in the normal scripting context.

I have just tested them in current Beta branch, and doMove should work in a normal script. The situations i believe it does not respond is when the unit has already been ordered to do something. An attack/support orders by an AI leader so far i haven't been able to disrupt, hopefully that would not be your case.

Sadly it is yeah. Since its an AI mod, I can't always guarantee the unit didn't receive an order.

I did however disable both target and autoTarget for the unit. Then used doWatch objNull to reset current target. It sometimes work but not consistently. It's very strange we don't get access to a direct hold fire command.

Share this post


Link to post
Share on other sites
Wat? :)

Oh, also I meant his idea of deleting ammo, not taking the AI out of the group :D

Share this post


Link to post
Share on other sites
Oh, also I meant his idea of deleting ammo, not taking the AI out of the group :D

I understand the need to NOT remove the unit temporarily, if nothing else as a simple precaution against losing functionality embbeded within grouping. But until bohemia provides more lowlevel overrides and/or some more individualized control i don't think you have much more hope than that.

but also try:

_group disableAtack true;

Share this post


Link to post
Share on other sites

I do understand. Thanks a lot for all the good info here guys. I will post here if i find anything to add.

Share this post


Link to post
Share on other sites

I was thinking about using the doMove command and get any remaining enemy AI from the group to move to the target location. If I create a trigger, is there a setup in the trigger options that will capture the an enemy reacting to coming under fire? Bearing in mind that I am sniping them from about 800 to 1,000 meters away??

Thanks

---------- Post added at 22:23 ---------- Previous post was at 21:43 ----------

Thank you all

Share this post


Link to post
Share on other sites
Sadly it is yeah. Since its an AI mod, I can't always guarantee the unit didn't receive an order.

I did however disable both target and autoTarget for the unit. Then used doWatch objNull to reset current target. It sometimes work but not consistently. It's very strange we don't get access to a direct hold fire command.

The problem seems to be the knowsabout value, if a unit knowsabout the enemy it's very difficult to get them to ignore the enemy.

If the AI don't know about a unit then dissableAI works quite well.

The only way I've found is to set the knowsabout value to zero is to have the [unit] join grpnull, this however wipes out all waypoints as well.

Share this post


Link to post
Share on other sites
The problem seems to be the knowsabout value, if a unit knowsabout the enemy it's very difficult to get them to ignore the enemy.

If the AI don't know about a unit then dissableAI works quite well.

The only way I've found is to set the knowsabout value to zero is to have the [unit] join grpnull, this however wipes out all waypoints as well.

Maybe a possible solution to this is

_waypointArray = waypoints yourGroup;

{
_position = waypointPosition _x;
yourGroup addWaypoint [_position, _forEachIndex + 1];	
}forEach _waypointArray;

Run that on each unit after you join them back to their group

Thinking outside the box here:

What if you teleported the unit to [0, 0, 99999] something insanely far away, maybe that would also wipe out the knowsAbout value?

Here's a quick mission I whipped up to test that "outside the box thinking" (Dropbox)

I tried sending the unit far underground (z: -999999), but he never came back. Used a hint to confirm code was running. It seems he was killed while underground, despite the time underground was only 1 line of code (next line was to teleport him back to his original position).

I tried sending him to [0,0,0] but I guess that's in water, and when I teleported him back he had to take his gun off his shoulder giving the enemy an unfair advantage.

Next I sent him to [4000,5000,0] which is on land, but you don't even notice him be teleported away. In fact, there isn't even a noticeable lapse in gunfire from either party.

I added a 2 second delay before teleporting him back (which is what you'll see in that download), but it seems you need a longer interval or some other method to make him forget about his target. Perhaps deleting the other unit and spawning a new one with the same loadout/waypoints?

I think the best way to do this would to be removing the unit from the group, adding him back, then using the code I posted above to add all the waypoints back to him (if any).

Edited by DreadedEntity

Share this post


Link to post
Share on other sites
_unit joinSilent grpNull; // should remove the unit from the group without messing the faction
_unit setCombatMode "GREEN"; // or "BLUE" should not mess with the rest of the group mode

disableAI "Target" would limit the target assignment from the leader

disableAI "Autotarget" would limit unit self assigning targets

instead of doMove you may also try moveTo (it is of lower level, i have used it with some success)

is moveTo working outside FSM? If so that's interesting.

About detaching / joining units to group: consider that it may cause issues / side-effects within group.

You may end up detaching leader, so leadership moves to 2nd in command. When you re-join him later it won't be leader anymore i suppose.

---------- Post added at 09:38 ---------- Previous post was at 09:32 ----------

I was thinking about using the doMove command and get any remaining enemy AI from the group to move to the target location. If I create a trigger, is there a setup in the trigger options that will capture the an enemy reacting to coming under fire? Bearing in mind that I am sniping them from about 800 to 1,000 meters away??

Thanks

Thank you all

That should work, i've coded something like that.

just issue these commands:

dostop _unit; // put unit out of formation, till move completion, so leader won't care about the unit;
_unit enableAttack false; // Avoid leader ordering unit(s) to do something else;
_unit domove _pos;

The tricky part is having the unit staying at destination, eventually.

---------- Post added at 09:41 ---------- Previous post was at 09:38 ----------

The problem seems to be the knowsabout value, if a unit knowsabout the enemy it's very difficult to get them to ignore the enemy.

If the AI don't know about a unit then dissableAI works quite well.

The only way I've found is to set the knowsabout value to zero is to have the [unit] join grpnull, this however wipes out all waypoints as well.

You may try tinkering with setTargetAge (https://community.bistudio.com/wiki/setTargetAge).

I tried using it in ArmA2, to make AI forget threats.

It didn't work, but that's worth checking again in ArmA3.

Share this post


Link to post
Share on other sites

The tricky part is having the unit staying at destination, eventually.

It's a simple doStop.

is moveTo working outside FSM?

I use it in an execFSM, and not in doFSM, so I guess it works in sqfs too. Moreover my execedFSM has a spawned block with a working moveTo as well.

Edited by zapat

Share this post


Link to post
Share on other sites
It's a simple doStop.

Yes, IF it ever get to destination, which is pretty unsure, especially in combat mode.

Usually i fiddle with unitReady + some timeout + evaluation of distance to destination in order to check whether some unit got to destination or failed to.

It's cumbersome.

If, like you say, moveTo is now supposed to work within .sqf, then moveToCompleted / moveToFailed would come in handy as well.

doStop won't prevent leader from calling some unit back or sending it to attack something elsewhere.

_unit Forcespeed 0 would be overridden by danger.fsm (bad design choice BIS!).

_unit disableAI "move" is cluncky, but it would definitely work.

Share this post


Link to post
Share on other sites

Just tested, looks to me moveTo is NOT working within plain .sqf scripts. DEV branch, latest build.

I'd say it's FSM only.

Share this post


Link to post
Share on other sites

Well, latest stable build (and I haven't seen anything related to moveTo in the changelogs):

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  

×