code:
:: secExpSmilingMan [nobr]

The Smiling Man

<<if $smilingManProgress == 0>>
	<<set $nextButton = "Continue", $nextLink = "Random Nonindividual Event">>

	During your morning routine you stumble upon a peculiar report: it's been several weeks now that your arcology has been victim of a series of cyber-crimes conducted by a mysterious figure.
	The egocentric criminal took great pride in its acts, to the point of signing his acts with his or her peculiar symbol: a stylized smiling face. Your arcology was not the only one under assault by the
	machinations of what the media would quickly nicknamed //the smiling man//.

Despite the sheer damage this criminal was doing, you cannot help but admire the skill with which every misdeed is carried: the worst white collar crimes of the century carried out with such elegancy
	they almost seemed the product of natural laws rather than masterful manipulation of the digital market.
	While you sift through the pages of the report, $assistantName remains strangely quiet. "I'm worried <<if def $PC.customTitle>>$PC.customTitle<<elseif $PC.title != 0>>sir<<else>>ma'am<</if>>, this individual seems to be able to penetrate whatever system gathers his attention. I... feel vulnerable" she said "It's not something I'm used to."

Fortunately you have not been hit directly by this criminal, not yet at least. Still the repercussions of numerous bankruptcies take their toll on your arcology, whose @@.red;prosperity suffers@@.

<<set $arcologies[0].prosperity *= random(80,90) * 0.01>>

	<<link "Devote funds to the search for this dangerous criminal">>
		<<if $cash >= 10000>>
			<<set $cash -= 10000>>
			<<set $investedFunds = 1>>
		<<else>>
			<<set $investedFunds += cash>>
			<<set $cash = 0>>
		<</if>>
		<<set $relationshipLM += 1>>
		<<set $smilingManProgress += 1>>
		<<replace "#result">>
			You devote funds to capture and neutralize the threat. You cannot help but wonder what is the end game of the laughing man. Money? Fame? Or is he on an ideological crusade?
		<</replace>>
	<</link>>

	<<link "Attempt to contact the mysterious figure, whatever it takes">>
		<<if $cash >= 10000>>
			<<set $cash -= 10000>>
			<<set $investedFunds = 1>>
		<<else>>
			<<set $investedFunds += cash>>
			<<set $cash = 0>>
		<</if>>
		<<set $relationshipLM += 2>>
		<<set $smilingManProgress += 1>>
		<<replace "#result">>
			You devote funds to the attempt at communicating with the smiling man. You cannot help but wonder what is the end game of the laughing man. Money? Fame? Or is he on an ideological crusade?
		<</replace>>
	<</link>>

	<<link "Invest funds to increase the cyber-security of the arcology">>
		<<if $cash >= 10000>>
			<<set $cash -= 10000>>
			<<set $investedFunds = 1>>
		<<else>>
			<<set $investedFunds += cash>>
			<<set $cash = 0>>
		<</if>>
		<<set $relationshipLM += random(5,10)>>
		<<set $hostileRoute -= 1>>
		<<set $smilingManProgress += 1>>
		<<replace "#result">>
			You devote funds to the improvement of the cyber-security of your arcology. You cannot help but wonder what is the end game of the laughing man. Money? Fame? Or is he on an ideological crusade?
		<</replace>>
	<</link>>

	<<link "Ignore the issue">>
		<<set $smilingManProgress += 1>>
		<<replace "#result">>
			You do not consider this individual a threat.
		<</replace>>
	<</link>>

<<elseif $smilingManProgress == 1>>
	<<set $nextButton = "Continue", $nextLink = "Random Nonindividual Event">>

	You just reached your penthouse, when your faithful assistant appears in front of you, evidently exited.
	"<<if def $PC.customTitle>>$PC.customTitle<<elseif $PC.title != 0>>Sir<<else>>Ma'am<</if>>, I have just received news of a new attack by the Smiling Man. It appears just 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.
	You can say whatever you want about him, but he has style... Anyway 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?" asks. You silently nod.

Suddenly the room flashes red, while your assistant fades for half a second. When it reappears her face was replaced by a stylized smiling face.

"Hello, my dear $PC.name. Can I call you by name, 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." said while letting out a very childlike giggle.
	"You see 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! Oh 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 flickered once more and an instant later your assistant returned to her usual self.

"I... I... I couldn't stop him! I'm sorry <<if def $PC.customTitle>>$PC.customTitle<<elseif $PC.title != 0>>sir<<else>>ma'am<</if>>."

Without wasting time you rush the console and check your finances. It's as you feared, @@.red;you have been robbed@@.
	<<set _lostCash = 200000>>
	<<if $assistantPower == 1>>
		<<set _lostCash -= 20000>>

Fortunately the computing power available to $assistantName allowed her to somewhat limit the losses.
	<<elseif $assistantPower == 2>>
		<<set _lostCash -= 30000>>

Fortunately the computing power available to $assistantName allowed her to limit the losses.
	<</if>>
	<<if $secUpgrades.cyberBots == 1>>
		<<set _lostCash -= 30000>>
		The additional cyber defenses acquired and running in the security HQ <<if _lostCash < 200000>>further<</if>> limit the damage.
	<</if>>
	<<if $investedFunds == 1>>
		<<set _lostCash -= 20000>>
		The funding you dedicated to the Smiling Man case saved some of the assets that would have otherwise lost.
	<</if>>
	<<set $cash -= _lostCash>>

	<<link ""I want him dead. Now."">>
		<<set $relationshipLM -= 1>>
		<<set $smilingManProgress += 1>>
		<<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 $relationshipLM += 1>>
		<<set $smilingManProgress += 1>>
		<<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 $relationshipLM += 2>>
		<<set $smilingManProgress += 1>>
		<<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 $smilingManProgress += 1>>
		<<set $nextButton = "Continue", $nextLink = "Random Nonindividual Event">>
		<<replace "#result">>
			You take no further action. Hopefully this ordeal is over.
		<</replace>>
	<</link>>

<<elseif $smilingManProgress == 2>>
	<<set $nextButton = "Continue", $nextLink = "Random Nonindividual Event">>

	<<set $smilingManWeek = $week>>
	$assistantName wakes you up violently, her worried expression can mean only one thing: the smiling man was back. "Today at midnight a new site popped up in the web: it's a very simple site, no visuals, no text, no data, only a countdown ticking away. It will reach zero this evening." said.
	This is troubling yet exciting news. The smiling man never failed to cause damage, but his ego got the best of him this time: having time to prepare before its attack will give you a chance to find him. For the rest of the day you do your best to plan, prepare and focus.

Evening came faster than you anticipated, by now 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 start acting weirdly, then it happened. On all screens in all the arcology the smiling man icon appeared, then every speaker started broadcasting the same voice, one that you already heard once before:

"Hello citizens of Earth! I am here in this special day to relay to you a very important message: we find ourselves in very peculiar times, times of strife and suffering! But also of change and regeneration! Indeed I say humanity is regenerating itself, 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 start 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 space 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 unjustice 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 se its memory erased, every archived cleaned, every drive deleted.

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

The voice stopped for a second.

"Have a good day." simply concluded, then it happened.

In little more than seconds all the data collected in the years vanished. It is a disaster.
	<<if $cash < 0>>
		The vast majority of currency is digital, so the actions of the smiling man have a devastating effect on the money supply. Luckily for you this means that your @@.yellowgreen;debt is reduced@@.
		<<set $cash *= 0.2>>
	<<else>>
		The vast majority of currency is digital, so the actions of the smiling man have a devastating effect on the money supply. Unfortunately this means that your @@.red;cash reserves are gutted@@.
		<<set $cash *= 0.2>>
	<</if>>
	You are not the only one affected by this however. @@.red;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 $globalCrisisWeeks = random(8,16)>>
	Trade is @@.red;severely affected@@.
	<<set $trade *= 0.2>>
	With the loss of so much information, most of your accomplishments are simply forgotten, @@.red;your reputation suffers.@@
	<<set $rep *= 0.6>>
	<<if $arcologies[0].ownership >= 60>>
		<<if $authority <= 10000>>
			<<for _i = 1; _i < $sectors.length; _i++>>
				<<if $sectors[_i].ownership == 1>>
					<<if $sectors[_i].type != "Brothel">>
					<<if $sectors[_i].type != "Club">>
					<<if $sectors[_i].type != "Arcade">>
					<<if $sectors[_i].type != "Dairy">>
					<<if $sectors[_i].type != "Pit">>
					<<if $sectors[_i].type != "Sweatshops">>
					<<if $sectors[_i].type != "Pens">>
					<<if $sectors[_i].type != "Barracks">>
					<<if random(1,100) >= 66>>
						<<set $sectors[_i].ownership = 0>>
						Vast amount of data relative to the ownership of the arcology is lost. You lost all legal claims to one of the sectors.
						<<break>>
					<</if>>
					<</if>>
					<</if>>
					<</if>>
					<</if>>
					<</if>>
					<</if>>
					<</if>>
					<</if>>
				<</if>>
			<</for>>
			Vast amount of data relative to the ownership of the arcology is lost. You would've run the risk of loosing 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 $secUpgrades.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 $secUpgrades.coldstorage == 0>>
		Your security department sees its archives butchered by the Smiling Man. Almost all data on criminals, citizens, operations, all lost. The @@.red;security of the arcology is greatly reduced@@. Criminals on the other hand, with their past cleansed, cannot wait to join this new world, @@.red;crime will inevitably increase@@.
		<<set $security = Math.clamp($security * 0.2,0,100)>>
		<<set $crime = Math.clamp($crime * 1.5, 20,100)>>
	<</if>>

