code:
VictoryRoad_B2F_MapScripts:: @ 82368D4
	.byte 0

VictoryRoad_B2F_EventScript_Vito:: @ 82368D5
	trainerbattle_single TRAINER_VITO, VictoryRoad_B2F_Text_VitoIntro, VictoryRoad_B2F_Text_VitoDefeat
	msgbox VictoryRoad_B2F_Text_VitoPostBattle, MSGBOX_AUTOCLOSE
	end

VictoryRoad_B2F_EventScript_Owen:: @ 82368EC
	trainerbattle_single TRAINER_OWEN, VictoryRoad_B2F_Text_OwenIntro, VictoryRoad_B2F_Text_OwenDefeat
	msgbox VictoryRoad_B2F_Text_OwenPostBattle, MSGBOX_AUTOCLOSE
	end

VictoryRoad_B2F_EventScript_Caroline:: @ 8236903
	trainerbattle_single TRAINER_CAROLINE, VictoryRoad_B2F_Text_CarolineIntro, VictoryRoad_B2F_Text_CarolineDefeat
	msgbox VictoryRoad_B2F_Text_CarolinePostBattle, MSGBOX_AUTOCLOSE
	end

VictoryRoad_B2F_EventScript_Julie:: @ 823691A
	trainerbattle_single TRAINER_JULIE, VictoryRoad_B2F_Text_JulieIntro, VictoryRoad_B2F_Text_JulieDefeat
	msgbox VictoryRoad_B2F_Text_JuliePostBattle, MSGBOX_AUTOCLOSE
	end

VictoryRoad_B2F_EventScript_Felix:: @ 8236931
	trainerbattle_single TRAINER_FELIX, VictoryRoad_B2F_Text_FelixIntro, VictoryRoad_B2F_Text_FelixDefeat
	msgbox VictoryRoad_B2F_Text_FelixPostBattle, MSGBOX_AUTOCLOSE
	end

VictoryRoad_B2F_EventScript_Dianne:: @ 8236948
	trainerbattle_single TRAINER_DIANNE, VictoryRoad_B2F_Text_DianneIntro, VictoryRoad_B2F_Text_DianneDefeat
	msgbox VictoryRoad_B2F_Text_DiannePostBattle, MSGBOX_AUTOCLOSE
	end

VictoryRoad_B2F_Text_VitoIntro: @ 823695F
	.string "I trained together with my whole family,\n"
	.string "every one of us!\l"
	.string "I'm not losing to anyone!$"

VictoryRoad_B2F_Text_VitoDefeat: @ 82369B3
	.string "Better than my family?!\n"
	.string "Is that possible?!$"

VictoryRoad_B2F_Text_VitoPostBattle: @ 82369DE
	.string "I was better than everyone in my\n"
	.string "family. I've never lost before…\p"
	.string "I've lost my confidence…\n"
	.string "Maybe I'll go home…$"

VictoryRoad_B2F_Text_OwenIntro: @ 8236A4C
	.string "I'd heard that there was a tough\n"
	.string "little kid around. Do they mean you?$"

VictoryRoad_B2F_Text_OwenDefeat: @ 8236A92
	.string "The little shrimp is tough!$"

VictoryRoad_B2F_Text_OwenPostBattle: @ 8236AAE
	.string "The rumors I heard, that tough little\n"
	.string "kid is from PETALBURG CITY.$"

VictoryRoad_B2F_Text_CarolineIntro: @ 8236AF0
	.string "You must be getting a little tired.$"

VictoryRoad_B2F_Text_CarolineDefeat: @ 8236B14
	.string "No signs of tiring at all!$"

VictoryRoad_B2F_Text_CarolinePostBattle: @ 8236B2F
	.string "VICTORY ROAD and the POKéMON LEAGUE\n"
	.string "are long and grueling challenges.\l"
	.string "Beware of fatigue!$"

VictoryRoad_B2F_Text_JulieIntro: @ 8236B88
	.string "You shouldn't get complacent just\n"
	.string "because you have a lot of GYM BADGES.\p"
	.string "There's always going to be someone\n"
	.string "who's better than you!$"

VictoryRoad_B2F_Text_JulieDefeat: @ 8236C0A
	.string "You're better than me!$"

VictoryRoad_B2F_Text_JuliePostBattle: @ 8236C21
	.string "Gaze on your collected BADGES and\n"
	.string "remember the TRAINERS you've faced.$"

VictoryRoad_B2F_Text_FelixIntro: @ 8236C67
	.string "I've come this far, but the tension's\n"
	.string "giving me awful stomach pain…$"

VictoryRoad_B2F_Text_FelixDefeat: @ 8236CAB
	.string "Ooh…\n"
	.string "It hurts…$"

VictoryRoad_B2F_Text_FelixPostBattle: @ 8236CBA
	.string "I can't help getting all tense knowing\n"
	.string "that I'm nearing the POKéMON LEAGUE.\p"
	.string "It's all I can do to feign calm.$"

VictoryRoad_B2F_Text_DianneIntro: @ 8236D27
	.string "The elite among the elite gather in\n"
	.string "this cave.\p"
	.string "How are you finding it?$"

VictoryRoad_B2F_Text_DianneDefeat: @ 8236D6E
	.string "Not rattled in the least bit!$"

VictoryRoad_B2F_Text_DiannePostBattle: @ 8236D8C
	.string "You do have guts! I like that!\n"
	.string "Keep it going!$"


code:
	.section .rodata

gMultiBootProgram_PokemonColosseum_Start:: @ 89AA144
	.incbin "data/pokemon_colosseum.mb"
gMultiBootProgram_PokemonColosseum_End::

repo_name: Lunos/pokeemerald

license: mit


code:
#include "constants/global.h"
#include "constants/flags.h"
#include "constants/items.h"
#include "constants/map_scripts.h"
#include "constants/mevent.h"
#include "constants/moves.h"
#include "constants/region_map_sections.h"
#include "constants/songs.h"
#include "constants/species.h"
#include "constants/vars.h"
	.include "asm/macros.inc"
	.include "asm/macros/event.inc"
	.include "constants/constants.inc"

	.section .rodata

	.align 2
	.include "data/scripts/mevent_stamp_card.inc"
	.include "data/scripts/mevent_pichu.inc"
	.include "data/scripts/mevent_trainer.inc"
	.include "data/scripts/mevent_battle_card.inc"
	.include "data/scripts/mevent_aurora_ticket.inc"
	.include "data/scripts/mevent_mystic_ticket.inc"
	.include "data/scripts/mevent_altering_cave.inc"
	.include "data/scripts/mevent_old_sea_map.inc"


code:
	.section script_data, "aw", %progbits

	.align 2
gMysteryEventScriptCmdTable:: @ 82DED2C
	.4byte MEScrCmd_nop                 @ 0x00
	.4byte MEScrCmd_checkcompat         @ 0x01
	.4byte MEScrCmd_end                 @ 0x02
	.4byte MEScrCmd_setmsg              @ 0x03
	.4byte MEScrCmd_setstatus           @ 0x04
	.4byte MEScrCmd_runscript           @ 0x05
	.4byte MEScrCmd_initramscript       @ 0x06
	.4byte MEScrCmd_setenigmaberry      @ 0x07
	.4byte MEScrCmd_giveribbon          @ 0x08
	.4byte MEScrCmd_givenationaldex     @ 0x09
	.4byte MEScrCmd_addrareword         @ 0x0a
	.4byte MEScrCmd_setrecordmixinggift @ 0x0b
	.4byte MEScrCmd_givepokemon         @ 0x0c
	.4byte MEScrCmd_addtrainer          @ 0x0d
	.4byte MEScrCmd_enableresetrtc      @ 0x0e
	.4byte MEScrCmd_checksum            @ 0x0f
	.4byte MEScrCmd_crc                 @ 0x10
gMysteryEventScriptCmdTableEnd::


code:
	.align 2
