PrisonF1_MapScriptHeader;trigger count
	db 0
 ;callback count
	db 1
	dbw MAPCALLBACK_TILES, PrisonF1_UpdateLockedDoors

PrisonF1Door1:
	writehalfword EVENT_PRISON_LOCKED_DOOR_1
	jump PrisonF1_HandleDoor

PrisonF1Door2:
	writehalfword EVENT_PRISON_LOCKED_DOOR_2
	jump PrisonF1_HandleDoor

PrisonF1Door3:
	writehalfword EVENT_PRISON_LOCKED_DOOR_3
	jump PrisonF1_HandleDoor

PrisonF1Door4:
	writehalfword EVENT_PRISON_LOCKED_DOOR_4
	jump PrisonF1_HandleDoor

PrisonF1Door5:
	writehalfword EVENT_PRISON_LOCKED_DOOR_5
	jump PrisonF1_HandleDoor

PrisonF1Door6:
	writehalfword EVENT_PRISON_LOCKED_DOOR_6
	jump PrisonF1_HandleDoor

PrisonF1Door7:
	writehalfword EVENT_PRISON_LOCKED_DOOR_7
	jump PrisonF1_HandleDoor

PrisonF1Door8:
	writehalfword EVENT_PRISON_LOCKED_DOOR_8
	jump PrisonF1_HandleDoor

PrisonF1Door9:
	writehalfword EVENT_PRISON_LOCKED_DOOR_9
	jump PrisonF1_HandleDoor

PrisonF1Door10:
	writehalfword EVENT_PRISON_LOCKED_DOOR_10
	jump PrisonF1_HandleDoor

PrisonF1Door11:
	writehalfword EVENT_PRISON_LOCKED_DOOR_11
	jump PrisonF1_HandleDoor

PrisonF1Door12:
	writehalfword EVENT_PRISON_LOCKED_DOOR_12
PrisonF1_HandleDoor:
	checkevent $ffff
	sif true
		end
	opentext
	checkitem CAGE_KEY
	sif false
		jumptext .need_key_text
	writetext .want_to_unlock_text
	yesorno
	sif false
		jump .refused_openDoor
	writetext .unlocked_text
	setevent $ffff
	takeitem CAGE_KEY, 1
	playsound SFX_ENTER_DOOR
	scall PrisonF1_UpdateLockedDoors
	refreshscreen 0
	reloadmappart
	closetext
	end

.refused_openDoor
	refreshscreen 0
	end
	
.need_key_text
	ctxt "You need a Cage"
	line "Key to unlock"
	cont "this door."
	done

.want_to_unlock_text
	ctxt "Do you want to"
	line "unlock this door?"
	done

.unlocked_text
	ctxt "Unlocked the"
	line "door!"
	sdone

PrisonF1CellSignpost:
	jumptext .text

.text
	ctxt "Don't try to jump"
	line "and escape."

	para "Don't forget,"
	line "you're here"
	cont "forever."
	done

PrisonF1_Item_1:
	db CAGE_KEY, 1

PrisonF1_Item_2:
	db PP_UP, 1

PrisonF1_Item_3:
	db FLUFFY_COAT, 1

PrisonF1_Item_4:
	db CAGE_KEY, 1

PrisonF1_Item_5:
	db FRIEND_BALL, 3

PrisonF1BlackPatroller:
	faceplayer
	opentext
	checkevent EVENT_PRISON_ROOF_CARD
	sif true
		jumptext .after_card_explanation_text
	writetext .intro_text
	verbosegiveitem ROOF_CARD, 1
	writetext .after_give_card_text
	setevent EVENT_PRISON_ROOF_CARD
	endtext

.intro_text
	start_asm
	ld hl, wStringBuffer1
	ld [hl], "h"
	inc hl
	ld a, [wPlayerGender]
	rra
	jr c, .female
	ld [hl], "i"
	inc hl
	ld [hl], "s"
	jr .done_gender
.female
	ld [hl], "e"
	inc hl
	ld [hl], "r"
.done_gender
	inc hl
	ld [hl], "@"
	ld hl, .intro_text_contents
	ret

