PrisonB1F_MapScriptHeader;trigger count
	db 0
 ;callback count
	db 1
	dbw MAPCALLBACK_TILES, .unlock_opened_doors

.unlock_opened_doors
	checkevent EVENT_PRISON_B1F_DOOR_7
	sif true
		changeblock 14, 16, $18
	checkevent EVENT_PRISON_B1F_DOOR_1
	sif true
		changeblock 2, 6, $18
	checkevent EVENT_PRISON_B1F_DOOR_2
	sif true
		changeblock 14, 6, $18
	checkevent EVENT_PRISON_B1F_DOOR_3
	sif true
		changeblock 24, 6, $18
	checkevent EVENT_PRISON_B1F_DOOR_4
	sif true
		changeblock 2, 20, $18
	checkevent EVENT_PRISON_B1F_DOOR_5
	sif true
		changeblock 14, 20, $18
	checkevent EVENT_PRISON_B1F_DOOR_6
	sif true
		changeblock 24, 20, $18
	return

PrisonB1FDoor1:
	checkevent EVENT_PRISON_B1F_DOOR_1
	sif true
		end
	opentext
	checkitem CAGE_KEY
	sif false
		jumptext PrisonB1F_Text_DoorIsLocked
	setevent EVENT_PRISON_B1F_DOOR_1
	writetext PrisonB1F_Text_UnlockedDoor
	waitbutton
	takeitem CAGE_KEY, 1
	playsound SFX_ENTER_DOOR
	jump PrisonB1F_AfterOpeningDoor

PrisonB1FDoor2:
	checkevent EVENT_PRISON_B1F_DOOR_2
	sif true
		end
	opentext
	checkitem CAGE_KEY
	sif false
		jumptext PrisonB1F_Text_DoorIsLocked
	setevent EVENT_PRISON_B1F_DOOR_2
PrisonB1F_OpenedCageDoor:
	writetext PrisonB1F_Text_UnlockedDoor
	waitbutton
	takeitem CAGE_KEY, 1
	playsound SFX_ENTER_DOOR
PrisonB1F_AfterOpeningDoor:
	setevent EVENT_0
	jump CheckPrisonBasementDoors

PrisonB1FDoor3:
	checkevent EVENT_PRISON_B1F_DOOR_3
	sif true
		end
	opentext
	checkitem CAGE_KEY
	sif false
		jumptext PrisonB1F_Text_DoorIsLocked
	setevent EVENT_PRISON_B1F_DOOR_3
	jump PrisonB1F_OpenedCageDoor

PrisonB1FDoor4:
	checkevent EVENT_PRISON_B1F_DOOR_4
	sif true
		end
	opentext
	checkitem CAGE_KEY
	sif false
		jumptext PrisonB1F_Text_DoorIsLocked
	setevent EVENT_PRISON_B1F_DOOR_4
	jump PrisonB1F_OpenedCageDoor

PrisonB1FDoor5:
	checkevent EVENT_PRISON_B1F_DOOR_5
	sif true
		end
	opentext
	checkitem CAGE_KEY
	sif false
		jumptext PrisonB1F_Text_DoorIsLocked
	setevent EVENT_PRISON_B1F_DOOR_5
	jump PrisonB1F_OpenedCageDoor

PrisonB1FDoor6:
	checkevent EVENT_PRISON_B1F_DOOR_6
	sif true
		end
	opentext
	checkitem CAGE_KEY
	sif false
		jumptext PrisonB1F_Text_DoorIsLocked
	setevent EVENT_PRISON_B1F_DOOR_6
	jump PrisonB1F_OpenedCageDoor

PrisonB1FPasswordDoor:
	checkevent EVENT_PRISON_B1F_PASSWORD_DOOR
	sif true
		end
	opentext
	checkevent EVENT_PRISON_B1F_KNOW_PASSWORD
	sif false
		jumptext .door_needs_password_text
	setevent EVENT_PRISON_B1F_PASSWORD_DOOR
	writetext .door_password_text
	waitbutton
	playsound SFX_ENTER_DOOR
	setevent EVENT_0
	setevent EVENT_PRISON_B1F_DOOR_7
	jump CheckPrisonBasementDoors

.door_needs_password_text
	ctxt "The door is"
	line "locked."

	para "It looks like it"
	line "needs a password"
	cont "to unlock."
	done

.door_password_text
	ctxt "Wigglyjelly!"
	done

