SpurgeGymB2F_MapScriptHeader;trigger count
	db 0
 ;callback count
	db 0

SpurgeGymB2FFourthMon:
	setevent EVENT_SPURGE_GYM_POKEMON_4
	jump SpurgeGymGetPokemon

SpurgeGymB2FFirstMon:
	setevent EVENT_SPURGE_GYM_POKEMON_1

SpurgeGymGetPokemon:
	scriptstartasm
	ld hl, wPartyCount
	inc [hl]
	ld c, [hl]
	ld b, 0
	add hl, bc
	ld de, wBackupSecondPartySpecies
	ld a, [de]
	ld [hli], a
	ld [hScriptVar], a
	ld a, [hl]
	ld [de], a
	ld [hl], $ff
	ld a, c
	dec a
	ld hl, wPartyMonNicknames
	call SkipNames
	ld d, h
	ld e, l
	ld hl, wStringBuffer1
	call CopyName2
	scriptstopasm
	opentext
	writetext .found_mon_text
	cry 0
	disappear LAST_TALKED
	closetextend

.found_mon_text
	text "<PLAYER> found"
	line "<STRBF1>!"
	done

SpurgeGymB2FButton:
	checkevent EVENT_SPURGE_GYM_SWITCH_ENABLED
	sif true
		jumptext .already_pushed_text
	playsound SFX_ENTER_DOOR
	setevent EVENT_SPURGE_GYM_SWITCH_ENABLED
	jumptext .pushed_text

.pushed_text
	db TX_COMPRESSED, $e1, $69, $09, $3c, $cb, $49
	db $bc, $ad, $ab, $b0, $93

	db $c0, $01, $e1, $b8, $86, $96, $72, $a4, $ed
	db $bd, $69, $db, $99, $1e, $69, $e0
	db $a6, $80

.already_pushed_text
	db TX_COMPRESSED, $29, $27, $15, $b5, $76, $12, $44, $ea
	db $1e, $de, $ac, $f7, $20, $a2, $b3, $32
	db $2a, $10, $d2, $12, $79
	db $f5, $34

SpurgeGymB2FLeader:
	checkcode VAR_PARTYCOUNT
	sif !=, 6
		jumptextfaceplayer .did_not_find_all_mons_text
	faceplayer
	opentext
	writetext .introduction_text
	winlosstext .battle_won_text, 0
	setlasttalked 255
	writecode VAR_BATTLETYPE, BATTLETYPE_NORMAL
	loadtrainer BRUCE, 1
	startbattle
	reloadmapafterbattle
	playmapmusic
	opentext
	writetext .received_badge_text
	playwaitsfx SFX_TCG2_DIDDLY_5
	setflag ENGINE_NALJOBADGE
	special RestartMapMusic
	writetext .before_giving_TM_text
	givetm TM_FLASH_CANNON + RECEIVED_TM
	opentext
	writetext .after_giving_TM_text
	writetext .parting_text
	setevent EVENT_SPURGE_GYM_DEFEATED
	special Special_BattleTowerFade
	playwaitsfx SFX_WARP_FROM
	clearevent EVENT_ENTERED_SPURGE_GYM
	warp SPURGE_CITY, 34, 6
	end

.did_not_find_all_mons_text
	db TX_COMPRESSED, $50, $1f, $c0, $41, $6a, $64, $79, $8f, $e9, $00
	db $bd, $bc, $9c, $b0, $cc, $06, $4c, $c7, $cf

	db $88, $06, $21, $a8, $c1, $8d, $7f, $80, $82, $d4, $c8, $f2, $4a
	db $63, $d8, $0c, $99, $9b, $de, $c0, $e1, $01, $05, $a5
	db $aa, $07, $2b, $e1, $24, $04, $77

	db $c4, $03, $68, $5f, $38, $af, $59, $52, $95, $24, $c9, $01, $05
	db $a7, $b0, $19, $33, $2d, $26, $fc, $de, $f7
	db $d4, $d0

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

	db $c4, $00, $91, $b3, $ad, $20, $e0, $70, $80, $82, $d2
	db $de, $56, $bd, $06, $35, $82, $88, $48, $6a
	db $22, $ab, $4a, $c2, $d7, $29, $8f, $82, $82, $1a, $13, $62, $6f, $a7
	db $f0, $0e, $a2, $74, $18, $e6, $4d, $91, $e4, $f3, $2c
	db $2f, $25, $a7, $d5, $f4, $14, $d6, $59, $31, $17, $01, $05, $a5
	db $aa, $65, $3b, $de, $99, $39, $39, $b7, $3b, $a8, $be

	db $20, $1d, $4d, $7e, $09, $2d, $a6, $4f, $f2, $d2
	db $6f, $08, $58, $5a, $cc, $51, $66, $7d, $8c, $20, $4f
	db $aa, $c7, $3d, $c9, $ae, $07, $08, $0f, $de, $d3, $81

	db $e2, $00, $a4, $9c, $c9, $e0, $64, $41, $c6, $74, $46, $81
	db $79, $58, $fa, $3b, $19, $a2, $07, $08, $8b, $33
	db $e8, $00, $72, $be, $12, $46, $74, $90, $86, $0c, $6b
	db $79, $59, $c7, $f6, $d9, $49, $e7

	db $88, $0a, $d6, $70, $10, $5a, $8b, $3d, $c8, $2a
	db $5a, $78, $80

