Field manual / Level editor
OG Script
OG Script is the scripting language of OpenGorky projects: the code of levels, objects, fighters and the game's hooks. Here is the short version.
Where code lives
src/game.ogs: the game's hooks, such asOnDamage(attacker, target, weapon, amount),OnTurnStart(side, turn),OnBattleEnd(won)andOnLevelEnter(level).- Level and object blocks under
src/locations/andsrc/battles/: their events and functions. src/rules/*.ogs: the engine's rules as call rows.- Components: behaviour attached to a fighter, an object or the game.
An example
A level path's code: when a walker passes the plank's first point going forward, it switches to the plank walk, and back to the normal walk at the second point.
level "01_port" {
path deska {
link = [182, 22, 189, 11];
points = [
PathPoint(x = 1460, y = 180, angle = 0.0, z = 135),
PathPoint(x = 1516, y = 92, angle = 0.0, z = 135),
];
fn OnNode(no, dir, walker) {
if (dir == 1 and no == 0) path::SetWalkAnimation("walk_footbridge");
if (dir == 1 and no == 1) path::SetWalkAnimation("walk");
}
}
}
Calling built-ins
Built-in functions live in packages: fighter::SetHp(host, 1). Open a package with use fighter; to write SetHp(host, 1). Where an object name is expected, a reference works too: host, @grandma, attacker. The Classic names (FighterSetHp) stay valid in Classic scripts, and the editor translates between the two.
All packages and their functions: built-in functions.
The full language
Types, components and traits, data blocks, events, scripted abilities, errors and determinism are covered in the OG Script language reference.