shithub: pokecrystal

Download patch

ref: ead04b3b75c79446a337b5b2c38f2650f22a5f3b
parent: b921226aea7e624655f0d32436638ea3ffd63419
author: PikalaxALT <PikalaxALT@gmail.com>
date: Sun Nov 15 09:59:38 EST 2015

Backup prior to global introduction of PERSONTYPE constants

--- a/constants/map_constants.asm
+++ b/constants/map_constants.asm
@@ -653,3 +653,12 @@
 	const PALETTE_DARK
 
 FIXED_FACING EQU 2
+
+	const_def
+	const PERSONTYPE_SCRIPT
+	const PERSONTYPE_ITEMFRAGMENT
+	const PERSONTYPE_TRAINER
+	const PERSONTYPE_3
+	const PERSONTYPE_4
+	const PERSONTYPE_5
+	const PERSONTYPE_6
--- a/engine/events.asm
+++ b/engine/events.asm
@@ -635,21 +635,23 @@
 	jp [hl]
 
 .nope_bugged
+	; pop bc
 	xor a
 	ret
 
 .pointers
-	dbw 0, .zero
-	dbw 1, .one
-	dbw 2, .two
-	dbw 3, .three
-	dbw 4, .four
-	dbw 5, .five
-	dbw 6, .six
+	dbw PERSONTYPE_SCRIPT, .script
+	dbw PERSONTYPE_ITEMFRAGMENT, .itemfragment
+	dbw PERSONTYPE_TRAINER, .trainer
+	; the remaining four are dummy events
+	dbw PERSONTYPE_3, .three
+	dbw PERSONTYPE_4, .four
+	dbw PERSONTYPE_5, .five
+	dbw PERSONTYPE_6, .six
 	db -1
 ; 96a04
 
-.zero ; 96a04
+.script ; 96a04
 	ld hl, MAPOBJECT_SCRIPT_POINTER
 	add hl, bc
 	ld a, [hli]
@@ -657,11 +659,10 @@
 	ld l, a
 	call GetMapScriptHeaderBank
 	call CallScript
-;	ld a, -1
 	ret
 ; 96a12
 
-.one ; 96a12
+.itemfragment ; 96a12
 	ld hl, MAPOBJECT_SCRIPT_POINTER
 	add hl, bc
 	ld a, [hli]
@@ -671,14 +672,14 @@
 	ld de, EngineBuffer1
 	ld bc, 2
 	call FarCopyBytes
-	ld a, 3
+	ld a, PLAYEREVENT_ITEMBALL
 	scf
 	ret
 ; 96a29
 
-.two ; 96a29
-	call Function3674
-	ld a, 2
+.trainer ; 96a29
+	call TalkToTrainer
+	ld a, PLAYEREVENT_TALKTOTRAINER
 	scf
 	ret
 ; 96a30
@@ -729,16 +730,16 @@
 ; 96a59
 
 .up
-	ld b, UP << 2
+	ld b, OW_UP
 	jr .checkdir
 .down
-	ld b, DOWN << 2
+	ld b, OW_DOWN
 	jr .checkdir
 .right
-	ld b, RIGHT << 2
+	ld b, OW_RIGHT
 	jr .checkdir
 .left
-	ld b, LEFT << 2
+	ld b, OW_LEFT
 	jr .checkdir
 
 .checkdir
--- a/engine/map_objects.asm
+++ b/engine/map_objects.asm
@@ -197,12 +197,12 @@
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
 	bit 0, [hl]
-	jr nz, Function44a3
+	jr nz, SetFacingStanding
 
 	ld hl, OBJECT_FLAGS2
 	add hl, bc
 	bit 6, [hl]
-	jr nz, Function44a3
+	jr nz, SetFacingStanding
 
 	bit 5, [hl]
 	jr nz, Function4448
@@ -215,7 +215,7 @@
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
 	bit 0, [hl]
-	jr nz, Function44a3
+	jr nz, SetFacingStanding
 	; fallthrough
 ; 4448
 
@@ -243,33 +243,33 @@
 ; 445f
 
 Pointers445f: ; 445f
