:: P coup attempt [nobr]

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

<<if $traitor != 0>>
	<<set _weeks = $traitorWeeks, _pregWeeks = $traitorWeeks, $traitorWeeks = 0>>

	<<set WombProgress($traitor, _pregWeeks, _pregWeeks)>> /* In all cases should be done */
	<<set WombUpdatePregVars($traitor)>>
	<<if WombBirthReady($traitor, $traitor.pregData.normalBirth) > 0 >> /* normal birth case, partial birthers not supported*/
		<<set $traitor.preg = -1, $traitor.counter.birthsTotal += WombBirthReady($traitor, $traitor.pregData.normalBirth)>>
		<<set WombFlush($traitor)>>
	<<else>>/* still pregnant slave */
		<<set $traitor.preg = WombMaxPreg($traitor)>> /*most ready fetus is a base*/
		<<set $traitor.pregWeek = WombMaxPreg($traitor)>> /*most ready fetus is a base*/
	<</if>>
	<<run SetBellySize($traitor)>> /*In any case it's useful to do.*/

	<<if $traitor.bald != 1>>
		<<if ($traitor.hLength < 150)>>
			<<set $traitor.hLength += _weeks>>
		<</if>>
	<</if>>
	<<if $seeAge != 0>>
		<<for _weeks > 0>>
			<<set $traitor.birthWeek++>>
			<<if $traitor.birthWeek >= 52>>
				<<set $traitor.birthWeek = 0>>
				<<run ageSlave($traitor)>>
			<</if>>
			<<set _weeks-->>
		<</for>>
	<</if>>
<</if>>
<<set _doubleAgent = ["agent", "trapper"].includes($traitorType) ? 1 : 0>>

You are awakened in the middle of the night by a jolt that shakes the entire arcology, accompanied by a distant boom. It is followed by the wail of the arcology's alarm systems, and then finally by a faint crackle that grows to a constant chatter of gunfire. Main power goes out, and you claw your way in the darkness to the video feeds, running on emergency backup. The Daughters of Liberty have more sympathizers in the arcology than even you suspected, and they're well armed and have the element of surprise.
<<if $arcologies[0].FSRomanRevivalistLaw == 1>>
	$arcologies[0].name, however, is home to a society that cannot be surprised, for each and every one of its citizens is armed and trained for instant contribution to the defense of Rome. Even as you do your best to reestablish control, you hear a thunderous, ubiquitous roar from all around you. Your citizens are already getting into the fight.
<</if>>

<br><br>

<<if $hackerSupport == 0>>
	Many of the arcology systems are not responding properly. It seems the Daughters' penetration of your systems is thorough. Your security systems are still reasonably functional, but the rebels are aided by partial control of things like lights and door locks.
<<else>>
	It seems your cyberwarfare ally of convenience is having an effect. Arcology systems are working perfectly unless the rebels disable them physically. Their fighters are impeded by uncooperative lights, resistant locking systems, and even $assistant.name's selective deployment of firefighting systems to obscure visibility.
<</if>>

<br><br>

<<if $personalArms == 0>>
	Since you are not well armed or armored, you stay in your penthouse and do what you can to coordinate the defense.
<<elseif $personalArms == 1>>
	The Daughters are appalled to encounter you striding thunderously out of your penthouse, fully armored. Your exoskeleton mounts an acoustic riot control system that even allows you to take prisoners.
<<else>>
	The Daughters are appalled to encounter you striding thunderously out of your penthouse, fully armored. Your exoskeleton mounts an acoustic riot control system that even allows you to take prisoners.
	<<if $arcologyUpgrade.drones > 0>>
		Meanwhile, your security drones are busily rearming themselves, and soon the dominant sound in the arcology is the ripping noise made by their small-caliber guns. A few of them retain their nonlethal weapons and swoop in to subdue when possible.
	<</if>>
<</if>>

<<if $traitor != 0 && ($traitorType == "trapper" || $traitorType == "agent")>>
	<br><br>
	Every now and then you catch sight of $traitor.slaveName seeding disorder through the ranks.
	<<if random(1,100) > $traitor.intelligence+$traitor.intelligenceImplant>>
		<<set _traitorDeath = 1>>
	<</if>>
<</if>>

<br><br>

<<if ($mercenaries == 0) && ($arcologies[0].FSRomanRevivalistLaw == 0)>>
	You are alone in contributing to the defense of your home.
<<elseif $mercenaries == 1>>
	Your mercenaries desperately defend their barracks but manage little else.
<<elseif $mercenaries == 3>>
	Your mercenaries manage to get into action quickly enough, but are bogged down in the streets. They are obliged to fight a confused battle to establish a perimeter. Only once it's stable are they able to push out.
