SaxifrageGym_MapScriptHeader;trigger count
	db 0
 ;callback count
	db 1
	dbw MAPCALLBACK_TILES, .set_lights

.set_lights
	checkevent EVENT_SAXIFRAGE_LIGHT_OFF_1
	sif true
		return
	scall SaxifrageGym_LightsOn1
	checkevent EVENT_SAXIFRAGE_LIGHT_OFF_2
	sif true
		return
	scall SaxifrageGym_LightsOn2
	checkevent EVENT_SAXIFRAGE_LIGHT_OFF_3
	sif true
		return
	scall SaxifrageGym_LightsOn3
	return

SaxifrageGym_LightsOn1:
	changeblock 6, 6, $d
	changeblock 8, 6, $1b
	changeblock 6, 8, $e
	end

SaxifrageGym_LightsOn2:
	changeblock 4, 4, $1d
	changeblock 4, 6, $e
	changeblock 6, 4, $1c
	end

SaxifrageGym_LightsOn3:
	changeblock 2, 0, $5
	changeblock 4, 0, $4
	changeblock 6, 0, $6
	changeblock 2, 2, $10
	changeblock 4, 2, $11
	changeblock 6, 2, $12
	end

SaxifrageGym_Trainer_1:
	trainer EVENT_SAXIFRAGE_GYM_TRAINER_1, GUITARIST, 1, .before_battle_text, .battle_won_text, $0000, .Script

.Script
	checkevent EVENT_SAXIFRAGE_LIGHT_OFF_3
	sif false
		jumptext .after_battle_text
	opentext
	writetext .turn_lights_on_text
	playsound SFX_ENTER_DOOR
	scall SaxifrageGym_LightsOn3
	clearevent EVENT_SAXIFRAGE_LIGHT_OFF_3
	reloadmappart
	appear $2
	closetext
	end

.before_battle_text
	db TX_COMPRESSED, $29, $23, $44, $1a, $25, $a4, $e1, $93
	db $2f, $60, $15, $c0, $41, $6b
	db $8d, $34

.battle_won_text
	db TX_COMPRESSED, $6e, $9d, $ba, $5e
	db $34, $d0

.turn_lights_on_text
	db TX_COMPRESSED, $75, $32, $3c, $92, $99, $11, $61, $11, $01, $05, $aa, $78

	db $00, $09, $35, $71, $d1, $64, $43, $4b, $38, $16
	db $96, $f7, $4f, $72, $6b, $95, $0f, $bd
	db $e3, $4f, $10

.after_battle_text
	db TX_COMPRESSED, $50, $1f, $c6, $93, $4f

	db $00, $0e, $00, $c0, $41, $6a, $27, $41, $8e
	db $6b, $ca, $f4, $99, $a5

	db $00, $db, $a4, $8e, $a5, $38, $11, $92
	db $96, $9a

SaxifrageGym_Trainer_2:
	trainer EVENT_SAXIFRAGE_GYM_TRAINER_2, GUITARIST, 2, .before_battle_text, .battle_won_text, $0000, .Script

.Script
	checkevent EVENT_SAXIFRAGE_LIGHT_OFF_2
	sif false
		jumptext .after_battle_text
	opentext
	writetext .turn_lights_on_text
	playsound SFX_ENTER_DOOR
	scall SaxifrageGym_LightsOn2
	reloadmappart
	clearevent EVENT_SAXIFRAGE_LIGHT_OFF_2
	appear $3
	closetext
	end

.before_battle_text
	db TX_COMPRESSED, $75, $1f, $1a, $11, $02, $d2, $e6, $74, $7d
	db $04, $f5, $39, $af, $a2, $60, $b0, $bf, $15, $eb, $2a
	db $4a, $86, $49, $69, $38, $1e, $e6, $67, $41, $23

	db $c0, $1d, $38, $7b, $2f, $54, $8e, $3e, $0a, $6f, $3c, $ac, $c0
	db $bc, $84, $0c, $24, $81, $6a, $e0, $49, $01, $05, $ae
	db $34, $d0

