Spells
trigscript/spells lets a Medic cast Restoration on its own. A unit hit by Lockdown or
Plague near an idle Medic is restored without the player clicking anything.
import { autoRestore } from "trigscript/spells";
autoRestore(); // at the top of the script: on for the whole game
A human player's Medic that stands idle, or is healing on its own after standing idle, casts Restoration on a unit within the spell's range that has Lockdown, Irradiate, Plague, Ensnare, Maelstrom, Acid Spores or Optical Flare. The unit is its owner's, or a player's its owner has set as an ally. Buildings are not restored.
- It is a real cast. The owner must have researched Restoration, and the Medic must
have the spell's energy, plus
keepEnergymore when that is given. The cast looks like a player's and costs the same. - One Medic to a unit. The nearest Medic goes to the nearest afflicted unit. A Medic never walks to reach one: if the unit moves out of range before the cast starts, the Medic stops.
- The player's orders come first. A Medic that is moving, attack-moving, holding, patrolling or casting because the player told it to is never used. Nor is one that could not cast for the player: a Medic in stasis, under Maelstrom, or loaded in a transport or a Bunker.
- Left alone: a unit with only Parasite, a unit in stasis or invincible, and a hallucination (Restoration would kill it). A Medic does not restore itself; another Medic does. Computer players' Medics are left to the computer, which casts Restoration itself.
Tied to a switch, keeping some energy. With switch, auto-restore runs only while
that switch of the map is set, so a campaign map can give it to the player partway
through. The name is one switches. lists: the map's own name for the switch, or
"Switch 1" for one it has not named. A name the map does not have is an error when the
script is built. With keepEnergy, a Medic casts only while it would have that much
energy left afterwards:
import { autoRestore } from "trigscript/spells";
autoRestore({ switch: "Switch 1", keepEnergy: 25 });
Where the call goes. autoRestore() makes a program, so the call goes at the top of a
script, outside program(). Inside program() or a listener it is an error at the call.
Once is enough: a second call, in the same file or another, adds nothing, and its options
are not used.
| Name | What it does |
|---|---|
autoRestore(options?) |
Turn auto-restore on. Options: switch (a switch's name; it runs only while that switch is set) and keepEnergy (energy a Medic keeps after casting, 0 when left out). At the top of a script only. |