.intro_text_contents
	ctxt "I recognize you."

	para "You went under-"
	line "cover and landed"
	cont "me up in here."

	para "I could easily"
	line "blame you for my"
	cont "being in here,"

	para "but I spent a"
	line "good deal of my"
	para "time here just"
	line "thinking about my"
	cont "life decisions."

	para "Not just my own"
	line "choices, but the"
	para "kind of choices"
	line "that get all of us"
	para "to change the road"
	line "we're set out on."

	para "Me, I joined a"
	line "group of #mon"
	para "Trainers who were"
	line "extreme in their"
	para "means of attaining"
	line "their philosophy."

	para "We used anything,"
	line "such as psychic"
	para "oppression with"
	line "our #mon, to"
	cont "get our way."

	para "I believed I was"
	line "doing good<...>"

	para "<...>that I was doing"
	line "a service to our"
	para "future generations"
	line "by finding ways to"
	para "radically improve"
	line "growth of #mon."

	para "I believed what I"
	line "was doing was good"
	para "until our run-ins"
	line "with you started:"

	para "you, just a humble"
	line "Trainer, who, with"
	para "<STRBF1> own #mon," ;gender selected above
	line "bested our"
	para "genetically"
	line "superior ones."

	para "You showed real"
	line "respect to your"
	para "#mon team and"
	line "crafted an extrem-"
	para "ely positive bond"
	line "between them."

	para "The world needs"
	line "more Trainers like"
	cont "you, not like us."

	para "Here, take this."

	para "You deserve this"
	line "more than me."
	sdone

.after_give_card_text
	ctxt "It's a card I found"
	line "on the ground."

	para "This card lets you"
	line "access the roof."

	para "The basement's door"
	line "is locked by some"
	cont "special code."

	para "That's where they"
	line "keep the unruly"
	cont "#mon of prison."

	para "Someone else might"
	line "know the passcode."
	done

.after_card_explanation_text
	ctxt "Worry about"
	line "yourself."
	done

PrisonF1_UpdateLockedDoors:
	checkevent EVENT_PRISON_LOCKED_DOOR_1
	sif true
		changeblock 20, 6, $1a
	checkevent EVENT_PRISON_LOCKED_DOOR_2
	sif true
		changeblock 34, 4, $1a
	checkevent EVENT_PRISON_LOCKED_DOOR_3
	sif true
		changeblock 36, 18, $57
	checkevent EVENT_PRISON_LOCKED_DOOR_4
	sif true
		changeblock 34, 26, $18
	checkevent EVENT_PRISON_LOCKED_DOOR_5
	sif true
		changeblock 26, 26, $18
	checkevent EVENT_PRISON_LOCKED_DOOR_6
	sif true
		changeblock 18, 26, $18
	checkevent EVENT_PRISON_LOCKED_DOOR_7
	sif true
		changeblock 12, 22, $18
	checkevent EVENT_PRISON_LOCKED_DOOR_8
	sif true
		changeblock 4, 22, $18
	checkevent EVENT_PRISON_LOCKED_DOOR_9
	sif true
		changeblock 4, 30, $57
	checkevent EVENT_PRISON_LOCKED_DOOR_10
	sif true
		changeblock 10, 30, $57
	checkevent EVENT_PRISON_LOCKED_DOOR_11
	sif true
		changeblock 36, 30, $57
	checkevent EVENT_PRISON_LOCKED_DOOR_12
	sif true
		changeblock 22, 30, $57
	return

PrisonF1_Trainer_1:
	trainer EVENT_PRISON_F1_TRAINER_1, COOLTRAINERM, 12, .before_battle_text, .battle_won_text, $0000, .Script

.Script
	jumptextfaceplayer .after_battle_text

.before_battle_text
	ctxt "Prison actually"
	line "isn't too bad."

	para "At least I don't"
	line "have to pay my"
	cont "student loans."
	done

.battle_won_text
	ctxt "More interest,"
	line "more pain."
	done

.after_battle_text
	ctxt "You seem like a"
	line "sensible young"
	para "kid, with a very"
	line "sensible kind of"
	cont "lifestyle."

	para "You pursue the"
	line "life that you want"
	para "over the life you"
	line "are expected to"
	para "live, and because"
	line "of that decision,"

	para "great things will"
	line "happen to you and"
	para "to those with whom"
	line "you've interacted."

	para "If you want some"
	line "real trustworthy"
	para "info: try and go"
	line "up to the roof."

	para "A bunch of the"
	line "prison guards go"
	para "up there to have a"
	line "drink and smoke"
	cont "during breaks."

	para "Some of them may"
	line "even be so drunk"
	para "they slip you the"
	line "secret password."
	done

PrisonF1_Trainer_2:
	trainer EVENT_PRISON_F1_TRAINER_2, FISHER, 14, .before_battle_text, .battle_won_text, $0000, .Script

.Script
	jumptextfaceplayer .after_battle_text

.before_battle_text
	ctxt "<...> I hope my girl"
	line "Jasmine is still"
	para "waiting for me"
	line "on the outside."
	done

.battle_won_text
	ctxt "No fair! I wasn't"
	line "paying attention!"
	done

.after_battle_text
	ctxt "Sorry, young one,"
	line "I don't have any"
	para "information to"
	line "spare with you."
	done

PrisonF1_Trainer_3:
	trainer EVENT_PRISON_F1_TRAINER_3, BIKER, 9, .before_battle_text, .battle_won_text, $0000, .Script

.before_battle_text
	ctxt "They're letting"
	line "kids into this"
	cont "place too, now?"

	para "Prison is hereby"
	line "officially uncool."
	done

