%%
%% *Skirmishing Plots
%%
%%  Mecha from a foreign power are in town skirmishing with the local security forces,
%%  but it's nothing serious. There will be a lot of mecha missions until everything
%%  calms down.
%%
%% Mood Spec:
%%  E1 = The city itself
%%  E2 = The enemy faction
%%

Plot
	name <Enemy Patrol>
	desc <Some mecha from the rampaging faction may attack the PC.>
	requires <*Skirmishing>

	% E1 is an outdoors scene
	% E2 is an encounter to place there
	% E3 is the faction that's rampaging
	% E4 is an ally of that faction
	Element1 <Scene Environs>
	Element2 <Prefab>
	Place2 <1>
	Element3 <Grab 2>
	Element4 <Character HasMecha !Ally 3 !XClude -1 -POLIC !Global>
	Place4 <2 (Enemies)>

	% P1 = Time Limit/Initialization Counter
	% P2 = Mode; if P2=1 then the player joins the battle on E4's side
	start <if# P1 0 ifG ComTime P1 EndPlot>
	update <if= P1 0 P= 1 ComTime P+ 1 21600>

	sub
		MetaScene 2 2
		% L1 = Encounter Over Counter
		% L2 = Initialization Counter
		MapWidth 50
		MapHeight 50

		SetFaction 3

		start <if= L2 0 L= 2 1>
		nu1 <if= T1 0   Return   if= V1 0 V= 1 1    AddRenown -1        EndPlot>
		nu2 <if= T2 0   if= V1 0 V= 1 1   AddRenown 1 Alert 2   XPV 100   SALVAGE   if= P2 0 else GoAltEnding FacXP+ RootSceneFac 1 EndPlot>
		GoAltEnding <FacXP+ %3% 1  FacXP+ NPCFac %4% 1  EndPlot>

		Msg2 <You have defeated the mecha.>


		sub
			team 1
			SetEnemy 2
			SetAlly 3
			ParaX 5
			ParaY 5

			team 2
			name <Enemies>
			SetEnemy 1 3
			Deploy <if= P2 0 else GoAltDeploy SetSelfFaction %3% WMecha 2 %threat% 75>
			GoAltDeploy <SetSelfFaction RootSceneFac WMecha 2 %threat% 200>
			ParaX 45
			ParaY 45

			team 3
			name <Allies>
			SetEnemy 2
			SetAlly 3
			Deploy <if= P2 1 SetSelfFaction %3% WMecha 3 %threat% 50>
			ParaX 10
			ParaY 10
		end

		Persona 4
		special <Unlisted NoEscape>
		greeting <if= PlotStatus %plotid% %id% else GoCheckEnemy NewChat SayAnything>
		GoCheckEnemy <SetPlotStatus %plotid% %id% ifFactionEnemy %3% else GoCheckAlly  Goto GoBattleChallenge>
		GoCheckAlly <ifFactionAlly %3% else GoCheckSides P= 2 1 SetNPCTeam %4% 3       Goto GoJoinPatrol>
		GoCheckSides <ifG React d30 else GoBattleChallenge EndChat Say 1 EndPlot>
		*GoBattleChallenge <*BattleChallenge&Avoid GoThemeEnemy GoEnd>
		*GoJoinPatrol <*JoinOurFacPatrol GoThemeAlly GoEnd %3% RootSceneFac>
		*GoThemeEnemy <*THEME_EXPO&Enemy GoStartCombat>
		*GoThemeAlly <*THEME_EXPO&Ally GoStartCombat>
		GoStartCombat <Exit %2%>
		GoEnd <EndPlot>
		Msg1 <My fight isn't with you, but you better get out of \SCENE RootSceneID while you can.>
	end
	inv
		STC ENCOUNTER-WANDER
		name <%name4%'s Patrol>
		EncounterMove 20
		use <ifG StatVal STAT_MetaVisibility -1  ForceChat %4%>
		ATTACK <ifG StatVal STAT_MetaVisibility -1   ifG PCScale 0   ifUStealth 10 else GoMaybeAttack ifYesNo 3 4 5 else GoAvoidAttack Goto GoAutoAttack>
		GoMaybeAttack <ifFactionEnemy %3% Goto GoAutoAttack>
		GoAutoAttack <ForceChat %4%>
		Msg3 <You encounter a group of infiltrators led by %name4% of \FACTION NPCFac %4% .>
		Msg4 <Contact them.>
		Msg5 <Slip away quietly.>
	end

