SoutherlyBattleHouse_MapScriptHeader;trigger count
	db 0
 ;callback count
	db 0

SoutherlyBattleHouseNPC:
	opentext
	writetext .introduction_text
	yesorno
	sif false
		jumptext .declined_text
	writetext .accepted_text
	closetext
	applymovement 2, .GuardMoveOut
	applymovement PLAYER, .PlayerEnterStamina
	setlasttalked 3
	writebyte 0
	pushvar
	jump .handleLoop

.loop
	pushvar
	applymovement 3, .TrainerWalkOut
	applymovement 2, .GuardWalkToHeal
	special HealParty
	special Special_BattleTowerFade
	playwaitsfx SFX_HEAL_POKEMON
	special FadeInPalettes
	applymovement 2, .GuardWalkawayHeal
.handleLoop
	callasm LoadBattleHouseTrainerData
	applymovement 3, .TrainerWalkIn
	opentext
	trainertext 0
	waitbutton
	closetext
	loadmemtrainer
	startbattle
	reloadmap
	sif true, then
		scall .exit
		jumptext .challenge_lost_text
	sendif
	opentext
	trainertext 2
	waitbutton
	closetext
	popvar
	addvar 1
	if_less_than 7, .loop
	scall .exit
	opentext
	writetext .challenge_won_text
	verbosegiveitem NUGGET
	endtext

.exit
	pause 30
	warpfacing UP, SOUTHERLY_BATTLE_HOUSE, 3, 7
	special HealParty
	end

.GuardWalkawayHeal
	step_left
	step_left
	step_left
	step_left
	step_left
	turn_head_right
	step_end

.GuardWalkToHeal
	step_right
	step_right
	step_right
	step_right
	step_right
	turn_head_up
	step_end

.TrainerWalkOut
	step_right
	step_right
	step_right
	step_right
	step_right
	step_up
	step_end

.TrainerWalkIn
	step_down
	step_left
	step_left
	step_left
	step_left
	step_left
	step_end

.GuardMoveOut
	step_up
	step_up
	turn_head_right
	step_end

.PlayerEnterStamina
	step_up
	step_up
	step_right
	step_right
	step_right
	step_right
	step_right
	step_up
	step_up
	turn_head_right
	step_end

.introduction_text
	db TX_COMPRESSED, $6e, $7d, $64, $2f, $9c, $b0, $cb, $49
	db $bc, $a2, $f5, $f1, $93, $63, $6a, $77, $bd, $32, $72, $7c

	db $40, $39, $42, $d4, $a8, $7d, $ec, $c3, $59, $39, $4f
	db $5e, $b0, $b5, $ca, $61, $4b, $d1, $90, $d6
	db $85, $43, $24, $d8, $b0, $d5

	db $e0, $0e, $b0, $80, $82, $d4, $7f, $54, $8e, $0e, $e6, $f7
	db $af, $5a, $4e, $55, $a0, $a5, $86, $5a
	db $4c, $01, $93, $3f, $80, $82, $d3, $87, $b3, $93, $b9
	db $af, $20, $41, $b2, $3d, $ec, $10, $b1, $89, $b3

	db $e2, $01, $be, $92, $e5, $86, $72, $30, $63, $83, $b9
	db $af, $21, $21, $ba
	db $5a, $68

.accepted_text
	db TX_COMPRESSED, $61, $04, $39, $fc, $64, $2f, $9c, $09, $20, $c9
	db $c6, $9e, $20

.declined_text
	db TX_COMPRESSED, $29, $3b, $78, $a6, $03, $21, $fe, $32, $17
	db $cd, $ed, $e7, $46, $4e
	db $34, $d0

.challenge_won_text
	db TX_COMPRESSED, $72, $85, $a9, $50, $49

	db $c4, $03, $13, $59, $c1, $a2, $02, $0b, $4b
	db $78, $42, $c6, $26, $cf
	db $88, $39, $80

.challenge_lost_text
	db TX_COMPRESSED, $29, $3b, $78, $a6, $c4, $27, $5f, $3f

	db $00, $29, $60, $a6, $f3, $a3, $24, $40, $5f
	db $37, $83, $69, $35, $cb, $1b, $e7
	db $c6, $9a

LoadBattleHouseTrainerData:
	ld a, [hScriptVar]
	ld bc, SoutherlyBattleHouse_TrainerDataEnd - SoutherlyBattleHouse_TrainerData
	ld hl, SoutherlyBattleHouse_TrainerData
	rst AddNTimes
	ld a, [hli]
	ld [Map2ObjectSprite], a
	ld [UsedSprites + $4], a
	ld [hUsedSpriteIndex], a
	ld a, [hli]
	ld [Map2ObjectColor], a
	ld a, [UsedSprites + $5]
	ld [hUsedSpriteTile], a
	ld de, wTempTrainerClass
	ld bc, 8
	rst CopyBytes
	ld a, [ScriptBank]
	ld [wTempTrainerBank], a
	jpba GetUsedSprite

