%%
%% *CS_END_Intro
%%
%%  This is the beginning of the end. The intro serves as the introduction to the
%%  conclusion, and also the first big fight scene. Following the battle it invokes
%%  the following subplots:
%%    *CS_END_Buildup
%%    *:CS_END_Partner_Arc
%%    *:CS_END_LoveInterest_Arc
%%
%%  Note that this subplot passes the Enemy NPC on to the final battle, so if redemption
%%  is going to happen it's going to happen right here. If the PC entered the conclusion
%%  without an enemy NPC, a new enemy must be created for the final battle and introduced
%%  right here.
%%
%%  PARAM1: The conclusion mood
%%

Content
	name <Meet the New Boss>
	% desc <The invader will announce their intentions.>
	desc <侵略者がその意図を明らかにする。>
	requires <*CS_END_Intro E:-->

	% E1 is the mood
	% E2 is the new enemy NPC
	Element2 <NewNPC -2 -7>
	Place2 </>

	% P%id%01 = Initialization Counter
	start <if= P%id%01 0 if= RootSceneID &EpisodeScene ifScene .%id%_scenetype Alert %id%01 Monologue %2% %id%02  History %id%03 P= %id%01 1 SetPlotStatus %plotid1% %id1%>
	.%id%_scenetype <building public>

	% Msg%id%01 <As you enter the building, you see that all public monitors are tuned into the same news broadcast.>
	% Msg%id%02 <This colony is now under our control... Any resistance will be swiftly crushed... Soon you will see the full extent of our power.>
	% Msg%id%03 <%name2% took control of \SCENE &EpisodeScene .>
	Msg%id%01 <建物に入ると、すべての公共モニタが同一の放送を流しているのが目に入った。>
	Msg%id%02 <このコロニーは今や%JF2%JF_TACHIの支配下にある……いかなる抵抗も速やかに粉砕される%JV_F_WA……%JS_AGGたちはすぐに%JF2%JF_TACHIの本気を目にすることになる%JV_DAROU。>
	Msg%id%03 <%name2% が \SCENE &EpisodeScene を占拠した。>

	% SubPlot1 is the final battle buildup
	%     This serves the purpose of a RevealEncounter task for the last fight
	SubPlot1 <*CS_END_Buildup 1 2>


Content
	name <Raid the Command Bunker>
	% desc <The PC will raid the enemy's command bunker, only to find the enemy missing.>
	desc <PC は敵司令施設を襲撃したが、倒すべき敵は不在だった。>
	requires <*CS_END_Intro E:++>

	% E1 is the mood
	% E2 is the enemy NPC
	% E3 is an outdoors scene for the base
	% E4 is the base itself
	Element2 <Grab 1>
	Element3 <Scene Outdoors !Near -7>
	Element4 <Prefab>
	Place4 <3>

	% P%id%01 = Initialization Counter
	% P%id%02 = Peaceful Entry Counter

	% At startup, activate the RevealEncounter task.
	update <if= p%id%01 0 p= %id%01 1 SetPlotStatus %plotid2% %id2% SetPlotStatus %plotid3% %id3%>

	.%id3%_%plotid3%_GoPeacefulEntry <P= %id%02 1>

	% SubPlot1 is the final battle buildup
	%     This serves the purpose of a RevealEncounter task for the last fight
	% SubPlot2 is the RevealEncounter for the Enemy's base
	% SubPlot3 is the peaceful entry for the Enemy's base
	SubPlot1 <*CS_END_Buildup 1 2>
	SubPlot2 <*:CS_RevealEncounter_NPCBase&EnemyNPC 3 4 2>
	SubPlot3 <*:CS_PeacefulEntry_NPCBase 4 2>

	sub
		MetaScene 4
		% rumor%id% <%name2% is preparing to launch a big operation.>
		rumor%id% <%name2% が大規模な作戦の準備を進めている>
		special <NOEXIT>
		mapwidth 35
		mapheight 35
		MonkeyMap
		LockedDoorChance 10
		SecretDoorChance 5
		NeededCells 2

		% L1 = Have completed task
		% L2 = Have spotted computer
		% L3 = Computer UID
		% L4 = History Message

		start <Print 1 if= L4 0 L= 4 1 History 3 CancelSubPlot %plotid5% if# P%id%02 0 TeamNeutral 2 TeamNeutral 3>
		end <if# L1 0 SetEncounterInactive %4%>
		tmove1 <if= L2 0 ifPCCanSeeLocal L3 L= 2 1 Alert 2>

		PCAttack <ifTeamNotHostile 2 TeamAttack 2 TeamAttack 3 TeamAttack 4 Alert 4>

		% Msg1 <You enter %name2%'s command bunker.>
		% Msg2 <You spot an important-looking computer terminal.>
		% Msg3 <You raided %name2%'s command bunker.>
		% Msg4 <Suddenly, an alarm goes off!>
		Msg1 <%name2% の司令壕に入った。>
		Msg2 <何やら重要そうな雰囲気のコンピュータ端末を発見した。>
		Msg3 <%name2% の司令壕を強襲した。>
		Msg4 <突然、警報が鳴り響いた！>

		Content1 <Some 2 80 Sub *Armory>

		sub
			Team 1
			SetEnemy 2 3 4

			Team 2
			name <Guards>
			type <SYNTH ROBOT GUARD>
			Deploy <if= V1 0 V= 1 1 MonsterUp 2 StoryDL>
			SetEnemy 1
			SetAlly 3 4

			Team 3
			name <First Encounter>
			home <Entrance>
			type <SYNTH ROBOT GUARD>
			Deploy <if= V1 0 V= 1 1 WMonster 3 StoryDL 50>
			SetEnemy 1
			SetAlly 2 4

			Team 4
			name <Last Encounter>
			home <Goal>
			type <SYNTH ROBOT GUARD>
			Deploy <if= V1 0 V= 1 1 if= P%id%02 0 WMonster 4 StoryDL 50>
			SetEnemy 1
			SetAlly 2 3

			room
			name <Entrance>
			name_I18N <入口>
			special <STARTHERE>
			sub
				TrapDoor
				Destination -1
				use <Print 1 Return>
			end

			room
			name <Goal>
			name_I18N <出口>
			sub
				STC COMPUTER-INDESTRUCTIBLE
				use <Alert 1 XPV 200 Retreat 2 Retreat 3 Retreat 4 MonsterOff 2 ForceChat %2% L= 1 1>
				update <L= 3 SelfUID>
				% Msg1 <You receive a holographic message from %name2%.>
				Msg1 <%name2% からのホログラム・メッセージを受信した。>
			end
		end

		Persona 2
		special <UNLISTED NOESCAPE>
		greeting <if= PlotStatus %plotid% %id% else GoChat SetPlotStatus %plotid1% %id1% Return Goto GoGreet>
		GoChat <EndChat SayAnything>
		*GoGreet <*CS_END_Intro_Greeting GoExplain>
		*GoExplain <*CS_END_Intro_Explanation>
	end
	inv
		STC CORE-ACTIVATABLE-STATIONARY-DEFENDED
		name <Command Base>
		name_I18N <司令基地>
	end

