Skip to content

Repair and healing

Restores structures for credits, services vehicles at a depot, heals infantry at a hospital, and mends objects that repair themselves.

Features & systemsUnits, buildings & economyBuildings & economy

Changed in 0.2.0

The game restores strength in five ways: the repair wrench on a structure, a service depot for vehicles and aircraft, a hospital for infantry, self-healing, and Tiberium healing. An armory uses the hospital’s settings to promote infantry instead of healing them.

The paths share their rules settings, and a setting’s name does not say which paths read it. Most settings reach more than one path. Changing RepairRate for the wrench also changes self-healing, and changing IRepairRate for the hospital also changes the armory. Only self-healing can be moved off the shared settings, using the three keys at the end of the table.

SettingWhat it controls
RepairRateThe interval between structure repair steps, and between self-healing steps when SelfHealRate is not set
URepairRateThe interval between service depot steps. It sets no step size
IRepairRateThe count a hospital reaches before it heals a step, and the count an armory reaches before it promotes
RepairStepThe strength one step restores to a structure, vehicle or aircraft, and a divisor in the credit cost
IRepairStepThe strength one step restores to infantry
RepairPercentThe multiplier at the end of the credit cost
TiberiumHealThe interval between Tiberium healing steps
SelfHealRateThe interval between self-healing steps, replacing RepairRate for self-healing only
SelfHealStepThe strength one self-healing step restores
SelfHealCapThe share of maximum strength at which self-healing stops, replacing ConditionYellow for self-healing only

Each interval setting is a fraction of a minute, which the engine multiplies by 900 frames. The wrench, self-healing and Tiberium healing step on frames that are multiples of the result, truncated to whole frames. The depot, the hospital and the armory count up and act when the count reaches the result, rounded up to a whole number. At the engine defaults, with SelfHealRate unset, the paths step at these intervals:

PathDefault interval
Structure repair14 frames
Self-healing14 frames
Tiberium healing15 frames
Service depot15 frames
Hospital15 frames
ArmoryAbout 210 frames, explained under Hospitals and armories

Repair Mode does nothing while a building is waiting to be placed. It turns on only if the player owns at least one building, and turning it on deselects everything. Every change of the mode turns off sell mode, power mode and waypoint mode.

In repair mode, the wrench cursor appears only over a repair candidate that the player controls. Everything else shows the refusal cursor.

A building is a repair candidate under all of, in this order:

  • its strength is above zero;
  • it is not a deployed vehicle (a type with UndeploysInto counts as one unless it is a construction yard);
  • Any of:

A mined structure is therefore a candidate even when it is undamaged.

Vehicles, infantry and aircraft are never candidates, so the wrench never appears over them. A damaged vehicle is served by a depot instead.

Each click switches the building’s repair on or off. Switching it on plays the click sound and flashes the building. Switching it on at maximum strength plays the scold sound instead, but still switches repair on; only a mined structure can be in that state.

A structure under repair takes a step on every frame that is a multiple of RepairRate * 900. Every structure repair in the match therefore steps on the same frames, every 14 frames at the default.

Each step charges the owner before it heals. If the owner’s available money covers the cost of one step, the money is spent and RepairStep strength is added. A step that reaches maximum strength caps the strength there and ends the repair.

After each paid step, the structure’s damaged animations and damage smoke are updated. A structure that rises above ConditionYellow loses its damage smoke and returns to its undamaged artwork on that step.

cost of one repair step
cost = (raw cost / (Strength / RepairStep)) * RepairPercent, never below 1

Both divisions drop the remainder, and the multiplication is truncated to whole credits. A full repair therefore rarely costs exactly RepairPercent of the building’s price. Take a structure with a raw cost of 1000 and Strength=400, at the engine defaults of RepairStep=5 and RepairPercent=0.25:

  1. 400 / 5 gives 80 steps.
  2. 1000 / 80 is 12.5, which the division cuts to 12.
  3. 12 * 0.25 gives 3 credits per step.

Repairing the structure from one hit point takes 80 steps and costs 240 credits, not the 250 that the multiplier suggests.

The one-credit minimum raises the cost of a cheap structure with high strength. A structure with a raw cost of 100 and Strength=1000 has 200 steps. 100 / 200 is already 0 before the multiplier applies, so every step costs the 1-credit minimum. A full repair costs 200 credits, twice what the structure cost to build.