.battle_won_text
	ctxt "I just can't"
	line "believe this!"

	para "Prison has ended"
	line "up becoming some"
	para "place for trendy"
	line "hipsters to get"
	para "locked up for non-"
	line "violent 'civil"
	cont "disobedience'."
	done

.give_key_text
	ctxt "The only reason"
	line "why I let myself"
	para "get locked up in"
	line "here is to get me"
	cont "some respect."

	para "<...> Which is why I"
	line "don't need this"
	cont "key anymore."
	sdone

.after_key_text
	ctxt "The only reason"
	line "why I let myself"

	para "get locked up in"
	line "here is to get"

	para "some respect from"
	line "my peers."
	done

.Script
	opentext
	checkevent EVENT_PRISON_GOT_KEY_FROM_TRAINER_3
	sif true
		jumptextfaceplayer .after_key_text
	writetext .give_key_text
	writehalfword EVENT_PRISON_GOT_KEY_FROM_TRAINER_3
PrisonF1_TrainerGiveKey:
	verbosegiveitem CAGE_KEY, 1
	sif false
		jumptext .no_room_text
	setevent $ffff
	closetext
	end

.no_room_text
	ctxt "Free some space."
	done

PrisonF1_Trainer_4:
	trainer EVENT_PRISON_F1_TRAINER_4, SAILOR, 4, .before_battle_text, .battle_won_text, $0000, .Script

.Script
	opentext
	checkevent EVENT_PRISON_GOT_KEY_FROM_TRAINER_4
	sif true
		jumptext .after_give_key_text
	writetext .give_key_text
	writehalfword EVENT_PRISON_GOT_KEY_FROM_TRAINER_4
	jump PrisonF1_TrainerGiveKey

.before_battle_text
	ctxt "I need some space."
	done

.battle_won_text
	ctxt "You just made a"
	line "very big mistake"
	cont "there, kid."
	done

.give_key_text
	ctxt "If you take this"
	line "rusty key off my"
	para "hands, I bother"
	line "with you."
	sdone

.after_give_key_text
	ctxt "Scram!"
	done

PrisonF1_Trainer_5:
	trainer EVENT_PRISON_F1_TRAINER_5, MINER, 1, .before_battle_text, .battle_won_text, $0000, .Script

.Script
	opentext
	checkevent EVENT_PRISON_GOT_KEY_FROM_TRAINER_5
	sif true
		jumptext .after_give_key_text
	writetext .give_key_text
	writehalfword EVENT_PRISON_GOT_KEY_FROM_TRAINER_5
	jump PrisonF1_TrainerGiveKey

.before_battle_text
	ctxt "You out for some"
	line "information?"

	para "Well, how about"
	line "a battle instead?"
	done

.battle_won_text
	ctxt "Darn, you're good!"
	done

.give_key_text
	ctxt "Heh, it's been so"
	line "long since I had"
	para "felt that thrill"
	line "of battling."

	para "Also, sorry, kid,"
	line "I don't have any"
	para "useful information"
	line "for you, really."

	para "I do have a key"
	line "though, somewhere."
	sdone

.after_give_key_text
	ctxt "Get outta here!"
	done

PrisonF1_Trainer_6:
	trainer EVENT_PRISON_F1_TRAINER_6, BIRD_KEEPER, 8, .before_battle_text, .battle_won_text, $0000, .Script

.Script
	opentext
	checkevent EVENT_PRISON_GOT_KEY_FROM_TRAINER_6
	sif true
		jumptext .after_give_key_text
	writetext .give_key_text
	writehalfword EVENT_PRISON_GOT_KEY_FROM_TRAINER_6
	jump PrisonF1_TrainerGiveKey

.before_battle_text
	ctxt "Hey there, friend!"
	done

.battle_won_text
	ctxt "What was that?"
	done

.give_key_text
	ctxt "I can't believe"
	line "you, after all"
	cont "we've been through!"

	para "Just, please, take"
	line "this key and go!"
	sdone

.after_give_key_text
	ctxt "Say no more, just"
	line "let me be!"
	done

PrisonF1_Trainer_7:
	trainer EVENT_PRISON_F1_TRAINER_7, SAILOR, 5, .before_battle_text, .battle_won_text, $0000, .script

.script
	opentext
	checkevent EVENT_PRISON_GOT_KEY_FROM_TRAINER_7
	sif true
		jumptext .after_give_key_text
	writetext .give_key_text
	waitbutton
	writehalfword EVENT_PRISON_GOT_KEY_FROM_TRAINER_7
	jump PrisonF1_TrainerGiveKey

.before_battle_text
	ctxt "It's awfully cold"
	line "in here<...>"
	done

.battle_won_text
	ctxt "Well, at least"
	line "that warmed me up."
	done