%%
%% *CS_END_Buildup
%%
%%  The fights leading up to (and revealing) the final battle.
%%
%%  PARAM1: The mood
%%  PARAM2: The enemy NPC
%%

Content
	name <Parade of Mini-Bosses>
	% desc <Fight a series of mini-bosses >
	desc <ミニボスとの連戦。>
	requires <*CS_END_Buildup>

	% E1 is the mood
	% E2 is the enemy NPC
	% E3 is an outdoors scene for the final battle
	% E4 is the final battle encounter-
	%     to be revealed once all the mini-bosses are done.
	Element3 <Scene Outdoors !Near -7>
	Element4 <Prefab>
	Place4 <3>

	% P%id%01 = Initialization Counter

	update <if= P%id%01 0 P= %id%01 1 SetPlotStatus %plotid1% %id1%>

	.%id1%_%plotid1%_GoWin <SetPlotStatus %plotid2% %id2%>
	.%id2%_%plotid2%_GoWin <SetPlotStatus %plotid3% %id3%>
	.%id3%_%plotid3%_GoWin <Alert %id%01 SetEncounterActive %4% SetPlotStatus %plotid4% %id4%>

	% Msg%id%01 <Having defeated all of the underlings, there's no-one left to fight but %name2%.>
	Msg%id%01 <すべての手下を打ち倒し、もはや残る相手は %name2% だけとなった。>

	% SubPlot1 is MiniBoss #1
	% SubPlot2 is MiniBoss #2
	% SubPlot3 is MiniBoss #3
	% SubPlot4 is the final battle
	SubPlot1 <*:CS_END_MiniBoss 4>
	SubPlot2 <*:CS_END_MiniBoss 4>
	SubPlot3 <*:CS_END_MiniBoss 4>
	SubPlot4 <*CS_END_FinalBattle 1 2 3 4>

	inv
		STC CORE-ACTIVATABLE
		name <Final Battle>
		name_I18N <最終決戦>
	end


%%
%% *CS_END_FinalBattle
%%
%%  The final battle. Exactly as advertised.
%%
%%  The enemy mecha forces must be Team 2, since any minibosses previously defeated
%%  will be added to this team.
%%
%%  NOTE: This component must kill the mood or at least give it a time limit.
%%
%%  PARAM1: The mood
%%  PARAM2: The enemy NPC
%%  PARAM3: The outdoor scene where the battle will take place
%%  PARAM4: The encounter for the final battle
%%