.battle_won_text
	db TX_COMPRESSED, $63, $4f, $02, $43, $55

	db $28, $06, $e7, $de, $fe, $10, $31, $fd, $bb, $35

	db $f8, $03, $94, $2d, $44, $e8, $31, $c3, $d5, $90
	db $f2, $f3, $e0, $a0, $96, $e7, $93, $fc, $d2, $66, $5a
	db $4c, $00, $44, $08, $0a, $ed, $a2, $0e, $c1, $4b
	db $0b, $cc, $85, $f1, $07, $67, $06, $49, $69
	db $35, $4e, $41, $d3, $81, $24, $c7, $3d, $e5, $a3
	db $e3, $4d

.received_badge_text
	db TX_COMPRESSED, $a7, $8e, $2c, $d9, $31, $83, $1e
	db $5e, $07, $ef, $69, $c0, $c1, $2d, $cf, $27
	db $c6, $9a

.before_giving_TM_text
	db TX_COMPRESSED, $75, $10, $d0, $81, $01, $41, $c7, $51, $90, $b5, $dc
	db $bd, $c8, $c1, $8e, $02, $0b, $52, $d2, $34, $4b, $08
	db $7d, $4f, $10

.after_giving_TM_text
	db TX_COMPRESSED, $29, $23, $44, $28, $56, $0d
	db $0f, $29, $f7, $50, $98, $db, $a4, $20, $49

	db $c4, $03, $ab, $c5, $36, $08, $0d, $46, $bc, $1a
	db $eb, $ca, $2c, $cf, $b1, $f0, $83, $1c, $b4, $ed
	db $80, $4e, $a2, $5a, $4e, $32, $9d, $23
	db $26, $f0, $70, $9d, $0d, $46, $b1, $93, $99, $69
	db $30, $18, $04, $f1, $45, $02, $0d, $91, $ef
	db $5e, $e0, $3c, $0c, $88, $39, $b1, $58, $ef
	db $8d, $3c, $40

.parting_text
	db TX_COMPRESSED, $6e, $7d, $ef, $e1, $03, $54, $1d, $e2
	db $7a, $c6, $f9, $cc, $02, $b8, $d2, $25
	db $85, $53, $fa, $a4, $70, $2d, $2e, $1d, $3a, $3b

	db $f0, $07, $51, $58, $f3, $01, $05
	db $a7, $b0, $d5, $9d, $47, $de
	db $fa, $9e, $20

SpurgeGymB2F_MapEventHeader:: db 0, 0

.Warps: db 4
	warp_def 33, 3, 2, SPURGE_GYM_B2F_SIDESCROLL
	warp_def 3, 3, 3, SPURGE_GYM_B1F
	warp_def 3, 13, 4, SPURGE_GYM_B1F
	warp_def 15, 7, 5, SPURGE_GYM_B1F

.CoordEvents: db 0

.BGEvents: db 1
	signpost 1, 3, SIGNPOST_READ, SpurgeGymB2FButton

.ObjectEvents: db 3
	person_event SPRITE_POKE_BALL, 24, 7, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_SCRIPT, 0, SpurgeGymB2FFirstMon, EVENT_SPURGE_GYM_POKEMON_1
	person_event SPRITE_POKE_BALL, 2, 12, SPRITEMOVEDATA_ITEM_TREE, 0, 0, -1, -1, PAL_OW_RED, PERSONTYPE_SCRIPT, 0, SpurgeGymB2FFourthMon, EVENT_SPURGE_GYM_POKEMON_4
	person_event SPRITE_CLAIR, 13, 8, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_BLUE, PERSONTYPE_SCRIPT, 0, SpurgeGymB2FLeader, -1

