"../deathforth/rooms/tutorial.txt" $load-rooms
"../deathforth/rooms/city.txt" $add-rooms

cyoa{

cyoa-choice: tutorchat-1
	pchar choosechar
	($ pname .. "笑嘻嘻的和" .. bname .. "说" .. "你先别急! " pbold $) text!
	($ bname .. "被这激怒了! " .. bHe .. "变得" .. "红温到冒烟! " rbold $) +crtext
	($ "我不确定和别人说" .. "“你先别急”" pbold .. "在整个人类历史上, 是否真的让其他人成功的别急过. " $) +crtext
	1 cchar .wits! 1 cchar .attitude!
	witsattREV badfx clear-cyoa morale2-all
;

cyoa-choice: tutorchat-2
	pchar choosechar
	($ pname .. "试着施展个人魅力来让" .. bname .. "帮助对抗蜂拥而至的僵尸.
	" .. bname .. "的头上冒汗了. " $) text!
	($ "我很忙! 我正忙着装东西呢! 你也赶紧去装东西吧! " pbold $) +crtext
	"好吧, 值得一试. 这可能对一个不那么混蛋的人有效. " +crtext
	6 cchar .wits! 6 cchar .attitude!
	witsattREV badfx clear-cyoa
;

cyoa-choice: tutorchat-3
	pchar choosechar
	($ pname .. "称" .. bname .. "就是个" .. "沙雕. " pbold $) text!
	($ bname .. " 感到十分震惊! 它终于可以说出实情 " .. bhim .. " 实际上是由沙子构成的元素生物 " .. bhe .. " 并不是人." $) +crtext
	goodfx clear-cyoa morale++all
;

cyoa: tutorchat
	rescue choosechar cicon
	cchar to bully
	dead? if npc-died then;
	($ pname .. "看见了" .. cname .. ", 他是一个真正的沙雕.
	" .. "僵尸闯进了我家! 这肯定都是因为你! 因为你才害得我这样! " pbold .. "
	当小队发现这个僵尸安全屋时, " .. bname .. "已经占领这个大卧室一段时间了. " $) text!

	choice( "暂时离" .. chim .. "远一些" )choice
	choice( "和" .. chim .. "说　你先别急" )choice: tutorchat-1
	choice( "说服" .. chim .. "一起对抗僵尸" )choice: tutorchat-2
	choice( "称" .. chim .. "为: 你这沙雕" )choice: tutorchat-3
;

cyoa: tutorrecruit
	recruitee choosechar cicon
	dead? if npc-died then;
	($ pname .. "跟" .. rname .. "打了个招呼.
	" .. "我想我们该离开这个安全屋了, 至少我们休息够了.
	我们应该试着去加拿大! 你想让我和你一起旅行吗? " pbold .. "
	多一个人, 多一份力. 但这也意味着需要更多的食物, 还要处理好队员间的摩擦与意见不合. " $) text!
	0.25 cchar .ai.wander_chance! 0 nearest .unseen! clear-cyoa
	recruit-yesno

;

}

: tutorial-npc1
	new-npc@ 0 over .ai.wander_chance! 180 lt .aim_angle! lt .character@ to rescue
	cyoa{ ' tutorchat cyoa! } drop
;

: tutorial-npc2
	// new-rescue-npc 0 lt .character@ .ai.wander_chance!
	new-npc@ rescue-weapon over .weapona! 1 lt .unseen! 0 over .ai.wander_chance! 180 lt .aim_angle! lt .character@ to recruitee
	cyoa{ ' tutorrecruit cyoa! } drop
;

mission{

: door-tutorial-escape
	cyoa-start
	beep "door-no-escape" print
	"此路不通! " cyoa-title!
	($ "你不能从这边离开这个地方!
	这扇门正好通向一个" .. "垃圾房" rbold .. ", 而那里已经被垃圾堆满了. 无论是谁设计了这个防僵尸掩体, 都没有考虑到里面的人要怎么出去.
	你必须找到另一条出路. " $) cyoa-text!
	"或者, 如果你愿意, 可以跳过教程. " rbold +text
		choice( "返回教程" )choice
		cyoa-add-choice
		"跳过教程! " cyoa-choice-text!
			cyoa{ ' tutorial-ladder-end cyoa-choice-handler! }
;

: tutortopmsg
	eventid THING_EVENT_TIMER <> if drop then;
	( beep ) // Good for debugging timers
	me .retrigger_timer
	curmapview me .mapid@ <> if then;
	WHITE swap $cat 60 view_w 0.5 * 16 msgtickxy
;

: best_btn_name args( cmd ) <- cmd p1_cmd_joy_alt <- cmd p1_btn_name ;


: attackbtn CMD_ATTACK best_btn_name ;
: swapbtn CMD_SWAP best_btn_name ;
: usebtn CMD_USE best_btn_name ;
: startbtn CMD_START best_btn_name ;

: upbtn CMD_UP best_btn_name ;
: downbtn CMD_DOWN best_btn_name ;
: leftbtn CMD_LEFT best_btn_name ;
: rightbtn CMD_RIGHT best_btn_name ;

: usebtns usebtn
	// .. usebtn $len 1 usebtn $len and if "OR " else "" then .. 1 usebtn
;
: attackbtns attackbtn
	// .. attackbtn $len 1 attackbtn $len and if "OR " else "" then .. 1 attackbtn
;
: swapbtns swapbtn
	// .. swapbtn $len 1 swapbtn $len and if "OR " else "" then .. 1 swapbtn
;
: startbtns startbtn
	// .. startbtn $len 1 startbtn $len and if "OR " else "" then .. 1 startbtn
;

: arrowbtns
	upbtn ", " .. downbtn .. ", " .. leftbtn .. ", " .. rightbtn ..
;

: tutorial_touch_check touch_controls@ 0 > ;

thing-event: tutormsg1
	tutorial_touch_check if
		($ "拖动左摇杆来移动
		点击你设置的　互动　按钮来互动或使用" $)
		// ADJUST CONTROLS IN TOP LEFT OF PAUSE MENU - Removed from second line for now
		// Could we have the USE button glow here or something? That way could get rid of the third line maybe...
	else
		($ arrowbtns .. "移动
		" .. usebtns .. "互动或使用" $)
	then tutortopmsg ;
thing-event: tutormsg2
	tutorial_touch_check if
		($ "点击你设置的　互动　按钮来拿起武器
		点击你设置的　切换　按钮切换武器
		按住你设置的　互动　放下武器" $)
	else
		($ usebtns .. "拿起武器
		" .. swapbtns .. "切换武器
		长按" .. usebtn .. "放下武器" $)
	then tutortopmsg ;
thing-event: tutormsg3
	tutorial_touch_check if
		($ "点击你设置的　互动　按钮举起/下砸椅子
		点击你设置的　攻击　按钮扔出椅子
		点击你设置的　切换　按钮放下椅子" $)
	else
		($ usebtns .. "举起/下砸椅子
		" .. attackbtns .. "扔出椅子
		" .. swapbtns .. "放下椅子" $)
	then tutortopmsg ;
thing-event: tutormsg4
	tutorial_touch_check if
		($ "点击你设置的　攻击　按钮进行攻击
		你可以打断敌人的攻击" $)
	else
		($ attackbtns .. "攻击
		你可以打断敌人的攻击" $)
	then tutortopmsg ;

thing-event: tutormsg5
	"小心数量庞大的僵尸群
	逃跑往往胜过战斗" tutortopmsg ;
thing-event: tutormsg6
	"梯子通向外面
	祝你好运" tutortopmsg ;

thing-event: tutormsg7
	tutorial_touch_check if
		($ "点击你设置的　互动　按钮进行对话或互动" $)
	else
		($ usebtns .. "对话或互动" $)
	then tutortopmsg ;

thing-event: tutormsg8
	"明智地选择你的伙伴" tutortopmsg ;
thing-event: tutormsg9
	"卫生间很可能储备有药品" tutortopmsg ;
thing-event: tutormsg10
	"能拿走的都拿走吧" tutortopmsg ;

	thing-event: tutormsg11
	tutorial_touch_check if
		($ "暂停来查看信息, 或交换小队内附近人员的武器
		你可以随时更换队长" $)
	else
		($ startbtns .. "用于查看信息, 或交换小队内附近人员的武器
		你可以随时更换队长" $)
	then tutortopmsg ;
}

map{ roomgen{

: tutorialbars
	spawn special_objects64_base_id 0x 9 + lt .spriteid!
	bbox immovable as-metal
;

: tutormsg lt .events! 1 sec>tick lt .repeating_timer invisible ;

: tutor1msg spawn mission{ ' tutormsg1 } tutormsg ;
: tutor2msg spawn mission{ ' tutormsg2 } tutormsg ;
: tutor3msg spawn mission{ ' tutormsg3 } tutormsg ;
: tutor4msg spawn mission{ ' tutormsg4 } tutormsg ;
: tutor5msg spawn mission{ ' tutormsg5 } tutormsg ;
: tutor6msg spawn mission{ ' tutormsg6 } tutormsg ;

: tutorbedmsg spawn mission{ ' tutormsg7 } tutormsg ;
: tutorkitchmsg spawn mission{ ' tutormsg8 } tutormsg ;
: tutorbathmsg spawn mission{ ' tutormsg9 } tutormsg ;
: tutorstormsg spawn mission{ ' tutormsg10 } tutormsg ;

: tutor11msg spawn mission{ ' tutormsg11 } tutormsg ;

} }

locdef{

location: tutorial
		max-rooms: 11
		entry-tags: tutor1
		script: set-theme-house
		pre-script: set-theme-house
		post-script: nad

		: tutor1script
			e random-edge-door "tutor2" only-with-door
			tutor1msg
		;

		: tutor2script
			e random-edge-door "tutor3" only-with-door
			s random-edge-door "tutorbath" only-with-door
			n random-edge-door "bedroom" only-with-door
			tutor2msg
			baseball .scatter wrench .scatter
		;

		: tutor3script
			e random-edge-door "tutor4" only-with-door
			n random-edge-door "kitchen" only-with-door
			tutor3msg
		;

		: tutor4script
			e random-edge-door "tutor5" only-with-door
			s random-edge-door "tutorstorage" only-with-door
			tutor4msg
		;

		: tutor5script
			e random-edge-door "tutor6" only-with-door
			tutor5msg
		;

		: tutor6script
			e random-edge-door "tutorend" only-with-door
			tutor11msg
		;

		room-choice: tutor1
			room-weight: 300
			room-count: 1
			room-script:
			room-post-script: tutor1script
			filter-only

		room-choice: tutor2
			room-weight: 300
			room-count: 1
			room-post-script: tutor2script
			filter-only

		room-choice: tutor3
			room-weight: 300
			room-count: 1
			room-post-script: tutor3script
			filter-only

		room-choice: tutor4
			room-weight: 300
			room-count: 1
			room-script: gcloset-theme
			room-post-script: tutor4script
			filter-only

		room-choice: tutorstorage
			room-weight: 300
			room-count: 1
			room-script: gcloset-theme
			room-post-script: tutorstormsg
			filter-only

		room-choice: tutor5
			room-weight: 300
			room-count: 1
			room-script: gcloset-theme
			room-post-script: tutor5script
			filter-only

		room-choice: tutor6
			room-weight: 300
			room-count: 1
			room-script: gcloset-theme
			room-post-script: tutor6script
			filter-only

		room-choice: tutorend
			room-weight: 300
			room-count: 1
			room-script: gcloset-theme
			// gcloset-theme gbath-theme
			room-post-script: tutor6msg
			filter-only

		room-choice: tutorbath
			room-weight: 1
			room-count: 1
			room-script: floor-bath
			room-post-script: tutorbathmsg

		room-choice: bedroom
			room-weight: 10
			room-count: 1
			room-post-script: tutorbedmsg tutorial-npc1

		room-choice: kitchen
			room-weight: 10
			room-count: 1
			room-script: floor-kitchen
			room-post-script: tutorial-npc2 tutorkitchmsg
}

regiondef{

	: tutorial-setup
		mission{ ' door-tutorial-escape to main-event-mission-location-leave }
		easy-music-fade 0 region.zombie_basespawn!
	;

	region: tutorial
		script: timeofday o'clock

		inside

		loc-choice: tutorial
			loc-weight: 99
			loc-count: 1

		post-script: tutorial-setup
}
