Jump to content
Sign in to follow this  
mr_centipede

Small AI Script Addon - Cent_Stick2gether

Recommended Posts

Hello, here I made a small AI script. nothing fancy really. Just made the AI maintain formation in firefight. Here's from readme:

CENT_STICK2GETHER v1.1 (Updated 18 July 2009)

OVERVIEW:

This script will make AI stick together in formation (AI won't issue engage orders) in firefight. They will only break formation and engage the enemy if friendly group to enemy ratio is greater than 70%.

It's just a simple script, but I think it would make firefight more interesting.

TECHNICAL DESCRIPTION:

The script will init to each MAN class and those that will inherit from MAN class. By default all groups will "enableAttack false"

It then will create a trigger on each man of 500m radius. The trigger will activate when, it has detected the enemy(activation by anybody, detected by whichever side the trigger is created on, eg detected by west) and will execute an sqf script.

The sqf script will then count the man in his group and count the enemy within the trigger. Some simple calculation later, it will decide to have them "enableAttack true" or "enableAttack false".

REQUIREMENT:

Community Based Addon (CBA)

INSTALLATION:

Just place @Cent_stick2gether folder in you ARMA2 folder. Then run your arma2.exe with -mod=@Cent_stick2gether command

AUTHOR

MR_CENTIPEDE

download links: v.1.1

obsolete

mirrors v1.1

obsolete

mirrors and feedbacks are welcome

[EDIT]

I have given all rights for zGuba to modify and release this addon. The latest version from zGuba is as follows

ZGB_Stick2gether.pbo

Edited by Mr_Centipede

Share this post


Link to post
Share on other sites

Cool!

This is exactly what I've been looking for. I'll try it later. I'd love to see an "Assault" mode where the AI stuck close and prioritized sticking near to the SL. Particularly useful for urban engagements. :P

-K

Share this post


Link to post
Share on other sites

Thx for this script addon, Mr_Centipede :)

Put it on our scripts section at Assault Mission Studio

dlicon.gif

Small AI Script Addon by Mr_Centipede

Share this post


Link to post
Share on other sites

:notworthy:

IMO this should be standard. Default A2 behaviour is kinda awkward especially in High Command, where teams gets killed while individual soldiers are engaging every target spotted.

Share this post


Link to post
Share on other sites

Thanks for this! I am looking forward to testing it.

Share this post


Link to post
Share on other sites

nice! will test when i get the chance.

i really hope someone can get into more AI scripts and mods.

the AI seems to have the ability to do nice things but they prioritise their actions in a weird way.

for example - i've seen the AI take cover behind trees and lean around them but i've only seen this done once! they tend to take cover behind objects in town but they also do it very rarely.

i really hope someone can get a mod up to make them use cover more! and also walk with the rifle up more since they tend to run around so much that they react slowly when see an enemy.

Share this post


Link to post
Share on other sites

I tested this with AI v AI with waypoint pointing towards each other on aware etc. both had equal amounts of AI in the apposing teams, but I still get "Target that" etc etc.

I tried looking through the eyes of AI (camera "internal") and tried different areas of the map, enemy high ground, then opposite etc. But they still have team leader set targets etc.

So am i missing the point of this? IE: targeting is the same but they dont run off as much on thier own? I notice they to tent to spread out more ... maybe I need to test without it and see.

Share this post


Link to post
Share on other sites

@mrcash, the AI leader will assign target to their group, but wont issue 'engage' command, so they wont break formation and 'engage'. But At certain case, they will issue engage command

Here's some technical/script flow description:

the script will init to each MAN class and those that will inherit from MAN class.

it then will create a trigger on each man of 500m radius. the trigger will activate when, it has detected the enemy(activation by anybody, detected by whichever side the trigger is created on, eg detected by west) and will execute an sqf script.

the sqf script will then count the man in his group and count the enemy within the trigger. some simple calculation later, it will decide to have them "enableAttack true" or "enableAttack false"

