From ca23c2af21ac37ce2600718f454190267569a404 Mon Sep 17 00:00:00 2001
From: lowercasedonkey <lowercasedonkey@gmail.com>
Date: Fri, 13 Nov 2020 17:56:05 -0500
Subject: [PATCH] death to js

---
 js/003-data/gameVariableData.js               |   6 +-
 .../backwardsCompatibility.js                 |   9 +
 .../backwardsCompatibility/datatypeCleanup.js |  14 +-
 src/endWeek/saLongTermEffects.js              |   6 +-
 src/js/SlaveState.js                          |   2 -
 src/js/death.js                               | 174 +++++++++++++++++-
 src/pregmod/seDeath.tw                        |  25 +--
 src/pregmod/widgets/deathWidgets.tw           | 127 -------------
 src/uncategorized/scheduledEvent.tw           |   3 +-
 9 files changed, 204 insertions(+), 162 deletions(-)
 delete mode 100644 src/pregmod/widgets/deathWidgets.tw

diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js
index 16aa0642711..23bc8c11e70 100644
--- a/js/003-data/gameVariableData.js
+++ b/js/003-data/gameVariableData.js
@@ -831,7 +831,11 @@ App.Data.resetOnNGPlus = {
 	cumPipeline: 0,
 	wcPiping: 0,
 	burstee: 0,
-	slaveDeath: 0,
+	slaveDeath: {
+		oldAge: [],
+		overdosed: [],
+		lowHealth: []
+	},
 	playerBred: 0,
 	propOutcome: 0,
 	EliteSires: ["crazy", "futa", "moves", "preggo", "quick", "virgin"],
diff --git a/src/data/backwardsCompatibility/backwardsCompatibility.js b/src/data/backwardsCompatibility/backwardsCompatibility.js
index d44fb8d7f83..d39d44c7412 100644
--- a/src/data/backwardsCompatibility/backwardsCompatibility.js
+++ b/src/data/backwardsCompatibility/backwardsCompatibility.js
@@ -1143,6 +1143,15 @@ App.Update.globalVariables = function(node) {
 		V.completedOrgans = newOrgans;
 	}
 
+	// Slave death
+	if (!isNaN(V.slaveDeath)) {
+		V.slaveDeath = {
+			oldAge: [],
+			overdosed: [],
+			lowHealth: []
+		};
+	}
+
 	FacilityDatatypeCleanup();
 
 	if (typeof V.TFS.compromiseWeek === "undefined") {
diff --git a/src/data/backwardsCompatibility/datatypeCleanup.js b/src/data/backwardsCompatibility/datatypeCleanup.js
index 4a33309be75..4b5f082552b 100644
--- a/src/data/backwardsCompatibility/datatypeCleanup.js
+++ b/src/data/backwardsCompatibility/datatypeCleanup.js
@@ -1135,8 +1135,18 @@ globalThis.SlaveDatatypeCleanup = (function SlaveDatatypeCleanup() {
 			slave.origBodyOwner = "";
 		}
 		slave.origBodyOwnerID = Math.max(+slave.origBodyOwnerID, 0) || 0;
-		if (typeof slave.death !== "string") {
-			slave.death = "";
+		if (slave.hasOwnProperty("death")) {
+			switch (slave.death) {
+				case "health":
+					planDeath(slave, "lowHealth");
+					break;
+				case "od":
+					planDeath(slave, "overdosed");
+					break;
+				case "old":
+					planDeath(slave, "oldAge");
+			}
+			delete slave.death;
 		}
 		if (slave.slaveCost !== 0) {
 			slave.slaveCost = Math.min(+slave.slaveCost, 1) || 1;
diff --git a/src/endWeek/saLongTermEffects.js b/src/endWeek/saLongTermEffects.js
index 1dfd4167a73..a74f55527a5 100644
--- a/src/endWeek/saLongTermEffects.js
+++ b/src/endWeek/saLongTermEffects.js
@@ -2537,16 +2537,16 @@ App.SlaveAssignment.longTermEffects = (function() {
 					deathSeed += 200;
 				}
 				if (random(1, 1000) > (400 + deathSeed)) {
-					planDeath(slave, "health");
+					planDeath(slave, "lowHealth");
 				}
 				if ((slave.aphrodisiacs > 0 || slave.inflationType === "aphrodisiac") && random(1, 1000) > (200 + deathSeed)) {
-					planDeath(slave, "OD");
+					planDeath(slave, "overdosed");
 				}
 			}
 			if (V.seeAge === 1) {
 				deathSeed = ((slave.health.health * 2) - (slave.physicalAge * 2) - (slave.chem * 4) - (slave.addict * 3));
 				if (slave.physicalAge >= Math.max((70 + (slave.health.health / 5) - (slave.addict) - (slave.chem / 20)), 50) && random(1, 1000) > 800 + deathSeed) {
-					planDeath(slave, "old");
+					planDeath(slave, "oldAge");
 				}
 			}
 		}
diff --git a/src/js/SlaveState.js b/src/js/SlaveState.js
index 9bf380863a1..fc2c38abf9e 100644
--- a/src/js/SlaveState.js
+++ b/src/js/SlaveState.js
@@ -2485,8 +2485,6 @@ App.Entity.SlaveState = class SlaveState {
 		this.origBodyOwner = "";
 		/** Who, if relevant, the body belonged to. */
 		this.origBodyOwnerID = 0;
-		/** Cause of slave death. */
-		this.death = "";
 		/**
 		 * Slave's current hormonal balance, directs saHormones changes
 		 *
diff --git a/src/js/death.js b/src/js/death.js
index fa243db18c7..801256400ce 100644
--- a/src/js/death.js
+++ b/src/js/death.js
@@ -1,4 +1,174 @@
 globalThis.planDeath = function(slave, reason) {
-	slave.death = reason;
-	V.slaveDeath = 1;
+	V.slaveDeath[reason].push(slave.ID);
+};
+
+App.EndWeek.allDeaths = function() {
+	const el = new DocumentFragment();
+
+	for (const deathType in V.slaveDeath) {
+		for (const id of V.slaveDeath[deathType]) {
+			const obit = document.createElement("p");
+			const deceased = getSlave(V.slaveDeath[deathType][id]);
+			if (deceased) {
+				App.SlaveAssignment.appendSlaveArt(obit, deceased);
+				el.append(obit);
+				el.append(sectionBreak());
+				removeSlave(deceased);
+			}
+		}
+
+		V.slaveDeath[deathType] = [];
+	}
+
+	return el;
+
+	function sectionBreak() {
+		const hr = document.createElement("hr");
+		hr.style.margin = "0";
+		return hr;
+	}
+};
+
+globalThis.death = function(slave) {
+	const el = new DocumentFragment();
+	const r = [];
+	const {
+		He, His,
+		he, his
+	} = getPronouns(slave);
+	return {oldAge, overdosed, lowHealth};
+
+	function oldAge() {
+		if (slave.assignment === "be confined in the arcade") {
+			r.push(`You are notified by ${V.arcadeName} staff that one of the cabinets has broken down and will need to be replaced. It would seem ''<span class="pink">${slave.slaveName}</span>'', the fucktoy encased in it, died`);
+			if (slave.physicalAge >= 70) {
+				r.push(`naturally of old age despite`);
+			} else {
+				r.push(`suddenly, unrelated to`);
+			}
+			r.push(`${his} living conditions. ${He} was a good unit; logs show ${he} was taking dick up until the very end.`);
+		} else if (slave.assignment === "work in the dairy" && V.dairyRestraintsSetting > 1) {
+			r.push(`You are notified by ${V.dairyName} staff that one of the occupied milkers has ceased producing. Upon inspection, it would seem ''<span class="pink">${slave.slaveName}</span>'', the cow restrained in it, died`);
+			if (slave.physicalAge >= 70) {
+				r.push(`naturally of old age despite`);
+			} else {
+				r.push(`suddenly, unrelated to`);
+			}
+			r.push(`${his} living conditions. ${He} was a good cow; ${he} gave milk up until ${his} death.`);
+		} else if (slave.fuckdoll > 0) {
+			r.push(`One of your Fuckdolls' monitoring systems alerts you that the slave contained within has died. It would seem ''<span class="pink">${slave.slaveName}</span>'' has died`);
+			if (slave.physicalAge >= 70) {
+				r.push(`naturally of old age despite`);
+			} else {
+				r.push(`suddenly, unrelated to`);
+			}
+			r.push(`${his} living conditions. Thankfully the suit notifies its owner of such things; especially with the rumors of earlier models and necrophilia you hear occasionally.`);
+		} else {
+			r.push(`''<span class="pink">${slave.slaveName}</span>'' failed to report in for a routine inspection, something that rarely occurs under your watch. It doesn't take long to track down the wayward slave.`);
+			const deathSeed = random(1, 100);
+			if (deathSeed > 75) {
+				r.push(`${He} is found dead in ${his} bed, having died sometime during the previous night.`);
+			} else if (deathSeed > 50) {
+				r.push(`${He} is found dead in a stairwell, having had a heart attack while trying to climb it.`);
+			} else if (deathSeed > 25) {
+				r.push(`${He} is found dead in the showers, having slipped sometime earlier.`);
+			} else {
+				if (App.Utils.hasNonassignmentSex(slave)) {
+					r.push(`${He} is found dead in the bed of another slave, having died during intercourse. ${His} lover is not taking it well.`);
+				} else {
+					r.push(`${He} is found dead in the cafeteria, having died during breakfast; ${he} ruined the day for a number of your slaves.`);
+				}
+			}
+			r.push(`${slave.slaveName} died at the age of ${slave.actualAge};`);
+			if (slave.actualAge < 10) {
+				r.push(`${he} lived a tragically short life.`);
+			} else if (slave.actualAge < 20) {
+				r.push(`${he} died far too young.`);
+			} else if (slave.actualAge < 30) {
+				r.push(`${he} died in what would be a sex slave's prime.`);
+			} else if (slave.actualAge < 50) {
+				r.push(`${he} died in ${his} prime.`);
+			} else if (slave.actualAge < 65) {
+				r.push(`${he} lived a fair life, good or bad.`);
+			} else if (slave.actualAge < 90) {
+				r.push(`${he} lived a long life and experienced much during it.`);
+			} else {
+				r.push(`${he} lived a very long life that few get to see.`);
+			}
+		}
+		App.Events.addNode(el, r);
+		return el;
+	}
+
+	function overdosed() {
+		if (slave.assignment === "be confined in the arcade") {
+			r.push(`You are notified by ${V.arcadeName} staff that one of the cabinets has broken down and will need to be replaced. It would seem ''<span class="pink">${slave.slaveName}</span>'', the fucktoy encased in it, died of an aphrodisiac overdose from the constant aphrodisiac injections. ${He} was a good unit; logs show ${he} was taking dick up until the very end.`);
+		} else if (slave.assignment === "work in the dairy" && V.dairyRestraintsSetting > 1) {
+			r.push(`You are notified by ${V.dairyName} staff that one of the occupied milkers has ceased producing. Upon inspection, it would seem ''<span class="pink">${slave.slaveName}</span>'', the cow restrained in it, died of an aphrodisiac overdose. How ${he} managed to get them is unknown, but ${he} was a good cow; ${he} gave milk up until ${his} death.`);
+		} else if (slave.fuckdoll > 0) {
+			r.push(`One of your Fuckdolls' monitoring systems alerts you that the slave contained within has died. It would seem ''<span class="pink">${slave.slaveName}</span>'' has died of an aphrodisiac overdose. Thankfully the suit notifies its owner of such things; especially with the rumors of earlier models and necrophilia you hear occasionally. It does little to deal with the resulting mess of the orgasm ${he} died during, however.`);
+		} else {
+			r.push(`''<span class="pink">${slave.slaveName}</span>'' failed to report in for a routine inspection, something that rarely occurs under your watch. It doesn't take long to track down the wayward slave.`);
+			r.push(`${He} is found dead in ${his} bed, having died sometime earlier. Judging by the mess and the expression on ${his} face, ${he} died of a heart attack during a particularly intense orgasm bought about by the massive amount of aphrodisiacs in ${his} system. ${slave.slaveName} died at the age of ${slave.actualAge};`);
+			if (slave.actualAge < 10) {
+				r.push(`${he} lived a tragically short life.`);
+			} else if (slave.actualAge < 20) {
+				r.push(`${he} died far too young.`);
+			} else if (slave.actualAge < 30) {
+				r.push(`${he} died in what would be a sex slave's prime.`);
+			} else if (slave.actualAge < 50) {
+				r.push(`${he} died in ${his} prime.`);
+			} else if (slave.actualAge < 65) {
+				r.push(`${he} lived a fair life, good or bad.`);
+			} else if (slave.actualAge < 90) {
+				r.push(`${he} lived a long life and experienced much during it.`);
+			} else {
+				r.push(`${he} lived a very long life that few get to see.`);
+			}
+		}
+		App.Events.addNode(el, r);
+		return el;
+	}
+
+	function lowHealth() {
+		if (slave.assignment === "be confined in the arcade") {
+			r.push(`You are notified by ${V.arcadeName} staff that one of the cabinets has broken down and will need to be replaced. It would seem ''<span class="pink">${slave.slaveName}</span>'', the fucktoy encased in it, died to poor health caused by ${his} living conditions. ${He} was a good unit; logs show ${he} was taking dick up until the very end.`);
+		} else if (slave.assignment === "work in the dairy" && V.dairyRestraintsSetting > 1) {
+			r.push(`You are notified by ${V.dairyName} staff that one of the occupied milkers has ceased producing. Upon inspection, it would seem ''<span class="pink">${slave.slaveName}</span>'', the cow restrained in it, died to poor health caused by ${his} living conditions. ${He} was a good cow; ${he} gave milk up until ${his} death.`);
+		} else if (slave.fuckdoll > 0) {
+			r.push(`One of your Fuckdolls' monitoring systems alerts you that the slave contained within has died. It would seem ''<span class="pink">${slave.slaveName}</span>'' has died of general poor health. Thankfully the suit notifies its owner of such things; especially with the rumors of earlier models and necrophilia you hear occasionally. Clean up is easy enough, however.`);
+		} else {
+			r.push(`''<span class="pink">${slave.slaveName}</span>'' failed to report in for a routine inspection, something that rarely occurs under your watch. It doesn't take long to track down the wayward slave.`);
+			r.push(`${He} is found dead in ${his} bed, having died sometime during the night. ${He} has been in very poor health lately, so you knew this was a possibility. ${slave.slaveName} died at the age of ${slave.actualAge};`);
+			if (slave.actualAge < 10) {
+				r.push(`${he} lived a tragically short life.`);
+			} else if (slave.actualAge < 20) {
+				r.push(`${he} died far too young.`);
+			} else if (slave.actualAge < 30) {
+				r.push(`${he} died in what would be a sex slave's prime.`);
+			} else if (slave.actualAge < 50) {
+				r.push(`${he} died in ${his} prime.`);
+			} else if (slave.actualAge < 65) {
+				r.push(`${he} lived a fair life, good or bad.`);
+			} else if (slave.actualAge < 90) {
+				r.push(`${he} lived a long life and experienced much during it.`);
+			} else {
+				r.push(`${he} lived a very long life that few get to see.`);
+			}
+			if (V.arcologies[0].FSPaternalist !== "unset" && slave.actualAge < 75) {
+				r.push(`Allowing a slave to die under your care <span class="red">severely damages</span> your image as a caring slaveowner and <span class="red">calls into question</span> your paternalistic resolve.`);
+				FutureSocieties.Change("Paternalist", -10);
+			}
+		}
+		App.Events.addNode(el, r);
+		return el;
+	}
+};
+
+globalThis.deathCheck = function(){
+	for (const deathType in V.slaveDeath) {
+		if (V.slaveDeath[deathType].length > 0) {
+			return true;
+		}
+	}
 };
diff --git a/src/pregmod/seDeath.tw b/src/pregmod/seDeath.tw
index 86903576de8..27ae7d667b5 100644
--- a/src/pregmod/seDeath.tw
+++ b/src/pregmod/seDeath.tw
@@ -1,26 +1,5 @@
 :: SE Death [nobr]
 
 <<set $nextButton = "Continue", $nextLink = "Scheduled Event", _killedSlaves = []>>
-<<for _slave range $slaves>>
-	<<switch _slave.death.toLowerCase()>>
-		<<case "old">>
-			<<DeathOldAge _slave>>
-			<br><br><hr style="margin:0"><br>
-			<<set _killedSlaves.push(_slave)>>
-		<<case "od">>
-			<<DeathOverdose _slave>>
-			<br><br><hr style="margin:0"><br>
-			<<set _killedSlaves.push(_slave)>>
-		<<case "health">>
-			<<DeathUnhealthy _slave>>
-			<br><br><hr style="margin:0"><br>
-			<<set _killedSlaves.push(_slave)>>
-	<</switch>>
-<</for>>
-<<if _killedSlaves.length == 0>>
-	/* if something beats this to the slaves, this should kick the player along instead of leaving them at a blank screen */
-	<<goto "Scheduled Event">>
-<</if>>
-<<for _slave range _killedSlaves>>
-	<<= removeSlave(_slave)>>
-<</for>>
\ No newline at end of file
+
+<<includeDOM App.EndWeek.allDeaths()>>
diff --git a/src/pregmod/widgets/deathWidgets.tw b/src/pregmod/widgets/deathWidgets.tw
deleted file mode 100644
index 18a1d9dbc5a..00000000000
--- a/src/pregmod/widgets/deathWidgets.tw
+++ /dev/null
@@ -1,127 +0,0 @@
-:: death widgets [widget nobr]
-
-<<widget "DeathOldAge">>
-	/* 000-250-006 */
-	<<if $seeImages && $seeReportImages>>
-		<div class="imageRef tinyImg">
-			<<= SlaveArt($args[0], 0, 0)>>
-		</div>
-	<</if>>
-	/* 000-250-006 */
-	<<setLocalPronouns $args[0]>>
-	<<if $args[0].assignment == "be confined in the arcade">>
-		You are notified by $arcadeName staff that one of the cabinets has broken down and will need to be replaced. It would seem ''@@.pink;$args[0].slaveName@@'', the fucktoy encased in it, died <<if $args[0].physicalAge >= 70>>naturally of old age despite<<else>>suddenly, unrelated to<</if>> $his living conditions. $He was a good unit; logs show $he was taking dick up until the very end.
-	<<elseif $args[0].assignment == "work in the dairy" && $dairyRestraintsSetting > 1>>
-		You are notified by $dairyName staff that one of the occupied milkers has ceased producing. Upon inspection, it would seem ''@@.pink;$args[0].slaveName@@'', the cow restrained in it, died <<if $args[0].physicalAge >= 70>>naturally of old age despite<<else>>suddenly, unrelated to<</if>> $his living conditions. $He was a good cow; $he gave milk up until $his death.
-	<<elseif $args[0].fuckdoll > 0>>
-		One of your Fuckdolls' monitoring systems alerts you that the slave contained within has died. It would seem ''@@.pink;$args[0].slaveName@@'' has died <<if $args[0].physicalAge >= 70>>naturally of old age despite<<else>>suddenly, unrelated to<</if>> $his living conditions. Thankfully the suit notifies its owner of such things; especially with the rumors of earlier models and necrophilia you hear occasionally.
-	<<else>>
-		''@@.pink;$args[0].slaveName@@'' failed to report in for a routine inspection, something that rarely occurs under your watch. It doesn't take long to track down the wayward slave.
-		<<set _deathSeed = random(1,100)>>
-		<<if _deathSeed > 75>>
-			$He is found dead in $his bed, having died sometime during the previous night.
-		<<elseif _deathSeed > 50>>
-			$He is found dead in a stairwell, having had a heart attack while trying to climb it.
-		<<elseif _deathSeed > 25>>
-			$He is found dead in the showers, having slipped sometime earlier.
-		<<else>>
-			<<if App.Utils.hasNonassignmentSex($args[0])>>
-				$He is found dead in the bed of another slave, having died during intercourse. $His lover is not taking it well.
-			<<else>>
-				$He is found dead in the cafeteria, having died during breakfast; $he ruined the day for a number of your slaves.
-			<</if>>
-		<</if>>
-		$args[0].slaveName died at the age of $args[0].actualAge;
-		<<if $args[0].actualAge < 10>>
-			$he lived a tragically short life.
-		<<elseif $args[0].actualAge < 20>>
-			$he died far too young.
-		<<elseif $args[0].actualAge < 30>>
-			$he died in what would be a sex slave's prime.
-		<<elseif $args[0].actualAge < 50>>
-			$he died in $his prime.
-		<<elseif $args[0].actualAge < 65>>
-			$he lived a fair life, good or bad.
-		<<elseif $args[0].actualAge < 90>>
-			$he lived a long life and experienced much during it.
-		<<else>>
-			$he lived a very long life that few get to see.
-		<</if>>
-	<</if>>
-<</widget>>
-
-<<widget "DeathOverdose">>
-	<<setLocalPronouns $args[0]>>
-	/* 000-250-006 */
-	<<if $seeImages && $seeReportImages>>
-		<div class="imageRef tinyImg">
-			<<= SlaveArt($args[0], 0, 0)>>
-		</div>
-	<</if>>
-	/* 000-250-006 */
-	<<if $args[0].assignment == "be confined in the arcade">>
-		You are notified by $arcadeName staff that one of the cabinets has broken down and will need to be replaced. It would seem ''@@.pink;$args[0].slaveName@@'', the fucktoy encased in it, died of an aphrodisiac overdose from the constant aphrodisiac injections. $He was a good unit; logs show $he was taking dick up until the very end.
-	<<elseif $args[0].assignment == "work in the dairy" && $dairyRestraintsSetting > 1>>
-		You are notified by $dairyName staff that one of the occupied milkers has ceased producing. Upon inspection, it would seem ''@@.pink;$args[0].slaveName@@'', the cow restrained in it, died of an aphrodisiac overdose. How $he managed to get them is unknown, but $he was a good cow; $he gave milk up until $his death.
-	<<elseif $args[0].fuckdoll > 0>>
-		One of your Fuckdolls' monitoring systems alerts you that the slave contained within has died. It would seem ''@@.pink;$args[0].slaveName@@'' has died of an aphrodisiac overdose. Thankfully the suit notifies its owner of such things; especially with the rumors of earlier models and necrophilia you hear occasionally. It does little to deal with the resulting mess of the orgasm $he died during, however.
-	<<else>>
-		''@@.pink;$args[0].slaveName@@'' failed to report in for a routine inspection, something that rarely occurs under your watch. It doesn't take long to track down the wayward slave.
-		$He is found dead in $his bed, having died sometime earlier. Judging by the mess and the expression on $his face, $he died of a heart attack during a particularly intense orgasm bought about by the massive amount of aphrodisiacs in $his system. $args[0].slaveName died at the age of $args[0].actualAge;
-		<<if $args[0].actualAge < 10>>
-			$he lived a tragically short life.
-		<<elseif $args[0].actualAge < 20>>
-			$he died far too young.
-		<<elseif $args[0].actualAge < 30>>
-			$he died in what would be a sex slave's prime.
-		<<elseif $args[0].actualAge < 50>>
-			$he died in $his prime.
-		<<elseif $args[0].actualAge < 65>>
-			$he lived a fair life, good or bad.
-		<<elseif $args[0].actualAge < 90>>
-			$he lived a long life and experienced much during it.
-		<<else>>
-			$he lived a very long life that few get to see.
-		<</if>>
-	<</if>>
-<</widget>>
-
-<<widget "DeathUnhealthy">>
-	/* 000-250-006 */
-	<<if $seeImages && $seeReportImages>>
-		<div class="imageRef tinyImg">
-			<<= SlaveArt($args[0], 0, 0)>>
-		</div>
-	<</if>>
-	/* 000-250-006 */
-	<<setLocalPronouns $args[0]>>
-	<<if $args[0].assignment == "be confined in the arcade">>
-		You are notified by $arcadeName staff that one of the cabinets has broken down and will need to be replaced. It would seem ''@@.pink;$args[0].slaveName@@'', the fucktoy encased in it, died to poor health caused by $his living conditions. $He was a good unit; logs show $he was taking dick up until the very end.
-	<<elseif $args[0].assignment == "work in the dairy" && $dairyRestraintsSetting > 1>>
-		You are notified by $dairyName staff that one of the occupied milkers has ceased producing. Upon inspection, it would seem ''@@.pink;$args[0].slaveName@@'', the cow restrained in it, died to poor health caused by $his living conditions. $He was a good cow; $he gave milk up until $his death.
-	<<elseif $args[0].fuckdoll > 0>>
-		One of your Fuckdolls' monitoring systems alerts you that the slave contained within has died. It would seem ''@@.pink;$args[0].slaveName@@'' has died of general poor health. Thankfully the suit notifies its owner of such things; especially with the rumors of earlier models and necrophilia you hear occasionally. Clean up is easy enough, however.
-	<<else>>
-		''@@.pink;$args[0].slaveName@@'' failed to report in for a routine inspection, something that rarely occurs under your watch. It doesn't take long to track down the wayward slave.
-		$He is found dead in $his bed, having died sometime during the night. $He has been in very poor health lately, so you knew this was a possibility. $args[0].slaveName died at the age of $args[0].actualAge;
-		<<if $args[0].actualAge < 10>>
-			$he lived a tragically short life.
-		<<elseif $args[0].actualAge < 20>>
-			$he died far too young.
-		<<elseif $args[0].actualAge < 30>>
-			$he died in what would be a sex slave's prime.
-		<<elseif $args[0].actualAge < 50>>
-			$he died in $his prime.
-		<<elseif $args[0].actualAge < 65>>
-			$he lived a fair life, good or bad.
-		<<elseif $args[0].actualAge < 90>>
-			$he lived a long life and experienced much during it.
-		<<else>>
-			$he lived a very long life that few get to see.
-		<</if>>
-		<<if ($arcologies[0].FSPaternalist != "unset") && ($args[0].actualAge < 75)>>
-			Allowing a slave to die under your care @@.red;severely damages@@ your image as a caring slaveowner and @@.red;calls into question@@ your paternalistic resolve.
-			<<run FutureSocieties.Change("Paternalist", -10)>>
-		<</if>>
-	<</if>>
-<</widget>>
diff --git a/src/uncategorized/scheduledEvent.tw b/src/uncategorized/scheduledEvent.tw
index c6c20a114c0..66f86f17f2d 100644
--- a/src/uncategorized/scheduledEvent.tw
+++ b/src/uncategorized/scheduledEvent.tw
@@ -111,8 +111,7 @@
 <<elseif ($burstee != 0)>>
 	<<set $burst = 0>>
 	<<goto "SE Burst">>
-<<elseif ($slaveDeath != 0)>>
-	<<set $slaveDeath = 0>>
+<<elseif (deathCheck())>>
 	<<goto "SE Death">>
 <<elseif ($birthee != 0)>>
 	<<goto "SE Birth">>
-- 
GitLab