-
Notifications
You must be signed in to change notification settings - Fork 2
Tutorial 05 New Move
Goal. Add a damaging special move with a custom secondary effect and a sound.
Prerequisites. Tutorial 04;
Reference: Registries (moves, move_effects).
Files created.
mods/tutorial_05_move/
├── manifest.json
└── main.lua
-
Register the effect first. Move effects are records the battle engine dispatches on — vanilla's own effects are registrations in the same registry (
src/battle/MoveEffects.lua):return function(mod) mod.content.move_effects:register("MODBEAM_EFFECT", { kind = "secondary", run = function(ctx) -- ~1 in 3: drop the target's defense a stage if ctx.rng(0, 255) < 85 then ctx.changeStage(ctx.target, "defense", -1) end end, }) end
kindis"primary"(replaces the damage step),"secondary"(runs after damage lands), or"full"(steered from inside the damage pipeline). Thectxfacade is the supported surface:ctx.user,ctx.target,ctx.move,ctx.rng,ctx.say(text),ctx.anim(name),ctx.damage(who, amount),ctx.inflict(who, statusId, opts),ctx.changeStage(who, stat, delta)— everything else in the battle state is engine-internal and may break. Outcome:modkit validateaccepts the record. -
Register the move.
mod.content.moves:register("MODBEAM", { id = "MODBEAM", name = "MODBEAM", type = "PSYCHIC_TYPE", category = "special", power = 80, accuracy = 90, pp = 10, effect = "MODBEAM_EFFECT", })
categorystates the physical/special/status split explicitly instead of relying on the Gen 1 type-based guess. Note the type id: the psychic type isPSYCHIC_TYPE(the move named PSYCHIC owns the bare name). Outcome: the move validates, and itseffectreference resolves in the post-merge pass. -
Teach it. Give your species from tutorial 03 the move, or patch a vanilla learnset with a wrapper:
mod.content.pokemon:patch("ABRA", { learnset = { __append = { { level = 10, move = "MODBEAM" } } }, })
Outcome: Abra learns MODBEAM at 10 and it deals special-side damage in battle; roughly one hit in three drops defense.
-
Give it a sound. Register an
sfxdef and name it from the move'sanimfield, or simply reuse a vanilla battle animation id. Sound defs are shape-dispatched —{ file = ... }for an audio file, a chip program for authenticity (Audio Authoring).
MODBEAM lands special-category damage (check against a high-Defense, low-Special target), and the defense drop message appears across several uses. Disable the mod: Abra's learnset and the move list are vanilla.
-
Omitting
category. The engine falls back to the type-based Gen 1 split; be explicit so a later type addition cannot reclassify your move. -
Touching
BattleStateinternals fromrun. Thectxfacade is the promise; raw battle fields are not. A handler that throws is pcall-isolated and logged against your mod — the battle continues. -
Effect id collisions.
registeron an existing effect id (SLEEP_EFFECT, ...) collides with the engine's own registration; use a new id, oroverridedeliberately.
Engine 1.0.0 · mod API 2 · repository · Discord
This project ships no ROM data. All game content is decoded on the player's machine from their own verified Pokemon Red ROM; mods ship recipes and original assets, never extracted content.
Start here
Concepts
Tutorials
- The ladder
- 01 Sprite and Text Tweak
- 02 Balance Patch
- 03 New Species
- 04 New Item and Ball
- 05 New Move
- 06 NPC and Dialogue
- 07 New Map
- 08 Quest
- 09 Custom Music
- 10 New Mechanic
- 11 Custom UI Screen
- 12 Mini Total Conversion
Reference
Guides
Playing