Plot 0
	name <>

	% A monk will offer the PC a job to go recover an object.
	% The PC can also get the same job from an NPC.

	% E1 is the HwangSa faction; E2 is a monk
	element1 <Grab 1>
	element2 <Character !Comrade 1>

	% E3 is the scene for this episode.
	Element3 <Grab 2>

	% E4 is a character who will give the recovery mission
	element4 <Character !Near 3>

	% E5 is the item to be recovered
	element5 <Prefab>

	% E6 is the scene for the next episode.
	Element6 <Scene Town !Far 2 !Far 3>

	% V1 = Initialization Counter; if V1=2 then the PC has the item
	% V2 = PC has accepted mission from monk
	% V3 = PC has entered the recovery mission.
	% V5 = Next plot has been activated

	% On a cleanup request, just delete this plot.
	cleanup <if= V3 0 else GoHasMission AdvancePlot 0>
	GoHasMission <AdvancePlot 1>

	start <ifKeyItem E5 else GoCheckBegin if= V1 1 else GoCheckBegin V= 1 2>
	GoCheckBegin <ifNPCOK E2 else GoDelete ifNPCOK E4 else GoDelete ifItemOK E5 else GoDelete if= V1 0  V= 1 1 ItemVar= E5 1 E6 Compose KEY E5 .key>
	GoDelete <if= P5 0 else GoRealDelete S= 201 0  N= 2 E6  AdvancePlot 0>
	GoRealDelete <AdvancePlot 0>
	.key <if= P5 0 S= 201 0  S+ 101 1  P= 5 1  N= 2 E6>

	% If the PC gets email about the mission, that counts as tacit
	% acceptance of the mission. Why? So if the PC completes the
	% mission without first going to see the monk, the monk won't
	% be surpised when the PC returns the item.
	5Min <if= d50 1 if= PCFac E1 if= V2 0 Email d5 V= 2 1>

	Msg1 <\ELEMENT 2 @ \SCENE EScene 2 :// There's an item in \ELEMENT 3 that we require. See what you can do.>
	Msg2 <\ELEMENT 2 @ \SCENE EScene 2 ://>
	Msg3 <\ELEMENT 2 @ \SCENE EScene 2 ://>
	Msg4 <\ELEMENT 2 @ \SCENE EScene 2 ://>
	Msg5 <\ELEMENT 2 @ \SCENE EScene 2 ://>

