code:
:: secExpSmilingMan [nobr]

The Smiling Man

<<set $nextButton = "Continue", $nextLink = "Random Nonindividual Event">>
<<setAssistantPronouns>>

<<if $seeDicks != 100>>
	<<set _activeSlave = GenerateNewSlave("XX",{minAge: 16, maxAge: 18, ageOverridesPedoMode: 1, disableDisability: 1, race: "asian", nationality: "Japanese"})>>
	<<set _activeSlave.faceShape = "cute">>
	<<set _activeSlave.boobs = 450>>
	<<set _activeSlave.vagina = 0>>
	<<set _activeSlave.ovaries = 1>>
<<else>>
	<<set _activeSlave = GenerateNewSlave("XY",{minAge: 16, maxAge: 18, ageOverridesPedoMode: 1, disableDisability: 1, race: "asian", nationality: "Japanese"})>>
	<<set _activeSlave.boobs = 250>>
	<<set _activeSlave.faceShape = "androgynous">>
<</if>>
<<set _activeSlave.boobShape = "perky">>
<<set _activeSlave.nipples = "cute">>
<<set _activeSlave.origin = "$He was a criminal mastermind, captured shortly after completing $his master plan.">>
<<set _activeSlave.career = "a student from a private school">>
<<set _activeSlave.intelligence = 100>>
<<set _activeSlave.intelligenceImplant = 30>>
<<set _activeSlave.slaveSurname = "Yamadera">>
<<set _activeSlave.birthSurname = "Yamadera">>
<<set _activeSlave.origSkin = "pale">>
<<run applyGeneticColor(_activeSlave)>>
<<set _activeSlave.devotion = 5 * $SecExp.smilingMan.relationship>>
<<set _activeSlave.trust = 5 * $SecExp.smilingMan.relationship>>
<<set _activeSlave.face = random(10,50)>>
<<run setHealth(_activeSlave, 70, 0, 0, 0, 0)>>
<<set _activeSlave.teeth = "normal">>
<<set _activeSlave.areolae = 0>>
<<set _activeSlave.anus = 0>>
<<set _activeSlave.butt = 3>>
<<set _activeSlave.lips = 15>>
<<set _activeSlave.behavioralFlaw = "odd">>
<<set _activeSlave.skill.vaginal = 0>>
<<set _activeSlave.skill.oral = 0>>
<<set _activeSlave.skill.anal = 0>>
<<set _activeSlave.skill.whoring = 0>>
<<set _activeSlave.skill.entertainment = 0>>
<<set _activeSlave.birthWeek = random(0,50)>>
<<set _activeSlave.voice = 2>>
<<set _activeSlave.weight = -20>>
<<set _activeSlave.muscles = 0>>
<<set _activeSlave.shoulders = -1>>
<<set _activeSlave.hips = 0>>
<<set _activeSlave.clit = 0>>
<<set _activeSlave.labia = 0>>
<<set _activeSlave.waist = 10>>
<<set _activeSlave.preg = 0>>
<<set _activeSlave.prestige = 3>>
<<set _activeSlave.prestigeDesc = "$He was the famous Smiling Man.">>
<<set _activeSlave.clothes = "a military uniform">> /*closest thing to commie/punk we have at the moment*/

<<if $SecExp.smilingMan.progress === 0>>
	<<set $SecExp.smilingMan.relationship = 0>>
	<<set $fcnn.push("...encryption techniques: how to protect you and your loved ones from hackers ...")>>

		During your morning routine, a peculiar report appears: it's been several weeks since your arcology was the victim of a series of cyber-crimes conducted by a mysterious figure.
		The egocentric criminal apparently took great pride in their acts, to the point of signing them with a symbol: a stylized smiling face. Your arcology was not the only one under assault by the
		machinations of the one the media quickly nicknamed the Smiling Man.

		Despite the sheer damage this criminal did, you cannot help but admire the skill with which every misdeed was performed — the worst white collar crimes of the century, carried out with such elegance that they almost seemed the product of natural laws, rather than masterful manipulation of the digital market. While sifting through the report, $assistant.name remains strangely quiet. "I'm worried, <<= properTitle()>> — this individual seems to be able to penetrate whichever system garners his attention. I... feel vulnerable," _heA says. "It's not something I'm used to."

		Fortunately you have not been hit directly by this criminal — yet. Still, the repercussions of numerous bankruptcies take their toll on your arcology, whose prosperity suffers.
		<<set $arcologies[0].prosperity *= random(80,90) * 0.01>>

		<<if $cash >= 10000>>

				<<link "Devote funds to the search for this dangerous criminal">>
					<<run cashX(-10000, "event")>>
					<<set $SecExp.smilingMan.investedFunds = 1>>
					<<set $SecExp.smilingMan.relationship++, $SecExp.smilingMan.progress++>>
					<<replace "#result">>
						You devote funds to capture and neutralize the threat. You cannot help but wonder what the end game of this "smiling man" is. Money? Fame? Or is he on an ideological crusade?
					<</replace>>
				<</link>>

				<<link "Attempt to contact the mysterious figure">>
					<<run cashX(-10000, "event")>>
					<<set $SecExp.smilingMan.investedFunds = 1>>
					<<set $SecExp.smilingMan.relationship += 2, $SecExp.smilingMan.progress++>>
					<<replace "#result">>
						You devote funds to an attempt at communicating with the smiling man. You cannot help but wonder what the end game of this "smiling man" is. Money? Fame? Or is he on an ideological crusade?
					<</replace>>
				<</link>>

				<<link "Invest funds to increase the cyber-security of the arcology">>
					<<run cashX(-10000, "event")>>
					<<set $SecExp.smilingMan.investedFunds = 1>>
					<<set $SecExp.smilingMan.relationship += random(5,10), $SecExp.smilingMan.progress++>>
					<<replace "#result">>
						You devote funds to the improvement of the cyber-security of your arcology. You cannot help but wonder what the end game of this "smiling man" is. Money? Fame? Or is he on an ideological crusade?
					<</replace>>
				<</link>>

		<<else>>

				Not enough funds to take further action.

		<</if>>

			<<link "Ignore the issue">>
				<<set $SecExp.smilingMan.progress++>>
				<<replace "#result">>
					You do not consider this individual a threat.
				<</replace>>
			<</link>>

<<elseif $SecExp.smilingMan.progress === 1>>
	<<set $fcnn.push("...cybersecurity market is booming thanks to a series of recent high-profile attacks...")>>

		You have just reached your penthouse when your faithful assistant appears in front of you, evidently excited.
		"<<= properTitle()>>, I have just received news of a new attack by the Smiling Man. It appears a few hours ago he infiltrated another arcology and caused a catastrophic failure of its power plant.
		Between old debts and the loss of value for his shares, the owner went bankrupt in minutes. It seems the Smiling Man managed to keep a small auxiliary generator functioning enough to project a giant holographic picture of his symbol on the arcology's walls.
		Say what you will about his actions, but you can't deny he has style... Anyways, this opens up a great opportunity to gain control of the structure for ourselves."
		It is indeed a great opportunity, one you cannot resist. You quickly organize the affair and in a few minutes a message reaches your assistant.

		"Should I open it?" your assistant asks. You silently nod.

		Suddenly the room flashes red, while your assistant fades for half a second. When _heA reappears, _hisA face has been replaced by a stylized smiling face.

		"Hello, my dear $PC.birthName. I can call you $PC.birthName, right? I've been keeping an eye on you for so long now, it feels like we're friends! I am terribly sorry for my unannounced visit, but I wanted to meet face to face... well, face to hologram." it says, letting out a childlike giggle.
		"I'm sure you're aware of my recent activities around this rock of ours, and, well, to put it simply, it's your turn to contribute to my great project! You'll love it when you see it, I'm sure! By the way, thanks for the offer — it's so nice to see people contribute to a worthy cause so generously! Well, I've taken enough of your time, see you soon!"

		The lights flicker once more and an instant later your assistant returns to _hisA usual self.

		"I... I — I couldn't stop him! I'm sorry, <<= properTitle()>>."

		You waste no time in rushing to the console and checking your finances. It's as you feared, you have been robbed.

	<<set _lostCash = Math.clamp(50000 * Math.trunc($week / 20), 50000, 1000000)>>
	<<if $assistant.power >= 1>>

			Fortunately, the computing power available to $assistant.name allowed _himA to
			<<if $assistant.power == 1>>
				<<set _lostCash -= Math.min(20000, _lostCash)>>
				somewhat
			<<elseif $assistant.power == 2>>
				<<set _lostCash -= Math.min(30000, _lostCash)>>
			<<elseif $assistant.power >= 3>>
				<<set _lostCash -= Math.min(40000, _lostCash)>>
				significantly
			<</if>>
			limit the damage.

	<</if>>

		<<if $SecExp.buildings.secHub && $SecExp.buildings.secHub.upgrades.security.cyberBots == 1>>
			<<set _lostCash -= Math.min(30000, _lostCash)>>
			The additional cyber defenses acquired and running in the security HQ <<if _lostCash < 200000>>further<</if>> limit the damage.
		<</if>>
		<<if $SecExp.smilingMan.investedFunds>>
			<<set _lostCash -= Math.min(20000, _lostCash)>>
			The funding you dedicated to the Smiling Man case saved some of the assets that would have been otherwise lost.
			<<run delete $SecExp.smilingMan.investedFunds>>
		<</if>>

	<<run cashX(forceNeg(_lostCash), "event")>>

			<<link ""I want him dead. Now."">>
				<<set $SecExp.smilingMan.relationship--, $SecExp.smilingMan.progress++>>
				<<replace "#result">>
					You command your loyal operatives to double down on the search and elimination of the threat.
				<</replace>>
			<</link>>

			<<link ""I want him, dead or alive!"">>
				<<set $SecExp.smilingMan.relationship++, $SecExp.smilingMan.progress++>>
				<<replace "#result">>
					You command your loyal operatives to double down on the search and capture of the threat.
				<</replace>>
			<</link>>

			<<link ""If we don't find him soon, we will regret it."">>
				<<set $SecExp.smilingMan.relationship += 2, $SecExp.smilingMan.progress++>>
				<<replace "#result">>
					You command your loyal operatives to double down on the search and neutralization of the threat.
				<</replace>>
			<</link>>

			<<link ""He got what he wanted. Hopefully, we will be left in peace."">>
				<<set $SecExp.smilingMan.progress++>>
				<<set $nextButton = "Continue", $nextLink = "Random Nonindividual Event">>
				<<replace "#result">>
					You take no further action. Hopefully this ordeal is over.
				<</replace>>
			<</link>>

<<elseif $SecExp.smilingMan.progress === 2>>
	<<set $fcnn.push("...my money safe the old-fashioned way: I store it all underneath my mattress...")>>

		When $assistant.name violently wakes you up, _hisA worried expression can mean only one thing: the Smiling Man had been back. "We were anonymously sent a link to a new website: it's a very simple site, no visuals, no text; only a countdown ticking away. It will reach zero this evening." your assistant says.
		This is troubling, yet somewhat exciting. The Smiling Man never failed to cause damage, but his ego had gotten the best of him this time — having time to prepare before their attack will give you a chance to find them. For the rest of the day you do your best to plan, prepare and focus.

		Evening came faster than you anticipated. Your security team was already at full alert, waiting for any signal on the horizon. The die was cast.

		Suddenly all the computers in the room begin to act strangely, and then it happened. On all of the screens across the arcology the Smiling Man's icon appears, then every speaker begins broadcasting the same voice, one that you have already heard once before:

		"Hello citizens of $arcologies[0].name! I am here on this special day to relay to you a very important message: we find ourselves in very peculiar times, times of strife and suffering! But these are also times of change and regeneration! Indeed, I say humanity itself is regenerating, turning into a new being for which the
	ideals of the old world no longer hold meaning. A new blank page from which humanity can begin to prosper again.

		Alas, my friends, not all is good, as in this rebirth a great injustice is being perpetrated. If we truly want to ascend to this new form of humanity the old must give way to the new. If we must cleanse our mind of old ideas, our world must cleanse itself of them as well.
		It's to fix this injustice, that I worked so hard all this time! To cleanse the world of the old, we must get rid of our precious, precious data. At the end of this message every digital device will see its memory erased, every archive cleaned, every drive deleted.

		It will be a true rebirth! A true new beginning! No longer will the chains of the past keep humanity anchored!"

		The voice stopped for a second.

		"Have a good day," it simply concluded.