<<else>>
	Your $mercenariesTitle spread out into the arcology, as invincible as Medieval men-at-arms matched against peasants. They are so dominant over the Daughters that they are able to take many prisoners. Their armor often permits them to approach armed, resisting rebels and disarm them manually.
<</if>>
<<if $arcologies[0].FSRomanRevivalistLaw == 1>>
	As the crisis is reached and passed, lower-class citizens armed as Hastati, with lighter weapons and personal armor, begin to sweep the arcology to ensure no one escapes. Middle-class citizens, meanwhile, heavily armored as Principes, methodically grind out pockets of armed resistance. The toughest rebel groups are left to the exoskeleton-armored Triarii.
<</if>>

<br><br>

<<set _newSlaves = []>>
<<if $arcologies[0].FSRomanRevivalistLaw + $mercenaries + $personalArms + $hackerSupport + _doubleAgent > 8>>
	@@.yellow;The Daughters of Liberty are utterly crushed.@@ $arcologies[0].name has been slightly damaged, but even as the last pockets of resistance are crushed, your citizens begin repairs themselves. The effect on your reputation is @@.green;immensely positive,@@ since your victory was insultingly easy and barely set the arcology's prosperity back at all. You also took a truly impressive bag of prisoners.
	<<set $daughtersVictory = 3>>
	<<run cashX(-2000, "war")>>
	<<run cashX(forceNeg(Math.trunc($cash*0.2)), "war")>>
	<<set $arcologies[0].prosperity = Math.trunc($arcologies[0].prosperity*0.7)>>
	<<run repX(2000, "war")>>
	<<set $activeSlaveOneTimeMinAge = 16>>
	<<set $activeSlaveOneTimeMaxAge = 32>>
	<<set $oneTimeDisableDisability = 1>>
	<<for _pca = 0; _pca < 8; _pca++>>
		<<if random(0,99) < $seeDicks>>
			<<set $activeSlave = GenerateNewSlave("XY")>>
			<<set $activeSlave.weight = random(-20,30)>>
			<<set $activeSlave.muscles = random(20,80)>>
			<<set $activeSlave.waist = random(10,80)>>
		<<else>>
			<<set $activeSlave = GenerateNewSlave("XX")>>
			<<set $activeSlave.weight = random(-50,30)>>
			<<set $activeSlave.muscles = random(0,80)>>
			<<set $activeSlave.waist = random(-20,20)>>
		<</if>>
		<<set $activeSlave.origin = "$He is an enslaved Daughter of Liberty.">>
		<<set _newSlaves.push($activeSlave)>>
	<</for>>
	<<set $desc = "a damaged plate carrier bearing Daughters of Liberty insignia">>
	<<set $trinkets.push($desc)>>
	<<= IncreasePCSkills('warfare', 5)>>
<<elseif $arcologies[0].FSRomanRevivalistLaw == 1>>
	@@.yellow;The Daughters of Liberty are annihilated.@@ @@.red;$arcologies[0].name has been damaged,@@ and the repairs will be quite costly. However, the effect on your reputation is @@.green;very positive,@@ since though your victory was hard-fought and set the arcology's prosperity back @@.red;considerably,@@ you did better than other arcology owners have done when faced with similar well-armed unrest. You also took a truly impressive bag of prisoners.
	<<set $daughtersVictory = 3>>
	<<run cashX(-5000, "war")>>
	<<run cashX(forceNeg(Math.trunc($cash*0.2)), "war")>>
	<<set $arcologies[0].prosperity = Math.trunc($arcologies[0].prosperity*0.7)>>
	<<run repX(1000, "war")>>
	<<if $seeDicks >= 50>>
		<<set _pcaj = 5>>
	<<elseif $seeDicks > 0>>
		<<set _pcaj = 2>>
	<<else>>
		<<set _pcaj = 0>>
	<</if>>
	<<for _pca = 0; _pca <= _pcaj; _pca++>>
		<<set $activeSlaveOneTimeMinAge = 16>>
		<<set $activeSlaveOneTimeMaxAge = 32>>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave("XY")>>
		<<set $activeSlave.origin = "$He is an enslaved Daughter of Liberty.">>
		<<set $activeSlave.weight = random(-20,30)>>
		<<set $activeSlave.muscles = random(20,80)>>
		<<set $activeSlave.waist = random(10,80)>>
		<<set _newSlaves.push($activeSlave)>>
	<</for>>
	<<if $seeDicks < 50>>
		<<set _pcaj = 5>>
	<<elseif $seeDicks < 100>>
		<<set _pcaj = 3>>
	<<else>>
		<<set _pcaj = 0>>
	<</if>>
	<<for _pca = 0; _pca <= _pcaj; _pca++>>
		<<set $activeSlaveOneTimeMinAge = 16>>
		<<set $activeSlaveOneTimeMaxAge = 32>>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave("XX")>>
		<<set $activeSlave.origin = "$He is an enslaved Daughter of Liberty.">>
		<<set $activeSlave.weight = random(-50,30)>>
		<<set $activeSlave.muscles = random(0,80)>>
		<<set $activeSlave.waist = random(-20,20)>>
		<<set _newSlaves.push($activeSlave)>>
	<</for>>
	<<set $desc = "a Daughters of Liberty flag that once hung in their forward command post within your arcology">>
	<<set $trinkets.push($desc)>>