-	dw Function44a3, Function44a3 ; 00
-	dw Function44b5, Function44aa ; 01
-	dw Function44c1, Function44aa ; 02
-	dw Function4508, Function44aa ; 03
-	dw Function4529, Function44aa ; 04
-	dw Function4539, Function44a3 ; 05
+	dw SetFacingStanding, SetFacingStanding ; 00
+	dw Function44b5, SetFacingCurrent ; 01
+	dw Function44c1, SetFacingCurrent ; 02
+	dw Function4508, SetFacingCurrent ; 03
+	dw Function4529, SetFacingCurrent ; 04
+	dw Function4539, SetFacingStanding ; 05
 	dw Function456e, Function456e ; 06
-	dw Function457b, Function44a3 ; 07
+	dw Function457b, SetFacingStanding ; 07
 	dw Function4582, Function4582 ; 08
 	dw Function4589, Function4589 ; 09
 	dw Function4590, Function45a4 ; 0a
-	dw Function45ab, Function44aa ; 0c
+	dw Function45ab, SetFacingCurrent ; 0c
 	dw Function45be, Function45be ; 0b
 	dw Function45c5, Function45c5 ; 0d
-	dw Function45da, Function44a3 ; 0e
-	dw Function45ed, Function44a3 ; 0f
-	dw Function44e4, Function44aa ; 10
+	dw Function45da, SetFacingStanding ; 0e
+	dw Function45ed, SetFacingStanding ; 0f
+	dw Function44e4, SetFacingCurrent ; 10
 ; 44a3
 
-Function44a3: ; 44a3
+SetFacingStanding: ; 44a3
 	ld hl, OBJECT_FACING_STEP
 	add hl, bc
-	ld [hl], -1
+	ld [hl], STANDING
 	ret
 ; 44aa
 
-Function44aa: ; 44aa
+SetFacingCurrent: ; 44aa
 	call GetSpriteDirection
 	or 0 ; useless
 	ld hl, OBJECT_FACING_STEP
@@ -284,7 +284,7 @@
 	ld a, [hl]
 	and 1
 	jr nz, Function44c1
-	jp Function44aa
+	jp SetFacingCurrent
 ; 44c1
 
 Function44c1: ; 44c1
@@ -291,7 +291,8 @@
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
 	bit 3, [hl]
-	jp nz, Function44aa
+	jp nz, SetFacingCurrent
+
 	ld hl, OBJECT_12
 	add hl, bc
 	ld a, [hl]
@@ -298,12 +299,13 @@
 	inc a
 	and %00001111
 	ld [hl], a
+
 	rrca
 	rrca
 	and %00000011
 	ld d, a
 	call GetSpriteDirection
-	or 0
+	or 0 ; useless
 	or d
 	ld hl, OBJECT_FACING_STEP
 	add hl, bc
@@ -315,7 +317,7 @@
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
 	bit 3, [hl]
-	jp nz, Function44aa
+	jp nz, SetFacingCurrent
 	ld hl, OBJECT_12
 	add hl, bc
 	ld a, [hl]
@@ -327,7 +329,7 @@
 	and %00000011
 	ld d, a
 	call GetSpriteDirection
-	or 0
+	or 0 ; useless
 	or d
 	ld hl, OBJECT_FACING_STEP
 	add hl, bc
@@ -339,7 +341,7 @@
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
 	bit 3, [hl]
-	jp nz, Function44aa
+	jp nz, SetFacingCurrent
 	ld hl, OBJECT_12
 	add hl, bc
 	inc [hl]
@@ -350,7 +352,7 @@
 	and %00000011
 	ld d, a
 	call GetSpriteDirection
-	or 0
+	or 0 ; useless
 	or d
 	ld hl, OBJECT_FACING_STEP
 	add hl, bc
@@ -363,7 +365,7 @@
 	ld hl, OBJECT_FACING
 	add hl, bc
 	ld a, [hl]
-	or 0
+	or 0 ; useless
 	ld hl, OBJECT_FACING_STEP
 	add hl, bc
 	ld [hl], a
@@ -372,7 +374,7 @@
 
 Function4539: ; 4539
 	call Function453f
-	jp Function44a3
+	jp SetFacingStanding
 ; 453f
 
 Function453f: ; 453f
@@ -409,7 +411,7 @@
 ; 456a
 
 .Directions ; 456a