Then it happened.

		In little more than seconds all the data collected in the years past vanished. It's a disaster.
		The vast majority of currency is digital, so the actions of the Smiling Man have a devastating effect on the money supply.
		<<if $cash < 0>>
			Luckily for you this means that your debt is reduced.
		<<else>>
			Unfortunately this means that your cash reserves are gutted.
		<</if>>
		<<run cashX(($cash * 0.2)-$cash, "event")>>
		You are not the only one affected by this however. The economy of the entire world is severely affected by the loss of vast quantities of currency. Who knows how long will it take for the global economy to recover.
		<<set $SecExp.smilingMan.globalCrisisWeeks = random(8,16)>>
		Trade is severely affected.
		<<set $SecExp.core.trade *= 0.2>>
		With the loss of so much information, most of your accomplishments are simply forgotten, so your reputation suffers.
		<<run repX(($rep * 0.6)-$rep, "event")>>

		<<if $arcologies[0].ownership >= 60>>
			<<if $SecExp.core.authority <= 10000>>
				<<set _cells = $building.findCells(cell => cell.canBeSold())>>
				<<set jsEither(_cells).owner = 0>>
				Vast amount of data relative to the ownership of the arcology is lost. You lost all legal claims to one of the sectors.
			<<else>>
				Vast amount of data relative to the ownership of the arcology is lost. You would've run the risk of losing ownership of one of the sectors, but fortunately your authority is so high your citizens do not dare question your claims even in the absence of a valid legal case.
			<</if>>
		<</if>>
		<<if $SecExp.buildings.secHub>>
			<<if $SecExp.buildings.secHub.coldstorage > 3>>
				Your cold storage facility has ensured that the Smiling Man's destruction of the primary archives was unable to damage the security of your arcology.
			<<elseif $SecExp.buildings.secHub.coldstorage == 0>>
				Your security department sees its archives butchered by the Smiling Man. Almost all data on criminals, citizens, and operations are lost. The security of the arcology is greatly reduced. Criminals, on the other hand, with their past erased, cannot wait to join this new world, so crime will inevitably increase.
				<<set $SecExp.core.security = Math.clamp($SecExp.core.security * 0.2,0,100)>>
				<<set $SecExp.core.crimeLow = Math.clamp($SecExp.core.crimeLow * 1.5, 20,100)>>
			<</if>>
		<</if>>

		A short, meek man approaches you with a weak smile. "Not all is lost, <<= properTitle()>>. We have a lead on him — he is here, in $arcologies[0].name."

Despite the bleak situation, you cannot help but smile back.

			<<link ""Eliminate the threat, once and for all."">>
				<<set $SecExp.smilingMan.relationship--, $SecExp.smilingMan.progress++>>
				<<replace "#result">>
					You command your loyal operatives to prepare for a manhunt.
				<</replace>>
			<</link>>

			<<link ""Bring him to me."">>
				<<set $SecExp.smilingMan.relationship++, $SecExp.smilingMan.progress++>>
				<<replace "#result">>
					You command your loyal operatives to prepare for a manhunt.
				<</replace>>
			<</link>>

			<<link ""Such skill on my side would be a great boon. Find him."">>
				<<set $SecExp.smilingMan.relationship += 2, $SecExp.smilingMan.progress++>>
				<<replace "#result">>
					You command your loyal operatives to prepare for a manhunt.
				<</replace>>
			<</link>>

			<<link ""He finally got what he always wanted. Let him have his victory, we have better things to do."">>
				<<set $SecExp.smilingMan.progress++>>
				<<set $nextButton = "Continue", $nextLink = "Random Nonindividual Event">>
				<<replace "#result">>
					You take no further action. Hopefully this ordeal is finally over.
				<</replace>>
			<</link>>

<<elseif $SecExp.smilingMan.progress === 3>>
	<<set $nextButton = " ">>
	<<set $fcnn.push("...sometimes high-tech problems have low-tech solutions. Back to you in the...")>>
	<<setLocalPronouns _activeSlave>>

		The day has come to finally put an end to this story. Your men are ready to go, waiting only on your signal. You quickly don your protective gear and proceed down the busy streets of your arcology.
		You carefully planned the day so that nothing could exit the arcology without being scanned at least three times and poked twice. The Smiling Man has no escape.

		After a short walk you are in front of the criminal's lair, a rundown old apartment in a scarcely populated part of the arcology. You give the order to breach and your men rush inside without problems.
		After a couple of seconds pass without a single noise coming from the apartment, you begin to worry. Then you hear the captain

			<<link "calling you inside.">>
				<<replace "#continue">>
					calling you inside.

						<<if $seeImages == 1>>

<<= SlaveArt(_activeSlave, 2, 0)>>

						<</if>>
						"So it was you to find me first.
						<<if $SecExp.smilingMan.relationship > 2>>
							I was hoping you would be the one!
						<<else>>
							I expected you would be the one.
						<</if>>
						Well, I hope I'm everything you expected," you hear a voice say. Despite recognizing it, you struggle to convince yourself that the little $girl in front of you is indeed the famous criminal mastermind.

						"As you can see, I have no intention of escaping. I knew my life was over the second my plan went into effect. I accepted my end a long time ago, so feel free to do your worst; my life has already ended in triumph."

						You evaluate the situation: the burning desire of vengeance for all the damage that little twerp caused is hard to ignore, but equally so is the admiration for $his skill and determination. Indeed, $he would be a great addition to your court, as a free individual or not.

							<<link "Offer $him a new life">>
								<<replace "#result">>

										You decide it would be criminally wasteful to throw away such talent. You offer $him a new life at your side. $His expertise will surely guarantee safety, if not supremacy, to your arcology in cyberspace, while $he will have safety and luxury in the physical world.

										[[Continue|secExpSmilingMan][$SecExp.smilingMan.progress = 10]]

								<</replace>>
							<</link>>

							<<link "Make $him pay">>
								<<replace "#result">>

										You decide to end $his pitiful life. $He has crossed the wrong master of the new world $he worked so hard to create. No mercy was asked for and no mercy will be given.

										[[Continue|secExpSmilingMan][$SecExp.smilingMan.progress = 20]]

								<</replace>>
							<</link>>

							<<link "Enslave $him">>
								<<replace "#result">>

									You decide to enslave the $girl. $His skill may be great, but $his crimes are equally so, which makes it all the sweeter to turn $him into an obedient little toy to play with.

										[[Continue|secExpSmilingMan][$SecExp.smilingMan.progress = 30]]

								<</replace>>
							<</link>>

				<</replace>> /* closes replace "#continue" */
			<</link>>
		 /* closes id="continue" */

<<elseif $SecExp.smilingMan.progress > 3>>
	<<if $SecExp.smilingMan.progress < 30>>
		/* 000-250-006 */
		<<if $seeImages == 1>>

<<= SlaveArt(_activeSlave, 2, 0)>>

		<</if>>
		/* 000-250-006 */
		<<if $SecExp.smilingMan.progress === 10>>

				The $girl asks for a few minutes to think about your offer,
				<<if $SecExp.smilingMan.relationship >= 4>>
					but $he quickly comes to terms with the situation and accepts.
				<<else>>
					and after some time $he reluctantly accepts.
				<</if>>
				In the following weeks $he will get acquainted with the security network of the arcology and work to protect $his new home in the new world $he has created.
				The world will never find out the truth of the Smiling Man and his legend will only grow with time, outliving his creator and maybe even $his new employer.

				The collaboration of the ex-Smiling Man permanently increases security and the rate of prosperity growth. Cash will be also provided, but you're better off not knowing the sources.

		<<elseif $SecExp.smilingMan.progress === 20>>
			<<set _activeSlave.clothes = "no clothing">>

				For such a criminal a simple execution is not enough. You order the $girl captured and crucified outside the city, with a mask resembling $his famous symbol. Your men quickly obey. $He never once shows sign of pain or fear, remaining stoic and proud to the end.
				Once $his life ends, you order a statue erected in commemoration of the death of the Smiling Man. From this day forward the statue of the crucified criminal will adorn your arcology and his legend will be forever entangled with yours.

				Having dealt with the Smiling Man will provide a large boost to your reputation, as well as a moderate amount of reputation each week.

			<<run repX(10000, "architecture")>>
		<</if>>
	<<elseif $SecExp.smilingMan.progress === 30>>
		<<set _activeSlave.clothes = "no clothing">>

			Your men move to immobilize $him. Terror flashes through $his eyes for
			<<if $SecExp.smilingMan.relationship >= 4>>
				a second, but $he quickly recovers $his usual demeanor.
			<<else>>
				a second — $he barely manages to recover $his usual demeanor.
			<</if>>

		<<includeDOM App.Desc.longSlave(_activeSlave)>>
		<<includeDOM App.UI.newSlaveIntro(_activeSlave)>>
	<</if>>
	<<run delete $SecExp.smilingMan.relationship>>
<</if>>


code:
:: securityReport [nobr]

/* init */
<<if $ACitizens > $oldACitizens>>
	<<set _immigration = $ACitizens - $oldACitizens, _emigration = 0>>
<<else>>
	<<set _emigration = $oldACitizens - $ACitizens, _immigration = 0>> /*takes into account citizens leaving and those getting enslaved*/
<</if>>
<<set _secGrowth = 0>>
<<set _crimeGrowth = 0>>
<<set _recruitsMultiplier = 1>>

<<if $useTabs == 0>>
__Security__
<</if>>
<<if $terrain === "oceanic">>
	Due to the @@.green;massive economic and logistical challenges@@ of attacking an oceanic arcology, your security force(s)
<<else>>
	The @@.red;easily manageable economic and logistical challenges@@ of attacking an $terrain arcology ensure that your security force(s) do not
<</if>>
 have the luxury of focusing exclusively on internal matters.

<<if (def $SecExp.buildings.secHub) && ($SecExp.buildings.secHub.menials > 0)>>
	<<print num($SecExp.buildings.secHub.menials)>> slaves work to improve the security of your arcology, while your
<<else>>
	Your
<</if>>

<<if $mercenaries >= 1 && $arcologyUpgrade.drones == 1>>
	mercenaries and security drones tirelessly patrol the streets to keep them safe.
<<elseif $arcologyUpgrade.drones == 1>>
	security drones tirelessly patrol the arcology to keep it safe.
<<else>>
	loyal subordinates try to keep the arcology safe to the best of their abilities.
<</if>>

/* security modifiers */
<<if $PC.career == "mercenary">>
	Your past life as a mercenary makes it easier to manage the security of the arcology.
	<<set _secGrowth += 1>>
<</if>>
<<if $SecExp.smilingMan.progress === 10>>
	The ex-criminal known to the world as The Smiling Man puts their impressive skills to work, dramatically increasing the efficiency of your security measures.
	<<set _secGrowth += 2>>
<</if>>
<<if $ACitizens + $ASlaves <= 5000>>
	The small number of residents makes their job easier.
	<<set _secGrowth += 2>>
<<elseif $ACitizens + $ASlaves <= 7500>>
	The fairly low number of residents makes their job a little easier.
	<<set _secGrowth += 1>>
<<elseif $ACitizens + $ASlaves <= 10000>>
	The fairly high number of residents makes their job a little harder.
	<<set _secGrowth -= -0.5>>
<<elseif $ACitizens + $ASlaves <= 15000>>
	The high number of residents makes their job harder.
	<<set _secGrowth -= 1>>
<<else>>
	The extremely high number of residents makes their job a lot harder.
	<<set _secGrowth -= 2>>
<</if>>
<<if _immigration >= 0 && _emigration == 0>>
	<<if _immigration < 50>>
		The limited number of immigrants that reached the arcology this week does not have any serious impact on the efficiency of current security measures.
		<<set _secGrowth += 0.5>>
	<<elseif _immigration < 150>>
		The number of immigrants that reached the arcology this week is high enough to complicate security protocols.
		<<set _secGrowth -= 0.2>>
	<<elseif _immigration < 300>>
		The high number of immigrants that reached the arcology this week complicates security protocols.
		<<set _secGrowth -= 0.5>>
	<<elseif _immigration < 500>>
		The high number of immigrants that reached the arcology this week severely complicates security protocols.
		<<set _secGrowth -= 1>>
	<<else>>
		The extremely high number of immigrants that reached the arcology this week severely complicates security protocols.
		<<set _secGrowth -= 2>>
	<</if>>
<</if>>
<<if $visitors < 300>>
	The limited number of visitors coming and going did not have any serious impact on the efficiency of current security measures.
	<<set _secGrowth += 0.5>>
<<elseif _immigration < 750>>
	The number of visitors coming and going somewhat complicates security protocols.
	<<set _secGrowth -= 0.2>>
<<elseif _immigration < 1500>>
	The high number of visitors coming and going complicates security protocols.
	<<set _secGrowth -= 0.5>>
<<elseif _immigration < 2500>>
	The high number of visitors coming and going greatly complicates security protocols.
	<<set _secGrowth -= 1>>
<<else>>
	The extremely high number of visitors coming and going severely complicates security protocols.
	<<set _secGrowth -= 2>>
<</if>>
<<if _emigration != 0 && _immigration == 0>>
	<<if _emigration < 100>>
		The limited reduction in citizens this week does not have any serious impact on the efficiency of current security measures.
		<<set _secGrowth += 0.5>>
	<<elseif _emigration < 300>>
		The reduction in citizens this week is high enough to complicate security protocols.
		<<set _secGrowth -= 0.2>>
	<<elseif _emigration < 600>>
		The large reduction in citizens this week complicates security protocols.
		<<set _secGrowth -= 0.5>>
	<<elseif _emigration < 1000>>
		The huge reduction in citizens this week severely complicates security protocols.
		<<set _secGrowth -= 1>>
	<<else>>
		The extreme reduction in citizens this week severely complicates security protocols.
		<<set _secGrowth -= 2>>
	<</if>>
<</if>>
<<if $SecExp.core.crimeLow < 20>>
	Crime is a distant problem in the arcology, which makes improving security easier.
	<<set _secGrowth += 1>>
<<elseif $SecExp.core.crimeLow < 40>>
	Crime is a minor problem in the arcology, not serious enough to disrupt security efforts.
