JensLab_MapScriptHeader;trigger count
	db 0
 ;callback count
	db 0

JensLabJen:
	faceplayer
	opentext
	checkevent EVENT_PROF_JEN_INTRO
	sif false, then
		setevent EVENT_PROF_JEN_INTRO
		jumptext .introduction_text
	sendif
	copybytetovar wRijonBadges
	sif !=, $ff
		jumptext .not_enough_badges_text
	checkevent EVENT_PROF_JEN_GIVEN_FERRY_TICKET
	sif true
		jumptext .after_receiving_ticket_text
	writetext .receive_ticket_text
	waitbutton
	verbosegiveitem FERRY_TICKET, 1
	setevent EVENT_PROF_JEN_GIVEN_FERRY_TICKET
	jumptext .free_mon_text

.introduction_text
	db TX_COMPRESSED, $62, $7d, $e8, $65, $a4, $c1, $46, $77, $bd
	db $79, $f3, $82, $64, $c9, $f9, $c2, $b0, $e1

	db $e0, $05, $0d, $fc, $53, $50, $81, $a2, $f4
	db $96, $f0, $c9, $66, $b2

	db $78, $07, $0a, $c3, $87, $a1, $43, $7f, $14, $56, $66
	db $47, $b6, $ad, $05, $30, $0a, $e6, $ca, $92, $3e

	db $98, $04, $06, $3a, $60, $39, $7a, $a4, $64, $81, $06, $35
	db $bc, $91, $a2, $2c, $d0, $7a, $b6, $53, $30, $0a
	db $d5, $10, $35

	db $78, $03, $b4, $fe, $02, $0b, $45, $c7, $2d
	db $26, $f1, $0e, $a3, $45, $c7, $20, $e9, $c0
	db $91, $56, $39, $ef, $2d, $1c, $65, $3a, $f8, $81, $84, $94

	db $a0, $1d, $4d, $66, $da, $de, $f4, $14, $52, $20, $6a
	db $78, $38, $4d, $88, $36, $56, $77, $15, $ed, $df

	db $4c, $02, $ce, $d6, $7b, $71, $9d, $ef, $4f, $32, $d2
	db $6f, $09, $6d, $df, $4e, $56, $b6, $77, $27

	db $e0, $0e, $b0, $80, $82, $d4, $64, $3d, $e9, $b3, $73, $7b
	db $d7, $a9, $f4, $72, $0e, $9c, $09, $22, $bd, $cf, $26, $8f, $c7

	db $40, $2a, $1f, $7b, $39, $18, $31, $c0, $41, $6a
	db $6b, $d6, $36, $54, $8e, $e5, $a4, $d6, $7e

	db $00, $c2, $08, $73, $3a, $d3, $2a, $5c
	db $69, $a0

.not_enough_badges_text
	db TX_COMPRESSED, $62, $39, $69, $35, $9f

	db $10, $0a, $2c, $7d, $ec, $c8, $49, $4c, $89, $d0, $63
	db $7b, $7b, $d9, $69, $38, $e4, $1d, $38, $12
	db $2a, $57, $b9, $e4, $d1

	db $4a, $01, $b9, $f7, $bf, $99, $09, $29, $93, $91, $83
	db $1b, $cd, $08
	db $e3, $4d

.receive_ticket_text
	db TX_COMPRESSED, $ad, $fd, $13, $63, $27, $3c

	db $40, $39, $42, $d4, $a8, $d6, $73, $55, $f4, $e5
	db $85, $e6, $43, $de, $9b, $37, $37, $bd, $81
	db $c1, $55, $a4, $e3, $90, $74, $e0, $49, $15, $ee, $79, $34, $71

	db $00, $56, $a9, $1c, $b4, $8d, $12, $c6, $ca, $91, $df
	db $de, $49, $ee, $65, $86, $36, $ea, $2d, $61

	db $00, $0e, $37, $bd, $30, $58, $a0, $80, $ae, $e6, $93
	db $2f, $5e, $a9, $1c, $b4, $9c, $42, $46, $22, $58
	db $55, $5a, $4e, $2b, $db, $be, $9c, $d5, $b3, $b9, $3f
	db $53, $40