sub
	Persona 2
	% The monk who may give the mission.
	% He will ask the PC to go vist E3, who will then give the actual
	% job. Upon the PC's return, E2 will tell the PC where the next
	% leg of the relay will take place.

	rumor <>

	% V2 = Message Randomizer
	% V3 = Reward offered

	greeting <NewChat ifKeyItem E5 else GoNoKey if= P2 1 else GoHasKeyNoMission Say d3 CashPrize Reward Threat S2 100 250 Goto GoWinMission>
	GoHasKeyNoMission <V= 2 3 V+ 2 d3 V= 3 Reward Threat S2 100 150  Say V2 AddChat d2 V= 2 2 V+ 2 d2 AddChat V2>
	% If the PC was given the mission but hasn't yet returned with
	% the item, print a small reminder here.
	GoNoKey <ifG P2 0 else GoNoMission V= 2 5 V+ 2 d2 Say V2>

	% Check to see whether or not the PC will be offered a mission.
	GoNoMission <if# P2 -1 else GoNoChance if= PCFac E1 else GoNoMember V= 2 7 V+ 2 d3 Say V2 S+ 103 1 P= 2 1 Memo 20>
	GoNoMember <ifG PCRep 2 d50 else GoNoChance ifG React d30 else GoNoChance V= 2 14 V+ 2 d4 Say V2 V= 2 4 V+ 2 d2 AddChat V2 V= 2 6 V+ 2 d2 AddChat V2>
	GoNoChance <P= 2 -1 SayAnything>

	result1 <NewChat CashPrize V3 V= 2 10 V+ 2 d2 Say V2 Goto GoWinMission>
	result2 <Goto result1>
	result3 <NewChat V= 2 12 V+ 2 d2 Say V2  if= P5 1 AdvancePlot 0>
	result4 <Goto result3>
	result5 <NewChat V= 2 7 V+ 2 d3 Say V2 S+ 103 1 P= 2 1 Memo 20>
	result6 <Goto result5>
	result7 <NewChat Say 19 P= 2 -1>
	result8 <Goto result7>

	GoWinMission <DeleteKeyItem E5  FacXP+ E1 2  if# P5 1 else GoRealDelete  S= 201 0  S+ 101 1  N= 2 E6  S+ 202 1  AdvancePlot 0>
	GoRealDelete <AdvancePlot 0>

	%  01 - 03 : Was given mission, returned with item.
	Msg1 <You have recovered the \ELEMENT 5 ! The next part will be found in \ELEMENT 6 .>
	Msg2 <You have recovered the \ELEMENT 5 ! The next part will be found in \ELEMENT 6 .>
	Msg3 <You have recovered the \ELEMENT 5 ! The next part will be found in \ELEMENT 6 .>

	%  04 - 05 : Not given mission, returned with item anyhow.
	Msg4 <I heard that you have a \ELEMENT 5 . I'll give you $ \VAL V3 for it!>
	Msg5 <I heard that you have a \ELEMENT 5 . I'll give you $ \VAL V3 for it!>

	%  06 - 07 : Remind PC about the mission.
	Msg6 <Go to \ELEMENT 3 and get me a \ELEMENT 5 .>
	Msg7 <Go to \ELEMENT 3 and get me a \ELEMENT 5 .>

	%  08 - 10 : Description of mission.
	Msg8 <We have been searching for something. The trail of information leads to \ELEMENT 3 .>
	Msg9 <You'll find what we're looking for in \ELEMENT 3 .>
	Msg10 <There is something important in \ELEMENT 3 that we need to recover.>

	%  11 - 12 : PC sold the item to the monk.
	Msg11 <>
	Msg12 <>

	%  13 - 14 : PC doesn't want to sell.
	Msg13 <>
	Msg14 <>

	%  15 - 18 : Monk will ask PC if he wants to take mission.
	Msg15 <>
	Msg16 <>
	Msg17 <>
	Msg18 <>

	%  19      : PC doesn't want the mission.
	Msg19 <>

	%  20      : Memo
	Msg20 <\ELEMENT 2 in \SCENE EScene 2 asked you to go to \ELEMENT 3 and recover \ELEMENT 5 .>

	%  01 - 02 : PC will sell the item for $V3.
	Prompt1 <It's a deal!>
	Prompt2 <Alright, you can have it.>

	%  03 - 04 : PC won't sell the item.
	Prompt3 <No, I think I want to keep it.>
	Prompt4 <Sorry, that's not good enough.>

	%  05 - 06 : PC will take the mission from the monk.
	Prompt5 <>
	Prompt6 <>

	%  05 - 06 : PC doesn't want this mission.
	Prompt7 <>
	Prompt8 <>


	Persona 4
	% The NPC who may give the mission.
	rumor <>

	% V1 = Mission Indicator; 1=Mission Given
	% V2 = Message Randomizer
	% V3 = Attempt to get mission recharge counter

	% If the PC has found the item, do whatever here.
	greeting <NewChat if= P1 2 else GoCheckMission V= 2 27 V+ 2 d3 Say V2 AddChat 11 ifKeyItem E5 AddCHat 12 if= P2 1 AddChat 13>

	% If the PC has not yet found the item, allow the mission here.
	GoCheckMission <ifG V1 0 else GoNoMission V= 2 7 V+ 2 d3 Say V2 Goto GoAddComOps>
	GoNoMission <ifG ComTime V3 else GoNoRecharge Say d5 AddChat d2 V= 2 2 V+ 2 d2 AddChat V2 if= P2 0 V= 2 4 V+ 2 d2 AddChat V2>
	GoNoRecharge <V= 2 5 V+ 2 d2 Say V2>

	GoAddComOps <V= 2 6 V+ 2 d2 AddChat V2 V= 2 8 V+ 2 d2 AddChat V2>

	result1 <NewChat ifG React d40 else GoR1Fail V= 1 1 Memo 23  V= 2 12 V+ 2 d3 Say V2 Goto GoAddComOps>
	GoR1Fail <V= 3 ComTime V+ 3 3600 V+ 3 d3600 V= 2 15 V+ 2 d2 Say V2>
	result2 <Goto result1>

	result3 <NewChat ifG Conversation 12 else GoR3Fail V= 1 1 Memo 23  V= 2 12 V+ 2 d3 Say V2 Goto GoAddComOps>
	GoR3Fail <V= 3 ComTime V+ 3 3600 V+ 3 d3600 V= 2 15 V+ 2 d2 Say V2>
	result4 <Goto result3>

	result5 <NewChat V= 2 10 V+ 2 d2 Say V2 if# P5 1 S= 201 0  N= 2 E6  AdvancePlot 0>
	result6 <Goto result5>

	result7 <EndChat V= 2 17 V+ 2 d3 Say V2 Goto GoStartCombat>
	GoStartCombat <P= 3 1 SavePos LoadD .scene SeekGate -1 PassVar 1 E5 PassVar 2 S2 PassVar 3 5 PassVar 4 3>
	.scene <SCENE_ItemDungeon.txt>
	result8 <Goto result7>

	result9 <NewChat V= 2 20 V+ 2 d2 Say V2>
	result10 <goto result9>

	% PC will not give item to NPC.
	result11 <NewChat V= 2 25 V+ 2 d2 Say V2>

	% PC gives item to NPC.
	result12 <NewChat V= 2 23 V+ 2 d2 Say V2 DeleteKeyItem E5 if# P5 1 else GoRealDelete S= 201 0  N= 2 E6  AdvancePlot 0>
	GoRealDelete <AdvancePlot 0>

	% PC will bring item to Hwang-Sa.
	result13 <NewChat V= 2 30 V+ 2 d3 Say V2>

	%  01 - 05 : NPC describes the situation; PC may be able to get mission
	Msg1 <>
	Msg2 <>
	Msg3 <>
	Msg4 <>
	Msg5 <>

	%  06 - 07 : Come back later...
	Msg6 <Come back later. I've got work to do.>
	Msg7 <Look, I don't have the time to speak with you now. Come back in maybe an hour or so.>

	%  08 - 10 : Ready to start the mission?
	Msg8 <Are you ready to go recover the artifact yet?>
	Msg9 <>
	Msg10 <>

	%  11 - 12 : PC not interested in the mission.
	Msg11 <I'll have to find someone to help me with this.>
	Msg12 <Too bad I don't know anyone who can help me...>

	%  13 - 15 : First time offered the mission.
	Msg13 <>
	Msg14 <>
	Msg15 <>

	%  16 - 17 : Attempt to get job has failed.
	Msg16 <>
	Msg17 <>

	%  18 - 20 : Entering combat.
	Msg18 <>
	Msg19 <>
	Msg20 <>

	%  21 - 22 : Need time to prepare.
	Msg21 <Hurry back when you're ready and we can start.>
	Msg22 <You'll need to be in top condition for this job. Return here after you're finished getting ready.>

	%  23 : Memo
	Msg23 <\ELEMENT 4 in \ELEMENT 3 asked you to recover an item.>

	%  24 - 25 : PC gives item to NPC.
	Msg24 <>
	Msg25 <>

	%  26 - 27 : PC doesn't give item to NPC.
	Msg26 <>
	Msg27 <>

	%  28 - 30 : PC returns with the item.
	Msg28 <>
	Msg29 <>
	Msg30 <>

	%  31 - 33 : PC will bring item to Hwang-Sa.
	Msg31 <>
	Msg32 <>
	Msg33 <>

	%  01 - 02 : PC tries to get job using Plan "A"
	%     DEFAULT: Use REACT score.
	Prompt1 <>
	Prompt2 <>

	%  03 - 04 : PC tries to get job using Plan "B"
	%     DEFAULT: Use CONVERSATION skill.
	Prompt3 <>
	Prompt4 <>

	%  05 - 06 : PC doesn't want this job
	Prompt5 <>
	Prompt6 <>

	%  07 - 08 : Start the mission now.
	Prompt7 <>
	Prompt8 <>

	%  08 - 10 : Wait for the PC to get ready.
	Prompt9 <>
	Prompt10 <>

	%  11      : PC will not give the item to the NPC.
	Prompt11 <>

	%  12      : PC gives the item to the NPC.
	Prompt12 <Here it is. [Give Item]>

	%  13      : PC must return item to HwangSa.
	Prompt13 <I must take this item to Hwang-Sa Temple.>

	Plot 1
		% Just explain to the PC that he's out of time.

		start <if= V1 0 else GoCheckTime V= 1 ComTime V+ 1 86400 ifItemOK E5 DeleteKeyItem E5>
		GoCheckTime <ifG ComTime V1 AdvancePlot 0>
	sub
		Persona 2
		greeting <NewChat Say 1 AdvancePlot 0>
		Msg1 <>

		Persona 4
		greeting <NewChat Say 1 AdvancePlot 0>
		Msg1 <>

	end

end
inv
	treasure 1000
	name <MacGuffin>
	% V1 = Location of next scene
	% V2 = Investigation indicator
	%   instead of investigation you can use Science(29), Mysticism(34),
	%    CodeBreaking(32) or Survival(14)
	use <if= V2 1 else GoNoSolve Print 1>
	GoNoSolve <V= 2 -1 Print 2>
	Clue37 <if= V2 0 else GoDid Mental ifG SkRoll 37 10 else GoNoSolve V= 2 1 Print 1 XPV 100 Trigger KEY SelfNID>
	GoDid <if= V2 1 else GoNoSolve Print 1>
	Msg1 <You have determined that the next part will be found in \SCENE V1 .>
	Msg2 <You haven't determined anything from this artifact.>

end