.battle_won_text
	db TX_COMPRESSED, $07, $86, $e6, $93, $95, $82, $86, $40, $b5, $ca, $78
	db $d3, $40

.turn_lights_on_text
	db TX_COMPRESSED, $75, $10, $d0, $81, $01, $41, $c0, $41, $6a, $33, $a4
	db $7b, $01, $f2, $9b, $96, $93, $84, $3a, $76
	db $d5, $72, $d0, $28, $c8, $5f, $19, $39, $8d, $08
	db $f5, $3c, $40

.after_battle_text
	db TX_COMPRESSED, $6d, $dc, $99, $19, $39, $56, $a2, $04, $8c
	db $9b, $da, $b5, $9a, $2c, $f3, $30, $0a, $e6, $46, $80
	db $2a, $ad, $a5, $ab, $19, $39, $96, $93, $82, $0f, $59, $3f

	db $00, $50, $93, $95, $6a, $25, $a4, $c9, $39, $18, $31
	db $91, $eb, $48, $d1, $18, $40, $9f, $8a, $cd, $9d, $69
	db $06, $01, $09, $39, $56, $a2, $5a, $4e, $0c, $8f, $ed
	db $9b, $d5, $24, $32, $d6, $7b, $67, $98, $93
	db $5a, $a0, $72, $be, $12, $4b, $49, $c5, $66, $8b
	db $f5, $34

SaxifrageGym_Trainer_3:
	trainer EVENT_SAXIFRAGE_GYM_TRAINER_3, GUITARIST, 3, .before_battle_text, .battle_won_text, $0000, .Script

.Script:
	checkevent EVENT_SAXIFRAGE_LIGHT_OFF_1
	sif false
		jumptext .after_battle_text
	opentext
	writetext .turn_lights_on_text
	playsound SFX_ENTER_DOOR
	scall SaxifrageGym_LightsOn1
	reloadmappart
	clearevent EVENT_SAXIFRAGE_LIGHT_OFF_1
	appear $4
	closetext
	end

.before_battle_text
	db TX_COMPRESSED, $c7, $3b, $c5, $2d, $a5, $92, $5a
	db $4d, $e0, $60, $f5, $a7, $ce, $34, $23
	db $8d, $34

.battle_won_text
	db TX_COMPRESSED, $13, $5d, $a2, $04, $1e, $60, $5a, $be
	db $34, $d0

.turn_lights_on_text
	db TX_COMPRESSED, $c7, $3b, $8f, $9c, $59, $83, $1e, $f6, $5a
	db $4d, $e2, $1d, $3b, $70, $a5, $e8, $c8, $6b, $98, $05
	db $6a, $81, $05, $af
	db $53, $c4

.after_battle_text
	db TX_COMPRESSED, $61, $04, $39, $9d, $69, $95, $2f, $c5, $6d, $67, $20, $b8

	db $80, $72, $85, $a2, $e3, $9c, $84, $84, $d8, $43, $3c
	db $bc, $3b, $fc, $4e, $a7, $53, $bc
	db $69, $a0

SaxifrageGymGuide:
	checkflag ENGINE_RAUCOUSBADGE
	sif true
		jumptextfaceplayer .won_badge_text
	jumptextfaceplayer .guide_text