gScriptCmdTable:: @ 81DB67C
	.4byte ScrCmd_nop      	                @ 0x00
	.4byte ScrCmd_nop1                      @ 0x01
	.4byte ScrCmd_end      	                @ 0x02
	.4byte ScrCmd_return                    @ 0x03
	.4byte ScrCmd_call                      @ 0x04
	.4byte ScrCmd_goto                      @ 0x05
	.4byte ScrCmd_goto_if                   @ 0x06
	.4byte ScrCmd_call_if                   @ 0x07
	.4byte ScrCmd_gotostd                   @ 0x08
	.4byte ScrCmd_callstd                   @ 0x09
	.4byte ScrCmd_gotostd_if                @ 0x0a
	.4byte ScrCmd_callstd_if                @ 0x0b
	.4byte ScrCmd_returnram                 @ 0x0c
	.4byte ScrCmd_killscript                @ 0x0d
	.4byte ScrCmd_setmysteryeventstatus     @ 0x0e
	.4byte ScrCmd_loadword                  @ 0x0f
	.4byte ScrCmd_loadbyte                  @ 0x10
	.4byte ScrCmd_writebytetoaddr           @ 0x11
	.4byte ScrCmd_loadbytefromaddr          @ 0x12
	.4byte ScrCmd_setptrbyte                @ 0x13
	.4byte ScrCmd_copylocal                 @ 0x14
	.4byte ScrCmd_copybyte                  @ 0x15
	.4byte ScrCmd_setvar                    @ 0x16
	.4byte ScrCmd_addvar                    @ 0x17
	.4byte ScrCmd_subvar                    @ 0x18
	.4byte ScrCmd_copyvar                   @ 0x19
	.4byte ScrCmd_setorcopyvar              @ 0x1a
	.4byte ScrCmd_compare_local_to_local    @ 0x1b
	.4byte ScrCmd_compare_local_to_value    @ 0x1c
	.4byte ScrCmd_compare_local_to_addr     @ 0x1d
	.4byte ScrCmd_compare_addr_to_local     @ 0x1e
	.4byte ScrCmd_compare_addr_to_value     @ 0x1f
	.4byte ScrCmd_compare_addr_to_addr      @ 0x20
	.4byte ScrCmd_compare_var_to_value      @ 0x21
	.4byte ScrCmd_compare_var_to_var        @ 0x22
	.4byte ScrCmd_callnative                @ 0x23
	.4byte ScrCmd_gotonative                @ 0x24
	.4byte ScrCmd_special                   @ 0x25
	.4byte ScrCmd_specialvar                @ 0x26
	.4byte ScrCmd_waitstate                 @ 0x27
	.4byte ScrCmd_delay                     @ 0x28
	.4byte ScrCmd_setflag                   @ 0x29
	.4byte ScrCmd_clearflag                 @ 0x2a
	.4byte ScrCmd_checkflag                 @ 0x2b
	.4byte ScrCmd_initclock                 @ 0x2c
	.4byte ScrCmd_dotimebasedevents         @ 0x2d
	.4byte ScrCmd_gettime                   @ 0x2e
	.4byte ScrCmd_playse                    @ 0x2f
	.4byte ScrCmd_waitse                    @ 0x30
	.4byte ScrCmd_playfanfare               @ 0x31
	.4byte ScrCmd_waitfanfare               @ 0x32
	.4byte ScrCmd_playbgm                   @ 0x33
	.4byte ScrCmd_savebgm                   @ 0x34
	.4byte ScrCmd_fadedefaultbgm            @ 0x35
	.4byte ScrCmd_fadenewbgm                @ 0x36
	.4byte ScrCmd_fadeoutbgm                @ 0x37
	.4byte ScrCmd_fadeinbgm                 @ 0x38
	.4byte ScrCmd_warp                      @ 0x39
	.4byte ScrCmd_warpsilent                @ 0x3a
	.4byte ScrCmd_warpdoor                  @ 0x3b
	.4byte ScrCmd_warphole                  @ 0x3c
	.4byte ScrCmd_warpteleport              @ 0x3d
	.4byte ScrCmd_setwarp                   @ 0x3e
	.4byte ScrCmd_setdynamicwarp            @ 0x3f
	.4byte ScrCmd_setdivewarp               @ 0x40
	.4byte ScrCmd_setholewarp               @ 0x41
	.4byte ScrCmd_getplayerxy               @ 0x42
	.4byte ScrCmd_getpartysize              @ 0x43
	.4byte ScrCmd_additem                   @ 0x44
	.4byte ScrCmd_removeitem                @ 0x45
	.4byte ScrCmd_checkitemspace            @ 0x46
	.4byte ScrCmd_checkitem                 @ 0x47
	.4byte ScrCmd_checkitemtype             @ 0x48
	.4byte ScrCmd_addpcitem                 @ 0x49
	.4byte ScrCmd_checkpcitem               @ 0x4a
	.4byte ScrCmd_adddecoration             @ 0x4b
	.4byte ScrCmd_removedecoration          @ 0x4c
	.4byte ScrCmd_checkdecor                @ 0x4d
	.4byte ScrCmd_checkdecorspace           @ 0x4e
	.4byte ScrCmd_applymovement             @ 0x4f
	.4byte ScrCmd_applymovement_at          @ 0x50
	.4byte ScrCmd_waitmovement              @ 0x51
	.4byte ScrCmd_waitmovement_at           @ 0x52
	.4byte ScrCmd_removeobject              @ 0x53
	.4byte ScrCmd_removeobject_at           @ 0x54
	.4byte ScrCmd_addobject                 @ 0x55
	.4byte ScrCmd_addobject_at              @ 0x56
	.4byte ScrCmd_setobjectxy               @ 0x57
	.4byte ScrCmd_showobject_at             @ 0x58
	.4byte ScrCmd_hideobject_at             @ 0x59
	.4byte ScrCmd_faceplayer                @ 0x5a
	.4byte ScrCmd_turnobject                @ 0x5b
	.4byte ScrCmd_trainerbattle             @ 0x5c
	.4byte ScrCmd_dotrainerbattle           @ 0x5d
	.4byte ScrCmd_gotopostbattlescript      @ 0x5e
	.4byte ScrCmd_gotobeatenscript          @ 0x5f
	.4byte ScrCmd_checktrainerflag          @ 0x60
	.4byte ScrCmd_settrainerflag            @ 0x61
	.4byte ScrCmd_cleartrainerflag          @ 0x62
	.4byte ScrCmd_setobjectxyperm           @ 0x63
	.4byte ScrCmd_copyobjectxytoperm        @ 0x64
	.4byte ScrCmd_setobjectmovementtype     @ 0x65
	.4byte ScrCmd_waitmessage               @ 0x66
	.4byte ScrCmd_message                   @ 0x67
	.4byte ScrCmd_closemessage              @ 0x68
	.4byte ScrCmd_lockall                   @ 0x69
	.4byte ScrCmd_lock                      @ 0x6a
	.4byte ScrCmd_releaseall                @ 0x6b
	.4byte ScrCmd_release                   @ 0x6c
	.4byte ScrCmd_waitbuttonpress           @ 0x6d
	.4byte ScrCmd_yesnobox                  @ 0x6e
	.4byte ScrCmd_multichoice               @ 0x6f
	.4byte ScrCmd_multichoicedefault        @ 0x70
	.4byte ScrCmd_multichoicegrid           @ 0x71
	.4byte ScrCmd_drawbox                   @ 0x72
	.4byte ScrCmd_erasebox                  @ 0x73
	.4byte ScrCmd_drawboxtext               @ 0x74
	.4byte ScrCmd_showmonpic                @ 0x75
	.4byte ScrCmd_hidemonpic                @ 0x76
	.4byte ScrCmd_showcontestwinner         @ 0x77
	.4byte ScrCmd_braillemessage            @ 0x78
	.4byte ScrCmd_givemon                   @ 0x79
	.4byte ScrCmd_giveegg                   @ 0x7a
	.4byte ScrCmd_setmonmove                @ 0x7b
	.4byte ScrCmd_checkpartymove            @ 0x7c
	.4byte ScrCmd_bufferspeciesname         @ 0x7d
	.4byte ScrCmd_bufferleadmonspeciesname  @ 0x7e
	.4byte ScrCmd_bufferpartymonnick        @ 0x7f
	.4byte ScrCmd_bufferitemname            @ 0x80
	.4byte ScrCmd_bufferdecorationname      @ 0x81
	.4byte ScrCmd_buffermovename            @ 0x82
	.4byte ScrCmd_buffernumberstring        @ 0x83
	.4byte ScrCmd_bufferstdstring           @ 0x84
	.4byte ScrCmd_bufferstring              @ 0x85
	.4byte ScrCmd_pokemart                  @ 0x86
	.4byte ScrCmd_pokemartdecoration        @ 0x87
	.4byte ScrCmd_pokemartdecoration2       @ 0x88
	.4byte ScrCmd_playslotmachine           @ 0x89
	.4byte ScrCmd_setberrytree              @ 0x8a
	.4byte ScrCmd_choosecontestmon          @ 0x8b
	.4byte ScrCmd_startcontest              @ 0x8c
	.4byte ScrCmd_showcontestresults        @ 0x8d
	.4byte ScrCmd_contestlinktransfer       @ 0x8e
	.4byte ScrCmd_random                    @ 0x8f
	.4byte ScrCmd_addmoney                  @ 0x90
	.4byte ScrCmd_removemoney               @ 0x91
	.4byte ScrCmd_checkmoney                @ 0x92
	.4byte ScrCmd_showmoneybox              @ 0x93
	.4byte ScrCmd_hidemoneybox              @ 0x94
	.4byte ScrCmd_updatemoneybox            @ 0x95
	.4byte ScrCmd_getpricereduction         @ 0x96
	.4byte ScrCmd_fadescreen                @ 0x97
	.4byte ScrCmd_fadescreenspeed           @ 0x98
	.4byte ScrCmd_setflashradius            @ 0x99
	.4byte ScrCmd_animateflash              @ 0x9a
	.4byte ScrCmd_messageautoscroll         @ 0x9b
	.4byte ScrCmd_dofieldeffect             @ 0x9c
	.4byte ScrCmd_setfieldeffectarg         @ 0x9d
	.4byte ScrCmd_waitfieldeffect           @ 0x9e
	.4byte ScrCmd_setrespawn                @ 0x9f
	.4byte ScrCmd_checkplayergender         @ 0xa0
	.4byte ScrCmd_playmoncry                @ 0xa1
	.4byte ScrCmd_setmetatile               @ 0xa2
	.4byte ScrCmd_resetweather              @ 0xa3
	.4byte ScrCmd_setweather                @ 0xa4
	.4byte ScrCmd_doweather                 @ 0xa5
	.4byte ScrCmd_setstepcallback           @ 0xa6
	.4byte ScrCmd_setmaplayoutindex         @ 0xa7
	.4byte ScrCmd_setobjectpriority         @ 0xa8
	.4byte ScrCmd_resetobjectpriority       @ 0xa9
	.4byte ScrCmd_createvobject             @ 0xaa
	.4byte ScrCmd_turnvobject               @ 0xab
	.4byte ScrCmd_opendoor                  @ 0xac
	.4byte ScrCmd_closedoor                 @ 0xad
	.4byte ScrCmd_waitdooranim              @ 0xae
	.4byte ScrCmd_setdooropen               @ 0xaf
	.4byte ScrCmd_setdoorclosed             @ 0xb0
	.4byte ScrCmd_addelevmenuitem           @ 0xb1
	.4byte ScrCmd_showelevmenu              @ 0xb2
	.4byte ScrCmd_checkcoins                @ 0xb3
	.4byte ScrCmd_addcoins                  @ 0xb4
	.4byte ScrCmd_removecoins               @ 0xb5
	.4byte ScrCmd_setwildbattle             @ 0xb6
	.4byte ScrCmd_dowildbattle              @ 0xb7
	.4byte ScrCmd_setvaddress               @ 0xb8
	.4byte ScrCmd_vgoto                     @ 0xb9
	.4byte ScrCmd_vcall                     @ 0xba
	.4byte ScrCmd_vgoto_if                  @ 0xbb
	.4byte ScrCmd_vcall_if                  @ 0xbc
	.4byte ScrCmd_vmessage                  @ 0xbd
	.4byte ScrCmd_vloadword                 @ 0xbe
	.4byte ScrCmd_vbufferstring             @ 0xbf
	.4byte ScrCmd_showcoinsbox              @ 0xc0
	.4byte ScrCmd_hidecoinsbox              @ 0xc1
	.4byte ScrCmd_updatecoinsbox            @ 0xc2
	.4byte ScrCmd_incrementgamestat         @ 0xc3
	.4byte ScrCmd_setescapewarp             @ 0xc4
	.4byte ScrCmd_waitmoncry                @ 0xc5
	.4byte ScrCmd_bufferboxname             @ 0xc6
	.4byte ScrCmd_nop1                      @ 0xc7
	.4byte ScrCmd_nop1                      @ 0xc8
	.4byte ScrCmd_nop1                      @ 0xc9
	.4byte ScrCmd_nop1                      @ 0xca
	.4byte ScrCmd_nop1                      @ 0xcb
	.4byte ScrCmd_nop1                      @ 0xcc
	.4byte ScrCmd_setmonobedient            @ 0xcd
	.4byte ScrCmd_checkmonobedience         @ 0xce
	.4byte ScrCmd_gotoram                   @ 0xcf
	.4byte ScrCmd_nop1                      @ 0xd0
	.4byte ScrCmd_warpD1                    @ 0xd1
	.4byte ScrCmd_setmonmetlocation         @ 0xd2
	.4byte ScrCmd_moverotatingtileobjects   @ 0xd3
	.4byte ScrCmd_turnrotatingtileobjects   @ 0xd4
	.4byte ScrCmd_initrotatingtilepuzzle    @ 0xd5
	.4byte ScrCmd_freerotatingtilepuzzle    @ 0xd6
	.4byte ScrCmd_warpmossdeepgym           @ 0xd7
	.4byte ScrCmd_cmdD8                     @ 0xd8
	.4byte ScrCmd_cmdD9                     @ 0xd9
	.4byte ScrCmd_closebraillemessage       @ 0xda
	.4byte ScrCmd_cmdDB                     @ 0xdb
	.4byte ScrCmd_fadescreenswapbuffers     @ 0xdc
	.4byte ScrCmd_buffertrainerclassname    @ 0xdd
	.4byte ScrCmd_buffertrainername         @ 0xde
	.4byte ScrCmd_pokenavcall               @ 0xdf
	.4byte ScrCmd_warpsootopolislegend      @ 0xe0
	.4byte ScrCmd_buffercontesttype         @ 0xe1
	.4byte ScrCmd_bufferitemnameplural      @ 0xe2

gScriptCmdTableEnd:: @ 81DBA08
	.4byte ScrCmd_nop


code:
AbnormalWeather_EventScript_PlaceTilesRoute114North:: @ 8273913
	setmetatile 7, 3, METATILE_Fallarbor_RedCaveEntrance_Top, 1
	setmetatile 7, 4, METATILE_Fallarbor_RedCaveEntrance_Bottom, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute114South:: @ 8273926
	setmetatile 6, 45, METATILE_Fallarbor_BrownCaveEntrance_Top, 1
	setmetatile 6, 46, METATILE_Fallarbor_BrownCaveEntrance_Bottom, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute115West:: @ 8273939
	setmetatile 21, 5, METATILE_Fallarbor_BrownCaveEntrance_Top, 1
	setmetatile 21, 6, METATILE_Fallarbor_BrownCaveEntrance_Bottom, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute115East:: @ 827394C
	setmetatile 36, 9, METATILE_Fallarbor_BrownCaveEntrance_Top, 1
	setmetatile 36, 10, METATILE_Fallarbor_BrownCaveEntrance_Bottom, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute116North:: @ 827395F
	setmetatile 59, 12, METATILE_General_CaveEntrance_Top, 1
	setmetatile 59, 13, METATILE_General_CaveEntrance_Bottom, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute116South:: @ 8273972
	setmetatile 79, 5, METATILE_General_CaveEntrance_Top, 1
	setmetatile 79, 6, METATILE_General_CaveEntrance_Bottom, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute118East:: @ 8273985
	setmetatile 42, 5, METATILE_General_CaveEntrance_Top, 1
	setmetatile 42, 6, METATILE_General_CaveEntrance_Bottom, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute118West:: @ 8273998
	setmetatile 9, 5, METATILE_General_CaveEntrance_Top, 1
	setmetatile 9, 6, METATILE_General_CaveEntrance_Bottom, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute105North:: @ 82739AB
	setmetatile 10, 28, METATILE_General_RoughWater, 0
	setmetatile 11, 28, METATILE_General_RoughWater, 0
	setmetatile 9, 29, METATILE_General_RoughWater, 0
	setmetatile 10, 29, METATILE_General_RoughDeepWater, 0
	setmetatile 11, 29, METATILE_General_RoughDeepWater, 0
	setmetatile 12, 29, METATILE_General_RoughWater, 0
	setmetatile 9, 30, METATILE_General_RoughWater, 0
	setmetatile 10, 30, METATILE_General_RoughDeepWater, 0
	setmetatile 11, 30, METATILE_General_RoughDeepWater, 0
	setmetatile 12, 30, METATILE_General_RoughWater, 0
	setmetatile 10, 31, METATILE_General_RoughWater, 0
	setmetatile 11, 31, METATILE_General_RoughWater, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute105South:: @ 8273A18
	setmetatile 20, 53, METATILE_General_RoughWater, 0
	setmetatile 21, 53, METATILE_General_RoughWater, 0
	setmetatile 19, 54, METATILE_General_RoughWater, 0
	setmetatile 20, 54, METATILE_General_RoughDeepWater, 0
	setmetatile 21, 54, METATILE_General_RoughDeepWater, 0
	setmetatile 22, 54, METATILE_General_RoughWater, 0
	setmetatile 19, 55, METATILE_General_RoughWater, 0
	setmetatile 20, 55, METATILE_General_RoughDeepWater, 0
	setmetatile 21, 55, METATILE_General_RoughDeepWater, 0
	setmetatile 22, 55, METATILE_General_RoughWater, 0
	setmetatile 20, 56, METATILE_General_RoughWater, 0
	setmetatile 21, 56, METATILE_General_RoughWater, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute125West:: @ 8273A85
	setmetatile 8, 16, METATILE_General_RoughWater, 0
	setmetatile 9, 16, METATILE_General_RoughWater, 0
	setmetatile 7, 17, METATILE_General_RoughWater, 0
	setmetatile 8, 17, METATILE_General_RoughDeepWater, 0
	setmetatile 9, 17, METATILE_General_RoughDeepWater, 0
	setmetatile 10, 17, METATILE_General_RoughWater, 0
	setmetatile 7, 18, METATILE_General_RoughWater, 0
	setmetatile 8, 18, METATILE_General_RoughDeepWater, 0
	setmetatile 9, 18, METATILE_General_RoughDeepWater, 0
	setmetatile 10, 18, METATILE_General_RoughWater, 0
	setmetatile 8, 19, METATILE_General_RoughWater, 0
	setmetatile 9, 19, METATILE_General_RoughWater, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute125East:: @ 8273AF2
	setmetatile 53, 18, METATILE_General_RoughWater, 0
	setmetatile 54, 18, METATILE_General_RoughWater, 0
	setmetatile 52, 19, METATILE_General_RoughWater, 0
	setmetatile 53, 19, METATILE_General_RoughDeepWater, 0
	setmetatile 54, 19, METATILE_General_RoughDeepWater, 0
	setmetatile 55, 19, METATILE_General_RoughWater, 0
	setmetatile 52, 20, METATILE_General_RoughWater, 0
	setmetatile 53, 20, METATILE_General_RoughDeepWater, 0
	setmetatile 54, 20, METATILE_General_RoughDeepWater, 0
	setmetatile 55, 20, METATILE_General_RoughWater, 0
	setmetatile 53, 21, METATILE_General_RoughWater, 0
	setmetatile 54, 21, METATILE_General_RoughWater, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute127North:: @ 8273B5F
	setmetatile 57, 9, METATILE_General_RoughWater, 0
	setmetatile 58, 9, METATILE_General_RoughWater, 0
	setmetatile 56, 10, METATILE_General_RoughWater, 0
	setmetatile 57, 10, METATILE_General_RoughDeepWater, 0
	setmetatile 58, 10, METATILE_General_RoughDeepWater, 0
	setmetatile 59, 10, METATILE_General_RoughWater, 0
	setmetatile 56, 11, METATILE_General_RoughWater, 0
	setmetatile 57, 11, METATILE_General_RoughDeepWater, 0
	setmetatile 58, 11, METATILE_General_RoughDeepWater, 0
	setmetatile 59, 11, METATILE_General_RoughWater, 0
	setmetatile 57, 12, METATILE_General_RoughWater, 0
	setmetatile 58, 12, METATILE_General_RoughWater, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute127South:: @ 8273BCC
	setmetatile 61, 30, METATILE_General_RoughWater, 0
	setmetatile 62, 30, METATILE_General_RoughWater, 0
	setmetatile 60, 31, METATILE_General_RoughWater, 0
	setmetatile 61, 31, METATILE_General_RoughDeepWater, 0
	setmetatile 62, 31, METATILE_General_RoughDeepWater, 0
	setmetatile 63, 31, METATILE_General_RoughWater, 0
	setmetatile 60, 32, METATILE_General_RoughWater, 0
	setmetatile 61, 32, METATILE_General_RoughDeepWater, 0
	setmetatile 62, 32, METATILE_General_RoughDeepWater, 0
	setmetatile 63, 32, METATILE_General_RoughWater, 0
	setmetatile 61, 33, METATILE_General_RoughWater, 0
	setmetatile 62, 33, METATILE_General_RoughWater, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute129West:: @ 8273C39
	setmetatile 16, 14, METATILE_General_RoughWater, 0
	setmetatile 17, 14, METATILE_General_RoughWater, 0
	setmetatile 15, 15, METATILE_General_RoughWater, 0
	setmetatile 16, 15, METATILE_General_RoughDeepWater, 0
	setmetatile 17, 15, METATILE_General_RoughDeepWater, 0
	setmetatile 18, 15, METATILE_General_RoughWater, 0
	setmetatile 15, 16, METATILE_General_RoughWater, 0
	setmetatile 16, 16, METATILE_General_RoughDeepWater, 0
	setmetatile 17, 16, METATILE_General_RoughDeepWater, 0
	setmetatile 18, 16, METATILE_General_RoughWater, 0
	setmetatile 16, 17, METATILE_General_RoughWater, 0
	setmetatile 17, 17, METATILE_General_RoughWater, 0
	return