battlehousetrainer: MACRO
	db SPRITE_\1, PAL_OW_\2 ; sprite, color
	db \3, \4 ; class, id
	dw \5, \6, \7 ; text before, win, after
	ENDM

SoutherlyBattleHouse_TrainerData:
	battlehousetrainer BEAUTY,        GREEN, BEAUTY,        6, StaminaTrainer1EncounterText, StaminaTrainer1DefeatedText, StaminaTrainer1AfterText
SoutherlyBattleHouse_TrainerDataEnd:
	battlehousetrainer SUPER_NERD,    BLUE,  SUPER_NERD,   10, StaminaTrainer2EncounterText, StaminaTrainer2DefeatedText, StaminaTrainer2AfterText
	battlehousetrainer YOUNGSTER,     BLUE,  YOUNGSTER,     6, StaminaTrainer3EncounterText, StaminaTrainer3DefeatedText, StaminaTrainer3AfterText
	battlehousetrainer PSYCHIC,       BLUE,  PSYCHIC_T,     7, StaminaTrainer4EncounterText, StaminaTrainer4DefeatedText, StaminaTrainer4AfterText
	battlehousetrainer COOLTRAINER_M, RED,   COOLTRAINERM, 13, StaminaTrainer5EncounterText, StaminaTrainer5DefeatedText, StaminaTrainer5AfterText
	battlehousetrainer FIREBREATHER,  BLUE,  FIREBREATHER, 10, StaminaTrainer6EncounterText, StaminaTrainer6DefeatedText, StaminaTrainer6AfterText
	battlehousetrainer COOLTRAINER_M, RED,   COOLTRAINERM, 14, StaminaTrainer7EncounterText, StaminaTrainer7DefeatedText, StaminaTrainer7AfterText

StaminaTrainer1EncounterText:
	db TX_COMPRESSED, $74, $59, $2d, $60, $86, $4e, $65, $86, $74
	db $ed, $e7, $c1, $40, $72, $be, $12, $46, $90, $73
	db $40, $10, $ea, $8f, $84, $18, $e5, $a7, $6e, $3a
	db $7b, $23, $43, $21, $06, $35, $9e, $78
	db $d3, $40

StaminaTrainer1DefeatedText:
	db TX_COMPRESSED, $51, $66, $7d, $82, $ed, $b3, $5c, $1a
	db $1e, $da, $8d, $01, $7c, $ff, $15, $b5, $70, $10, $5a
	db $55, $ab, $38, $ac, $ee, $cd, $7c
	db $69, $a0

StaminaTrainer1AfterText:
	db TX_COMPRESSED, $50, $17, $ce, $67, $41, $47, $4e, $1e, $cc, $06, $4c
	db $bc, $60, $c6, $48, $f8, $56, $71, $f0, $83, $1a, $38
	db $d3, $40

StaminaTrainer2EncounterText:
	db TX_COMPRESSED, $29, $27, $11, $7a, $b8, $1c, $23, $e0
	db $9e, $b3, $d7, $e0, $d1, $1b, $9e, $83, $0f, $a7
	db $c6, $9a

StaminaTrainer2DefeatedText:
	db TX_COMPRESSED, $75, $73, $23, $c9, $29, $91, $1a, $0c, $71, $f3
	db $e3, $4d

StaminaTrainer2AfterText:
	db TX_COMPRESSED, $6e, $6e, $1e, $c4, $24, $35, $40, $41
	db $69, $e5, $61, $42, $21, $0e, $9d, $b9, $63, $7c, $f8
	db $d3, $40

StaminaTrainer3EncounterText:
	db TX_COMPRESSED, $62, $fb, $ef, $d2, $ce, $00, $c7, $51, $48, $81
	db $a9, $e0, $41, $6a
	db $96, $9a

StaminaTrainer3DefeatedText:
	db TX_COMPRESSED, $6e, $90, $cd, $59, $c0, $41, $6a
	db $96, $9a

StaminaTrainer3AfterText:
	db TX_COMPRESSED, $72, $1e, $f7, $a0, $a9

	db $40, $39, $42, $d1, $71, $cc, $7d, $23, $27, $8a, $29, $0f, $34
	db $b4, $d0

StaminaTrainer4EncounterText:
	db TX_COMPRESSED, $74, $c0, $71, $59, $99, $25, $5a, $3b, $19, $39
	db $7b, $00, $ae, $5a, $46, $8e
	db $34, $d0

