:: 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>>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br>__Security__<</if>>
<br>

<strong>Security</strong>:
<<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.<br>
<<if $secMenials > 0>>
	<<print num($secMenials)>> 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 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>>
<<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>>
	The transport hub, for all its usefulness, is a hotspot of malicious
	<<if $airport + $docks > $hubSecurity * 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.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 $SFSupportLevel >= 3>>
		The two squads of $SF.Lower assigned to the Security HQ provide an essential help to the security department.
	<</if>>
	<<if $SFSupportLevel >= 2>>
		The training officers of $SF.Lower assigned to the Security HQ improve its effectiveness.
	<</if>>
	<<if $SFSupportLevel >= 1>>
		Providing your Security Department with equipment from $SF.Lower slightly boosts the security of your arcology.
	<</if>>
	<<if $SFSupportLevel >= 1>>
		<<set _secGrowth *= 1+($SFSupportLevel/10)>>
	<</if>>
<</if>>

/* resting point */
<<set _secRest = App.SecExp.Check.secRestPoint() * (Math.clamp($secMenials,0,App.SecExp.Check.reqMenials()) / App.SecExp.Check.reqMenials())>>
<<if _secRest < 0>>
	<<set _secRest = 20>>
<</if>>
<<if _secRest < App.SecExp.Check.reqMenials() && $secHQ == 1>>
	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.security.cap > (_secRest + 5)>>
	over its effective resting point, limiting the achievable growth this week.
	<<set _secGrowth *= 0.5>>
<<elseif $SecExp.security.cap < (_secRest - 5)>>
	under its effective resting point, speeding up its growth.
	<<set _secGrowth *= 1.5>>
<<elseif $SecExp.security.cap == _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.security.cap) * 0.2>>
<<set _newSec = Math.trunc($SecExp.security.cap + _secGrowth + _restGrowth)>>
<<if _newSec < $SecExp.security.cap>>
	This week @@.red;security decreased.@@
<<elseif _newSec == $SecExp.security.cap>>
	This week @@.yellow;security did not change.@@
<<else>>
	This week @@.green;security improved.@@
<</if>>
<<set $SecExp.security.cap = Math.clamp(_newSec, 0, 100)>>