AbnormalWeather_EventScript_PlaceTilesRoute129East:: @ 8273CA6
	setmetatile 42, 19, METATILE_General_RoughWater, 0
	setmetatile 43, 19, METATILE_General_RoughWater, 0
	setmetatile 41, 20, METATILE_General_RoughWater, 0
	setmetatile 42, 20, METATILE_General_RoughDeepWater, 0
	setmetatile 43, 20, METATILE_General_RoughDeepWater, 0
	setmetatile 44, 20, METATILE_General_RoughWater, 0
	setmetatile 41, 21, METATILE_General_RoughWater, 0
	setmetatile 42, 21, METATILE_General_RoughDeepWater, 0
	setmetatile 43, 21, METATILE_General_RoughDeepWater, 0
	setmetatile 44, 21, METATILE_General_RoughWater, 0
	setmetatile 42, 22, METATILE_General_RoughWater, 0
	setmetatile 43, 22, METATILE_General_RoughWater, 0
	return

AbnormalWeather_EventScript_HideMapNamePopup:: @ 8273D13
	setflag FLAG_HIDE_MAP_NAME_POPUP
	return

AbnormalWeather_StartKyogreWeather:: @ 8273D17
	setweather WEATHER_DOWNPOUR
	return

AbnormalWeather_StartGroudonWeather:: @ 8273D1B
	setweather WEATHER_DROUGHT
	return

AbnormalWeather_EventScript_EndEventAndCleanup_1:: @ 8273D1F
	lockall
	compare VAR_ABNORMAL_WEATHER_LOCATION, MARINE_CAVE_LOCATIONS_START
	goto_if_ge AbnormalWeather_EventScript_ShowRainEndedMessage
	goto AbnormalWeather_EventScript_ShowSunEndedMessage
	end

AbnormalWeather_EventScript_EndEventAndCleanup_2:: @ 8273D31
	closemessage
	fadescreenswapbuffers FADE_TO_BLACK
	setweather WEATHER_SUNNY
	doweather
	call AbnormalWeather_EventScript_CleanupMapTiles
	special DrawWholeMapView
	setvar VAR_ABNORMAL_WEATHER_LOCATION, ABNORMAL_WEATHER_NONE
	setvar VAR_SHOULD_END_ABNORMAL_WEATHER, 0
	clearflag FLAG_HIDE_MAP_NAME_POPUP
	fadescreenswapbuffers FADE_FROM_BLACK
	releaseall
	end

AbnormalWeather_EventScript_ShowRainEndedMessage:: @ 8273D51
	msgbox gText_AbnormalWeatherEnded_Rain, MSGBOX_DEFAULT
	goto AbnormalWeather_EventScript_EndEventAndCleanup_2
	end

AbnormalWeather_EventScript_ShowSunEndedMessage:: @ 8273D5F
	msgbox gText_AbnormalWeatherEnded_Sun, MSGBOX_DEFAULT
	goto AbnormalWeather_EventScript_EndEventAndCleanup_2
	end

AbnormalWeather_EventScript_CleanupMapTiles:: @ 8273D6D
	switch VAR_ABNORMAL_WEATHER_LOCATION
	case ABNORMAL_WEATHER_ROUTE_114_NORTH, AbnormalWeather_EventScript_CleanupRoute114North
	case ABNORMAL_WEATHER_ROUTE_114_SOUTH, AbnormalWeather_EventScript_CleanupRoute114South
	case ABNORMAL_WEATHER_ROUTE_115_WEST, AbnormalWeather_EventScript_CleanupRoute115West
	case ABNORMAL_WEATHER_ROUTE_115_EAST, AbnormalWeather_EventScript_CleanupRoute115East
	case ABNORMAL_WEATHER_ROUTE_116_NORTH, AbnormalWeather_EventScript_CleanupRoute116North
	case ABNORMAL_WEATHER_ROUTE_116_SOUTH, AbnormalWeather_EventScript_CleanupRoute116South
	case ABNORMAL_WEATHER_ROUTE_118_EAST, AbnormalWeather_EventScript_CleanupRoute118East
	case ABNORMAL_WEATHER_ROUTE_118_WEST, AbnormalWeather_EventScript_CleanupRoute118West
	case ABNORMAL_WEATHER_ROUTE_105_NORTH, AbnormalWeather_EventScript_CleanupRoute105North
	case ABNORMAL_WEATHER_ROUTE_105_SOUTH, AbnormalWeather_EventScript_CleanupRoute105South
	case ABNORMAL_WEATHER_ROUTE_125_WEST, AbnormalWeather_EventScript_CleanupRoute125West
	case ABNORMAL_WEATHER_ROUTE_125_EAST, AbnormalWeather_EventScript_CleanupRoute125East
	case ABNORMAL_WEATHER_ROUTE_127_NORTH, AbnormalWeather_EventScript_CleanupRoute127North
	case ABNORMAL_WEATHER_ROUTE_127_SOUTH, AbnormalWeather_EventScript_CleanupRoute127South
	case ABNORMAL_WEATHER_ROUTE_129_WEST, AbnormalWeather_EventScript_CleanupRoute129West
	case ABNORMAL_WEATHER_ROUTE_129_EAST, AbnormalWeather_EventScript_CleanupRoute129East
	return

AbnormalWeather_EventScript_CleanupRoute114North:: @ 8273E23
	setmetatile 7, 3, METATILE_Fallarbor_RedRockWall, 1
	setmetatile 7, 4, METATILE_Fallarbor_RedRockWall, 1
	return

AbnormalWeather_EventScript_CleanupRoute114South:: @ 8273E36
	setmetatile 6, 45, METATILE_Fallarbor_BrownRockWall, 1
	setmetatile 6, 46, METATILE_Fallarbor_BrownRockWall, 1
	return

AbnormalWeather_EventScript_CleanupRoute115West:: @ 8273E49
	setmetatile 21, 5, METATILE_Fallarbor_BrownRockWall, 1
	setmetatile 21, 6, METATILE_Fallarbor_BrownRockWall, 1
	return

AbnormalWeather_EventScript_CleanupRoute115East:: @ 8273E5C
	setmetatile 36, 9, METATILE_Fallarbor_BrownRockWall, 1
	setmetatile 36, 10, METATILE_Fallarbor_BrownRockWall, 1
	return

AbnormalWeather_EventScript_CleanupRoute116North:: @ 8273E6F
	setmetatile 59, 12, METATILE_General_RockWall_RockBase, 1
	setmetatile 59, 13, METATILE_General_RockWall_RockBase, 1
	return

AbnormalWeather_EventScript_CleanupRoute116South:: @ 8273E82
	setmetatile 79, 5, METATILE_General_RockWall_RockBase, 1
	setmetatile 79, 6, METATILE_General_RockWall_RockBase, 1
	return

AbnormalWeather_EventScript_CleanupRoute118East:: @ 8273E95
	setmetatile 42, 5, METATILE_General_RockWall_RockBase, 1
	setmetatile 42, 6, METATILE_General_RockWall_GrassBase, 1
	return

AbnormalWeather_EventScript_CleanupRoute118West:: @ 8273EA8
	setmetatile 9, 5, METATILE_General_RockWall_RockBase, 1
	setmetatile 9, 6, METATILE_General_RockWall_GrassBase, 1
	return

AbnormalWeather_EventScript_CleanupRoute105North:: @ 8273EBB
	setmetatile 10, 28, METATILE_General_CalmWater, 0
	setmetatile 11, 28, METATILE_General_CalmWater, 0
	setmetatile 9, 29, METATILE_General_CalmWater, 0
	setmetatile 10, 29, METATILE_General_CalmWater, 0
	setmetatile 11, 29, METATILE_General_CalmWater, 0
	setmetatile 12, 29, METATILE_General_CalmWater, 0
	setmetatile 9, 30, METATILE_General_CalmWater, 0
	setmetatile 10, 30, METATILE_General_CalmWater, 0
	setmetatile 11, 30, METATILE_General_CalmWater, 0
	setmetatile 12, 30, METATILE_General_CalmWater, 0
	setmetatile 10, 31, METATILE_General_CalmWater, 0
	setmetatile 11, 31, METATILE_General_CalmWater, 0
	return

AbnormalWeather_EventScript_CleanupRoute105South:: @ 8273F28
	setmetatile 20, 53, METATILE_General_CalmWater, 0
	setmetatile 21, 53, METATILE_General_CalmWater, 0
	setmetatile 19, 54, METATILE_General_CalmWater, 0
	setmetatile 20, 54, METATILE_General_CalmWater, 0
	setmetatile 21, 54, METATILE_General_CalmWater, 0
	setmetatile 22, 54, METATILE_General_CalmWater, 0
	setmetatile 19, 55, METATILE_General_CalmWater, 0
	setmetatile 20, 55, METATILE_General_CalmWater, 0
	setmetatile 21, 55, METATILE_General_CalmWater, 0
	setmetatile 22, 55, METATILE_General_CalmWater, 0
	setmetatile 20, 56, METATILE_General_CalmWater, 0
	setmetatile 21, 56, METATILE_General_CalmWater, 0
	return

AbnormalWeather_EventScript_CleanupRoute125West:: @ 8273F95
	setmetatile 8, 16, METATILE_General_CalmWater, 0
	setmetatile 9, 16, METATILE_General_CalmWater, 0
	setmetatile 7, 17, METATILE_General_CalmWater, 0
	setmetatile 8, 17, METATILE_General_CalmWater, 0
	setmetatile 9, 17, METATILE_General_CalmWater, 0
	setmetatile 10, 17, METATILE_General_CalmWater, 0
	setmetatile 7, 18, METATILE_General_CalmWater, 0
	setmetatile 8, 18, METATILE_General_CalmWater, 0
	setmetatile 9, 18, METATILE_General_CalmWater, 0
	setmetatile 10, 18, METATILE_General_CalmWater, 0
	setmetatile 8, 19, METATILE_General_CalmWater, 0
	setmetatile 9, 19, METATILE_General_CalmWater, 0
	return

AbnormalWeather_EventScript_CleanupRoute125East:: @ 8274002
	setmetatile 53, 18, METATILE_General_CalmWater, 0
	setmetatile 54, 18, METATILE_General_CalmWater, 0
	setmetatile 52, 19, METATILE_General_CalmWater, 0
	setmetatile 53, 19, METATILE_General_CalmWater, 0
	setmetatile 54, 19, METATILE_General_CalmWater, 0
	setmetatile 55, 19, METATILE_General_CalmWater, 0
	setmetatile 52, 20, METATILE_General_CalmWater, 0
	setmetatile 53, 20, METATILE_General_CalmWater, 0
	setmetatile 54, 20, METATILE_General_CalmWater, 0
	setmetatile 55, 20, METATILE_General_CalmWater, 0
	setmetatile 53, 21, METATILE_General_CalmWater, 0
	setmetatile 54, 21, METATILE_General_CalmWater, 0
	return

AbnormalWeather_EventScript_CleanupRoute127North:: @ 827406F
	setmetatile 57, 9, METATILE_General_CalmWater, 0
	setmetatile 58, 9, METATILE_General_CalmWater, 0
	setmetatile 56, 10, METATILE_General_CalmWater, 0
	setmetatile 57, 10, METATILE_General_CalmWater, 0
	setmetatile 58, 10, METATILE_General_CalmWater, 0
	setmetatile 59, 10, METATILE_General_CalmWater, 0
	setmetatile 56, 11, METATILE_General_CalmWater, 0
	setmetatile 57, 11, METATILE_General_CalmWater, 0
	setmetatile 58, 11, METATILE_General_CalmWater, 0
	setmetatile 59, 11, METATILE_General_CalmWater, 0
	setmetatile 57, 12, METATILE_General_CalmWater, 0
	setmetatile 58, 12, METATILE_General_CalmWater, 0
	return

AbnormalWeather_EventScript_CleanupRoute127South:: @ 82740DC
	setmetatile 61, 30, METATILE_General_CalmWater, 0
	setmetatile 62, 30, METATILE_General_CalmWater, 0
	setmetatile 60, 31, METATILE_General_CalmWater, 0
	setmetatile 61, 31, METATILE_General_CalmWater, 0
	setmetatile 62, 31, METATILE_General_CalmWater, 0
	setmetatile 63, 31, METATILE_General_CalmWater, 0
	setmetatile 60, 32, METATILE_General_CalmWater, 0
	setmetatile 61, 32, METATILE_General_CalmWater, 0
	setmetatile 62, 32, METATILE_General_CalmWater, 0
	setmetatile 63, 32, METATILE_General_CalmWater, 0
	setmetatile 61, 33, METATILE_General_CalmWater, 0
	setmetatile 62, 33, METATILE_General_CalmWater, 0
	return