A short meek man approaches you with a weak smile. "Not all is lost, <<if def $PC.customTitle>>$PC.customTitle<<elseif $PC.title != 0>>sir<<else>>ma'am<</if>>. We have a lead on him: he is here, in $arcologies[0].name."

Despite the bleak situation, you could not help but smile back.

	<<link ""Eliminate the threat, once and for all."">>
		<<set $relationshipLM -= 1>>
		<<set $smilingManProgress += 1>>
		<<replace "#result">>
			You command your loyal operatives to prepare for a manhunt.
		<</replace>>
	<</link>>

	<<link ""Bring him to me."">>
		<<set $relationshipLM += 1>>
		<<set $smilingManProgress += 1>>
		<<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 $relationshipLM += 2>>
		<<set $smilingManProgress += 1>>
		<<replace "#result">>
			You command your loyal operatives to prepare for a manhunt.
		<</replace>>
	<</link>>

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

<<elseif $smilingManProgress == 3>>
	<<set $nextButton = " ">>

	The day has come to finally put an end to this story. Your men are ready to go, waiting only your signal. You quickly finish to wear 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, an rundown old apartment in a scarcely populated part of the arcology. You give the order to breach and your men rush inside without problems.
	A couple of seconds pass without a single noise coming out of the apartment, you start to worry, when you hear the captain calling you inside.

"So it was you to find me first.
	<<if $relationshipLM > 2>>
		I was hoping you would be the one!
	<<else>>
		I expected you would be the one.
	<</if>>
	Well I hope I am everything you expected" said. Despite recognizing the quirky voice you struggle to convince yourself that the little girl in front of you is indeed the famous international criminal.
	"As you can see I have no intention of escaping. I knew my life was over the second my plan would start. 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 it's equally so the admiration for her skill and determination. Indeed she would be a great addition to your court, as free individual or not.

	<<link "Offer her a new life">>
		<<set $smilingManFate = 0>>
		<<replace "#result">>
			You decide it would a criminally wasteful to throw away such talent. You offer her a new life at your side. Her expertise will surely guarantee safety, if not supremacy to your arcology in cyberspace, while she will have safety and luxury in the physical world.

			<<link "Continue">>
				<<set $smilingManProgress += 1>>
				<<goto "secExpSmilingMan">>
			<</link>>
		<</replace>>
	<</link>>

	<<link "make her pay">>
		<<set $smilingManFate = 1>>
		<<replace "#result">>
			You decide to end her pitiful life. She has crossed the wrong master of the new world she worked so hard to create. No mercy was asked and no mercy will be given.

			<<link "Continue">>
				<<set $smilingManProgress += 1>>
				<<goto "secExpSmilingMan">>
			<</link>>
		<</replace>>
	<</link>>

	<<link "Enslave her">>
		<<set $smilingManFate = 2>>
		<<replace "#result">>
			You decide to enslave the girl. Her skill may be great, her crimes equally so, but that makes is all so much sweeter to turn her into an obedient little toy to play with.

			<<link "Continue">>
				<<set $smilingManProgress += 1>>
				<<goto "secExpSmilingMan">>
			<</link>>
		<</replace>>
	<</link>>

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

	<<if $smilingManFate == 0>>
		<<if $relationshipLM >= 4>>
			The girl asks for a few minutes to think about your offer, but she quickly comes to terms with the situation and accepts. In the following weeks she will get acquainted with the security network of the arcology and work to protect her new home in the new world she created.
			The world at large will never find out what was the end of the Smiling Man and his legend will only grow with the years, outliving his creator and maybe even her new employer.
		<<else>>
			The girl asks for a few minutes to think about your offer and after some time she reluctantly accepts. In the following weeks she will get acquainted with the security network of the arcology and work to protect her new home in the new world she created.
			The world at large will never find out what was the end of the Smiling Man and his legend will only grow with the years, outliving his creator and maybe even her new employer.
		<</if>>

The collaboration of the ex-Smiling Man permanently increases @@.green;security and the rate of prosperity growth@@. Also from time to time @@.limegreen;cash will be provided@@, however it is better not to know the sources.
	<<elseif $smilingManFate == 1>>
		For such a criminal a simple execution is not enough. You order the girl captured and crucified outside the city, with a mask resembling her famous symbol. Your men quickly obey. She never once showed sign of pain or fear, remaining stoic and proud to the end.
		Once her life ended you ordered a statue be 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 @@.green;a moderate amount of reputation each week as well as an large immediate bonus@@.
	<<elseif $smilingManFate == 2>>
		<<if $relationshipLM >= 4>>
			Your men move to immobilize her. Terror flashes through her eyes for a second, but she quickly recover her usual attitude.
		<<else>>
			Your men move to immobilize her. Terror flashes through her eyes for a second, she barely manages to recover her usual attitude.
		<</if>>
		<<include "Generate XX Slave">>
		<<set $activeSlave.origin = "She was a criminal mastermind, captured shortly after completing her master plan.">>
		<<set $activeSlave.career = "a student from a private school">>
		<<set $activeSlave.nationality = "Japanese">>
		<<set $activeSlave.intelligence = 3>>
		<<set $activeSlave.intelligenceImplant = 1>>
		<<NationalityToName $activeSlave>>
		<<NationalityToAccent $activeSlave>>
		<<NationalityToRace $activeSlave>>
		<<set $activeSlave.slaveSurname = "Yamadera">>
		<<set $activeSlave.birthSurname = "Yamadera">>
		<<set $activeSlave.skin = "pale">>
		<<set $activeSlave.devotion = 5 * $relationshipLM>>
		<<set $activeSlave.trust = 5 * $relationshipLM>>
		<<set $activeSlave.face = random(10,50)>>
		<<set $activeSlave.health = 70>>
		<<set $activeSlave.teeth = "normal">>
		<<set $activeSlave.faceShape = "cute">>
		<<set $activeSlave.boobShape = "perky">>
		<<set $activeSlave.boobs = 450>>
		<<set $activeSlave.nipples = "cute">>
		<<set $activeSlave.areolae = 0>>
		<<set $activeSlave.anus = 0>>
		<<set $activeSlave.butt = 3>>
		<<set $activeSlave.vagina = 0>>
		<<set $activeSlave.ovaries = 1>>
		<<set $activeSlave.lips = 15>>
		<<set $activeSlave.behavioralFlaw = "odd">>
		<<set $activeSlave.vaginalSkill = 0>>
		<<set $activeSlave.oralSkill = 0>>
		<<set $activeSlave.analSkill = 0>>
		<<set $activeSlave.whoreSkill = 0>>
		<<set $activeSlave.entertainSkill = 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 = "She was the famous Smiling Man.">>
		<<if $minimumSlaveAge > 16>>
			<<set $activeSlave.actualAge = $minimumSlaveAge>>
			<<set $activeSlave.physicalAge = $minimumSlaveAge>>
			<<set $activeSlave.visualAge = $minimumSlaveAge>>
		<<else>>
			<<set $activeSlave.actualAge = 16>>
			<<set $activeSlave.physicalAge = 16>>
			<<set $activeSlave.visualAge = 16>>
		<</if>>

		<<set $saleDescription = 0, $applyLaw = 0>>
		<<include "Long Slave Description">>

		<<include "New Slave Intro">>
	<</if>>
<</if>>


code:
:: secInit [nobr]

/* base vars */
<<set $authority = 0>>
<<set $security = 30>>
<<set $secRestPoint = 30>>
<<set $crime = 30>>
<<set $crimeCap = 100>>
<<set $readiness = 1>>
<<set $recon = 0>>
<<set $maxUnits = 6>>
<<set $trade = 0>>
<<set $activeUnits = 0>>
<<set $attackType = "none">>
<<set $attackThisWeek = 0>>
<<set $lastAttackWeeks = 0>>
<<set $hasFoughtOnce = 0>>
<<set $hasFoughtMajorBattleOnce = 0>>
<<set $hasRebelledOnce = 0>>
<<set $majorBattle = 0>>
<<set $PCvictoryStreak = 0>>
<<set $PCvictories = 0>>
<<set $PClossStreak = 0>>
<<set $PClosses = 0>>
<<set $oldFlux = 0>>
<<set $showBattleStatistics = 0>>
<<set $forceBattle = 0>>
<<set $forceMajorBattle = 0>>
<<set $foughtThisWeek = 0>>
<<set $battlesEnabled = 1>>
<<set $battlesEnabledOceanic = 0>>
<<set $majorBattlesEnabled = 1>>
<<set $majorBattleGameOver = 1>>
<<set $rebellionsEnabled = 1>>
<<set $forceRebellion = 0>>
<<set $rebellionGameOver = 1>>
<<set $allowPrestigeFromBattles = 1>>
<<set $battleFrequency = 1>>
<<set $rebellionSpeed = 1>>