.guide_text
	db TX_COMPRESSED, $62, $39, $bc, $e8, $c9

	db $c4, $01, $49, $1a, $20, $d1, $1b, $77, $26, $46, $4f

	db $c0, $14, $24, $e2, $2f, $57, $67, $99, $b1, $61, $65
	db $49, $e5, $7a, $4c, $ca, $b4, $14, $57, $ac, $a9

	db $78, $05, $78, $59, $ae, $5a, $4c, $6b, $8f, $e9, $01
	db $3d, $86, $8f, $ad, $2c, $d1, $f9, $69, $30
	db $40, $32, $6c, $8f, $27, $99, $61, $88, $bd, $5d
	db $bc, $d0, $89, $69, $31, $ae, $06, $a2, $46, $10, $27
	db $c0, $20, $41, $b2, $3d, $e8, $c4, $d8, $c9, $cc, $19
	db $1e, $50, $16, $89, $98, $0e, $57, $c2, $4f

	db $00, $12, $6a, $e5, $a4, $d6, $73, $56, $64, $a6
	db $3c, $64, $0b, $5c, $a6, $07, $09, $69, $0a, $0f

	db $e0, $10, $19, $69, $30, $52, $d2, $b3, $aa, $20, $2f
	db $9b, $c7, $d3, $66, $d6, $36, $60, $48, $68, $83, $25
	db $85, $55, $a4, $e3, $e3, $a7, $65, $84, $3e
	db $a6, $80

.won_badge_text
	db TX_COMPRESSED, $29, $3b, $71, $5e, $dd, $f4, $e5, $5a
	db $87, $97, $af, $ab, $68, $8c, $d8, $c2, $d2, $38
	
	db $80, $75, $13, $b9, $96, $18, $21, $ab, $83
	db $23, $c0, $f7, $23, $92, $0b, $21, $65, $05, $da, $b1, $1d, $6b, $94, $71
	db $a6, $80

SaxifrageGymLeader:
	checkflag ENGINE_RAUCOUSBADGE
	sif true
		jumptextfaceplayer .already_beaten_text
	faceplayer
	opentext
	writetext .introduction_text
	winlosstext .battle_won_text, 0
	setlasttalked 255
	writecode VAR_BATTLETYPE, BATTLETYPE_NORMAL
	loadtrainer CADENCE, CADENCE_GYM
	startbattle
	reloadmapafterbattle
	opentext
	writetext .received_badge_text
	playwaitsfx SFX_TCG2_DIDDLY_5
	writetext .give_TM_text
	waitbutton
	givetm 79 + RECEIVED_TM
	setflag ENGINE_RAUCOUSBADGE
	jumptext .after_TM_text

.introduction_text
	db TX_COMPRESSED, $6e, $9d, $bc, $51, $a1, $14, $bc

	db $40, $3a, $2c, $8d, $bb, $93, $23, $27

	db $e0, $0e, $a3, $48, $39, $69, $38, $20, $35, $1a, $e0, $70
	db $79, $01, $68, $99, $96, $18, $64, $4e, $91, $93
	db $01, $69, $38, $ce, $88, $d5, $63, $e8, $ec, $66
	db $87, $83, $84, $7c, $14, $07, $2b, $e1, $27

	db $10, $05, $24, $e0, $80, $d4, $6b, $81
	db $c1, $e4, $05, $a2, $66, $69, $33, $1f, $69, $03
	db $64, $03, $3a, $48, $ca, $74, $9c, $9c, $48, $6a
	db $78, $24, $38, $20, $d7, $80, $56, $fa, $38

	db $80, $c7, $08, $54, $a6, $dc, $04, $16, $bf, $01, $05
	db $a7, $84, $2c, $2a, $f5, $5f, $41, $4c, $84, $94
	db $c0, $06, $0c, $64, $8a, $44, $0d, $52, $d2
	db $6f, $64, $78, $60, $6b, $32, $32, $71, $59, $dd, $46, $64
	db $01, $b1, $03, $21, $ca, $b4, $18, $e6, $93
	db $2f, $6c, $40, $b3, $6b, $56, $72, $ad, $06, $3e

	db $20, $01, $e1, $8f, $ed, $d9, $af, $d1, $d1
	db $63, $d7, $aa, $43, $27, $30, $10, $5a, $99, $0d, $44
	db $e3, $4f, $10