.after_receiving_ticket_text
	db TX_COMPRESSED, $29, $26, $b3, $c5, $37, $b5, $68, $24
	db $3c, $43, $aa, $69, $33, $35, $fd, $13, $63, $27

	db $20, $32, $34, $32, $10, $63, $58, $cd, $13, $55, $85, $ab
	db $78, $1c, $af, $84, $92, $c3, $30, $19, $33

	db $c4, $03, $a8, $90, $88, $38, $12, $1c, $ce, $82
	db $79, $d3, $87, $b1, $59, $cd, $80, $e5, $7c, $24

	db $00, $21, $61, $c0, $d0, $80, $ae, $5a, $76, $f1
	db $3d, $a8, $88, $7f, $57, $73, $51, $1f
	db $04, $ab, $95, $e9, $33, $86, $da, $4d, $7c
	db $69, $a0

.free_mon_text
	db TX_COMPRESSED, $74, $e1, $ec, $de, $a0, $33, $a7, $70, $10, $5a
	db $79, $3a, $0c, $70, $24, $38, $1c, $25, $a4, $d0

	db $60, $08, $75, $74, $14, $4e, $db, $29, $3c
	db $bc, $0e, $57, $c2, $4f

	db $00, $ae, $14, $bd, $19, $0d, $73
	db $50, $f2, $14, $87, $de, $e0, $d7, $66

	db $a0, $00, $20, $b4, $b4, $1f, $70, $88, $48, $5a, $ee
	db $5e, $56, $73, $55, $f4, $e5, $86, $2f, $46, $83

	db $00, $12, $1c, $0e, $12, $d2, $6f
	db $bc, $b1, $f2, $9b
	db $e3, $4d

JensLabRedBall:
	scall JensLab_CheckFreeMonStatus
	sif true
		jumptext .ball_text
	writebyte CHARMANDER
	scall JensLab_ConfirmMon
	sif false
		end
	disappear 3
	opentext
	writetext .mon_text
	playwaitsfx SFX_DEX_FANFARE_80_109
	givepoke CHARMANDER, 5, NO_ITEM, 0
	setevent EVENT_PROF_JEN_PICKED_UP_FREE_POKE
	setevent EVENT_PROF_JEN_CHARMANDER
	closetext
	end

.ball_text
	db TX_COMPRESSED, $75, $78, $a6, $c5, $9e
	db $5e, $07, $2a, $bd, $ef, $78
	db $d3, $40

.mon_text
	db TX_COMPRESSED, $a7, $8e, $2c, $d9, $31, $83, $1e
	db $5e, $6d, $4e, $ad, $fd, $26, $4d, $7c
	db $69, $a0

JensLabBlueBall:
	scall JensLab_CheckFreeMonStatus
	sif true
		jumptext .ball_text
	writebyte SQUIRTLE
	scall JensLab_ConfirmMon
	sif false
		end
	disappear 4
	opentext
	writetext .mon_text
	playwaitsfx SFX_DEX_FANFARE_80_109
	givepoke SQUIRTLE, 5, NO_ITEM, 0
	setevent EVENT_PROF_JEN_PICKED_UP_FREE_POKE
	setevent EVENT_PROF_JEN_SQUIRTLE
	closetext
	end

.ball_text
	db TX_COMPRESSED, $75, $78, $a6, $c5, $7d, $68
	db $de, $07, $2a, $bd, $ef, $78
	db $d3, $40

.mon_text
	db TX_COMPRESSED, $a7, $8e, $2c, $d9, $31, $83, $1e
	db $5e, $50, $2c, $da, $1a, $ef, $a7
	db $c6, $9a