AbnormalWeather_EventScript_CleanupRoute129West:: @ 8274149
	setmetatile 16, 14, METATILE_General_CalmWater, 0
	setmetatile 17, 14, METATILE_General_CalmWater, 0
	setmetatile 15, 15, METATILE_General_CalmWater, 0
	setmetatile 16, 15, METATILE_General_CalmWater, 0
	setmetatile 17, 15, METATILE_General_CalmWater, 0
	setmetatile 18, 15, METATILE_General_CalmWater, 0
	setmetatile 15, 16, METATILE_General_CalmWater, 0
	setmetatile 16, 16, METATILE_General_CalmWater, 0
	setmetatile 17, 16, METATILE_General_CalmWater, 0
	setmetatile 18, 16, METATILE_General_CalmWater, 0
	setmetatile 16, 17, METATILE_General_CalmWater, 0
	setmetatile 17, 17, METATILE_General_CalmWater, 0
	return

AbnormalWeather_EventScript_CleanupRoute129East:: @ 82741B6
	setmetatile 42, 19, METATILE_General_CalmWater, 0
	setmetatile 43, 19, METATILE_General_CalmWater, 0
	setmetatile 41, 20, METATILE_General_CalmWater, 0
	setmetatile 42, 20, METATILE_General_CalmWater, 0
	setmetatile 43, 20, METATILE_General_CalmWater, 0
	setmetatile 44, 20, METATILE_General_CalmWater, 0
	setmetatile 41, 21, METATILE_General_CalmWater, 0
	setmetatile 42, 21, METATILE_General_CalmWater, 0
	setmetatile 43, 21, METATILE_General_CalmWater, 0
	setmetatile 44, 21, METATILE_General_CalmWater, 0
	setmetatile 42, 22, METATILE_General_CalmWater, 0
	setmetatile 43, 22, METATILE_General_CalmWater, 0
	return

AbnormalWeather_Underwater_SetupEscapeWarp:: @ 8274223
	switch VAR_ABNORMAL_WEATHER_LOCATION
	case ABNORMAL_WEATHER_ROUTE_105_NORTH, AbnormalWeather_Underwater_SetupEscapeWarpRoute105North
	case ABNORMAL_WEATHER_ROUTE_105_SOUTH, AbnormalWeather_Underwater_SetupEscapeWarpRoute105South
	case ABNORMAL_WEATHER_ROUTE_125_WEST, AbnormalWeather_Underwater_SetupEscapeWarpRoute125West
	case ABNORMAL_WEATHER_ROUTE_125_EAST, AbnormalWeather_Underwater_SetupEscapeWarpRoute125East
	case ABNORMAL_WEATHER_ROUTE_127_NORTH, AbnormalWeather_Underwater_SetupEscapeWarpRoute127North
	case ABNORMAL_WEATHER_ROUTE_127_SOUTH, AbnormalWeather_Underwater_SetupEscapeWarpRoute127South
	case ABNORMAL_WEATHER_ROUTE_129_WEST, AbnormalWeather_Underwater_SetupEscapeWarpRoute129West
	case ABNORMAL_WEATHER_ROUTE_129_EAST, AbnormalWeather_Underwater_SetupEscapeWarpRoute129East
	return

AbnormalWeather_Underwater_SetupEscapeWarpRoute105North:: @ 8274281
	setescapewarp MAP_ROUTE105, 255, 11, 29
	return

AbnormalWeather_Underwater_SetupEscapeWarpRoute105South:: @ 827428A
	setescapewarp MAP_ROUTE105, 255, 21, 54
	return

AbnormalWeather_Underwater_SetupEscapeWarpRoute125West:: @ 8274293
	setescapewarp MAP_ROUTE125, 255, 9, 17
	return

AbnormalWeather_Underwater_SetupEscapeWarpRoute125East:: @ 827429C
	setescapewarp MAP_ROUTE125, 255, 54, 19
	return

AbnormalWeather_Underwater_SetupEscapeWarpRoute127North:: @ 82742A5
	setescapewarp MAP_ROUTE127, 255, 58, 10
	return

AbnormalWeather_Underwater_SetupEscapeWarpRoute127South:: @ 82742AE
	setescapewarp MAP_ROUTE127, 255, 62, 31
	return

AbnormalWeather_Underwater_SetupEscapeWarpRoute129West:: @ 82742B7
	setescapewarp MAP_ROUTE129, 255, 17, 15
	return

AbnormalWeather_Underwater_SetupEscapeWarpRoute129East:: @ 82742C0
	setescapewarp MAP_ROUTE129, 255, 43, 20
	return


code:
.set LOCALID_APPRENTICE, 6

BattleFrontier_BattleTowerLobby_EventScript_Apprentice:: @ 82B688D
	lock
	faceplayer
	apprentice_gavelvlmode
	compare VAR_RESULT, FALSE
	goto_if_eq Apprentice_EventScript_FirstMeeting
	apprentice_shouldcheckgone
	compare VAR_0x8004, FALSE  @ Always TRUE here
	goto_if_eq Apprentice_EventScript_AskQuestion
	goto_if_set FLAG_DAILY_APPRENTICE_LEAVES, Apprentice_EventScript_Gone
Apprentice_EventScript_AskQuestion: @ 82B68BE
	apprentice_getquestion
	compare VAR_RESULT, APPRENTICE_QUESTION_WHICH_MON
	goto_if_eq Apprentice_EventScript_UseWhichMon
	compare VAR_RESULT, APPRENTICE_QUESTION_WHAT_ITEM
	goto_if_eq Apprentice_EventScript_UseWhatHeldItem
	compare VAR_RESULT, APPRENTICE_QUESTION_WHICH_MOVE
	goto_if_eq Apprentice_EventScript_UseWhichMove
	compare VAR_RESULT, APPRENTICE_QUESTION_WHICH_FIRST
	goto_if_eq Apprentice_EventScript_PutWhichMonFirst
	compare VAR_RESULT, APPRENTICE_QUESTION_WIN_SPEECH
	goto_if_eq Apprentice_EventScript_PickWinSpeech
	release
	releaseall
	end

Apprentice_EventScript_FirstMeeting: @ 82B6900
	apprentice_buff 0, APPRENTICE_BUFF_NAME
	apprentice_msg FALSE, APPRENTICE_MSG_PLEASE_TEACH
Apprentice_EventScript_WhichLvlMode: @ 82B6925
	apprentice_menu APPRENTICE_ASK_YES_NO
	compare VAR_RESULT, 1
	goto_if_eq Apprentice_EventScript_RejectTeach
	apprentice_msg FALSE, APPRENTICE_MSG_WHICH_LVL_MODE
	apprentice_menu APPRENTICE_ASK_WHICH_LEVEL
	apprentice_setlvlmode VAR_RESULT
	apprentice_shufflespecies
	apprentice_buff 0, APPRENTICE_BUFF_LEVEL
	apprentice_msg TRUE, APPRENTICE_MSG_THANKS_LVL_MODE
	call Apprentice_EventScript_SetHideFlags
	release
	releaseall
	switch VAR_FACING
	case DIR_NORTH, Apprentice_EventScript_LeaveNorth
	goto Apprentice_EventScript_Leave
	end

@ Its impossible to fully reject an Apprentice, they just keep asking for you to teach them
Apprentice_EventScript_RejectTeach: @ 82B69BB
	apprentice_msg FALSE, APPRENTICE_MSG_REJECT
	goto Apprentice_EventScript_WhichLvlMode

Apprentice_EventScript_UseWhichMon: @ 82B69D3
	apprentice_initquestion APPRENTICE_QUESTION_WHICH_MON
	apprentice_buff 0, APPRENTICE_BUFF_SPECIES1
	apprentice_buff 1, APPRENTICE_BUFF_SPECIES2
	apprentice_msg FALSE, APPRENTICE_MSG_WHICH_MON
	apprentice_menu APPRENTICE_ASK_2SPECIES
	copyvar VAR_0x8005, VAR_RESULT
	compare VAR_0x8005, 0
	call_if_eq Apprentice_EventScript_ChoseFirstMon
	compare VAR_0x8005, 1
	call_if_eq Apprentice_EventScript_ChoseSecondMon
	apprentice_getnumpartymons
	apprentice_setpartymon VAR_RESULT
	apprentice_answeredquestion
	apprentice_getnumpartymons
	compare VAR_RESULT, MULTI_PARTY_SIZE
	call_if_eq Apprentice_EventScript_LastMonSelected
	apprentice_buff 0, VAR_0x8007
	apprentice_freequestion
	apprentice_msg TRUE, APPRENTICE_MSG_THANKS_MON
	call Apprentice_EventScript_SetHideFlags
	release
	releaseall
	switch VAR_FACING
	case DIR_NORTH, Apprentice_EventScript_LeaveNorth
	goto Apprentice_EventScript_Leave
	end

Apprentice_EventScript_ChoseFirstMon: @ 82B6ABA
	setvar VAR_0x8007, APPRENTICE_BUFF_SPECIES1
	return

Apprentice_EventScript_ChoseSecondMon: @ 82B6AC0
	setvar VAR_0x8007, APPRENTICE_BUFF_SPECIES2
	return

Apprentice_EventScript_LastMonSelected: @ 82B6AC6
	apprentice_randomizequestions
	return

Apprentice_EventScript_UseWhatHeldItem: @ 82B6ACF
	apprentice_initquestion APPRENTICE_QUESTION_WHAT_ITEM
	apprentice_buff 0, APPRENTICE_BUFF_SPECIES3
	apprentice_msg TRUE, APPRENTICE_MSG_WHAT_HELD_ITEM
	apprentice_freequestion
Apprentice_EventScript_ChooseHoldItem: @ 82B6B09
	fadescreen FADE_TO_BLACK
	setvar VAR_RESULT, 0
	apprentice_openbag
	compare VAR_RESULT, FALSE
	goto_if_eq Apprentice_EventScript_ConfirmHoldNothing
	apprentice_trysetitem
	compare VAR_RESULT, FALSE
	goto_if_eq Apprentice_EventScript_AlreadySuggestedItem
	apprentice_buff 0, APPRENTICE_BUFF_ITEM
	apprentice_msg TRUE, APPRENTICE_MSG_THANKS_HELD_ITEM
	apprentice_answeredquestion
	call Apprentice_EventScript_SetHideFlags
	release
	releaseall
	switch VAR_FACING
	case DIR_NORTH, Apprentice_EventScript_LeaveNorth
	goto Apprentice_EventScript_Leave
	end

Apprentice_EventScript_ConfirmHoldNothing: @ 82B6B81
	apprentice_initquestion APPRENTICE_QUESTION_WHAT_ITEM
	apprentice_buff 0, APPRENTICE_BUFF_SPECIES3
	apprentice_msg FALSE, APPRENTICE_MSG_HOLD_NOTHING
	apprentice_menu APPRENTICE_ASK_GIVE
	apprentice_freequestion
	compare VAR_RESULT, 0
	goto_if_eq Apprentice_EventScript_ChooseHoldItem
Apprentice_EventScript_HoldNothing: @ 82B6BD4
	apprentice_msg TRUE, APPRENTICE_MSG_THANKS_NO_HELD_ITEM
	apprentice_answeredquestion
	call Apprentice_EventScript_SetHideFlags
	release
	releaseall
	switch VAR_FACING
	case DIR_NORTH, Apprentice_EventScript_LeaveNorth
	goto Apprentice_EventScript_Leave
	end

@ Because Battle Tower mons may not hold the same item, the player must suggest a
@ different item if theyve already told the Apprentice to use it for another mon
Apprentice_EventScript_AlreadySuggestedItem: @ 82B6C0C
	apprentice_initquestion APPRENTICE_QUESTION_WHAT_ITEM
	apprentice_buff 0, APPRENTICE_BUFF_ITEM
	apprentice_buff 1, APPRENTICE_BUFF_SPECIES3
	apprentice_msg FALSE, APPRENTICE_MSG_ITEM_ALREADY_SUGGESTED
	apprentice_menu APPRENTICE_ASK_GIVE
	apprentice_freequestion
	compare VAR_RESULT, 0
	goto_if_eq Apprentice_EventScript_ChooseHoldItem
	goto Apprentice_EventScript_HoldNothing
	end

Apprentice_EventScript_UseWhichMove: @ 82B6C77
	apprentice_initquestion APPRENTICE_QUESTION_WHICH_MOVE
	apprentice_buff 0, APPRENTICE_BUFF_SPECIES3
	apprentice_buff 1, APPRENTICE_BUFF_MOVE1
	apprentice_buff 2, APPRENTICE_BUFF_MOVE2
	apprentice_msg FALSE, APPRENTICE_MSG_WHICH_MOVE
	apprentice_menu APPRENTICE_ASK_MOVES
	copyvar VAR_0x8005, VAR_RESULT
	compare VAR_0x8005, 0
	call_if_eq Apprentice_EventScript_ChoseMove1
	compare VAR_0x8005, 1
	call_if_eq Apprentice_EventScript_ChoseMove2
	apprentice_setmove
	apprentice_answeredquestion
	apprentice_buff 0, VAR_0x8007
	apprentice_freequestion
	apprentice_msg TRUE, APPRENTICE_MSG_THANKS_MOVE
	call Apprentice_EventScript_SetHideFlags
	release
	releaseall
	switch VAR_FACING
	case DIR_NORTH, Apprentice_EventScript_LeaveNorth
	goto Apprentice_EventScript_Leave
	end

Apprentice_EventScript_ChoseMove1: @ 82B6D50
	setvar VAR_0x8007, APPRENTICE_BUFF_MOVE1
	return

Apprentice_EventScript_ChoseMove2: @ 82B6D56
	setvar VAR_0x8007, APPRENTICE_BUFF_MOVE2
	return

Apprentice_EventScript_PutWhichMonFirst: @ 82B6D5C
	apprentice_msg FALSE, APPRENTICE_MSG_WHICH_MON_FIRST
	apprentice_menu APPRENTICE_ASK_3SPECIES
	apprentice_setleadmon VAR_RESULT
	apprentice_answeredquestion
	apprentice_buff 0, APPRENTICE_BUFF_LEAD_MON_SPECIES
	apprentice_msg TRUE, APPRENTICE_MSG_THANKS_MON_FIRST
	call Apprentice_EventScript_SetHideFlags
	release
	releaseall
	switch VAR_FACING
	case DIR_NORTH, Apprentice_EventScript_LeaveNorth
	goto Apprentice_EventScript_Leave
	end