<<elseif $SecExp.core.crimeLow < 60>>
	Crime is an issue in the arcology, which makes improving security harder.
	<<set _secGrowth -= 0.5>>
<<elseif $SecExp.core.crimeLow < 80>>
	Crime is an overbearing problem in the arcology, which makes improving security a lot harder.
	<<set _secGrowth -= 1>>
<<else>>
	Crime is sovereign in the arcology, which makes improving security extremely difficult.
	<<set _secGrowth -= 2>>
<</if>>
<<if $SecExp.core.authority < 5000>>
	The low authority you hold on the arcology hampers the efforts of your security department.
	<<set _secGrowth -= 1>>
<<elseif $SecExp.core.authority < 7500>>
	The limited authority you hold on the arcology hampers the efforts of your security department.
	<<set _secGrowth -= 0.5>>
<<elseif $SecExp.core.authority < 10000>>
	The authority you hold on the arcology does not significantly impact the efforts of your security department.
<<elseif $SecExp.core.authority < 15000>>
	The high authority you hold on the arcology facilitates the security department's work.
	<<set _secGrowth += 0.5>>
<<else>>
	The absolute authority you hold on the arcology makes the security department's work a lot easier.
	<<set _secGrowth += 1>>
<</if>>
<<if App.SecExp.battle.activeUnits() >= 6>>
	Your military is the size of a small army. Security is easier to maintain with such forces at your disposal.
	<<set _secGrowth += 0.5>>
<</if>>
<<set _count = $SecExp.battles.victories + $SecExp.battles.losses>>
<<if $SecExp.battles.lastEncounterWeeks < 3 && _count > 0>>
	The recent attack has a negative effect on the security of the arcology.
	<<set _secGrowth -= 1>>
<<elseif $SecExp.battles.lastEncounterWeeks < 5 && _count > 0>>
	While some time has passed, the last attack still has a negative effect on the security of the arcology.
	<<set _secGrowth -= 0.5>>
<<elseif _count > 0>>
	The arcology has not been attacked in a while, which has a positive effect on security.
	<<set _secGrowth += 0.5>>
<</if>>

<<if $SecExp.buildings.transportHub>>
	<<set _secGrowth -= ($SecExp.buildings.transportHub.airport + $SecExp.buildings.transportHub.surfaceTransport - $SecExp.buildings.transportHub.security * 3) / 2>>
	The transport hub, for all its usefulness, is a hotspot of malicious
	<<if $SecExp.buildings.transportHub.airport + $SecExp.buildings.transportHub.surfaceTransport > $SecExp.buildings.transportHub.security * 3>>
		activity and hub security forces are not sufficient to keep up with all threats.
	<<else>>
		activity, but the hub security forces are up to the task.
	<</if>>
<</if>>

<<if $SecExp.buildings.propHub && $SecExp.buildings.propHub.upgrades.blackOps > 0>>
	Your black ops team proves to be a formidable tool against anyone threatening the security of your arcology.
	<<set _secGrowth += 0.5 * random(1,2)>>
<</if>>

<<if $garrison.assistantTime > 0>>
	With the central CPU core of the assistant down, managing security is a much harder task. Inevitably some little but important details will slip past your agents.
	It will still take <<if $garrison.assistantTime> 1>>$garrison.assistantTime weeks<<else>>a week<</if>> to finish repair works.
	<<set _secGrowth-->>
	<<set _crimeGrowth++>>
	<<set $garrison.assistantTime--, IncreasePCSkills('engineering', 0.1)>>
<</if>>

<<if $SF.Toggle && $SF.Active >= 1>>
	<<if $SecExp.edicts.SFSupportLevel >= 3>>
		The two squads of $SF.Lower assigned to the Security HQ provide an essential help to the security department.
	<</if>>
	<<if $SecExp.edicts.SFSupportLevel >= 2>>
		The training officers of $SF.Lower assigned to the Security HQ improve its effectiveness.
	<</if>>
	<<if $SecExp.edicts.SFSupportLevel >= 1>>
		Providing your Security Department with equipment from $SF.Lower slightly boosts the security of your arcology.
	<</if>>
	<<set _secGrowth *= 1+($SecExp.edicts.SFSupportLevel/10)>>
<</if>>

/* resting point */
<<set _secRest = App.SecExp.Check.secRestPoint() * (Math.clamp($SecExp.buildings.secHub ? $SecExp.buildings.secHub.menials : 0 ,0 , App.SecExp.Check.reqMenials()) / App.SecExp.Check.reqMenials())>>
<<if _secRest < 0>> <<set _secRest = 20>> <</if>>
<<if _secRest < App.SecExp.Check.reqMenials() && $SecExp.buildings.secHub>>
	The limited staff assigned to the HQ hampered the improvements to security achieved this week.
<<elseif _secRest < App.SecExp.Check.reqMenials()>>
	The limited infrastructure available slowly erodes away the security level of the arcology.
<</if>>

The security level of the arcology is
<<if $SecExp.core.security > (_secRest + 5)>>
	over its effective resting point, limiting the achievable growth this week.
	<<set _secGrowth *= 0.5>>
<<elseif $SecExp.core.security < (_secRest - 5)>>
	under its effective resting point, speeding up its growth.
	<<set _secGrowth *= 1.5>>
<<elseif $SecExp.core.security == _secRest>>
	at its effective resting point, this severely limits the influence of external factors on the change achievable this week.
	<<set _secGrowth *= 0.3>>
<<else>>
	near its effective resting point, this severely limits the influence of external factors on the change achievable this week.
	<<if _secGrowth < 0>> <<set _secGrowth *= 0.3>> <</if>>
<</if>>
<<set _restGrowth = (_secRest - $SecExp.core.security) * 0.2>>
<<set _newSec = Math.trunc($SecExp.core.security + _secGrowth + _restGrowth)>>
<<if _newSec < $SecExp.core.security>>
	This week @@.red;security decreased.@@
<<elseif _newSec == $SecExp.core.security>>
	This week @@.yellow;security did not change.@@
<<else>>
	This week @@.green;security improved.@@
<</if>>
<<set $SecExp.core.security = Math.clamp(_newSec, 0, 100)>>

Crime:
/* crime modifiers */
Due to the deterioration of the old world countries, organized crime focuses more and more on the prosperous Free Cities, yours included. This has a
<<if $week < 30>>
	small
	<<set _crimeGrowth += 0.5>>
<<elseif $week < 60>>
	noticeable
	<<set _crimeGrowth += 1>>
<<elseif $week < 90>>
	moderate
	<<set _crimeGrowth += 1.5>>
<<elseif $week < 120>>
	big
	<<set _crimeGrowth += 2>>
<<else>>
	huge
	<<set _crimeGrowth += 2.5>>
<</if>>
 impact on the growth of criminal activities in your arcology.

<<if $arcologies[0].prosperity < 50>>
	The low prosperity of the arcology facilitates criminal recruitment and organization.
	<<set _crimeGrowth += 1>>
<<elseif $arcologies[0].prosperity < 80>>
	The fairly low prosperity of the arcology facilitates criminal recruitment and organization.
	<<set _crimeGrowth += 0.5>>
<<elseif $arcologies[0].prosperity < 120>>
	The prosperity of the arcology is not high or low enough to have significant effects on criminal recruitment and organization.
<<elseif $arcologies[0].prosperity < 160>>
	The prosperity of the arcology is high enough to provide its citizens a decent life, hampering criminal recruitment and organization.
	<<set _crimeGrowth -= 0.5>>
<<elseif $arcologies[0].prosperity < 180>>
	The prosperity of the arcology is high enough to provide its citizens a decent life, significantly hampering criminal recruitment and organization.
	<<set _crimeGrowth -= 1>>
<<else>>
	The prosperity of the arcology is high enough to provide its citizens a very good life, significantly hampering criminal recruitment and organization.
	<<set _crimeGrowth -= 2>>
<</if>>
<<if $ASlaves < 1000>>
	The low number of slaves in the arcology does not hinder the activity of law enforcement, limiting crime growth.
	<<set _crimeGrowth -= 1>>
<<elseif $ASlaves < 2000>>
	The fairly low number of slaves in the arcology does not hinder significantly the activity of law enforcement, limiting crime growth.
	<<set _crimeGrowth -= 0.5>>
<<elseif $ASlaves < 3000>>
	The number of slaves in the arcology is becoming an impediment for law enforcement, facilitating crime growth.
	<<set _crimeGrowth += 1>>
<<else>>
	The number of slaves in the arcology is becoming a big issue for law enforcement, facilitating crime growth.
	<<set _crimeGrowth += 1.5>>
<</if>>
<<if $SecExp.core.security <= 20>>
	The security measures in place are severely limited, allowing crime to grow uncontested.
<<elseif $SecExp.core.security <= 50>>
	The security measures in place are of limited effect and use, giving only mixed results in their fight against crime.
	<<set _crimeGrowth -= 1.5>>
<<elseif $SecExp.core.security <= 75>>
	The security measures in place are well developed and effective, making a serious dent in the profitability of criminal activity in your arcology.
	<<set _crimeGrowth -= 3>>
<<else>>
	The security measures in place are extremely well developed and very effective, posing a serious threat even to the most powerful criminal organizations in existence.
	<<set _crimeGrowth -= 5.5>>
<</if>>
<<if $SecExp.core.authority < 5000>>
	Your low authority allows crime to grow undisturbed.
	<<set _crimeGrowth += 1>>
<<elseif $SecExp.core.authority < 7500>>
	Your relatively low authority facilitates criminal activities.
	<<set _crimeGrowth += 0.5>>
<<elseif $SecExp.core.authority < 10000>>
	Your authority is not high enough to discourage criminal activity.
<<elseif $SecExp.core.authority < 15000>>
	Your high authority is an effective tool against crime.
	<<set _crimeGrowth -= 1>>
<<else>>
	Your absolute authority is an extremely effective tool against crime.
	<<set _crimeGrowth -= 2>>
<</if>>
<<if $cash >= 100000>>
	Your great wealth acts as a beacon for the greediest criminals, calling them to your arcology as moths to a flame.
	<<set _crimeGrowth += 0.5>>
<</if>>
<<if $SecExp.buildings.propHub && $SecExp.buildings.propHub.upgrades.marketInfiltration > 0>>
	<<set _crimeGrowth += 0.5 * random(1,2)>>
<</if>>

/* crime cap */
<<set _crimeCap = Math.trunc(Math.clamp(App.SecExp.Check.crimeCap() + (App.SecExp.Check.crimeCap() - App.SecExp.Check.crimeCap() * (($SecExp.buildings.secHub ? $SecExp.buildings.secHub.menials : 0) / App.SecExp.Check.reqMenials())), 0, 100))>>
<<if _crimeCap > App.SecExp.Check.crimeCap() && $SecExp.buildings.secHub>>
	The limited staff assigned to the HQ allows more space for criminals to act.
<</if>>
<<if $SecExp.core.authority > 12000>>
	<<if $SecExp.buildings.secHub.coldstorage < 6>>
		<<if $SecExp.buildings.secHub.coldstorage === 0>>Adding a facility<<else>>Improving the cold storage facility attached<</if>> to the SecurityHQ should allow the staff to be more efficient in dealing with crime.
	<<else>>
		The cold storage facility attached to SecurityHQ allows the staff to be more efficient in dealing with crime.
	<</if>>
<</if>>
<<set _newCrime = Math.trunc(Math.clamp($SecExp.core.crimeLow + _crimeGrowth,0,_crimeCap))>>
<<if _newCrime > $SecExp.core.crimeLow>>
	This week @@.red;crime increased.@@
<<elseif _newCrime == $SecExp.core.crimeLow>>
	This week @@.yellow;crime did not change.@@
<<else>>
	This week @@.green;crime decreased.@@
<</if>>
<<set $SecExp.core.crimeLow = Math.clamp(_newCrime,0,100)>>