-	db DOWN << 2, RIGHT << 2, UP << 2, LEFT << 2
+	db OW_DOWN, OW_RIGHT, OW_UP, OW_LEFT
 ; 456e
 
 Function456e: ; 456e
@@ -562,12 +564,12 @@
 	add hl, bc
 	ld [hl], a
 
-	call Function4661
+	call SetTallGrassFlags
 	ld hl, OBJECT_NEXT_TILE
 	add hl, bc
 	ld a, [hl]
 
-	call Function4679
+	call UselessAndA
 	ret
 ; 462a
 
@@ -593,30 +595,30 @@
 Function463f: ; 463f
 	ld hl, OBJECT_FLAGS2
 	add hl, bc
-	bit 3, [hl]
+	bit 3, [hl] ; is current tile grass?
 	jr z, .ok
 	ld hl, OBJECT_NEXT_TILE
 	add hl, bc
 	ld a, [hl]
-	call Function4661
+	call SetTallGrassFlags
 
 .ok
 	ld hl, OBJECT_NEXT_TILE
 	add hl, bc
 	ld a, [hl]
-	call Function4679
-	ret c
+	call UselessAndA
+	ret c ; never happens
 	ld hl, OBJECT_STANDING_TILE
 	add hl, bc
 	ld a, [hl]
-	call Function4679
+	call UselessAndA
 	ret
 ; 4661
 
-Function4661: ; 4661
+SetTallGrassFlags: ; 4661
 	call CheckSuperTallGrassTile
 	jr z, .set
-	call Function1875
+	call CheckGrassTile
 	jr c, .reset
 
 .set
@@ -632,7 +634,7 @@
 	ret
 ; 4679
 
-Function4679: ; 4679
+UselessAndA: ; 4679
 	and a
 	ret
 ; 467b
@@ -661,7 +663,7 @@
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
 	bit FIXED_FACING, [hl]
-	jr nz, GetStandingTile
+	jr nz, GetNextTile
 
 rept 2
 	add a
@@ -670,8 +672,8 @@
 	ld hl, OBJECT_FACING
 	add hl, bc
 	ld [hl], a
-GetStandingTile: ; 46a6
 
+GetNextTile: ; 46a6
 	call GetStepVector
 
 	ld hl, OBJECT_STEP_DURATION
@@ -852,7 +854,7 @@
 	ret
 ; 4793
 
-JumptoObjectMovementByteIndex: ; 4793
+MovementAnonymousJumptable: ; 4793
 	ld hl, OBJECT_MOVEMENT_BYTE_INDEX
 	add hl, bc
 	ld a, [hl]
@@ -1073,7 +1075,7 @@
 ; 48ac
 
 .Strength: ; 48ac
-	call JumptoObjectMovementByteIndex
+	call MovementAnonymousJumptable
 	dw .Strength_Start
 	dw .Strength_Stop
 ; 48b3
@@ -1120,8 +1122,6 @@
 
 .on_pit
 	call IncrementObjectMovementByteIndex
-	; fallthrough
-; 48f8
 
 .Strength_Stop: ; 48f8
 	ld hl, OBJECT_DIRECTION_WALKING
@@ -1227,7 +1227,7 @@
 ; 4984
 
 .MovementSpinCounterclockwise: ; 4984
-	call JumptoObjectMovementByteIndex
+	call MovementAnonymousJumptable
 	dw .MovementSpinInit
 	dw .MovementSpinRepeat
 	dw .MovementSpinTurnLeft
@@ -1234,7 +1234,7 @@
 ; 498d
 
 .MovementSpinClockwise: ; 498d
-	call JumptoObjectMovementByteIndex
+	call MovementAnonymousJumptable
 	dw .MovementSpinInit
 	dw .MovementSpinRepeat
 	dw .MovementSpinTurnRight
@@ -1243,9 +1243,6 @@
 .MovementSpinInit: ; 4996
 	call Function467b
 	call IncrementObjectMovementByteIndex
-	; fallthrough
-; 499c
-
 .MovementSpinRepeat: ; 499c
 	ld hl, OBJECT_ACTION
 	add hl, bc
@@ -1271,7 +1268,7 @@
 ; 49c0
 
 .DirectionData_Counterclockwise ; 49c0
