Skip to main content

Module group_formations

Module group_formations 

Source
Expand description

This module contains the implementation of the Group Formations file format for Total War games.

Group formations define fixed formation templates that both the AI and player can use to deploy their units on the battlefield. Each formation is designed for specific tactical scenarios (attack, defend, naval, etc.) and specifies unit placement, spacing, arrangement patterns, and which unit types should be placed in each position.

§File Format

The group formations file (groupformations.bin) is a binary file containing formation definitions that can be used by both AI and players to deploy armies tactically. Each formation can specify:

  • AI purpose flags (attack, defend, river crossing, naval, etc.)
  • Priority and unit category requirements
  • Supported factions and subcultures
  • Formation blocks defining unit positions (absolute, relative, or spanning)
  • Entity preferences specifying which unit types go where

§Game Support

This file format is not versioned in the traditional sense. Instead, different games have different implementations in the versions/ subdirectory:

  • Shogun 2: Basic formation system with entity types and arrangements
  • Rome 2 (and later): Extended system with entity weights, subcultures, and more AI purposes

§File Location

Group formations files are typically found at:

  • groupformations.bin in the root of a game’s pack

§Usage Example

use rpfm_lib::files::{Decodeable, group_formations::*};

// Decode a group formations file
let mut data = std::io::Cursor::new(file_data);
let extra_data = Some(DecodeableExtraData {
    game_info: Some(game_info),
    ..Default::default()
});
let formations = GroupFormations::decode(&mut data, &extra_data)?;

// Access formation data
for formation in formations.formations() {
    println!("Formation: {}", formation.name());
    println!("Priority: {}", formation.ai_priority());
}

Modules§

versions

Structs§

ContainerAbsolute
A container block positioned at absolute coordinates on the battlefield.
ContainerRelative
A container block positioned relative to another block.
EntityPreference
Defines a preference for a specific type of unit to occupy a formation block.
GroupFormation
A single formation definition specifying how units should be arranged.
GroupFormationBlock
A formation block defining a specific position or region in the formation.
GroupFormations
Represents an entire Group Formations file decoded in memory.
MinUnitCategoryPercentage
Specifies a minimum percentage requirement for a unit category in a formation.
Spanning
A spanning block that encompasses multiple other blocks.

Enums§

AIPurpose
AI purpose flags indicating when a formation should be used.
Block
Types of formation blocks that can be used to define unit positions.
Entity
Entity type classifications.
EntityArrangement
How units should be arranged within a formation block (line, column, crescent, etc.).
EntityWeight
Entity weight classifications (light, medium, heavy, etc.).
UnitCategory
Unit category classifications (cavalry, infantry melee, infantry ranged, naval, etc.).

Constants§

PATH
Fixed path to the Group Formations file.