<<else>>
	@@.yellow;The Daughters of Liberty are defeated.@@ @@.red;$arcologies[0].name is heavily damaged,@@ and the repairs will be very costly. The effect on your reputation is @@.green;muted, but positive,@@ since though you won, your victory was hard-fought and set the arcology's prosperity back @@.red;a long way.@@
	<<if $traitor != 0 && !["agent", "trapper"].includes($traitorType)>>
		$traitor.slaveName was killed in the fighting.
		<<set $traitor = 0, $traitorStats = 0, $traitorType = 0>>
	<</if>>
	<<set $daughtersVictory = 2>>
	<<run cashX(-10000, "war")>>
	<<run cashX(forceNeg(Math.trunc($cash*0.3)), "war")>>
	<<set $arcologies[0].prosperity = Math.trunc($arcologies[0].prosperity*0.5)>>
	<<run repX(500, "war")>>
	<<if $seeDicks >= 50>>
		<<set _pcaj = 3>>
	<<elseif $seeDicks > 0>>
		<<set _pcaj = 1>>
	<<else>>
		<<set _pcaj = 0>>
	<</if>>
	<<for _pca = 0; _pca <= _pcaj; _pca++>>
		<<set $activeSlaveOneTimeMinAge = 16>>
		<<set $activeSlaveOneTimeMaxAge = 32>>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave("XY")>>
		<<set $activeSlave.origin = "$He is an enslaved Daughter of Liberty.">>
		<<set $activeSlave.weight = random(-20,30)>>
		<<set $activeSlave.muscles = random(20,80)>>
		<<set $activeSlave.waist = random(10,80)>>
		<<set _newSlaves.push($activeSlave)>>
	<</for>>
	<<if $seeDicks < 50>>
		<<set _pcaj = 3>>
	<<elseif $seeDicks < 100>>
		<<set _pcaj = 2>>
	<<else>>
		<<set _pcaj = 0>>
	<</if>>
	<<for _pca = 0; _pca <= _pcaj; _pca++>>
		<<set $activeSlaveOneTimeMinAge = 16>>
		<<set $activeSlaveOneTimeMaxAge = 32>>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave("XX")>>
		<<set $activeSlave.origin = "$He is an enslaved Daughter of Liberty.">>
		<<set $activeSlave.weight = random(-50,30)>>
		<<set $activeSlave.muscles = random(0,80)>>
		<<set $activeSlave.waist = random(-20,20)>>
		<<set _newSlaves.push($activeSlave)>>
	<</for>>
	<<set $desc = "a Daughters of Liberty brassard">>
	<<set $trinkets.push($desc)>>
	<<= IncreasePCSkills('warfare', 5)>>
<</if>>