@ Last question, after which the Apprentice leaves (and is saved) to be replaced by another
Apprentice_EventScript_PickWinSpeech: @ 82B6DD4
	apprentice_msg TRUE, APPRENTICE_MSG_PICK_WIN_SPEECH
	apprentice_shiftsaved
	setvar VAR_0x8004, EASY_CHAT_TYPE_APPRENTICE
	call Common_ShowEasyChatScreen
	lock
	faceplayer
	apprentice_save
	apprentice_buff 0, APPRENTICE_BUFF_WIN_SPEECH
	apprentice_msg TRUE, APPRENTICE_MSG_THANKS_WIN_SPEECH
	apprentice_reset
	call Apprentice_EventScript_SetHideFlags
	release
	releaseall
	switch VAR_FACING
	case DIR_NORTH, Apprentice_EventScript_LeaveNorth
	goto Apprentice_EventScript_Leave
	end

Apprentice_EventScript_SetHideFlags: @ 82B6E4D
	setflag FLAG_HIDE_APPRENTICE
	setflag FLAG_DAILY_APPRENTICE_LEAVES
	return

Apprentice_EventScript_LeaveNorth: @ 82B6E54
	apprentice_shouldleave
	compare VAR_0x8004, FALSE  @ Always TRUE here
	goto_if_eq Apprentice_EventScript_DontMove
	applymovement LOCALID_APPRENTICE, Apprentice_Movement_LeaveNorth
	waitmovement 0
	end

Apprentice_EventScript_Leave: @ 82B6E72
	apprentice_shouldleave
	compare VAR_0x8004, FALSE  @ Always TRUE here
	goto_if_eq Apprentice_EventScript_DontMove
	applymovement LOCALID_APPRENTICE, Apprentice_Movement_Leave
	waitmovement 0
	end

Apprentice_EventScript_Gone: @ 82B6E90
	release
	releaseall
	end

Apprentice_EventScript_DontMove: @ 82B6E93
	end

Apprentice_Movement_LeaveNorth: @ 82B6E94
	walk_fast_right
Apprentice_Movement_Leave: @ 82B6E95
	walk_fast_down
	walk_fast_down
	walk_fast_right
	walk_fast_right
	walk_fast_right
	walk_fast_right
	walk_fast_right
	walk_fast_right
	walk_fast_right
	walk_fast_right
	walk_fast_right
	set_invisible
	slide_down
	slide_down
	slide_down
	step_end


code:
@ Note: LOCALIDs shared with BattleFrontier_BattlePikeRoomNormal
BattleFrontier_BattlePikeRoomNormal_MapScripts_2C3E1B: @ 82C3E1B
	map_script MAP_SCRIPT_ON_TRANSITION, BattleFrontier_BattlePikeRoom_OnTransition
	map_script MAP_SCRIPT_ON_WARP_INTO_MAP_TABLE, BattleFrontier_BattlePikeRoom_OnWarp

BattleFrontier_BattlePikeRoom_OnTransition: @ 82C3E25
	pike_setroomobjects
	pike_getroomtype
	switch VAR_RESULT
	case PIKE_ROOM_SINGLE_BATTLE, BattleFrontier_BattlePikeRoomNormal_EventScript_SetOneObjectRoomPos
	case PIKE_ROOM_HEAL_FULL, BattleFrontier_BattlePikeRoomNormal_EventScript_SetOneObjectRoomPos
	case PIKE_ROOM_NPC, BattleFrontier_BattlePikeRoomNormal_EventScript_SetNPCRoomObjPos
	case PIKE_ROOM_STATUS, BattleFrontier_BattlePikeRoomNormal_EventScript_SetTwoObjectRoomPos
	case PIKE_ROOM_HEAL_PART, BattleFrontier_BattlePikeRoomNormal_EventScript_SetOneObjectRoomPos
	case PIKE_ROOM_DOUBLE_BATTLE, BattleFrontier_BattlePikeRoomNormal_EventScript_SetDoubleBattleObjPos
	case PIKE_ROOM_HARD_BATTLE, BattleFrontier_BattlePikeRoomNormal_EventScript_SetTwoObjectRoomPos
	case PIKE_ROOM_BRAIN, BattleFrontier_BattlePikeRoomNormal_EventScript_SetBrainRoomObjPos
	end

BattleFrontier_BattlePikeRoomNormal_EventScript_SetDoubleBattleObjPos:: @ 82C3E93
	setobjectxyperm LOCALID_OBJ_0, 2, 5
	setobjectxyperm LOCALID_OBJ_1, 6, 5
	end

BattleFrontier_BattlePikeRoomNormal_EventScript_SetTwoObjectRoomPos:: @ 82C3EA2
	setobjectxyperm LOCALID_OBJ_0, 4, 4
	setobjectxyperm LOCALID_OBJ_1, 3, 4
	end

BattleFrontier_BattlePikeRoomNormal_EventScript_SetOneObjectRoomPos:: @ 82C3EB1
	setobjectxyperm LOCALID_OBJ_0, 4, 4
	setobjectxyperm LOCALID_OBJ_1, 0, 0
	end

BattleFrontier_BattlePikeRoomNormal_EventScript_SetNPCRoomObjPos:: @ 82C3EC0
	setobjectxyperm LOCALID_OBJ_0, 5, 5
	setobjectxyperm LOCALID_OBJ_1, 0, 0
	end

BattleFrontier_BattlePikeRoomNormal_EventScript_SetBrainRoomObjPos:: @ 82C3ECF
	setobjectxyperm LOCALID_OBJ_0, 4, 3
	setobjectxyperm LOCALID_OBJ_1, 4, 4
	end

BattleFrontier_BattlePikeRoom_OnWarp: @ 82C3EDE
	map_script_2 VAR_TEMP_4, 0, BattleFrontier_BattlePikeRoomNormal_EventScript_InitRoomObjects
	.2byte 0

BattleFrontier_BattlePikeRoomNormal_EventScript_InitRoomObjects:: @ 82C3EE8
	setvar VAR_OBJ_GFX_ID_1, OBJ_EVENT_GFX_LINK_RECEPTIONIST
	setvar VAR_OBJ_GFX_ID_0, OBJ_EVENT_GFX_LINK_RECEPTIONIST
	pike_getroomtype
	compare VAR_RESULT, PIKE_ROOM_STATUS
	goto_if_eq BattleFrontier_BattlePikeRoomNormal_EventScript_InitTwoObjectRoom
	compare VAR_RESULT, PIKE_ROOM_HARD_BATTLE
	goto_if_eq BattleFrontier_BattlePikeRoomNormal_EventScript_InitTwoObjectRoom
	compare VAR_RESULT, PIKE_ROOM_DOUBLE_BATTLE
	goto_if_eq BattleFrontier_BattlePikeRoomNormal_EventScript_InitTwoObjectRoom
	compare VAR_RESULT, PIKE_ROOM_BRAIN
	goto_if_eq BattleFrontier_BattlePikeRoomNormal_EventScript_InitBrainRoomObjects
	hideobjectat LOCALID_OBJ_1, MAP_BATTLE_FRONTIER_BATTLE_PIKE_ROOM_NORMAL
	setvar VAR_TEMP_4, 1
	turnobject OBJ_EVENT_ID_PLAYER, DIR_NORTH
	end

BattleFrontier_BattlePikeRoomNormal_EventScript_InitTwoObjectRoom:: @ 82C3F35
	setvar VAR_TEMP_4, 1
	turnobject OBJ_EVENT_ID_PLAYER, DIR_NORTH
	end

BattleFrontier_BattlePikeRoomNormal_EventScript_InitBrainRoomObjects:: @ 82C3F3F
	setvar VAR_TEMP_4, 1
	turnobject OBJ_EVENT_ID_PLAYER, DIR_NORTH
	hideobjectat LOCALID_OBJ_0, MAP_BATTLE_FRONTIER_BATTLE_PIKE_ROOM_NORMAL  @ Pike Queen hidden initially
	end

BattleFrontier_BattlePikeThreePathRoom_EventScript_LeftRoomWarp:: @ 82C3F4E
	setvar VAR_0x8007, PIKE_ROOM_LEFT
	goto BattleFrontier_BattlePikeThreePathRoom_EventScript_RoomWarp
	end

BattleFrontier_BattlePikeThreePathRoom_EventScript_CenterRoomWarp:: @ 82C3F59
	setvar VAR_0x8007, PIKE_ROOM_CENTER
	goto BattleFrontier_BattlePikeThreePathRoom_EventScript_RoomWarp
	end

BattleFrontier_BattlePikeThreePathRoom_EventScript_RightRoomWarp:: @ 82C3F64
	setvar VAR_0x8007, PIKE_ROOM_RIGHT
	goto BattleFrontier_BattlePikeThreePathRoom_EventScript_RoomWarp
	end

BattleFrontier_BattlePikeThreePathRoom_EventScript_RoomWarp:: @ 82C3F6F
	pike_get PIKE_DATA_WIN_STREAK
	addvar VAR_RESULT, 1
	pike_set PIKE_DATA_WIN_STREAK, VAR_RESULT
	frontier_get FRONTIER_DATA_BATTLE_NUM
	addvar VAR_RESULT, 1
	frontier_set FRONTIER_DATA_BATTLE_NUM, VAR_RESULT
	pike_setnextroom
	pike_getroomtype
	switch VAR_RESULT
	case PIKE_ROOM_SINGLE_BATTLE, BattleFrontier_BattlePikeThreePathRoom_EventScript_WarpNPCRoom
	case PIKE_ROOM_HEAL_FULL, BattleFrontier_BattlePikeThreePathRoom_EventScript_WarpNPCRoom
	case PIKE_ROOM_NPC, BattleFrontier_BattlePikeThreePathRoom_EventScript_WarpNPCRoom
	case PIKE_ROOM_STATUS, BattleFrontier_BattlePikeThreePathRoom_EventScript_WarpNPCRoom
	case PIKE_ROOM_HEAL_PART, BattleFrontier_BattlePikeThreePathRoom_EventScript_WarpNPCRoom
	case PIKE_ROOM_WILD_MONS, BattleFrontier_BattlePikeThreePathRoom_EventScript_WarpWildMonRoom
	case PIKE_ROOM_HARD_BATTLE, BattleFrontier_BattlePikeThreePathRoom_EventScript_WarpNPCRoom
	case PIKE_ROOM_DOUBLE_BATTLE, BattleFrontier_BattlePikeThreePathRoom_EventScript_WarpNPCRoom
	case PIKE_ROOM_BRAIN, BattleFrontier_BattlePikeThreePathRoom_EventScript_WarpNPCRoom
	end

BattleFrontier_BattlePikeThreePathRoom_EventScript_WarpNPCRoom:: @ 82C4030
	applymovement OBJ_EVENT_ID_PLAYER, BattleFrontier_BattlePikeRoom_Movement_HidePlayer
	waitmovement 0
	call BattleFrontier_BattlePike_EventScript_CloseCurtain
	warpsilent MAP_BATTLE_FRONTIER_BATTLE_PIKE_ROOM_NORMAL, 255, 4, 7
	waitstate
	end

BattleFrontier_BattlePikeThreePathRoom_EventScript_WarpWildMonRoom:: @ 82C4049
	applymovement OBJ_EVENT_ID_PLAYER, BattleFrontier_BattlePikeRoom_Movement_HidePlayer
	waitmovement 0
	call BattleFrontier_BattlePike_EventScript_CloseCurtain
	warpsilent MAP_BATTLE_FRONTIER_BATTLE_PIKE_ROOM_WILD_MONS, 255, 4, 19
	waitstate
	end

BattleFrontier_BattlePikeThreePathRoom_EventScript_SetEnteredRoom:: @ 82C4062
	setvar VAR_TEMP_3, 1
	setvar VAR_TEMP_2, 1
	end

BattleFrontier_BattlePikeThreePathRoom_EventScript_NoTurningBack:: @ 82C406D
	setvar VAR_TEMP_3, 0
	setvar VAR_TEMP_2, 0
	lockall
	msgbox BattleFrontier_BattlePike_Text_PathBlockedNoTurningBack, MSGBOX_DEFAULT
	closemessage
	end

BattleFrontier_BattlePikeRoomNormal_EventScript_SetEnteredRoom:: @ 82C4082
	setvar VAR_TEMP_3, 1
	setvar VAR_TEMP_2, 1
	end

BattleFrontier_BattlePikeRoomNormal_EventScript_NoTurningBack:: @ 82C408D
	setvar VAR_TEMP_3, 0
	setvar VAR_TEMP_2, 0
	lockall
	msgbox BattleFrontier_BattlePike_Text_PathBlockedNoTurningBack, MSGBOX_DEFAULT
	closemessage
	end

BattleFrontier_BattlePikeRoomNormal_EventScript_Exit:: @ 82C40A2
	pike_ispartyfullhealth
	compare VAR_RESULT, TRUE
	call_if_eq BattleFrontier_BattlePikeRoom_EventScript_DisableHealing
	compare VAR_RESULT, TRUE
	call_if_ne BattleFrontier_BattlePikeRoom_EventScript_EnableHealing
	pike_get PIKE_DATA_WIN_STREAK
	addvar VAR_RESULT, 1
	pike_set PIKE_DATA_WIN_STREAK, VAR_RESULT
	frontier_get FRONTIER_DATA_BATTLE_NUM
	addvar VAR_RESULT, 1
	frontier_set FRONTIER_DATA_BATTLE_NUM, VAR_RESULT
	pike_isfinalroom
	compare VAR_RESULT, TRUE
	call_if_eq BattleFrontier_BattlePikeRoom_EventScript_WarpToFinalRoom
	compare VAR_RESULT, FALSE
	call_if_eq BattleFrontier_BattlePikeRoom_EventScript_WarpToThreePathRoom
	waitstate
	end

BattleFrontier_BattlePikeRoom_EventScript_DisableHealing:: @ 82C4128
	pike_nohealing TRUE
	return

BattleFrontier_BattlePikeRoom_EventScript_EnableHealing:: @ 82C4136
	pike_nohealing FALSE
	return

BattleFrontier_BattlePikeRoom_EventScript_WarpToFinalRoom:: @ 82C4144
	applymovement OBJ_EVENT_ID_PLAYER, BattleFrontier_BattlePikeRoom_Movement_HidePlayer
	waitmovement 0
	call BattleFrontier_BattlePike_EventScript_CloseCurtain
	warpsilent MAP_BATTLE_FRONTIER_BATTLE_PIKE_ROOM_FINAL, 255, 2, 7
	return

BattleFrontier_BattlePikeRoom_EventScript_WarpToThreePathRoom:: @ 82C415C
	applymovement OBJ_EVENT_ID_PLAYER, BattleFrontier_BattlePikeRoom_Movement_HidePlayer
	waitmovement 0
	call BattleFrontier_BattlePike_EventScript_CloseCurtain
	warpsilent MAP_BATTLE_FRONTIER_BATTLE_PIKE_THREE_PATH_ROOM, 255, 6, 10
	return

