PhloxLabB1F_MapScriptHeader;trigger count
	db 0
 ;callback count
	db 0

phlox_lab_spinner: MACRO
	switch ((\1) * 10 + 4) - (\2)
ENDM

PhloxLabB1FTrapLeft1:
	phlox_lab_spinner LEFT, 1
PhloxLabB1FTrapLeft2:
	phlox_lab_spinner LEFT, 2
PhloxLabB1FTrapLeft5:
	phlox_lab_spinner LEFT, 5
PhloxLabB1FTrapLeft7:
	phlox_lab_spinner LEFT, 7
PhloxLabB1FTrapLeft9:
	phlox_lab_spinner LEFT, 9
PhloxLabB1FTrapRight1:
	phlox_lab_spinner RIGHT, 1
PhloxLabB1FTrapRight5:
	phlox_lab_spinner RIGHT, 5
PhloxLabB1FTrapRight6:
	phlox_lab_spinner RIGHT, 6
PhloxLabB1FTrapRight9:
	phlox_lab_spinner RIGHT, 9
PhloxLabB1FTrapUp1:
	phlox_lab_spinner UP, 1
PhloxLabB1FTrapUp2:
	phlox_lab_spinner UP, 2
PhloxLabB1FTrapUp3:
	phlox_lab_spinner UP, 3
PhloxLabB1FTrapUp8:
	phlox_lab_spinner UP, 8
PhloxLabB1FTrapUp9:
	phlox_lab_spinner UP, 9
PhloxLabB1FTrapDown1:
	phlox_lab_spinner DOWN, 1
PhloxLabB1FTrapDown2:
	phlox_lab_spinner DOWN, 2
PhloxLabB1FTrapDown3:
	phlox_lab_spinner DOWN, 3
PhloxLabB1FTrapDown4:
	phlox_lab_spinner DOWN, 4

;fallthrough	
	sendif
	addhalfwordtovar .movement
	playsound SFX_SQUEAK
	applymovement PLAYER, -1
	end

.movement
	rept 4
		turn_waterfall_down
	endr
	step_end
	rept 9
		turn_waterfall_up
	endr
	step_end
	rept 9
		turn_waterfall_left
	endr
	step_end
	rept 9
		turn_waterfall_right
	endr
	step_end

PhloxLabB1FGuard:
	faceplayer
	opentext
	checkevent EVENT_PHLOX_LAB_B1F_KEY
	sif true
		jumptext .already_battled_text
	writetext .before_battle_text
	winlosstext .battle_won_text, 0
	setlasttalked 255
	writecode VAR_BATTLETYPE, BATTLETYPE_NORMAL
	loadtrainer OFFICER, 8
	startbattle
	reloadmapafterbattle
	playmapmusic
	opentext
	writetext .after_battle_text
	verbosegiveitem LAB_CARD, 1
	waitbutton
	writetext .gave_lab_card_text
	setevent EVENT_PHLOX_LAB_B1F_KEY
	endtext

.before_battle_text
	db TX_COMPRESSED, $13, $62, $6c, $4d, $d3

	db $c0, $02, $b4, $fe, $34, $9f, $ca, $93, $b7

	db $4a, $01, $ba, $76, $e5, $8d, $f3, $83, $44, $1d, $d2

	db $80, $76, $99, $56, $8e, $ff, $35, $67, $01, $05
	db $a7, $96, $7b, $de, $82, $88, $68, $40, $80, $a0
	db $f2, $aa, $c3, $15, $9c, $19, $22, $4d, $67

	db $4a, $00, $a5, $82, $19, $39, $96, $18, $8b, $3d
	db $eb, $c6, $2c, $da, $18, $87, $cc, $97, $03, $86, $10, $38
	db $00, $10, $b1, $83, $6d, $9c, $10, $b0, $88, $35, $d8, $2f
	db $bd, $ab, $38, $08, $2d, $42, $06, $aa

	db $50, $0e, $8b, $26, $e0, $bd, $1e, $60, $20, $b5, $13, $a0
	db $c6, $f5, $86, $74, $f4, $18, $ff, $04, $2c, $24, $b0

	db $f8, $05, $3c

	db $00, $1b, $a4, $14, $c8, $60, $20, $b5, $29, $c6, $91
	db $6f, $22, $f4, $99, $96, $93, $59, $d2

	db $80, $af, $bd, $88, $1f, $4c, $97

	db $4a, $01, $ca, $16, $8b, $8e, $10, $37, $39, $08, $c9
	db $cb, $d6, $18, $23, $ba, $0a, $69, $01, $47, $c6, $4c
	db $80, $e7, $5f, $34, $40, $92, $3e, $7f
	db $7a, $d2, $34, $43, $26, $51, $08, $1a, $b8
	db $d3, $c4