-	db RIGHT << 2, LEFT << 2, DOWN << 2, UP << 2
+	db OW_RIGHT, OW_LEFT, OW_DOWN, OW_UP
 ; 49c4
 
 .MovementSpinTurnRight: ; 49c4
@@ -1281,7 +1278,7 @@
 ; 49cc
 
 .DirectionData_Clockwise ; 49cc
-	db LEFT << 2, RIGHT << 2, UP << 2, DOWN << 2
+	db OW_LEFT, OW_RIGHT, OW_UP, OW_DOWN
 ; 49d0
 
 .MovementSpinNextFacing: ; 49d0
@@ -1485,16 +1482,19 @@
 
 .RandomWalkContinue: ; 4af0
 	call Function4690
-	call Function6ec1
-	jr c, Function4b17
+	call Function6ec1 ; check whether the object can move in that direction
+	jr c, .NewDuration
+
 	call Function463f
 	ld hl, OBJECT_ACTION
 	add hl, bc
 	ld [hl], PERSON_ACTION_02
+
 	ld hl, wd4cf
 	ld a, [hMapObjectIndexBuffer]
 	cp [hl]
 	jr z, .load_6
+
 	ld hl, OBJECT_STEP_TYPE
 	add hl, bc
 	ld [hl], STEP_TYPE_07
@@ -1506,12 +1506,9 @@
 	ld [hl], STEP_TYPE_06
 	ret
 
-Function4b17: ; 4b17
+.NewDuration: ; 4b17
 	call Function467b
 	call Function462a
-	; fallthrough
-; 4b1d
-
 RandomStepDuration_Slow: ; 4b1d
 	call Random
 	ld a, [hRandomAdd]
@@ -1598,7 +1595,7 @@
 	dec [hl]
 	ret nz
 	call Function4600
-	call GetStandingTile
+	call GetNextTile
 	ld hl, OBJECT_FLAGS2
 	add hl, bc
 	res 3, [hl]
@@ -1655,7 +1652,7 @@
 ; 4bf2
 
 Function4bf2: ; 4bf2
-	call GetStandingTile
+	call GetNextTile
 	ld hl, wPlayerStepFlags
 	set 7, [hl]
 	call IncrementObjectStructField28
@@ -2880,7 +2877,7 @@
 	ld hl, OBJECT_NEXT_TILE
 	add hl, bc
 	ld [hl], a
-	callba Function463f
+	callba Function463f ; no need to farcall
 	ret
 ; 56a3
 
--- a/engine/movement.asm
+++ b/engine/movement.asm
@@ -750,7 +750,7 @@
 	call CheckSuperTallGrassTile
 	jr z, .shake_grass
 
-	call Function1875
+	call CheckGrassTile
 	jr c, .skip_grass
 
 .shake_grass
--- a/home.asm
+++ b/home.asm
@@ -1464,26 +1464,28 @@
 	ld [EngineBuffer2], a
 	ld a, c
 	ld [EngineBuffer3], a
-	jr Function367e
+	jr LoadTrainer_continue
 ; 3674
 
-Function3674:: ; 3674
+TalkToTrainer:: ; 3674
 	ld a, 1
 	ld [EngineBuffer2], a
 	ld a, -1
 	ld [EngineBuffer3], a
 
-Function367e:: ; 367e
+LoadTrainer_continue:: ; 367e
 	call GetMapScriptHeaderBank
 	ld [EngineBuffer1], a
+
 	ld a, [hLastTalked]
 	call GetMapObject
+
 	ld hl, MAPOBJECT_SCRIPT_POINTER
 	add hl, bc
 	ld a, [EngineBuffer1]
 	call GetFarHalfword
-	ld de, wd041
-	ld bc, $000d
+	ld de, wTempTrainerHeader
+	ld bc, wTempTrainerHeaderEnd - wTempTrainerHeader
 	ld a, [EngineBuffer1]
 	call FarCopyBytes
 	xor a
@@ -1537,12 +1539,12 @@
 	cpl
 	inc a
 	ld d, a
-	ld e, UP << 2
+	ld e, OW_UP
 	jr .CheckFacing
 
 .Above
 	ld d, a
-	ld e, DOWN << 2
+	ld e, OW_DOWN
 	jr .CheckFacing
 
 .CheckX