Content
	name <Battleship Battle>
	% desc <Fight a battleship, then your enemy.>
	desc <戦艦、そして宿敵と戦う。>
	requires <*CS_END_FinalBattle *CORE_FINAL>

	% E1 is the mood
	% E2 is the enemy NPC
	% E3 is an outdoors scene for the final battle
	% E4 is the final battle encounter

	% P%id%01 = Initialization Counter
	update <if= p%id%01 0 P= %id%01 1 NPCLevel %2% 90>

	% SubPlot1 is the ending stub; activate this subplot to start the ending.
	subplot1 <*:CS_END_TheEnd 2>

	sub
		MetaScene 4 2
		% rumor%id% <%name2%'s ship is in %name3%. This could mean the end of everything.>
		rumor%id% <これで何もかも終わるの%JG_KANA？ %name2% の艦が %name3% に来ている>
		special <NORESCUE>
		% L1 = Encounter Over Counter
		% L2 = Initialization Counter; resets each time
		% L3 = Second deployment happened
		% L4 = Enemy NPC died
		MapWidth 50
		MapHeight 50

		Start <if= L2 0 L= 2 1 L= 1 0   if= L3 0 else GoFightEnemy Alert 1   Trigger0 RollCall>
		GoFightEnemy <ForceChat %2%>
		nu1 <if= T1 0   Return if= L1 0 L= 1 1 if= L4 0 else GoPartial LoseRenown LoseRenown>
		nu2 <if= T2 0   if= L3 0 else nu5   ifG T3 0  Alert 2 WMecha 2 StoryDL 100>
		nu3 <if= T3 0   if= L3 0   L= 3 1   Alert 3  DeployNPC %2% 5  WMecha 5 StoryDL 100 ForceChat %2%>
		nu5 <if= T5 0   if= L3 1  if= T2 0  if= L1 0  L= 1 1  Goto GoVictory>
		Faint%2% <L= 4 1>
		end <L= 2 0>

		GoPartial <Alert 4  History 4   &EndPartialVictory      SetMoodTimeLimit %1% 86400   SetEncounterInactive %4%>
		GoVictory <Alert 5  History 5   &EndCompleteVictory     KillMood %1%                 SetEncounterInactive %4%>

		% Msg1 <You face %name2%'s battleship.>
		% Msg2 <Reinforcements arrive!>
		% Msg3 <As the battleship explodes, %name2% launches.>
		% Msg4 <With %name2% dead, \PPR %2% forces slowly begin to disperse.>
		% Msg5_1 <You have completely defeated %name2%'s forces.>
		% CMsg5_1 <if= &EnemyFac 0 Accept>
		% Msg5_2 <You have completely destroyed %name2%'s forces, and with them \FACTION &EnemyFac 's plans for domination.>
		% CMsg5_2 <if# &EnemyFac 0 Accept>
		Msg1 <%name2% の戦艦と対峙した。>
		Msg2 <敵の増援が現れた！>
		Msg3 <爆轟に包まれる敵艦から、%name2% が出撃した。>
		Msg4 <%name2% の死により、\SPR %2%の手勢は緩やかに霧散していった。>
		Msg5_1 <%name2% の軍勢を完全に撃滅した。>
		CMsg5_1 <if= &EnemyFac 0 Accept>
		Msg5_2 <%name2% の軍勢は完全に壊滅し、それにより \FACTION &EnemyFac の征服への野望もまた潰えた。>
		CMsg5_2 <if# &EnemyFac 0 Accept>

		sub
			team 1
			SetAlly 4
			SetEnemy 2 3 5
			ParaX 45
			ParaY 25

			team 2
			name <Enemies>
			SetEnemy 1 4
			SetAlly 3 5
			Deploy <if= PlotStatus %plotid% %id% SetSelfFaction &EnemyFac   ifDCCompleted OFF_5 else GoCheckOFF4 WMecha 2 80 275>
			GoCheckOFF4 <ifDCCompleted OFF_4 else GoBigBattle WMecha 2 90 300>
			GoBigBattle <WMecha 2 100 300>
			home <Enemy Zone>

			team 3
			name <Battleship>
			setenemy 1 4
			setally 2 5

			team 4
			name <Allies>
			setenemy 2 3 5
			setally 1
			Deploy <if= PlotStatus %plotid% %id% &ifDefensesRallied   SetSelfFaction &AllyFac   ifDCCompleted DEF_5 else GoCheckDef4 WMecha 4 100 150>
			GoCheckDef4 <ifDCCompleted DEF_4 else GoSmallAllies WMecha 4 70 150>
			GoSmallAllies <WMecha 4 40 100>
			home <Ally Zone>

			team 5
			name <Big Boss>
			home <Ship Zone>
			Deploy <SetSelfFaction &EnemyFac if= L3 1   ifDCCompleted OFF_5 else GoCheckOFF4 WMecha 5 StoryDL 100>
			GoCheckOFF4 <ifDCCompleted OFF_4 else GoBigBattle WMecha 5 StoryDL 150>
			GoBigBattle <WMecha 5 StoryDL 200>
			setenemy 1 4
			setally 2 3

			rect
			name <Enemy Zone>
			special <SubZone>
			width 5
			Height 48
			MFX 1
			MFY 2
			Content1 <Some 2 100 Here *CS_END_Final_Enemies na>

			rect
			name <Ally Zone>
			special <SubZone>
			width 5
			Height 48
			MFX 45
			MFY 2
			Content1 <Some 3 100 Here *CS_END_Final_Allies na>

			rect
			name <Ship Zone>
			special <SubZone>
			width 12
			height 12
			MFX 6
			MFY 19
			sub
				SuperProp
				requires <*BattleShip>
				SetTeam 3
			end
		end

		Persona 2
		special <UNLISTED>
		greeting <if= PlotStatus %plotid% %id% else %pop% if= v%id%01 0 else .%id%_GoSecondTime V= %id%01 1 Goto .%id%_GoGreet>
		*.%id%_GoSecondTime <*Back_For_More>
		*.%id%_GoGreet <*CS_END_FinalBattle_Greeting .%id%_GoThemeExpo>
		*.%id%_GoThemeExpo <*THEME_EXPO&Enemy na>
	end