/* edicts */
<<set $edictsUpkeep = 0>>
<<set $edictsAuthUpkeep = 0>>
<<set $alternativeRents = 0>>
<<set $enslavementRights = 0>>
<<set $securityExemption = 0>>
<<set $sellData = 0>>
<<set $propCampaignBoost = 0>>
<<set $slaveWatch = 0>>
<<set $subsidyChurch = 0>>
<<set $limitImmigration = 0>>
<<set $openBorders = 0>>
<<set $limitSubhumans = 0>>
<<set $slavesOfficers = 0>>
<<set $martialSchool = 0>>
<<set $discountMercenaries = 0>>
<<set $militiaFounded = 0>>
<<set $recruitVolunteers = 0>>
<<set $militaryService = 0>>
<<set $militarizedSociety = 0>>
<<set $militaryExemption = 0>>
<<set $lowerRquirements = 0>>
<<set $noSubhumansInArmy = 0>>
<<set $pregExemption = 0>>
<<set $eliteOfficers = 0>>
<<set $liveTargets = 0>>
<<set $legionTradition = 0>>
<<set $eagleWarriors = 0>>
<<set $ronin = 0>>
<<set $sunTzu = 0>>
<<set $mamluks = 0>>
<<set $pharaonTradition = 0>>
<<set $weaponsLaw = 3>>
<<set $soldierWages = 1>>
<<set $militiaSoldierPrivilege = 0>>
<<set $slaveSoldierPrivilege = 0>>
<<set $mercSoldierPrivilege = 0>>
<<set $tradeLegalAid = 0>>
<<set $taxTrade = 0>>

/* proclamations */
<<set $proclamationsCooldown = 0>>
<<set $proclamationCurrency = "authority">>
<<set $proclamationType = "none">>

/* buildings */
<<set $upgradeUpkeep = 40>>
<<set $secHQ = 0>>
<<set $secHQUpkeep = $facilityCost * 5>>
<<set $secBarracks = 0>>
<<set $secBarracksUpkeep = $facilityCost * 5>>
<<set $secBarracksUpgrades ={
	size: 0,
	luxury: 0,
	training: 0,
	loyaltyMod: 0}>>
<<set $secHelots = 0>>
<<set $reqHelots = 20>>
<<set $secUpgrades = {
	nanoCams: 0,
	cyberBots: 0,
	eyeScan: 0,
	cryptoAnalyzer: 0,
	coldstorage: 0}>>
<<set $crimeUpgrades = {
	autoTrial: 0,
	autoArchive: 0,
	worldProfiler: 0,
	advForensic: 0}>>
<<set $intelUpgrades = {
	sensors: 0,
	radar: 0,
	signalIntercept: 0}>>
<<set $readinessUpgrades = {
	earlyWarn: 0,
	rapidPlatforms: 0,
	pathways: 0,
	rapidVehicles: 0}>>
<<set $propHub = 0>>
<<set $propHubUpkeep = $facilityCost * 5>>
<<set $propCampaign = 0>>
<<set $propFocus = "none">>
<<set $miniTruth = 0>>
<<set $fakeNews = 0>>
<<set $controlLeaks = 0>>
<<set $secretService = 0>>
<<set $blackOps = 0>>
<<set $marketInfiltration = 0>>
<<set $riotCenter = 0>>
<<set $riotUpkeep = $facilityCost * 5>>
<<set $riotUpgrades = {
	freeMedia: 0,
	rapidUnit: 0,
	rapidUnitSpeed: 0}>>
<<set $fort = {
	reactor: 0,
	waterway: 0,
	assistant:0}>>
<<set $sentUnitCooldown = 0>>
<<set $advancedRiotEquip = 0>>
<<set $brainImplant = -1>>
<<set $brainImplantProject = 0>>
<<set $weapManu = 0>>
<<set $weapHelots = 0>>
<<set $weapProductivity = 1>>
<<set $weapLab = 1>>
<<set $baseUpgradeTime = 10>>
<<set $currentUpgrade = {
	name: " ",
	unit: 0,
	type: 0,
	time: 0}>>
<<set $droneUpgrades = {
	attack: 0,
	defense: 0,
	hp:0}>>
<<set $humanUpgrade = {
	attack: 0,
	defense: 0,
	hp:0,
	morale: 0}>>
<<set $sellTo = {
	citizen: 1,
	raiders: 1,
	oldWorld: 1,
	FC: 1}>>
<<set $completedUpgrades = []>>
<<set $transportHub = 0>>
<<set $airport = 0>>
<<set $railway = 0>>
<<set $docks = 0>>
<<set $hubSecurity = 1>>

/* events */
<<set $smilingManProgress = 0>>
<<set $investedFunds = 0>>
<<set $relationshipLM = 0>>
<<set $captureRoute = 0>>
<<set $collaborationRoute = 0>>
<<set $hostileRoute = 0>>
<<set $smilingManWeek = 0>>
<<set $globalCrisisWeeks = 0>>
<<set $smilingManFate = 4>>

/* rebellions */
<<set $tension = 0>>
<<set $slaveProgress = 0>>
<<set $citizenProgress = 0>>
<<set $slaveRebellionEventFires = 0>>
<<set $citizenRebellionEventFires = 0>>
<<set $slaveRebellion = 0>>
<<set $citizenRebellion = 0>>
<<set $rebellingUnits = []>>
<<set $notInvolved = 0>>
<<set $irregulars = 0>>
<<set $engageRule = 0>>
<<set $rebellingMilitia = 0>>
<<set $rebellingSlaves = 0>>
<<set $rebellingMercs = 0>>
<<set $repairTime = 3>>
<<set $arcRepairTime = 0>>
<<set $rebelDefeatAftermath = 0>>
<<set $garrison = {
	penthouse: 0,
	reactor: 0,
	assistant: 0,
	waterway: 0,
	reactorTime: 0,
	assistantTime: 0,
	waterwayTime: 0 }>>
<<set $rebellionsCount = 0>>
<<set $PCrebWon = 0>>
<<set $PCrebLoss = 0>>

/* armed forces stats */
<<set $difficulty = 1>>
<<set $targetUnit = 0>>
<<set $targetIndex = 0>>
<<set $secBotsCost = 500>>
<<set $secBotsUpgradeCost = 250>>
<<set $equipUpgradeCost = 250>>
<<set $maxTroops = 30>>
<<set $militiaTotalManpower = 0>>
<<set $militiaFreeManpower = 0>>
<<set $militiaEmployedManpower = 0>>
<<set $militiaTotalCasualties = 0>>
<<set $slavesOfficers = 0>>
<<set $slavesEmployedManpower = 0>>
<<set $slavesTotalCasualties = 0>>
<<set $mercTotalManpower = 0>>
<<set $mercEmployedManpower = 0>>
<<set $mercTotalCasualties = 0>>
<<set $soldierUpkeep = 10>>
<<set $createdSlavesUnits = 0>>
<<set $createdMilitiaUnits = 0>>
<<set $createdMercUnits = 0>>
<<set $mercFreeManpower = 0>>
<<if $wasToggledBefore == 0>>
	<<if $mercenaries == 1>>
		<<set $mercFreeManpower = random(5,20)>>
	<<elseif $mercenaries > 1>>
		<<set $mercFreeManpower = random(10,30)>>
	<</if>>
<</if>>

/* battle relevant variables */
<<set $troopCount = 0>>
<<set $slaveVictories = []>>
<<set $slaveIncreasedPrestige = 0>>
<<set $totalKills = 0>>
<<set $battlesCount = 0>>
<<set $majorBattlesCount = 0>>
<<set $chosenTactic = "none">>
<<set $leadingTroops = "none">>
<<set $attackTroops = 0>>
<<set $attackEquip = 0>>
<<set $deployableUnits = 0>>
<<set $deployedUnits = 0>>
<<set $deployingBots = 0>>
<<set $deployingMilitia = 0>>
<<set $deployingSlaves = 0>>
<<set $deployingMercs = 0>>
<<set $battleTerrain = "none">>
<<set $maxTurns = 10>>
<<set $battleResult = 4>>			/* sets $battleResult value outside accepted range (-3,3) to avoid evaluation problems */
<<set $losses = 0>>
<<set $enemyLosses = 0>>
<<set $battleTurns = 0>>
<<set $bribeCost = 0>>
<<set $tacticsSuccessful = 0>>
<<set $leaderWounded = 0>>
<<set $woundType = 0>>				/* 0=no wound, 1=mute, 2=blind, 3=amputee, 4<=health */
<<set $gainedCombat = 0>>
<<set $gainedWarfare = 0>>
<<set $PCWounded = 0>>
<<set $PCWoundCooldown = 0>>
<<set $expectedEquip = 0>>
<<set $estimatedMen = 0>>
<<set $SFIntervention = 0>>
<<set $carriableSoldiers = 0>>
<<set $SFatk = 0>>
<<set $SFdef = 0>>
<<set $SFhp = 0>>
<<set $rebellingID = []>>
<<set $saveValid = 0>>
<<set $lastSelection = []>>

