%%
%% UTILITY SUBPLOTS
%%
%%  This unit holds utility subplots. These are usually very short subplots which are used for
%%  handling common situations- running out of time on a mission, earning a cash reward, and
%%  so on.
%%

%%
%% *UTIL_GiveEquipment
%%
%%  As a reward for something or another, the PC is being given some
%%  upgraded hardware. This will probably be something that can't
%%  be gotten in any other way.
%%
%%  Persona 1 must include a .%id%_GoGiveEquipment script.
%%
%%  This subplot doesn't affect the PlotStatus at all, and in fact
%%  doesn't need its PlotID activated. It's not much more than a
%%  glorified PFrag for handing out an item.
%%
%% Param1: The item-giver
%%

Content
	name <New Mecha>
	requires <*UTIL_GiveEquipment>

	% E1 is the item-giver

	sub
		Persona 1
		% V%id%01 = Threat Counter
		.%id%_GoGiveEquipment <NewChat Say %id%01 V= %id%01 %threat% V+ %id%01 d10  RandomMecha .%id%_Factions V%id%01>
		% Msg%id%01 <You can never own too many mecha. Here, you can have this one. May it never be shot out from under you.>
		Msg%id%01 <メックは何台持ってても困らないもの%JG_DAYO。ほら、この１台も受け取っていくといい%JV_F_WA。コイツが%JS2に壊されてしまわないことを願っている%JG_YO。>
		.%id%_Factions <GENERAL \FACTION_DESIG RootSceneFac \FACTION_DESIG ChatNPCFac>
	end

Content
	name <Mecha Gun 1: Grenade Launcher>
	requires <*UTIL_GiveEquipment !Ne ~1:CRAFT>

	% E1 is the item-giver
	% E2 is the item
	Element2 <Prefab>

	sub
		Persona 1
		.%id%_GoGiveEquipment <NewChat Say %id%01 GiveItem %2%>
		% Msg%id%01 <This mecha grenade launcher should come in handy. It's just the thing for taking out swarms of quick enemies.>
		Msg%id%01 <このメック用グレネード・ランチャー、きっと役に立つ%JV_DAROU。素早い敵の群れを片付けるのにぴったりの一品%JG_DAYO。>
	end
	inv
		Gun 9
		name <Grenade Launcher>
		name_I18N <グレネード・ランチャー>
		caliber <50mm explosive cannister>
		range 6
		scale 2
		Magazine 30
		sub
			Ammo 9
			caliber <50mm explosive cannister>
			type <BLAST 3 BRUTAL>
		end
	end

Content
	name <Mecha Gun 2: Mech Assault Rifle>
	requires <*UTIL_GiveEquipment !Lo ~1:CRAFT>

	% E1 is the item-giver
	% E2 is the item
	Element2 <Prefab>

	sub
		Persona 1
		.%id%_GoGiveEquipment <NewChat Say %id%01 GiveItem %2%>
		% Msg%id%01 <Here's a mecha assault rifle. It's a versatile weapon that can be used in either fully auto or semiautomatic mode.>
		Msg%id%01 <これはメック用アサルト・ライフル。フルオートとセミオートのモードを備えた汎用火器%JG_DAYO。>
	end
	inv
		Gun 8
		Scale 2
		name <Mech Assault Rifle>
		name_I18N <メック・アサルトライフル>
		caliber <30mm caseless>
		Range 6
		Magazine 60
		BV 2
		Speed 3
		Acc 1
		mass -5
		sub
			Ammo 8
			caliber <30mm caseless>
			mass -6
		end
	end

%%
%% *UTIL_BlankState
%%
%%  For when you need a PlotState, but don't need anything to happen.
%%

Content
	name <Blank State>
	requires <*UTIL_BlankState>

%%
%% *UTIL_ReferredMission
%%
%%  The PC has been sent to this person, who will now give a basic mecha
%%  mission.
%%
%%  The master plot must have a PayRate set.
%%
%%  PARAM1: The Referrer
%%  PARAM2: The mission-giver
%%