.battle_won_text
	text "What?"
	done

.after_battle_text
	db TX_COMPRESSED, $76, $26, $3f, $1d, $38, $7b, $15, $9c, $48, $48, $68
	db $b7, $aa, $1d, $a6, $02, $0b, $51, $26, $b3

	db $f0, $07, $51, $3a, $0c, $70, $81, $b4, $8c, $9c
	db $bc, $7d, $41, $cb, $0c, $c9, $e0, $64
	db $ca, $a7, $c1, $20, $fb, $84, $a8, $76, $98, $40, $d5

	db $e0, $0e, $a2, $74, $18, $e2, $02, $f9, $da, $46, $4e
	db $5e, $04, $16, $a3, $e3, $e5, $37, $2a, $d2, $5d, $3c

	db $00, $1d, $38, $7b, $39, $18, $31, $c1, $dc, $b0, $c0, $41
	db $69, $e1, $e1, $01, $05, $a9, $4e, $34, $8b, $96, $d2
	db $c8, $ab, $56, $16, $89, $99, $a4, $cc, $e9, $e8, $31

	db $f8, $03, $74, $99, $20, $85, $85, $5f, $4d, $f4
	db $3c, $9d, $10, $20, $c9, $12, $6b, $3f
	db $80, $1d, $e2, $84, $30, $63, $5c, $30, $63
	db $5b, $da, $40, $4a, $c3, $90, $58, $a6, $1a, $d7, $6f
	db $d4, $f1, $00

.gave_lab_card_text
	db TX_COMPRESSED, $29, $3b, $71, $09, $0b, $5d, $cc, $e4
	db $ed, $e0, $41, $6a, $0c, $96, $19, $69, $39, $dd, $57
	db $f0, $15, $24, $d6, $70, $10, $5a, $95, $04, $94, $c8, $ac
	db $de, $7c, $14, $10, $b0, $ab, $e9, $bf, $4f
	db $05, $3c, $40

.already_battled_text
	db TX_COMPRESSED, $75, $32, $12, $53, $22, $74, $18
	db $de, $d2, $02, $b4, $8c, $9c, $c3, $ea
	db $0c, $02, $b6, $ae, $5a, $4e, $33, $d0, $da, $4d
	db $0f, $04, $91, $f0, $51, $5e, $b2, $a5, $f9, $a4
	db $c8, $07, $51, $3a, $0c, $64, $a6, $4a, $b5, $09, $3c
	db $bd, $69, $0a, $0e, $0c, $92, $a3, $35, $24
	db $7a, $9a

PhloxLabB1F_MapEventHeader ;filler
	db 0, 0