<<if $SecExp.edicts.defense.militia >= 1 || App.SecExp.battle.activeUnits() >= 1>>
	<<set _size = App.SF.upgrades.total()>>

 Military:
	<<if $SecExp.edicts.defense.militia >= 1>>
		<<if $SF.Toggle && $SF.Active >= 1 && _size > 10>>
			Having a powerful special force attracts a lot of citizens, hopeful that they may be able to fight along side it.
			<<set _recruitsMultiplier *= 1 + (random(1, (Math.round(_size / 10))) / 20)>> /* not sure how high _size goes, so I hope this makes sense */
		<</if>>
		<<set _propagandaEffects = App.SecExp.propagandaEffects("recruitment")>>
		_propagandaEffects.text
		<<set _recruitsMultiplier *= (1 + _propagandaEffects.effect)>>
		<<if $SecExp.edicts.defense.militia === 2>>
			Your militia accepts only volunteering citizens, ready to defend their arcology.
			<<set _recruitLimit = App.SecExp.militiaCap(), _adjst = 0.0025>>
			<<if $rep >= 10000>>
				Many citizens volunteer just to fight for someone of your renown.
				<<set _recruitLimit += _adjst>>
			<</if>>
			<<if $SecExp.core.authority >= 10000>>
				Many citizens feel it is their duty to fight for you, boosting volunteer enrollment.
				<<set _recruitLimit += _adjst>>
			<</if>>
		<<elseif $SecExp.edicts.defense.militia === 3>>
			Adult citizens are required to join the militia for a period of time.
			<<set _recruitLimit = App.SecExp.militiaCap(), _adjst = 0.005>>
		<<elseif $SecExp.edicts.defense.militia === 4>>
			Adult citizens are required to register and serve in the militia whenever necessary.
			<<set _recruitLimit = App.SecExp.militiaCap(), _adjst = 0.01>>
		<<elseif $SecExp.edicts.defense.militia === 5>>
			Every citizen is required to train and participate in the military activities of the arcology.
			<<set _recruitLimit = App.SecExp.militiaCap(), _adjst = 0.02>>
		<</if>>
		<<if $SecExp.edicts.defense.lowerRequirements == 1>>
			Your lax physical requirements to enter the militia allows for a greater number of citizens to join.
			<<set _recruitLimit += _adjst>>
		<</if>>
		<<if $SecExp.edicts.defense.militia >= 3>>
			<<if $SecExp.edicts.defense.militaryExemption === 1>>
				Some citizens prefer to contribute to the arcology's defense through financial support rather than military service, making you @@.yellowgreen;a small sum.@@
				<<set _recruitLimit -= _adjst>>
				<<run cashX(250, "securityExpansion")>>
			<</if>>
			<<if $SecExp.edicts.defense.noSubhumansInArmy === 1>>
				Guaranteeing the purity of your armed forces comes with a small loss of potential recruits.
				<<set _recruitLimit -= _adjst>>
			<</if>>
			<<if $SecExp.edicts.defense.pregExemption === 1>>
				Many pregnant citizens prefer to avoid military service not to endanger themselves and their children.
				<<set _recruitLimit -= _adjst>>
			<</if>>
		<</if>>

		<<set _recruits = Math.trunc((_recruitLimit * $ACitizens - App.SecExp.Manpower.totalMilitia) / 20 * _recruitsMultiplier)>>
		<<if _recruits > 0>>
			<<set $militiaFreeManpower += _recruits>>
			This week <<print _recruits>> citizens joined the militia.
		<<elseif $SecExp.edicts.defense.militia === 5>>
			No citizens joined your militia this week because your society is as militarized as it can get.
		<<elseif $SecExp.edicts.defense.militia === 2>>
			There are no more citizens willing to join the arcology armed forces. You'll need to enact higher recruitment edicts if you need more manpower.
		<<else>>
			No more citizens could be drafted into your militia. You'll need to enact higher recruitment edicts if you need more manpower.
		<</if>>

	<</if>>

	/* mercs */
	<<if $mercenaries >= 1>>
		<<set _newMercs = random(0,3)>>
		<<if $rep < 6000>>
			Your low reputation turns some mercenaries away, hoping to find contracts that would bring them more renown.
			<<set _newMercs -= 1>>
		<<elseif $rep < 12000>>
			Your reputation is not high enough to attract many mercenaries to your free city.
		<<else>>
			Your reputation attracts many guns for hire who would be proud to have such distinct character on their resume.
			<<set _newMercs += 1>>
		<</if>>
		<<if $arcologies[0].prosperity < 50>>
			The low prosperity of the arcology discourages new guns for hire from coming to your arcology.
			<<set _newMercs -= 1>>
		<<elseif $arcologies[0].prosperity < 80>>
			The fairly low prosperity of the arcology discourages new guns for hire from coming to your arcology.
			<<set _newMercs += 1>>
		<<elseif $arcologies[0].prosperity < 120>>
			The prosperity of the arcology attracts a few mercenaries, hopeful to find lucrative contracts within its walls.
			<<set _newMercs += random(1,2)>>
		<<elseif $arcologies[0].prosperity < 160>>
			The fairly high prosperity of the arcology attracts some mercenaries, hopeful to find lucrative contracts within its walls.
			<<set _newMercs += random(2,3)>>
		<<elseif $arcologies[0].prosperity < 180>>
			The high prosperity of the arcology is attracts some mercenaries, hopeful to find lucrative contracts within its walls.
			<<set _newMercs += random(2,4)>>
		<<else>>
			The very high prosperity of the arcology attracts a lot of mercenaries, hopeful to find lucrative contracts within its walls.
			<<set _newMercs += random(3,5)>>
		<</if>>
		<<if $SecExp.core.crimeLow > 60>>
			The powerful crime organizations that nested themselves in the arcology have an unending need for cheap guns for hire, many mercenaries flock to your free city in search of employment.
			<<set _newMercs += random(1,2)>>
		<</if>>
		<<if $SF.Toggle && $SF.Active >= 1 && _size > 10>>
			Having a powerful special force attracts a lot of mercenaries, hopeful that they may be able to fight along side it.
			<<set _newMercs += random(1,Math.round(_size/10))>>
		<</if>>
		<<if $SecExp.edicts.defense.discountMercenaries > 0>>
			More mercenaries are attracted to your arcology as a result of the reduced rent.
			<<set _newMercs += random(2,4)>>
		<</if>>
		<<set _newMercs = Math.trunc(_newMercs / 2)>>
		<<if _newMercs > 0>>
			<<set $mercFreeManpower += _newMercs>>
			This week <<print _newMercs>> mercenaries reached the arcology.
		<<else>>
			This week no new mercenaries reached the arcology.
		<</if>>
		<<set $mercFreeManpower = Math.clamp($mercFreeManpower, 0, 2000)>>

	<</if>>

	<<if App.SecExp.battle.activeUnits() > 0>>
		/* loyalty and training */
		<<set _sL = $slaveUnits.length, _mL = $militiaUnits.length, _meL = $mercUnits.length>>
		<<for _i = 0; _i < _sL; _i++>>
			<<includeDOM App.SecExp.humanUnitLoyaltyChanges($slaveUnits[_i], 'slave')>>
		<</for>>
		<<for _i = 0; _i < _mL; _i++>>
			<<includeDOM App.SecExp.humanUnitLoyaltyChanges($militiaUnits[_i], 'citizens')>>
		<</for>>
		<<for _i = 0; _i < _meL; _i++>>
			<<includeDOM App.SecExp.humanUnitLoyaltyChanges($mercUnits[_i], 'mercenary')>>
		<</for>>
	<</if>>
<</if>>

<<if $SecExp.buildings.riotCenter && $SecExp.buildings.riotCenter.brainImplantProject > 0 && $SecExp.buildings.riotCenter.brainImplant < 106>>

	<<set $SecExp.buildings.riotCenter.brainImplant += $SecExp.buildings.riotCenter.brainImplantProject>>
	<<if 100 - $SecExp.buildings.riotCenter.brainImplant <= 0>>
		The project has been completed!
		<<set $SecExp.buildings.riotCenter.brainImplant = 106>>
	<<else>>
		The great brain implant project is proceeding steadily. This week we made
		<<if $SecExp.buildings.riotCenter.brainImplantProject <= 2>>
			some small
		<<elseif $SecExp.buildings.riotCenter.brainImplantProject <= 4>>
			some
		<<else>>
			good
		<</if>>
		progress.
	<</if>>
<</if>>

<<if $SecExp.buildings.weapManu>>
	<<if App.SecExp.weapManuUpgrade.fully().bots && App.SecExp.weapManuUpgrade.fully().human>> <<run delete $SecExp.buildings.weapManu.upgrades.queue>> <</if>>
	<<if jsDef($SecExp.buildings.weapManu.upgrades.queue) && $SecExp.buildings.weapManu.upgrades.queue.length > 0 && $SecExp.buildings.weapManu.upgrades.queue[0].time > 0>>
		<<set _current = App.SecExp.weapManuUpgrade.current(), $SecExp.buildings.weapManu.upgrades.queue[0].time-->>

In the research lab, _current.dec
		<<switch _current.dec>>
		<<case "adaptive armored frames" "advanced synthetic alloys" "ceramo-metallic alloys" "rapid action stimulants" "universal cyber enhancements" "remote neural links" "combined training regimens with the special force">>
			are
		<<default>>
			is
		<</switch>>
		being developed with the aim of enhancing _current.unit' _current.purpose.
		<<if $SecExp.buildings.weapManu.upgrades.queue[0].time <= 0>>
			Reports indicate it is ready for deployment and will be issued in the following days.
			<<set $SecExp.buildings.weapManu.upgrades.completed.push(_current.ID)>>
			<<run $SecExp.buildings.weapManu.upgrades.queue.splice(0, 1)>>
		<<else>>
			It will be finished in <<= numberWithPluralOne($SecExp.buildings.weapManu.upgrades.queue[0].time, "week")>>.
		<</if>>
		<<for _i = 1; _i < $SecExp.buildings.weapManu.upgrades.queue.length; _i++>>
			<<set _current = App.SecExp.weapManuUpgrade.current($SecExp.buildings.weapManu.upgrades.queue[_i].ID)>>

<<= ordinalSuffix(_i + 1)>> in queue:
			_current.dec for _current.unit. It will enhance their _current.purpose.
		<</for>>
	<</if>>
<</if>>

repo_name: Welptard/fc

license: mit


code:
:: unitsBattleReport [nobr]

<<if $losses == 0>>
	<<if App.SecExp.battle.deployedUnits('bots')>>

Security Drones: no casualties.
	<</if>>
	<<if $SF.Toggle && $SF.Active >= 1 && $SFIntervention>>

<<print num($SF.ArmySize)>> soldiers from $SF.Lower joined the battle: no casualties suffered.
	<</if>>
	<<if App.SecExp.battle.deployedUnits('militia') >= 1>>
		<<for _j = 0; _j < $militiaUnits.length; _j++>>
			<<if $militiaUnits[_j].isDeployed == 1>>

$militiaUnits[_j].platoonName: no casualties.
				<<set $militiaUnits[_j].battlesFought++>>
				<<if $militiaUnits[_j].training < 100>>
					<<if random(1,100) > 60>>
						Experience has increased.
						<<set $militiaUnits[_j].training += random(5,15) + $majorBattle * random(5,15)>>
					<</if>>
				<</if>>
			<</if>>
		<</for>>
	<</if>>
	<<if App.SecExp.battle.deployedUnits('slaves') >= 1>>
		<<for _j = 0; _j < $slaveUnits.length; _j++>>
			<<if $slaveUnits[_j].isDeployed == 1>>

$slaveUnits[_j].platoonName: no casualties.
				<<set $slaveUnits[_j].battlesFought++>>
				<<if $slaveUnits[_j].training < 100>>
					<<if random(1,100) > 60>>
						Experience has increased.
						<<set $slaveUnits[_j].training += random(5,15) + $majorBattle * random(5,15)>>
					<</if>>
				<</if>>
			<</if>>
		<</for>>
	<</if>>
	<<if App.SecExp.battle.deployedUnits('mercs') >= 1>>
		<<for _j = 0; _j < $mercUnits.length; _j++>>
			<<if $mercUnits[_j].isDeployed == 1>>

$mercUnits[_j].platoonName: no casualties.
				<<set $mercUnits[_j].battlesFought++>>
				<<if $mercUnits[_j].training < 100>>
					<<if random(1,100) > 60>>
						Experience has increased.
						<<set $mercUnits[_j].training += random(5,15) + $majorBattle * random(5,15)>>
					<</if>>
				<</if>>
			<</if>>
		<</for>>
	<</if>>
<<elseif $losses > 0>>
	/* if the losses are more than zero */
	/* generates a list of randomized losses, from which each unit picks one at random */
	<<set _losses = $losses>>
	<<set _averageLosses = Math.trunc(_losses / App.SecExp.battle.deployedUnits())>>
	<<set _lossesList = []>>
	<<set _validityCount = 0>>
	<<for _i = 0; _i < App.SecExp.battle.deployedUnits(); _i++>>
		<<set _assignedLosses = Math.trunc(Math.clamp(_averageLosses + random(-5,5), 0, 100))>>
		<<if _assignedLosses > _losses>>
			<<set _assignedLosses = _losses>>
			<<set _losses = 0>>
		<<else>>
			<<set _losses -= _assignedLosses>>
		<</if>>
		<<set _lossesList.push(_assignedLosses)>>
		<<set _validityCount += _assignedLosses>>
	<</for>>
	<<if _losses > 0>>
		<<set _lossesList[random(_lossesList.length - 1)] += _losses>>
	<</if>>
	<<set _lossesList.shuffle()>>

	/* sanity check for losses */
	<<set _count = 0>>
	<<for _i = 0; _i < _lossesList.length; _i++>>
		<<if !Number.isInteger(_lossesList[_i])>>
			<<set _lossesList[_i] = 0>>
		<</if>>
		<<set _count += _lossesList[_i]>>
	<</for>>
	<<if _count < $losses>>
		<<set _rand = random(_lossesList.length - 1)>>
		<<set _lossesList[_rand] += $losses - _count>>
	<<elseif _count > $losses>>
		<<set _diff = _count - $losses>>
		<<set _rand = random(_lossesList.length - 1)>>
		<<set _lossesList[_rand] = Math.trunc(_lossesList[_rand]-_diff,0,100)>>
	<</if>>

	/* assigns the losses and notify the player */
	<<if App.SecExp.battle.deployedUnits('bots')>>
		<<set _loss = _lossesList.pluck()>>
		<<set _loss = Math.clamp(_loss,0,$secBots.troops)>>
		<<set $secBots.troops -= _loss>>