Content
	name <SPECIAL: Peace and Love>
	% desc <Try one last time to get a peace agreement. If it doesn't work, thwack 'em.>
	desc <最後にもう一度だけ和平協定を試みる。これで駄目なら、叩きのめすしかない。>
	requires <*CS_END_FinalBattle *CORE_F_PAL>
	%% Before the final battle starts, you get a conversation in which to
	%% argue for peace. Succeed and you activate the special ending. Fail and
	%% you need to fight everybody as normal, plus you can only get the
	%% partial victory ending.

	% E1 is the mood
	% E2 is the enemy NPC
	% E3 is an outdoors scene for the final battle
	% E4 is the final battle encounter

	% P%id%01 = Initialization Counter
	update <if= p%id%01 0 P= %id%01 1 NPCLevel %2% 90>

	% SubPlot1 is the ending stub; activate this subplot to start the ending.
	% SubPlot2 is the special ending
	subplot1 <*:CS_END_TheEnd 2>
	subplot2 <*:CS_END_Special_PAL 2>

	sub
		MetaScene 4 2
		% rumor%id% <%name2%'s ship is in %name3%. This could mean the end of everything.>
		rumor%id% <これで何もかも終わるの%JG_KANA？ %name2% の艦が %name3% に来ている>
		special <NORESCUE>
		% L1 = Encounter Over Counter
		% L2 = Initialization Counter; resets each time
		% L3 = Second deployment happened
		% L4 = Enemy NPC died
		MapWidth 50
		MapHeight 50

		Start <if= L2 0 L= 2 1 L= 1 0   if= L3 0 else GoFightEnemy Alert 1   Trigger0 RollCall  ForceChat %2%>
		GoFightEnemy <ForceChat %2%>
		nu1 <if= T1 0   Return if= L1 0 L= 1 1 if= L4 0 else GoPartial LoseRenown LoseRenown>
		nu2 <if= T2 0   if= L3 0 else nu5   ifG T3 0  Alert 2 WMecha 2 StoryDL 100>
		nu3 <if= T3 0   if= L3 0   L= 3 1   Alert 3  DeployNPC %2% 5  WMecha 5 StoryDL 100 ForceChat %2%>
		nu5 <if= T5 0   if= L3 1  if= T2 0  if= L1 0  L= 1 1  Goto GoPyrrhic>
		Faint%2% <L= 4 1>
		end <L= 2 0>

		GoPartial <Alert 4  History 4   &EndPartialVictory      SetMoodTimeLimit %1% 86400   SetEncounterInactive %4%>
		GoPyrrhic <Alert 5  History 5   &EndPartialVictory      KillMood %1%                 SetEncounterInactive %4%>

		% Msg1 <You face %name2%'s battleship.>
		% Msg2 <Reinforcements arrive!>
		% Msg3 <As the battleship explodes, %name2% launches.>
		% Msg4 <With %name2% dead, \PPR %2% forces slowly begin to disperse.>
		% Msg5 <You failed to secure peace, but at least defeated %name2%.>
		Msg1 <%name2% の戦艦と対峙した。>
		Msg2 <敵の増援が現れた！>
		Msg3 <爆轟に包まれる敵艦から、%name2% が出撃した。>
		Msg4 <%name2% の死により、\SPR %2%の手勢は緩やかに霧散していった。>
		Msg5 <あなたは和平を掴むことができなかったが、少なくとも %name2% は打ち倒した。>

		sub
			team 1
			SetAlly 4
			SetEnemy 2 3 5
			ParaX 45
			ParaY 25

			team 2
			name <Enemies>
			SetEnemy 1 4
			SetAlly 3 5
			Deploy <if= PlotStatus %plotid% %id% SetSelfFaction &EnemyFac   ifDCCompleted OFF_5 else GoCheckOFF4 WMecha 2 80 275>
			GoCheckOFF4 <ifDCCompleted OFF_4 else GoBigBattle WMecha 2 90 300>
			GoBigBattle <WMecha 2 100 300>
			home <Enemy Zone>

			team 3
			name <Battleship>
			setenemy 1 4
			setally 2 5

			team 4
			name <Allies>
			setenemy 2 3 5
			setally 1
			Deploy <if= PlotStatus %plotid% %id% &ifDefensesRallied   SetSelfFaction &AllyFac   WMecha 4 120 150>
			home <Ally Zone>

			team 5
			name <Big Boss>
			home <Ship Zone>
			Deploy <SetSelfFaction &EnemyFac if= L3 1   ifDCCompleted OFF_5 else GoCheckOFF4 WMecha 5 StoryDL 100>
			GoCheckOFF4 <ifDCCompleted OFF_4 else GoBigBattle WMecha 5 StoryDL 150>
			GoBigBattle <WMecha 5 StoryDL 200>
			setenemy 1 4
			setally 2 3

			rect
			name <Enemy Zone>
			special <SubZone>
			width 5
			Height 48
			MFX 1
			MFY 2
			Content1 <Some 2 100 Here *CS_END_Final_Enemies na>

			rect
			name <Ally Zone>
			special <SubZone>
			width 5
			Height 48
			MFX 45
			MFY 2
			Content1 <Some 3 100 Here *CS_END_Final_Allies na>

			rect
			name <Ship Zone>
			special <SubZone>
			width 12
			height 12
			MFX 6
			MFY 19
			sub
				SuperProp
				requires <*BattleShip>
				SetTeam 3
			end
		end

		Persona 2
		special <UNLISTED>
		% V%id%01 = First time counter
		% V%id%02 = Final skill roll difficulty counter
		greeting <if= PlotStatus %plotid% %id% else %pop% if= v%id%01 0 else .%id%_GoSecondTime V= %id%01 1 V= %id%02 20  Goto .%id%_GoGreet>
		*.%id%_GoSecondTime <*Back_For_More>
		%% You get one chance to secure the peace. Let's see how it goes.
		%% The three bonuses:
		%% - Have a high Heroism score
		%% - Have a friend/ally/lover/family on the other side
		%% - Have the authority to speak now
		*.%id%_GoGreet <*CS_END_FPAL_Greeting .%id%_GoQuest1 .%id%_GoThemeExpo>
		*.%id%_GoQuest1 <*CS_END_FPAL_Quest1 .%id%_GoQuest2 .%id%_GoQ1Okay .%id%_GoQ1Fail>
		.%id%_GoQ1Okay <V+ %id%02 25 Goto .%id%_GoQuest2>
		.%id%_GoQ1Fail <V+ %id%02 50 Goto .%id%_GoQuest2>
		*.%id%_GoQuest2 <*CS_END_FPAL_Quest2 .%id%_GoQuest3 .%id%_GoQ2Okay .%id%_GoQ2Fail>
		.%id%_GoQ2Okay <V+ %id%02 25 ifG 100 v%id%02 else .%id%_GoRejectPeace Goto .%id%_GoQuest3>
		.%id%_GoQ2Fail <V+ %id%02 50 ifG 100 v%id%02 else .%id%_GoRejectPeace Goto .%id%_GoQuest3>
		*.%id%_GoQuest3 <*CS_END_FPAL_Quest3 .%id%_GoQ3Good .%id%_GoQ3Okay .%id%_GoQ3Fail>
		.%id%_GoQ3Good <ifG 21 v%id%02 else .%id%_GoQuest4 Goto .%id%_GoMakePeace>
		.%id%_GoQ3Okay <V+ %id%02 25 ifG 125 v%id%02 else .%id%_GoRejectPeace Goto .%id%_GoQuest4>
		.%id%_GoQ3Fail <V+ %id%02 50 ifG 125 v%id%02 else .%id%_GoRejectPeace Goto .%id%_GoQuest4>
		%% Question #4 is optional- if the player scored perfect on all tests so far, the
		%% peace deal is guaranteed. Otherwise the PC needs to make a skill roll to seal the deal.
		*.%id%_GoQuest4 <*CS_END_FPAL_Quest4 v%id%02 .%id%_GoMakePeace .%id%_GoRejectPeace>
		*.%id%_GoMakePeace <*CS_END_FPAL_Accept .%id%_GoWinGame>
		.%id%_GoWinGame <L= 1 1  SetEncounterInactive %4%  KillMood %1%    SetPlotStatus %plotid2% %id2%>
		*.%id%_GoRejectPeace <*CS_END_FPAL_Reject .%id%_GoThemeExpo>
		*.%id%_GoThemeExpo <*THEME_EXPO&Enemy na>
	end