StaminaTrainer4DefeatedText:
	db TX_COMPRESSED, $75, $72, $ad, $44, $a8, $2b, $b4, $cb, $49
	db $bd, $56, $8e, $f8
	db $d3, $40

StaminaTrainer4AfterText:
	db TX_COMPRESSED, $29, $3a, $45, $28, $08, $2d, $4c, $02, $b8, $40
	db $db, $dc, $8c, $18, $64, $e6, $34, $23
	db $8d, $34

StaminaTrainer5EncounterText:
	db TX_COMPRESSED, $76, $9f, $c4, $9f, $7a, $1f

	db $00, $c7, $3b, $8f, $9c, $57, $b7, $7d, $38, $08, $2d
	db $3c, $b3, $de, $c1, $66, $d0, $d9, $52

	db $f0, $07, $57, $8a, $10, $37, $3a, $35, $23, $80, $82
	db $d3, $c9, $d0, $63, $88, $0b, $e7, $69, $19, $39
	db $00, $37, $c4, $05, $77, $a4, $b9, $61, $99, $0c, $0a
	db $de, $d2, $02, $b4, $8c, $9c
	db $fa, $9a

StaminaTrainer5DefeatedText:
	db TX_COMPRESSED, $76, $9f, $46, $e7, $de, $fe, $3a, $2c, $84, $0d
	db $bc, $37, $c4, $2c, $d0, $83, $cf
	db $a9, $a0

StaminaTrainer5AfterText:
	db TX_COMPRESSED, $72, $85, $a8, $c9, $ae, $f4, $64, $e8, $28, $fb, $48
	db $b7, $93, $a0, $c7, $36, $74, $37, $03, $84, $c1, $66
	db $60, $2c, $6f, $9c, $b0, $c6, $42, $f9, $c5, $60
	db $9e, $49, $ac

	db $fc, $01, $84, $18, $8d, $06, $39, $69, $39, $50, $57, $dc
	db $bc, $15, $c4, $05, $f3, $b4, $8c, $9c
	db $fa, $9a

StaminaTrainer6EncounterText:
	db TX_COMPRESSED, $12, $73, $b9, $01, $ff, $82, $55, $89, $39, $7f, $04, $9c, $ee, $40, $7f

	db $10, $14, $f0, $4a, $78, $25, $3c
	db $0f, $53, $c1, $29, $e0, $94, $f0

	db $00, $75, $84, $75, $11, $a0, $a6, $90, $14, $7c, $2b, $3f
	db $bc, $ea, $2c, $68, $52, $8c, $84, $40, $25, $8f, $94
	db $da, $a1, $93, $05, $8c, $9c, $9b, $e6, $4b
	db $e3, $4d

StaminaTrainer6DefeatedText:
	db TX_COMPRESSED, $af, $94, $f1, $9c, $03, $43, $21, $9a, $4c
	db $bd, $80, $d6, $73, $21, $25, $32, $3e, $3a, $77
	db $8d, $34

StaminaTrainer6AfterText:
	db TX_COMPRESSED, $72, $1b, $e6, $fa, $b3, $5c, $52, $1e, $51
	db $f7, $95, $ac, $f6, $d2, $73, $01, $ac
	db $d5, $2c, $d0, $20, $24, $40, $d5, $f4, $17
	db $1a, $68

StaminaTrainer7EncounterText:
	db TX_COMPRESSED, $74, $59, $15, $85, $67, $9f

	db $00, $c7, $3b, $c5, $13, $a0, $c7
	db $35, $e5, $7b, $77, $d3
	db $e3, $4d

StaminaTrainer7DefeatedText:
	db TX_COMPRESSED, $a7, $83, $49, $98, $40, $d5, $1d, $16, $45, $61, $59
	db $e5, $ed, $e7, $46, $4f
	db $53, $40

StaminaTrainer7AfterText:
	db TX_COMPRESSED, $a7, $81, $01, $8a, $c2, $b3, $cf
	db $a9, $a0

SoutherlyBattleHouse_MapEventHeader ;filler
	db 0, 0

;warps
	db 2
	warp_def $9, $6, 3, SOUTHERLY_CITY
	warp_def $9, $7, 3, SOUTHERLY_CITY

	;xy triggers
	db 0

	;signposts
	db 0

	;people-events
	db 2
	person_event SPRITE_OFFICER, 6, 3, SPRITEMOVEDATA_STANDING_DOWN, 0, 0, -1, -1, PAL_OW_GREEN, PERSONTYPE_SCRIPT, 0, SoutherlyBattleHouseNPC, -1
	person_event SPRITE_TEACHER, 2, 14, SPRITEMOVEDATA_00, 0, 0, -1, -1, PAL_OW_BLUE, PERSONTYPE_SCRIPT, 0, ObjectEvent, -1