BattleFrontier_BattlePikeRoomWildMons_EventScript_Exit:: @ 82C4174
	pike_exitwildmonroom
	pike_ispartyfullhealth
	compare VAR_RESULT, TRUE
	call_if_eq BattleFrontier_BattlePikeRoom_EventScript_DisableHealing
	compare VAR_RESULT, TRUE
	call_if_ne BattleFrontier_BattlePikeRoom_EventScript_EnableHealing
	pike_get PIKE_DATA_WIN_STREAK
	addvar VAR_RESULT, 1
	pike_set PIKE_DATA_WIN_STREAK, VAR_RESULT
	frontier_get FRONTIER_DATA_BATTLE_NUM
	addvar VAR_RESULT, 1
	frontier_set FRONTIER_DATA_BATTLE_NUM, VAR_RESULT
	pike_isfinalroom
	compare VAR_RESULT, TRUE
	call_if_eq BattleFrontier_BattlePikeRoom_EventScript_WarpToFinalRoom
	compare VAR_RESULT, FALSE
	call_if_eq BattleFrontier_BattlePikeRoom_EventScript_WarpToThreePathRoom
	waitstate
	end

BattleFrontier_BattlePikeRoomWildMons_EventScript_SetEnteredRoom:: @ 82C4202
	setvar VAR_TEMP_3, 1
	setvar VAR_TEMP_2, 1
	end

BattleFrontier_BattlePikeRoomWildMons_EventScript_NoTurningBack:: @ 82C420D
	setvar VAR_TEMP_3, 0
	setvar VAR_TEMP_2, 0
	lockall
	msgbox BattleFrontier_BattlePike_Text_PathBlockedNoTurningBack, MSGBOX_DEFAULT
	closemessage
	end

BattleFrontier_BattlePike_EventScript_Retire:: @ 82C4222
	frontier_set FRONTIER_DATA_CHALLENGE_STATUS CHALLENGE_STATUS_LOST
	warp MAP_BATTLE_FRONTIER_BATTLE_PIKE_LOBBY, 255, 5, 6
	waitstate
	end

BattleFrontier_BattlePikeRoom_OnResume: @ 82C423E
	setorcopyvar VAR_0x8006, VAR_RESULT  @ Save VAR_RESULT from being overwritten
	frontier_get FRONTIER_DATA_CHALLENGE_STATUS
	compare VAR_RESULT, CHALLENGE_STATUS_PAUSED
	goto_if_eq BattleFrontier_BattlePikeThreePathRoom_EventScript_EndOnResume
	compare VAR_RESULT, CHALLENGE_STATUS_SAVING
	goto_if_eq BattleFrontier_BattlePikeThreePathRoom_EventScript_EndOnResume
	call BattleFrontier_BattlePikeRoom_EventScript_ResetSketchedMoves
BattleFrontier_BattlePikeThreePathRoom_EventScript_EndOnResume:: @ 82C426B
	setorcopyvar VAR_RESULT, VAR_0x8006
	end

BattleFrontier_BattlePikeRoom_EventScript_ResetSketchedMoves:: @ 82C4271
	frontier_resetsketch
	return

BattleFrontier_BattlePikeRoom_Movement_HidePlayer: @ 82C427A
	set_invisible
	step_end


code:
@ Note: local IDs shared with scripts.inc for LilycoveCity_ContestLobby
.set LOCALID_MAN, 3
.set LOCALID_BOY, 9
.set LOCALID_TWIN, 10
.set LOCALID_POKEFAN_F, 15
.set LOCALID_EXPERT_M, 16
.set LOCALID_GIRL, 17

.set NUM_OPPONENTS, VAR_0x8009

BerryBlender_Text_WantToMakePokeblocks: @ 8292DEE
	.string "Oh? Did you want to make some {POKEBLOCK}S\n"
	.string "with this old-timer?$"

BerryBlender_Text_Excellent: @ 8292E28
	.string "Excellent!$"

BerryBlender_Text_MadeOldTimerSad: @ 8292E33
	.string "Oh…\n"
	.string "You've made this old-timer sad…$"

BerryBlender_Text_KnowHowToMakePokeblocks: @ 8292E57
	.string "Do you know how to make a {POKEBLOCK}?$"

BerryBlender_Text_LetsBerryBlender: @ 8292E78
	.string "Let's get started, then!\p"
	.string "Let's BERRY BLENDER!$"

BerryBlender_Text_ExplainBerryBlending: @ 8292EA6
	.string "Okay, a little explanation, then.\p"
	.string "Oh, don't worry, it's quite simple.\p"
	.string "When the BLENDER's arrow comes to\n"
	.string "your marker, just press the A Button.\p"
	.string "That's all you have to do.\n"
	.string "You'll see how easy it is when you try.$"

BerryBlender_Text_DontHaveAnyBerries: @ 8292F77
	.string "Oh?\n"
	.string "You don't have any BERRIES?\p"
	.string "If you don't have any BERRIES,\n"
	.string "you can't make any {POKEBLOCK}S.$"

BerryBlender_Text_CanHaveOneOfMyBerries: @ 8292FD1
	.string "Well, that won't do at all now, will it?\p"
	.string "If you don't mind leftovers, you can\n"
	.string "have one of my BERRIES.\p"
	.string "That way, we could make some {POKEBLOCK}S\n"
	.string "together using the BERRY BLENDER.$"

BerryBlender_Text_DontHaveAnyBerriesToSpare: @ 829307D
	.string "If I had some BERRIES left over,\n"
	.string "I'd gladly give you one…\p"
	.string "But, I don't have any to spare today.\n"
	.string "We'll have to do this another time.$"

BerryBlender_Text_PokeblockCaseIsFull: @ 8293101
	.string "But your {POKEBLOCK} CASE is full.\p"
	.string "You should use some {POKEBLOCK}S before\n"
	.string "you come see me again.$"

BerryBlender_Text_DontHavePokeblockCase: @ 8293157
	.string "But you don't have a {POKEBLOCK} CASE.\p"
	.string "You should get a {POKEBLOCK} CASE and then\n"
	.string "come see me.$"

BerryBlender_Text_LetsGetBlendingAlready: @ 82931AA
	.string "Let's get blending already!$"

BerryBlender_Text_WhatKindOfPokeblockWillIGet: @ 82931C6
	.string "I wonder what kind of {POKEBLOCK} I'll get?\n"
	.string "This is so exciting!$"

BerryBlender_Text_WantToBlendPokeblocksWithUs: @ 8293201
	.string "Hi, there! Did you want to blend some\n"
	.string "{POKEBLOCK}S with us?$"

BerryBlender_Text_Okay: @ 8293237
	.string "Okay!$"

BerryBlender_Text_ThatsTooBad: @ 829323D
	.string "That's too bad…\p"
	.string "But we'll always be around whenever\n"
	.string "you get the urge to blend!$"

BerryBlender_Text_KnowHowToMakePokeblocks2: @ 829328C
	.string "Of course, you do know how to\n"
	.string "blend {POKEBLOCK}S, don't you?$"

BerryBlender_Text_LetsBerryBlender2: @ 82932C3
	.string "Let's get started, then!\p"
	.string "Let's BERRY BLENDER!$"

BerryBlender_Text_ExplainBerryBlending2: @ 82932F1
	.string "Okay!\n"
	.string "Let me explain it to you!\p"
	.string "When the spinning BLENDER's arrow\n"
	.string "reaches your marker, just press\l"
	.string "the A Button.\p"
	.string "That's all it takes.\n"
	.string "Pretty easy, don't you think?$"

BerryBlender_Text_DontHaveAnyBerries2: @ 8293394
	.string "Oh, but wait a second here…\n"
	.string "You don't have any BERRIES.\p"
	.string "You can't make any {POKEBLOCK}S without\n"
	.string "BERRIES…\p"
	.string "We'll always be around whenever you\n"
	.string "get hold of some BERRIES to blend.$"

BerryBlender_Text_PokeblockCaseIsFull2: @ 829343E
	.string "Oh, but wait a second here…\n"
	.string "Your {POKEBLOCK} CASE is full.\p"
	.string "You should use some {POKEBLOCK}S and\n"
	.string "then come back.$"

BerryBlender_Text_DontHavePokeblockCase2: @ 82934A2
	.string "Oh, but wait a second here…\n"
	.string "You don't have a {POKEBLOCK} CASE.\p"
	.string "You should get a {POKEBLOCK} CASE and\n"
	.string "then come back.$"

@ Unused
BerryBlender_Text_MakePokeblocksWithOurGroup: @ 829350B
	.string "Oh, hello! Did you want to make some\n"
	.string "{POKEBLOCK}S with our little group?$"

BerryBlender_Text_OhDear: @ 829354E
	.string "Oh, dear!$"

BerryBlender_Text_LeftUsInShock: @ 8293558
	.string "Oh, dear me…\p"
	.string "You've left us in shock!$"

BerryBlender_Text_KnowHowToMakePokeblocks3: @ 829357E
	.string "Naturally, you know how to make\n"
	.string "{POKEBLOCK}S, don't you?$"

BerryBlender_Text_LetsBerryBlender3: @ 82935B1
	.string "Okay, dear!\n"
	.string "Let's get started!\p"
	.string "Let's BERRY BLENDER!$"

BerryBlender_Text_ExplainBerryBlending3: @ 82935E5
	.string "Oh, dear!\p"
	.string "Then, I'll explain it to you nicely.\p"
	.string "When the BLENDER's arrow spins to\n"
	.string "your marker, press the A Button.\p"
	.string "That's all it takes.\n"
	.string "Isn't it simple?$"

BerryBlender_Text_DontHaveAnyBerries3: @ 829367D
	.string "You don't have any BERRIES,\n"
	.string "do you?\p"
	.string "If you don't have any BERRIES,\n"
	.string "you can't make any {POKEBLOCK}S.\p"
	.string "We'll always be making {POKEBLOCK}S here,\n"
	.string "so let's make some together when\l"
	.string "you get a BERRY or two.$"

BerryBlender_Text_PokeblockCaseIsFull3: @ 8293738
	.string "Your {POKEBLOCK} CASE is full,\n"
	.string "it looks like.\p"
	.string "You should use some {POKEBLOCK}S up\n"
	.string "and then come back.$"

BerryBlender_Text_DontHavePokeblockCase3: @ 8293792
	.string "You haven't gotten a {POKEBLOCK} CASE\n"
	.string "yet, it looks like.\p"
	.string "You need to get a {POKEBLOCK} CASE before\n"
	.string "you come back.$"

BerryBlender_Text_SetNewBlenderRecord: @ 82937F9
	.string "Okay! Today's going to be the day that\n"
	.string "I set a new BLENDER speed record!$"

BerryBlender_Text_LookGoodAtBlendingJoinUs: @ 8293842
	.string "Oh, dear!\n"
	.string "You look as if you're good at blending.\l"
	.string "Would you like to join us?$"

BerryBlender_Text_MakeDeliciousPokeblocks: @ 829388F
	.string "I'm going to make delicious {POKEBLOCK}S\n"
	.string "and make my POKéMON cuter.$"

BerryBlender_Text_SaveGameBeforeBerryBlenderLink: @ 82938CD
	.string "{POKEBLOCK}S will be made with your friends \n"
	.string "from BERRIES in the BERRY BLENDER.\p"
	.string "Is it okay to save the game before\n"
	.string "linking with your friends?$"

BerryBlender_Text_SearchingForFriends: @ 8293955
	.string "Searching for your friends…\n"
	.string "… … B Button: Cancel$"

BerryBlender_Text_Player1Arrived: @ 8293986
	.string "{STR_VAR_1} arrived.$"

BerryBlender_Text_Player1And2Arrived: @ 8293992
	.string "{STR_VAR_1} and {STR_VAR_2} arrived.$"

BerryBlender_Text_AllPlayersArrived: @ 82939A5
	.string "{STR_VAR_1}, {STR_VAR_2}, and\n"
	.string "{STR_VAR_3} arrived.$"

BerryBlender_Text_NoBerriesLink: @ 82939BD
	.string "You have no BERRIES.\n"
	.string "The BERRY BLENDER can't be used.$"

BerryBlender_Text_PokeblockCaseIsFullLink: @ 82939F3
	.string "Your {POKEBLOCK} CASE is full.\n"
	.string "The BERRY BLENDER can't be used.$"

BerryBlender_Text_DontHavePokeblockCaseLink: @ 8293A2D
	.string "You don't have a {POKEBLOCK} CASE.\n"
	.string "The BERRY BLENDER can't be used.$"

BerryBlender_Text_LoveMakingPokeblocks: @ 8293A6B
	.string "I love making {POKEBLOCK}S.\p"
	.string "I always have some BERRIES with me.$"

BerryBlender_Text_MakePokeblocksUsingBerryBlender: @ 8293AA5
	.string "If you'd like, we could make some\n"
	.string "{POKEBLOCK}S together using the\l"
	.string "BERRY BLENDER.$"

BerryBlender_Text_DontHaveAnyBerriesHaveOne: @ 8293AF0
	.string "Oh?\n"
	.string "You don't have any BERRIES?\p"
	.string "Well, that won't do at all now, will it?\p"
	.string "If you don't mind leftovers, you can\n"
	.string "have one of my BERRIES.$"

BerryBlender_Text_UseItToMakePokeblocksTogether: @ 8293B76
	.string "We'll use it to make {POKEBLOCK}S together\n"
	.string "using the BERRY BLENDER.$"

BerryBlender_Text_DontHaveAnyBerriesNoneToSpare: @ 8293BB4
	.string "Oh?\n"
	.string "You don't have any BERRIES?\p"
	.string "If I had some left over, I'd gladly\n"
	.string "give you one…\p"
	.string "But, I don't have any to spare today.\n"
	.string "Sorry about that.$"

BerryBlender_EventScript_BerryBlender1:: @ 8293C3E
	lockall
	goto_if_unset FLAG_HIDE_LILYCOVE_CONTEST_HALL_BLEND_MASTER, BerryBlender_EventScript_BlendMasterPresent
	setvar NUM_OPPONENTS, 1
	applymovement LOCALID_EXPERT_M, BerryBlender_Movement_BlendLeaderWalkInPlace
	waitmovement 0
	msgbox BerryBlender_Text_WantToMakePokeblocks, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_TryUseBerryBlender1
	goto BerryBlender_EventScript_DeclineBlender1
	end