.battle_won_text
	db TX_COMPRESSED, $6e, $7d, $ef, $e0, $ee, $68, $81, $07, $ab
	db $43, $d6, $9d, $b8, $f8, $29, $c8, $f9, $83, $44, $68
	db $42, $ad, $26, $63, $a2, $c8, $b0, $b2, $a4, $79, $81, $6a

	db $fc, $01, $41, $9b, $e8, $80, $82, $d3, $01, $c3, $d5, $90
	db $f2, $f0, $20, $b4, $b4, $1f, $70, $96, $93, $82, $16, $16
	db $b2, $a9, $c9, $ad, $32, $16, $91, $04, $b7, $3c, $9f
	db $1a, $68

.received_badge_text
	db TX_COMPRESSED, $a7, $8e, $2c, $d9, $31, $83, $1e
	db $5e, $72, $6b, $4c, $85, $a4, $41, $2d, $cf, $27
	db $ea, $68

.give_TM_text
	db TX_COMPRESSED, $62, $6b, $3c, $53, $61, $42, $b2, $d3
	db $b6, $f7, $23, $06, $34, $40, $41, $6a, $5a
	db $4d, $50, $80, $d4, $6b, $81, $c2, $20, $2d, $13, $3c
	db $69, $e2

.after_TM_text
	db TX_COMPRESSED, $28, $56, $9e, $b9, $98, $34
	db $3c, $c4, $10, $83, $5c, $07, $01, $1b, $27

	db $c4, $03, $ab, $c5, $36, $22, $d6, $12
	db $72, $f2, $02, $d1, $33, $36, $ef, $59, $52

	db $01, $69, $db, $70, $f6, $3f, $aa
	db $46, $f0, $20, $b4, $b8, $11, $02, $02, $43, $25, $e2
	db $54, $7a, $b4, $41, $01, $68, $99
	db $e3, $4d

.already_beaten_text
	db TX_COMPRESSED, $74, $59, $39, $08, $c9, $cc, $b0
	db $bc, $8b, $d5, $dc, $a9, $63, $b1, $93
	db $95, $48, $0b, $e7, $08, $75, $44, $04, $9c, $a3

	db $88, $01, $50, $50, $1c, $af, $84, $91, $9d
	db $23, $c9, $3e, $88, $8f, $9c, $7f, $54, $8e, $5a
	db $4c, $00, $83, $5e, $06, $cd, $c5, $85, $95, $28, $16
	db $ad, $e4, $04, $9c, $f1
	db $a6, $80

SaxifrageGym_MapEventHeader ;filler
	db 0, 0

;warps
	db 2
	warp_def $d, $5, 2, SAXIFRAGE_ISLAND
	warp_def $d, $4, 2, SAXIFRAGE_ISLAND

	;xy triggers
	db 0

	;signposts
	db 0

	;people-events
	db 5
	person_event SPRITE_PRYCE, 1, 4, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_YELLOW, PERSONTYPE_SCRIPT, 0, SaxifrageGymLeader, EVENT_SAXIFRAGE_LIGHT_OFF_3
	person_event SPRITE_ROCKER, 5, 5, SPRITEMOVEDATA_SPINCLOCKWISE, 0, 0, -1, -1, PAL_OW_YELLOW, PERSONTYPE_TRAINER, 0, SaxifrageGym_Trainer_1, EVENT_SAXIFRAGE_LIGHT_OFF_2
	person_event SPRITE_ROCKER, 7, 7, SPRITEMOVEDATA_SPINCLOCKWISE, 0, 0, -1, -1, PAL_OW_YELLOW, PERSONTYPE_TRAINER, 0, SaxifrageGym_Trainer_2, EVENT_SAXIFRAGE_LIGHT_OFF_1
	person_event SPRITE_ROCKER, 9, 3, SPRITEMOVEDATA_SPINCLOCKWISE, 0, 0, -1, -1, PAL_OW_YELLOW, PERSONTYPE_TRAINER, 0, SaxifrageGym_Trainer_3, -1
	person_event SPRITE_GYM_GUY, 10, 7, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_GREEN, PERSONTYPE_SCRIPT, 0, SaxifrageGymGuide, -1