%%
%% *:CS_END_MiniBoss
%%
%% The PC has to fight some minibosses before getting to the main boss. Hooray!
%% If a miniboss is defeated but not killed, it will be moved to the final battle
%% scene and assigned to team 2 there.
%%
%% If the PC loses the battle, no problem: the fight will repeat every 3-5 hours
%% until the PC wins. If the boss NPC dies, this counts as a win even if the PC
%% doesn't finish off the lancemates.
%%
%% The minibosses will be leveled to renown 82, as opposed to the main boss who
%% will be leveled to 90.
%%
%% When this subplot concludes, it sets the following trigger:
%%  .%id%_%plotid%_GoWin
%%
%% PARAM1: The final battle scene
%%

Content
	name <Faction MiniBoss>
	% desc <Fight someone aligned with the enemy faction.>
	desc <敵勢力の協力者と戦う。>
	requires <*:CS_END_MiniBoss F:++>
	Size 6

	% E1 is the final battle scene
	% E2 is an outdoors scene for the encounter
	% E3 is the encounter itself
	% E4 is the NPC to fight
	Element2 <Scene Outdoors !Near -7>
	Element3 <Prefab>
	Place3 <2>
	Element4 <Character !Comrade -2 !Global HasMecha NeverFail>
	Place4 <3 (Enemies) SD enemy>
	NeverFail4 <Mecha Pilot>

	% P%id%01 = Initialization Counter
	update <if= P%id%01 0 P= %id%01 1 NPCLevel %4% 82>

	sub
		MetaScene 3 2
		% rumor%id% <%name4% has been looking for you in %name2%.>
		rumor%id% <%name4% が %name2% で%JS2のことを探している>
		special <UNCHARTABLE>
		% L1 = Encounter Over Counter
		% L2 = Initialization Counter; resets each time
		MapWidth 50
		MapHeight 50

		Start <if= L2 0 L= 2 1   L= 1 0   ForceChat %4%>
		nu1 <if= T1 0   Return  if= L1 0   L= 1 1   AddRenown -3>
		nu2 <if= T2 0   if= L1 0   L= 1 1   Goto GoVictory>
		Faint%4% <if= L1 0 L= 1 1 Goto GoVictory>
		GoVictory <StoryNote 1 XPV 200 Salvage Trigger0 .%id%_%plotid%_GoWin WinSubPlot %plotid% ifNPCOK %4% MoveNPC %4% %1% SetNPCTeam %4% 2>
		end <L= 2 0>

		% Msg1 <You defeated %name4%'s lance.>
		Msg1 <%name4% の部隊を撃破した。>

		sub
			team 1
			SetEnemy 2
			ParaX 5
			ParaY 5

			team 2
			name <Enemies>
			SetEnemy 1
			Deploy <if= PlotStatus %plotid% %id% SetSelfFaction NPCFac %4%   WMecha 2 StoryDL 100>
			ParaX 45
			ParaY 45
		end

		Persona 4
		special <UNLISTED>
		greeting <if= PlotStatus %plotid% %id% else %pop% if= v%id%01 0 else .%id%_GoSecondTime V= %id%01 1 Goto .%id%_GoGreet>
		*.%id%_GoSecondTime <*Back_For_More>
		*.%id%_GoGreet <*BattleChallenge .%id%_GoThemeExpo na>
		*.%id%_GoThemeExpo <*THEME_EXPO&Enemy na>
	end
	inv
		Encounter
		name <%name4%'s Lance>
		name_I18N <%name4% の部隊>
		% V1 = Recharge Counter
		% This encounter will appear once every 3-5 hours, as long as this is the active subplot.
		update <if= PlotStatus %plotid% %id% else GoHide if# V1 0 else GoSetTimer ifG ComTime V1 else GoHide SetStat STAT_MetaVisibility 0  Goto GoSetOrders>
		GoSetTimer <V= 1 ComTime V+ 1 1800 Goto GoHide>
		GoSetOrders <GrabSource GSetNAtt NAG_EpisodeData NAS_Orders 0>
		use <ifG StatVal STAT_MetaVisibility -1  V= 1 ComTime V+ 1 10800 V+ 1 d7200  Print -1 Exit Destination>
		GoAutoAttack <V= 1 ComTime V+ 1 10800 V+ 1 d7200  Alert -2 Exit Destination>
		GoAvoidAttack <V= 1 ComTime V+ 1 7200 V+ 1 d3600  Print -6 AddSociable -1 UpdateProps>
	end