@@ -1555,12 +1557,12 @@
 	cpl
 	inc a
 	ld d, a
-	ld e, LEFT << 2
+	ld e, OW_LEFT
 	jr .CheckFacing
 
 .Left
 	ld d, a
-	ld e, RIGHT << 2
+	ld e, OW_RIGHT
 
 .CheckFacing
 	call GetSpriteDirection
--- a/home/map_objects.asm
+++ b/home/map_objects.asm
@@ -124,7 +124,18 @@
 ; 1875
 
 
-Function1875:: ; 1875
+CheckGrassTile:: ; 1875
+	; and %00110111
+	; cp $10
+	; ret c
+	; cp $30
+	; jr nc, .okay
+	; scf
+	; ret
+	; .okay
+	; xor a
+	; ret
+
 	ld d, a
 	and $f0
 	cp $10
@@ -140,7 +151,7 @@
 	ret z
 	scf
 	ret
-
+; For some reason, the above code is duplicated down here.
 .ok_20
 	ld a, d
 	and 7
--- a/main.asm
+++ b/main.asm
@@ -2123,10 +2123,11 @@
 	ld hl, OBJECT_PALETTE
 	add hl, bc
 	bit 5, [hl]
-	jr z, .asm_6ed9
+	jr z, .not_bit_5
+
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
-	bit 4, [hl]
+	bit 4, [hl] ; lost
 	push hl
 	push bc
 	call Function6f2c
@@ -2133,13 +2134,13 @@
 	pop bc
 	pop hl
 	ret c
-	jr .asm_6ee9
+	jr .resume
 
-.asm_6ed9
+.not_bit_5
 	ld hl, OBJECT_FLAGS1
 	add hl, bc
 	bit 4, [hl]
-	jr nz, .asm_6ee9
+	jr nz, .resume
 	push hl
 	push bc
 	call Function6f07
@@ -2147,9 +2148,9 @@
 	pop hl
 	ret c
 
-.asm_6ee9
+.resume
 	bit 6, [hl]
-	jr nz, .asm_6ef5
+	jr nz, .bit_6
 
 	push hl
 	push bc
@@ -2158,18 +2159,20 @@
 	pop hl
 	ret c
 
-.asm_6ef5
+.bit_6
 	bit 5, [hl]
-	jr nz, .asm_6f05
+	jr nz, .bit_5
 	push hl
 	call Function70a4
 	pop hl
 	ret c
+
 	push hl
 	call Function70ed
 	pop hl
 	ret c
-.asm_6f05
+
+.bit_5
 	and a
 	ret
 ; 6f07
@@ -34881,6 +34884,7 @@
 	ld a, movement_step_sleep_1
 	cp [hl]
 	ret z
+
 	ld [hl], a
 	ld a, 0
 	ld [wd04e], a
--- a/maps/AzaleaGym.asm
+++ b/maps/AzaleaGym.asm
@@ -372,9 +372,9 @@
 .PersonEvents:
 	db 7
 	person_event SPRITE_BUGSY, 7, 5, SPRITEMOVEDATA_SPINRANDOM_SLOW, 0, 0, -1, -1, (1 << 3) | PAL_OW_GREEN, 0, 0, BugsyScript, -1
-	person_event SPRITE_BUG_CATCHER, 3, 5, SPRITEMOVEDATA_SPINRANDOM_FAST, 0, 0, -1, -1, (1 << 3) | PAL_OW_BROWN, 2, 2, TrainerBug_catcherbenny, -1
-	person_event SPRITE_BUG_CATCHER, 8, 8, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_BROWN, 2, 3, TrainerBug_catcherAl, -1
-	person_event SPRITE_BUG_CATCHER, 2, 0, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_BROWN, 2, 3, TrainerBug_catcherJosh, -1
-	person_event SPRITE_TWIN, 10, 4, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, 2, 1, TrainerTwinsAmyandmay1, -1
-	person_event SPRITE_TWIN, 10, 5, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, 2, 1, TrainerTwinsAmyandmay2, -1
+	person_event SPRITE_BUG_CATCHER, 3, 5, SPRITEMOVEDATA_SPINRANDOM_FAST, 0, 0, -1, -1, (1 << 3) | PAL_OW_BROWN, PERSONTYPE_TRAINER, 2, TrainerBug_catcherbenny, -1
+	person_event SPRITE_BUG_CATCHER, 8, 8, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_BROWN, PERSONTYPE_TRAINER, 3, TrainerBug_catcherAl, -1
+	person_event SPRITE_BUG_CATCHER, PERSONTYPE_TRAINER, 0, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_BROWN, PERSONTYPE_TRAINER, 3, TrainerBug_catcherJosh, -1
+	person_event SPRITE_TWIN, 10, 4, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_TRAINER, 1, TrainerTwinsAmyandmay1, -1
+	person_event SPRITE_TWIN, 10, 5, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, PERSONTYPE_TRAINER, 1, TrainerTwinsAmyandmay2, -1
 	person_event SPRITE_GYM_GUY, 13, 7, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_RED, 0, 0, AzaleaGymGuyScript, -1