If you wanted them to never issue 'engage' command, you can use "enableAttack false" not much scripting needed. My version is that sometimes, I wanted them to move in and engage, so I figure if they outnumbers the enemy something like 70%, then the AI will issue engage command, but only within small arms range... so I put in 500m radius trigger...

It's crude.. but I hope to improve it, when I get better with scripting.

Share this post


Link to post
Share on other sites

Hi, Mr Centipede.

Very nice addon, i tried myself doing something like that some days ago.

One thing i've noticed doing my stuff is that putting just "_group1 enableAttack true" won't stop the leader himself from blindly engaging / running into enemies. It was frustrating, since i found no reliable way to stop him from doing that (i wrote plenty of useless stuff to keep him near to his squaddies).

Then just a suggestion: do not check only the number of units in the group, check the number of friendly units in the area (including air units!) ... that should give you a more reliable power ratio ;). I did that stuff via the "neartargets" function, but doing it (as you did) via trigger is possibily more efficient ?

Share this post


Link to post
Share on other sites
Hi, Mr Centipede.

Very nice addon, i tried myself doing something like that some days ago.

One thing i've noticed doing my stuff is that putting just "_group1 enableAttack true" won't stop the leader himself from blindly engaging / running into enemies. It was frustrating, since i found no reliable way to stop him from doing that (i wrote plenty of useless stuff to keep him near to his squaddies).

Then just a suggestion: do not check only the number of units in the group, check the number of friendly units in the area (including air units!) ... that should give you a more reliable power ratio ;). I did that stuff via the "neartargets" function, but doing it (as you did) via trigger is possibily more efficient ?

I did thought about counting friendly units inside the trigger for better ratio, but I figure that there wont be some sort of cooperation between groups (they do communicate with each other I think regarding enemy position but I dont think they will coordinate an assault together) so I decided just to count number of friendly in his group. Maybe I'll try your idea and see how it goes.

About AI leader charging away like a maniac... yeah, I dont know how to do that either. I hope I can come up with something

Share this post


Link to post
Share on other sites
I did thought about counting friendly units inside the trigger for better ratio, but I figure that there wont be some sort of cooperation between groups (they do communicate with each other I think regarding enemy position but I dont think they will coordinate an assault together) so I decided just to count number of friendly in his group. Maybe I'll try your idea and see how it goes.

About AI leader charging away like a maniac... yeah, I dont know how to do that either. I hope I can come up with something

About communication / cooperation between groups: i made any group leader "revealing" to other nearby group leaders (< 150/200m distance) their spotted targets. That was enough and worked fine, included for nearby air and armor units ;)

Share this post


Link to post
Share on other sites

@ Mr Centipede

Thanks for the extra description, I think it was needed just to get an angle on exactly what it did. My post was slightly dumb ref obvious it would target, and yes in that case this works as it should.

Would be nice to see any input for fancy expansion on other awareness variables.

Great work so far.

Share this post


Link to post
Share on other sites

I think my script is quite broken actually. Figuring something out...

it somewhere here:

trg setTriggerStatements["this", "[list trg,man] execVM 'cent_stick2gether\cent_stick.sqf'", "_grp enableAttack false"];

but I figure global variable isnt the right way to do it... so I' thinking something like>

_trg setTriggerStatements["this", "_trgList=list this", "_grp enableAttack false"]; 

then, execute the sqf:

[_trgList,_man] execVM 'cent_stick2gether\cent_stick.sqf'

The problem is the code inside triggerStatement is outside of the scope of the sqs script, how I can go around this? They key problem is I needed the list of units inside the trigger, thats what originally "list trg" do.

[edit] Got figured it out

use like this:

[list _trg,_man] execVM 'cent_stick2gether\cent_stick.sqf'

Edited by Mr_Centipede

Share this post


Link to post
Share on other sites