Content
	name <Enemy MiniBoss>
	% desc <Fight a previously made enemy.>
	desc <以前に作った敵と戦う。>
	requires <*:CS_END_MiniBoss>
	Size 6

	% E1 is the final battle scene
	% E2 is an outdoors scene for the encounter
	% E3 is the encounter itself
	% E4 is the NPC to fight
	Element2 <Scene Outdoors !Near -7>
	Element3 <Prefab>
	Place3 <2>
	Element4 <Character ArchEnemy !Okay -2 !Global HasMecha>
	Place4 <3 (Enemies) SD enemy>

	% P%id%01 = Initialization Counter
	update <if= P%id%01 0 P= %id%01 1 NPCLevel %4% 82>

	sub
		MetaScene 3 2
		% rumor%id% <%name4% is hunting for you in %name2%.>
		rumor%id% <%name4% が %name2% で%JS2を狙っている>
		special <UNCHARTABLE>
		% L1 = Encounter Over Counter
		% L2 = Initialization Counter; resets each time
		MapWidth 50
		MapHeight 50

		Start <if= L2 0 L= 2 1   L= 1 0   ForceChat %4%>
		nu1 <if= T1 0   Return  if= L1 0   L= 1 1   AddRenown -3>
		nu2 <if= T2 0   if= L1 0   L= 1 1   Goto GoVictory>
		Faint%4% <if= L1 0 L= 1 1 Goto GoVictory>
		GoVictory <StoryNote 1 XPV 200 Salvage Trigger0 .%id%_%plotid%_GoWin WinSubPlot %plotid% ifNPCOK %4% MoveNPC %4% %1% SetNPCTeam %4% 2>
		end <L= 2 0>

		% Msg1 <You defeated %name4%'s lance.>
		Msg1 <%name4% の部隊を撃破した。>

		sub
			team 1
			SetEnemy 2
			ParaX 5
			ParaY 5

			team 2
			name <Enemies>
			SetEnemy 1
			Deploy <if= PlotStatus %plotid% %id% SetSelfFaction NPCFac %4%   WMecha 2 StoryDL 100>
			ParaX 45
			ParaY 45
		end

		Persona 4
		special <UNLISTED>
		greeting <if= PlotStatus %plotid% %id% else %pop% if= v%id%01 0 else .%id%_GoSecondTime V= %id%01 1 Goto .%id%_GoGreet>
		*.%id%_GoSecondTime <*Back_For_More>
		*.%id%_GoGreet <*BattleChallenge .%id%_GoThemeExpo na>
		*.%id%_GoThemeExpo <*THEME_EXPO&Enemy na>
	end
	inv
		Encounter
		name <%name4%'s Lance>
		name_I18N <%name4% の部隊>
		% V1 = Recharge Counter
		% This encounter will appear once every 3-5 hours, as long as this is the active subplot.
		update <if= PlotStatus %plotid% %id% else GoHide if# V1 0 else GoSetTimer ifG ComTime V1 else GoHide SetStat STAT_MetaVisibility 0  Goto GoSetOrders>
		GoSetTimer <V= 1 ComTime V+ 1 1800 Goto GoHide>
		GoSetOrders <GrabSource GSetNAtt NAG_EpisodeData NAS_Orders 0>
		use <ifG StatVal STAT_MetaVisibility -1  V= 1 ComTime V+ 1 10800 V+ 1 d7200  Print -1 Exit Destination>
		GoAutoAttack <V= 1 ComTime V+ 1 10800 V+ 1 d7200  Alert -2 Exit Destination>
		GoAvoidAttack <V= 1 ComTime V+ 1 7200 V+ 1 d3600  Print -6 AddSociable -1 UpdateProps>
	end


%%
%% *:CS_END_RallyDefenses
%%
%%  The PC will be able to get some help for the final battle here.
%%
%%  Upon rallying the defenses, this plot will set the following trigger:
%%    .%id%_%plotid%_GoRallyDefenses
%%

