Otter Snippets Otter Upstream Otter 1.0.1 Tested

Game Actor Combat & Damage

Declare RPG entity state and compute clamped damage with death detection.

ID: snippet/game-actor-damage Version: 1.0.0 License: MIT Framework: Otter 1.0.1

Architecture & Runtime Preview

Otter 1.0.1

Zero-dependency Otter 1.0.1 snippet (Game & Simulation). Copy the parameterized template or run the self-contained example.

  1. 1Category: Game & Simulation
  2. 2Attribution: Otter Reusable Library (Official)
  3. 3Zero external pack dependencies — paste directly into any .ot file

Source Code (2 files)

template.ot · otter
a Entity has
    name
    health
    isAlive
.

to takeDamage entity amount
    cur is health of entity
    newHp is cur minus amount
    if newHp is at most 0
        health of entity is 0
        isAlive of entity is false
        return 0
    .
    health of entity is newHp
    return newHp
.

Installation & Usage

otter snippet inspect game-actor-damage

Copy template.ot directly into your .ot source file, or run example.ot with 'otter run example.ot'.