First off, thanks for the advice!
1. I was thinking about something similar. However, for my group AI, I would like the player to be able to issue orders to individual units in the group, however, those orders would be processed by the group AI, rather than by the unit. In effect, the would be no difference between giving the order to 1, n or all of the units in the group - the groupAI would work out what the individual units do given the current 'group' order. I hope I explained that ok...
The thing that I thought about doing was to add another function to the group AI interface -
Code: Select all
UnitGetCommand(int unitid, command * c)
This funcdtion would effectively mirror the existing function GetCommand(int unitid, command * c), which is called when the whole group is issues an order by the player. UnitGetCommand would be called when an individual unit in the group was given an order. The default action would be to hand this off to wherever unit commands normally go - i.e. if you didn't redefine the function it in your specific groupAI, then individual unit orders would be handled as normal. However, I'm not sure you cxan do this with the current system, I think I'm thinking of subclassing and overriding and without having the spring source in front of me, I can't remember exactly how the group ai stuff is set up. However, it would be pretty easy to add this function to existing groupais anyway - it would probably look like
Code: Select all
UnitGetCommand(int unitid, command * c)
{
aicb->UnitGiveCommand(unitid, c) // I can't actually remember how to do this atm, but you get the idea
}
The idea being that for group ais like mine, you could effectively 'grab' the unit's command before it's processed, this I could do something like
Code: Select all
UnitGetCommand(int unitid, command * c)
{
GetCommand(c) // This effectively gives the order to the groupai
}
Does that make any sense - can you see what I'm trying to do, roughly? Is this a good way to do it? All it would need is for a quick check on the normal order-handling stuff to see if a unit given an order is in a groupAI and if so then hand off the command to the group ai's routine rahter than the unit's own ai routine.
E.g.
Currently (this is how i imagine it works, i cant check right now)
1. Global command order handler receives command
2. Passes command to unit ai
New system:
1. Global command order handler receives command
2. If the target of the command is a unit in a group ai, pass the command to the group ai's
2. Passes command to unit ai's UnitGiveCommand function
3. Otherwise pass it to the unit directly as normal.
Thanks!