Field manual / Level editor
fighter — Fighter
A single fighter: health, level, skills, AI, damage, states, transformation. OpenGorky-only functions have named parameters (§8.1); outside battle they do nothing and return 0 or nil.
Summary
fighter::GetHp | Returns the fighter's current hit points (0 if the object is not found). |
fighter::SetHp | Sets the fighter's hit points. |
fighter::SetLevel | Sets the fighter's level and experience equal to that level's threshold. |
fighter::SetWeaponSkill | Sets the fighter's skill level with the weapon of this classic_id; adds the skill if there is none. |
fighter::Appear | The enemy is placed on tile (x0, y0), often beyond the edge of the grid, and at the start of battle walks to (x1, y1). |
fighter::LockTarget | The fighter attacks only this target (sets ai_mode 1). |
fighter::GuardTile | The fighter holds battle tile (x, y) (sets ai_mode 3). |
fighter::SetTarget | The fighter's AI attacks the target first (like Grandma attacking her child's killer). |
fighter::Damage | Deals damage to the fighter immediately, ignoring armor and OnHit (reflected damage is not reflected back). |
fighter::GetLastAttacker | The fighter that hit it last, or nil. |
fighter::Native | The fighter's native component with this name ("Guard", "Stand"…) or nil; its parameters are its variables: fighter::Native(host, "Guard").div = 4 changes the defense from that moment on (§13.2). |
fighter::AddState | Gives the fighter a state: "sleep", "freeze", "burn", "gas", "soak", "defend" for turns turns, "rage" for turns actions (default 1). |
fighter::Side | "hero", "enemy", "neutral" (an obstacle), "civilian" (on nobody's side) or "" (not in battle). |
fighter::IsAlive | True while the fighter is in battle. |
fighter::Popup | Text popping up above the fighter, like "Miss". |
fighter::Transform | The fighter transforms into class into — a class key as the rules name it ("ft_hornet"), or a class file (.mtm, .ftr) — the same way as the battle's Transform row: moveLock and attackLock and the glow are removed; after morf_life2 ticks come the new class's values (its init(): hp, max_hp…) and model anim (empty means the class's model), then the idle animation plays once, with sound sound. |
Functions
fighter::GetHp(string) → int
Returns the fighter's current hit points (0 if the object is not found).
fighter::SetHp(string, int) → int
Sets the fighter's hit points. Only an integer is accepted; there is no upper limit. OpenGorky: a call from OG Script in battle is written to the battle log (name: hp set N); a call from Classic is not.
fighter::SetLevel(string, int) → int
Sets the fighter's level and experience equal to that level's threshold.
fighter::SetWeaponSkill(string, int, int) → int
Sets the fighter's skill level with the weapon of this classic_id; adds the skill if there is none.
fighter::Appear(string, int, int, int, int) → int
The enemy is placed on tile (x0, y0), often beyond the edge of the grid, and at the start of battle walks to (x1, y1).
fighter::LockTarget(string, string) → int
The fighter attacks only this target (sets ai_mode 1).
fighter::GuardTile(string, int, int) → int
The fighter holds battle tile (x, y) (sets ai_mode 3).
fighter::SetTarget(string who, string target) → int
The fighter's AI attacks the target first (like Grandma attacking her child's killer).
fighter::Damage(string who, int amount, ?string kind, ?string from) → int
Deals damage to the fighter immediately, ignoring armor and OnHit (reflected damage is not reflected back). from is on whose behalf (that fighter becomes the killer); kind is written to the battle log.
fighter::GetLastAttacker(string who) → any
The fighter that hit it last, or nil.
fighter::Native(string who, string name) → any
The fighter's native component with this name ("Guard", "Stand"…) or nil; its parameters are its variables: fighter::Native(host, "Guard").div = 4 changes the defense from that moment on (§13.2). In and out of battle.
fighter::AddState(string who, string state, ?int turns) → int
Gives the fighter a state: "sleep", "freeze", "burn", "gas", "soak", "defend" for turns turns, "rage" for turns actions (default 1). Returns 1 if done, 0 if there is no such state. Only the counter is set, without the effect's pose, sound and caption.
fighter::Side(string who) → string
"hero", "enemy", "neutral" (an obstacle), "civilian" (on nobody's side) or "" (not in battle).
fighter::IsAlive(string who) → bool
True while the fighter is in battle.
fighter::Popup(string who, string text) → int
Text popping up above the fighter, like "Miss".
fighter::Transform(string who, string into, ?string anim, ?string idle, ?sound sound) → int
The fighter transforms into class into — a class key as the rules name it ("ft_hornet"), or a class file (.mtm, .ftr) — the same way as the battle's Transform row: moveLock and attackLock and the glow are removed; after morf_life2 ticks come the new class's values (its init(): hp, max_hp…) and model anim (empty means the class's model), then the idle animation plays once, with sound sound. The health the fighter has at the end of the transformation (including health set by fighter::SetHp after fighter::Transform) is kept; max_hp and the rest come from the new class. Native and scripted abilities are taken from the Abilities row of the new class: the old scripted abilities that are not in it are detached, new ones are attached, and one present in both stays as it was (with its variables). Returns 1; 0 if there is no such fighter or class.