Content
	name <Basic Referred Mission>
	% The basic patrol job is a fight against some generic enemy mecha.
	% This job gives salvage. This job will not result in the PC making
	% any enemies.
	requires <*UTIL_ReferredMission>

	% E1 is the referrer
	% E2 is the mission-giver
	% E3 is a scene where the encounter will take place
	Element3 <Scene Outdoors>

	% SubPlot1 is the combat encounter
	SubPlot1 <*MECHAMISSION_Basic 2 3>

	% P%id%01 = Time Limit
	start <ifNPCOK %2% else .%id%_GoDelete if# P%id%01 0 ifG ComTime P%id%01 EndPlot>
	.%id%_GoDelete <EndPlot>
	update <if= P%id%01 0 P= %id%01 ComTime P+ %id%01 86400>

	% SubPlot1 is the mission
	SubPlot1 <*MECHAMISSION_Basic 2 3>

	sub
		Persona 2
		greeting <if# PlotStatus %plotid% %id% else .%id%_GoGreet if# PlotStatus %plotid% %id1% else .%id%_GoRemind  Goto %pop%>
		*.%id%_GoRemind <*MechaMissionReminder %3%>
		*.%id%_GoGreet <*ReferredForJob %1% .%id%_GoBriefing>
		*.%id%_GoBriefing <*BasicMissionBriefing %3% .%id%_GoAcceptMission .%id%_GoRejectMission %threat%>
		*.%id%_GoAcceptMission <*GoodLuckOnMission&NoEnemyFac .%id%_GoAccept ChatNPCFac na>
		.%id%_GoAccept <PMemo %plotid% %id%01 SetPlotStatus %plotid% %id1%>
		*.%id%_GoRejectMission <*RejectMission .%id%_GoEnd>
		.%id%_GoEnd <EndPlot>
		% Msg%id%01 <%name2% in \SCENE NPCScene %2% hired you to fight some mecha in \EXACT_SCENE %3% .>
		Msg%id%01 <\SCENE NPCScene %2% の %name2% に雇われて、\EXACT_SCENE %3% でメック部隊と戦うことになった。>
	end


%%
%% *UTIL_WinMission
%%
%%  The player has won this mission, and will be paid by the NPC according to the agreed upon
%%  pay rate. There may be an additional bonus, depending on the situation.
%%
%% The master plot must have a PayRate set.
%%
%%  PARAM1: The mission-giving NPC

Content
	name <Friend/Lover Win Mission>
	requires <*UTIL_WinMission (1:FRIEND|1:LOVER)>

	% E1 is the mission-giving NPC.

	start <ifNPCDead %1% EndPlot>

	sub
		Persona 1
		greeting <if= PlotStatus %plotid% %id% else %pop%  NewChat Say %id%01 CashPrize Reward %threat% PayRate    { FacXP+ ChatNPCFac 1 }    RandomMecha .%id%_meks %threat%   EndPlot>
		.%id%_meks <GENERAL \FACTION_DESIG RootSceneID \FACTION_DESIG ChatNPCFac>
		% Msg%id%01 <Here's your reward for that last mission, \PC . I decided to throw in a little something extra as well.>
		% Msg%id%01_1 <Your mission was a complete success. You're impressing a lot of people with your performance, \PC . In addition to the mission pay you've also been awarded this special gift.>
		% CMsg%id%01_1 <ifNPCSociable Accept>
		% Msg%id%01_2 <Good work, \PC . You've been awarded this new mecha.>
		% CMsg%id%01_2 <ifNPCShy Accept>
		% Msg%id%01_3 <Hey \PC . I hope the mission wasn't too hard... Anyhow, because of your success, I've been asked to give you this new mecha in addition to your regular pay.>
		% CMsg%id%01_3 <ifNPCEasygoing Accept>
		% Msg%id%01_4 <You did it! Wow, you really are a powerful fighter... In recognition of your success, I'm pleased to give you this brand new mecha in addition to your pay. Pilot it well!>
		% CMsg%id%01_4 <ifNPCPassionate Accept>
		% Msg%id%01_5 <Good job, \PC ! You'll be pleased to know that the higher-ups are just as impressed with you as I am. In addition to the regular mission pay, they've authorized me to give you this brand new mecha.>
		% CMsg%id%01_5 <ifNPCCheerful Accept>
		% Msg%id%01_6 <I'm glad to see that you made it back in one piece. Here, this new mecha is for you. You're probably going to need a backup one of these days.>
		% CMsg%id%01_6 <ifNPCMelancholy Accept>
		Msg%id%01 <これがあのミッションの報酬%JV_M_DA%JV_YO、\PC。少しオマケも付けることにしたから%JV_NA%JV_SIL_R。>
		Msg%id%01_1 <ミッションは大成功だった%JG_YO。みんな%JS2の腕に感銘を受けている%JV_ZO%JV_F_YO、\PC。%JS2には、通常の報酬に加えて特別な品も贈られることになった%JV_N%JV_M_DA。>
		CMsg%id%01_1 <ifNPCSociable Accept>
		Msg%id%01_2 <よくやった%JV_F_NE、\PC。%JS2にはメックが贈られることになった%JG_YO。>
		CMsg%id%01_2 <ifNPCShy Accept>
		Msg%id%01_3 <ああ \PC。ミッションはキツくなかった%JV_Q？ ともかく、%JS2の成功に応えて、報酬にこのメックを上乗せすることになった%JG_SK。>
		CMsg%id%01_3 <ifNPCEasygoing Accept>
		Msg%id%01_4 <やった%JG_NE！ %JR_YES、%JS2は本当に強いパイロット%JG_DA%JV_SIL_R成功を祝して、報酬にこの新品のメックを加えることになった%JV_ZO。十分に使ってやって%JG_R。>
		CMsg%id%01_4 <ifNPCPassionate Accept>
		Msg%id%01_5 <\PC、いい仕事だった%JG_YO！ 上の人たちも%JF2と同じくらい感心したみたい%JG_DANE%JV_SIL_R通常の報酬に加えて、この新品のメックを与えるように通達されてる%JG_NDA。>
		CMsg%id%01_5 <ifNPCCheerful Accept>
		Msg%id%01_6 <無事に戻ってきたみたいで何より%JG_DA。ほら、このメックは%JS2への報酬%JG_DAYO。予備の一台もきっと必要なご時世だから%JV_NA。>
		CMsg%id%01_6 <ifNPCMelancholy Accept>
	end