BerryBlender_EventScript_DeclineBlender1: @ 8293C70
	msgbox BerryBlender_Text_MadeOldTimerSad, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender1NoBerries: @ 8293C7A
	msgbox BerryBlender_Text_DontHaveAnyBerries, MSGBOX_DEFAULT
	dotimebasedevents
	goto_if_set FLAG_DAILY_CONTEST_LOBBY_RECEIVED_BERRY, BerryBlender_EventScript_Blender1NoSpareBerries
	goto BerryBlender_EventScript_Blender1GiveSpareBerry
	end

BerryBlender_EventScript_Blender1NoSpareBerries: @ 8293C92
	msgbox BerryBlender_Text_DontHaveAnyBerriesToSpare, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender1GiveSpareBerry: @ 8293C9C
	msgbox BerryBlender_Text_CanHaveOneOfMyBerries, MSGBOX_DEFAULT
	giveitem ITEM_PECHA_BERRY
	setflag FLAG_DAILY_CONTEST_LOBBY_RECEIVED_BERRY
	goto BerryBlender_EventScript_UseBerryBlender1
	end

BerryBlender_EventScript_UseBerryBlender1: @ 8293CB9
	msgbox BerryBlender_Text_KnowHowToMakePokeblocks, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_StartBlender1
	goto BerryBlender_EventScript_ExplainBlending1
	end

BerryBlender_EventScript_StartBlender1: @ 8293CD2
	msgbox BerryBlender_Text_LetsBerryBlender, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_DoBerryBlending
	end

BerryBlender_EventScript_ExplainBlending1: @ 8293CE0
	msgbox BerryBlender_Text_ExplainBerryBlending, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_StartBlender1
	end

BerryBlender_EventScript_TryUseBerryBlender1: @ 8293CEE
	checkitem ITEM_POKEBLOCK_CASE, 1
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_Blender1NoCase
	specialvar VAR_RESULT, GetFirstFreePokeblockSlot
	compare VAR_RESULT, 65535
	goto_if_eq BerryBlender_EventScript_Blender1CaseFull
	specialvar VAR_RESULT, PlayerHasBerries
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_Blender1NoBerries
	msgbox BerryBlender_Text_Excellent, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_UseBerryBlender1
	end

BerryBlender_EventScript_DoBerryBlending: @ 8293D2C
	copyvar VAR_0x8004, NUM_OPPONENTS
	fadescreen FADE_TO_BLACK
	special DoBerryBlending
	waitstate
	releaseall
	end

BerryBlender_EventScript_Blender1CaseFull: @ 8293D39
	msgbox BerryBlender_Text_PokeblockCaseIsFull, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender1NoCase: @ 8293D43
	msgbox BerryBlender_Text_DontHavePokeblockCase, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_BerryBlender2:: @ 8293D4D
	lockall
	setvar NUM_OPPONENTS, 2
	applymovement LOCALID_TWIN, Common_Movement_FaceOriginalDirection
	applymovement LOCALID_MAN, BerryBlender_Movement_BlendLeaderWalkInPlace
	waitmovement 0
	msgbox BerryBlender_Text_WantToBlendPokeblocksWithUs, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_TryUseBerryBlender2
	goto BerryBlender_EventScript_DeclineBlender2
	end

BerryBlender_EventScript_DeclineBlender2: @ 8293D7D
	msgbox BerryBlender_Text_ThatsTooBad, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender2NoBerries: @ 8293D87
	msgbox BerryBlender_Text_DontHaveAnyBerries2, MSGBOX_DEFAULT
	release
	end

BerryBlender_EventScript_UseBerryBlender2: @ 8293D91
	msgbox BerryBlender_Text_KnowHowToMakePokeblocks2, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_StartBlender2
	goto BerryBlender_EventScript_ExplainBlending2
	end

BerryBlender_EventScript_StartBlender2: @ 8293DAA
	msgbox BerryBlender_Text_LetsBerryBlender2, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_DoBerryBlending
	end

BerryBlender_EventScript_ExplainBlending2: @ 8293DB8
	msgbox BerryBlender_Text_ExplainBerryBlending2, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_StartBlender2
	end

BerryBlender_EventScript_TryUseBerryBlender2: @ 8293DC6
	specialvar VAR_RESULT, PlayerHasBerries
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_Blender2NoBerries
	checkitem ITEM_POKEBLOCK_CASE, 1
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_Blender2NoCase
	msgbox BerryBlender_Text_Okay, MSGBOX_DEFAULT
	specialvar VAR_RESULT, GetFirstFreePokeblockSlot
	compare VAR_RESULT, 65535
	goto_if_ne BerryBlender_EventScript_UseBerryBlender2
	compare VAR_RESULT, 65535
	goto_if_eq BerryBlender_EventScript_Blender2CaseFull
	end

BerryBlender_EventScript_Blender2CaseFull: @ 8293E0A
	msgbox BerryBlender_Text_PokeblockCaseIsFull2, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender2NoCase: @ 8293E14
	msgbox BerryBlender_Text_DontHavePokeblockCase2, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_BerryBlender3:: @ 8293E1E
	lockall
	setvar VAR_0x8008, LOCALID_POKEFAN_F
	setvar NUM_OPPONENTS, 3
	applymovement LOCALID_BOY, Common_Movement_FaceOriginalDirection
	applymovement LOCALID_GIRL, Common_Movement_FaceOriginalDirection
	applymovement VAR_0x8008, BerryBlender_Movement_BlendLeaderWalkInPlace
	waitmovement 0
	msgbox BerryBlender_Text_LookGoodAtBlendingJoinUs, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_TryUseBlender3
	goto BerryBlender_EventScript_DeclineBlender3
	end

BerryBlender_EventScript_DeclineBlender3: @ 8293E5A
	msgbox BerryBlender_Text_LeftUsInShock, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender3NoBerries: @ 8293E64
	msgbox BerryBlender_Text_DontHaveAnyBerries3, MSGBOX_DEFAULT
	release
	end

BerryBlender_EventScript_UseBerryBlender3: @ 8293E6E
	msgbox BerryBlender_Text_KnowHowToMakePokeblocks3, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_StartBlender3
	goto BerryBlender_EventScript_ExplainBlending3
	end

BerryBlender_EventScript_StartBlender3: @ 8293E87
	msgbox BerryBlender_Text_LetsBerryBlender3, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_DoBerryBlending
	end

BerryBlender_EventScript_ExplainBlending3: @ 8293E95
	msgbox BerryBlender_Text_ExplainBerryBlending3, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_StartBlender3
	end

BerryBlender_EventScript_TryUseBlender3: @ 8293EA3
	specialvar VAR_RESULT, PlayerHasBerries
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_Blender3NoBerries
	checkitem ITEM_POKEBLOCK_CASE, 1
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_Blender3NoCase
	msgbox BerryBlender_Text_OhDear, MSGBOX_DEFAULT
	specialvar VAR_RESULT, GetFirstFreePokeblockSlot
	compare VAR_RESULT, 65535
	goto_if_ne BerryBlender_EventScript_UseBerryBlender3
	compare VAR_RESULT, 65535
	goto_if_eq BerryBlender_EventScript_Blender3CaseFull
	end

BerryBlender_EventScript_Blender3CaseFull: @ 8293EE7
	msgbox BerryBlender_Text_PokeblockCaseIsFull3, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender3NoCase: @ 8293EF1
	msgbox BerryBlender_Text_DontHavePokeblockCase3, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_BlendMasterPresent: @ 8293EFB
	lockall
	setvar NUM_OPPONENTS, 1
	msgbox BerryBlender_Text_SeeMyMasteryInAction, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_TryBlendWithBlendMaster
	msgbox BerryBlender_Text_TooBusyNowIsee, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_BlendMasterNoBerries: @ 8293F1E
	msgbox BerryBlender_Text_BlendMasterNoBerries, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_TryBlendWithBlendMaster: @ 8293F28
	checkitem ITEM_POKEBLOCK_CASE, 1
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_BlendMasterNoCase
	specialvar VAR_RESULT, PlayerHasBerries
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_BlendMasterNoBerries
	specialvar VAR_RESULT, GetFirstFreePokeblockSlot
	compare VAR_RESULT, 65535
	goto_if_ne BerryBlender_EventScript_BlendWithBlendMaster
	compare VAR_RESULT, 65535
	goto_if_eq BerryBlender_EventScript_BlendMasterCaseFull
	end

BerryBlender_EventScript_BlendWithBlendMaster: @ 8293F64
	msgbox BerryBlender_Text_BlendMasterKnowHowToMakePokeblocks, MSGBOX_YESNO
	compare VAR_RESULT, NO
	call_if_eq BerryBlender_EventScript_BlendMasterExplainBlending
	msgbox BerryBlender_Text_BlendMasterLetsBerryBlender, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_DoBerryBlending
	end

BerryBlender_EventScript_BlendMasterExplainBlending: @ 8293F85
	msgbox BerryBlender_Text_BlendMasterExplainBerryBlending, MSGBOX_DEFAULT
	return

BerryBlender_EventScript_BlendMasterNoCase: @ 8293F8E
	msgbox BerryBlender_Text_BlendMasterNoPokeblockCase, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_BlendMasterCaseFull: @ 8293F98
	msgbox BerryBlender_Text_BlendMasterPokeblockCaseFull, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_Blender2Man:: @ 8293FA2
	msgbox BerryBlender_Text_SetNewBlenderRecord, MSGBOX_NPC
	end

BerryBlender_EventScript_Blender3PokefanF:: @ 8293FAB
	msgbox BerryBlender_Text_LookGoodAtBlendingJoinUs, MSGBOX_NPC
	end

BerryBlender_EventScript_Blender2Twin:: @ 8293FB4
	msgbox BerryBlender_Text_MakeDeliciousPokeblocks, MSGBOX_NPC
	end

BerryBlender_EventScript_Blender1ExpertM:: @ 8293FBD
	setvar VAR_0x8008, 15
	goto BerryBlender_EventScript_ExpertMCheckGiveBerry
	end

BerryBlender_EventScript_ExpertMCheckGiveBerry: @ 8293FC8
	lock
	faceplayer
	msgbox BerryBlender_Text_LoveMakingPokeblocks, MSGBOX_DEFAULT
	specialvar VAR_RESULT, PlayerHasBerries
	compare VAR_RESULT, TRUE
	goto_if_eq BerryBlender_EventScript_ExpertMPlayerHasBerries
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_ExpertMNoBerries
	end

BerryBlender_EventScript_ExpertMPlayerHasBerries: @ 8293FEE
	msgbox BerryBlender_Text_MakePokeblocksUsingBerryBlender, MSGBOX_DEFAULT
	release
	end

BerryBlender_EventScript_ExpertMNoBerries: @ 8293FF8
	checkitem ITEM_POKEBLOCK_CASE, 1
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_ExpertMNoSpareBerries
	specialvar VAR_RESULT, GetFirstFreePokeblockSlot
	compare VAR_RESULT, 65535
	goto_if_eq BerryBlender_EventScript_ExpertMNoSpareBerries
	dotimebasedevents
	goto_if_set FLAG_DAILY_CONTEST_LOBBY_RECEIVED_BERRY, BerryBlender_EventScript_ExpertMNoSpareBerries
	goto BerryBlender_EventScript_ExpertMGiveBerry
	end

BerryBlender_EventScript_ExpertMNoSpareBerries: @ 8294028
	msgbox BerryBlender_Text_DontHaveAnyBerriesNoneToSpare, MSGBOX_DEFAULT
	release
	end

BerryBlender_EventScript_ExpertMGiveBerry: @ 8294032
	msgbox BerryBlender_Text_DontHaveAnyBerriesHaveOne, MSGBOX_DEFAULT
	giveitem ITEM_PECHA_BERRY
	setflag FLAG_DAILY_CONTEST_LOBBY_RECEIVED_BERRY
	msgbox BerryBlender_Text_UseItToMakePokeblocksTogether, MSGBOX_DEFAULT
	release
	end

BerryBlender_Movement_BlendLeaderWalkInPlace: @ 8294053
	walk_in_place_fastest_right
	step_end

BerryBlender_EventScript_BerryBlenderLink:: @ 8294055
	lockall
	specialvar VAR_RESULT, PlayerHasBerries
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_LinkBlenderNoBerries
	checkitem ITEM_POKEBLOCK_CASE, 1
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_LinkBlenderNoCase
	specialvar VAR_RESULT, GetFirstFreePokeblockSlot
	compare VAR_RESULT, 65535
	goto_if_ne BerryBlender_EventScript_LinkBlenderSaveGame
	compare VAR_RESULT, 65535
	goto_if_eq BerryBlender_EventScript_LinkBlenderCaseFull
	end

BerryBlender_EventScript_LinkBlenderSaveGame: @ 8294092
	msgbox BerryBlender_Text_SaveGameBeforeBerryBlenderLink, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryBlender_EventScript_TryDoLinkBlender
	compare VAR_RESULT, NO
	goto_if_eq BerryBlender_EventScript_CancelLinkBlender
	end

BerryBlender_EventScript_LinkBlenderNoBerries: @ 82940B1
	msgbox BerryBlender_Text_NoBerriesLink, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_TryDoLinkBlender: @ 82940BB
	call Common_EventScript_SaveGame
	compare VAR_RESULT, FALSE
	goto_if_eq BerryBlender_EventScript_CancelLinkBlender
	specialvar VAR_RESULT, IsWirelessAdapterConnected
	compare VAR_RESULT, TRUE
	goto_if_eq BerryBlender_EventScript_StartDecideLinkLeader
	message BerryBlender_Text_SearchingForFriends
	waitmessage
	special TryBerryBlenderLinkup
	waitstate
	compare VAR_RESULT, LINKUP_SUCCESS
	goto_if_eq BerryBlender_EventScript_SpawnLinkPartners
	compare VAR_RESULT, LINKUP_SOMEONE_NOT_READY
	goto_if_eq BerryBlender_EventScript_CloseLinkNotReady
	compare VAR_RESULT, LINKUP_DIFF_SELECTIONS
	goto_if_eq BerryBlender_EventScript_CloseLinkDifferentSelections
	compare VAR_RESULT, LINKUP_FAILED
	goto_if_eq BerryBlender_EventScript_CloseLink
	compare VAR_RESULT, LINKUP_CONNECTION_ERROR
	goto_if_eq BerryBlender_EventScript_LinkError
	end

BerryBlender_EventScript_TwoPlayerLink: @ 829411D
	msgbox BerryBlender_Text_Player1Arrived, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_DoLinkBerryBlending
	end

BerryBlender_EventScript_ThreePlayerLink: @ 829412B
	msgbox BerryBlender_Text_Player1And2Arrived, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_DoLinkBerryBlending
	end