The raw cost is the type’s Cost, before any country or difficulty multiplier. For a structure, the price of what it gives away is subtracted:

  • the cost of its FreeUnit;
  • the average cost of the PadAircraft types, on one structure type only: the first entry in the Dock list of the first PadAircraft type. This subtraction does not apply when SeparateAircraft=yes, or when that structure’s FreeUnit is an aircraft.

When the type has a FreeUnit, the result is never below 0. A refinery that comes with a free harvester is therefore cheaper to repair than its listed price suggests.

  • Reaching maximum strength.
  • A step the owner cannot pay for. The repair ends on that step.
  • Another click.
  • Selling the structure.
  • Capture. The new owner receives the structure with repair off.
  • An engineer. It restores the structure to maximum strength at no cost and switches repair off.

A limpet mine does not stop a repair, and repairing does not remove it. A mined structure at maximum strength therefore stays a candidate. If the player switches repair on, the next step charges one step’s cost, caps the strength at the maximum again, and ends the repair. The mine stays.

UnitRepair=yes makes a building a service depot. The depot accepts vehicles and aircraft that ask to dock, offers the player’s selected vehicles a move cursor onto its pad, and runs the repair cycle.

RepairBay names the one BuildingType that repair orders look for. The engine reads the two settings separately, so they can name different buildings:

  • A RepairBay type without UnitRepair=yes refuses every docking request. A vehicle ordered to repair keeps searching for as long as its house owns one.
  • A depot that RepairBay does not name serves anything that reaches it, but a repair order never sends a vehicle there.

Five routes lead to a depot. Some look for a UnitRepair building and some look for the RepairBay type.

RouteLooks forConditions
Player moves a vehicle onto a depotUnitRepairThe depot is allied, not serving anyone, and holds nothing. The vehicle does not need to be damaged
Player sends an aircraft inUnitRepair or a helipadThe building is allied, not serving anyone, and holds nothing
Repair orderRepairBayThe nearest own or allied building of exactly that type that accepts the vehicle, in the same movement zone as the vehicle’s destination cell. The search runs only while the vehicle’s house owns a building of that type
Computer vehicle, checked every 16 framesUnitRepairThe vehicle is damaged, has no mission queued, and is not a harvester or weeder. It is on area guard duty, or on guard duty with no remembered position. It picks its house’s nearest depot within twenty cell diagonals, a little over 28 cells
Computer aircraftRepairBayThe aircraft is on guard duty below its flight level, and at or below ConditionYellow. It is not in contact with another object, unless it has landed and that object is not a RepairBay building. Its house has at least 100 credits, a floor fixed in the engine. The building is chosen as for a repair order, except that aircraft skip the movement-zone test

The repair order search normally takes the nearest building. A building with its house’s primary-factory flag is the exception: it replaces every building checked before it, whatever the distance. A building checked after it still replaces it if that building is strictly nearer. The check order follows the engine’s internal building list, which nothing on the map shows. A depot has the primary-factory flag only if its type also produces something.

A computer vehicle remembers where it stood before it leaves for the depot, and returns there after the repair.

A depot accepts a docking request only from an allied vehicle or aircraft. It also refuses while any of these is true:

  • it is switched off;
  • it is under construction, being sold, or still playing its buildup;
  • it is already in contact with another object;
  • the requesting object is already standing on it.

When the object arrives, the depot starts its service mission and the object goes to sleep. Once the object is within 150 leptons of the depot’s center, the depot switches off the object’s locomotor and clears its destination. This holds the object still on the pad.

A vehicle that is stopped or given another order while it drives onto the pad is released by the depot. When it reaches the pad cell it was heading for, it moves to the nearest free cell. It stays on the pad if no cell is free or if it is still turning.

The depot asks the parked object for one repair step at a time. The object refuses while it has a destination.

The first request comes as soon as the object is parked:

  • An object that needs nothing is released at once.
  • If the first step is paid for, the repair cycle starts.
  • If the owner cannot pay for the first step, the object stays on the pad. The depot asks again at each update of its mission, every 14 frames at the default Rate of the [Repair] mission, and makes no announcement.

