Open Route 30 with map trainers and multi-Pokémon trainer battles
Map trainers run the ROM's TalkToTrainerScript and SeenByTrainerScript. _CheckTrainerBattle runs before tile events at the end of each step and on idle ticks; TrainerWalkToPlayer builds wMovementBuffer natively, and writeobjectxy keeps the trainer where it stopped. The interpreter gains the trainer header commands, wRunningTrainerBattleScript and hidden items (HiddenItemScript). Trainers with several Pokémon send out the next one through EnemyPartyMonEntrance and FindMonInOTPartyToSwitchIntoBattle, including its BattleRandom fallback. AI_SwitchOrTryItem, CheckAbleToSwitch and AI_Switch are translated with their original bugs, and wPlayerUsedMoves is recorded. The Shift-mode switch offer, trainer items, Pursuit on a switch, Perish Song and Spikes remain refused. Route 30 and its Berry house are enabled; Mr. Pokémon's house and Route 31 stay closed. A refused trainer sighting does not restart until the player moves, so a rollback cannot trap the player in view. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
0d1bedb3b1
commit
e00dfab42e
18 files changed
+1156
-62
No files matched your search
@@ -0,0 +1,24 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { trainerWalkBuffer } from "../src/game/scripts/interpreter";
|
||||
import { readMovement } from "../src/game/scripts/movement";
|
||||
|
||||
describe("TrainerWalkToPlayer", () => {
|
||||
const decode = (buffer: number[]) => readMovement({ byte: (index) => buffer[index] }, 0);
|
||||
it("only pauses when the player is adjacent", () => {
|
||||
expect(trainerWalkBuffer({ x: 5, y: 5 }, { x: 5, y: 6 }, 1)).toEqual([0x3e, 0x47]);
|
||||
expect(decode([0x3e, 0x47])).toEqual([{ kind: "sleep", ticks: 1 }]);
|
||||
});
|
||||
it("walks all but the last tile toward the player at normal speed", () => {
|
||||
// step DOWN is movement_step | DOWN.
|
||||
expect(trainerWalkBuffer({ x: 1, y: 7 }, { x: 1, y: 10 }, 3)).toEqual([0x3e, 0x0c, 0x0c, 0x47]);
|
||||
expect(trainerWalkBuffer({ x: 9, y: 4 }, { x: 4, y: 4 }, 5)).toEqual([0x3e, 0x0e, 0x0e, 0x0e, 0x0e, 0x47]);
|
||||
expect(trainerWalkBuffer({ x: 2, y: 4 }, { x: 4, y: 4 }, 2)).toEqual([0x3e, 0x0f, 0x47]);
|
||||
expect(decode([0x3e, 0x0d, 0x47])).toEqual([
|
||||
{ kind: "sleep", ticks: 1 },
|
||||
{ kind: "step", direction: "up", ticks: 8, animate: true },
|
||||
]);
|
||||
});
|
||||
it("follows ComputePathToWalkToPlayer off a straight line: the shorter axis first", () => {
|
||||
expect(trainerWalkBuffer({ x: 0, y: 0 }, { x: 3, y: 1 }, 4)).toEqual([0x3e, 0x0c, 0x0f, 0x0f, 0x47]);
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user