--- a/maps/IlexForest.asm
+++ b/maps/IlexForest.asm
@@ -950,14 +950,14 @@
 
 .PersonEvents:
 	db 11
-	person_event SPRITE_BIRD, 31, 14, SPRITEMOVEDATA_SPINRANDOM_SLOW, 0, 0, -1, -1, (1 << 3) | PAL_OW_BROWN, 0, 0, BirdScript_0x6eb8f, EVENT_ILEX_FOREST_FARFETCHD
-	person_event SPRITE_YOUNGSTER, 28, 7, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_GREEN, 0, 0, YoungsterScript_0x6eb7b, EVENT_ILEX_FOREST_APPRENTICE
-	person_event SPRITE_BLACK_BELT, 28, 5, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, 0, 0, 0, BlackBeltScript_0x6edae, EVENT_ILEX_FOREST_CHARCOAL_MASTER
-	person_event SPRITE_ROCKER, 14, 15, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, 0, 0, 0, RockerScript_0x6edde, -1
-	person_event SPRITE_POKE_BALL, 32, 20, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, 0, 1, 0, ItemFragment_0x6ee10, EVENT_ILEX_FOREST_REVIVE
-	person_event SPRITE_KURT, 29, 8, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, 0, 0, 0, ObjectEvent, EVENT_ILEX_FOREST_KURT
-	person_event SPRITE_LASS, 24, 3, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, (1 << 3) | PAL_OW_GREEN, 0, 0, LassScript_0x6ee0d, EVENT_ILEX_FOREST_LASS
-	person_event SPRITE_YOUNGSTER, 1, 12, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, (1 << 3) | PAL_OW_GREEN, 2, 0, TrainerBug_catcherWayne, -1
-	person_event SPRITE_POKE_BALL, 17, 9, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, 0, 1, 0, ItemFragment_0x6ee12, EVENT_ILEX_FOREST_X_ATTACK
-	person_event SPRITE_POKE_BALL, 7, 17, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, 0, 1, 0, ItemFragment_0x6ee14, EVENT_ILEX_FOREST_ANTIDOTE
-	person_event SPRITE_POKE_BALL, 1, 27, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, 0, 1, 0, ItemFragment_0x6ee16, EVENT_ILEX_FOREST_ETHER
+	person_event SPRITE_BIRD, 31, 14, SPRITEMOVEDATA_SPINRANDOM_SLOW, 0, 0, -1, -1, (1 << 3) | PAL_OW_BROWN, PERSONTYPE_SCRIPT, 0, BirdScript_0x6eb8f, EVENT_ILEX_FOREST_FARFETCHD
+	person_event SPRITE_YOUNGSTER, 28, 7, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, (1 << 3) | PAL_OW_GREEN, PERSONTYPE_SCRIPT, 0, YoungsterScript_0x6eb7b, EVENT_ILEX_FOREST_APPRENTICE
+	person_event SPRITE_BLACK_BELT, 28, 5, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, 0, PERSONTYPE_SCRIPT, 0, BlackBeltScript_0x6edae, EVENT_ILEX_FOREST_CHARCOAL_MASTER
+	person_event SPRITE_ROCKER, 14, 15, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, 0, PERSONTYPE_SCRIPT, 0, RockerScript_0x6edde, -1
+	person_event SPRITE_POKE_BALL, 32, 20, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, 0, PERSONTYPE_ITEMFRAGMENT, 0, ItemFragment_0x6ee10, EVENT_ILEX_FOREST_REVIVE
+	person_event SPRITE_KURT, 29, 8, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, 0, PERSONTYPE_SCRIPT, 0, ObjectEvent, EVENT_ILEX_FOREST_KURT
+	person_event SPRITE_LASS, 24, 3, SPRITEMOVEDATA_STANDING_RIGHT, 0, 0, -1, -1, (1 << 3) | PAL_OW_GREEN, PERSONTYPE_SCRIPT, 0, LassScript_0x6ee0d, EVENT_ILEX_FOREST_LASS
+	person_event SPRITE_YOUNGSTER, 1, 12, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, (1 << 3) | PAL_OW_GREEN, PERSONTYPE_TRAINER, 0, TrainerBug_catcherWayne, -1
+	person_event SPRITE_POKE_BALL, 17, 9, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, 0, PERSONTYPE_ITEMFRAGMENT, 0, ItemFragment_0x6ee12, EVENT_ILEX_FOREST_X_ATTACK
+	person_event SPRITE_POKE_BALL, 7, 17, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, 0, PERSONTYPE_ITEMFRAGMENT, 0, ItemFragment_0x6ee14, EVENT_ILEX_FOREST_ANTIDOTE
+	person_event SPRITE_POKE_BALL, 1, 27, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, 0, PERSONTYPE_ITEMFRAGMENT, 0, ItemFragment_0x6ee16, EVENT_ILEX_FOREST_ETHER
--- a/wram.asm
+++ b/wram.asm
@@ -1566,6 +1566,7 @@
 
 wd041::
 EngineBuffer4::
