From 28e01323e59bd5852615f0ef269c3dc7acaca867 Mon Sep 17 00:00:00 2001
From: Arkerthan <arkerthan@mailbox.org>
Date: Tue, 21 Feb 2023 23:57:53 +0100
Subject: [PATCH] Set health of slaves from neighboring arcs to something more
 reasonable

---
 src/npc/generate/generateMarketSlave.js | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/src/npc/generate/generateMarketSlave.js b/src/npc/generate/generateMarketSlave.js
index 349d9b2efc6..22843621dcd 100644
--- a/src/npc/generate/generateMarketSlave.js
+++ b/src/npc/generate/generateMarketSlave.js
@@ -465,7 +465,7 @@ globalThis.generateMarketSlave = function(market = "kidnappers", numArcology = 1
 		}
 		case "neighbor": {
 			const neighborID = (typeof V.arcologies[numArcology] === 'object') ? numArcology : 1;
-			const neighbor = V.arcologies[neighborID];
+			const neighbor = /** @type {FC.ArcologyState} */V.arcologies[neighborID];
 			const opinion = Math.clamp(Math.trunc(App.Neighbor.opinion(V.arcologies[0], neighbor) / 20), -10, 10);
 
 			/**
@@ -495,7 +495,18 @@ globalThis.generateMarketSlave = function(market = "kidnappers", numArcology = 1
 			slave.origin += ".";
 			slave.devotion = -20 + Math.trunc(neighbor.prosperity / 10) + jsRandom(0, 10);
 			slave.trust = -20 + Math.trunc(neighbor.prosperity / 10) + jsRandom(0, 10);
-			setHealth(slave, -50 + Math.trunc(neighbor.prosperity / 25) + jsRandom(0, 5), Math.max(15 - neighbor.prosperity / 20 + normalRandInt(0, 2), 0), Math.max(15 - neighbor.prosperity / 20 + normalRandInt(0, 2), 0), undefined, Math.max(jsRandom(10, 40) - neighbor.prosperity / 15, 10));
+			let healthTarget = 0;
+			if (neighbor.FSPaternalist !== "unset") {
+				healthTarget = 20;
+			} else if (neighbor.FSDegradationist !== "unset") {
+				healthTarget = -20;
+			}
+			healthTarget += Math.trunc((neighbor.prosperity - 100) / 10) + jsRandom(0, 10);
+			setHealth(slave, healthTarget, // min: -50, max: -33
+				Math.max(15 - neighbor.prosperity / 20 + normalRandInt(0, 2), 0), // min: 0, max: 21
+				Math.max(15 - neighbor.prosperity / 20 + normalRandInt(0, 2), 0), // min: 0, max: 21
+				undefined,
+				Math.max(jsRandom(10, 40) - neighbor.prosperity / 15, 10)); // min: 10, max: 40
 			if (jsRandom(1, 100) < neighbor.prosperity / 10 + 50) {
 				slave.health.illness = 0;
 			}
-- 
GitLab