Docs Quick code
Combat
Status effects (poison, burn, slow, stun, freeze), knockback and floating text from code — with recipes for poison traps, burning swords and boss stuns.
Five functions add action-game moments to any script. They work on the player and on enemies (objects with the Health behavior that move: Chase, Patrol).
| Function | Does |
|---|---|
add_status(target, kind, seconds = 3, power = 0) |
Puts a status on the player or an enemy. |
remove_status(target, kind = "") |
Takes one off ("" = all of them). |
has_status(target, kind = "") |
true while it has that status ("" = any). |
knockback(target, strength = 6, from = nil) |
Pushes it away from from (this object if nil). |
pop_text(where, text, color = "white") |
Floating text that pops, rises and fades. |
target is player, an object (self, object("boss"), nearest("enemy")) or a Script name.
#Status effects
| Kind | What it does | Looks |
|---|---|---|
"poison" |
Loses health over time (3 a second; power changes it) |
Green |
"burn" |
Loses health faster (6 a second) | Orange |
"slow" |
Moves at half speed | Blue |
"stun" |
Can't move or attack | Yellow |
"freeze" |
Frozen solid: can't move or attack | Ice blue |
Putting the same status on again just makes it last longer (the longest wins). Enemies are tinted the status color; the player sees it in the top-left corner (☠ Poisoned).
Without code: the action Add status, a weapon's Hits inflict (Items), and an enemy's Attack inflicts (Chase player).
#Recipes
A poison puddle (on the puddle's script, Event: Player touches it):
add_status(player, "poison", 4)
pop_text(player, "Poisoned!", "green")
A boss that's stunned when it hits a wall (the boss's script, Event: It bumps into something):
if other ~= player then
add_status(self, "stun", 2)
pop_text(self, "Dazed!", "yellow")
end
A freezing blast around the player (a script run by an item):
for e in objects_near(player, 3, "enemy") do
add_status(e, "freeze", 3)
knockback(e, 8, player)
end
play("zap")
Only hit things that aren't already burning:
local foe = nearest("enemy", player)
if foe ~= nil and not has_status(foe, "burn") then
add_status(foe, "burn", 5, 10) -- 10 damage a second
end
#Knockback and floating text
knockback(player, 10) -- away from this object
knockback(object("crate"), 4, player) -- away from the player
pop_text(self, "+25 gold", "gold")
pop_text(player, "Level up!", "#9fffd8")
#Game Settings that go with it
- Player ▸ Safe after a hit: seconds after being hurt when the player takes no damage.
- Player ▸ Dodge roll: Ctrl (or the right stick) dashes, using stamina, safe for a moment.