During the cycle, the depot counts to URepairRate * 900 before each further request, one count per frame. Steps therefore fall 15 frames apart at the engine default. Each step restores RepairStep strength. Its cost comes from the structure formula, using the vehicle’s or aircraft’s Cost and Strength.

The depot acts on the object’s answer to each request:

  • Paid. The strength is added and the cycle continues.
  • Unaffordable. The depot announces insufficient funds and stops the cycle. The object stays parked, and the depot asks again at each mission update as it does for the first step.
  • Anything else. This covers a step that finishes the repair, an object that needs nothing, and an object that has been given a destination. The depot announces that the unit is repaired and releases the object. A computer-owned object with a remembered position returns there, as a computer vehicle does after reaching the pad on its own. Every other object moves to an exit cell beside the depot.

Each request to an object with no destination clears its limpet mine and resets its turret and body turn rates to the type’s ROT, at no charge.

A ManualReload=yes object whose ammunition is not full is then refilled completely, also for free. The refill takes the place of the repair step for that request. An undamaged mine layer is therefore rearmed and released at once. A damaged one is rearmed at the first request and starts repairing at the next.

Selling a depot while an object is parked within half a cell of it sells the object instead. The object is released and sold, the depot is not sold, and the depot returns to guard duty. The same condition is what lets the player sell a parked vehicle or aircraft at all.

A computer house sells a harvester or weeder that has run out of places to harvest, if it is below maximum strength. The depot first charges for and restores one step, then sells the harvester at the point where the repair cycle would start. At maximum strength, such a harvester is released at once like any object that needs nothing. A human house’s harvester in the same state is repaired and released as usual.

UnitReload=yes makes a building give the docked object one ammunition point per ReloadRate interval, 45 frames at the engine default. It repairs nothing. A helipad needs this flag to rearm the aircraft that land on it.

A building runs only one service. Its service mission checks these flags in order and runs the first one the type sets:

  1. construction yard;
  2. Hospital;
  3. Armory;
  4. UnitRepair;
  5. UnitReload.

The docking check uses a different order and tests UnitRepair before the two infantry flags. A type that is both a depot and a hospital therefore refuses infantry at the door.

Hospital=yes and Armory=yes serve infantry only, and only infantry that the player sends in with the enter cursor. The building must be allied. A hospital offers the cursor to damaged infantry, and an armory to infantry that is not yet elite.

The building admits the infantry under all of, in this order:

  • its house is allied with the infantry’s;
  • it is not under construction, being sold, or still playing its buildup;
  • it is not in contact with anything other than this infantry;
  • it is switched on;
  • the caller is infantry, not a vehicle or an aircraft;
  • its Ammo count is not zero;
  • it is not already serving someone.

Each admission uses up one point of Ammo.

A hospital heals IRepairStep strength per step, at no charge. It takes a step each time its count reaches IRepairRate * 900, counting once per frame. It releases the occupant at maximum strength. An occupant that needs no healing is released at the first count and still uses up its admission.

An armory heals nothing. When its count reaches IRepairRate * 900, it promotes the occupant and releases it. Below-rookie infantry leaves as veteran, and any other infantry leaves as elite. A rookie therefore gains two ranks in one visit, and a veteran gains one. Promotion without kills compares the armory with the other sources of rank. The VeteranAbilities or EliteAbilities of the new rank apply as soon as the occupant leaves.

SelfHealing=yes, or the SELF_HEAL ability from VeteranAbilities or EliteAbilities, makes an object heal itself with no building, order or credits. It works for structures, vehicles, aircraft and infantry.

Three settings decide what a tick does:

Read fromStepIntervalCeiling
The object’s typeSelfHealingStepSelfHealingRateSelfHealingCap
The rulesSelfHealStepSelfHealRateSelfHealCap
Neither1RepairRateConditionYellow

Read each column from the top. A value below zero passes to the row beneath. With none of them set, an object heals one point every 14 frames until it passes half strength. RepairStep and IRepairStep never affect self-healing.

Self-healing steps on frames that are multiples of the interval, so every object on the same interval heals on the same frames. Each tick adds the step and caps the result at maximum strength, so no setting overheals. A step below 1 heals 1 point, and an interval shorter than one frame heals on every frame.