I've done some more test. I think it didn't do much than vanilla. On my test mission, USMC assaulting a hill occupied by russian squad got slaughtered. without this addon, the russian got slaughtered. Which to me is quite okey, since the russian on hill insise cover of trees, defending, should win. So I guess on the bright side, we can have a proper defend waypoint for the AI since they wont leave their position and pursuit the attacker.

Honestly I made this script on the pretense the game was like ARMA1, which basically thats where this script came from, I made this in ARMA1 so the AI will stick together in formation. In ARMA1, it works. but in ARMA2, they spread more, but still they wont attack alone like in ARMA1.

Hope to hear more from your tests

Share this post


Link to post
Share on other sites

I tested version 1.0. My results were a bit inconclusive unfortunately. At times I thought it was working, at other times they appeared to be exhibiting vanilla behaviour.

Have the link and mirrors been updated to version 1.1? I can't get it from rapidshare at the moment as their servers are "busy".

Could you perhaps include the version number in file name just to make it obvious which version is being downloaded?

Edited by stun

Share this post


Link to post
Share on other sites

Is your rapidshare link on page 1 now 1.1 all others seems to link to 1.0? But yours doesn't say if that's actually 1.1 file?

EDIT .. ok readme confirms the rapidshare is 1.1 :)

Edited by mrcash2009

Share this post


Link to post
Share on other sites

Mr Centipede, have you tried setting all Subordinate AI groups to setCombatMode "yellow" as a possible solution, or do the AI commanders instantly overide this by issuing an engage order?

I would have been happy if BI had made open fire the default be combat mode in high command as opposed to "fire at will, engage at will".

Share this post


Link to post
Share on other sites

I think the default is combatMode "YELLOW". it's just the the AI leader will command their group to engage enemy. That's what enableAttack false do, to disable the AI leader to give engage command. At least that's what I think...

But I try it anyway... preliminary test show not much difference. They still spread around, but they wont attack. It also seems the AI leader seems less suicidal now... might made fabrizio_T happy. Will test more might just be a fluke...

[edit] about suicidal leader... they're still suicidal... charging like a maniac

Edited by Mr_Centipede

Share this post


Link to post
Share on other sites

I had a bit of a play with your scripts. I added setcombatmode "yellow" and changed instances of enableAttack true to enableAttack false (so that regardless of the condition it would be false). I did this to see if I could prevent the AI from engaging completely. It seems to have worked, although the AI commanders are still issuing engage commands verbally, the units don't appear to be carrying out the order. If I issue them an attack command they do appear to carry this out. The one problem with vanilla and your addon seems to be that when AI subordinates order units to engage, they never seem to order them back into formation, or to disengage once the enemy is destroyed.

It is very hard to set up scenarios to test this accurately - to determine if it is a fluke or not!

I wish BI would just enable the full set of normal interface commands for high command - it would be nice to be able to set a "hold waypoint", or order an subordinate unit to disengage.

Edited by stun

Share this post


Link to post
Share on other sites

I try to use setBehaviour "combat", and it seems most of the time the AI will group close together... not bunch up but it looks like the integrity of the squad seems intact. Or maybe it's just me... I edit a bit the sqf file.. whenever there was a contact, they will automatically change behaviour to "combat" (danger). Then when all is clear (_ratio >= 1) they will revert back their behaviour to whatever the waypoint behaviour was set to, except in hold waypoint, I force them to stay in COMBAT behaviour. So far it looks good... will test more

Share this post


Link to post
Share on other sites

I have been playing about testing. Setcombatmode "yellow" definitely causes subordinate commanders to order units to disengage. the disengage order doesn't seem to cause units to regroup however. Is there a scripting command that orders units to regroup? I find it impossible to believe that there isn't such a command.

Update:

After some more testing I am starting to come to the conclusion that the disengage command doesn't work in Arma 2. My test: order a unit in my squad to target an enemy and then order engage at will. The unit moved off to attack the enemy unit. when I ordered the unit to disengage he kept after the target and wouldn't return to formation until the enemy unit had been destroyed.

Edited by stun

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.
Sign in to follow this  

×