/* statistics */
<<set $baseBribePerAttacker = 5>>
<<set $equipMod = 0.15>>
<<set $secBotsBaseAttack = 7>>
<<set $secBotsBaseDefense = 3>>
<<set $secBotsMorale = 200>>
<<set $secBotsBaseHp = 3>>
<<set $militiaBaseAttack = 7>>
<<set $militiaBaseDefense = 5>>
<<set $militiaBaseMorale = 140>>
<<set $militiaBaseHp = 3>>
<<set $slaveBaseAttack = 8>>
<<set $slaveBaseDefense = 3>>
<<set $slaveBaseMorale = 110>>
<<set $slaveBaseHp = 3>>
<<set $mercBaseAttack = 8>>
<<set $mercBaseDefense = 4>>
<<set $mercBaseMorale = 125>>
<<set $mercBaseHp = 4>>
<<set $SFBaseAttack = 8>>
<<set $SFBaseDefense = 4>>
<<set $SFBaseMorale = 140>>
<<set $SFBaseHp = 4>>

<<set $raBaseAttack = 7>>
<<set $raBaseDefense = 2>>
<<set $raBaseMorale = 100>>
<<set $raBaseHp = 2>>
<<set $fcBaseAttack = 6>>
<<set $fcBaseDefense = 4>>
<<set $fcBaseMorale = 130>>
<<set $fcBaseHp = 3>>
<<set $owBaseAttack = 8>>
<<set $owBaseDefense = 4>>
<<set $owBaseMorale = 110>>
<<set $owBaseHp = 2>>
<<set $ffBaseAttack = 9>>
<<set $ffBaseDefense = 2>>
<<set $ffBaseMorale = 160>>
<<set $ffBaseHp = 2>>

<<set $secBots = {
	active: 0,
	ID: -1,
	isDeployed: 0,
	troops: 0,
	maxTroops: 0,
	equip: 0} >>
<<set $militiaUnits = []>>
<<set $slaveUnits = []>>
<<set $mercUnits = []>>

/* SFanon additons */
<<set $SFSupportLevel = 0>>
<<set $SFSupportUpkeep = 0>>

/* helper widgets */
<<calcInitialTrade>>

repo_name: weresmilodon/fc

license: mit


code:
:: securityHQ [nobr]

<<if $career == "mercenary" || $career == "gang" || $career == "slaver">>
	<<set _HistoryDiscount = .5>>
<<else>>
	<<set _HistoryDiscount = 1>>
<</if>>

<<set $nextButton = "Back to Arcology Management", $nextLink = "Manage Arcology", $returnTo = "Manage Arcology">>

Security headquarters

The security headquarters stand in front of you. Innumerable screens flood with light the great central room. <<if $secHelots > 0>>Some slaves see you enter and interrupt their work to greet you.<</if>> From here you can build a safe and prosperous arcology.

/* security level. Slaves */
You have <<print $secHelots>> slaves working in the HQ. $reqHelots are required and you have <<print $helots>> free menial slaves.
<<if $secHelots < $reqHelots>>
	You do not have enough slaves here. You will not receive the full benefit of the installed upgrades.
<<else>>
	You have enough slaves to man all security systems.
<</if>>
<<silently>><<MenialPopCap>><</silently>>
<<set _menialPrice = Math.trunc(($slaveCostFactor*1000)/100)*100>>
<<set _menialPrice = Math.clamp(_menialPrice, 500, 1500)>>
<<if $PopCap > $helots+$fuckdolls+$menialBioreactors || $helots+$fuckdolls+$menialBioreactors == 0>>

	[[Buy|securityHQ][$helots+=1,$menialDemandFactor+=1,$cash-=_menialPrice]]
	<<if $cash > _menialPrice*10>>
		[[(x10)|securityHQ][$helots+=10,$menialDemandFactor+=10,$cash-=_menialPrice*10]]
	<</if>>
	<<if $cash > _menialPrice*100>>
		[[(x100)|securityHQ][$helots+=100,$menialDemandFactor+=100,$cash-=_menialPrice*100]]
	<</if>>
	<<if $cash > _menialPrice*2>>
		[[(max)|securityHQ][$helots+=Math.trunc($cash/(_menialPrice)),$menialDemandFactor+=Math.trunc($cash/(_menialPrice)),$cash-=Math.trunc($cash/(_menialPrice))*(_menialPrice)]]
	<</if>>
<</if>>

<<if $helots >= 5>>
	<<link "Transfer 5 menial slaves to the headquarters">>
		<<set $helots -= 5>>
		<<set $secHelots += 5>>
		<<replace "#secHel">><<print $secHelots>><</replace>>
		<<replace "#hel">><<print $helots>><</replace>>
		<<if $helots < 5 || $secHelots >= $reqHelots || $secHelots == 5>>
			<<goto "securityHQ">>
		<</if>>
	<</link>>
<<else>>
	Transfer 5 menial slaves to the headquarters
<</if>>
|
<<if $secHelots >= 5>>
	<<link "Transfer out 5 slaves">>
		<<set $helots += 5>>
		<<set $secHelots -= 5>>
		<<replace "#secHel">><<print $secHelots>><</replace>>
		<<replace "#hel">><<print $helots>><</replace>>
		<<if $secHelots < 5>>
			<<goto "securityHQ">>
		<</if>>
		<<if $secHelots < $reqHelots>>
			<<goto "securityHQ">>
		<</if>>
	<</link>>
<<else>>
	Transfer out 5 slaves
<</if>>
|
<<if $secHelots != $reqHelots>>
	<<link "Match the requirement">>
		<<if $helots >= $reqHelots - $secHelots>>
			<<set $helots -= $reqHelots - $secHelots>>
			<<set $secHelots = $reqHelots>>
		<<elseif $reqHelots < $secHelots>>
			<<set $helots += $secHelots - $reqHelots>>
			<<set $secHelots = $reqHelots>>
		<<else>>
			<<set $secHelots += $helots>>
			<<set $helots = 0>>
		<</if>>
		<<replace "#secHel">><<print $secHelots>><</replace>>
		<<replace "#hel">><<print $helots>><</replace>>
		<<if $secHelots == $reqHelots>>
			<<goto "securityHQ">>
		<</if>>
	<</link>>
<<else>>
	Match the requirement
<</if>>

/* security level and upgrades */
<<if $security <= 20>>
	Your security level (@@.deepskyblue;<<print $security>>@@) is dangerously low.
<<elseif $security <= 40>>
	Your security level (@@.deepskyblue;<<print $security>>@@) is low.
<<elseif $security <= 60>>
	Your security level (@@.deepskyblue;<<print $security>>@@) is decent.
<<elseif $security <= 80>>
	Your security level (@@.deepskyblue;<<print $security>>@@) is good.
<<else>>
	Your security level (@@.deepskyblue;<<print $security>>@@) is great.
<</if>>
Considering the current upgrades the resting level for security is <<print $secRestPoint>>, while the effective maximum level is <<print Math.trunc($secRestPoint * (Math.clamp($secHelots,0,$reqHelots) / $reqHelots))>>.