A ceiling of 0 turns self-healing off. A tick needs the object’s strength ratio to be at or below the ceiling. Any object with strength left has a ratio above 0, so it never heals.

SelfHealing=no turns self-healing off unless the object has the SELF_HEAL ability.

An object at zero strength never heals. Only an aircraft can be at zero strength and still in play: one killed in the air keeps flying until it lands. Without this rule it could heal in mid-air and fly on.

Tiberium healing is a separate path. TiberiumHeal=yes on an infantry, vehicle or aircraft type, or the TIBERIUM_HEAL ability, heals the object while its cell contains Tiberium. Height is not checked, so such an aircraft also heals while flying over Tiberium. Structures never heal this way.

The rules key of the same name, TiberiumHeal, sets the interval, 15 frames at the engine default. Each tick restores the type’s repair step: IRepairStep for infantry and RepairStep for vehicles and aircraft, with a minimum of 1. Tiberium healing continues to maximum strength and has no ceiling.

A weapon that deals negative damage, such as a medic’s or a mechanic’s, heals through ordinary damage and uses none of the settings on this page. Each heal also clears the target’s limpet mine and resets its turn rates to the type’s ROT.

A healer’s kind decides what it can heal: infantry heal infantry, and every other healer heals vehicles, including landed aircraft. Mechanic=yes makes infantry heal vehicles instead of infantry, and OmniHealer=yes makes a healer heal both.

The computer decides on each of its buildings in turn. It switches a building’s repair on when these tests pass, in this order:

  1. The owning house’s IQ is at or above RepairSell, and the building is neither under construction nor being sold.
  2. The building is a repair candidate by the same test the wrench uses.
  3. The house’s available money is at or above CreditReserve.
  4. The house has not started a repair since its waiting time last ran out.
  5. The building is not already under repair, and it has been captured, is flagged for repair, or belongs to a human-controlled house.

The repair then runs as an ordinary repair tick, paid from the house’s money. Outside campaign games every computer house has the maximum IQ, so the first test passes whenever RepairSell is at or below MaxIQLevels.

Three things flag a building for repair:

  • outside campaign games, placing any building of a computer house that is not MultiplayPassive=yes;
  • a computer MCV deploying into a construction yard;
  • a map record for the structure that flags it for repair.

After a computer house starts one repair, it waits a random time between RepairDelay * 225 and RepairDelay * 1800 frames before it may start another. At the RepairDelay default that is 4 to 36 frames, so a base’s repairs start one at a time. A human-controlled house has no waiting time and may start another repair on its next update.

When the house’s money is below its credit reserve, the computer considers selling the building instead. After the first two tests above, the sale needs all of, in this order:

  • Any of: the game is not a campaign game, or the structure is marked sellable;
  • the structure has been damaged by something its house is not allied with;
  • the owning house’s tech level is at or above SellBack;
  • a random number from 0 to 50 is below that same tech level;
  • the structure has no trigger tag;
  • its type does not produce buildings;
  • its strength ratio is below ConditionRed.

The random number is drawn again on every frame while the other terms hold, so it delays a sale but does not prevent one.

The sellable mark belongs to the structure, not to its type’s rules. A structure starts marked unless its type has no buildup animation. A structure placed by the map takes the mark from the field after the trigger name in its map record instead, whatever its type’s artwork. A record that leaves the field out gives 0, not sellable. Outside campaign games the mark is never checked.

The sale itself also requires a buildup animation, in every game mode. A type without one is never sold this way, whatever its mark.

A computer house repairs and sells its buildings only through this routine. Rebuilding a destroyed structure is a separate decision.

36 of 36

