PhloxTown_MapScriptHeader;trigger count
	db 0
 ;callback count
	db 2

	dbw 5, .set_fly_flag
	dbw MAPCALLBACK_TILES, .open_lab_door

.set_fly_flag
	setflag ENGINE_FLYPOINT_PHLOX_TOWN
	return

.open_lab_door
	checkevent EVENT_PHLOX_LAB_UNLOCKED
	sif true
		changeblock 14, 4, $17
	return

PhloxTownBingoSign:
	db TX_COMPRESSED, $12, $19, $39, $0c, $63, $bd
	db $ed, $34

PhloxTownAcquaMinesSign:
	db TX_COMPRESSED, $ad, $91, $66, $d6, $c1, $51, $90
	db $d1, $4d

PhloxTownLabSign:
	db TX_COMPRESSED, $af, $bc, $9a, $c8, $12
	db $53, $c2, $c7, $d5, $61, $5e, $d8, $56, $33
	db $45, $34

PhloxTownTownSign:
	db TX_COMPRESSED, $29, $27, $05, $9b, $43, $3b
	db $a7, $84, $f8, $5a, $25, $e8, $c9, $16, $3c, $f2
	db $74, $d0

PhloxTownNPC1:
	jumptextfaceplayer .text

.text
	db TX_COMPRESSED, $75, $78, $a6, $f6, $ad, $04, $88, $c8, $7b, $98, $d0
	db $87, $86, $49, $69, $34, $1c, $11, $ab, $b4

	db $78, $00, $b8, $18, $c9, $32, $d2, $c6, $4e, $65, $a4
	db $de, $7c, $79, $cf, $4e, $07, $08, $86, $9f, $7c, $d7
	db $ea, $68

PhloxTownNPC2:
	jumptextfaceplayer .text

.text
	db TX_COMPRESSED, $6e, $72, $a3, $59, $cb, $0d, $ef, $7a
	db $09, $ec, $06, $43, $95, $0e, $d3, $3a, $30, $61, $93
	db $95, $43, $24, $41, $b3, $d6, $90, $30, $93

	db $c0, $1b, $a4, $14, $c8, $4d, $10, $c1, $8d, $60, $82, $43
	db $7a, $ad, $25, $cb, $0c, $10, $d5, $c3, $06, $35, $82
	db $02, $aa, $d2, $32, $73, $2c, $3c, $9d, $a4, $d7

	db $4a, $01, $b7, $49, $4c, $9a, $40, $56, $91, $93
	db $97, $8c, $18, $d7, $29, $c6, $91, $71, $17, $a4
	db $ca, $ad, $e8, $48, $73, $48, $09, $f0, $ac, $e9
	db $69, $a0

PhloxTownNPC3:
	jumptextfaceplayer .text

.text
	db TX_COMPRESSED, $29, $3b, $71, $5b, $43, $ee, $46, $4e, $65, $5a
	db $87, $95, $b4, $3e, $dc, $09, $23, $e0, $a6, $1a
	db $0c, $ab, $01, $a1, $23, $27, $31, $02, $03, $7c

	db $40, $14, $93, $05, $13, $b9, $9b, $04, $1a, $df, $1d
	db $fd, $e4, $06, $3a, $8c, $e9, $29, $91, $59, $cb, $08
	db $55, $34, $21, $07, $7f, $8e, $a7, $2d, $1a, $11, $4f
	db $05, $34

PhloxTownNPC4:
	jumptextfaceplayer .text

.text
	db TX_COMPRESSED, $29, $26, $b3, $c5, $36, $20, $d9, $eb, $59, $3c
	db $bc, $d1, $32, $6b, $e5, $61, $68, $99, $8c, $e8, $31
	db $aa, $d5, $85, $a2, $66, $24, $d6, $7e

	db $00, $a0, $2f, $9d, $8d, $f3, $44, $cb, $4b, $19, $39
	db $7a, $d2, $73, $3a, $0b, $f0, $77
	db $89, $55, $86, $f7, $bd, $05, $30, $e8, $43, $93, $cf
	db $1a, $68

PhloxTownLabDoor:
	opentext
	checkevent EVENT_PHLOX_LAB_UNLOCKED
	sif true
		jumptext .already_unlocked_text
	checkitem LAB_CARD
	sif false
		jumptext .locked_text
	setevent EVENT_PHLOX_LAB_UNLOCKED
	playsound SFX_TRANSACTION
	writetext .unlocked_door_text
	closetext
	changeblock 14, 4, $17
	reloadmappart
	end

.unlocked_door_text
	db TX_COMPRESSED, $72, $85, $a8, $d1, $3a, $16, $54, $8f, $32, $d2
	db $6f, $64, $21, $5c, $a8, $76, $99, $69
	db $35, $58, $fa, $ae, $36, $ea, $f3
	db $c6, $9e, $20

.locked_text
	db TX_COMPRESSED, $29, $27, $32, $10, $ae, $0d
	db $0f, $74, $2c, $a9, $1e
	db $7d, $4d

.already_unlocked_text
	db TX_COMPRESSED, $29, $27, $32, $10, $af, $14, $de, $ac, $f7, $20
	db $9e, $68, $9d, $0b, $2a, $47, $9f
	db $53, $40

PhloxTown_MapEventHeader:: db 0, 0

.Warps: db 7
	warp_def 17, 13, 1, PHLOX_POKECENTER
	warp_def 23, 29, 1, PHLOX_MART
	warp_def 5, 14, 1, PHLOX_LAB_1F
	warp_def 27, 7, 2, PHLOX_ENTRY
	warp_def 23, 21, 1, PHLOX_BINGO
	warp_def 15, 21, 1, PHLOX_MYLES
	warp_def 9, 27, 2, ACQUA_PHLOXENTRANCE

.CoordEvents: db 0

.BGEvents: db 5
	signpost 25, 19, SIGNPOST_LOAD, PhloxTownBingoSign
	signpost 9, 23, SIGNPOST_LOAD, PhloxTownAcquaMinesSign
	signpost 5, 11, SIGNPOST_LOAD, PhloxTownLabSign
	signpost 29, 13, SIGNPOST_LOAD, PhloxTownTownSign
	signpost 5, 14, SIGNPOST_READ, PhloxTownLabDoor

.ObjectEvents: db 4
	person_event SPRITE_COOLTRAINER_M, 13, 30, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, PAL_OW_RED, PERSONTYPE_SCRIPT, 0, PhloxTownNPC1, -1
	person_event SPRITE_YOUNGSTER, 29, 19, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, PAL_OW_RED, PERSONTYPE_SCRIPT, 0, PhloxTownNPC2, -1
	person_event SPRITE_FISHING_GURU, 6, 20, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, PAL_OW_RED, PERSONTYPE_SCRIPT, 0, PhloxTownNPC3, -1
	person_event SPRITE_POKEFAN_F, 16, 5, SPRITEMOVEDATA_WANDER, 1, 1, -1, -1, PAL_OW_RED, PERSONTYPE_SCRIPT, 0, PhloxTownNPC4, -1

