Jump to content
Sign in to follow this  
Grumpy Old Man

AI squads: Assigning and commanding units in fireteams like team "RED" via scripts?

Recommended Posts

Hey folks,

currently trying to figure out a way to assign AI squad members to fireteams,

the team is not being controlled by the player and the commands from the biki are confusing/mixed up with the ancient "team" commands (replaced by "group" commands in a2).

I know you can assign units to a team using

_unit assignTeam "RED";

and it's working, but how can I issue commands to team "RED" or team "GREEN"?

Doesn't look like there's any command that can achieve this, by using assignedTeam I only get the "RED" or "GREEN" string returned, not the actual team members.

Basically I want to achieve that an AI squad leader gives orders like "Team Red, move to xyz" for individual AI scripts.

Cheers!

Share this post


Link to post
Share on other sites

Hi!

Well, looking at the wiki:

https://community.bistudio.com/wiki/forEachMemberTeam

But, if you click on the "Team Member" link, it says: "This is a reserved Type for future implementations. In Armed Assault it is not implemented yet"

Weird. I never tried to script AI with teams.

Workaround: ¿why not make subarrays of units of a group and issue separate commands to them? I suppose UPS / UPSMon does something like that....

Share this post


Link to post
Share on other sites

Yeah, that's my workaround so far, I just hoped that I could improve unit count by dividing squads into 4 fireteams instead of creating 4 new groups for the same cause (not to mention the awkward scripting approach to manage multiple groups at the same time and performance hit).

Share this post


Link to post
Share on other sites

Scripting AI with fireteams would have many advantages (way more headroom for the group limit), sharing of enemy positions without the need to run additional scripts etc.

Found out another issue, if you're in an AI squad without being the squad leader you're still the formation leader for all subordinate units, they will follow you around.

Now if you try to achieve the same thing (basically what I want from the AI to do) with a 100% AI squad without the player it just doesn't work, any move commands will be executed by that unit that receives the command.

Weird.

I stumbled across setDestination, looks like it could do what I need, the documentation is pretty sparse and it doesn't seem to do anything at all, or maybe I'm missing something

Edited by Grumpy Old Man

Share this post


Link to post
Share on other sites

You are working on something with more than the group cap????

Anyway, I suggest you to check exactly how is done in UPS...

Share this post


Link to post
Share on other sites

UPS is using multiple groups, just as you spawn or place them in the editor.

Right now I got a script to filter individual units within a group and assign them to a fireteam depending on their roles (depending how many units died from the original units group they'll join up with other groups nearby, in case you were wondering).

It just doesn't look too good if you're issuing around AI units with dostop and domove commands since they won't keep formation after using the dostop command.

I guess having individual fireteams within a group just isn't possible with AI squad leaders, looks like there's always only one formation leader within an AI group.

Edited by Grumpy Old Man

Share this post


Link to post
Share on other sites

I think I understand, you want to make a semi-HC-AI which manages groups depending on specialities (snipers, don't get too close, grunts, flank and get as close as possible, MGs supress). UPS does this but I think it does not care about "specialities" ,and using reveal is not the same experience for the AI than being in the same group...

Not easy, I suppose the way of doing that. Having original group leader, his waypoints, check behaviour loop, check distance to waypoint, array of known enemies, looped reveal + dynamically create subroups depending on typeOf, with dynamic waypoints (you have original waypoint + enemies positions as references), and after leader reching the original waypoint or no enemies nearby, everyone joins again...

Doing that, you will create let's say 4 groups as much for each, and just one waypoint on them, finding caps, if you do things clean and deletegroups, could mean more than 60 groups per side...

Share this post


Link to post
Share on other sites
I think I understand, you want to make a semi-HC-AI which manages groups depending on specialities (snipers, don't get too close, grunts, flank and get as close as possible, MGs supress). UPS does this but I think it does not care about "specialities" ,and using reveal is not the same experience for the AI than being in the same group...

Not easy, I suppose the way of doing that. Having original group leader, his waypoints, check behaviour loop, check distance to waypoint, array of known enemies, looped reveal + dynamically create subroups depending on typeOf, with dynamic waypoints (you have original waypoint + enemies positions as references), and after leader reching the original waypoint or no enemies nearby, everyone joins again...

Doing that, you will create let's say 4 groups as much for each, and just one waypoint on them, finding caps, if you do things clean and deletegroups, could mean more than 60 groups per side...

Yeah, it's a pretty extensive script on itself, but it's only a small part of what I got so far (around 140 functions in total, all interacting with each other), don't know if I want to turn it into a sandbox or a sandbox campaign for now.

After doing some performance tests around 100 units in a single group yields around 30 fps, 10 groups with 10 units is a whole different matter, gonna play a bit more with the setDestination command, as for now I think it's not doing much at all...

Cheers

Share this post


Link to post
Share on other sites

Personally I would create groups, and have groups that are almost eliminated join groups that are within a certain distance.

I would also cause the creation of groups not to happen until the players group/leader is within X meters of each "zone". My findings have been that, even on a dedicated server, the more units/objects the less FPS the server has, and the lower everyones experience is. So now i try to make one script that watches for boolean values (like triggers) and only creates units etc if players are near.

I also make heavy use of arrays even though the syntax for using arrays in this script language is subpar at best.

There are so many things one could do that are overly complicated in this language I am suprised there is as much good content as there is. Seems like every time I want to do something with a script, its overly complicated. Thats the price you pay for a real pc game these days I guess. I won't complain though. If a european country wants to make a pc game when all the us companies don't, then I say "right on" to the EU and the US can kiss something of mine for selling out to the console crowd lol.

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  

×