Skip to content

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::GetHpReturns the fighter's current hit points (0 if the object is not found).
fighter::SetHpSets the fighter's hit points.
fighter::SetLevelSets the fighter's level and experience equal to that level's threshold.
fighter::SetWeaponSkillSets the fighter's skill level with the weapon of this classic_id; adds the skill if there is none.
fighter::AppearThe 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::LockTargetThe fighter attacks only this target (sets ai_mode 1).
fighter::GuardTileThe fighter holds battle tile (x, y) (sets ai_mode 3).
fighter::SetTargetThe fighter's AI attacks the target first (like Grandma attacking her child's killer).
fighter::DamageDeals damage to the fighter immediately, ignoring armor and OnHit (reflected damage is not reflected back).
fighter::GetLastAttackerThe fighter that hit it last, or nil.
fighter::NativeThe 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::AddStateGives 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::IsAliveTrue while the fighter is in battle.
fighter::PopupText popping up above the fighter, like "Miss".
fighter::TransformThe 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

Classic: FighterGetHp

Returns the fighter's current hit points (0 if the object is not found).

fighter::SetHp(string, int) → int

Classic: FighterSetHp

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

Classic: FighterSetLevel

Sets the fighter's level and experience equal to that level's threshold.

fighter::SetWeaponSkill(string, int, int) → int

Classic: FighterSetWeaponSkillLevel

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

Classic: AIEnemyAppear

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

Classic: AITargetLock

The fighter attacks only this target (sets ai_mode 1).

fighter::GuardTile(string, int, int) → int

Classic: AIGuardPoint

The fighter holds battle tile (x, y) (sets ai_mode 3).

fighter::SetTarget(string who, string target) → int

Classic: FighterSetTarget

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

Classic: FighterDamage

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

Classic: FighterGetLastAttacker

The fighter that hit it last, or nil.

fighter::Native(string who, string name) → any

OpenGorky onlyClassic: FighterNative

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

Classic: FighterAddState

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

Classic: FighterSide

"hero", "enemy", "neutral" (an obstacle), "civilian" (on nobody's side) or "" (not in battle).

fighter::IsAlive(string who) → bool

Classic: FighterAlive

True while the fighter is in battle.

fighter::Transform(string who, string into, ?string anim, ?string idle, ?sound sound) → int

Classic: FighterTransform

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.