;warps
	db 7
	warp_def $b, $3, 4, PHLOX_LAB_B1F
	warp_def $9, $21, 3, PHLOX_LAB_B1F
	dummy_warp $15, $19
	dummy_warp $b, $f
	warp_def $b, $13, 3, PHLOX_LAB_B1F
	warp_def $15, $1c, 8, ACQUA_LABBASEMENTPATH
	warp_def $15, $1d, 8, ACQUA_LABBASEMENTPATH

	;xy triggers
	db 49
	xy_trigger 0, $13, $1b, $0, PhloxLabB1FTrapLeft1, $0, $0
	xy_trigger 0, $12, $1b, $0, PhloxLabB1FTrapLeft2, $0, $0
	xy_trigger 0, $d, $5, $0, PhloxLabB1FTrapLeft1, $0, $0
	xy_trigger 0, $10, $16, $0, PhloxLabB1FTrapUp3, $0, $0
	xy_trigger 0, $e, $16, $0, PhloxLabB1FTrapUp1, $0, $0
	xy_trigger 0, $c, $16, $0, PhloxLabB1FTrapUp8, $0, $0
	xy_trigger 0, $d, $15, $0, PhloxLabB1FTrapLeft9, $0, $0
	xy_trigger 0, $b, $d, $0, PhloxLabB1FTrapLeft1, $0, $0
	xy_trigger 0, $d, $b, $0, PhloxLabB1FTrapLeft7, $0, $0
	xy_trigger 0, $c, $5, $0, PhloxLabB1FTrapLeft1, $0, $0
	xy_trigger 0, $b, $c, $0, PhloxLabB1FTrapUp9, $0, $0
	xy_trigger 0, $c, $a, $0, PhloxLabB1FTrapUp8, $0, $0
	xy_trigger 0, $c, $3, $0, PhloxLabB1FTrapRight1, $0, $0
	xy_trigger 0, $c, $2, $0, PhloxLabB1FTrapUp1, $0, $0
	xy_trigger 0, $c, $1, $0, PhloxLabB1FTrapRight1, $0, $0
	xy_trigger 0, $9, $0, $0, PhloxLabB1FTrapDown3, $0, $0
	xy_trigger 0, $4, $0, $0, PhloxLabB1FTrapDown3, $0, $0
	xy_trigger 0, $3, $2, $0, PhloxLabB1FTrapLeft2, $0, $0
	xy_trigger 0, $2, $3, $0, PhloxLabB1FTrapDown1, $0, $0
	xy_trigger 0, $2, $4, $0, PhloxLabB1FTrapDown1, $0, $0
	xy_trigger 0, $2, $6, $0, PhloxLabB1FTrapLeft1, $0, $0
	xy_trigger 0, $2, $8, $0, PhloxLabB1FTrapLeft1, $0, $0
	xy_trigger 0, $2, $9, $0, PhloxLabB1FTrapLeft2, $0, $0
	xy_trigger 0, $2, $d, $0, PhloxLabB1FTrapLeft1, $0, $0
	xy_trigger 0, $3, $d, $0, PhloxLabB1FTrapLeft1, $0, $0
	xy_trigger 0, $4, $15, $0, PhloxLabB1FTrapLeft9, $0, $0
	xy_trigger 0, $5, $16, $0, PhloxLabB1FTrapUp1, $0, $0
	xy_trigger 0, $1, $10, $0, PhloxLabB1FTrapUp1, $0, $0
	xy_trigger 0, $4, $b, $0, PhloxLabB1FTrapLeft1, $0, $0
	xy_trigger 0, $4, $9, $0, PhloxLabB1FTrapLeft5, $0, $0
	xy_trigger 0, $4, $5, $0, PhloxLabB1FTrapLeft1, $0, $0
	xy_trigger 0, $3, $5, $0, PhloxLabB1FTrapLeft1, $0, $0
	xy_trigger 0, $3, $7, $0, PhloxLabB1FTrapDown2, $0, $0
	xy_trigger 0, $3, $a, $0, PhloxLabB1FTrapUp1, $0, $0
	xy_trigger 0, $6, $a, $0, PhloxLabB1FTrapUp2, $0, $0
	xy_trigger 0, $5, $a, $0, PhloxLabB1FTrapUp1, $0, $0
	xy_trigger 0, $7, $b, $0, PhloxLabB1FTrapRight9, $0, $0
	xy_trigger 0, $9, $9, $0, PhloxLabB1FTrapRight1, $0, $0
	xy_trigger 0, $7, $9, $0, PhloxLabB1FTrapLeft1, $0, $0
	xy_trigger 0, $6, $8, $0, PhloxLabB1FTrapRight1, $0, $0
	xy_trigger 0, $7, $17, $0, PhloxLabB1FTrapRight5, $0, $0
	xy_trigger 0, $8, $6, $0, PhloxLabB1FTrapRight1, $0, $0
	xy_trigger 0, $9, $5, $0, PhloxLabB1FTrapRight5, $0, $0
	xy_trigger 0, $9, $3, $0, PhloxLabB1FTrapLeft2, $0, $0
	xy_trigger 0, $9, $2, $0, PhloxLabB1FTrapLeft1, $0, $0
	xy_trigger 0, $8, $1, $0, PhloxLabB1FTrapRight6, $0, $0
	xy_trigger 0, $7, $3, $0, PhloxLabB1FTrapLeft2, $0, $0
	xy_trigger 0, $8, $4, $0, PhloxLabB1FTrapDown1, $0, $0
	xy_trigger 0, $5, $4, $0, PhloxLabB1FTrapDown4, $0, $0

	;signposts
	db 0

	;people-events
	db 3
	person_event SPRITE_POKE_BALL, 10, 17, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_ITEMBALL, 1, MAX_REVIVE, EVENT_PHLOX_LAB_B1F_ITEM_MAX_REVIVE
	person_event SPRITE_POKE_BALL, 5, 11, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_ITEMBALL, 2, RARE_CANDY, EVENT_PHLOX_LAB_B1F_ITEM_RARE_CANDIES
	person_event SPRITE_OFFICER, 11, 24, SPRITEMOVEDATA_STANDING_LEFT, 0, 0, -1, -1, PAL_OW_GREEN, PERSONTYPE_SCRIPT, 0, PhloxLabB1FGuard, -1

