# Project Trio MOBA foundation

Selected source: https://github.com/project-trio/moba

Pinned commit: `4a394665fe9c25ab6b474e58cbc90ed6c46f0b51`

License: ISC. Copyright 2020 Kyle Coburn. Verified from the downloaded repository's `LICENSE`. The GitHub repository landing page also identifies ISC. Keep `LICENSE-ISC.txt` and the adapter's embedded notice with distributed copies. The exact upstream files are preserved in the source repository under `tools/combat-v17/trio-upstream/`; their SHA256 checksums and pinned GitHub URLs are in `source-manifest.json`.

This is an actual browser MOBA with lane minions, towers/base destruction, hero abilities, skill targeting, projectiles, AOE, fog, and multiplayer simulation. It uses Three.js/Vue for presentation, but the selected gameplay algorithms are JavaScript. It is independently published source, not League of Legends source.

## Deliverable

`trio-moba-foundation.js` is a standalone ES module for the current vanilla Canvas game. It removes Three.js, Vue state, network events, and the source's fixed point coordinate scaling. It adapts these substantive source routines:

| Adapter export | Exact upstream source | Adaptation |
| --- | --- | --- |
| `LanePath` | `src/play/game/entity/unit/mini.js`: `setPath`, `reachedDestination`, `checkTarget`, `updateDestination` | Preserves the pathing/combat/return-to-path state transition and saved waypoint. Accepts a complete array of world-space waypoints, replacing source half-map coordinate mirroring. Stops at the final waypoint. |
| `nearestAttackTarget` | `src/play/game/entity/unit/mini.js`: `getAttackTarget` | Same team/validity-filtered closest-enemy scan. Host callback supplies visibility and protected-structure rules. |
| `stableAttackTarget` | `src/play/game/entity/unit/tower.js`: `getAttackTarget` | Prior target bias, validity/range gate, and closest-candidate scan. Uses a configurable world-pixel switching margin measured from the current target instead of source's scaled acquisition-distance snapshot. `Infinity` keeps a valid target for its entire range. |
| `queueRangeCast`, `resolveRangeCast` | `src/play/game/entity/unit/ship.js`: `trySkill`, `checkQueuedSkill` | Queues ground/unit targets, follows moving target coordinates, moves until range, then attempts cast and preserves or clears movement according to skill data. New explicit expiry/dead-target cancellation and action results let the host retain its controls. |
| `shortestAngle`, `faceTowards` | `src/play/game/util.js`: `radianDistance`; `src/play/game/entity/unit/unit.js`: `angleTo` | Uses the source's floating-point angular wrap and turn-distance clamp. World time is seconds; zero-radian facing is valid. |
| `homingProjectileStep` | `src/play/game/entity/attack/bullet.js`: `updateTarget`, `setDestination`, `move` | Tracks valid unit position, freezes last destination on target loss, and returns an arrival/lost-target result. No target substitution or damage is performed in this module. |
| `stepToDestination` | `src/play/game/entity/unit/movable.js`: `move` | Normalized pixel motion and exact arrival clamp replace source scaled fixed-step vectors. Obstacle collision remains owned by the host. |
| `distanceSquared` | `src/play/game/util.js`: `pointDistance` | Renames coordinates from `px/py` to `x/y`. |

## Integrated runtime

- `dist/moba-foundation.js` imports the licensed adapter, wraps lane waypoints and acceleration, and adds continuous projectile collision.
- `dist/lane-ai.js` uses saved lane paths for minions and stable, visibility-aware targeting for minions and structures. Tower retaliation retains the host game's rules.
- `dist/engine.js` uses normalized arrival and smooth facing for mobile units; nearest and stable target acquisition for ordinary attacks and the A attack-move order; queued approach-and-cast for ground area/barrage skills; and cached-destination homing flight after a target disappears.
- `dist/app.js`, `dist/ability-art.js` and `dist/render.js` expose A attack-move and show the queued ground target while walking into range. Explicit movement, stop, target changes, and death cancel the queue.

These source-derived gameplay algorithms form a new foundation beneath the existing 2D game. The upstream presentation, network stack, maps and art were not ported. The game's obstacle navigation, vision, progression, balance and bot strategies remain host implementations.

The source does **not** provide a robust general pathfinder or collision steering: `Movable.blocked` checks occupancy, movement stops when blocked, and minions override `blocked` with `false`. Keep the current lane geometry/obstacle navigation and collision work. Do not claim full upstream pathfinding reuse.

## Verification

Ran direct Node checks against the exact adapter module for angular wrap and zero facing; target stability, switching margin, and dead-target replacement; saved-waypoint rejoin and route completion; out-of-range cast movement without early casting; and projectile arrival/no overshoot plus continuation to last destination after target loss. All checks passed. The integrated `verify-moba-v17.mjs` and `verify-attack-move-v17.mjs` check actual engine behavior: lane resumption, tower focus, queued casting, cancellation, projectile collisions/lifetime, brush visibility, attack cadence, recovery and resumed movement. The full project regression suite passes; see `QA-v17.md` in the source repository.
