RTS Modding: Reworking Unit Pathfinding and Combat Logic

    A practical guide to improving pathfinding, tile occupancy, combat attribution, and mode-specific behavior in older real-time strategy games. Learn how to separate engine limitations from configurable behavior, turn gameplay observations into testable specifications, and use AI coding tools for focused analysis and repeatable validation.

    The appeal of single-player battles in older real-time strategy games often depends less on graphics than on whether their rules hold up at scale. Add enough units, and intersections lock up. Garrisoned infantry fire without earning experience. Flying units that should attack from range insist on hovering directly above their targets.

    These are not visual shortcomings. They are system defects caused by tightly coupled pathfinding, tile occupancy, weapon resolution, and command interpretation. AI coding tools are useful in modding not because they can invent a new game for you, but because they can help translate vague gameplay complaints into verifiable behavior specifications.

    Establish the Engine’s Boundaries First

    Before making changes, document three things: what the engine already supports, what configuration can change, and what requires a behavioral workaround. Many modding plans fail because they assume that logic introduced in an expansion or later release also exists in the base game.

    Start with a capability checklist rather than adding units:

    • Building capture and garrisons: Does the building or the infantry execute the attack? Who receives kill credit and experience?
    • Passenger firing: Does the engine provide general support for passengers firing from vehicles? Without it, an armored transport is simply a mobile container.
    • Flying units: If a unit cannot land, must it use airship-style bombing behavior, or can it hold position, circle, and resolve ranged attacks?
    • Pathfinding and occupancy: Are tiles released immediately after death, mission changes, teleportation, and unloading?
    • Script triggers: Can skirmish, deathmatch, and defense maps load different behavior profiles?

    Use this checklist to distinguish goals that configuration can achieve from goals that require missing mechanics. When a mechanic is absent, reduce the requirement or change the interaction. Do not describe unsupported behavior as though the engine provides it.

    Turn Gameplay Expectations into Testable Specifications

    “More aggressive attacks” and “infantry that do not jam” are not implementable specifications. Break them into observable criteria:

    • Sustained pressure: On a fixed map with a fixed resource progression, attack-wave intervals stay below a defined limit, and attacks do not stop because scripts cycle without issuing useful actions.
    • Rally-point throughput: Measure time spent stalled, direction reversals, and units pushing against one another at the same chokepoint during peak traffic.
    • Occupancy cleanup: After a unit leaves, another unit can occupy its former tile on the next simulation tick. No invisible blockers remain.
    • Combat resolution: Damage attribution, experience attribution, and interface feedback agree for garrisoned, ranged, and airborne attacks.
    • Mode switching: The same unit definitions load different behavior profiles in skirmish and high-pressure play, producing reproducible differences in force density.

    AI coding tools can turn observation notes into checklists, compare two configurations, and rewrite informal descriptions as “condition—action—failure criterion.” They cannot replace your understanding of engine timing.

    Specific instructions produce useful output. A request to “make it stronger” tends to produce a pile of parameter changes that cannot be meaningfully regression-tested.

    Pathfinding Congestion: Reduce Conflicts Before Increasing Attack Density

    Large infantry jams usually combine three problems: target selection, rally-point capacity, and occupancy release. Increasing production speed alone moves the congestion from the barracks exit to the bridge.

    A practical sequence is:

    1. Separate rally areas and default attack routes by unit type. Avoid sending every unit through the same narrow passage.
    2. Stagger attack waves instead of assigning the entire army the same destination at once. Position ranged units first, send melee units next, and bring in slower units last.
    3. Reduce competition for individual tiles. For units prone to crowding, shorten the path-recalculation interval or allow lateral replanning when blocked, rather than repeatedly issuing the same command in place.
    4. Clear residual mission state. Unloading, entering buildings, dying, being mind-controlled, and interrupting missions need explicit occupancy release and re-registration.
    5. Reproduce failures on small maps. A bridge, a narrow gap, or a cluster of buildings can reveal most deadlocks more reliably than an entire campaign map.

    In a high-pressure mode, having roughly a full infantry formation on screen should be treated as a density target, not a reason to spawn unlimited units. As density increases, first verify that decisions continue updating during simulation ticks. If units receive orders only when they spawn, larger armies increasingly behave like walls.

    Ghost Tiles: Treat Occupancy as a State Machine

    A ghost tile appears empty but remains occupied in the game’s logic. It can make units behind it believe a route is blocked or cause building exits to jam unpredictably.

    The usual cause is an incomplete state transition: as a unit moves between movement, attack, garrison, loading, and death states, occupancy is registered but never cleared.

    The principles are straightforward:

    • Every departure path needs a matching release action, including normal death, removal, mission failure, and teleportation at map boundaries.
    • Building garrisons and vehicle passengers should use separate occupancy tables so that a unit entering a container does not leave a blocker on the ground.
    • A failed pathfinding attempt should not repeatedly write occupancy back to the old tile. The unit should briefly wait or choose another target instead of rewriting the same occupancy every tick.
    • Debug logs should record who occupied a tile, when it was occupied, and when it was released. The final rendered scene alone will miss transient errors.

    AI coding tools can organize these logs into state-transition tables and highlight branches with an entry but no exit. Implementation must still use configuration or scripting entry points the engine actually exposes. Do not invent callbacks that do not exist.

    Garrisons and Air Units: Choose One Combat Attribution Model

    Two recurring combat problems stem from inconsistent ownership of weapons and attacks.

    Garrisoned Infantry

    Some rule systems lend the first garrisoned infantry unit’s weapon to the building and credit kills to the building. Others give each infantry unit a separate garrison weapon, crediting kills and experience to that unit.

    Mixing these models can produce a bunker that appears to fire correctly while veterancy, kill statistics, and downstream triggers disagree. Each building type should use one consistent attribution model.

    If the platform cannot support each occupant firing independently and accumulating individual credit, do not promise full-garrison firepower and individual experience gains. An alternative is to switch the building’s weapon according to the garrison type and design a separate experience-compensation rule. That compensation must be documented in the same behavior specification.

    Passenger Firing

    The same limitation applies to transports. Without general passenger-firing support, adding passenger slots increases transport capacity—not firepower.

    Either accept the vehicle as a transport or change the interaction: unload passengers at the destination and let the vehicle’s own weapon provide its damage output. Do not imply that infantry inside can fire through the armor.

    Airborne Attacks

    For flying units, separate the ability to land from the logic used to choose an attack position.

    If all units that cannot land are forced into airship-style bombing behavior, a ranged weapon may become ineffective: the unit flies directly over the target instead of stopping at weapon range.

    Check whether the attack mission means “approach the drop point” or “enter weapon range and hold position.” If position-holding attacks are unsupported, do not design the unit around helicopter-style precision targeting. Area bombing, reconnaissance that calls in support, or a one-time strike may fit the engine better.

    Load Behavior Profiles by Game Mode

    Skirmish and deathmatch should not share identical attack priorities.

    The standard mode emphasizes sustainable operations, linking resources, power, technology, and attack waves. A high-pressure mode emphasizes on-screen pressure by shortening assembly time, allowing more simultaneous deployments, and reducing long detours.

    Loading can be simple: select a behavior profile at match start based on the mode name. Keep profile changes limited to decision thresholds, wave templates, and rally rules; leave unit identity data unchanged. This makes regression analysis clearer: did the units change, or did their orders change?

    Define the meaning of these fields consistently and document the observations behind them:

    • Attack interval and minimum wave size.
    • Deployment order for melee, ranged, siege, and air units.
    • Retry limits after obstruction and conditions for switching targets.
    • Whether defense and counterattack triggers compete for control of the same force.
    • Maximum unit count at a single rally point.

    Label parameter explanations as observations from the current platform, not universal rules. A change in map size or chokepoint width can turn the same value from workable to self-blocking.

    A Repeatable Workflow with AI Coding Tools

    A repeatable loop is more valuable than one long conversation:

    1. Record a failure in 10–20 lines. Include map features, unit composition, the simulation frame where congestion began, and the expected behavior.
    2. Ask the tool for a difference analysis only. Compare two behavior profiles and identify entries that could affect pathfinding or attack ownership. Do not ask it to directly “make the game fun.”
    3. Change one hypothesis at a time. Test staggered assembly before also changing weapon range and movement speed.
    4. Fix the replay conditions. Use the same random seed or trigger sequence, resources, and spawn points.
    5. Roll back failed hypotheses. Add the new logs to the checklist before testing the next change.

    Discard suggested values that cannot be mapped to fields in your actual configuration. Do not invent interface names or memory-editing procedures to make a suggestion appear valid.

    A personal mod can be ambitious, but every conclusion should be testable in the next match.

    Validate the Changes and Document the Limits

    After a round of changes, retain evidence for at least three outcomes:

    • High-pressure attacks continue without stalling because scripts stop producing useful actions.
    • Infantry spend less time stalled at narrow passages.
    • Damage attribution for garrisons, vehicles, and air units matches the design.

    Test ghost tiles by checking whether a unit’s old position becomes immediately traversable—not whether the units merely look more spread out.

    Finally, document what the platform cannot do. Without passenger-firing logic, do not promise firing from inside transports. Without position-holding attack behavior, do not promise precision airborne attacks. Without independent garrison weapons, do not promise per-infantry experience.

    These limits prevent engine deficiencies from being mistaken for tuning failures when maps or modes change. AI coding tools can accelerate specification, comparison, and regression testing. The resulting gameplay still depends on how clearly you define timing, occupancy, and combat attribution.