SpurgeGym1F_MapScriptHeader;trigger count
	db 2
	maptrigger .Trigger0
	maptrigger .Trigger1

 ;callback count
	db 0

.Trigger0
	priorityjump .Script
.Trigger1
	end

.Script
	checkevent EVENT_ENTERED_SPURGE_GYM
	clearevent EVENT_ENTERED_SPURGE_GYM
	sif true, then
		checkevent EVENT_SPURGE_GYM_B1F_DYNAMITE
		sif true, then
			checkevent EVENT_SPURGE_GYM_SMASHROCK
			sif false
				takeitem DYNAMITE, 1
		sendif
		callasm UnhideParty
		applymovement 2, .leader_approaches_player
		faceperson PLAYER, LEFT
		showtext .forfeit_text
		applymovement 2, .leader_moves_back
	sendif
	dotrigger 1
	end

.leader_approaches_player
	step_down
	step_end

.leader_moves_back
	step_up
	step_end

.forfeit_text
	db TX_COMPRESSED, $07, $86, $e3, $42, $26, $01, $5c, $b4
	db $9b, $cc, $a7, $7b, $d3, $27, $27

	db $4a, $01, $89, $ac, $e6, $ac, $e0, $20, $b4
	db $b7, $81, $ca, $f8, $49, $15, $eb, $2a, $5f
	db $55, $69, $32, $7a, $09, $34, $fb, $e6, $bf

	db $00, $6d, $0b, $e7, $15, $eb, $2a, $50, $24, $64
	db $de, $04, $16, $a7, $27, $71, $16, $b0, $93, $93, $5f
	db $a9, $e2
	
SpurgeGymSign:
	db TX_COMPRESSED, $50, $21, $a5, $f2, $71, $84, $09
	
	db $f0, $18, $e7, $b9, $35, $b8, $c1, $25, $b4, $c9
	db $d3, $40

SpurgeGym1FLeader:
	faceplayer
	checkevent EVENT_SPURGE_GYM_DEFEATED
	sif true
		jumptext .already_defeated_text
	checkcode VAR_PARTYCOUNT
	sif !=, 6
		jumptext .less_than_six_mons_text
	callasm .CheckPartyForEggs
	sif false
		jumptext .have_egg_text
	showtext .introduction_text
	playsound SFX_ENTER_DOOR
	changeblock 4, 2, $17
	reloadmappart
	pause 16
	blackoutmod SPURGE_GYM_1F
	special HealParty
	callasm SpurgeHidePokemon
	setevent EVENT_ENTERED_SPURGE_GYM
	clearevent EVENT_SPURGE_GYM_POKEMON_1
	clearevent EVENT_SPURGE_GYM_POKEMON_2
	clearevent EVENT_SPURGE_GYM_POKEMON_3
	clearevent EVENT_SPURGE_GYM_POKEMON_4
	clearevent EVENT_SPURGE_GYM_POKEMON_5
	clearevent EVENT_SPURGE_GYM_POKEMON_6
	clearevent EVENT_SPURGE_GYM_B1F_CADENCE
	clearevent EVENT_SPURGE_GYM_B1F_JOSIAH
	clearevent EVENT_SPURGE_GYM_B1F_EDISON
	clearevent EVENT_SPURGE_GYM_B1F_RINJI
	clearevent EVENT_SPURGE_GYM_PUSHROCK
	clearevent EVENT_SPURGE_GYM_B1F_DYNAMITE
	clearevent EVENT_SPURGE_GYM_SWITCH_ENABLED
	clearevent EVENT_SPURGE_GYM_SMASHROCK
	applymovement PLAYER, .hide_player
	warp SPURGE_GYM_B1F, 20, 36
	warpsound
	applymovement PLAYER, .sky_fall
	domaptrigger SPURGE_GYM_1F, 0
	jumptext .instructions_text

.CheckPartyForEggs:
	ld hl, wPartySpecies
	xor a
	ld [hScriptVar], a
.loop
	ld a, [hli]
	cp EGG
	ret z
	inc a
	jr nz, .loop
	inc a
	ld [hScriptVar], a
	ret

.hide_player
	skyfall_top
	step_end

.sky_fall
	skyfall
	step_end
	
.less_than_six_mons_text
	db TX_COMPRESSED, $50, $15, $ac, $17, $e5, $a4, $68, $8c, $20, $4f
	db $bc, $b3, $16, $6d, $0d, $66, $89, $80, $57, $01, $05
	db $a0, $16, $18, $9d, $06, $39, $b3, $06, $bb
	db $d7, $84, $6a, $ec, $14, $0e, $11, $03, $a7

	db $7c, $01, $b4, $2f, $9c, $57, $ac, $a9, $4a, $87, $69
	db $7b, $66, $0d, $77, $b2, $cf, $5f, $fc, $d2
	db $65, $55, $a4, $c9, $2a, $37, $0f, $65, $ef, $54

	db $bc, $02, $be, $a0, $3f, $99, $09, $29, $91, $5a, $c6, $4e
	db $5e, $d2, $02, $87, $cf, $28, $83, $25, $86, $02, $0b, $4b
	db $54, $23, $57, $60, $bf, $04, $74, $f5, $07

	db $e0, $0e, $af, $14, $c0, $2b, $80, $82, $d2
	db $de, $56, $64, $3c, $07, $7f, $9a, $40, $55, $68, $2f
	db $53, $40