<<if $secUpgrades.nanoCams == 0>>
	[[Install a nano-camera system |securityHQ][$cash -= Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount), $secUpgrades.nanoCams = 1, $secRestPoint += 15, $reqHelots += 5, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will raise rest point of security by 10 points, but will require 5 extra slaves in the headquarters and increases upkeep.//
<<else>>
	You have installed all across the arcology closed circuit nano-cameras to keep the arcology under your watchful eye.
<</if>>

<<if $secUpgrades.cyberBots == 0>>
	[[Buy cybersecurity algorithms|securityHQ][$cash -= Math.trunc(7500*$upgradeMultiplierArcology*_HistoryDiscount), $secUpgrades.cyberBots = 1, $secRestPoint += 15, $reqHelots += 5, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(7500*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will raise rest point of security by 10 points, but will require 5 extra slaves in the headquarters and increases upkeep.//
<<else>>
	You have bought advanced cybersecurity algorithms that will defend your arcology against hack attempts or cyber frauds.
<</if>>

<<if $rep > 10000>>
	<<if $secUpgrades.eyeScan == 0>>
		[[Install invisible eye scanners|securityHQ][$cash -= Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount), $secUpgrades.eyeScan = 1, $secRestPoint += 20, $reqHelots += 10, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will raise rest point of security by 15 points, but will require 10 extra slaves in the headquarters and increases upkeep.//
	<<else>>
		You have installed numerous hidden eye scanners that accurately register the movements of everyone inside the arcology.
	<</if>>

	<<if $secUpgrades.cryptoAnalyzer == 0>>
		[[Buy and install crypto analyzers|securityHQ][$cash -= Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount), $secUpgrades.cryptoAnalyzer = 1, $secRestPoint += 20, $reqHelots += 10, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will raise rest point of security by 15 points, but will require 10 extra slaves in the headquarters and increases upkeep.//
	<<else>>
		You have bought and employed sophisticated crypto analyzing software to accurately track and archive every financial movement or transaction made inside the walls of your arcology.
	<</if>>
<<else>>

You lack the reputation to access more advanced upgrades.
<</if>>

/* crime level and upgrades */
<<if $crime <= 20>>
	Your crime level (@@.orangered;<<print $crime>>@@) is very low.
<<elseif $crime <= $upgradeUpkeep>>
	Your crime level (@@.orangered;<<print $crime>>@@) is low.
<<elseif $crime <= 60>>
	Your crime level (@@.orangered;<<print $crime>>@@) is average.
<<elseif $crime <= $upgradeUpkeep>>
	Your crime level (@@.orangered;<<print $crime>>@@) is high.
<<else>>
	Your crime level (@@.orangered;<<print $crime>>@@) is extremely high.
<</if>>
Considering the current upgrades the maximum level of crime is <<print $crimeCap>>, while the effective maximum level is <<print Math.trunc(Math.clamp($crimeCap + ($crimeCap - $crimeCap * ($secHelots / $reqHelots)),0,100))>>.

<<if $crimeUpgrades.advForensic == 0>>
	[[Install advanced forensic equipment|securityHQ][$cash -= Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount), $crimeUpgrades.advForensic = 1, $crimeCap -= 10, $reqHelots += 5, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will bring down the crime level cap by 10 points, but will require 5 extra slaves in the headquarters and increases upkeep.//
<<else>>
	You have installed advanced forensic equipment, able to extract every bit of precious information from any clue.
<</if>>

<<if $crimeUpgrades.autoArchive == 0>>
	[[Install auto-curating archiver|securityHQ][$cash -= Math.trunc(7500*$upgradeMultiplierArcology*_HistoryDiscount), $crimeUpgrades.autoArchive = 1, $crimeCap -= 10, $reqHelots += 5, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(7500*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will bring down the crime level cap by 10 points, but will require 5 extra slaves in the headquarters and increases upkeep.//
<<else>>
	You have installed auto-curating archiver software, which will update in real time your data archives with any new relevant information on criminals residing in your arcology.
<</if>>

<<if $rep > 10000>>
	<<if $crimeUpgrades.autoTrial == 0>>
		[[Install automated trials software|securityHQ][$cash -= Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount), $crimeUpgrades.autoTrial = 1, $crimeCap -= 15, $reqHelots += 10, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will bring down the crime level cap by 15 points, but will require 10 extra slaves in the headquarters and increases upkeep.//
	<<else>>
		You have installed advanced legal algorithms that allows the handling of legal matters much quicker and much more accurately.
	<</if>>

	<<if $crimeUpgrades.worldProfiler == 0>>
		[[Install worldwide profilers|securityHQ][$cash -= Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount), $crimeUpgrades.worldProfiler = 1, $crimeCap -= 15, $reqHelots += 10, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will bring down the crime level cap by 15 points, but will require 10 extra slaves in the headquarters and increases upkeep.//
	<<else>>
		You have installed advanced profiler software, which will constantly scour every known data archive on the globe (legally or not) to gather as much information as possible on dangerous criminals.
	<</if>>
<<else>>

You lack the reputation to access more advanced upgrades.
<</if>>

/* intelligence */

<<if $recon == 0>>
	Your reconnaissance capabilities are very limited. Very little information will be available if the arcology is attacked.
<<elseif $recon == 1>>
	You have limited reconnaissance capabilities. You'll have limited intel available in case of an attack.
<<elseif $recon == 2>>
	You have good reconnaissance capabilities. Good, reliable intel will be available if the arcology is attacked.
<<else>>
	You have great reconnaissance capabilities. You'll have very accurate information on the enemy if the arcology is attacked.
<</if>>

<<if $intelUpgrades.sensors == 0>>
	[[Install perimeter	sensors|securityHQ][$cash -= Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount), $intelUpgrades.sensors = 1, $recon += 1, $reqHelots += 5, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase recon capabilites, but will require 5 extra slaves in the headquarters and increases upkeep.//
<<else>>
	You have installed perimeter seismic sensors able to detect movement with high accuracy.
<</if>>

<<if $intelUpgrades.signalIntercept == 0>>
	[[Create signal interception hub|securityHQ][$cash -= Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount), $intelUpgrades.signalIntercept = 1, $recon += 1, $reqHelots += 5, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase recon capabilities, but will require 5 extra slaves in the headquarters and increases upkeep.//
<<else>>
	You have installed advanced signal interception equipment.
<</if>>

<<if $rep > 10000>>
	<<if $intelUpgrades.radar == 0>>
		[[Install advanced radar equipment|securityHQ][$cash -= Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount), $intelUpgrades.radar = 1, $recon += 1, $reqHelots += 10, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase recon capabilities, but will require 10 extra slaves in the headquarters and increases upkeep.//
	<<else>>
		You have installed sophisticated radar equipment.
	<</if>>
<<else>>

You lack the reputation to access more advanced upgrades.
<</if>>

/* readiness */

<<if $readiness == 1>>
	You have low readiness. You won't be able to mobilize many troops in time in case of an attack.
<<elseif $readiness == 2>>
	You have decent readiness. You will be able to muster up sufficient forces to handle an average attack.
<<elseif $readiness == 3>>
	You have good readiness. You will be able to mobilize a lot of troops in case of an attack.
<<else>>
	You have great readiness. You can mobilize an small army in very little time.
<</if>>

<<if $readinessUpgrades.pathways == 0>>
	[[Build specialized pathways in the arcology|securityHQ][$cash -= Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount), $readinessUpgrades.pathways = 1, $readiness += 1, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(5000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase readiness by 1, but will increases upkeep.//
<<else>>
	You have built specialized pathways inside the arcology to quickly move troops around the structure.
<</if>>

<<if $readinessUpgrades.rapidVehicles == 0>>
	[[Buy rapid armored transport vehicles|securityHQ][$cash -= Math.trunc(7500*$upgradeMultiplierArcology*_HistoryDiscount), $readinessUpgrades.rapidVehicles = 1, $readiness += 2, $reqHelots += 5, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(75000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase readiness by 2, but will require 5 extra slaves in the headquarters and increases upkeep.//
<<else>>
	You have bought rapid armored transport vehicles able to bring your troops to battle much quicker than before.
<</if>>

<<if $rep > 10000>>
	<<if $readinessUpgrades.rapidPlatforms == 0>>
		[[Build rapid deployment platforms|securityHQ][$cash -= Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount), $readinessUpgrades.rapidPlatforms = 1, $readiness += 2, $reqHelots += 5, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase readiness by 2, but will require 5 extra slaves in the headquarters and increases upkeep.//
	<<else>>
		You have built rapid deployment platforms able to equip and deploy units within very limited time windows.
	<</if>>

	<<if $readinessUpgrades.earlyWarn == 0>>
		[[Institute early warning systems|securityHQ][$cash -= Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount), $readinessUpgrades.earlyWarn = 1, $readiness += 2, $reqHelots += 10, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(15000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase readiness by 2, but will require 10 extra slaves in the headquarters and increases upkeep.//
	<<else>>
		You have created early warning systems that constantly analyze in real time data to determine the likeness of an attack.
	<</if>>
<<else>>

You lack the reputation to access more advanced upgrades.
<</if>>

<<if $rep > 12000>>

__Cold Data Storage Facility__:
	<<if $secUpgrades.coldstorage == 6 && $rep >= 19500 && $reqHelots > 10>>

You have installed a cold storage facility for the Security HQ's archives with a data retention capability of two years.

		[[Expand the cold storage facility to increase data retention to three years|securityHQ][$cash -= Math.trunc(2400000*$upgradeMultiplierArcology*_HistoryDiscount), $secUpgrades.coldstorage++, $reqHelots -= 10, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(2400000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will lower the amount of required slaves by a further 10, but will increases upkeep.//
	<<elseif $secUpgrades.coldstorage == 5 && $rep >= 19500 && $reqHelots > 10>>

You have installed a cold storage facility for the Security HQ's archives with a data retention capability of one year.

		[[Expand the cold storage facility to increase data retention to two years|securityHQ][$cash -= Math.trunc(1200000*$upgradeMultiplierArcology*_HistoryDiscount), $secUpgrades.coldstorage++, $reqHelots -= 10, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(1200000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will lower the amount of required slaves by a further 10, but will increases upkeep.//
	<<elseif $secUpgrades.coldstorage == 4 && $rep >= 19500 && $reqHelots > 10>>

You have installed a cold storage facility for the Security HQ's archives with a data retention capability of nine months.

		[[Expand the cold storage facility to increase data retention to one year|securityHQ][$cash -= Math.trunc(900000*$upgradeMultiplierArcology*_HistoryDiscount), $secUpgrades.coldstorage++, $reqHelots -= 10, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(900000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will lower the amount of required slaves by a further 10, but will increases upkeep.//
	<<elseif $secUpgrades.coldstorage == 3 && $rep > 18000 && $reqHelots > 10>>

You have installed a cold storage facility for the Security HQ's archives with a data retention capability of six months.

		[[Expand the cold storage facility to increase data retention to nine months|securityHQ][$cash -= Math.trunc(600000*$upgradeMultiplierArcology*_HistoryDiscount), $secUpgrades.coldstorage++, $reqHelots -= 10, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(600000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will lower the amount of required slaves by a further 10, but will increases upkeep.//
	<<elseif $secUpgrades.coldstorage == 2 && $rep > 16000 && $reqHelots > 10>>

You have installed a cold storage facility for the Security HQ's archives with a data retention capability of three months.

		[[Expand the cold storage facility to increase data retention to six months|securityHQ][$cash -= Math.trunc(300000*$upgradeMultiplierArcology*_HistoryDiscount), $secUpgrades.coldstorage++, $reqHelots -= 10, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(300000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will lower the amount of required slaves by a further 10, but will increases upkeep.//
	<<elseif $secUpgrades.coldstorage == 1 && $rep > 14000 && $reqHelots > 10>>

You have installed a cold storage facility for the Security HQ's archives with a data retention capability of one month.

		[[Expand the cold storage facility to increase data retention to three months|securityHQ][$cash -= Math.trunc(100000*$upgradeMultiplierArcology*_HistoryDiscount), $secUpgrades.coldstorage++, $reqHelots -= 10, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(100000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will lower the amount of required slaves by a further 10, but will increases upkeep.//
	<<elseif $secUpgrades.coldstorage == 0 && $rep > 12000 && $reqHelots > 10>>
		[[Install a cold storage facility|securityHQ][$cash -= Math.trunc(50000*$upgradeMultiplierArcology*_HistoryDiscount), $secUpgrades.coldstorage++, $reqHelots -= 10, $secHQUpkeep += $upgradeUpkeep]]

//Costs <<print cashFormat(Math.trunc(50000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will lower the amount of required slaves by 10, but will increases upkeep.//
	<<elseif $secUpgrades.coldstorage > 6>>

You have installed a cold storage facility for the Security HQ's archives with a data retention capability of three years.
	<<elseif $reqHelots <= 10>>

Personnel cannot be further reduced.
	<<else>>

You lack the reputation to access more advanced upgrades.
	<</if>>
<</if>>


code:
:: securityReport [nobr]

/* init */
<<set _immigration = $ACitizens - $oldACitizens>>
<<set _secGrowth = 0>>
<<set _secRest = 0>>
<<set _restGrowth = 0>>
<<set _newSec = 0>>
<<set _crimeGrowth = 0>>
<<set _crimeCap = 0>>
<<set _newCrime = 0>>
<<set _recruits = 0>>
<<set _newMercs = 0>>

<<if $useTabs == 0>>__Security__<</if>>

Security:
<<if $secHelots > 0>>
	<<print $secHelots>> slaves work to improve the security of your arcology,
	<<if $mercenaries >= 1 && $arcologyUpgrade.drones == 1>>
		while your mercenaries and security drones tirelessly patrol the streets to keep them safe.
	<<elseif $arcologyUpgrade.drones == 1>>
		while your security drones tirelessly patrol the arcology to keep it safe.
	<<else>>
		while your loyal subordinates try to keep the arcology safe to the best of their abilities.
	<</if>>
<<else>>
	<<if $mercenaries >= 1 && $arcologyUpgrade.drones == 1>>
		Your mercenaries and security drones tirelessly patrol the streets to keep them safe.
	<<elseif $arcologyUpgrade.drones == 1>>
		Your security drones tirelessly patrol the arcology to keep it safe.
	<<else>>
		Your loyal subordinates try to keep the arcology safe to the best of their abilities.
	<</if>>
<</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 $smilingManFate == 0>>
	The ex-criminal known to the world as The Smiling Man puts her impressive skills to work, dramatically increasing the efficacy of your security measures.
	<<set _secGrowth += 2>>
<</if>>
<<if $ACitizens + $ASlaves <= 2000>>
	The small number of residents makes their job easier.<<set _secGrowth += 2>>
<<elseif $ACitizens + $ASlaves <= 4000>>
	The fairly low number of residents makes their job a little easier.<<set _secGrowth += 1>>
<<elseif $ACitizens + $ASlaves <= 6000>>
	The fairly high number of residents makes their job a little harder.<<set _secGrowth -= -0.5>>
<<elseif $ACitizens + $ASlaves <= 8000>>
	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 < 10>>
	The limited number of immigrants that reached the arcology this week does not have any serious impact on the efficacy of current security measures.<<set _secGrowth += 0.5>>
<<elseif _immigration < 30>>
	The number of immigrants that reached the arcology this week is high enough to complicate security protocols.<<set _secGrowth -= 0.2>>
<<elseif _immigration < 60>>
	The high number of immigrants that reached the arcology this week complicates security protocols.<<set _secGrowth -= 0.5>>
<<elseif _immigration < 80>>
	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 $crime < 20>>
	Crime is a distant problem in the arcology, which makes improving security easier.<<set _secGrowth += 1>>
<<elseif $crime < 40>>
	Crime is a minor problem in the arcology, not serious enough to disrupt security efforts.
<<elseif $crime < 60>>
	Crime is an issue in the arcology, which makes improving security harder.<<set _secGrowth -= 0.5>>
<<elseif $crime < 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 $authority < 5000>>
	The low authority you hold on the arcology hampers the efforts of your security department.<<set _secGrowth -= 1>>
<<elseif $authority < 7500>>
	The limited authority you hold on the arcology hampers the efforts of your security department.<<set _secGrowth -= 0.5>>
<<elseif $authority < 10000>>
	The authority you hold on the arcology does not significantly impact the efforts of your security department.
<<elseif $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 $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>>
<<if $lastAttackWeeks < 3 && $hasFoughtOnce == 1>>
	The recent attack has a negative effect on the security of the arcology.<<set _secGrowth -= 1>>
<<elseif $lastAttackWeeks < 5 && $hasFoughtOnce == 1>>
	While some time has passed, the last attack still has a negative effect on the security of the arcology.<<set _secGrowth -= 0.5>>
<<elseif $hasFoughtOnce == 1>>
	The arcology has not been attacked in a while, which has a positive effect on security.<<set _secGrowth += 0.5>>
<</if>>

<<if $transportHub == 1>>
	<<if $terrain != "oceanic" && $terrain != "marine">>
		<<set _secGrowth -= ($airport + $railway - $hubSecurity * 3) / 2>>
	<<else>>
		<<set _secGrowth -= ($airport + $docks - $hubSecurity * 3) / 2>>
	<</if>>
	<<if $airport + $docks > $hubSecurity * 3>>
		The transport hub, for all its usefulness, is a hotspot of malicious activity and hub security forces are not sufficient to keep up with all threats.
	<<else>>
		The transport hub, for all its usefulness, is a hotspot of malicious activity, but the hub security forces are up to the task.
	<</if>>
<</if>>

<<if $blackOps == 1>>
	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--, $PC.engineering += .1>>
<</if>>

<<if $SFSupportLevel >= 3>>
	The two squads of $securityForceName assigned to the Security HQ provide an essential help to the security department.
<</if>>
<<if $SFSupportLevel >= 2>>
	The training officers of $securityForceName assigned to the Security HQ improve its effectiveness.
<</if>>
<<if $SFSupportLevel >= 1>>
	Providing your Security Department with equipment from $securityForceName slightly boosts the security of your arology.
<</if>>

/* resting point */
<<set _secRest = $secRestPoint * (Math.clamp($secHelots,0,$reqHelots) / $reqHelots)>>
<<if _secRest < 0>>
	<<set _secRest = 20>>
<</if>>
<<if _secRest < $secRestPoint && $secHQ == 1>>
	The limited staff assigned to the HQ hampered the improvements to security achieved this week.
<<elseif _secRest < $secRestPoint>>
	The limited infrastructure available slowly erodes away the security level of the arcology.
<</if>>
<<if $security > (_secRest + 5)>>
	The security level of the arcology is over its effective resting point, limiting the achievable growth this week.
	<<set _secGrowth *= 0.5>>
<<elseif $security < (_secRest - 5)>>
	The security level of the arcology is under its effective resting point, speeding up its growth.
	<<set _secGrowth *= 1.5>>
<<elseif $security ==  _secRest>>
	The security level of the arcology is at its effective resting point, this severely limits the influence of external factors on the change achievable this week.
	<<set _secGrowth *= 0.3>>
<<else>>
	The security level of the arcology is 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 - $security) * 0.2>>
<<set _newSec = Math.trunc($security + _secGrowth + _restGrowth)>>
<<if _newSec < $security>>
	This week @@.red;security decreased@@.
<<elseif _newSec == $security>>
	This week @@.yellow;security did not change@@.
<<else>>
	This week @@.green;security improved@@.
<</if>>
<<set $security = Math.clamp(_newSec, 0, 100)>>

Crime:
/* crime modifiers */
<<if $week < 30>>
	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 small impact on the growth of criminal activities in your arcology.<<set _crimeGrowth += 0.5>>
<<elseif $week < 60>>
	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 noticeable impact on the growth of criminal activities in your arcology.<<set _crimeGrowth += 1>>
<<elseif $week < 90>>
	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 moderate impact on the growth of criminal activities in your arcology.<<set _crimeGrowth += 1.5>>
<<elseif $week < 120>>
	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 big impact on the growth of criminal activities in your arcology.<<set _crimeGrowth += 2>>
<<else>>
	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 huge impact on the growth of criminal activities in your arcology.<<set _crimeGrowth += 2.5>>
<</if>>
<<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 a big issue for law enforcement, facilitating crime growth.<<set _crimeGrowth += 1.5>>
<</if>>
<<if $security <= 20>>
	The security measures in place are severely limited, allowing crime to grow uncontested.
<<elseif $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 $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 $authority < 5000>>
	Your low authority allows crime to grow undisturbed.<<set _crimeGrowth += 1>>
<<elseif $authority < 7500>>
	Your relatively low authority facilitates criminal activities.<<set _crimeGrowth += 0.5>>
<<elseif $authority < 10000>>
	Your authority is not high enough to discourage criminal activity.
<<elseif $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 $marketInfiltration == 1>>
	<<set _crimeGrowth += 0.5 * random(1,2)>>
<</if>>

/* crime cap */
<<set _crimeCap = Math.trunc(Math.clamp($crimeCap + ($crimeCap - $crimeCap * ($secHelots / $reqHelots)),0,100))>>
<<if _crimeCap > $crimeCap && $secHQ == 1>>
	The limited staff assigned to the HQ allows more space for criminals to act.
<</if>>
<<set _newCrime = Math.trunc(Math.clamp($crime + _crimeGrowth,0,_crimeCap))>>
<<if _newCrime > $crime>>
	This week @@.red;crime increased@@.
<<elseif _newCrime == $crime>>
	This week @@.yellow;crime did not change@@.
<<else>>
	This week @@.green;crime decreased@@.
<</if>>
<<set $crime = Math.clamp(_newCrime,0,100)>>

<<if $militiaFounded == 1 || $activeUnits >= 1>>

	/* militia */
	Military:
	<<if $recruitVolunteers == 1>>
		Your militia accepts only volunteering citizens, ready to defend their arcology.
		<<set _recruits = random(1,2)>>
		<<if $rep >= 10000>>
			Many citizens volunteer just to fight for someone of your renown.
			<<set _recruits += 1>>
		<</if>>
		<<if $authority >= 10000>>
			Many citizens feel it is their duty to fight for you, boosting volunteer enrollment.
			<<set _recruits += 1>>
		<</if>>
		<<if $lowerRquirements == 1>>
			Your lax physical requirements to enter the militia allows for a greater number of citizens to join.
			<<set _recruits += 1>>
		<</if>>
		<<if $militiaTotalManpower - $militiaTotalCasualties + _recruits <= 0.02 * $ACitizens>>
			<<set $militiaTotalManpower += _recruits>>
			<<set $militiaFreeManpower += _recruits>>
			This week <<print _recruits>> citizens joined the militia.
		<<else>>
			There are not many more citizens willing to join the arcology armed forces. You'll need to enact higher recruitment edicts if you need more manpower.
		<</if>>
	<<elseif $conscription == 1>>
		Adult citizens are required to join the militia for a period of time.
		<<set _recruits = random(3,5)>>
		<<if $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 _recruits -= random(1,2)>>
			<<set $cash += 250>>
		<</if>>
		<<if $lowerRquirements == 1>>
			Your lax physical requirements to enter the militia allows for a greater number of citizens to join.
			<<set _recruits += 1>>
		<</if>>
		<<if $noSubhumansInArmy == 1>>
			Guaranteeing the purity of your armed forces comes with a small loss of potential recruits.
			<<set _recruits -= random(0,1)>>
		<</if>>
		<<if $pregExemption == 1>>
			Many pregnant citizens prefer to avoid military service not to endanger themselves and their children.
			<<set _recruits -= 1>>
		<</if>>
		<<if $militiaTotalManpower - $militiaTotalCasualties + _recruits <= 0.05 * $ACitizens>>
			<<set $militiaTotalManpower += _recruits>>
			<<set $militiaFreeManpower += _recruits>>
			This week <<print _recruits>> citizens joined the militia.
		<<else>>
			There are not many more citizens able to join the arcology armed forces. You'll need to enact higher recruitment edicts if you need more manpower.
		<</if>>
	<<elseif $militaryService == 1>>
		Adult citizens are required to register and serve in the militia whenever necessary.
		<<set _recruits = random(5,7)>>
		<<if $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 _recruits -= random(1,2)>>
			<<set $cash += 250>>
		<</if>>
		<<if $lowerRquirements == 1>>
			Your lax physical requirements to enter the militia allows for a greater number of citizens to join.
			<<set _recruits += 1>>
		<</if>>
		<<if $noSubhumansInArmy == 1>>
			Guaranteeing the purity of your armed forces comes with a small loss of potential recruits.
			<<set _recruits -= random(0,1)>>
		<</if>>
		<<if $pregExemption == 1>>
			Many pregnant citizens prefer to avoid military service not to endanger themselves and their children.
			<<set _recruits -= 1>>
		<</if>>
		<<if $militiaTotalManpower - $militiaTotalCasualties + _recruits <= 0.10 * $ACitizens>>
			<<set $militiaTotalManpower += _recruits>>
			<<set $militiaFreeManpower += _recruits>>
			This week <<print _recruits>> citizens joined the militia.
		<<else>>
			There are not many more citizens able to join the arcology armed forces. You'll need to enact higher recruitment edicts if you need more manpower.
		<</if>>
	<<elseif $militarizedSociety == 1>>
		Every citizen is required to train and participate in the military activities of the arcology.
		<<set _recruits = random(7,9)>>
		<<if $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 _recruits -= random(1,2)>>
			<<set $cash += 250>>
		<</if>>
		<<if $lowerRquirements == 1>>
			Your lax physical requirements to enter the militia allows for a greater number of citizens to join.
			<<set _recruits += 1>>
		<</if>>
		<<if $noSubhumansInArmy == 1>>
			Guaranteeing the purity of your armed forces comes with a small loss of potential recruits.
			<<set _recruits -= random(0,1)>>
		<</if>>
		<<if $pregExemption == 1>>
			Many pregnant citizens prefer to avoid military service not to endanger themselves and their children.
			<<set _recruits -= 1>>
		<</if>>
		<<if $militiaTotalManpower - $militiaTotalCasualties + _recruits <= 0.20 * $ACitizens>>
			<<set $militiaTotalManpower += _recruits>>
			<<set $militiaFreeManpower += _recruits>>
			This week <<print _recruits>> citizens joined the militia.
		<<else>>
			There are not many more citizens able to join the arcology armed forces. 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 $crime > 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>>
		<<set _newMercs = Math.trunc(_newMercs / 2)>>
		<<if _newMercs > 0>>
			<<set $mercTotalManpower += _newMercs>>
			<<set $mercFreeManpower += _newMercs>>
			This week <<print _newMercs>> mercenaries reached the arcology.
		<<else>>
			This week no new mercenaries reached the arcology.
		<</if>>
		<<if $mercFreeManpower > 2000>>
			<<set $mercTotalManpower -= $mercFreeManpower - 2000>>
			<<set $mercFreeManpower = 2000>>
		<</if>>
	<</if>>

	/* loyalty and training */
	<<set _sL = $slaveUnits.length>>
	<<for _i = 0; _i < _sL; _i++>>
		<<set _loyaltyChange = 0>>

$slaveUnits[_i].platoonName:
		<<if $secBarracksUpgrades.loyaltyMod >= 1>>
			<<set _loyaltyChange += 2 * $secBarracksUpgrades.loyaltyMod>>
			is periodically sent to the indoctrination facility in the barracks for thought correction therapy.
		<</if>>
		<<if $slaveUnits[_i].commissars >= 1>>
			The commissars attached to the unit carefully monitor the officers and grunts for signs of insubordination.
			<<set _loyaltyChange += 2 * $slaveUnits[_i].commissars>>
		<</if>>
		<<if $soldierWages == 2>>
			The slaves greatly appreciate the generous wage given to them for their service as soldiers. Occasions to earn money for a slave are scarce after all.
			<<set _loyaltyChange += random(5,10)>>
		<<elseif $soldierWages == 1>>
			The slaves appreciate the wage given to them for their service as soldiers, despite it being just adequate. Occasions to earn money for a slave are scarce after all.
			<<set _loyaltyChange += random(-5,5)>>
		<<else>>
			The slaves do not appreciate the low wage given to them for their service as soldiers, but occasions to earn money for a slave are scarce, so they're not too affected by it.
			<<set _loyaltyChange -= random(5,10)>>
		<</if>>
		<<if $slaveSoldierPrivilege == 1>>
			Allowing them to hold material possessions earns you their devotion and loyalty.
			<<set _loyaltyChange += random(1,2)>>
		<</if>>
		<<if _loyaltyChange > 0>>
			The loyalty of this unit @@.green;increased@@ this week.
		<<elseif _loyaltyChange == 0>>
			The loyalty of this unit @@.yellow;did not change@@ this week.
		<<else>>
			The loyalty of this unit @@.red;decreased@@ this week.
		<</if>>
		<<set $slaveUnits[_i].loyalty = Math.clamp($slaveUnits[_i].loyalty + _loyaltyChange,0,100)>>
		<<if $slaveUnits[_i].training < 100 && $secBarracksUpgrades.training >= 1>>

The unit is able to make use of the training facilities to better prepare its soldiers, slowing increasing their experience level.
			<<set $slaveUnits[_i].training += random(2,4) * 1.5 * $secBarracksUpgrades.training>>
		<</if>>
	<</for>>
	<<set _mL = $militiaUnits.length>>
	<<for _i = 0; _i < _mL; _i++>>

$militiaUnits[_i].platoonName:
		<<set _loyaltyChange = 0>>
		<<if $secBarracksUpgrades.loyaltyMod >= 1>>
			<<set _loyaltyChange += 2 * $secBarracksUpgrades.loyaltyMod>>
			is periodically sent to the indoctrination facility in the barracks for thought correction therapy.
		<</if>>
		<<if $militiaUnits[_i].commissars >= 1>>
			The commissars attached to the unit carefully monitor the officers and grunts for signs of insubordination.
			<<set _loyaltyChange += 2 * $militiaUnits[_i].commissars>>
		<</if>>
		<<if $soldierWages == 2>>
			The soldiers greatly appreciate the generous wage given to them for their service. They are proud to defend their homes while making a small fortune out of it.
			<<set _loyaltyChange += random(5,10)>>
		<<elseif $soldierWages == 1>>
			The soldiers appreciate the wage given to them for their service, despite it being just adequate. They are proud to defend their homes, though at the cost of possible financial gains.
			<<set _loyaltyChange += random(-5,5)>>
		<<else>>
			The soldiers do not appreciate the low wage given to them for their service. Their sense of duty keeps them proud of their role as defenders of the arcology, but many do feel its financial weight.
			<<set _loyaltyChange -= random(5,10)>>
		<</if>>
		<<if $militiaSoldierPrivilege == 1>>
			Allowing them to avoid rent payment for their military service earns you their happiness and loyalty.
			<<set _loyaltyChange += random(1,2)>>
		<</if>>
		<<if _loyaltyChange > 0>>
			The loyalty of this unit @@.green;increased@@ this week.
		<<elseif _loyaltyChange == 0>>
			The loyalty of this unit @@.yellow;did not change@@ this week.
		<<else>>
			The loyalty of this unit @@.red;decreased@@ this week.
		<</if>>
		<<set $militiaUnits[_i].loyalty = Math.clamp($militiaUnits[_i].loyalty + _loyaltyChange,0,100)>>
		<<if $militiaUnits[_i].training < 100 && $secBarracksUpgrades.training >= 1>>

The unit is able to make use of the training facilities to better prepare its soldiers, slowing increasing their experience level.
			<<set $militiaUnits[_i].training += random(2,4) * 1.5 * $secBarracksUpgrades.training>>
		<</if>>
	<</for>>
	<<set _meL = $mercUnits.length>>
	<<for _i = 0; _i < _meL; _i++>>

$mercUnits[_i].platoonName:
		<<set _loyaltyChange = 0>>
		<<if $secBarracksUpgrades.loyaltyMod >= 1>>
			<<set _loyaltyChange += 2 * $secBarracksUpgrades.loyaltyMod>>
			is periodically sent to the indoctrination facility in the barracks for thought correction therapy.
		<</if>>
		<<if $mercUnits[_i].commissars >= 1>>
			The commissars attached to the unit carefully monitor the officers and grunts for signs of insubordination.
			<<set _loyaltyChange += 2 * $mercUnits[_i].commissars>>
		<</if>>
		<<if $soldierWages == 2>>
			The mercenaries greatly appreciate the generous wage given to them for their service. After all coin is the fastest way to reach their hearts.
			<<set _loyaltyChange += random(5,10)>>
		<<elseif $soldierWages == 1>>
			The mercenaries do not appreciate the barely adequate wage given to them for their service. Still their professionalism keeps them determined to finish their contract.
			<<set _loyaltyChange += random(-5,5)>>
		<<else>>
			The mercenaries do not appreciate the low wage given to them for their service.Their skill would be better served by a better contract and this world does not lack demand for guns for hire.
			<<set _loyaltyChange -= random(5,10)>>
		<</if>>
		<<if $mercSoldierPrivilege == 1>>
			Allowing them to keep part of the loot gained from your enemies earns you their trust and loyalty.
			<<set _loyaltyChange += random(1,2)>>
		<</if>>
		<<if _loyaltyChange > 0>>
			The loyalty of this unit @@.green;increased@@ this week.
		<<elseif _loyaltyChange == 0>>
			The loyalty of this unit @@.yellow;did not change@@ this week.
		<<else>>
			The loyalty of this unit @@.red;decreased@@ this week.
		<</if>>
		<<set $mercUnits[_i].loyalty = Math.clamp($mercUnits[_i].loyalty + _loyaltyChange,0,100)>>
		<<if $mercUnits[_i].training < 100 && $secBarracksUpgrades.training >= 1>>

The unit is able to make use of the training facilities to better prepare its soldiers, slowing increasing their experience level.
			<<set $mercUnits[_i].training += random(2,4) * 1.5 * $secBarracksUpgrades.training>>
		<</if>>
	<</for>>
<</if>>

<<if $brainImplantProject > 0 && $brainImplant < 106>>

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

<<if $currentUpgrade.time > 0>>

	In the research lab, <<print $currentUpgrade.name>> is being developed, with the objective to enhance
	<<if $currentUpgrade.type == "attack">>
		attack power
	<<elseif $currentUpgrade.type == "defense">>
		defense capabilities
	<<elseif $currentUpgrade.type == "hp">>
		survivability
	<<elseif $currentUpgrade.type == "morale">>
		standing power
	<<elseif $currentUpgrade.type == "attackAndDefense">>
		offensive and defensive effectiveness
	<<elseif $currentUpgrade.type == "hpAndMorale">>
		morale and survivability
	<<elseif $currentUpgrade.type == "all">>
		offensive,defensive effectiveness in addition to morale and survivability
	<</if>>
	for <<if $currentUpgrade.unit == 0>> the security drones<<else>> our human troops<</if>>.

	<<set $currentUpgrade.time-->>
	<<if $currentUpgrade.time <= 0>>
		Reports indicate it is ready for deployment and will be issued to
		<<if $currentUpgrade.unit == 0>>
			the security drones
			<<if $currentUpgrade.type == "attack">>
				<<set $droneUpgrades.attack++>>
			<<elseif $currentUpgrade.type == "defense">>
				<<set $droneUpgrades.defense++>>
			<<elseif $currentUpgrade.type == "hp">>
				<<set $droneUpgrades.hp++>>
			<</if>>
		<<else>>
			all human troops
			<<if $currentUpgrade.type == "attack">>
				<<set $humanUpgrade.attack++>>
			<<elseif $currentUpgrade.type == "defense">>
				<<set $humanUpgrade.defense++>>
			<<elseif $currentUpgrade.type == "hp">>
				<<set $humanUpgrade.hp++>>
			<<elseif $currentUpgrade.type == "morale">>
				<<set $humanUpgrade.morale += 10>>
			<<elseif $currentUpgrade.type == "attackAndDefense">>
				<<set $humanUpgrade.attack++>>
				<<set $humanUpgrade.defense++>>
			<<elseif $currentUpgrade.type == "hpAndMorale">>
				<<set $humanUpgrade.hp++>>
				<<set $humanUpgrade.morale += 10>>
			<<elseif $currentUpgrade.type == "all">>
				<<set $humanUpgrade.attack++>>
				<<set $humanUpgrade.defense++>>
				<<set $humanUpgrade.hp++>>
				<<set $humanUpgrade.morale += 10>>
			<</if>>
		<</if>>
		<<set $currentUpgrade.name = " ">>
		<<set $currentUpgrade.type = " ">>
		<<set $currentUpgrade.unit = -1>>
		<<set $currentUpgrade.time = 0>>
		in the next days.
		<<recalcBaseStats>>
		<<set $completedUpgrades.push($currentUpgrade.ID)>>
	<<else>>
		It will be finished in <<if $currentUpgrade.time == 1>> one week.<<else>><<print $currentUpgrade.time>> weeks.<</if>>
	<</if>>
<</if>>