BerryBlender_EventScript_FourPlayerLink: @ 8294139
	msgbox BerryBlender_Text_AllPlayersArrived, MSGBOX_DEFAULT
	goto BerryBlender_EventScript_DoLinkBerryBlending
	end

BerryBlender_EventScript_DoLinkBerryBlending: @ 8294147
	setvar VAR_0x8004, 0  @ number of opponents, 0 indicates Link
	fadescreen FADE_TO_BLACK
	removeobject 240 @ Unclear where these local IDs come from,
	removeobject 239 @ but presumably they'd be the 4 link players
	removeobject 238
	removeobject 237
	special DoBerryBlending
	waitstate
	releaseall
	end

BerryBlender_EventScript_CancelLinkBlender: @ 8294160
	releaseall
	end

BerryBlender_EventScript_LinkBlenderCaseFull: @ 8294162
	msgbox BerryBlender_Text_PokeblockCaseIsFullLink, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_LinkBlenderNoCase: @ 829416C
	msgbox BerryBlender_Text_DontHavePokeblockCaseLink, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_CloseLinkNotReady: @ 8294176
	special CloseLink
	msgbox Text_SomeoneIsNotReadyToLink, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_CloseLinkDifferentSelections: @ 8294183
	special CloseLink
	msgbox Text_PlayersMadeDifferentSelections, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_CloseLink: @ 8294190
	special CloseLink
	msgbox gText_PokeblockLinkCanceled, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_LinkError: @ 829419D
	special CloseLink
	msgbox Text_LinkErrorPleaseReset, MSGBOX_DEFAULT
	releaseall
	end

BerryBlender_EventScript_SpawnLinkPartners: @ 82941AA
	fadescreen FADE_TO_BLACK
	specialvar VAR_RESULT, GetLinkPartnerNames
	copyvar VAR_0x8008, VAR_RESULT
	copyvar VAR_0x8004, VAR_0x8008
	special SpawnLinkPartnerObjectEvent
	goto BerryBlender_EventScript_LinkPlayersArrived
	end

BerryBlender_EventScript_LinkPlayersArrived: @ 82941C4
	fadescreen FADE_FROM_BLACK
	switch VAR_0x8008
	case 2, BerryBlender_EventScript_TwoPlayerLink
	case 3, BerryBlender_EventScript_ThreePlayerLink
	case 4, BerryBlender_EventScript_FourPlayerLink
	end

BerryBlender_EventScript_StartDecideLinkLeader: @ 82941ED
	setvar VAR_0x8004, LINK_GROUP_BERRY_BLENDER
	goto BerryBlender_EventScript_DecideLinkLeader
	end

BerryBlender_EventScript_DecideLinkLeader: @ 82941F8
	message LilycoveCity_ContestLobby_Text_PleaseDecideLinkLeader
	waitmessage
	multichoice 16, 6, MULTI_LINK_LEADER, 0
	switch VAR_RESULT
	case 0, BerryBlender_EventScript_TryJoinGroup
	case 1, BerryBlender_EventScript_TryLeadGroup
	case 2, BerryBlender_EventScript_CloseLink
	case MULTI_B_PRESSED, BerryBlender_EventScript_CloseLink
	end

BerryBlender_EventScript_TryLeadGroup: @ 8294235
	call BerryBlender_EventScript_TryBecomeLinkLeader
	compare VAR_RESULT, LINKUP_SUCCESS
	goto_if_eq BerryBlender_EventScript_LinkLeaderDecided
	compare VAR_RESULT, LINKUP_FAILED
	goto_if_eq BerryBlender_EventScript_DecideLinkLeader
	compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
	goto_if_eq BerryBlender_EventScript_TryLeadGroup
	release
	end

BerryBlender_EventScript_TryJoinGroup: @ 829425D
	call BerryBlender_EventScript_TryJoinLinkGroup
	compare VAR_RESULT, LINKUP_SUCCESS
	goto_if_eq BerryBlender_EventScript_LinkLeaderDecided
	compare VAR_RESULT, LINKUP_FAILED
	goto_if_eq BerryBlender_EventScript_DecideLinkLeader
	compare VAR_RESULT, LINKUP_RETRY_ROLE_ASSIGN
	goto_if_eq BerryBlender_EventScript_TryJoinGroup
	release
	end

BerryBlender_EventScript_TryBecomeLinkLeader: @ 8294285
	special TryBecomeLinkLeader
	waitstate
	return

BerryBlender_EventScript_TryJoinLinkGroup: @ 829428A
	special TryJoinLinkGroup
	waitstate
	return

BerryBlender_EventScript_LinkLeaderDecided: @ 829428F
	goto BerryBlender_EventScript_SpawnLinkPartners
	end


code:
BerryTreeScript:: @ 82742F9
	special ObjectEventInteractionGetBerryTreeData
	switch VAR_0x8004
	case BERRY_STAGE_SPARKLING, BerryTree_EventScript_Sparkling
	case BERRY_STAGE_NO_BERRY, BerryTree_EventScript_CheckSoil
	case BERRY_STAGE_PLANTED, BerryTree_EventScript_CheckBerryStage1
	case BERRY_STAGE_SPROUTED, BerryTree_EventScript_CheckBerryStage2
	case BERRY_STAGE_TALLER, BerryTree_EventScript_CheckBerryStage3
	case BERRY_STAGE_FLOWERING, BerryTree_EventScript_CheckBerryStage4
	case BERRY_STAGE_BERRIES, BerryTree_EventScript_CheckBerryFullyGrown
	end

BerryTree_EventScript_Sparkling:: @ 827434F
	lockall
	message BerryTree_Text_ExclamationPoint
	waitmessage
	waitbuttonpress
	releaseall
	end

BerryTree_EventScript_CheckSoil:: @ 8274359
	lock
	faceplayer
	specialvar VAR_RESULT, PlayerHasBerries
	compare VAR_RESULT, TRUE
	goto_if_eq BerryTree_EventScript_WantToPlant
	message BerryTree_Text_ItsSoftLoamySoil
	waitmessage
	waitbuttonpress
	release
	end

BerryTree_EventScript_WantToPlant:: @ 8274374
	msgbox BerryTree_Text_WantToPlant, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryTree_EventScript_ChooseBerryToPlant
	compare VAR_RESULT, NO
	goto_if_eq BerryTree_EventScript_CancelPlanting
	end

BerryTree_EventScript_ChooseBerryToPlant:: @ 8274393
	fadescreen FADE_TO_BLACK
	closemessage
	special Bag_ChooseBerry
	waitstate
	compare VAR_ITEM_ID, 0
	goto_if_eq BerryTree_EventScript_CancelPlanting
	removeitem VAR_ITEM_ID
	call BerryTree_EventScript_PlantBerry

BerryTree_EventScript_CancelPlanting:: @ 82743AF
	release
	end

BerryTree_EventScript_CheckBerryStage1:: @ 82743B1
	lockall
	special ObjectEventInteractionGetBerryCountString
	message BerryTree_Text_BerryGrowthStage1
	waitmessage
	waitbuttonpress
	goto BerryTree_EventScript_WantToWater

BerryTree_EventScript_CheckBerryStage2:: @ 82743C1
	lockall
	special ObjectEventInteractionGetBerryName
	message BerryTree_Text_BerryGrowthStage2
	waitmessage
	waitbuttonpress
	goto BerryTree_EventScript_WantToWater

BerryTree_EventScript_CheckBerryStage3:: @ 82743D1
	lockall
	special ObjectEventInteractionGetBerryName
	message BerryTree_Text_BerryGrowthStage3
	waitmessage
	waitbuttonpress
	goto BerryTree_EventScript_WantToWater

BerryTree_EventScript_CheckBerryStage4:: @ 82743E1
	call BerryTree_EventScript_GetCareAdverb
	lockall
	special ObjectEventInteractionGetBerryName
	message BerryTree_Text_BerryGrowthStage4
	waitmessage
	waitbuttonpress
	goto BerryTree_EventScript_WantToWater

@ VAR_0x8005 here is the number of times watered
@ Buffered by ObjectEventInteractionGetBerryTreeData
BerryTree_EventScript_GetCareAdverb:: @ 82743F6
	compare VAR_0x8005, 0
	goto_if_eq BerryTree_EventScript_SetAdverbPoor
	compare VAR_0x8005, 4
	goto_if_eq BerryTree_EventScript_SetAdverbGreat
	bufferstring 1, BerryTree_Text_CareAdverbGood
	return

BerryTree_EventScript_SetAdverbGreat:: @ 8274413
	bufferstring 1, BerryTree_Text_CareAdverbGreat
	return

BerryTree_EventScript_SetAdverbPoor:: @ 827441A
	bufferstring 1, BerryTree_Text_CareAdverbPoor
	return

@ VAR_0x8006 here is the number of berries
BerryTree_EventScript_CheckBerryFullyGrown:: @ 8274421
	buffernumberstring 1, VAR_0x8006
	lock
	faceplayer
	special ObjectEventInteractionGetBerryCountString
	msgbox BerryTree_Text_WantToPick, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryTree_EventScript_PickBerry
	compare VAR_RESULT, NO
	goto_if_eq BerryTree_EventScript_CancelPickingBerry

BerryTree_EventScript_PickBerry:: @ 8274448
	special ObjectEventInteractionPickBerryTree
	compare VAR_0x8004, 0
	goto_if_eq BerryTree_EventScript_BerryPocketFull
	special IncrementDailyPickedBerries
	special ObjectEventInteractionRemoveBerryTree
	message BerryTree_Text_PickedTheBerry
	playfanfare MUS_OBTAIN_BERRY
	waitmessage
	waitfanfare
	waitbuttonpress
	message BerryTree_Text_PutAwayBerry
	waitmessage
	waitbuttonpress
	release
	end

BerryTree_EventScript_BerryPocketFull:: @ 8274470
	message BerryTree_Text_BerryPocketFull
	waitmessage
	waitbuttonpress
	release
	end

BerryTree_EventScript_CancelPickingBerry:: @ 8274479
	message BerryTree_Text_BerryLeftUnpicked
	waitmessage
	waitbuttonpress
	release
	end

BerryTree_EventScript_ItemUsePlantBerry:: @ 8274482
	lockall
	special ObjectEventInteractionGetBerryTreeData
	call BerryTree_EventScript_PlantBerry
	releaseall
	end

BerryTree_EventScript_WantToWater:: @ 827448D
	checkitem ITEM_WAILMER_PAIL, 1
	compare VAR_RESULT, 0
	goto_if_eq BerryTree_EventScript_DontWater
	special ObjectEventInteractionGetBerryName
	msgbox BerryTree_Text_WantToWater, MSGBOX_YESNO
	compare VAR_RESULT, YES
	goto_if_eq BerryTree_EventScript_WaterBerry
	compare VAR_RESULT, NO
	goto_if_eq BerryTree_EventScript_DontWater

BerryTree_EventScript_DontWater:: @ 82744BE
	releaseall
	end

BerryTree_EventScript_ItemUseWailmerPail:: @ 82744C0
	special ObjectEventInteractionGetBerryTreeData
	lockall
BerryTree_EventScript_WaterBerry:: @ 82744C4
	special ObjectEventInteractionGetBerryName
	message BerryTree_Text_WateredTheBerry
	waitmessage
	special ObjectEventInteractionWaterBerryTree
	special DoWateringBerryTreeAnim
	waitstate
	message BerryTree_Text_PlantIsDelighted
	waitmessage
	waitbuttonpress
	releaseall
	end

BerryTree_EventScript_PlantBerry:: @ 82744DD
	special ObjectEventInteractionPlantBerryTree
	incrementgamestat GAME_STAT_PLANTED_BERRIES
	special IncrementDailyPlantedBerries
	special ObjectEventInteractionGetBerryCountString
	message BerryTree_Text_PlantedOneBerry
	waitmessage
	waitbuttonpress
	return

BerryTree_Text_ItsSoftLoamySoil: @ 82744F0
	.string "It's soft, loamy soil.$"

BerryTree_Text_WantToPlant: @ 8274507
	.string "It's soft, loamy soil.\n"
	.string "Want to plant a BERRY?$"

BerryTree_Text_PlantedOneBerry: @ 8274535
	.string "{PLAYER} planted one {STR_VAR_1} in\n"
	.string "the soft, loamy soil.$"

BerryTree_Text_BerryGrowthStage1: @ 8274560
	.string "One {STR_VAR_1} was planted here.$"

BerryTree_Text_BerryGrowthStage2: @ 8274579
	.string "{STR_VAR_1} has sprouted.$"

BerryTree_Text_BerryGrowthStage3: @ 827458A
	.string "This {STR_VAR_1} plant is growing taller.$"

BerryTree_Text_BerryGrowthStage4: @ 82745AB
	.string "These {STR_VAR_1} flowers are blooming\n"
	.string "{STR_VAR_2}.$"

BerryTree_Text_CareAdverbGreat: @ 82745CD
	.string "very beautifully$"

BerryTree_Text_CareAdverbPoor: @ 82745DE
	.string "cutely$"

BerryTree_Text_CareAdverbGood: @ 82745E5
	.string "prettily$"

BerryTree_Text_WantToPick: @ 82745EE
	.string "You found {STR_VAR_2} {STR_VAR_1}!\p"
	.string "Do you want to pick the\n"
	.string "{STR_VAR_1}?$"

BerryTree_Text_PickedTheBerry: @ 827461B
	.string "{PLAYER} picked the {STR_VAR_2} {STR_VAR_1}.$"

BerryTree_Text_PutAwayBerry: @ 8274630
	.string "{PLAYER} put away the {STR_VAR_1}\n"
	.string "in the BAG's BERRIES POCKET.\p"
	.string "The soil returned to its soft and\n"
	.string "loamy state.$"

BerryTree_Text_BerryPocketFull: @ 827468F
	.string "The BAG's BERRIES POCKET is full.\p"
	.string "The {STR_VAR_1} couldn't be taken.$"

BerryTree_Text_BerryLeftUnpicked: @ 82746CB
	.string "{PLAYER} left the {STR_VAR_1}\n"
	.string "unpicked.$"

BerryTree_Text_WantToWater: @ 82746E4
	.string "Want to water the {STR_VAR_1} with the\n"
	.string "WAILMER PAIL?$"

BerryTree_Text_WateredTheBerry: @ 8274710
	.string "{PLAYER} watered the {STR_VAR_1}.$"

BerryTree_Text_PlantIsDelighted: @ 8274723
	.string "The plant seems to be delighted.$"

BerryTree_Text_ExclamationPoint: @ 8274744
	.string "!$"