.give_key_text
	ctxt "If you take this"
	line "key, will you"
	cont "please just go?"
	done

.after_give_key_text
	ctxt "I'll just eat and"
	line "gain blubber."
	done

PrisonF1_MapEventHeader:: db 0, 0

.Warps: db 11
	warp_def 35, 18, 1, SAXIFRAGE_ISLAND
	warp_def 35, 19, 1, SAXIFRAGE_ISLAND
	warp_def 2, 2, 2, PRISON_PATHS
	warp_def 17, 22, 7, PRISON_PATHS
	warp_def 15, 31, 3, PRISON_PATHS
	warp_def 8, 37, 1, PRISON_F2
	warp_def 12, 34, 1, PRISON_B1F
	warp_def 26, 0, 1, PRISON_BATHS
	warp_def 27, 0, 2, PRISON_BATHS
	warp_def 28, 39, 1, PRISON_WORKOUT
	warp_def 29, 39, 2, PRISON_WORKOUT

.CoordEvents: db 0

.BGEvents: db 13
	signpost 7, 20, SIGNPOST_READ, PrisonF1Door1
	signpost 5, 34, SIGNPOST_READ, PrisonF1Door2
	signpost 23, 5, SIGNPOST_READ, PrisonF1Door8
	signpost 23, 13, SIGNPOST_READ, PrisonF1Door7
	signpost 27, 19, SIGNPOST_READ, PrisonF1Door6
	signpost 27, 27, SIGNPOST_READ, PrisonF1Door5
	signpost 19, 37, SIGNPOST_READ, PrisonF1Door3
	signpost 27, 35, SIGNPOST_READ, PrisonF1Door4
	signpost 30, 4, SIGNPOST_READ, PrisonF1Door9
	signpost 30, 10, SIGNPOST_READ, PrisonF1Door10
	signpost 2, 19, SIGNPOST_READ, PrisonF1CellSignpost
	signpost 30, 22, SIGNPOST_READ, PrisonF1Door12
	signpost 30, 36, SIGNPOST_READ, PrisonF1Door11

.ObjectEvents: db 14
	person_event SPRITE_COOLTRAINER_M, 20, 4, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_BROWN, PERSONTYPE_TRAINER, 0, PrisonF1_Trainer_1, -1
	person_event SPRITE_POKE_BALL, 5, 5, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_PURPLE, PERSONTYPE_ITEMBALL, 0, PrisonF1_Item_1, EVENT_PRISON_F1_ITEM_1
	person_event SPRITE_OFFICER, 8, 20, SPRITEMOVEDATA_STANDING_UP, 0, 0, -1, -1, PAL_OW_GREEN, PERSONTYPE_SCRIPT, 0, ObjectEvent, EVENT_PRISON_F1_NPC_1
	person_event SPRITE_FISHER, 25, 35, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, PAL_OW_BROWN, PERSONTYPE_TRAINER, 0, PrisonF1_Trainer_2, -1
	person_event SPRITE_BIKER, 24, 25, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, PAL_OW_RED, PERSONTYPE_TRAINER, 0, PrisonF1_Trainer_3, -1
	person_event SPRITE_POKE_BALL, 24, 19, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_ITEMBALL, 0, PrisonF1_Item_2, EVENT_PRISON_F1_ITEM_2
	person_event SPRITE_SAILOR, 20, 11, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, PAL_OW_BROWN, PERSONTYPE_TRAINER, 0, PrisonF1_Trainer_4, -1
	person_event SPRITE_POKE_BALL, 5, 2, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_PURPLE, PERSONTYPE_ITEMBALL, 0, PrisonF1_Item_3, EVENT_PRISON_F1_ITEM_3
	person_event SPRITE_POKE_BALL, 16, 2, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_PURPLE, PERSONTYPE_ITEMBALL, 0, PrisonF1_Item_4, EVENT_PRISON_F1_ITEM_4
	person_event SPRITE_POKE_BALL, 32, 23, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_ITEMBALL, 0, PrisonF1_Item_5, EVENT_PRISON_F1_ITEM_5
	person_event SPRITE_MINER, 32, 13, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, PAL_OW_BROWN, PERSONTYPE_TRAINER, 0, PrisonF1_Trainer_5, -1
	person_event SPRITE_BIRDKEEPER, 32, 29, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, PAL_OW_BLUE, PERSONTYPE_TRAINER, 0, PrisonF1_Trainer_6, -1
	person_event SPRITE_PALETTE_PATROLLER, 32, 3, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, PAL_OW_SILVER, PERSONTYPE_SCRIPT, 0, PrisonF1BlackPatroller, EVENT_PHLOX_LAB_CEO
	person_event SPRITE_SAILOR, 3, 35, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, PAL_OW_BLUE, PERSONTYPE_TRAINER, 0, PrisonF1_Trainer_7, -1