<br><br>
<strong>Crime</strong>:
/* 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.security.cap <= 20>>
	The security measures in place are severely limited, allowing crime to grow uncontested.
<<elseif $SecExp.security.cap <= 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.security.cap <= 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.active > 0 && $SecExp.buildings.propHub.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() * ($secMenials / App.SecExp.Check.reqMenials())),0,100))>>
<<if _crimeCap > App.SecExp.Check.crimeCap() && $secHQ == 1>>
	The limited staff assigned to the HQ allows more space for criminals to act.
<</if>>
<<if $SecExp.core.authority > 12000>>
	<<if $secUpgrades.coldstorage < 6>>
		<<if $secUpgrades.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 $militiaFounded == 1 || App.SecExp.battle.activeUnits() >= 1>>
	<br><br>
	<strong> Military</strong>: /* militia */
	<<if $SF.Toggle && $SF.Active >= 1 && $SF.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($SF.Size / 10))) / 20)>> /* not sure how high $SF.Size goes, so I hope this makes sense */
	<</if>>
	<<if $SecExp.buildings.propHub.active > 0>>
		<<if $SecExp.buildings.propHub.campaign >= 1 && $SecExp.buildings.propHub.focus == "recruitment">>
			<<if $SecExp.buildings.propHub.recuriterOffice === 0 || $Recruiter == 0>>
				<<if $propCampaignBoost == 1>>
					<<set _recruitsMultiplier *= 1.1>>
				<<else>>
					<<set _recruitsMultiplier *= 1.05>>
				<</if>>
			<<elseif $SecExp.buildings.propHub.recuriterOffice > 0 && $Recruiter > 0>>
				<<setLocalPronouns $Recruiter>>
				<span class='slave-name'><<= SlaveFullName($Recruiter)>></span> is able to further boost your militia recruitment campaign from $his PR hub office.
				<<if $propCampaignBoost == 1>>
					<<set _recruitsMultiplier *= 1.2 + (($Recruiter.intelligence+$Recruiter.intelligenceImplant)/650)>>
				<<else>>
					<<set _recruitsMultiplier *= 1.15 + (($Recruiter.intelligence+$Recruiter.intelligenceImplant)/650)>>
				<</if>>
			<</if>>
		<</if>>
	<</if>>
	<<if $recruitVolunteers == 1>>
		Your militia accepts only volunteering citizens, ready to defend their arcology.
		<<set _recruitLimit = 0.02>>
		<<if $rep >= 10000>>
			Many citizens volunteer just to fight for someone of your renown.
			<<set _recruitLimit += 0.0025>>
		<</if>>
		<<if $SecExp.core.authority >= 10000>>
			Many citizens feel it is their duty to fight for you, boosting volunteer enrollment.
			<<set _recruitLimit += 0.0025>>
		<</if>>
		<<if $lowerRquirements == 1>>
			Your lax physical requirements to enter the militia allows for a greater number of citizens to join.
			<<set _recruitLimit += 0.0025>>
		<</if>>
	<<elseif $conscription == 1>>
		Adult citizens are required to join the militia for a period of time.
		<<set _recruitLimit = 0.05>>
		<<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 _recruitLimit -= 0.005>>
			<<run cashX(250, "securityExpansion")>>
		<</if>>
		<<if $lowerRquirements == 1>>
			Your lax physical requirements to enter the militia allows for a greater number of citizens to join.
			<<set _recruitLimit += 0.005>>
		<</if>>
		<<if $noSubhumansInArmy == 1>>
			Guaranteeing the purity of your armed forces comes with a small loss of potential recruits.
			<<set _recruitLimit -= 0.005>>
		<</if>>
		<<if $pregExemption == 1>>
			Many pregnant citizens prefer to avoid military service not to endanger themselves and their children.
			<<set _recruitLimit -= 0.005>>
		<</if>>
	<<elseif $militaryService == 1>>
		Adult citizens are required to register and serve in the militia whenever necessary.
		<<set _recruitLimit = 0.1>>
		<<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 _recruitLimit -= 0.01>>
			<<run cashX(250, "securityExpansion")>>
		<</if>>
		<<if $lowerRquirements == 1>>
			Your lax physical requirements to enter the militia allows for a greater number of citizens to join.
			<<set _recruitLimit += 0.01>>
		<</if>>
		<<if $noSubhumansInArmy == 1>>
			Guaranteeing the purity of your armed forces comes with a small loss of potential recruits.
			<<set _recruitLimit -= 0.01>>
		<</if>>
		<<if $pregExemption == 1>>
			Many pregnant citizens prefer to avoid military service not to endanger themselves and their children.
			<<set _recruitLimit -= 0.01>>
		<</if>>
	<<elseif $militarizedSociety == 1>>
		Every citizen is required to train and participate in the military activities of the arcology.
		<<set _recruitLimit = 0.2>>
		<<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 _recruitLimit -= 0.02>>
			<<run cashX(250, "securityExpansion")>>
		<</if>>
		<<if $lowerRquirements == 1>>
			Your lax physical requirements to enter the militia allows for a greater number of citizens to join.
			<<set _recruitLimit += 0.02>>
		<</if>>
		<<if $noSubhumansInArmy == 1>>
			Guaranteeing the purity of your armed forces comes with a small loss of potential recruits.
			<<set _recruitLimit -= 0.02>>
		<</if>>
		<<if $pregExemption == 1>>
			Many pregnant citizens prefer to avoid military service not to endanger themselves and their children.
			<<set _recruitLimit -= 0.02>>
		<</if>>
	<</if>>
	<<if $militiaFounded == 1>>
		<<set _recruits = Math.trunc((_recruitLimit * $ACitizens - ($militiaTotalManpower - $militiaTotalCasualties)) / 20 * _recruitsMultiplier)>>
		<<if _recruits > 0>>
			<<set $militiaTotalManpower += _recruits>>
			<<set $militiaFreeManpower += _recruits>>
			This week <<print _recruits>> citizens joined the militia.
		<<elseif $militarizedSociety == 1>>
			No citizens joined your militia this week because your society is as militarized as it can get.
		<<elseif $recruitVolunteers == 1>>
			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>>
		<br>
	<</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 && $SF.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($SF.Size/10))>>
		<</if>>
		<<if $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 $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>>
		<br>
	<</if>>

	<<if App.SecExp.battle.activeUnits() > 0>>
		/* loyalty and training */
		<<set _sL = $slaveUnits.length>>
		<<for _i = 0; _i < _sL; _i++>>
			<<set _loyaltyChange = 0>>
			<br>
			<br> $slaveUnits[_i].platoonName:
			<<if $SecExp.buildings.barracks.upgrades.loyaltyMod >= 1>>
				<<set _loyaltyChange += 2 * $SecExp.buildings.barracks.upgrades.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 && $SecExp.buildings.barracks.upgrades.training >= 1>>
				<br>The unit is able to make use of the training facilities to better prepare its soldiers, slowly increasing their experience level.
				<<set $slaveUnits[_i].training += random(2,4) * 1.5 * $SecExp.buildings.barracks.upgrades.training>>
			<</if>>
		<</for>>
		<<set _mL = $militiaUnits.length>>
		<<for _i = 0; _i < _mL; _i++>>
			<br>
			<br>$militiaUnits[_i].platoonName:
			<<set _loyaltyChange = 0>>
			<<if $SecExp.buildings.barracks.upgrades.loyaltyMod >= 1>>
				<<set _loyaltyChange += 2 * $SecExp.buildings.barracks.upgrades.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 && $SecExp.buildings.barracks.upgrades.training >= 1>>
				<br>The unit is able to make use of the training facilities to better prepare its soldiers, slowly increasing their experience level.
				<<set $militiaUnits[_i].training += random(2,4) * 1.5 * $SecExp.buildings.barracks.upgrades.training>>
			<</if>>
		<</for>>
		<<set _meL = $mercUnits.length, _loyaltyTotal = 0>>
		<<for _i = 0; _i < _meL; _i++>>
			<br>
			<br>$mercUnits[_i].platoonName:
			<<set _loyaltyChange = 0>>
			<<if $SecExp.buildings.barracks.upgrades.loyaltyMod >= 1>>
				<<set _loyaltyChange += 2 * $SecExp.buildings.barracks.upgrades.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)>>
			<<set _loyaltyTotal += $mercUnits[_i].loyalty>>
			<<if $mercUnits[_i].training < 100 && $SecExp.buildings.barracks.upgrades.training >= 1>>
				<br>The unit is able to make use of the training facilities to better prepare its soldiers, slowly increasing their experience level.
				<<set $mercUnits[_i].training += random(2,4) * 1.5 * $SecExp.buildings.barracks.upgrades.training>>
			<</if>>
		<</for>>
		<<if _meL > 0>>
			<<set $mercLoyalty = (_loyaltyTotal/_meL)>>
		<</if>>
	<</if>>
<</if>>


<<if $brainImplantProject > 0 && $brainImplant < 106>>
	<br>
	<br>
	<<set $brainImplant += $brainImplantProject>>
	<<if 100 - $brainImplant <= 0>>
		The project has been completed!
		<<set $brainImplant = 106>>
	<<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>>
	<br>
	<br>
	In the research lab, <<print $currentUpgrade.name>>
	<<switch $currentUpgrade.name>>
	<<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 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 following 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>>
<br>

src/Mods/SecExp/securityReport.tw