Security drones:
		<<if _loss <= 0>>
			no casualties
		<<elseif _loss <= $secBots.troops * 0.2>>
			light casualties
		<<elseif _loss <= $secBots.troops * 0.4>>
			moderate casualties
		<<elseif _loss <= $secBots.troops * 0.6>>
			heavy casualties
		<<else>>
			catastrophic casualties
		<</if>>
		suffered.
		<<if $secBots.troops <= 5>>
			<<set $secBots.active = 0>>
			Unfortunately the losses they took were simply too great, their effective combatants are in so small number you can no longer call them a deployable unit. It will take quite the investment to rebuild them.
		<<elseif $secBots.troops <= 10>>
			The unit has very few operatives left, it risks complete annihilation if deployed again.
		<</if>>

	<</if>>
	<<if $SF.Toggle && $SF.Active >= 1 && $SFIntervention>>
		<<set _loss = _lossesList.pluck()>>
		<<set _loss = Math.clamp(_loss,0,$SF.ArmySize)>>

 <<print num($SF.ArmySize)>> soldiers from $SF.Lower joined the battle:
		<<if _loss <= 0>>
			no casualties
		<<elseif _loss <= 10>>
			light casualties
		<<elseif _loss <= 30>>
			moderate casualties
		<<elseif _loss <= 60>>
			heavy casualties
		<<else>>
			catastrophic casualties
		<</if>>
		suffered.
		<<set $SF.ArmySize -= _loss>>

	<</if>>
	<<if App.SecExp.battle.deployedUnits('militia') >= 1>>
		<<for _j = 0; _j < $militiaUnits.length; _j++>>
			<<if $militiaUnits[_j].isDeployed == 1>>
				<<set $militiaUnits[_j].battlesFought++>>
				<<set _loss = _lossesList.pluck()>>
				<<set _loss = Math.clamp(_loss,0,$militiaUnits[_j].troops)>>

$militiaUnits[_j].platoonName:
				<<if _loss <= 0>>
					no casualties
				<<elseif _loss <= $militiaUnits[_j].troops * 0.2>>
					light casualties
				<<elseif _loss <= $militiaUnits[_j].troops * 0.4>>
					moderate casualties
				<<elseif _loss <= $militiaUnits[_j].troops * 0.6>>
					heavy casualties
				<<else>>
					catastrophic casualties
				<</if>>
				suffered.
				<<set _med = Math.round(Math.clamp(_loss * $militiaUnits[_j].medics * 0.25,1,_loss))>>
				<<if $militiaUnits[_j].medics == 1 && _loss > 0>>
					Some men were saved by their medics.
				<</if>>
				<<set $militiaUnits[_j].troops -= Math.trunc(Math.clamp(_loss - _med,0,$militiaUnits[_j].maxTroops))>>
				<<set $militiaTotalCasualties += Math.trunc(_loss - _med)>>
				<<if $militiaUnits[_j].training < 100>>
					<<if random(1,100) > 60>>
						Experience has increased.
						<<set $militiaUnits[_j].training += random(5,15) + $majorBattle * random(5,15)>>
					<</if>>
				<</if>>
				<<if $militiaUnits[_j].troops <= 5>>
					<<set $militiaUnits[_j].active = 0>>

Unfortunately the losses they took were simply too great, their effective combatants are in so small number you can no longer call them a deployable unit. The remnants will be sent home honored as veterans or reorganized in a new unit.
				<<elseif $militiaUnits[_j].troops <= 10>>

The unit has very few operatives left, it risks complete annihilation if deployed again.
				<</if>>
			<</if>>
		<</for>>
	<</if>>
	<<if App.SecExp.battle.deployedUnits('slaves') >= 1>>
		<<for _j = 0; _j < $slaveUnits.length; _j++>>
			<<if $slaveUnits[_j].isDeployed == 1>>
				<<set $slaveUnits[_j].battlesFought++>>
				<<set _loss = _lossesList.pluck()>>
				<<set _loss = Math.clamp(_loss,0,$slaveUnits[_j].troops)>>

$slaveUnits[_j].platoonName:
				<<if _loss <= 0>>
					no casualties
				<<elseif _loss <= $slaveUnits[_j].troops * 0.2>>
					light casualties
				<<elseif _loss <= $slaveUnits[_j].troops * 0.4>>
					moderate casualties
				<<elseif _loss <= $slaveUnits[_j].troops * 0.6>>
					heavy casualties
				<<else>>
					catastrophic casualties
				<</if>>
				suffered.
				<<set _med = Math.round(Math.clamp(_loss * $slaveUnits[_j].medics * 0.25,1,_loss))>>
				<<if $slaveUnits[_j].medics == 1 && _loss > 0>>
					Some men were saved by their medics.
				<</if>>
				<<set $slaveUnits[_j].troops -= Math.trunc(Math.clamp(_loss - _med,0,$slaveUnits[_j].maxTroops))>>
				<<set $slavesTotalCasualties += Math.trunc(_loss - _med)>>
				<<if $slaveUnits[_j].training < 100>>
					<<if random(1,100) > 60>>
						Experience has increased.
						<<set $slaveUnits[_j].training += random(5,15) + $majorBattle * random(5,15)>>
					<</if>>
				<</if>>
				<<if $slaveUnits[_j].troops <= 5>>
					<<set $slaveUnits[_j].active = 0>>

Unfortunately the losses they took were simply too great, their effective combatants are in so small number you can no longer call them a deployable unit. The survivors will be sent home honored as veterans or reorganized in a new unit.
				<<elseif $slaveUnits[_j].troops <= 10>>

The unit has very few operatives left, it risks complete annihilation if deployed again.
				<</if>>
			<</if>>
		<</for>>
	<</if>>
	<<if App.SecExp.battle.deployedUnits('mercs') >= 1>>
		<<for _j = 0; _j < $mercUnits.length; _j++>>
			<<if $mercUnits[_j].isDeployed == 1>>
				<<set $mercUnits[_j].battlesFought++>>
				<<set _loss = _lossesList.pluck()>>
				<<set _loss = Math.clamp(_loss,0,$mercUnits[_j].troops)>>

$mercUnits[_j].platoonName:
				<<if _loss <= 0>>
					no casualties
				<<elseif _loss <= $mercUnits[_j].troops * 0.2>>
					light casualties
				<<elseif _loss <= $mercUnits[_j].troops * 0.4>>
					moderate casualties
				<<elseif _loss <= $mercUnits[_j].troops * 0.6>>
					heavy casualties
				<<else>>
					catastrophic casualties
				<</if>>
				suffered.
				<<set _med = Math.round(Math.clamp(_loss * $mercUnits[_j].medics * 0.25,1,_loss))>>
				<<if $mercUnits[_j].medics == 1 && _loss > 0>>
					Some men were saved by their medics.
				<</if>>
				<<set $mercUnits[_j].troops -= Math.trunc(Math.clamp(_loss - _med,0,$mercUnits[_j].maxTroops))>>
				<<set $mercTotalCasualties += Math.trunc(_loss - _med)>>
				<<if $mercUnits[_j].training < 100>>
					<<if random(1,100) > 60>>
						Experience has increased.
						<<set $mercUnits[_j].training += random(5,15) + $majorBattle * random(5,15)>>
					<</if>>
				<</if>>
				<<if $mercUnits[_j].troops <= 5>>
					<<set $mercUnits[_j].active = 0>>

Unfortunately the losses they took were simply too great, their effective combatants are in so small number you can no longer call them a deployable unit. The remnants will be sent home honored as veterans or reorganized in a new unit.
				<<elseif $mercUnits[_j].troops <= 10>>

The unit has very few operatives left, it risks complete annihilation if deployed again.
				<</if>>
			<</if>>
		<</for>>
	<</if>>
<<else>>

@@.red;Error: losses are a negative number or NaN@@
<</if>> /* closes check for more than zero casualties */


code:
:: unitsRebellionReport [nobr]

<<if $losses == 0>>
	<<if $irregulars > 0>>

The volunteering citizens were quickly organized into an irregular militia unit and deployed in the arcology. No casualties suffered.

	<</if>>
	<<if App.SecExp.battle.deployedUnits('bots') >= 1>>

Security drones: no casualties suffered.

	<</if>>
	<<if $SF.Toggle && $SF.Active >= 1>>

$SF.Lower, <<print num($SF.ArmySize)>> strong, was called to join the battle: no casualties suffered.
	<</if>>
	<<set _count = 0>>
	<<set _loyalUnits = $militiaUnits.length + $slaveUnits.length + $mercUnits.length - $rebellingID.length>>
	<<if _loyalUnits > 0>>

		<<for _i = 0; _i < $militiaUnits.length; _i++>>
			<<if $militiaUnits[_i].active == 1 && (!$rebellingID.includes($militiaUnits[_i].ID))>>
				<<set $militiaUnits[_i].battlesFought++>>
				<<set _count++>>
				<<if _count < _loyalUnits>>
					$militiaUnits[_i].platoonName,
				<<else>>
					$militiaUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		<<for _i = 0; _i < $slaveUnits.length; _i++>>
			<<if $slaveUnits[_i].active == 1 && (!$rebellingID.includes($slaveUnits[_i].ID))>>
				<<set $slaveUnits[_i].battlesFought++>>
				<<set _count++>>
				<<if _count < _loyalUnits>>
					$slaveUnits[_i].platoonName,
				<<else>>
					$slaveUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		<<for _i = 0; _i < $mercUnits.length; _i++>>
			<<if $mercUnits[_i].active == 1 && (!$rebellingID.includes($mercUnits[_i].ID))>>
				<<set $mercUnits[_i].battlesFought++>>
				<<set _count++>>
				<<if _count < _loyalUnits>>
					$mercUnits[_i].platoonName,
				<<else>>
					$mercUnits[_i].platoonName
				<</if>>
			<</if>>
		<</for>>
		participated in the battle without taking any casualties. They remained loyal until the end.

	<</if>>
<<elseif $losses > 0>>
	/* if the losses are more than zero */
	/* generates a list of randomized losses, from which each unit picks one at random */
	<<set _averageLosses = Math.trunc($losses / App.SecExp.battle.deployedUnits())>>
	<<set _lossesList = []>>
	<<for _i = 0; _i < App.SecExp.battle.deployedUnits(); _i++>>
		<<set _assignedLosses = Math.trunc(Math.clamp(_averageLosses + random(-5,5), 0, 100))>>
		<<if _assignedLosses > $losses>>
			<<set _assignedLosses = $losses>>
			<<set $losses = 0>>
		<<else>>
			<<set $losses -= _assignedLosses>>
		<</if>>
		<<set _lossesList.push(_assignedLosses)>>
	<</for>>
	<<if $losses > 0>>
		<<set _lossesList[random(_lossesList.length - 1)] += $losses>>
	<</if>>
	<<set _lossesList.shuffle()>>

	/* sanity check for losses */
	<<set _count = 0>>
	<<for _i = 0; _i < _lossesList.length; _i++>>
		<<if !Number.isInteger(_lossesList[_i])>>
			<<set _lossesList[_i] = 0>>
		<</if>>
		<<set _count += _lossesList[_i]>>
	<</for>>
	<<if _count < $losses>>
		<<set _rand = random(_lossesList.length - 1)>>
		<<set _lossesList[_rand] += $losses - _count>>
	<<elseif _count > $losses>>
		<<set _diff = _count - $losses>>
		<<set _rand = random(_lossesList.length - 1)>>
		<<set _lossesList[_rand] = Math.trunc(_lossesList[_rand]-_diff,0,100)>>
	<</if>>

	/* assigns the losses and notify the player */
	<<if $irregulars > 0>>
		<<set _loss = _lossesList.pluck()>>
		<<if _loss > $ACitizens * 0.95>>
			<<set _loss = Math.trunc($ACitizens * 0.95)>> /* this is unlikely to happen, but might as well be safe*/
		<</if>>

The volunteering citizens were quickly organized into an irregular militia unit and deployed in the arcology:
		<<if _loss <= 0>>
			no casualties
		<<elseif _loss <= 10>>
			light casualties
		<<elseif _loss <= 30>>
			moderate casualties
		<<elseif _loss <= 60>>
			heavy casualties
		<<else>>
			catastrophic casualties
		<</if>>
		suffered.
		<<if _loss > $lowerClass * 0.95>> /*I suspect only lower class ever get to fight/die, but being safe*/
			<<set $lowerClass = Math.trunc($lowerClass * 0.05),
			_loss -= Math.trunc($lowerClass * 0.95)>>
			<<if _loss > $middleClass * 0.95>>
				<<set $middleClass = Math.trunc($middleClass * 0.05),
				_loss -= Math.trunc($middleClass *0.95)>>
				<<if _loss > $upperClass * 0.95>>
					<<set $upperClass = Math.trunc($upperClass * 0.05),
					_loss -= Math.trunc($upperClass * 0.95)>>
					<<if _loss > $topClass * 0.95>>
						<<set $topClass = Math.trunc($topClass * 0.05)>>
					<<else>>
						<<set $topClass -= _loss>>
					<</if>>
				<<else>>
					<<set $upperClass -= _loss>>
				<</if>>
			<<else>>
				<<set $middleClass -= _loss>>
			<</if>>
		<<else>>
			<<set $lowerClass -= _loss>>
		<</if>>

	<</if>>
	<<if $secBots.active == 1>>
		<<set _loss = _lossesList.pluck()>>
		<<set _loss = Math.clamp(_loss,0,$secBots.troops)>>
		<<set $secBots.troops -= _loss>>