<<if $traitor != 0 && _traitorDeath != 1>>
	<<setLocalPronouns $traitor>>
	<<if ["agent", "trapper"].includes($traitorType)>>
		$traitor.slaveName returns to your service having completed the task assigned to $him.
		<<set $traitor.assignment = "rest">>
	<<elseif $traitorType == "hostage">>
		$traitor.slaveName wanders back to the penthouse, battered and bloody, but alive.
		<<set $traitor.assignment = "rest">>
		<<run setHealth($traitor, $traitor.health.condition, $traitor.health.condition - $traitor.health.shortDamage + 80, $traitor.health.longDamage, $traitor.health.illness, $traitor.health.tired)>>
	<<else>>
		$traitor.slaveName was captured and has been returned to you.
		<<set $traitor.assignment = "stay confined">>
		<<run setHealth($traitor, $traitor.health.condition, $traitor.health.condition - $traitor.health.shortDamage + 80, $traitor.health.longDamage, $traitor.health.illness, $traitor.health.tired)>>
		<<set $traitor.origin = "$He was your slave, but you freed $him, which $he repaid by participating in a coup attempt against you. It failed, and $he is again your chattel.">>
	<</if>>
	<<if $traitorStats.PCpregSource > 0 && $PC.preg > 0 && $PC.pregSource == 0>>
		<<set $PC.pregSource = $traitor.ID>>
	<</if>>
	<<if $traitorStats.PCmother > 0>>
		<<set $PC.mother = $traitor.ID>>
	<</if>>
	<<if $traitorStats.PCfather > 0>>
		<<set $PC.father = $traitor.ID>>
	<</if>>
	<<for _pca = 0; _pca < $slaves.length; _pca++>>
		<<if $traitorStats.traitorMother.includes($slaves[_pca].ID)>>
			<<set $slaves[_pca].mother = $traitor.ID>>
		<</if>>
		<<if $traitorStats.traitorFather.includes($slaves[_pca].ID)>>
			<<set $slaves[_pca].father = $traitor.ID>>
		<</if>>
		<<if $traitorStats.traitorPregSources.includes($slaves[_pca].ID) && $slaves[_pca].preg > 0 && $slaves[_pca].pregSource == 0>>
			<<set $slaves[_pca].pregSource = $traitor.ID>>
		<</if>>
	<</for>>
	<<if $incubator > 0>>
		<<for _pca = 0; _pca < $tanks.length; _pca++>>
			<<if $traitorStats.traitorMotherTank.includes($tanks[_pca].ID)>>
				<<set $tanks[_pca].mother = $traitor.ID>>
			<</if>>
			<<if $traitorStats.traitorFatherTank.includes($tanks[_pca].ID)>>
				<<set $tanks[_pca].father = $traitor.ID>>
			<</if>>
		<</for>>
	<</if>>
	<<if $nursery > 0>>
		<<for _pca = 0; _pca < $cribs.length; _pca++>>
			<<if $traitorStats.traitorMotherTank.includes($cribs[_pca].ID)>>
				<<set $cribs[_pca].mother = $traitor.ID>>
			<</if>>
			<<if $traitorStats.traitorFatherTank.includes($cribs[_pca].ID)>>
				<<set $cribs[_pca].father = $traitor.ID>>
			<</if>>
		<</for>>
	<</if>>
	<<if $traitorStats.boomerangBody > 0>>
		<<set _pca = $slaveIndices[$traitorStats.traitorBody]>>
		<<if def _pca>>
			<<set $slaves[_pca].origBodyOwnerID = $traitor.ID>>
		<</if>>
	<</if>>
	<<for _pca = 0; _pca < $slaves.length; _pca++>>
		<<run WombChangeID($slaves[_pca], $traitor.missingParentTag, $traitor.ID)>>
		<<run WombChangeGeneID($slaves[_pca], $traitor.missingParentTag, $traitor.ID)>>
	<</for>>
	<<run newSlave($traitor)>> /* skip New Slave Intro */
	<<set $traitor = 0, $traitorStats = 0, $traitorType = 0>>
<<elseif $traitor != 0>>
	$traitor.slaveName's body was found among the dead. $He died sabotaging the Daughters' efforts.
	<<set $traitor = 0, $traitorStats = 0, $traitorType = 0>>
<</if>>

<br><br>

<span id="result">
<<link "Sell your prisoners immediately">>
	<<replace "#result">>
	<<for _pca = 0; _pca < _newSlaves.length; _pca++>>
		<<set _slaveCost = slaveCost(_newSlaves[_pca])>>
		<<run cashX(_slaveCost, "slaveTransfer")>>
	<</for>>
	Prisoners sold.
	<</replace>>
<</link>> <<if $traitor != 0>>//$traitor.slaveName will not be sold.//<</if>>
<br><<link "Give your prisoners to those who suffered property damage">>
	<<replace "#result">>
	<<for _pca = 0; _pca < _newSlaves.length; _pca++>>
		<<set _slaveCost = slaveCost(_newSlaves[_pca])>>
		<<run repX(Math.trunc(_slaveCost/10), "war")>>
	<</for>>
	Prisoners @@.green;given away.@@
	<</replace>>
<</link>> <<if $traitor != 0>>//$traitor.slaveName will not be given away.//<</if>>
<br><<link "Enslave all of your prisoners">>
	<<replace "#result">>
	<<for _pca = 0; _pca < _newSlaves.length; _pca++>>
		<<run newSlave(_newSlaves[_pca])>> /* skip New Slave Intro */
	<</for>>
	You simply enslave all of the prisoners yourself. You will make them pay for attacking your arcology.
	<</replace>>
<</link>>
</span>

src/uncategorized/pCoupAttempt.tw