From 8b56ec2d7781e56f2c39a1c2bc45fcaf79e17743 Mon Sep 17 00:00:00 2001 From: bryanthaboi Date: Thu, 27 Aug 2026 07:39:58 -0400 Subject: [PATCH] big egg energy --- src/core/gen2/Breeding.lua | 6 ++++-- tests/gen2_breeding_test.lua | 10 ++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/core/gen2/Breeding.lua b/src/core/gen2/Breeding.lua index 57db6832..f7d03e16 100644 --- a/src/core/gen2/Breeding.lua +++ b/src/core/gen2/Breeding.lua @@ -1101,8 +1101,10 @@ function Breeding.hatch(data, save, index, nickname, where) hatched.experience = egg.experience -- `ld a, [de] / ld [hli], a` twice: HP := MaxHP. hatched.hp = hatched.maxHp - hatched.ot = egg.ot or (save.player and save.player.name) - hatched.otId = egg.otId or (save.player and save.player.id) + -- HatchEggs overwrites OT unconditionally, so the ODD_EGG's "ODD" and its + -- table id do not survive -- engine/pokemon/breeding.asm:299-309 + hatched.ot = (save.player and save.player.name) or egg.ot + hatched.otId = (save.player and save.player.id) or egg.otId hatched.caughtLevel = egg.level or Breeding.EGG_LEVEL -- SetEggMonCaughtData swaps wCurPartyLevel for CAUGHT_EGG_LEVEL around the -- shared setter -- engine/pokemon/caught_data.asm:235-246. diff --git a/tests/gen2_breeding_test.lua b/tests/gen2_breeding_test.lua index 532512bb..f14c9507 100644 --- a/tests/gen2_breeding_test.lua +++ b/tests/gen2_breeding_test.lua @@ -645,6 +645,16 @@ save = newSave({ eggWith(0) }) hatched = Breeding.hatch(DATA, save, 1, "SPROUT") eq(hatched.nickname, "SPROUT", "a nickname taken from the naming screen sticks") +-- HatchEggs writes wPlayerID / wPlayerName over whatever the egg carried, so +-- the ODD_EGG's "ODD" and its table id do not survive the hatch. +-- engine/pokemon/breeding.asm:299-309 +save = newSave({ eggWith(0) }) +save.party[1].ot = "ODD" +save.party[1].otId = 2048 +hatched = Breeding.hatch(DATA, save, 1) +eq(hatched.ot, "GOLD", "the hatchling's OT becomes the player") +eq(hatched.otId, 1234, "and MON_OT_ID becomes wPlayerID") + eq(#Breeding.readyToHatch(newSave({ eggWith(0), eggWith(2), eggWith(0) })), 2, "readyToHatch names every spent counter")