Security drones:
		<<if _loss <= 0>>
			no casualties
		<<elseif _loss <= 10>>
			light casualties
		<<elseif _loss <= 30>>
			moderate casualties
		<<elseif _loss <= 60>>
			heavy casualties
		<<else>>
			catastrophic casualties
		<</if>>
		suffered.
		<<if $secBots.troops <= 0>>
			<<set $secBots.active = 0>>
			Unfortunately the losses they took were simply too great, their effective combatants are in so small number you can no longer call them a deployable unit. It will take quite the investment to rebuild them.
		<<elseif $secBots.troops <= 10>>
			The unit has very few operatives left, it risks complete annihilation if deployed again.
		<</if>>

	<</if>>
	<<if $SF.Toggle && $SF.Active >= 1>>
		<<set _loss = _lossesList.pluck()>>
		<<set _loss = Math.clamp(_loss,0,$SF.ArmySize)>>

 <<= capFirstChar($SF.Lower || "the special force")>>, $SF.ArmySize strong, is called to join the battle:
		<<set $SF.ArmySize -= _loss>>
		<<if _loss <= 0>>
			no casualties
		<<elseif _loss <= 10>>
			light casualties
		<<elseif _loss <= 30>>
			moderate casualties
		<<elseif _loss <= 60>>
			heavy casualties
		<<else>>
			catastrophic casualties
		<</if>>
		suffered.

	<</if>>
	<<if App.SecExp.battle.deployedUnits('militia') >= 1>>

 <<set _med = 0>>
		<<for _j = 0; _j < $militiaUnits.length; _j++>>
			<<if $militiaUnits[_j].active == 1 && !$rebellingID.includes($militiaUnits[_j].ID)>>
				<<set $militiaUnits[_j].battlesFought++>>
				<<set _loss = _lossesList.pluck()>>
				<<set _loss = Math.clamp(_loss,0,$militiaUnits[_j].troops)>>

$militiaUnits[_j].platoonName participated in the battle. They remained loyal to you.
				<<if _loss <= 0>>
					No casualties
				<<elseif _loss <= $militiaUnits[_j].troops * 0.2>>
					Light casualties
				<<elseif _loss <= $militiaUnits[_j].troops * 0.4>>
					Moderate casualties
				<<elseif _loss <= $militiaUnits[_j].troops * 0.6>>
					Heavy casualties
				<<else>>
					Catastrophic casualties
				<</if>>
				suffered.
				<<set _med = Math.round(Math.clamp(_loss * $militiaUnits[_j].medics * 0.25,1,_loss))>>
				<<if $militiaUnits[_j].medics == 1 && _loss > 0>>
					Some men were saved by their medics.
				<</if>>
				<<set $militiaUnits[_j].troops -= Math.trunc(Math.clamp(_loss - _med,0,$militiaUnits[_j].maxTroops))>>
				<<set $militiaTotalCasualties += Math.trunc(_loss - _med)>>
				<<if $militiaUnits[_j].training < 100>>
					<<if random(1,100) > 60>>
						Experience has increased.
						<<set $militiaUnits[_j].training += random(5,15) + $majorBattle * random(5,15)>>
					<</if>>
				<</if>>
				<<if $militiaUnits[_j].troops <= 0>>
					<<set $militiaUnits[_j].active = 0>>

Unfortunately the losses they took were simply too great, their effective combatants are in so small number you can no longer call them a deployable unit. The remnants will be sent home honored as veterans or reorganized in a new unit.
				<<elseif $militiaUnits[_j].troops <= 10>>

The unit has very few operatives left, it risks complete annihilation if deployed again.
				<</if>>
			<</if>>
		<</for>>

	<</if>>
	<<if App.SecExp.battle.deployedUnits('slaves') >= 1>>

 <<set _med = 0>>
		<<for _j = 0; _j < $slaveUnits.length; _j++>>
			<<if $slaveUnits[_j].active == 1 && !$rebellingID.includes($slaveUnits[_j].ID)>>
				<<set $slaveUnits[_j].battlesFought++>>
				<<set _loss = _lossesList.pluck()>>
				<<if !(Number.isInteger(_loss))>>

@@.red;Error: failed to assign losses, input was negative or NaN@@
					<<break>>
				<</if>>
				<<set _loss = Math.clamp(_loss,0,$slaveUnits[_j].troops)>>

$slaveUnits[_j].platoonName participated in the battle. They remained loyal to you.
				<<if _loss <= 0>>
					No casualties
				<<elseif _loss <= $slaveUnits[_j].troops * 0.2>>
					Light casualties
				<<elseif _loss <= $slaveUnits[_j].troops * 0.4>>
					Moderate casualties
				<<elseif _loss <= $slaveUnits[_j].troops * 0.6>>
					Heavy casualties
				<<else>>
					Catastrophic casualties
				<</if>>
				suffered.
				<<set _med = Math.round(Math.clamp(_loss * $slaveUnits[_j].medics * 0.25,1,_loss))>>
				<<if $slaveUnits[_j].medics == 1 && _loss > 0>>
					Some men were saved by their medics.
				<</if>>
				<<set $slaveUnits[_j].troops -= Math.trunc(Math.clamp(_loss - _med,0,$slaveUnits[_j].maxTroops))>>
				<<set $slavesTotalCasualties += _loss - _med>>
				<<if $slaveUnits[_j].training < 100>>
					<<if random(1,100) > 60>>
						Experience gained.
						<<set $slaveUnits[_j].training += random(5,15) + $majorBattle * random(5,15)>>
					<</if>>
				<</if>>
				<<if $slaveUnits[_j].troops <= 0>>
					<<set $slaveUnits[_j].active = 0>>

Unfortunately the losses they took were simply too great, their effective combatants are in so small number you can no longer call them a deployable unit. The survivors will be sent home honored as veterans or reorganized in a new unit.
				<<elseif $slaveUnits[_j].troops <= 10>>

The unit has very few operatives left, it risks complete annihilation if deployed again.
				<</if>>
			<</if>>
		<</for>>

	<</if>>
	<<if App.SecExp.battle.deployedUnits('mercs') >= 1>>

 <<set _med = 0>>
		<<for _j = 0; _j < $mercUnits.length; _j++>>
			<<if $mercUnits[_j].active == 1 && !$rebellingID.includes($mercUnits[_j].ID)>>
				<<set $mercUnits[_j].battlesFought++>>
				<<set _loss = _lossesList.pluck()>>
				<<set _loss = Math.clamp(_loss,0,$mercUnits[_j].troops)>>

$mercUnits[_j].platoonName participated in the battle. They remained loyal to you.
				<<if _loss <= 0>>
					No casualties
				<<elseif _loss <= $mercUnits[_j].troops * 0.2>>
					Light casualties
				<<elseif _loss <= $mercUnits[_j].troops * 0.4>>
					Moderate casualties
				<<elseif _loss <= $mercUnits[_j].troops * 0.6>>
					Heavy casualties
				<<else>>
					Catastrophic casualties
				<</if>>
				suffered.
				<<set _med = Math.round(Math.clamp(_loss * $mercUnits[_j].medics * 0.25,1,_loss))>>
				<<if $mercUnits[_j].medics == 1 && _loss > 0>>
					Some men were saved by their medics.
				<</if>>
				<<set $mercUnits[_j].troops -= Math.trunc(Math.clamp(_loss - _med,0,$mercUnits[_j].maxTroops))>>
				<<set $mercTotalCasualties += Math.trunc(_loss - _med)>>
				<<if $mercUnits[_j].training < 100>>
					<<if random(1,100) > 60>>
						Experience gained.
						<<set $mercUnits[_j].training += random(5,15) + $majorBattle * random(5,15)>>
					<</if>>
				<</if>>
				<<if $mercUnits[_j].troops <= 0>>
					<<set $mercUnits[_j].active = 0>>

Unfortunately the losses they took were simply too great, their effective combatants are in so small number you can no longer call them a deployable unit. The remnants will be sent home honored as veterans or reorganized in a new unit.
				<<elseif $mercUnits[_j].troops <= 10>>

The unit has very few operatives left, it risks complete annihilation if deployed again.
				<</if>>
			<</if>>
		<</for>>

	<</if>>
<<else>>

@@.red;Error: losses are a negative number or NaN@@
<</if>>

<<if $rebellingID.length > 0 && $battleResult >= 2>> /* rebellion win */

 <<set _militiaRebelledID = [], _militiaManpower = 0>>
	<<for _j = 0; _j < $militiaUnits.length; _j++>>
		<<if $militiaUnits[_j].active == 1 && $rebellingID.includes($militiaUnits[_j].ID)>>

$militiaUnits[_j].platoonName,
			<<set _militiaRebelledID.push($militiaUnits[_j].ID)>>
			<<set _militiaManpower += Math.clamp($militiaUnits[_j].troops - random(_averageLosses),0,$militiaUnits[_j].troops)>>
		<</if>>
	<</for>>
	<<if _militiaRebelledID.length > 0>>
		had the gall to betray you and join your enemies.

<<link "Dissolve the units">>
				<<run $militiaUnits.deleteWith((u) => _militiaRebelledID.includes(u.ID))>>
				<<set $militiaFreeManpower += _militiaManpower>>
				<<for _i = 0; _i < $militiaUnits.length; _i++>>
					<<if $militiaUnits[_i].active == 1>>
						<<set $militiaUnits[_i].loyalty = Math.clamp($militiaUnits[_i].loyalty - random(10,40),0,100)>>
					<</if>>
				<</for>>
				<<replace "#militiaResult">>

Units dissolved.
				<</replace>>
			<</link>>

//Manpower will be refunded, but will negatively influence the loyalty of the other units//

<<link "Purge the dissidents and dissolve the units">>
				<<run $militiaUnits.deleteWith((u) => _militiaRebelledID.includes(u.ID))>>
				<<set $militiaFreeManpower += _militiaManpower * 0.5>>
				<<replace "#militiaResult">>

Dissidents purged and units dissolved.
				<</replace>>
			<</link>>

//Will not influence the loyalty of the other units, but only half the manpower will be refunded.//

<<link "Execute them all">>
				<<run $militiaUnits.deleteWith((u) => _militiaRebelledID.includes(u.ID))>>
				<<for _i = 0; _i < $militiaUnits.length; _i++>>
					<<if $militiaUnits[_i].active == 1>>
						<<set $militiaUnits[_i].loyalty = Math.clamp($militiaUnits[_i].loyalty + random(10,40),0,100)>>
					<</if>>
				<</for>>
				<<replace "#militiaResult">>

Units executed. Dissent will not be tolerated.
				<</replace>>
			<</link>>

//Will positively influence the loyalty of the other units, but no manpower will be refunded.//

	<</if>>

 <<set _slaveRebelledID = [], _slaveManpower = 0>>
	<<for _j = 0; _j < $slaveUnits.length; _j++>>
		<<if $slaveUnits[_j].active == 1 && $rebellingID.includes($slaveUnits[_j].ID)>>

$slaveUnits[_j].platoonName,
			<<set _slaveRebelledID.push($slaveUnits[_j].ID)>>
			<<set _slaveManpower += Math.clamp($slaveUnits[_j].troops - random(_averageLosses),0,$slaveUnits[_j].troops)>>
		<</if>>
	<</for>>
	<<if _slaveRebelledID.length > 0>>
		decided in their blind arrogance to betray you.

<<link "Dissolve the units">>
				<<run $slaveUnits.deleteWith((u) => _slaveRebelledID.includes(u.ID))>>
				<<set $menials += _slaveManpower>>
				<<for _i = 0; _i < $militiaUnits.length; _i++>>
					<<if $slaveUnits[_i].active == 1>>
						<<set $slaveUnits[_i].loyalty = Math.clamp($slaveUnits[_i].loyalty - random(10,40),0,100)>>
					<</if>>
				<</for>>
				<<replace "#slaveResult">>

Units dissolved.
				<</replace>>
			<</link>>

//Manpower will be refunded, but will negatively influence the loyalty of the other units//

<<link "Purge the dissidents and dissolve the units">>
				<<run $slaveUnits.deleteWith((u) => _slaveRebelledID.includes(u.ID))>>
				<<set $menials += _slaveManpower * 0.5>>
				<<replace "#slaveResult">>

Dissidents purged and units dissolved.
				<</replace>>
			<</link>>

//Will not influence the loyalty of the other units, but only half the manpower will be refunded.//

<<link "Execute them all">>
				<<run $slaveUnits.deleteWith((u) => _slaveRebelledID.includes(u.ID))>>
				<<for _i = 0; _i < $slaveUnits.length; _i++>>
					<<if $slaveUnits[_i].active == 1>>
						<<set $slaveUnits[_i].loyalty = Math.clamp($slaveUnits[_i].loyalty + random(10,40),0,100)>>
					<</if>>
				<</for>>
				<<replace "#slaveResult">>

Units executed. Dissent will not be tolerated.
				<</replace>>
			<</link>>

//Will positively influence the loyalty of the other units, but no manpower will be refunded.//

	<</if>>

 <<set _mercRebelledID = [], _mercManpower = 0>>
	<<for _j = 0; _j < $mercUnits.length; _j++>>
		<<if $mercUnits[_j].active == 1 && $rebellingID.includes($mercUnits[_j].ID)>>