Content
	name <Basic Win Mission>
	requires <*UTIL_WinMission Common>

	% E1 is the mission-giving NPC.

	start <ifNPCDead %1% EndPlot>

	sub
		Persona 1
		greeting <if= PlotStatus %plotid% %id% else %pop%  Goto .%id%_GoWinMission>
		*.%id%_GoWinMission <*MissionWasSuccess&Reward .%id%_GoEnd ChatNPCFac na>
		.%id%_GoEnd <CashPrize Reward %threat% PayRate    { FacXP+ ChatNPCFac 1 }    AddReact d6   EndPlot>
	end

Content
	name <Mecha Win Mission>
	requires <*UTIL_WinMission &Mecha Common>

	% E1 is the mission-giving NPC.

	start <ifNPCDead %1% EndPlot>

	sub
		Persona 1
		greeting <if= PlotStatus %plotid% %id% else %pop%  Goto .%id%_GoWinMission>
		*.%id%_GoWinMission <*MissionWasSuccess&Reward&Mecha .%id%_GoEnd ChatNPCFac na>
		.%id%_GoEnd <CashPrize Reward %threat% PayRate    { FacXP+ ChatNPCFac 1 }   AddReact d6   EndPlot>
	end

%%
%% *UTIL_LoseMission
%%
%%  The player has lost this mission.
%%
%%  PARAM1: The mission-giving NPC

Content
	name <Basic Lose Mission>
	requires <*UTIL_LoseMission>

	% E1 is the mission-giving NPC.

	% P%id%01 = Time Limit
	start <ifNPCOK %1% else .%id%_GoEnd ifG ComTime P%id%01 EndPlot>
	.%id%_GoEnd <EndPlot>
	update <if= p%id%01 0 P= %id%01 ComTime P+ %id%01 43200>

	sub
		Persona 1
		greeting <if= PlotStatus %plotid% %id% else %pop%  Goto .%id%_GoLostMission>
		*.%id%_GoLostMission <*MissionWasFailure .%id%_GoEnd ChatNPCFac na>
		.%id%_GoEnd <AddReact -d6   EndPlot>
	end

Content
	name <Basic Lose Mission>
	requires <*UTIL_LoseMission &Mecha>

	% E1 is the mission-giving NPC.

	% P%id%01 = Time Limit
	start <ifNPCOK %1% else .%id%_GoEnd ifG ComTime P%id%01 EndPlot>
	.%id%_GoEnd <EndPlot>
	update <if= p%id%01 0 P= %id%01 ComTime P+ %id%01 43200>

	sub
		Persona 1
		greeting <if= PlotStatus %plotid% %id% else %pop%  Goto .%id%_GoLostMission>
		*.%id%_GoLostMission <*MissionWasFailure&Mecha .%id%_GoEnd ChatNPCFac na>
		.%id%_GoEnd <AddReact -d6   EndPlot>
	end

%%
%% *UTIL_TimeOver
%%
%%  The player was given a mission, but didn't complete it in time.
%%
%%  PARAM1: The mission-giving NPC

Content
	name <Basic Time Over>
	requires <*UTIL_TimeOver>

	% E1 is the mission-giving NPC.

	% P%id%01 = Time Limit
	start <if= PlotStatus %plotid% %id% else %pop% ifNPCOK %1% else .%id%_GoEnd ifG ComTime P%id%01 EndPlot>
	.%id%_GoEnd <EndPlot>
	update <if= PlotStatus %plotid% %id% else %pop% if= p%id%01 0 P= %id%01 ComTime P+ %id%01 21600 SetNPC %1% EMail %id%01>

	% Msg%id%01_1 <%name1% @ \SCENE NPCScene %1% :// Your mission has been cancelled.>
	% Msg%id%01_2 <%name1% @ \SCENE NPCScene %1% :// Your mission has been aborted.>
	Msg%id%01_1 <%name1% @ \SCENE NPCScene %1% :// %JS2の任務はキャンセルになった%JV_ZO。>
	Msg%id%01_2 <%name1% @ \SCENE NPCScene %1% :// %JS2の任務は中止された%JV_F_WA。>

	sub
		Persona 1
		greeting <if= PlotStatus %plotid% %id% else %pop%  NewChat Say %id%01 AddReact -d3 EndPlot>
		% Msg%id%01 <I'm afraid that you took too long on that mission. It's over now.>
		Msg%id%01 <残念だ%JG_GA、時間をかけすぎた%JG_NE。%JS2に任せていたあの任務は終わってしまった%JG_YO。>
	end