PrisonB1FRival:
	trainer EVENT_PRISON_B1F_TRAINER_1, RIVAL1, RIVAL1_4, .before_battle_text, .battle_won_text, $0000, .Script

.Script
	faceplayer
	opentext
	checkevent EVENT_DEFEATED_RIVAL_IN_PRISON
	sif true
		jumptext .after_giving_HM_text
	writetext .after_winning_text
	waitbutton
	givetm 100 + RECEIVED_TM
	opentext
	writetext .got_HM_text
	setevent EVENT_DEFEATED_RIVAL_IN_PRISON
	endtext

.before_battle_text
	ctxt "So you're looking"
	line "for a way out of"
	cont "here as well?"

	para "This prison is ma-"
	line "naged by some lazy"

	para "businessman, and"
	line "guarded by fat,"
	cont "useless imbeciles."

	para "I was arrested"
	line "for my battling"
	para "and hard training"
	line "methods, but<...>"

	para "unfortunately for"
	line "this world full"

	para "of weaklings, I'm"
	line "too powerful to"

	para "be locked within"
	line "these walls of"
	cont "crumbling cement."

	para "I battle #mon"
	line "the way these"
	para "creatures have"
	line "been bred to be."

	para "You think these"
	line "tiny cretins have"
	para "developed their"
	line "ability to"

	para "breathe fire,"
	line "throw boulders,"

	para "and slice their"
	line "enemies to battle"
	cont "just for sport?"

	para "Of course not!"

	para "I battle these"
	line "creatures the way"
	para "they're meant to"
	line "battle: ruthless."

	para "In battle, the"
	line "only true way to"
	para "achieve absolute"
	line "power is exploit-"
	para "ing the weakness"
	line "of the enemy while"
	para "maintaining com-"
	line "plete control of"
	cont "the entire field."

	para "Come, my humble"
	line "Trainer, and let's"
	cont "do battle! Haha."
	done

.battle_won_text
	ctxt "Impossible!"
	done

.after_winning_text
	ctxt "You know, I feel"
	line "sorry for you."

	para "You're never going"
	line "to experience a"
	para "#mon battle"
	line "like I do being"
	cont "stuck in here."

	para "Take this HM."
	done

.got_HM_text
	ctxt "That's what I'm"
	line "using to escape."

	para "I'm not telling"
	line "you how to use"
	para "it to escape, you"
	line "gotta figure that"
	cont "out yourself."
	done

.after_giving_HM_text
	ctxt "The next time we"
	line "meet, I promise."

	para "That battle will"
	line "end the way I"
	cont "desire."
	done

PrisonB1FMetagross:
	faceplayer
	setevent EVENT_PRISON_B1F_NPC_1
	cry METAGROSS
	waitsfx
	setlasttalked 255
	writecode VAR_BATTLETYPE, BATTLETYPE_NORMAL
	loadwildmon METAGROSS, 50
	startbattle
	reloadmapafterbattle
	disappear 3
	end

PrisonB1FFambaco:
	faceplayer
	setevent EVENT_PRISON_B1F_NPC_2
	clearevent EVENT_FAMBACO
	cry FAMBACO
	waitsfx
	applymovement 4, .step_aside
	spriteface 0, 3
	applymovement 4, .leave
	disappear 4
	end

.step_aside
	fast_jump_step_right
	step_end

.leave
	fast_slide_step_right
	fast_slide_step_right
	fast_slide_step_up
	fast_slide_step_up
	fast_slide_step_up
	fast_slide_step_up
	fast_slide_step_up
	step_end

PrisonB1Makuhita:
	cry HARIYAMA
	waitsfx
	setlasttalked 255
	writecode VAR_BATTLETYPE, BATTLETYPE_NORMAL
	loadwildmon HARIYAMA, 45
	startbattle
	reloadmapafterbattle
	end

PrisonB1FNPC3:
	faceplayer
	setevent EVENT_PRISON_B1F_NPC_3
	scall PrisonB1Makuhita
	disappear 5
	end

PrisonB1FNPC4:
	faceplayer
	setevent EVENT_PRISON_B1F_NPC_4
	scall PrisonB1Makuhita
	disappear 6
	end

PrisonB1FNPC5:
	faceplayer
	setevent EVENT_PRISON_B1F_NPC_5
	cry MACHOKE
	waitsfx
	setlasttalked 255
	writecode VAR_BATTLETYPE, BATTLETYPE_NORMAL
	loadwildmon MACHOKE, 45
	startbattle
	reloadmapafterbattle
	disappear 7
	end