JensLabGreenBall:
	scall JensLab_CheckFreeMonStatus
	sif true
		jumptext .ball_text
	writebyte BULBASAUR
	scall JensLab_ConfirmMon
	sif false
		end
	disappear 5
	opentext
	writetext .mon_text
	playwaitsfx SFX_DEX_FANFARE_80_109
	givepoke BULBASAUR, 5, NO_ITEM, 0
	setevent EVENT_PROF_JEN_PICKED_UP_FREE_POKE
	setevent EVENT_PROF_JEN_BULBASAUR
	closetext
	end

.ball_text
	db TX_COMPRESSED, $75, $78, $a6, $ce, $56, $66
	db $47, $81, $ca, $af, $7b, $de
	db $34, $d0

.mon_text
	db TX_COMPRESSED, $a7, $8e, $2c, $d9, $31, $83, $1e
	db $5e, $12, $6b, $aa, $f5, $1a, $d2, $f8
	db $d3, $40

JensLab_CheckFreeMonStatus:
	; returns 0 if the free mon is available, -1 if the ticket hasn't been given away yet, or 1 if it was already picked up
	checkevent EVENT_PROF_JEN_GIVEN_FERRY_TICKET
	addvar -1
	sif true
		end
	checkevent EVENT_PROF_JEN_PICKED_UP_FREE_POKE
	end

JensLab_ConfirmMon:
	refreshscreen 0
	pokepic 0
	cry 0
	waitbutton
	closepokepic
	pokenamemem 0, 0
	opentext
	writetext .mon_text
	yesorno
	sif false, then
		closetext
		end
	sendif
	checkcode VAR_PARTYCOUNT
	addvar 1 ;just in case you have 0 mons for some reason...
	sif <=, 6
		end
	checkcode VAR_BOXSPACE
	sif true
		end
	writebyte 0
	jumptext .no_space_text

.mon_text
	db TX_COMPRESSED, $75, $78, $a6, $ca, $79, $71
	
	db $00, $df, $49, $70, $77
	db $4b, $4d

.no_space_text
	db TX_COMPRESSED, $53, $59, $9c, $68, $44, $40, $5f
	db $37, $90, $23, $59, $38, $32, $43, $1d, $a4

	db $d6, $00, $10, $5a, $5c, $11, $ab, $b0, $50, $2b
	db $79, $58, $69, $de
	db $34, $d0

JensLabGoldTokenCollector1:
	writehalfword EVENT_PROF_JEN_PROF_1
	jump JensLabGoldTokenCollector

JensLabGoldTokenCollector2:
	writehalfword EVENT_PROF_JEN_PROF_2
	; fallthrough

JensLabGoldTokenCollector:
	faceplayer
	opentext
	checkevent EVENT_PROF_JEN_GIVEN_FERRY_TICKET
	sif false
		jumptext .introduction_text
	checkevent EVENT_PROF_JEN_PICKED_UP_FREE_POKE
	sif false
		jumptext .pending_gift_text
	checkevent $ffff
	sif true
		jumptext .already_exchanged_text
	writetext .offer_text
	yesorno
	sif false
		jumptext .refused_text
	takeitem GOLD_TOKEN, 8
	sif false
		jumptext .not_enough_tokens_text
	clearevent EVENT_PROF_JEN_PICKED_UP_FREE_POKE
	setevent $ffff
	jumptext .pick_one_text

.introduction_text
	db TX_COMPRESSED, $75, $35, $f9, $c2, $b0, $e1, $0a, $1b, $f8
	db $9e, $d1, $e4

	db $fc, $01, $d4, $7c, $7c, $a6, $e2, $74, $18, $e6
	db $91, $e0, $e1, $81, $ae, $60, $15, $c0, $41

	db $68, $06, $e1, $66, $b8, $08, $2d, $41, $be, $21, $66, $84
	db $3c, $26, $4c, $90, $20, $c6, $b9, $69, $35, $9f
	db $a9, $a0