+wTempTrainerHeader::
 wTempTrainerEventFlagLo::
 	ds 1
 
@@ -1600,6 +1601,7 @@
 wd04b:: ds 2
 wd04d:: ds 1
 MenuItemsListEnd::
+wTempTrainerHeaderEnd::
 wd04e:: ds 2
 wOaksPkmnTalkPkmnNameBuffer::
 wd050:: ds PKMN_NAME_LENGTH +- 1
@@ -2222,19 +2224,27 @@
 \1Action:: ds 1
 \1Object12:: ds 1
 \1Facing:: ds 1
-\1NextTile:: ds 1 ; collision
-\1StandingTile:: ds 1     ; collision
+\1NextTile:: ds 1     ; collision
+\1StandingTile:: ds 1 ; collision
 \1NextMapX:: ds 1
 \1NextMapY:: ds 1
 \1MapX:: ds 1
 \1MapY:: ds 1
-	ds 3
+\1ObjectInitX:: ds 1
+\1ObjectInitY:: ds 1
+\1Radius:: ds 1
 \1SpriteX:: ds 1
 \1SpriteY:: ds 1
 \1SpriteXOffset:: ds 1
 \1SpriteYOffset:: ds 1
-	ds 6
+\1MovementByteIndex:: ds 1
+\1Object28:: ds 1
+\1Object29:: ds 1
+\1Object30:: ds 1
+\1Object31:: ds 1
+\1Range:: ds 1
 	ds 7
+\1StructEnd::
 ENDM
 
 	object_struct Player
@@ -2250,10 +2260,12 @@
 	object_struct Object10
 	object_struct Object11
 	object_struct Object12
+ObjectStructsEnd::
 
 wd6de::
 	ds $40
 
+MapObjects:: ; d71e
 map_object: MACRO
 \1Object::
 \1ObjectStructID::  ds 1
@@ -2271,7 +2283,6 @@
 	ds 2
 endm
 
-MapObjects:: ; d71e
 	map_object Player
 	map_object Map1
 	map_object Map2
@@ -2288,6 +2299,7 @@
 	map_object Map13
 	map_object Map14
 	map_object Map15
+MapObjectsEnd::
 
 wObjectMasks:: ds NUM_OBJECTS ; d81e
 
@@ -2319,6 +2331,7 @@
 	; 6 - hall of fame
 	; 7 - bug contest on
 	ds 1
+
 StatusFlags2:: ; d84d
 	; 0 - rockets
 	; 1 -