PrisonB1FNPC6:
	faceplayer
	setevent EVENT_PRISON_B1F_NPC_6
	cry BRONZONG
	waitsfx
	setlasttalked 255
	writecode VAR_BATTLETYPE, BATTLETYPE_NORMAL
	loadwildmon BRONZONG, 50
	startbattle
	reloadmapafterbattle
	disappear 8
	end

CheckPrisonBasementDoors:
	checkevent EVENT_PRISON_B1F_DOOR_1
	sif true, then
		changeblock 2, 6, $18
	selse
		changeblock 2, 6, $19
	sendif
	checkevent EVENT_PRISON_B1F_DOOR_2
	sif true, then
		changeblock 14, 6, $18
	selse
		changeblock 14, 6, $19
	sendif
	checkevent EVENT_PRISON_B1F_DOOR_3
	sif true, then
		changeblock 24, 6, $18
	selse
		changeblock 24, 6, $19
	sendif
	checkevent EVENT_PRISON_B1F_DOOR_4
	sif true, then
		changeblock 2, 20, $18
	selse
		changeblock 2, 20, $19
	sendif
	checkevent EVENT_PRISON_B1F_DOOR_5
	sif true, then
		changeblock 14, 20, $18
	selse
		changeblock 14, 20, $19
	sendif
	checkevent EVENT_PRISON_B1F_DOOR_6
	sif true, then
		changeblock 24, 20, $18
	selse
		changeblock 24, 20, $19
	sendif
	checkevent EVENT_PRISON_B1F_DOOR_7
	sif true, then
		changeblock 14, 16, $18
	selse
		changeblock 14, 16, $19
	sendif
	checkevent EVENT_0
	sif false
		return
	clearevent EVENT_0
	refreshscreen 0
	reloadmappart
	closetext
	end

PrisonB1F_Text_UnlockedDoor:
	ctxt "Unlocked the door!"
	done

PrisonB1F_Text_DoorIsLocked:
	ctxt "The door is"
	line "locked."
	done

PrisonB1F_MapEventHeader ;filler
	db 0, 0

;warps
	db 1
	warp_def $e, $f, 7, PRISON_F1

	;xy triggers
	db 0

	;signposts
	db 7
	signpost 7, 3, SIGNPOST_READ, PrisonB1FDoor1
	signpost 7, 15, SIGNPOST_READ, PrisonB1FDoor2
	signpost 7, 25, SIGNPOST_READ, PrisonB1FDoor3
	signpost 21, 3, SIGNPOST_READ, PrisonB1FDoor4
	signpost 21, 15, SIGNPOST_READ, PrisonB1FDoor5
	signpost 21, 25, SIGNPOST_READ, PrisonB1FDoor6
	signpost 17, 15, SIGNPOST_READ, PrisonB1FPasswordDoor

	;people-events
	db 7
	person_event SPRITE_SILVER, 18, 2, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, 0, 2, 0, PrisonB1FRival, EVENT_PRISON_B1F_TRAINER_1
	person_event SPRITE_METAGROSS, 24, 26, SPRITEMOVEDATA_POKEMON, 0, 0, -1, -1, PAL_OW_BLUE, 0, 0, PrisonB1FMetagross, EVENT_PRISON_B1F_NPC_1
	person_event SPRITE_FAMBACO, 22, 11, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_RED, 0, 0, PrisonB1FFambaco, EVENT_PRISON_B1F_NPC_2
	person_event SPRITE_HARIYAMA, 24, 3, SPRITEMOVEDATA_POKEMON, 0, 0, -1, -1, PAL_OW_BROWN, 0, 0, PrisonB1FNPC3, EVENT_PRISON_B1F_NPC_3
	person_event SPRITE_HARIYAMA, 4, 26, SPRITEMOVEDATA_POKEMON, 0, 0, -1, -1, PAL_OW_BROWN, 0, 0, PrisonB1FNPC4, EVENT_PRISON_B1F_NPC_4
	person_event SPRITE_MACHOKE, 4, 14, SPRITEMOVEDATA_POKEMON, 0, 0, -1, -1, PAL_OW_BLUE, 0, 0, PrisonB1FNPC5, EVENT_PRISON_B1F_NPC_5
	person_event SPRITE_BRONZONG, 4, 3, SPRITEMOVEDATA_POKEMON, 0, 0, -1, -1, PAL_OW_BLUE, 0, 0, PrisonB1FNPC6, EVENT_PRISON_B1F_NPC_6