Plot
	name <Skirmishing Job>
	% This job gives salvage.
	requires <*Skirmishing>
	PayRate 125

	% E1 is the faction to be fought
	% E2 is a character who will offer the mission
	% E3 is a scene where the encounter will take place
	Element1 <Faction !Ally -2 !Xclude -1>
	Element2 <Character (HasMecha|POLIT) -POLIC !Ally -1 !Xclude 1>
	Element3 <Scene Environs>

	% SubPlot1 is the combat encounter
	SubPlot1 <*MECHAMISSION_Versus 2 3 1>

	% P1 = Time Limit
	% P2 = Email Indicator
	start <if= PlotStatus %plotid% 0 ifNPCOK %2% else GoDelete ifG ComTime P1 EndPlot>
	GoDelete <EndPlot>
	update <if= PlotStatus %plotid% 0 if= P1 0 P= 1 ComTime P+ 1 86400>

	% Insert email here
	5min <if= PlotStatus %plotid% 0 if= RootSceneID %1% if= P2 0  if= PCFac NPCFac %2%    ifG PCCharm d30  SetNPC %2% Email 1 P= 2 1>
	Msg1   <%name2%@ \SCENE NPCSCene %2% :// \RANK \PC , report to \SCENE EScene 2 for a mission.>
	Msg1_1 <%name2%@ \SCENE NPCSCene %2% :// I have a job for you at \SCENE EScene 2 .>
	Msg1_2 <%name2%@ \SCENE NPCSCene %2% :// %name1% needs your help. Come see me at \SCENE EScene 2 .>
	Msg1_3 <%name2%@ \SCENE NPCSCene %2% :// Call when you can; I've got a mission for you.>

	sub
		Persona 2
		rumor0 <%name2% needs a pilot to fight the infiltrators from %name1%.>
		greeting <if= PlotStatus %plotid% %id1% else GoCheckOffer Goto GoRemind>
		*GoRemind <*MechaMissionReminder %3%>
		GoCheckOffer <if# PlotStatus %plotid% 0 else GoCheckEnemy NewChat SayAnything>
		*GoCheckEnemy <*ENEMY_CHECK GoCheckEmail ChatNPCFac GoEnd>
		GoCheckEmail <if= P2 1 else GoCheckMember Goto GoGotEmail>
		*GoGotEmail <*DidYouGetEmail GoMissionBriefing>
		GoCheckMember <if= PCFac ChatNPCFac else GoCheckAuto  Goto GoIsMember>
		*GoIsMember <*IHaveAJobForYou GoMissionBriefing>
		*GoCheckAuto <*AutoMissionTest&Mecha GoMissionBriefing GoRejectMission GoCheckSkill ChatNPCFac na>
		*GoCheckSkill <*CivilDefenseTest&Mecha  GoMissionBriefing GoEnd GoRejectMission GoReducePay ChatNPCFac %1% %threat%>
		GoReducePay <SetPayRate 75  Goto GoMissionBriefing>
		*GoRejectMission <*RejectMission GoEnd>
		GoEnd <EndPlot>
		GoMissionBriefing <NewChat Say 1  AddChat 1 AddChat 2>
		*result1 <*GoodLuckOnMission&NoEnemyFac GoR1Final ChatNPCFac na>
		GoR1Final <Memo 2 SetPlotStatus %plotid% %id1%>
		result2 <Goto GoRejectMission>
		Msg1 <Infiltrators sent by %name1% have been spotted in %name3%. I want you to go defeat them; do this, and you'll earn $ \VAL Reward %threat% PayRate plus salvage.>
		Msg1_1 <No doubt you've heard about the infiltrators from %name1%. They've been seen in %name3%; your mission, if you choose to accept it, is to engage and defeat them. For this you'll earn $ \VAL Reward %threat% PayRate plus salvage.>
		CMsg1_1 <ifNPCSociable Accept>
		Msg1_2 <Infiltrators from %name1% have been tracked to %name3%. Defeat them and you'll earn $ \VAL Reward %threat% PayRate plus salvage rights.>
		CMsg1_2 <ifNPCShy Accept>
		Msg1_3 <>
		CMsg1_3 <ifNPCEasygoing Accept>
		Msg1_4 <>
		CMsg1_4 <ifNPCPassionate Accept>
		Msg1_5 <>
		CMsg1_5 <ifNPCCheerful Accept>
		Msg1_6 <>
		CMsg1_6 <ifNPCMelancholy Accept>
		Msg2 <\ELEMENT 2 in \SCENE NPCScene %2% hired you to fight %name1% in %name3%.>
		Prompt1 <No problem. I'll be back when I'm done.>
		Prompt1_1 <I can do that.>
		Prompt1_2 <Alright, I'll do it.>
		Prompt2 <Sorry, but I'd rather not make any more enemies.>
		CPrompt2 <if# PCFac ChatNPCFac Accept>
		Prompt2_1 <Sorry, but I don't want this job.>
		Prompt2_2 <Wait, I've changed my mind about this job.>
	end