KeyDescriptionValueWhen omitted
AmmoAircraftType, BuildingType, InfantryType, UnitTypeThe number of shots a runtime instance holds, or the number of visitors a hospital or armory can admit.integer-1
ArmoryBuildingTypeAdmits one infantry at a time and promotes it when the servicing delay elapses.booleanno
ConditionRedglobal rulesThe fraction of maximum strength at or below which an object counts as critically damaged.floating point.5
ConditionYellowglobal rulesThe fraction of maximum strength at or below which an object counts as damaged.floating point.5
Cost6 applicable typesThe credit price of one object of this type, or the multiplier a country or a difficulty applies to every price it pays.integerVaries by type
CreditReserveglobal rulesThe balance a computer house must hold before it will start repairing one of its buildings.integer1000
EliteAbilitiesAircraftType, BuildingType, InfantryType, UnitTypeThe abilities an object of this type gains at elite rank, on top of its veteran abilities.abilities(empty)
HospitalBuildingTypeAdmits one damaged infantry at a time and heals it to full strength.booleanno
IQHouse (per-scenario)A campaign house's intelligence level, which turns on each computer behavior whose threshold it reaches.integer0
IRepairRateglobal rulesThe interval between servicing steps inside a hospital, and an armory's promotion delay.floating point.016
IRepairStepglobal rulesThe strength one repair step restores to an infantry.integer1
ManualReloadAircraftType, BuildingType, InfantryType, UnitTypeHas a service depot refill a vehicle's ammunition for free, and stops firing from starting its reload delay.booleanno
MechanicAircraftType, BuildingType, InfantryType, UnitTypeTurns a healing weapon away from infantry and onto vehicles.booleanno
OmniHealerAircraftType, BuildingType, InfantryType, UnitTypeLets a healing weapon mend infantry and vehicles alike.booleanno
ReloadRateglobal rulesThe interval between the ammunition points a rearming building hands the object docked with it.floating point.05
RepairBayglobal rulesThe BuildingType that a vehicle on the Repair mission, or a damaged computer aircraft, heads for to be repaired.classnone
RepairDelaydifficulty settingsThe wait a computer house takes between starting one building repair and starting the next.floating point.02
RepairPercentglobal rulesThe share of an object's price that a full repair charges.floating point.25
RepairRateglobal rulesThe interval between structure repair steps, and the interval self-healing falls back to.floating point.016
RepairSellglobal rulesThe IQ a house needs before it repairs its damaged structures by itself or sells them when money runs short.integer3
RepairStepglobal rulesThe strength one repair step restores to a structure, vehicle or aircraft.integer5
RepairableAircraftType, BuildingType, InfantryType, UnitTypeAllows a structure to be repaired with the wrench, worked on by an engineer, and treated as a building by a commando.booleanyes
SelfHealCapglobal rulesThe share of maximum strength at which self-healing stops.floating point-1
SelfHealRateglobal rulesThe interval between self-healing ticks.floating point-1
SelfHealStepglobal rulesThe strength one self-healing tick restores.integer1
SelfHealingAircraftType, BuildingType, InfantryType, UnitTypeMends the object a step at a time while it is below its self-healing ceiling.booleanno
SelfHealingCapAircraftType, BuildingType, InfantryType, UnitTypeThe share of maximum strength at which this type stops healing itself.floating point-1
SelfHealingRateAircraftType, BuildingType, InfantryType, UnitTypeThe interval between this type's self-healing ticks.floating point-1
SelfHealingStepAircraftType, BuildingType, InfantryType, UnitTypeThe strength one self-healing tick restores to this type.integer-1
SellBackglobal rulesThe tech level a house must have reached before the computer will sell a building it cannot afford to repair.integer2
StrengthNo effect in some scopes12 applicable typesThe maximum strength of most object types; wall overlays use it as a per-hit damage threshold.integerVaries by type
TiberiumHeal5 applicable typesWhether an object mends itself while standing on Tiberium, and how often every such object is mended.booleanVaries by type
URepairRateglobal rulesThe interval between the repair steps a service depot applies to the vehicle or aircraft docked with it.floating point.016
UnitReloadBuildingTypeMakes the building rearm the object docked with it, one ammunition point at a time.booleanno
UnitRepairBuildingTypeMakes the building take in one vehicle or aircraft at a time and repair it for credits.booleanno
VeteranAbilitiesAircraftType, BuildingType, InfantryType, UnitTypeThe abilities an object of this type gains at veteran rank and keeps at elite.abilities(empty)

History

  1. Changed0.1.0

    Use repair capability for player aircraft actions

  2. Changed0.2.0In development

    Stop vehicles blowing up on a service depot pad

  3. Changed0.2.0In development

    Stop a self-healing aircraft from reviving in mid-air

  4. Changed0.2.0In development

    Give self-healing its own step, interval and ceiling