> ## Documentation Index
> Fetch the complete documentation index at: https://docs.eucaengine.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MOBA systems

> MOBA is an example game (games/euca-moba) — open it in euca-studio, or build a Dota-style arena from the generic spawn, item, and rule routes. There are no /moba or /hero routes; this page shows how the pieces snap together. Fully headless.

`euca-moba` is a complete MOBA kit — hero attributes (STR/AGI/INT), towers and barracks, creep waves,
Roshan, neutral camps, fog-of-war and wards, day-night — shipped as an **example game** under
`games/euca-moba`, layered on the genre-neutral [gameplay](/systems/gameplay-and-combat),
[units](/systems/heroes), and [inventory](/systems/inventory-and-economy) primitives. Two mental models
to hold:

1. **It is a game, not an API.** Open it in [`euca-studio`](/concepts/the-cli) (`cargo run -p euca-studio`,
   pick the **MOBA** project) and press Play, or serve it headless with
   `cargo run -p euca-studio -- --headless moba` (agent HTTP API on `:3917`, no window). The engine names
   no game; the studio resolves the `moba` project's `app` id to its `Game`.
2. **There are no `/moba/*` or `/hero/*` endpoints.** An arena is assembled from the *generic* spawn,
   item, rule, and gameplay routes plus the MOBA ECS systems that run inside `game.step`. The repo's
   `scripts/moba.sh` builds the whole arena this way over the API — read it as the worked end-to-end
   example.

This page shows the core loop — spawn a unit from components, give it an item, drive scoring with rules —
with output captured from a real headless server.

## Stand up an arena

**1. Spawn a hero unit from components.** A hero is a generic entity composed in one `/spawn` call (see
[Units & roles](/systems/heroes)); the same call the CLI's `entity create` sends. There is no template
or registry — the flags *are* the unit.

```bash theme={null}
curl -s -X POST http://localhost:3917/spawn -H 'Content-Type: application/json' -d '{
  "mesh":"sphere","color":"cyan","position":[-7,0.5,0],"scale":[1.2,1.2,1.2],
  "physics_body":"Kinematic","collider":{"shape":"Sphere","radius":0.6},
  "health":500,"team":1,"combat":true,"combat_damage":30,"combat_range":2,
  "combat_speed":4,"combat_cooldown":0.8,"role":"hero",
  "gold":0,"gold_bounty":300,"xp_bounty":200,"player":true}'
# {"entity_id":103,"entity_generation":0}
```

`scripts/moba.sh` does exactly this for both teams' heroes, plus structures and towers as `--physics
Static` units with `--combat --combat-style stationary --role tower`.

**2. Give the hero an item.** Items are global definitions traded onto entities (see
[Inventory & economy](/systems/inventory-and-economy)). Define one, then give it — `/item/give`
auto-creates the unit's inventory:

```bash theme={null}
curl -s -X POST http://localhost:3917/item/define -H 'Content-Type: application/json' \
  -d '{"id":1,"name":"Iron Branch","properties":{"cost":50,"health":15}}'
# {"ok":true,"message":"Defined item 1: Iron Branch"}

curl -s -X POST http://localhost:3917/item/give \
  -H 'Content-Type: application/json' -d '{"entity_id":103,"item_id":1,"count":1}'
# {"ok":true,"message":"Added 1 of item 1"}
```

**3. Towers, creeps, and scoring are rules + entities.** Towers and barracks are just entities with combat
stats, a `team`, and an `EntityRole::tower`/`structure`; creep waves are driven by timer
[rules](/concepts/rules-as-data); kill bounties and scoring come from `death` rules. `scripts/moba.sh`
sets all of this up over the API:

```bash theme={null}
# (from scripts/moba.sh — creep wave every 20s, score on enemy death)
euca rule create --when timer:20 --do-action "spawn cube -7,0.5,0 blue 80 1 ... minion 3"
euca rule create --when death --filter team:2 --do-action "score source +1"
```

Or load a whole match from one scenario document (see [Build a scene](/guides/build-a-scene)).

## Behavior and gotchas

The things you only find out by running it:

* **There is no `/moba/spawn`, `/moba/match`, `/hero/define`, or `/hero/select`.** Those MOBA-specific
  routes were removed; they 404. The MOBA layer is pure ECS systems plus the generic spawn / item / rule /
  gameplay routes. A hero is one `/spawn` with combat + role flags; a creep is `/spawn` plus a combat role,
  or a timer rule.
* **The full hero kit (mana, abilities, stat growth) is in-game, not over HTTP.** `euca-moba`'s Rust
  `spawn_hero` inserts an `AbilitySet`, `Mana`, and base/growth stats. The generic `/spawn` does not — see
  [Units & roles](/systems/heroes) and [Abilities & status effects](/systems/abilities-and-status-effects).
* **The MOBA systems run inside `game.step`.** `tower_aggro_system`, `neutral_camp_system`, vision/wards,
  and day-night are part of the MOBA game's per-tick schedule, so they advance on every `/step` of the
  headless host without any MOBA-specific endpoint.
* **Serve it with the project id.** `cargo run -p euca-studio -- --headless moba` loads the `moba` project
  under `projects/`. With no id, the first discovered project is served instead.

## Endpoints

The MOBA layer borrows the generic surface — there are **no dedicated `/moba` or `/hero` routes**:

| Method         | Path                                                              | Borrowed for                                                                                                                                       |
| -------------- | ----------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------- |
| `POST`         | `/spawn` · `/entities/{id}/components`                            | Compose heroes, towers, creeps from components ([Units](/systems/heroes))                                                                          |
| `POST` / `GET` | `/item/define` · `/item/give` · `/item/equip` · `/item/list/{id}` | Items, inventory, equipment ([Inventory](/systems/inventory-and-economy))                                                                          |
| `POST` / `GET` | `/ability/*` · `/effect/*`                                        | Status effects (any entity) and ability routes (drive an `AbilitySet`, attached only in Rust — [Abilities](/systems/abilities-and-status-effects)) |
| `POST` / `GET` | `/step` · `/entities/{id}` · `/events`                            | Core tick, read-back, and combat substrate ([Gameplay](/systems/gameplay-and-combat))                                                              |
| `POST`         | `/rule/create`                                                    | Creep-wave timers and kill-bounty scoring ([Rules](/concepts/rules-as-data))                                                                       |

## Status

* **Shipped** — hero attributes (STR/AGI/INT, derived stats), towers and barracks, creep waves, Roshan,
  neutral camps, item actives, fog-of-war and wards, day-night, tower aggro, and gold/XP. Runs as the
  `euca-moba` example game in `euca-studio` (windowed) or headless.
* **Requires** — rendering a match needs a [GPU host](/systems/camera-and-rendering) (the windowed
  studio); the match logic itself is fully headless.

<Card title="The full API" icon="chess-rook" href="/api-reference/introduction" horizontal>
  The spawn, item, gameplay, and ability endpoints used to assemble a MOBA, with schemas.
</Card>
