Recent Changes - Search:

Main.SideBar (edit)

PmWiki

UnitGroups

What are unit groups?

Unit groups are meant to group units into logical teams. Such teams operate as a single entity, trying to fulfill the same task.
When player selects unit, we'd select the whole group which contains this unit (although we should definitely also make it possible to select single units).

What would groups consist of?

Group would basically be a list of units that belong to this group (team members), but each group also has a leader - the unit that leads the group - and zero or more subgroups.

Leader
Leader is the highest-ranking unit in the group. Leader can also choose new leader for the group and put some units in the group into a subgroup. The leader can also give commands to subgroups.

Subgroups
Subgroups are groups which belong to (are under command of) a higher-level group. This creates a group hierarchy where the leader of the highest-level group (the one without parent group) can be viewed as a general. Leaders of subgroups of the highest-level group would be captains, etc.
Group leader also has possibility to put some of the units in his group into new subgroup and give it new objective. This can be used by unit AI to create some interesting tactics - e.g. leader of the big group may create few subgroups and order them to attack enemy from the side.

Group members
Every member unit of the group has a rank associated with it. When the leader of the group dies, the highest-ranked member of the group will be the new leader.
Note that members do not include members of the subgroups.
TODO: what if last member of the group dies and group has parent group and subgroups? Probably we should then reparent all subgroups to the parent group.

Why is it good?

There are several advantages of the groups over single units:

  • Easier controlling - controlling groups is often probably easier for the player than controlling individual units. Of course initially you have to create the groups but once that's done, controlling units should be easy.
    We could make a keyboard shortcut for putting all the selected units into new group.
  • Less pathing overhead - only the group leader would do the pathfinding. All other group members will just follow them (or rather try to maintain their relative position to the leader). It may require some more coding to get it done at first, but in the long term, I think it'll pay off as the pathfinding time decreases and we can thus make pathfinder smarter without making the game slower.
  • Formations - by storing relative position to the group leader (either x and y pos deltas or, better, distance and rotation) for all group members and trying to maintain them, we'd have basic formations support.
  • Unit AI can use tactics - the group leader may choose to use interesting tactics for attacking the enemy such as flanking.

Implementation

Some implementation ideas:

  • Player orders should be given to groups, not to individual units.
  • Bigger decisions such as pathfinding should only be made by the group leader - this saves us time as well as makes sure that the group acts as a whole - instead of every member searching it's own path, the others just follow the leader.
    • Should make pathfinding aware of groups - you don't want to move a 100-unit group through a narrow passage when a much wider is available and just a little bit farther.
      Might be difficult to implement though.
  • Every group stores it's orders (that is, it's Work as well as Work-dependant data (e.g. destination point or target unit))
Edit - History - Print - Recent Changes - Search
Page last modified on March 17, 2006, at 13:35