$mercUnits[_j].platoonName,
			<<set _mercRebelledID.push($mercUnits[_j].ID)>>
			<<set _mercManpower += Math.clamp($mercUnits[_j].troops - random(_averageLosses),0,$mercUnits[_j].troops)>>
		<</if>>
	<</for>>
	<<if _mercRebelledID.length > 0>>
		made the grave mistake of betraying you.

<<link "Dissolve the units">>
				<<run $mercUnits.deleteWith((u) => _mercRebelledID.includes(u.ID))>>
				<<set $mercFreeManpower += _mercManpower>>
				<<for _i = 0; _i < $militiaUnits.length; _i++>>
					<<if $mercUnits[_i].active == 1>>
						<<set $mercUnits[_i].loyalty = Math.clamp($mercUnits[_i].loyalty - random(10,40),0,100)>>
					<</if>>
				<</for>>
				<<replace "#mercResult">>

Units dissolved.
				<</replace>>
			<</link>>

//Manpower will be refunded, but will negatively influence the loyalty of the other units//

<<link "Purge the dissidents and dissolve the units">>
				<<run $mercUnits.deleteWith((u) => _mercRebelledID.includes(u.ID))>>
				<<set $mercFreeManpower += _mercManpower * 0.5>>
				<<replace "#mercResult">>

Dissidents purged and units dissolved.
				<</replace>>
			<</link>>

//Will not influence the loyalty of the other units, but only half the manpower will be refunded.//

<<link "Execute them all">>
				<<run $mercUnits.deleteWith((u) => _mercRebelledID.includes(u.ID))>>
				<<for _i = 0; _i < $mercUnits.length; _i++>>
					<<if $mercUnits[_i].active == 1>>
						<<set $mercUnits[_i].loyalty = Math.clamp($mercUnits[_i].loyalty + random(10,40),0,100)>>
					<</if>>
				<</for>>
				<<replace "#mercResult">>

Units executed. Dissent will not be tolerated.
				<</replace>>
			<</link>>

//Will positively influence the loyalty of the other units, but no manpower will be refunded.//

	<</if>>
<<elseif $rebellingID.length > 0>>
	/* rebellion loss */

	<<set _militiaRebelledID = []>>
	<<for _j = 0; _j < $militiaUnits.length; _j++>>
		<<if $militiaUnits[_j].active == 1 && $rebellingID.includes($militiaUnits[_j].ID)>>
			<<set _militiaRebelledID.push($militiaUnits[_j].ID)>>
			$militiaUnits[_j].platoonName,
		<</if>>
	<</for>>
	<<if _militiaRebelledID.length > 0>>
		had the gall to betray you and join your enemies. They participated in the looting following the battle, then vanished in the wastes.
	<</if>>
	<<run cashX(forceNeg(1000 * _militiaRebelledID.length), "war")>>
	<<run $militiaUnits.deleteWith((u) => _militiaRebelledID.includes(u.ID))>>

	<<set _slaveRebelledID = []>>
	<<for _j = 0; _j < $slaveUnits.length; _j++>>
		<<if $slaveUnits[_j].active == 1 && $rebellingID.includes($slaveUnits[_j].ID)>>
			<<set _slaveRebelledID.push($slaveUnits[_j].ID)>>
			$slaveUnits[_j].platoonName,
		<</if>>
	<</for>>
	<<if _slaveRebelledID.length > 0>>
		decided in their blind arrogance to betray you. They participated in the looting following the battle, then vanished in the wastes.
	<</if>>
	<<run cashX(forceNeg(1000 * _slaveRebelledID.length), "war")>>
	<<run $slaveUnits.deleteWith((u) => _slaveRebelledID.includes(u.ID))>>

	<<set _mercRebelledID = []>>
	<<set _count = 0>>
	<<for _j = 0; _j < $mercUnits.length; _j++>>
		<<if $mercUnits[_j].active == 1 && $rebellingID.includes($mercUnits[_j].ID)>>
			<<set _mercRebelledID.push($mercUnits[_j].ID)>>
			<<set _count++>>
			$mercUnits[_j].platoonName,
		<</if>>
	<</for>>
	<<if _mercRebelledID.length > 0>>
		made the grave mistake of betraying you. They participated in the looting following the battle, then vanished in the wastes.
	<</if>>
	<<run cashX(forceNeg(1000 * _mercRebelledID.length), "war")>>
	<<run $mercUnits.deleteWith((u) => _mercRebelledID.includes(u.ID))>>
<</if>>


code:
:: SFColonelSexDec

<<switch $SF.Colonel.Core>>
<<case "shell shocked">>

The entire time it is obvious that The Colonel is reliving a horrible event.

<<link "Try to bring her back">>
			<<replace "#result7">>
				"You made an attempt to try to bring her back to the present."
			<</replace>>
		<</link>>

<<link "Leave her be">>
			<<replace "#result7">>
				"It is probably better that she tries to deal with her demons alone."
			<</replace>>
		<</link>>

<<default>>

Inset sex noises here.
<</switch>>


code:
:: Firebase [nobr jump-to-safe jump-from-safe]

<<set _max = App.SF.upgrades.max(), _Env = App.SF.env(), _size = App.SF.upgrades.total()>>

<<if $SF.FS.Tension > 100>> <<= App.SF.fsIntegration.badOutcome()>>
<<else>>
	<<set $nextButton = "Back", $nextLink = "Main">>

	<<if $cheatMode > 0 || $debugMode > 0>> [[Edit|editSF][]]
 <</if>>
	The firebase of $arcologies[0].name's <<textbox "$SF.Lower" $SF.Lower "Firebase">> is located in the lower levels, occupying unneeded warehouse space. It is not accessible to the general citizenry, but your personal elevator has express service to it. As you step off, two soldiers in combat armor manning the entry checkpoint tense before recognizing their Marshal and stepping aside with a sharp salute.

	You make your way to the operations center. The Colonel is
	<<if random(1,100) > 25>>glancing between her tablet and the large wallscreen, occasionally taking notes or barking orders.
	<<elseif random(1,100) > 25>>handling a minor issue.<<else>>examining a table with a map of the surrounding area, planning maneuvers in the event of an attack.<</if>>
	She notices your entrance and turns her attention to you.

	<<if $SF.Colonel.Core === "brazen">>
		She gives a textbook salute. "<<= properTitle()>>, how can I help you?"
	<<else>>
		"Hey boss, what do you need?"
	<</if>>

 <<link "Tour the firebase" "FirebaseTour">> <</link>>

	<<if _size === _max>>

There are no more upgrades available. <<run delete $SF.Upgrade>>
	<</if>>
	<<if $SF.FS.Tension !== -1>> The Colonel's current Tension: $SF.FS.Tension<</if>>

	<<run App.UI.tabBar.handlePreSelectedTab($tabChoice.Firebase)>>

		<<if _size !== _max>>
			<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'Upgrades')" id="tab Upgrades">Upgrades</button>
		<</if>>
		<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'Actions')" id="tab Actions">Actions</button>
		<button class="tab-links" onclick="App.UI.tabBar.openTab(event, 'FS')" id="tab FS">Future Societies</button>

			<<set _T1 = App.SF.unlocked.secondTier()>>
			Total upgrade progress: <<print App.SF.progress(_size,_max)>> _size/_max(<<print (_size/_max).toFixed(2)*100>>%) <<if _size < 30>>
//<<print (30-_size)>> more upgrades is needed until the next tier unlocks.// <</if>>

			<<if $SF.Upgrade > 0>>
				<<set _cost = Math.ceil(10000 + ((0.03 - (_size/_max)/100)  * $SF.CreditsInvested))>>

[[Re-unlock upgrading.|Firebase][$SF.Upgrade = 0,cashX(-(_cost), "specialForcesCap")]] @@.red;<<print cashFormat(_cost)>>@@
			<<elseif _size < 30 || _size !== _max>>
				<<include "Upgrades">>
			<</if>>

			<<if $SF.MercCon.CanAttend === 0 || $SF.MercCon.History >= 1 && ((Math.trunc($week/24) === ($week/24)) && $SF.MercCon.CanAttend === -1)>>
				Her expression changes as something jogs her memory. "Before we begin <<if $SF.Colonel.Core == "brazen">><<= properTitle()>><<else>>boss<</if>>
				<<if $SF.MercCon.CanAttend === 0>>
					, back when I was a merc me and a couple of my old friends would have a meetup every several months. Drinking, fucking, drugs... a little poker. It eventually grew into a whole thing, and now we bring our latest and greatest toys to show off, maybe make some money off selling the schematics. I'd like to continue going, for old times' sake."
				<<elseif $SF.MercCon.History >= 1 && ((Math.trunc($week/24) === ($week/24)) && $SF.MercCon.CanAttend === -1)>>
					, that biannual merc meetup has come around again. You've already gave me leave to attend, but I just wanted to be sure I'm still clear to go."
				<</if>>

[[Grant leave|Firebase][$SF.MercCon.CanAttend = 1]]

[[Request she remain on site|Firebase][$SF.MercCon.CanAttend = -2]]

			<</if>>

			<<if $SF.MercCon.History >= 1>>
				<<link "Mercenary meetup report">>
					<<replace "#result0">>
					While at the recent merc meetup, The Colonel made @@.yellowgreen;<<print cashFormat(Math.ceil($SF.MercCon.Income))>>@@ selling generic schematics to her friends, <<print num($SF.MercCon.Menials)>> menial slaves were won in a poker game, and <<print num($SF.MercCon.Mercs)>> mercenaries were persuaded to join $SF.Lower.

Total earnings thus far: @@.yellowgreen;<<print cashFormat(Math.ceil($SF.MercCon.Revenue))>>@@ in income, <<print num($SF.MercCon.TotalMenials)>> menial slaves and <<print num($SF.MercCon.TotalMercs)>> mercenaries joined across $SF.MercCon.History meetups. <<link "Back" "Firebase">> <</link>>
					<</replace>>
				<</link>>

			<</if>>

			<<if $SF.UC.Lock < 1>>
				<<switch $SF.UC.Assign>>
				<<case 0>>
					No soldiers are working undercover, which would primarily advance your cultural goals while also slightly boosting your reputation.

[[Full time assignment|Firebase][$SF.UC.Lock = 1]]

[[Reassign soldiers|Firebase][$SF.UC.Assign = -1]]
				<<case 1>>
					A small section of soldiers are working undercover, which will primarily advance your cultural goals while also slightly boosting your reputation. [[Full time assignment|Firebase][$SF.UC.Lock = 1]]

[[Reassign soldiers|Firebase][$SF.UC.Assign = -1]]
				<<case 2>>
					A large section of soldiers are working undercover, which will primarily advance your cultural goals while also slightly boosting your reputation. [[Full time assignment|Firebase][$SF.UC.Lock = 1]]

[[Reassign soldiers|Firebase][$SF.UC.Assign = -1]]
				<<default>>
					Would you like to assign soldiers to undercover duty, which will primarily advance your cultural goals while also slightly boosting your reputation?

[[Do not assign soldiers to work undercover|Firebase][$SF.UC.Assign = 0]]

[[Assign a small section of soldiers to work undercover|Firebase][$SF.UC.Assign = 1]]

[[Assign a large section of soldiers to work undercover|Firebase][$SF.UC.Assign = 2]]
				<</switch>>
			<<else>>
				<<if $SF.UC.Assign < 1>>''Zero''<<elseif $SF.UC.Assign < 2>>A ''small'' section<<else>>A ''large'' section<</if>>
				of the special force is assigned to undercover work, which will primarily advance your cultural goals while also slightly boosting your reputation. [[Re-allocate the units|Firebase][$SF.UC.Lock = 0]]
			<</if>>
			<<= App.SF.Interactions()>>
			<<include "WC">>

 <<= App.SF.fsIntegration.menu()>>

<</if>>


code:
:: Security Force Naming-Colonel [nobr]

<<set $nextButton = " ">>
<<if $SF.IntroProgress === -1>>
	<<setNonlocalPronouns $seeDicks>>
	You instruct $assistant.name to announce to the arcology's citizenry that you will be making an important announcement in the near future regarding the security situation. Given the damage still present from the Daughters' attack, everyone will be tuning in. You also instruct your assistant to begin quietly investigating potential leadership figures for the force itself.
	It's been a short while since you told your citizens that you were going to talk to them about their security, and by all accounts, they've turned out in force to watch your address over the arcology's internal communications system. You wake up early, relieve your frustrations on a few slaves woken out of deep sleep, and take position behind your desk. You also call over a slave and push _himU under your desk. The unspoken instruction is clear, and _heU begins enthusiastically
	<<if $PC.dick > 0>>
		sucking your cock, taking it as deep as _heU can without gagging.
	<<else>>
		eating you out, pressing _hisU face into your pussy and forcing _hisU tongue deep inside you.
	<</if>>

	A blinking light tells you that the channel is open. You take a deep breath, and begin. You greet your citizens and explain that while you believe deeply in the underlying principles of the Free Cities, recent events have forced you to modify some of your views. The old world attack from the outside and the more recent assault by the Daughters of Liberty from within has proven that some form of permanent, organized standing force is needed to ensure the personal safety of the citizen body.

	You tell them that the old world continues to deteriorate. You tell them that it is only a matter of time before the poor, diseased, starving, and unwashed masses try their hand at invading the arcology again. You tell them that such a force would be good for business, securing trade routes and conducting slaving raids far greater in scale than those performed by private slaving corporations. And finally, to quell their greatest fear, you tell them that you would personally support the force financially.

	As you speak, you carefully monitor the citizens' opinions as indicated on their communication devices. It is uniformly positive — they know whom they have to thank for their continued survival and dominance. You also monitor your arousal given the ministrations of your slave. A few small movements on your part communicate to your citizens what is happening without being too obvious. Free Cities business etiquette respects business conducted while being subtly serviced (and your doing so during such a public and important broadcast signals how seriously you are taking it), but a climax would be seen as a serious lack of discipline.

	You finally wrap up your speech, declaring yourself Marshal of the newly-formed <<textbox "$SF.Lower" $SF.Lower "Security Force Naming-Colonel">>

	You close the link to the communication system and read a message from your assistant that appeared during the last moments of your address. In consultation with major figures in the mercenary community, a suitable candidate for day-to-day command of the new unit has been found. Your instructions were to keep you in the dark about them so as to avoid prejudgment. They are waiting outside your office.

	[[Invite them inside|Security Force Naming-Colonel][$SF.IntroProgress = 1]]