Content
	name <New Task: Liberate the Armory>
	requires <*:CS_END_RallyDefenses>
	% desc <The PC needs help, but the armory was captured by the enemy.>
	desc <PC は援軍を求めるが、兵器庫が敵に制圧されていた。>

	%% E1 is a public scene for the meeting
	%% E2 is the person to be met
	%% E3 is an urban scene for the armory
	Element1 <Scene Building Public !Near -7>
	Element2 <Character HasMecha !Near -7 !Ally -7 !XClude -2>
	Place2 <1 (Guards) pass>
	Element3 <Scene Urban !Near -7>

	% if E2 died, that cancels this subplot, but if the armory liberation has already
	%  been started that can still succeed.
	start <ifNPCDead %2% LoseSubPlot %plotid%>

	% Winning the armor liberation will give the RallyDefenses advantage,
	% regardless of whether E1 is alive or dead.
	.%id1%_%plotid1%_GoWin  <WinSubPlot %plotid%   Alert %id%01 History %id%02 PMemo %plotid% %id%03   &RallyDefenses>
	.%id1%_%plotid1%_GoLoss <LoseSubPlot %plotid%  Alert %id%04 PMemo %plotid% 0>

	% Msg%id%01 <You have liberated the \SCENE &EpisodeScene armory. Now at least you'll have some backup in the fight to come.>
	% Msg%id%02_1 <You liberated the armory from \FACTION &EnemyFac .>
	% CMsg%id%02_1 <if# &EnemyFac 0 Accept>
	% Msg%id%02_2 <You liberated the armory from \PERSONA &EnemyNPC 's henchmen.>
	% CMsg%id%02_2 <ifNPCOK &EnemyNPC Accept>
	% Msg%id%02_3 <You liberated the armory from your enemies.>
	% CMsg%id%02_3 <ifNPCDead &EnemyNPC if= &EnemyFac 0 Accept>
	% Msg%id%03_1 <You liberated the armory from \FACTION &EnemyFac . Now you should have some backup in the final battle.>
	% CMsg%id%03_1 <if# &EnemyFac 0 Accept>
	% Msg%id%03_2 <You liberated the armory from \PERSONA &EnemyNPC 's henchmen. Now you should have some backup in the final battle.>
	% CMsg%id%03_2 <ifNPCOK &EnemyNPC Accept>
	% Msg%id%03_3 <You liberated the armory from your enemies. Now you should have some backup in the final battle.>
	% CMsg%id%03_3 <ifNPCDead &EnemyNPC if= &EnemyFac 0 Accept>
	% Msg%id%04 <You destroyed the \SCENE &EpisodeScene armory.>
	Msg%id%01 <\SCENE &EpisodeScene の兵器庫を奪還した。これで少なくとも、来たるべき戦いでいくらかの支援が受けられるだろう。>
	Msg%id%02_1 <\FACTION &EnemyFac の手から兵器庫を奪還した。>
	CMsg%id%02_1 <if# &EnemyFac 0 Accept>
	Msg%id%02_2 <\FACTION &EnemyFac の手下たちから兵器庫を奪還した。>
	CMsg%id%02_2 <ifNPCOK &EnemyNPC Accept>
	Msg%id%02_3 <敵勢力から兵器庫を奪還した。>
	CMsg%id%02_3 <ifNPCDead &EnemyNPC if= &EnemyFac 0 Accept>
	Msg%id%03_1 <\FACTION &EnemyFac の手から兵器庫を奪還した。これで最後の戦いにいくらかの支援が得られるはずだ。>
	CMsg%id%03_1 <if# &EnemyFac 0 Accept>
	Msg%id%03_2 <\FACTION &EnemyFac の手下たちから兵器庫を奪還した。これで最後の戦いにいくらかの支援が得られるはずだ。>
	CMsg%id%03_2 <ifNPCOK &EnemyNPC Accept>
	Msg%id%03_3 <敵勢力から兵器庫を奪還した。これで最後の戦いにいくらかの支援が得られるはずだ。>
	CMsg%id%03_3 <ifNPCDead &EnemyNPC if= &EnemyFac 0 Accept>
	Msg%id%04 <\SCENE &EpisodeScene の兵器庫は破壊された。>

	% SubPlot1 is the armory liberation
	SubPlot1 <*:CS_CaptureBuilding 3>

	sub
		Persona 2
		% rumor%id% <%name2% has been leading the resistance movement.>
		rumor%id% <%name2% が反攻の動きを主導している>
		greeting <ifSubPlotWon %plotid% else GoCheckLoss NewChat Say 1>
		GoCheckLoss <ifSubPlotLost %plotid% else GoCheckMission NewChat Say 2>
		GoCheckMission <if# PlotStatus %plotid1% 0 else GoCheckFirst NewChat Say 3>
		GoCheckFirst <if= PlotStatus %plotid% %id% else GoChat NewChat Say 4 AddChat 1 AddChat 2>
		GoChat <NewChat SayAnything>
		*result1 <*CS_END_StatusReport result2>
		result2 <NewChat Say 5 History 6 PMemo %plotid% 7 SetPlotStatus %plotid1% %id1%>
		% Msg1 <You did it! Now we can start fighting back properly!>
		% Msg1_1 <The armory has been liberated. Now, we'll be able to strike back at \PERSONA &EnemyNPC !>
		% CMsg1_1 <ifNPCOK &EnemyNPC Accept>
		% Msg1_3 <You liberated the armory from \FACTION &EnemyFac ! We'll be there to support you when the time comes to strike.>
		% CMsg1_3 <if# &EnemyFac 0 Accept>
		% Msg2 <The armory has been destroyed...>
		% Msg2_1 <The armory has been destroyed... At least \PERSONA &EnemyNPC won't be able to use it either.>
		% CMsg2_1 <ifNPCOK &EnemyNPC Accept>
		% Msg2_3 <The armory has been destroyed... At least it can't be used by \FACTION &EnemyFac anymore.>
		% CMsg2_3 <if# &EnemyFac 0 Accept>
		% Msg3 <You need to liberate the armory in %name3%; otherwise we won't be able to put up a fight!>
		% Msg3_1 <The armory is still under the control of \PERSONA &EnemyNPC . We need to get it back if we're going to reist \OPR &EnemyNPC .>
		% CMsg3_1 <ifNPCOK &EnemyNPC Accept>
		% Msg3_3 <The armory is still under the control of \FACTION &EnemyFac . We need to get it back if we're going to reist them.>
		% CMsg3_3 <if# &EnemyFac 0 Accept>
		% Msg4 <Hey there \PC . \SCENE &EpisodeScene could use the help of someone like you in these dark times.>
		% Msg4_1 <\PC , it's a good thing you're here. \PERSONA &EnemyNPC has taken control and we need your help to defeat \OPR &EnemyNPC .>
		% CMsg4_1 <ifNPCOK &EnemyNPC Accept>
		% Msg4_2 <These are dark times for \SCENE &EpisodeScene ... We are at the mercy of \FACTION &EnemyFac , and could use the help of someone like you to defeat them.>
		% CMsg4_2 <if# &EnemyFac 0 Accept>
		% Msg5 <There's no way we can put up a proper fight because the armory in %name3% has been captured. Nobody can do anything without those weapons.>
		% Msg5_1 <We can't even fight back because \PERSONA &EnemyNPC has captured the armory in %name3%. If we could get those weapons back, then maybe that'd even the odds a bit.>
		% CMsg5_1 <ifNPCOK &EnemyNPC Accept>
		% Msg5_2 <The armory in %name3% has been occupied by \FACTION &EnemyFac . We can't put up a fight if we don't have any weapons, now can we?>
		% CMsg5_2 <if# &EnemyFac 0 Accept>
		% Msg6 <%name2% revealed that the armory had been captured.>
		% Msg7 <The armory in %name3% has been captured. You will need to liberate it if you hope to get any backup in this fight.>
		% Prompt1 <First tell me exactly what's going on.>
		% Prompt1_1 <I'm glad to help, but what exactly is happening?>
		% Prompt2 <Yeah, good job you've done defending the place.>
		% Prompt2_1 <Wait, wasn't that supposed to be your job?>
		Msg1 <やった%JV_F_WA%JV_NA！ これでようやく反撃が始められる%JV_ZO！>
		Msg1_1 <兵器庫は奪還された%JG_YO。これで \PERSONA &EnemyNPC に反撃ができる%JV_ZO%JV_F_YO！>
		CMsg1_1 <ifNPCOK &EnemyNPC Accept>
		Msg1_3 <\FACTION &EnemyFac から兵器庫を取り戻してくれた%JV_F_NO%JV_F_NE%JV_KA_Q！ 決戦の時が来たら、%JF2%JF_TACHIも支援に駆けつける%JV_ZO%JV_F_YO。>
		CMsg1_3 <if# &EnemyFac 0 Accept>
		Msg2 <兵器庫は失われた%JV_F_WA……。>
		Msg2_1 <兵器庫は失われた%JV_F_WA……少なくとも、\PERSONA &EnemyNPC に利用されることもなくなった%JG_GA。>
		CMsg2_1 <ifNPCOK &EnemyNPC Accept>
		Msg2_3 <兵器庫は失われた%JV_F_WA……少なくとも、\FACTION &EnemyFac に利用されることもなくなった%JG_GA。>
		CMsg2_3 <if# &EnemyFac 0 Accept>
		Msg3 <%name3% にある兵器庫を奪還して%JG_R%JV_SIL_Rそうしなければ%JF2%JF_TACHIは戦いを続けることができない%JV_F_WA！>
		Msg3_1 <兵器庫はまだ \PERSONA &EnemyNPC の支配下にある%JV_F_WA。奴と戦っていくためにはこれを奪還しなければ。>
		CMsg3_1 <ifNPCOK &EnemyNPC Accept>
		Msg3_3 <兵器庫はまだ \FACTION &EnemyFac の支配下にある%JV_F_WA。奴らと戦っていくためにはこれを奪還しなければ。>
		CMsg3_3 <if# &EnemyFac 0 Accept>
		Msg4 <ああ \PC。苦難の中にある \SCENE &EpisodeScene には、%JS2のような者の助けが必要%JG_DAYO%JV_SIL_R。>
		Msg4_1 <\PC、%JS2がここに来てくれて良かった%JG_YO。\PERSONA &EnemyNPC にしてやられて、%JS2に奴を倒してもらわないといけない%JG_NDA。>
		CMsg4_1 <ifNPCOK &EnemyNPC Accept>
		Msg4_2 <\SCENE &EpisodeScene にとっては苦難の時代%JG_DA%JV_SIL_R%JF2%JF_TACHIは \FACTION &EnemyFac に命綱を握られてしまった%JV_F_NO。もう%JS2のような者に彼らを撃破してもらうしか手がない%JV_F_WA……。>
		CMsg4_2 <if# &EnemyFac 0 Accept>
		Msg5 <%name3% にある兵器庫が制圧されてしまったせいで、まともな戦いができなくなってしまった%JG_NDA。あそこの武器がなければ何もすることができない%JV_F_WA……。>
		Msg5_1 <\PERSONA &EnemyNPC が %name3% にある兵器庫を制圧してしまったせいで、反撃すらできなくなってしまった%JV_F_WA。あそこの武器が取り戻せれば、まだ趨勢は挽回できる%JV_Nだ%JG_GA……。>
		CMsg5_1 <ifNPCOK &EnemyNPC Accept>
		Msg5_2 <%name3% にある兵器庫が \FACTION &EnemyFac によって占拠されてしまった%JG_NDA。武器が押さえられてしまったのでは、戦いようがない%JV_F_WA……。>
		CMsg5_2 <if# &EnemyFac 0 Accept>
		Msg6 <兵器庫が制圧されたことを %name2% から明かされた。>
		Msg7 <%name3% にある兵器庫が制圧された。この先の戦いで支援を得ようと考えるなら、これを奪還する必要がある。>
		Prompt1 <まずは、何が起こってるのか正確に教えて%JG_R。>
		Prompt1_1 <喜んで手を貸す%JG_GA、いったい何が起こってる%JG_NDA？>
		Prompt2 <へえ、随分しっかりと守ってた%JV_N%JV_M_DA%JV_NA。>
		Prompt2_1 <%JR_NO、それは%JS2%JF_TACHIの仕事じゃないの%JV_KA_Q？>
	end

