Formations?
Moderator: Moderators
-
MileHighGuy
- Jedi

- Posts: 1194
- Joined: Fri Dec 19, 2008 7:58 pm
Formations?
Is it possible to make the ai go into formations via lua? Or at least travel in groups? For example, can I have clones follow the first clone commander they see? How complex can we go with this?
-
Marth8880
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: Formations?
You could possibly create a table with a for...while loop that compiles all of the currently-spawned Commander units and then create an AI goal that's set to defend or follow (defend is a loose follow, follow is a tight follow) the entity ptrs stored in that table. Or something like that. I'm not very familiar with tables, so I can't help you very much with it. However, I think the AI goal bit would probably be something along the lines of this:
Code: Select all
AddAIGoal(REP, "Defend", 80, [commandertable])-
MileHighGuy
- Jedi

- Posts: 1194
- Joined: Fri Dec 19, 2008 7:58 pm
Re: Formations?
Are there any examples of this being used in the stock files? I will have to look up how to use tables in lua.
-
razac920
- 2nd Lieutenant

- Posts: 365
- Joined: Sun Jan 16, 2011 12:42 am
Re: Formations?
AIGoals seems like a good idea. I don't know of any examples like this in the stock files, but here's how I would do it:
Since there is a maximum of 20 AI Goals, make sure you don't have too many commanders on the map at the same time.
Hidden/Spoiler:
Since there is a maximum of 20 AI Goals, make sure you don't have too many commanders on the map at the same time.
Last edited by razac920 on Sat May 31, 2014 9:52 am, edited 1 time in total.
-
Marth8880
- Resistance Leader
- Posts: 5042
- Joined: Tue Feb 09, 2010 8:43 pm
- Projects :: DI2 + Psychosis
- xbox live or psn: Marth8880
- Location: Edinburgh, UK
- Contact:
Re: Formations?
Looks great! The syntax for the defend/follow goal is AddAIGoal( team, "Defend", weight, gameObjectPtr ), though. 
-
razac920
- 2nd Lieutenant

- Posts: 365
- Joined: Sun Jan 16, 2011 12:42 am
Re: Formations?
Fixed, good catch!