.have_egg_text
	db TX_COMPRESSED, $50, $15, $ac, $17, $e1, $f3, $ca, $26, $ac, $c9, $4c
	db $7b, $7b, $d0, $d4, $79, $83, $24, $b4, $8d
	db $0a, $98, $40, $9f, $8c, $a7, $7b, $d3, $27, $27

	db $e0, $0d, $a1, $7c, $e2, $bd, $65, $4a, $54, $3b, $4c, $20
	db $5e, $3e, $79, $44, $19, $20, $20, $b4, $b8, $23, $57, $60
	db $80, $0f, $08, $08, $2d, $4a, $b4, $97, $2c
	db $2f, $32, $9d, $ef, $4c, $9c, $9c, $b4, $9c, $61, $02, $7f
	db $d4, $d0

.introduction_text
	db TX_COMPRESSED, $6e, $7d, $64, $2f, $9f, $e1, $4b, $d1, $90, $d7

	db $c4, $05, $6b, $38, $08, $2d, $45, $9e, $e4, $14, $b0
	db $bd, $80, $f9, $4d, $cc, $02, $b9, $69
	db $35, $40, $fd, $ed, $38, $18, $25, $b9, $e4, $e9

	db $40, $53

	db $c0, $01, $b9, $f7, $bf, $8e, $8b, $21, $03, $7e
	db $a7, $88

.instructions_text
	db TX_COMPRESSED, $62, $6b, $3c, $52, $d2, $71, $0a, $43, $21, $01

	db $78, $03, $a6, $03, $97, $aa, $46, $49, $bd, $ec, $0e
	db $0f, $02, $0b, $4b, $80, $e5, $7c, $24

	db $f0, $07, $64, $64, $e0, $20, $b5, $30, $19, $33, $37, $bd
	db $78, $38, $4b, $49, $bf, $f8, $c8, $5f, $39, $a4
	db $c8, $0c, $06, $4c, $c7, $cf, $d0, $a4, $99, $23, $a7, $0f
	db $5e, $41, $9c, $1e, $10, $10, $5a, $2e
	db $30, $16, $b6, $ba, $0a, $54, $15, $da, $41, $40
	db $e0, $f7, $27, $76, $32, $73, $1f, $05, $15, $ee, $79, $3f
	db $53, $40

.already_defeated_text
	db TX_COMPRESSED, $07, $86, $a9, $69, $db, $80, $82, $d4, $4e, $83
	db $1b, $d6, $93, $80, $fd, $ed, $38, $18, $25, $b9, $e4
	db $fe, $00, $10, $5a, $95, $0f, $bd, $8a, $ce, $6a, $be
	db $9b, $d6, $18, $c8, $5f, $10, $76, $70, $64, $96, $93
	db $54, $e4, $1d, $38, $12, $4c, $73, $de, $5a, $3e

	db $20, $0a, $0c, $e4, $ee, $5a, $4d, $67
	db $f7, $b9, $0c, $b0, $ca, $d9, $d2, $0f, $67, $00, $59, $52
	db $42, $ad, $26, $62, $4f, $73, $0f, $51, $7e

	db $00, $e5, $0b, $4e, $1e, $c5, $9e, $b2, $99, $69
	db $37, $81, $fb, $da, $70, $30, $48, $2b, $c9, $af
	db $e0, $2a, $49, $ac, $e0, $20, $b4, $e1, $ec, $56
	db $6f, $6a, $be, $9c, $b0, $c3, $25, $9a, $e5, $a4
	db $d5, $28, $32, $1b, $3b, $1b, $74, $18, $d6, $44

	db $78, $02, $9a, $c2, $fc, $b4, $ed, $c1, $01, $19
	db $2d, $e0, $93, $f0, $10, $5a, $70, $f6, $27, $41, $8e, $58
	db $40, $2c, $fa, $0a, $04, $90, $10, $5a, $5c, $0d, $44
	db $79, $0a, $43, $ef, $65, $86, $13, $41, $87, $ce, $d9
	db $80, $b4, $ac, $2d, $72, $98, $3b, $83
	db $23, $c1, $5e, $4d, $72, $c3, $16, $7a, $ca
	db $55, $5a, $4e, $39, $07, $4e, $04, $93, $1c, $f7, $96, $8f

	db $c0, $14, $5e, $82, $88, $b5, $84, $9c, $f1
	db $a6, $80

SpurgeGym1F_MapEventHeader:: db 0, 0

.Warps: db 2
	warp_def 13, 4, 6, SPURGE_CITY
	warp_def 13, 5, 6, SPURGE_CITY

.CoordEvents: db 0

.BGEvents: db 2
	signpost 11, 2, SIGNPOST_TEXT, SpurgeGymSign
	signpost 11, 7, SIGNPOST_TEXT, SpurgeGymSign

.ObjectEvents: db 1
	person_event SPRITE_CLAIR, 2, 4, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_BLUE, PERSONTYPE_SCRIPT, 0, SpurgeGym1FLeader, -1