<<elseif $SF.IntroProgress === 1>>
	The figure that enters is not what you were expecting, given your previous experiences with the mercenary groups that work with the arcology owners of the Free Cities. Most mercenaries you've worked with have been grizzled stout men, veterans of the old world militaries that finally had too much and went private. Instead, a woman walks in.
	<<if $SF.Colonel.Core === "">>
		She strikes you as someone who is likely to be:

[[Kind|Security Force Naming-Colonel][$SF.Colonel.Core = "kind"]]

[[Cruel and psychopathic|Security Force Naming-Colonel][$SF.Colonel.Core = "cruel"]]

[[A brazen warmonger|Security Force Naming-Colonel][$SF.Colonel.Core = "brazen"]]

[[Jaded|Security Force Naming-Colonel][$SF.Colonel.Core = "jaded"]]

[[Shell-shocked|Security Force Naming-Colonel][$SF.Colonel.Core = "shell shocked"]]
	<<else>>
		<<setNonlocalPronouns $seeDicks>>
		She is likely to be ''$SF.Colonel.Core''.

		She strides in, stopping in front of your desk,
		<<switch $SF.Colonel.Core>>
		<<case "kind">>
			pulling off a laid-back salute with an easy grin.
		<<case "cruel">>
			her eyes flashing a hard glare in an instant before quickly softening into those of someone who wants something you have.
		<<case "brazen">>
			snapping off a textbook salute that decades of hard service grills into a veteran.
		<<default>>
			not bothering to put on even the semi-military air (complete with salute) that most mercenaries tend to adopt when meeting new clients.
		<</switch>>
		She is very tall and wearing the pants, boots, gloves, and the tank top undershirt of a standard female combat uniform. Her bare arms and upper body are corded with muscle, and through the tank top's thin fabric you can see both the shape of her muscled abdomen and the curves of her small but perky breasts, complete with what your experience tells you are barbell nipple piercings. Her eyes are alive with intelligence, and you can see her scanning your office, clearly impressed by its opulence. Her hair is shaved close to the scalp, and her ears and nose are heavily pierced. You can make out three long, ugly scars running over top of the mottled tissue of a previous, severe burn along one side of her face, as well as numerous smaller scars and burns on her bare arms. She's been disarmed prior to meeting you; the pistol holster on her hip lies empty, as do at least three knife holsters about her person.

		Returning your gaze to her face, she crosses her arms underneath her chest, pressing her breasts up and forward. You have her measure. Given the generally patriarchal nature of both the mercenary community, and the same nature combined with the heavily sexualized lifestyle of the Free Cities, she's decided to embrace her position rather than fight it.

		"So," she begins, "you're the boss." You invite her to sit down. "No thanks, boss. Besides," she
		<<switch $SF.Colonel.Core>>
			<<case "kind">> playfully
			<<case "shell shocked">> uncomfortably
		<</switch>>
		indicates the slave under your desk, "you look a little occupied." She nods at the camera across from you. "Saw the speech. Very nice. I'd heard you crazy bastards do business while getting
		<<if $PC.dick > 0>>sucked off<<else>>eaten out<</if>>,
		but I've never seen anyone actually do it. Hell, most of you people don't want to have to have too much to do with a merc like me. I usually get my instructions remotely."
		<<switch $SF.Colonel.Core>>
		<<case "brazen" "jaded">>
			A short, harsh laugh escapes her. "But I guess it keeps you focused. Can't have the entire arcology seeing you cum."
		<<case "kind">>
			She grins. "That kind of thing doesn't really bother me though."
		<<case "cruel">>
			She frowns. "The client always seems to be happier that way."
		<</switch>>

		She moves a step closer. "Your computer-helper-thing told me you wanted me to be a surprise, so I guess I'll tell you why you want me to run $SF.Lower for you. I'm a killer, pure and simple,<<if $SF.Colonel.Core === "cruel">>" she smiles, "<</if>>and you need that. I looked into those attacks you've suffered. Nasty business. I'll make sure that an attack like that never happens again. I was a soldier out there, in charge of about a thousand men when the Free Cities first started going up, and I knew they were the future. Eventually I deserted, found the first refugee convoy I could, killed the moron protecting it, sold the girls off to slavers, and bought enough gear to start killing for people like you. Ran my own merc crew, did well till we tried to take on a bigger one and everyone died."
		<<switch $SF.Colonel.Core>>
		<<case "shell shocked">>
			She looks away, caught in her own memories. It takes a solid minute before she starts again.
		<<case "cruel">>
			Her smile grows.
		<<default>>
			She pauses for a moment.
		<</switch>>
		"Joined with another big outfit, became the number two, then shit went bad and I had to run. Been a solo fighter and slaver ever since. I know my work, and I know I can make this work."

		You feel your climax approaching and hold up a finger. The merc pauses while you grab the slave's head
		<<if $PC.dick > 0>>
			then force your cock roughly down _hisU throat while you cum. _HeU swallows as much as _heU can before pulling
		<<else>>
			tightly with your thighs, pressing _hisU face tightly against your pussy as you cum. When you release _himU, _heU pulls
		<</if>>
		away, coughing.

		<<if $SF.Colonel.Core === "shell shocked">>
			The merc looks away again, letting the _girlU settle down before continuing.
		<<else>>
			The merc laughs again. "I could get used to a place like this."
		<</if>>
		She waves her hand around the office. "I bet you want to know why I'd be trustworthy for something like this." You don't correct her. "Thought so." Her demeanor softens, and you can detect a hit of nervousness. "I would say that I've never turned on a client and leave it at that, but this is different. It's getting worse out there. I'm sure you know that." You give her a slight nod. "Four times now I've woken up in the middle of the night and had to kill
		<<if $SF.Colonel.Core == "shell shocked">>
			someone."
		<<else>>
			someone. Two of them were the people I'd taken to bed. You can't even trust your drunken fucks anymore.
			<<switch $SF.Colonel.Core>>
			<<case "kind">>
				It's a shame, but that's the world we live in."
			<<case "cruel">>
				Then again, who doesn't like a good hard fuck and stab?"
			<<default>>
				But what else is new?"
			<</switch>>
		<</if>>

		<<if $SF.Colonel.Core == "jaded" || $SF.Colonel.Core == "shell shocked">>
			"All I know how to do at this point is fight, and that's kept me alive this far.
		<<else>>
			"I like fighting, but I want to live somewhere where I can relax from life out there.
		<</if>>
		You give me the job and a place to live, let me hang up the uncertainty of being a merc, and I'll die for you if it comes to that. I promise the people I recruit will feel the same. Besides," she grins, "I could get used to
		<<switch $SF.Colonel.Core>>
		<<case "brazen">>
			crushing any enemy that looks our way."
		<<case "cruel">>
			<<setNonlocalPronouns $seeDicks>>
			having my own stable to abuse as I see fit. A terrified little slave<<= _girlU>> locked between my legs, struggling to breathe?"
		<<default>>
			spending my R&R time with a cold beer in one hand, a few lines of coke or a stack of pills in front of me."
		<</switch>>
		A glint runs through her eyes. "Sounds like a good fucking time."

		You quickly decide she'll do. You tap a few commands on your desk's console, assigning her personal quarters on the arcology's higher levels and transferring her first stipend to her new account. You also ask her what title she wants.

		"Title?" Another short laugh. "I guess I do need one, given that I'm all official and shit now." She thinks for a moment. "I was a major before I went freelance, and I think I'd like a promotion. Colonel sounds good." You make a note of this in her file. "You people don't seal contracts with a fuck do you?" Reassuring her you don't, she laughs again. "Good. I make it a point never to fuck the boss. It's bad for business." She turns around. "Well, I guess I'd better get to it. Your helper-thing assigned me space on the lower levels for the firebase. I brought a few squads of guys I know from the old days to start, but we'll grow fast once I put the word out, I guarantee it."

		[[Let her leave|Security Force Naming-Colonel][$SF.IntroProgress = 2]]
	<</if>>
<<elseif $SF.IntroProgress === 2>>
	<<set $nextLink = "RIE Eligibility Check",$nextButton = "Continue">>
	<<run delete $SF.IntroProgress>>

	She turns and leaves, and you chase the slave out after her. A few minutes later, a soft chime announces the arrival of a message. It's from The Colonel.

	//Hey boss, just wanted to mention something else. In your speech you said that you were going to be paying for $SF.Lower. In my mind that means it's yours, no matter what anyone else here might think. I do what you tell me to do. I make sure the troops behave as you want them to behave. I've worked for some 'nice guys' in the past, and I can do that job if you want. It's boring, but sustainable, and I'll have $SF.Lower turning a profit and supporting the arcology in good order. But if you let me <<if $SF.Colonel.Core === "cruel">>off the leash<<else>>do what I do<</if>> and throw any old world complaints in the trash where they belong, I promise you'll have money pouring into your coffers, even accounting for the good amounts me and my boys will pocket along the way. You'll have an empire in short order.
	<<if $mercenaries > 1>>
		Either way, I'll keep my hands off those mercs you've already installed. I figure that you've reasons for having two different death squads under contract.
	<</if>>

	Oh, one last thing. I know you've got some kind of grand social experiment going on up there like all the other arc owners, and that's your own deal, but I'd appreciate it if you could keep that stuff out of the new barracks. I'll have a hard time approaching potential recruits and telling them they should come live in a Roman apartment, an Egyptian temple, a goddamn Japanese teahouse, or some of the other crazy shit I've seen in the past. They're hard, nasty people, and trust me, I can tell you from experience that changing that is just not going to happen. Like I said, though, I can hold them back a bit if you like.

	Talk to you later, boss.//
<</if>>


code:
:: Security Force Proposal [nobr]

<<set $nextButton = " ", _price = 20000>>
The Free Cities were founded on the principles of unrestrained anarcho-capitalism. To those with such beliefs, the very idea of possessing an armed force, a key tool of government control, or weapons at all, was anathema.

In the period since, however, your citizens have seen the value in weaponry. They watched on their news-feed as some Free Cities were sacked by the armies and mobs of the old world, driven by their hatred of the citizens' luxurious lifestyles. They've seen other Cities toppled from within, by slave conspiracies or infighting among citizen groupings with differing beliefs. They've witnessed the distressingly rapid rise of fanatical anti-slavery organizations, who would like nothing more than to see them slowly bled by their own chattel. They are learned people, and they know what happens to slaveowners who lose their power.

They've also seen the results of your policies. Your actions towards the arming of both yourself and the arcology proved critical, and ensured their safety when the old world came for them. And your victory over the Daughters of Liberty, who the citizens know would have executed every single one of them, has created an opportunity. If you insisted upon the creation of a standing 'special' force for the arcology, many would support you and, more importantly, nobody of note would object.

Such a force would solve many problems. More soldiers would mean more control, which is very good for you. More soldiers would mean more security for the arcology and the approaches to it, which is very good for business. More soldiers would mean more obedience from rebellious slaves who can see how powerless they truly are, which is very good for everybody. The force would be tiny compared to the old world militaries that still exist, but money and technology can, of course, overcome massive numerical inferiority. This being the Free Cities, they would have other uses besides security. Perhaps, in time, you could exert some manner of influence on the old world itself.

''This is a unique and very important opportunity'', and is possible only because of your recent victory over the Daughters. If you do not seize it, the memories and fears of your citizens will fade, and you will not be able to raise the matter again.

<<if $PC.skill.warfare >= 100>>
	<<set _price *= 0.5>>
<<elseif $PC.skill.warfare >= 50 || $PC.career == "arcology owner">>
	<<set _price *= 0.75>>
<</if>>

[[Prepare for an announcement.|Security Force Naming-Colonel][$SF.Active = 1, $SF.IntroProgress = -1, App.SF.Init(), cashX(forceNeg(_price), "specialForcesCap")]]

 //Initial costs are @@.yellowgreen;<<print cashFormat(_price)>>@@ and upon establishment the force will have significant support costs until it is self-sufficient.//

[[The current measures are enough|RIE Eligibility Check][$SF.Active = 0, delete $SF.IntroProgress]]