.pending_gift_text
	db TX_COMPRESSED, $e1, $1b, $2a, $51, $a1, $10, $10, $5a, $5c, $e4, $78
	db $5b, $d8, $0d, $68, $be
	db $34, $d0

.already_exchanged_text
	db TX_COMPRESSED, $29, $3a, $45, $24, $4c, $02, $b9, $69
	db $37, $ac, $2a, $46, $44, $47, $c1, $4e, $42, $1c
	db $aa, $7f, $49
	db $c6, $9a

.offer_text
	db TX_COMPRESSED, $75, $35, $f9, $c2, $b0, $e1, $0a, $1b, $f8
	db $9e, $d1, $e4, $e6, $a2, $54, $7d, $ec, $d4
	db $00, $d8, $c8, $7b, $d3, $66, $c2, $b8, $1c
	db $1e, $61, $07, $b9, $85, $05, $48, $c8, $8f

	db $00, $75, $84, $04, $16, $a7, $23, $06, $38, $f9
	db $bc, $63, $e5, $37, $f8, $e9, $c3, $d9, $d3
	db $b0, $00, $82, $d4, $4e, $83, $1c, $09, $0e, $07
	db $07, $ad, $21, $41, $c0, $72, $be, $12, $40
	db $91, $55, $a7, $6e, $5e, $ab, $e9

	db $f8, $03, $9c, $44, $c0, $2b, $83, $ba
	db $5a, $68

.refused_text
	db TX_COMPRESSED, $62, $1a, $a3, $21, $6b, $b9, $80, $82, $d4, $46, $82
	db $78, $81, $96, $18, $43, $aa, $03, $95, $f0, $92
	db $96, $9a

.not_enough_tokens_text
	db TX_COMPRESSED, $07, $86, $e1, $90, $2d, $72, $9f, $c6, $42, $f9
	db $bc, $af, $59, $52, $9d, $db, $35
	db $fa, $9a

.pick_one_text
	db TX_COMPRESSED, $61, $2c, $f6, $ff, $08, $1a, $a0, $81, $b2
	db $a4, $f0, $48, $70, $38, $61, $03, $84, $b4
	db $9a, $ab, $d5, $7d, $3e
	db $34, $d0

JensLab_MapEventHeader ;filler
	db 0, 0

;warps
	db 2
	warp_def $b, $4, 3, GRAVEL_TOWN
	warp_def $b, $5, 3, GRAVEL_TOWN

	;xy triggers
	db 0

	;signposts
	db 0

	;people-events
	db 6
	person_event SPRITE_DAISY, 2, 4, SPRITEMOVEDATA_00, 0, 0, -1, -1, PAL_OW_PURPLE, 0, 0, JensLabJen, -1
	person_event SPRITE_POKE_BALL, 3, 8, SPRITEMOVEDATA_00, 0, 0, -1, -1, PAL_OW_RED, 0, 0, JensLabRedBall, EVENT_PROF_JEN_CHARMANDER
	person_event SPRITE_POKE_BALL, 3, 7, SPRITEMOVEDATA_00, 0, 0, -1, -1, PAL_OW_BLUE, 0, 0, JensLabBlueBall, EVENT_PROF_JEN_SQUIRTLE
	person_event SPRITE_POKE_BALL, 3, 6, SPRITEMOVEDATA_00, 0, 0, -1, -1, PAL_OW_GREEN, 0, 0, JensLabGreenBall, EVENT_PROF_JEN_BULBASAUR
	person_event SPRITE_SCIENTIST, 9, 8, SPRITEMOVEDATA_00, 0, 0, -1, -1, PAL_OW_RED, 0, 0, JensLabGoldTokenCollector1, -1
	person_event SPRITE_SCIENTIST, 9, 1, SPRITEMOVEDATA_00, 0, 0, -1, -1, PAL_OW_RED, 0, 0, JensLabGoldTokenCollector2, -1

