code:
/*
This is a womb processor/simulator script. It takes care of calculation of belly sizes based on individual fetus sizes, with full support of broodmothers implant random turning on and off possibility. Also this can be expanded to store more parents data in each individual fetus in future.
Design limitations:
- Mother can't gestate children with different speeds at same time. All speed changes apply to all fetuses.
- Sizes of individual fetuses updated only on call of WombGetVolume - not every time as called WombProgress. This is for better overall code speed.
- For broodmothers we need actual "new ova release" code now. But it's possible to control how many children will be added each time, and so - how much children is ready to birth each time.

Usage from sugarcube code (samples):

WombInit($slave) - before first pregnancy, at slave creation, of as backward compatibility update.

WombImpregnate($slave, $fetus_count, $fatherID, $initial_age) - should be added after normal impregnation code, with already calculated fetus count. ID of father - can be used in future for processing children from different fathers in one pregnancy. Initial age normally 1 (as .preg normally set to 1), but can be raised if needed. Also should be called at time as broodmother implant add another fetus(es), or if new fetuses added from other sources in future (transplanting maybe?)

WombProgress($slave, $time_to_add_to_fetuses, $real_time_to_add_to_fetuses) - after code that update $slave.preg, time to add should be the same.

$isReady = WombBirthReady($slave, $birth_ready_age) - how many children ready to be birthed if their time to be ready is $birth_ready_age (40 is for normal length pregnancy). Return int - count of ready to birth children, or 0 if no ready exists.

$children = WombBirth($slave, $birth_ready_age) - for actual birth. Return array with fetuses objects that birthed (can be used in future) and remove them from womb array of $slave. Should be called at actual birth code in sugarcube. fetuses that not ready remained in womb (array).

WombFlush($slave) - clean womb (array). Can be used at broodmother birthstorm or abortion situations in game. But birthstorm logically should use WombBirth($slave, 35) or so before - some children in this event is live capable, others is not.

$slave.bellyPreg = WombGetWolume($slave) - return double, with current womb volume in CC - for updating $slave.bellyPreg, or if need to update individual fetuses sizes.

*/

// Init womb system.
window.WombInit = function(actor) {
	let i;

	if (!Array.isArray(actor.womb)) {
		// alert("creating new womb"); //debugging
		actor.womb = [];
	}

	// console.log("broodmother:" + typeof actor.broodmother);

	if (typeof actor.broodmother !== "number") {
		actor.broodmother = 0;
		actor.broodmotherFetuses = 0;
	}

	if (typeof actor.readyOva !== "number") {
		actor.readyOva = 0;
	}

	if (actor.pregData === undefined) {
		actor.pregData = clone(setup.pregData.human);
		// Setup should be through deep copy, so in future, if we like, these values can be changed individually. Gameplay expansion possibilities. But for dev time to simplify debugging:
		// actor.pregData = setup.pregData.human;  // any changes in setup pregData template will be applied immediately to all. But can't be made separate changes.
	}

	// backward compatibility setup. Fully accurate for normal pregnancy only.
	if (actor.womb.length > 0 && actor.womb[0].genetics === undefined && actor.eggType === "human") {
		i = 0;
		actor.womb.forEach(function(ft) {
			ft.genetics = generateGenetics(actor, actor.pregSource, i);
			i++;
		});
	} else if (actor.womb.length === 0 && actor.pregType > 0 && actor.broodmother === 0) {
		WombImpregnate(actor, actor.pregType, actor.pregSource, actor.preg);
	} else if (actor.womb.length === 0 && actor.pregType > 0 && actor.broodmother > 0 && actor.broodmotherOnHold < 1) {
		// sorry but for already present broodmothers it's impossible to calculate fully, approximation used.
		let pw = actor.preg,
			bCount, bLeft;
		if (pw > actor.pregData.normalBirth) { pw = actor.pregData.normalBirth; } // to avoid disaster.
		bCount = Math.floor(actor.pregType / pw);
		bLeft = actor.pregType - (bCount * pw);
		if (pw > actor.pregType) {
			pw = actor.pregType; // low children count broodmothers not supported here. It's emergency/backward compatibility code, and they not in game anyway. So minimum is 1 fetus in week.
			actor.preg = pw; // fixing initial pregnancy week.
		}
		for (i = 0; i < pw; i++) {
			WombImpregnate(actor, bCount, actor.pregSource, i); // setting fetuses for every week, up to 40 week at max.
		}

		if (bLeft > 0) {
			WombImpregnate(actor, bLeft, actor.pregSource, i + 1); // setting up leftover of fetuses.
		}
	}
};

window.WombImpregnate = function(actor, fCount, fatherID, age, surrogate) {
	let i;
	let tf;
	for (i = 0; i < fCount; i++) {
		tf = {}; // new Object
		tf.age = age; // initial age
		tf.realAge = 1; // initial real age (first week in mother)
		tf.fatherID = fatherID; // We can store who is father too.
		tf.volume = 1; // Initial, to create property. Updated with actual data after WombGetVolume call.
		tf.reserve = ""; // Initial, to create property. Used later to mark if this child is to be kept.
		tf.identical = 0; // Initial, to create property. Updated with actual data during fetalSplit call.
		tf.splitted = 0; // marker for already splitted fetus.
		if (surrogate) {
			tf.motherID = surrogate.ID; // Initial biological mother ID setup.
			if (actor.eggType === "human") {
				tf.genetics = generateGenetics(surrogate, fatherID, i + 1); // Stored genetic information.
			}
		} else {
			tf.motherID = actor.ID; // Initial biological mother ID setup.
			if (actor.eggType === "human") {
				tf.genetics = generateGenetics(actor, fatherID, i + 1); // Stored genetic information.
			}
		}
		tf.ID = generateNewID();

		try {
			if (actor.womb.length === 0) {
				actor.pregWeek = age;
				actor.preg = age;
			}
			actor.womb.push(tf);
		} catch (err) {
			WombInit(actor);
			actor.womb.push(tf);
			alert("WombImpregnate warning - " + actor.slaveName + " " + err);
		}
	}
	MissingParentIDCorrection(actor);
};

window.WombSurrogate = function(actor, fCount, mother, fatherID, age) {
	WombImpregnate(actor, fCount, fatherID, age, mother);
};

window.WombImpregnateClone = function(actor, fCount, mother, motherOriginal, age) {
	let i;
	let tf;
	for (i = 0; i < fCount; i++) {
		tf = {}; // new Object
		tf.age = age; // initial age
		tf.realAge = 1; // initial real age (first week in mother)
		tf.fatherID = mother.ID; // We can store who is father too.
		tf.volume = 1; // Initial, to create property. Updated with actual data after WombGetVolume call.
		tf.reserve = ""; // Initial, to create property. Used later to mark if this child is to be kept.
		tf.identical = 0; // Initial, to create property. Updated with actual data during fetalSplit call.
		tf.splitted = 0; // marker for already splitted fetus.
		tf.motherID = mother.ID; // Initial biological mother ID setup.
		tf.genetics = generateGenetics(mother, mother.ID, i + 1); // Stored genetic information.
		tf.ID = generateNewID();

		// Welcome to having to set up common relatives for the slave and her clone
		if (mother.father === 0 || (mother.father < -1 && mother.father >= -20 && mother.father !== -3)) {
			mother.father = State.variables.missingParentID;
			State.variables.missingParentID--;
		}
		if (mother.mother === 0 || (mother.mother < -1 && mother.mother >= -20 && mother.mother !== -3)) {
			mother.mother = State.variables.missingParentID;
			State.variables.missingParentID--;
		}

		// gene corrections
		tf.fatherID = -7;
		tf.genetics.gender = mother.genes;
		tf.genetics.mother = mother.mother;
		tf.genetics.father = mother.father;
		if (mother.ID === -1) {
			tf.genetics.motherName = mother.name;
			tf.genetics.fatherName = mother.name;
			tf.genetics.clone = PlayerName(mother);
			tf.genetics.cloneID = -1;
		} else {
			tf.genetics.motherName = mother.slaveName;
			tf.genetics.fatherName = mother.slaveName;
			tf.genetics.clone = SlaveFullName(mother);
			tf.genetics.cloneID = mother.ID;
		}
		tf.genetics.intelligence = motherOriginal.intelligence;
		tf.genetics.face = motherOriginal.face;
		tf.genetics.faceShape = motherOriginal.faceShape;
		tf.genetics.geneticQuirks = clone(motherOriginal.geneticQuirks);
		tf.genetics.skin = motherOriginal.skin;

		try {
			if (actor.womb.length === 0) {
				actor.pregWeek = age;
				actor.preg = age;
				actor.pregSource = -7;
			}
			actor.womb.push(tf);
		} catch (err) {
			WombInit(actor);
			actor.womb.push(tf);
			alert("WombImpregnate warning - " + actor.slaveName + " " + err);
		}
	}
};

// Should be used to set biological age for fetus (ageToAdd), AND chronological (realAgeToAdd). Speed up or slow down gestation drugs should affect ONLY biological.
window.WombProgress = function(actor, ageToAdd, realAgeToAdd = ageToAdd) {
	ageToAdd = Math.ceil(ageToAdd * 10) / 10;
	realAgeToAdd = Math.ceil(realAgeToAdd * 10) / 10;
	try {
		actor.womb.forEach(ft => {
			ft.age += ageToAdd;
			ft.realAge += realAgeToAdd;
		});
	} catch (err) {
		WombInit(actor);
		alert("WombProgress warning - " + actor.slaveName + " " + err);
	}
};

window.WombBirth = function(actor, readyAge) {
	try {
		WombSort(actor); // For normal processing fetuses that more old should be first. Now - they are.
	} catch (err) {
		WombInit(actor);
		alert("WombBirth warning - " + actor.slaveName + " " + err);
	}

	let birthed = [];
	let ready = WombBirthReady(actor, readyAge);
	let i;

	for (i = 0; i < ready; i++) { // here can't be used "for .. in .." syntax.
		birthed.push(actor.womb.shift());
	}

	return birthed;
};

window.WombFlush = function(actor) {
	actor.womb = [];
};

window.WombBirthReady = function(actor, readyAge) {
	let readyCnt = 0;
	try {
		readyCnt += actor.womb.filter(ft => ft.age >= readyAge).length;
	} catch (err) {
		WombInit(actor);
		alert("WombBirthReady warning - " + actor.slaveName + " " + err);
		return 0;
	}

	return readyCnt;
};

window.WombGetVolume = function(actor) { // most legacy code from pregJS.tw with minor adaptation.
	if (actor.pregData.sizeType === 0) {
		return getVolByLen(actor);
	} else if (actor.pregData.sizeType === 1) {
		return getVolByWeight(actor);
	} else if (actor.pregData.sizeType === 2) {
		return getVolByRaw(actor);
	} else {
		return 0;
	}

	function getCurData(actor, age) {
		let i = 0;
		let min, max, ageMin, ageMax, rateMin, rateMax, one, rateOne, rate, cage, csize;
		let data = {};

		while (actor.pregData.fetusWeek[i + 1] < age && i < actor.pregData.fetusWeek.length - 1) {
			i++;
		}

		min = actor.pregData.fetusSize[i];
		max = actor.pregData.fetusSize[i + 1];
		ageMin = actor.pregData.fetusWeek[i];
		ageMax = actor.pregData.fetusWeek[i + 1];
		rateMin = actor.pregData.fetusRate[i];
		rateMax = actor.pregData.fetusRate[i + 1];

		cage = age - ageMin;

		one = (max - min) / (ageMax - ageMin);
		rateOne = (rateMax - rateMin) / (ageMax - ageMin);

		rate = rateMin + (rateOne * cage);

		csize = (min + (one * cage));
		// console.log("min:"+min+"  max:"+max+"  ageMin:"+ageMin+"  ageMax:"+ageMax+"  one:"+one+"  rateOne:"+rateOne+"  cage:"+cage+"  rate:"+rate+"  csize:"+csize+"  final size:"+csize*rate);

		data.size = csize;
		data.rate = rate;

		return data; // csize * rate;
		// maybe not very effective code, but simple and easy to debug. May be optimized more in future.
	}

	function getVolByLen(actor) {
		let phi = 1.618;
		let targetData, targetLen;
		let wombSize = 0;

		try {
			actor.womb.forEach(ft => {
				/* legacy block for debug only
				let gestastionWeek = ft.age;
				let oldLen;
				let oldVol;
				if (gestastionWeek <= 32) {
					oldLen = (0.00006396 * Math.pow(gestastionWeek, 4)) -
						(0.005501 * Math.pow(gestastionWeek, 3)) +
						(0.161 * Math.pow(gestastionWeek, 2)) -
						(0.76 * gestastionWeek) +
						0.208;
				} else if (gestastionWeek <= 106) {
					oldLen = (-0.0000004675 * Math.pow(gestastionWeek, 4)) +
						(0.0001905 * Math.pow(gestastionWeek, 3)) -
						(0.029 * Math.pow(gestastionWeek, 2)) +
						(2.132 * gestastionWeek) -
						16.575;
				} else {
					oldLen = (-0.00003266 * Math.pow(gestastionWeek,2)) +
						(0.076 * gestastionWeek) +
						43.843;
				}
				*/

				targetData = getCurData(actor, ft.age);
				targetLen = targetData.size * targetData.rate;

				ft.volume = ((4 / 3) * (Math.PI) * (phi / 2) * (Math.pow((targetLen / 2), 3)));
				wombSize += ft.volume;

				// oldVol = ((4 / 3) * (Math.PI) * (phi / 2) * (Math.pow((oldLen / 2), 3))); //for debug

				// console.log("fetus.age:" + ft.age + "  oldLen:"+oldLen+"  targetLen:"+targetLen+"  ft.volume:"+ft.volume+ "  old volume:"+oldVol );
				/*
					I found, that previous targetLen calculation not exactly accurate if compared to the actual medical data chart for fetal length. It's been rough approximation based only on pregnancy week (giving smaller fetus size then it should in most cases). So I need all this debug code to compare data and verify calculations. After final tweaking I will remove or comment out legacy code. Please not touch this before it.
					Pregmodfan.
				*/
			});
		} catch (err) {
			WombInit(actor);
			alert("WombGetVolume warning - " + actor.slaveName + " " + err);
		}
		if (wombSize < 0) { // catch for strange cases, to avoid messing with outside code.
			wombSize = 0;
		}

		return wombSize;
	}

	function getVolByWeight(actor) {
		let targetData;
		let wombSize = 0;

		actor.womb.forEach(ft => {
			targetData = getCurData(actor, ft.age);

			wombSize += targetData.size * targetData.rate;
		});

		if (wombSize < 0) { // catch for strange cases, to avoid messing with outside code.
			wombSize = 0;
		}

		return wombSize;
	}

	function getVolByRaw(actor) {
		let targetData;
		let wombSize = 0;

		actor.womb.forEach(ft => {
			targetData = getCurData(actor, ft.age);

			wombSize += targetData.size;
		});

		if (wombSize < 0) { // catch for strange cases, to avoid messing with outside code.
			wombSize = 0;
		}

		return wombSize;
	}
};

window.WombUpdatePregVars = function(actor) {
	WombSort(actor);
	if (actor.womb.length > 0) {
		if (actor.preg > 0 && actor.womb[0].age > 0) {
			actor.preg = actor.womb[0].age;
		}
		actor.pregType = actor.womb.length;
		actor.bellyPreg = WombGetVolume(actor);
	}
};

window.WombMinPreg = function(actor) {
	WombSort(actor);
	if (actor.womb.length > 0) {
		return actor.womb[actor.womb.length - 1].age;
	} else {
		return 0;
	}
};

window.WombMaxPreg = function(actor) {
	WombSort(actor);
	if (actor.womb.length > 0) {
		return actor.womb[0].age;
	} else {
		return 0;
	}
};

window.WombNormalizePreg = function(actor) {
	// console.log("New actor: " + actor.slaveName + " ===============" + actor.name);
	WombInit(actor);

	// this is broodmother on hold.
	if (actor.womb.length === 0 && actor.broodmother >= 1) {
		actor.pregType = 0;
		actor.pregKnown = 0;

		// to avoid legacy code conflicts - broodmother on hold
		// can't be impregnated, but she is not on normal contraceptives.
		// So we set this for special case.
		if (actor.preg >= 0) {
			actor.preg = 0.1;
		}

		if (actor.pregSource > 0) {
			actor.pregSource = 0;
		}

		if (actor.pregWeek > 0) {
			actor.pregWeek = 0;
		}

		actor.broodmotherCountDown = 0;
	}

	if (actor.womb.length > 0) {
		let max = WombMaxPreg(actor);
		// console.log("max: " + max);
		// console.log(".preg: "+ actor.preg);
		if (actor.pregWeek < 1) {
			actor.pregWeek = 1;
		}

		if (max < actor.preg) {
			WombProgress(actor, actor.preg - max, actor.preg - max);
			// console.log("progressin womb");
		} else if (max > actor.preg) {
			actor.preg = max;
			// console.log("advancing .preg");
		}

		actor.pregType = actor.womb.length;
		actor.pregSource = actor.womb[0].fatherID;
	} else if (actor.womb.length === 0 && actor.broodmother < 1) {
		// not broodmother
		// console.log("preg fixing");
		actor.pregType = 0;
		actor.pregKnown = 0;

		if (actor.preg > 0) {
			actor.preg = 0;
		}

		if (actor.pregSource > 0) {
			actor.pregSource = 0;
		}

		// We can't properly set postpartum here,
		// but can normalize obvious error with forgotten property.
		if (actor.pregWeek > 0) {
			actor.pregWeek = 0;
		}
	}
	actor.bellyPreg = WombGetVolume(actor);
};

window.WombZeroID = function(actor, id) {
	WombInit(actor);
	actor.womb
		.filter(ft => ft.fatherID === id)
		.forEach(ft => ft.fatherID = 0);
	WombNormalizePreg(actor);
};

window.WombChangeID = function(actor, fromID, toID) {
	WombInit(actor);
	actor.womb
		.filter(ft => ft.fatherID === fromID)
		.forEach(ft => ft.fatherID = toID);
	WombNormalizePreg(actor);
};

window.WombChangeGeneID = function(actor, fromID, toID) {
	WombInit(actor);
	actor.womb
		.filter(ft => ft.genetics.father === fromID)
		.forEach(ft => ft.genetics.father = toID);
	actor.womb
		.filter(ft => ft.genetics.mother === fromID)
		.forEach(ft => ft.genetics.mother = toID);
	WombNormalizePreg(actor);
};

/* Sorts the womb object by age with oldest and thus soonest to be born, first. This will be needed in the future once individual fertilization is a possibility.*/
window.WombSort = function(actor) {
	actor.womb.sort((a, b) => {
		return b.age - a.age;
	});
};

// now function work with chance. Literary we give it "one from X" as chance.
window.fetalSplit = function(actor, chance) {
	let nft;

	actor.womb.forEach(function(s) {
		if ((jsRandom(1, chance) >= chance) && s.splitted !== 1) {
			nft = {};
			nft.age = s.age;
			nft.realAge = s.realAge;
			nft.fatherID = s.fatherID;
			nft.motherID = s.motherID;
			nft.volume = s.volume;
			nft.reserve = ""; // splitted fetus is new separate, reserve - it's not genetic to split.
			nft.genetics = clone(s.genetics);
			s.splitted = 1; // this is marker that this is already splitted fetus (to not split second time in loop), only source fetus needed it.
			nft.identical = 1; // this is marker that this fetus has at least one twin.
			s.identical = 1; // this is marker that this fetus has at least one twin.

			if (s.twinID === "" || s.twinID === undefined) {
				s.twinID = generateNewID();
			}

			nft.twinID = s.twinID;

			actor.womb.push(nft);
		}
	});
	WombNormalizePreg(actor);
};

// safe alternative to .womb.length.
window.WombFetusCount = function(actor) {
	WombInit(actor);
	return actor.womb.length;
};

// give reference to fetus object, but not remove fetus, use for manipulation in the womb.
window.WombGetFetus = function(actor, fetusNum) {
	WombInit(actor);
	if (actor.womb.length >= fetusNum) {
		return actor.womb[fetusNum];
	} else {
		return null;
	}
};

// give reference to fetus object, and remove it form the womb.
window.WombRemoveFetus = function(actor, fetusNum) {
	WombInit(actor);
	if (actor.womb.length >= fetusNum) {
		let ft = actor.womb[fetusNum];
		actor.womb.splice(fetusNum, 1);
		WombSort(actor);
		actor.pregType = actor.womb.length;
		return ft;
	} else {
		return null;
	}
};

/* to add fetus object in the womb. Be warned - you can add one single fetus to many wombs, or even add it many times to one womb. It will not show error, but behavior becomes strange, as fetus object will be the same - it's reference, not full copies. If this is not desired - use clone() on fetus before adding.*/
window.WombAddFetus = function(actor, fetus) {
	WombInit(actor);
	actor.womb.push(fetus);
	WombSort(actor);
};

// change property for all fetuses. Like fetus.age = X.
window.WombChangeFetus = function(actor, propName, newValue) {
	WombInit(actor);
	actor.womb.forEach(ft => ft[propName] = newValue);
};

// change genetic property of all fetuses. Like fetus.genetic.intelligence = X
window.WombChangeGene = function(actor, geneName, newValue) {
	WombInit(actor);
	actor.womb.forEach(ft => ft.genetics[geneName] = newValue);
};

// change genetic property of all fetuses based on race
window.WombFatherRace = function(actor, raceName) {
	let skinColor = randomRaceSkin(raceName);
	let eyeColor = randomRaceEye(raceName);
	let hairColor = randomRaceHair(raceName);
	WombChangeGene(actor, "race", raceName);
	WombChangeGene(actor, "skin", skinColor);
	WombChangeGene(actor, "eyeColor", eyeColor);
	WombChangeGene(actor, "hColor", hairColor);
};

// replaces untraceable fatherIDs with missingParentID. Required for concurrent pregnancy to differentiate between siblings.
window.MissingParentIDCorrection = function(actor) {
	WombInit(actor);
	actor.womb
		.filter(ft => (ft.genetics.father === 0 || (ft.genetics.father < -1 && ft.genetics.father >= -20 && ft.genetics.father !== -3)))
		.forEach(ft => ft.genetics.father = State.variables.missingParentID);
	State.variables.missingParentID--;
};

window.WombCleanYYFetuses = function(actor) {
	let reserved = [];

	let i = actor.womb.length - 1;
	let ft;

	while (i >= 0) {
		ft = actor.womb[i];

		if (ft.genetics.gender === "YY") {
			reserved.push(ft);
			actor.womb.splice(i, 1);
		}

		i--;
	}
	actor.pregType = actor.womb.length;

	return reserved;
};

window.FetusGlobalReserveCount = function(reserveType) {
	let cnt = 0;
	let SV = State.variables;

	if (typeof reserveType !== 'string') {
		return 0;
	}

	SV.slaves.forEach(function(slave) {
		slave.womb.forEach(function(ft) {
			if (ft.reserve === reserveType) {
				cnt++;
			}
		});
	});

	SV.PC.womb.forEach(function(ft) {
		if (ft.reserve === reserveType) {
			cnt++;
		}
	});

	return cnt;
};

window.WombSetGenericReserve = function(actor, type, count) {
	// console.log ("actor: " + actor + "  type: " + type + "  typeof: " + typeof type + "  count: " + count);
	actor.womb.forEach(function(ft) {
		// console.log ("  type: " + ft.reserve + "  typeof: " + typeof ft.reserve);
		if ((ft.reserve === "" || ft.reserve === type) && count > 0) {
			// console.log ("!trigger");
			ft.reserve = type;
			count--;
		}
	});
};

window.WombAddToGenericReserve = function(actor, type, count) {
	WombSetGenericReserve(actor, type, (WombReserveCount(actor, type) + count));
};

window.WombChangeReserveType = function(actor, oldType, newType) {
	let count = 0;

	actor.womb.forEach(function(ft) {
		if (ft.reserve === oldType) {
			ft.reserve = newType;
			count++;
		}
	});

	return count;
};

window.WombCleanGenericReserve = function(actor, type, count) {
	actor.womb.forEach(function(ft) {
		if (ft.reserve === type && count > 0) {
			ft.reserve = "";
			count--;
		}
	});
};

window.WombReserveCount = function(actor, type) {
	let cnt = 0;

	actor.womb.forEach(function(ft) {
		if (ft.reserve === type) /* the lazy equality will catch "" case */ {
			cnt++;
		}
	});

	return cnt;
};

window.WombGetReservedFetuses = function(actor, type) {
	let reserved = [];

	actor.womb.forEach(function(ft) {
		if (ft.reserve === type) {
			reserved.push(ft);
		}
	});

	return reserved;
};

window.WombRemoveReservedFetuses = function(actor, type) {
	let reserved = [];

	let i = actor.womb.length - 1;
	let ft;

	while (i >= 0) {
		ft = actor.womb[i];

		if (ft.reserve === type) {
			reserved.push(ft);
			actor.womb.splice(i, 1);
		}

		i--;
	}

	return reserved;
};

window.WombCleanAllReserve = function(actor) {
	actor.womb.forEach(function(ft) {
		ft.reserve = "";
	});
};

/*
Function return object with data about litters in actor womb. This data can be used for descriptions of pregnancy with complicated structure. What it contain:

data.litters.length = summary count of separate litters in the womb.
data.litters[x] = age (.realAge) of litter "x".
data.countLitter[x] = count of fetuses in "x" litter.

data.litterData[x] = contain array with actual fetuses that belong to a litter "x". Can be used to check anything related to fetus. (This is not copy, but reference to actual fetuses, so be careful with changes of this array).

Sample of usage in SugarScript:
---
<<set _wd = WombGetLittersData($activeSlave)>>
She is _wd.litters[0] weeks pregnant with her first set of _wd.countLitter[0] children<<if _wd.litters > 1>>, _wd.litters[1] weeks along with her second set<</if>><<if _wd.litters > 2>>, _wd.litters[2] and _wd.litters[2] weeks along with her third<</if>>.
In summary she carry _wd.litters.length separate sets of children. Her most progressed fetus of second pregnancy is already reached _wd.litterData[1][0].age biological week of gestation.
---
*/
window.WombGetLittersData = function(actor) {
	let data = {};
	let unicLiters = []; // array with realAges of separate litters.
	let countLitter = [];
	let litterData = [];
	let tmp;

	// in first place we need to know how many litters here (Assuming that unique litter is have similar .realAge). Also we will know their ages.
	actor.womb.forEach(function(ft) {
		if (!unicLiters.includes(Math.ceil(ft.realAge))) {
			unicLiters.push(Math.ceil(ft.realAge));
		}
	});

	// now we should find and store separate litters data (count of fetuses):
	unicLiters.forEach(function(litter) {
		tmp = actor.womb.filter(ft => Math.ceil(ft.realAge) === litter);
		countLitter.push(tmp.length);
		litterData.push(tmp);
	});

	data.litters = unicLiters;
	data.countLitter = countLitter;
	data.litterData = litterData;

	return data;
};

window.BCReserveInit = function() {
	let SV = State.variables;

	SV.slaves.forEach(function(slave) {
		slave.womb.forEach(function(ft) {
			if (typeof ft.reserve !== 'string') {
				ft.reserve = "";
			}
			if (typeof ft.motherID !== 'number') { // setting missing biological mother ID for fetus.
				ft.motherID = slave.ID;
			}
			if (ft.ID === undefined) {
				ft.ID = generateNewID();
			}
			if (typeof ft.realAge !== 'number') { // setting missing chronological age
				ft.realAge = ft.age;
			}
		});
	});

	SV.PC.womb.forEach(function(ft) {
		if (typeof ft.reserve !== 'string') {
			ft.reserve = "";
		}
		if (typeof ft.motherID !== 'number') {
			ft.motherID = SV.PC.ID;
		}
		if (typeof ft.realAge !== 'number') { // setting missing chronological age
			ft.realAge = ft.age;
		}
	});
};

/* alt
window.fetalSplit = function(actor, chance)
{
	let i, ft, nft;

	actor.womb.forEach(function(s){
		if ((jsRandom(1,chance) >= chance) && s.identical !== 1)
		{
			nft = clone(s);
			actor.womb.push(nft);
			s.identical = 1;
		}
	});
	WombNormalizePreg(actor);

}
*/

repo_name: AmbrosiaCheesecake/fc


code:
window.arcologyOpinion = function() {
	const V = State.variables;

	if (typeof V.activeArcology.FSNull === "undefined") { V.activeArcology.FSNull = "unset"; }
	if (typeof V.targetArcology.FSNull === "undefined") { V.targetArcology.FSNull = "unset"; }

	let opinion = 0;

	if (V.activeArcology.FSSubjugationist !== "unset") {
		if (V.targetArcology.FSSubjugationist !== "unset") {
			if (V.targetArcology.FSSubjugationistRace === V.activeArcology.FSSubjugationistRace) {
				opinion += V.activeArcology.FSSubjugationist;
				opinion += V.targetArcology.FSSubjugationist;
			} else {
				opinion -= V.activeArcology.FSSubjugationist;
				opinion -= V.targetArcology.FSSubjugationist;
			}
		} else if (V.targetArcology.FSSupremacist !== "unset") {
			if (V.targetArcology.FSSupremacistRace === V.activeArcology.FSSubjugationistRace) {
				opinion -= V.activeArcology.FSSubjugationist;
				opinion -= V.targetArcology.FSSupremacist;
			}
		}
	}
	if (V.activeArcology.FSSupremacist !== "unset") {
		if (V.targetArcology.FSSupremacist !== "unset") {
			if (V.targetArcology.FSSupremacistRace === V.activeArcology.FSSupremacistRace) {
				opinion += V.activeArcology.FSSupremacist;
				opinion += V.targetArcology.FSSupremacist;
			} else {
				opinion -= V.activeArcology.FSSupremacist;
				opinion -= V.targetArcology.FSSupremacist;
			}
		} else if (V.targetArcology.FSSubjugationist !== "unset") {
			if (V.targetArcology.FSSubjugationistRace === V.activeArcology.FSSupremacistRace) {
				opinion -= V.activeArcology.FSSupremacist;
				opinion -= V.targetArcology.FSSubjugationist;
			}
		}
	}
	if (V.activeArcology.FSRepopulationFocus !== "unset") {
		if (V.targetArcology.FSRepopulationFocus !== "unset") {
			opinion += V.activeArcology.FSRepopulationFocus;
			opinion += V.targetArcology.FSRepopulationFocus;
		} else if (V.targetArcology.FSRestart !== "unset") {
			opinion -= V.activeArcology.FSRepopulationFocus;
			opinion -= V.targetArcology.FSRestart;
		}
	} else if (V.activeArcology.FSRestart !== "unset") {
		if (V.targetArcology.FSRestart !== "unset") {
			opinion += V.activeArcology.FSRestart;
			opinion += V.targetArcology.FSRestart;
		} else if (V.targetArcology.FSRepopulationFocus !== "unset") {
			opinion -= V.activeArcology.FSRestart;
			opinion -= V.targetArcology.FSRepopulationFocus;
		}
	}
	if (V.activeArcology.FSGenderRadicalist !== "unset") {
		if (V.targetArcology.FSGenderRadicalist !== "unset") {
			opinion += V.activeArcology.FSGenderRadicalist;
			opinion += V.targetArcology.FSGenderRadicalist;
		} else if (V.targetArcology.FSGenderFundamentalist !== "unset") {
			opinion -= V.activeArcology.FSGenderRadicalist;
			opinion -= V.targetArcology.FSGenderFundamentalist;
		}
	} else if (V.activeArcology.FSGenderFundamentalist !== "unset") {
		if (V.targetArcology.FSGenderFundamentalist !== "unset") {
			opinion += V.activeArcology.FSGenderFundamentalist;
			opinion += V.targetArcology.FSGenderFundamentalist;
		} else if (V.targetArcology.FSGenderRadicalist !== "unset") {
			opinion -= V.activeArcology.FSGenderFundamentalist;
			opinion -= V.targetArcology.FSGenderRadicalist;
		}
	}
	if (V.activeArcology.FSPaternalist !== "unset") {
		if (V.targetArcology.FSPaternalist !== "unset") {
			opinion += V.activeArcology.FSPaternalist;
			opinion += V.targetArcology.FSPaternalist;
		} else if (V.targetArcology.FSDegradationist !== "unset") {
			opinion -= V.activeArcology.FSPaternalist;
			opinion -= V.targetArcology.FSDegradationist;
		}
	} else if (V.activeArcology.FSDegradationist !== "unset") {
		if (V.targetArcology.FSDegradationist !== "unset") {
			opinion += V.activeArcology.FSDegradationist;
			opinion += V.targetArcology.FSDegradationist;
		} else if (V.targetArcology.FSPaternalist !== "unset") {
			opinion -= V.activeArcology.FSDegradationist;
			opinion -= V.targetArcology.FSPaternalist;
		}
	}
	if (V.activeArcology.FSBodyPurist !== "unset") {
		if (V.targetArcology.FSBodyPurist !== "unset") {
			opinion += V.activeArcology.FSBodyPurist;
			opinion += V.targetArcology.FSBodyPurist;
		} else if (V.targetArcology.FSTransformationFetishist !== "unset") {
			opinion -= V.activeArcology.FSBodyPurist;
			opinion -= V.targetArcology.FSTransformationFetishist;
		}
	} else if (V.activeArcology.FSTransformationFetishist !== "unset") {
		if (V.targetArcology.FSTransformationFetishist !== "unset") {
			opinion += V.activeArcology.FSTransformationFetishist;
			opinion += V.targetArcology.FSTransformationFetishist;
		} else if (V.targetArcology.FSBodyPurist !== "unset") {
			opinion -= V.activeArcology.FSTransformationFetishist;
			opinion -= V.targetArcology.FSBodyPurist;
		}
	}
	if (V.activeArcology.FSYouthPreferentialist !== "unset") {
		if (V.targetArcology.FSYouthPreferentialist !== "unset") {
			opinion += V.activeArcology.FSYouthPreferentialist;
			opinion += V.targetArcology.FSYouthPreferentialist;
		} else if (V.targetArcology.FSMaturityPreferentialist !== "unset") {
			opinion -= V.activeArcology.FSYouthPreferentialist;
			opinion -= V.targetArcology.FSMaturityPreferentialist;
		}
	} else if (V.activeArcology.FSMaturityPreferentialist !== "unset") {
		if (V.targetArcology.FSMaturityPreferentialist !== "unset") {
			opinion += V.activeArcology.FSMaturityPreferentialist;
			opinion += V.targetArcology.FSMaturityPreferentialist;
		} else if (V.targetArcology.FSYouthPreferentialist !== "unset") {
			opinion -= V.activeArcology.FSMaturityPreferentialist;
			opinion -= V.targetArcology.FSYouthPreferentialist;
		}
	}
	if (V.activeArcology.FSSlimnessEnthusiast !== "unset") {
		if (V.targetArcology.FSSlimnessEnthusiast !== "unset") {
			opinion += V.activeArcology.FSSlimnessEnthusiast;
			opinion += V.targetArcology.FSSlimnessEnthusiast;
		} else if (V.targetArcology.FSAssetExpansionist !== "unset") {
			opinion -= V.activeArcology.FSSlimnessEnthusiast;
			opinion -= V.targetArcology.FSAssetExpansionist;
		}
	} else if (V.activeArcology.FSAssetExpansionist !== "unset") {
		if (V.targetArcology.FSAssetExpansionist !== "unset") {
			opinion += V.activeArcology.FSAssetExpansionist;
			opinion += V.targetArcology.FSAssetExpansionist;
		} else if (V.targetArcology.FSSlimnessEnthusiast !== "unset") {
			opinion -= V.activeArcology.FSAssetExpansionist;
			opinion -= V.targetArcology.FSSlimnessEnthusiast;
		}
	}
	if (V.activeArcology.FSPastoralist !== "unset") {
		if (V.targetArcology.FSPastoralist !== "unset") {
			opinion += V.activeArcology.FSPastoralist;
			opinion += V.targetArcology.FSPastoralist;
		} else if (V.targetArcology.FSCummunism !== "unset") {
			opinion -= V.activeArcology.FSPastoralist;
			opinion -= V.targetArcology.FSCummunism;
		}
	} else if (V.activeArcology.FSCummunism !== "unset") {
		if (V.targetArcology.FSCummunism !== "unset") {
			opinion += V.activeArcology.FSCummunism;
			opinion += V.targetArcology.FSCummunism;
		} else if (V.targetArcology.FSPastoralist !== "unset") {
			opinion -= V.activeArcology.FSCummunism;
			opinion -= V.targetArcology.FSPastoralist;
		}
	}
	if (V.activeArcology.FSPhysicalIdealist !== "unset") {
		if (V.targetArcology.FSPhysicalIdealist !== "unset") {
			opinion += V.activeArcology.FSPhysicalIdealist;
			opinion += V.targetArcology.FSPhysicalIdealist;
		} else if (V.targetArcology.FSHedonisticDecadence !== "unset") {
			opinion -= V.activeArcology.FSPhysicalIdealist;
			opinion -= V.targetArcology.FSHedonisticDecadence;
		}
	} else if (V.activeArcology.FSHedonisticDecadence !== "unset") {
		if (V.targetArcology.FSHedonisticDecadence !== "unset") {
			opinion += V.activeArcology.FSHedonisticDecadence;
			opinion += V.targetArcology.FSHedonisticDecadence;
		} else if (V.targetArcology.FSPhysicalIdealist !== "unset") {
			opinion -= V.activeArcology.FSHedonisticDecadence;
			opinion -= V.targetArcology.FSPhysicalIdealist;
		}
	}
	if (V.activeArcology.FSChattelReligionist !== "unset") {
		if (V.targetArcology.FSChattelReligionist !== "unset") {
			opinion += V.activeArcology.FSChattelReligionist;
			opinion += V.targetArcology.FSChattelReligionist;
		} else if (V.targetArcology.FSNull !== "unset") {
			opinion -= V.activeArcology.FSChattelReligionist;
			opinion -= V.targetArcology.FSNull;
		}
	} else if (V.activeArcology.FSNull !== "unset") {
		if (V.targetArcology.FSNull !== "unset") {
			opinion += V.activeArcology.FSNull;
			opinion += V.targetArcology.FSNull;
		} else if (V.targetArcology.FSChattelReligionist !== "unset") {
			opinion -= V.activeArcology.FSNull;
			opinion -= V.targetArcology.FSChattelReligionist;
		} else {
			opinion += V.activeArcology.FSNull;
		}
	} else if (V.targetArcology.FSNull !== "unset") {
		opinion += V.targetArcology.FSNull;
	}
	if (V.activeArcology.FSRomanRevivalist !== "unset") {
		if (V.targetArcology.FSRomanRevivalist !== "unset") {
			opinion += V.activeArcology.FSRomanRevivalist;
			opinion += V.targetArcology.FSRomanRevivalist;
		} else if (V.targetArcology.FSAztecRevivalist !== "unset") {
			opinion -= V.activeArcology.FSRomanRevivalist;
			opinion -= V.targetArcology.FSAztecRevivalist;
		} else if (V.targetArcology.FSEgyptianRevivalist !== "unset") {
			opinion -= V.activeArcology.FSRomanRevivalist;
			opinion -= V.targetArcology.FSEgyptianRevivalist;
		} else if (V.targetArcology.FSEdoRevivalist !== "unset") {
			opinion -= V.activeArcology.FSRomanRevivalist;
			opinion -= V.targetArcology.FSEdoRevivalist;
		} else if (V.targetArcology.FSArabianRevivalist !== "unset") {
			opinion -= V.activeArcology.FSRomanRevivalist;
			opinion -= V.targetArcology.FSArabianRevivalist;
		} else if (V.targetArcology.FSChineseRevivalist !== "unset") {
			opinion -= V.activeArcology.FSRomanRevivalist;
			opinion -= V.targetArcology.FSChineseRevivalist;
		}
	} else if (V.activeArcology.FSAztecRevivalist !== "unset") {
		if (V.targetArcology.FSAztecRevivalist !== "unset") {
			opinion += V.activeArcology.FSAztecRevivalist;
			opinion += V.targetArcology.FSAztecRevivalist;
		} else if (V.targetArcology.FSRomanRevivalist !== "unset") {
			opinion -= V.activeArcology.FSAztecRevivalist;
			opinion -= V.targetArcology.FSRomanRevivalist;
		} else if (V.targetArcology.FSEgyptianRevivalist !== "unset") {
			opinion -= V.activeArcology.FSAztecRevivalist;
			opinion -= V.targetArcology.FSEgyptianRevivalist;
		} else if (V.targetArcology.FSEdoRevivalist !== "unset") {
			opinion -= V.activeArcology.FSAztecRevivalist;
			opinion -= V.targetArcology.FSEdoRevivalist;
		} else if (V.targetArcology.FSArabianRevivalist !== "unset") {
			opinion -= V.activeArcology.FSAztecRevivalist;
			opinion -= V.targetArcology.FSArabianRevivalist;
		} else if (V.targetArcology.FSChineseRevivalist !== "unset") {
			opinion -= V.activeArcology.FSAztecRevivalist;
			opinion -= V.targetArcology.FSChineseRevivalist;
		}
	} else if (V.activeArcology.FSEgyptianRevivalist !== "unset") {
		if (V.targetArcology.FSEgyptianRevivalist !== "unset") {
			opinion += V.activeArcology.FSEgyptianRevivalist;
			opinion += V.targetArcology.FSEgyptianRevivalist;
		} else if (V.targetArcology.FSRomanRevivalist !== "unset") {
			opinion -= V.activeArcology.FSEgyptianRevivalist;
			opinion -= V.targetArcology.FSRomanRevivalist;
		} else if (V.targetArcology.FSAztecRevivalist !== "unset") {
			opinion -= V.activeArcology.FSEgyptianRevivalist;
			opinion -= V.targetArcology.FSAztecRevivalist;
		} else if (V.targetArcology.FSEdoRevivalist !== "unset") {
			opinion -= V.activeArcology.FSEgyptianRevivalist;
			opinion -= V.targetArcology.FSEdoRevivalist;
		} else if (V.targetArcology.FSArabianRevivalist !== "unset") {
			opinion -= V.activeArcology.FSEgyptianRevivalist;
			opinion -= V.targetArcology.FSArabianRevivalist;
		} else if (V.targetArcology.FSChineseRevivalist !== "unset") {
			opinion -= V.activeArcology.FSEgyptianRevivalist;
			opinion -= V.targetArcology.FSChineseRevivalist;
		}
		if (V.targetArcology.FSIncestFetishist !== "unset") {
			opinion += V.activeArcology.FSEgyptianRevivalist;
			opinion += V.targetArcology.FSIncestFetishist;
		}
	} else if (V.activeArcology.FSEdoRevivalist !== "unset") {
		if (V.targetArcology.FSEdoRevivalist !== "unset") {
			opinion += V.activeArcology.FSEdoRevivalist;
			opinion += V.targetArcology.FSEdoRevivalist;
		} else if (V.targetArcology.FSEgyptianRevivalist !== "unset") {
			opinion -= V.activeArcology.FSEdoRevivalist;
			opinion -= V.targetArcology.FSEgyptianRevivalist;
		} else if (V.targetArcology.FSRomanRevivalist !== "unset") {
			opinion -= V.activeArcology.FSEdoRevivalist;
			opinion -= V.targetArcology.FSRomanRevivalist;
		} else if (V.targetArcology.FSAztecRevivalist !== "unset") {
			opinion -= V.activeArcology.FSEdoRevivalist;
			opinion -= V.targetArcology.FSAztecRevivalist;
		} else if (V.targetArcology.FSArabianRevivalist !== "unset") {
			opinion -= V.activeArcology.FSEdoRevivalist;
			opinion -= V.targetArcology.FSArabianRevivalist;
		} else if (V.targetArcology.FSChineseRevivalist !== "unset") {
			opinion -= V.activeArcology.FSEdoRevivalist;
			opinion -= V.targetArcology.FSChineseRevivalist;
		}
	} else if (V.activeArcology.FSArabianRevivalist !== "unset") {
		if (V.targetArcology.FSArabianRevivalist !== "unset") {
			opinion += V.activeArcology.FSArabianRevivalist;
			opinion += V.targetArcology.FSArabianRevivalist;
		} else if (V.targetArcology.FSEgyptianRevivalist !== "unset") {
			opinion -= V.activeArcology.FSArabianRevivalist;
			opinion -= V.targetArcology.FSEgyptianRevivalist;
		} else if (V.targetArcology.FSEdoRevivalist !== "unset") {
			opinion -= V.activeArcology.FSArabianRevivalist;
			opinion -= V.targetArcology.FSEdoRevivalist;
		} else if (V.targetArcology.FSRomanRevivalist !== "unset") {
			opinion -= V.activeArcology.FSArabianRevivalist;
			opinion -= V.targetArcology.FSRomanRevivalist;
		} else if (V.targetArcology.FSAztecRevivalist !== "unset") {
			opinion -= V.activeArcology.FSArabianRevivalist;
			opinion -= V.targetArcology.FSAztecRevivalist;
		} else if (V.targetArcology.FSChineseRevivalist !== "unset") {
			opinion -= V.activeArcology.FSArabianRevivalist;
			opinion -= V.targetArcology.FSChineseRevivalist;
		}
	} else if (V.activeArcology.FSChineseRevivalist !== "unset") {
		if (V.targetArcology.FSChineseRevivalist !== "unset") {
			opinion += V.activeArcology.FSChineseRevivalist;
			opinion += V.targetArcology.FSChineseRevivalist;
		} else if (V.targetArcology.FSEgyptianRevivalist !== "unset") {
			opinion -= V.activeArcology.FSChineseRevivalist;
			opinion -= V.targetArcology.FSEgyptianRevivalist;
		} else if (V.targetArcology.FSEdoRevivalist !== "unset") {
			opinion -= V.activeArcology.FSChineseRevivalist;
			opinion -= V.targetArcology.FSEdoRevivalist;
		} else if (V.targetArcology.FSArabianRevivalist !== "unset") {
			opinion -= V.activeArcology.FSChineseRevivalist;
			opinion -= V.targetArcology.FSArabianRevivalist;
		} else if (V.targetArcology.FSRomanRevivalist !== "unset") {
			opinion -= V.activeArcology.FSChineseRevivalist;
			opinion -= V.targetArcology.FSRomanRevivalist;
		} else if (V.targetArcology.FSAztecRevivalist !== "unset") {
			opinion -= V.activeArcology.FSChineseRevivalist;
			opinion -= V.targetArcology.FSAztecRevivalist;
		}
	}
	if (V.activeArcology.FSIncestFetishist !== "unset") {
		if (V.targetArcology.FSIncestFetishist !== "unset") {
			opinion += V.activeArcology.FSIncestFetishist;
			opinion += V.targetArcology.FSIncestFetishist;
		}
		if (V.targetArcology.FSEgyptianRevivalist !== "unset") {
			opinion += V.activeArcology.FSIncestFetishist;
			opinion += V.targetArcology.FSEgyptianRevivalist;
		}
	}

	V.opinion = Number(opinion) || 0;

	V.activeArcology = 0;
	V.targetArcology = 0;
};


code:
:: Abort [nobr]

<<set $nextButton = "Back", $nextLink = "Slave Interact">>
<<run clearSummaryCache($activeSlave)>>

The remote surgery makes aborting a pregnancy quick and efficient.

<<if $activeSlave.preg < 4>>
	It was so early in $his pregnancy that the potential mental effects are diminished.
<<else>>
	$activeSlave.slaveName is
	<<if ($activeSlave.fuckdoll > 0) || ($activeSlave.fetish == "mindbroken")>>
		completely unmoved by the development.
	<<elseif $activeSlave.sexualFlaw == "breeder">>
		@@.red;fundamentally broken.@@ $His entire concept of self and sexuality was wrapped up in the life growing within $him, and now it is gone.
		<<set $activeSlave.fetish = "mindbroken", $activeSlave.behavioralQuirk = "none", $activeSlave.behavioralFlaw = "none", $activeSlave.sexualQuirk = "none", $activeSlave.sexualFlaw = "none", $activeSlave.devotion = 0, $activeSlave.trust = 0>>
	<<elseif $activeSlave.devotion < -50>>
		@@.mediumorchid;filled with violent, consuming hatred.@@ Even though $he knew $his baby was destined for a slave orphanage, it seems $he cared for it and views you as its killer. $He is @@.gold;terrified of your power@@ over $his body.
		<<set $activeSlave.trust -= 10, $activeSlave.devotion -= 25>>
	<<elseif $activeSlave.devotion < -20>>
		@@.mediumorchid;afflicted by desperate, inconsolable sobbing.@@ Even though $he knew $his baby was destined for a slave orphanage, it seems $he cared for it. $He is @@.gold;terrified of your power@@ over $his body.
		<<set $activeSlave.trust -= 10, $activeSlave.devotion -= 10>>
	<<elseif $activeSlave.fetish == "pregnancy">>
		@@.mediumorchid;filled with a deep sorrow.@@ To a pregnancy fetishist, having a pregnancy end like this hurts far worse than birth ever would. $He is @@.gold;terrified of a repeat performance.@@
		<<set _fetishModifier = $activeSlave.fetishStrength/2>>
		<<set $activeSlave.devotion -= 1*_fetishModifier, $activeSlave.trust -= 1*_fetishModifier>>
	<<elseif $activeSlave.devotion <= 20>>
		@@.mediumorchid;consumed by muted weeping and enduring sorrow.@@ Even though $he knew $his baby was destined for a slave orphanage, it seems $he cared for it. $He is @@.gold;terrified of your power@@ over $his body.
		<<set $activeSlave.trust -= 10, $activeSlave.devotion -= 5>>
	<<elseif $activeSlave.devotion <= 50>>
		dully obedient. $He has been broken to slave life so thoroughly that even this is neither surprising nor affecting. $He is @@.gold;terrified of your power@@ over $his body.
		<<set $activeSlave.trust -= 10>>
	<<else>>
		@@.hotpink;pleased by this stark development,@@ since $he is so attentive to your will. $He also expects $he'll be able to fuck better now.
		<<set $activeSlave.devotion += 4>>
	<</if>>
<</if>>

<<if $activeSlave.abortionTat > -1>>
	<<set $activeSlave.abortionTat++>>
	The temporary tattoo of a child has been replaced with $his <<= ordinalSuffix($activeSlave.abortionTat)>> crossed out infant.
	<<run cashX(forceNeg($modCost), "slaveMod", $activeSlave)>>
<</if>>

<<if lastPregRule($activeSlave,$defaultRules)>><<set $activeSlave.preg = -1>><<else>><<set $activeSlave.preg = 0>><</if>>

<<set $reservedChildren = FetusGlobalReserveCount("incubator")>>
<<set $reservedChildrenNursery = FetusGlobalReserveCount("nursery")>>

<<set $activeSlave.pregType = 0>>
<<set $activeSlave.pregSource = 0>>
<<set $activeSlave.pregKnown = 0>>
<<set $activeSlave.pregWeek = -2>>
<<set WombFlush($activeSlave)>>
<<run SetBellySize($activeSlave)>>


code:
:: Acquisition [nobr]

<<unset $slaveWithoutBonuses, $startingGirlCopied, $startingGirlRelation>>

<<set $fixedNationality = 0, $encyclopedia = " ">>

<<if $saveImported == 1>><<set _valueOwed = 5000>><<else>><<set _valueOwed = 50000>><</if>>
<<if $freshPC == 1 || $saveImported == 0>>
	<<if $PC.career == "servant">>
		<<set $PC.geneticQuirks.fertility = 1>>
	<</if>>
	<<if $PC.vagina == 1>>
		<<set $PC.births = 0>>
		<<if $PC.career == "servant">>
			<<if $PC.pregType != 8>>
				<<if $PC.actualAge >= 50>>
					<<set $PC.births = 9>>
					<<set $PC.birthMaster = 9>>
				<<elseif $PC.actualAge >= 35>>
					<<set $PC.births = 6>>
					<<set $PC.birthMaster = 6>>
				<<else>>
					<<set $PC.births = 3>>
					<<set $PC.birthMaster = 3>>
				<</if>>
			<<else>> /* Master kept you pregged up */
				<<if $PC.actualAge >= 50>>
					<<set $PC.births = 70>>
					<<set $PC.birthMaster = 70>>
				<<elseif $PC.actualAge >= 35>>
					<<set $PC.births = 40>>
					<<set $PC.birthMaster = 40>>
				<<else>>
					<<set $PC.births = 16>>
					<<set $PC.birthMaster = 16>>
				<</if>>
			<</if>>
			<<set $PC.geneticQuirks.fertility = 2>>
			<<for $i = 0; $i < $slaves.length; $i++>>
				<<if $slaves[$i].mother == -1>>
					<<set $PC.births += 1>>
					<<if $slaves[$i].father == -1>>
						<<set $PC.birthSelf += 1>>
					<<else>>
						<<set $slaves[$i].father = -3>>
						<<set $PC.birthMaster += 1>>
					<</if>>
				<</if>>
			<</for>>
		<<elseif $PC.career == "escort">>
			<<for $i = 0; $i < $slaves.length; $i++>>
				<<if $slaves[$i].mother == -1>>
					<<set $PC.births += 1>>
					<<if $slaves[$i].father == -1>>
						<<set $PC.birthSelf += 1>>
					<<else>>
						<<set $slaves[$i].father = -5>>
						<<set $PC.birthClient += 1>>
					<</if>>
				<<elseif $slaves[$i].father == -1>>
					<<set $slaves[$i].mother = -5>>
				<</if>>
			<</for>>
		<<else>>
			<<for $i = 0; $i < $slaves.length; $i++>>
				<<if $slaves[$i].mother == -1>>
					<<set $PC.births += 1>>
					<<if $slaves[$i].father == -1>>
						<<set $PC.birthSelf += 1>>
					<<else>>
						<<set $PC.birthOther += 1>>
					<</if>>
				<</if>>
			<</for>>
		<</if>>
		<<if $PC.preg > 0>>
			<<set $PC.pregWeek = $PC.preg>>
			<<if $PC.pregType != 8>>
				<<set $PC.pregType = 1>>
			<<else>>
				<<set $PC.geneticQuirks.hyperFertility = 2>>
			<</if>>
			<<if $PC.career == "servant">>
				<<set $PC.pregSource = -3>>
				<<if $PC.pregType != 8>>
					<<set $PC.pregType += random(0,0,1)>>
				<</if>>
			<<elseif $PC.career == "escort">>
				<<set $PC.pregSource = -5>>
			<</if>>
			<<set $PC.pregKnown = 1>>
			<<set $PC.belly = getPregBellySize($PC)>>
			<<set WombImpregnate($PC, $PC.pregType, $PC.pregSource, $PC.preg)>>
		<</if>>
	<</if>>
	<<if $PC.dick == 1>>
		<<set $PC.geneticQuirks.wellHung = 2>>
	<</if>>
	<<set $PC.ovaryAge = $PC.physicalAge>>
<<else>> /*testtest*/
	<<set $PC.sisters = 0>>
	<<set $PC.daughters = 0>>
<</if>> /*closes ng*/
<<if $familyTesting == 1>>
	<<set _pcMomFound = 0, _pcDadFound = 0>>
	<<if def $slaveIndices[$PC.mother]>>
		<<set _pcMomFound = 1>>
	<</if>>
	<<if def $slaveIndices[$PC.father]>>
		<<set _pcDadFound = 1>>
	<</if>>
	<<for _i = 0; _i < $slaves.length; _i++>>
		<<if $slaves[_i].mother == $PC.ID || $slaves[_i].father == $PC.ID>>
			<<set $PC.daughters += 1>>
		<</if>>
		<<if areSisters($slaves[_i], $PC) > 0>>
			<<set $PC.sisters += 1>>
		<</if>>
	<</for>>
	<<if _pcMomFound == 0 && $PC.mother > 0>>
		<<set _lostMom = $PC.mother>>
		<<set $PC.mother = $missingParentId>>
		<<for _i = 0; _i < $slaves.length; _i++>>
			<<if $slaves[_i].mother == _lostMom>>
				<<set $slaves[_i].mother = $missingParentId>>
			<</if>>
		<</for>>
		<<set $missingParentId-->>
	<</if>>
	<<if _pcDadFound == 0 && $PC.father > 0>>
		<<set _lostDad = $PC.father>>
		<<set $PC.father = $missingParentId>>
		<<for _i = 0; _i < $slaves.length; _i++>>
			<<if $slaves[_i].father == _lostDad>>
				<<set $slaves[_i].father = $missingParentId>>
			<</if>>
		<</for>>
		<<set $missingParentId-->>
	<</if>>
	<<for _i = 0; _i < $slaves.length; _i++>>
		<<set _slaveMomFound = 0, _slaveDadFound = 0>>
		<<if def $slaveIndices[$slaves[_i].mother]>>
			<<set _slaveMomFound = 1>>
		<</if>>
		<<if def $slaveIndices[$slaves[_i].father]>>
			<<set _slaveDadFound = 1>>
		<</if>>
		<<if _slaveMomFound == 0 && $slaves[_i].mother > 0>>
			<<set _lostMom = $slaves[_i].mother>>
			<<set $slaves[_i].mother = $missingParentID>>
			<<for _j = 0; _j < $slaves.length; _j++>>
				<<if $slaves[_j].mother == _lostMom>>
					<<set $slaves[_j].mother = $missingParentID>>
				<</if>>
			<</for>>
			<<set $missingParentID-->>
		<</if>>
		<<if _slaveDadFound == 0 && $slaves[_i].father > 0>>
			<<set _lostDad = $slaves[_i].father>>
			<<set $slaves[_i].father = $missingParentID>>
			<<for _j = 0; _j < $slaves.length; _j++>>
				<<if $slaves[_j].father == _lostDad>>
					<<set $slaves[_j].father = $missingParentID>>
				<</if>>
			<</for>>
			<<set $missingParentID-->>
		<</if>>
	<</for>>
<</if>>
<<if $plot == 1 && $neighboringArcologies > 0>>
	<<set _bestProsperity = 0, _bestProsperityIndex = 1>>
	<<for _acq = 1; _acq < $arcologies.length; _acq++>>
		<<if $arcologies[_acq].prosperity > _bestProsperity>>
			<<set _bestProsperity = $arcologies[_acq].prosperity>>
			<<set _bestProsperityIndex = _acq>>
		<</if>>
	<</for>>
	<<set $rivalSet = 1>>
	<<set $arcologies[_bestProsperityIndex].rival = 1>>
<</if>>

You've done it.

You arrive at your new arcology, $arcologies[0].name, and head straight to the penthouse to enter the access codes that will tell the $arcologies[0].name systems to recognize you as their owner. The penthouse office is ready to receive the codes, and they authenticate. A voice activates in your earpiece.

//Congratulations. I am a personal assistant program, and it is my pleasure to assist you,
<<= PlayerName()>>
the new owner of $arcologies[0].name. I will offer useful information whenever possible in italics. Your new arcology has some unusual equipment. The previous owner kept a small stable of sex slaves. The penthouse therefore has a body modification studio for tattooing, bleaching and piercing, and an auto salon for more prosaic things like hair care. It also has a remote surgery, a small surgical theater that can be operated remotely by a qualified surgeon if you can pay the fee. Finally, it has a slave nutrition system connected to the arcology's hydroponics bays. This system produces a tasty protein-rich drink that provides the physically active female body all its necessary nutrients while leaving the lower digestive tract extremely clean. It even causes a mild increase in sex drive.

The previous owner seems to have left in something of a hurry.
<<if $cheatMode == 1>>
	Since you've elected to take over an arcology with special advantages, you've acquired a very special group of slaves.
<<elseif $saveImported == 1>>
	Since it took some time for you to ensure that your existing stable of slaves were safely moved to $arcologies[0].name, the previous owner had the time to get most of their things away.
<<elseif ($targetArcology.type != "New") && ($targetArcology.type != "Multiculturalist")>>
	<<switch $targetArcology.type>>
	<<case "Supremacist">>
		They kept a personal stable of fearful $arcologies[0].FSSupremacistRace sex slaves, but their sexual training is incomplete. Several of them are still here.
	<<case "Subjugationist">>
		They made it a special goal to enslave and whore out as many $arcologies[0].FSSubjugationistRace people as possible. Several of them are still here.
	<<case "GenderRadicalist">>
		They were in the process of building a stable of pretty young shemale whores. Several of them are still here. They're are all very attracted to men, and skilled at pleasing them.
	<<case "GenderFundamentalist">>
		They kept a personal stable of slaves for breeding purposes. Several of them are still here. They've been kept pregnant, and work as servants when they aren't being bred.
	<<case "Paternalist">>
		Their slaves were all very well treated. Several of them are still here. They were allowed to work as maids, and weren't even forced to have sex.
	<<case "Degradationist">>
		Their personal slaves were all Fuckdolls, slaves who have been permanently encased in advanced latex suits and converted into living sex toys. Several of them are still here.
	<<case "AssetExpansionist">>
		They kept a collection of bejeweled boobs for company, but they focused on breast expansion to the exclusion the slaves' emotional training. Several of them are still here.
	<<case "SlimnessEnthusiast">>
		They kept a harem of slim, pretty girls, and treated them very well. Several of them are still here. They should be very trusting of a new owner.
	<<case "TransformationFetishist">>
		They were just putting the finishing touches on a planned brothel's worth of surgically enhanced whores. Several of them are still here. They are already used to prostitution.
	<<case "BodyPurist">>
		Their slaves were trained for sexual use, but their health, fitness, and natural appearance were the main priorities. Several of them are still here.
	<<case "MaturityPreferentialist">>
		They preferred to keep their MILFs as scantily clad servants. Several of them are still here. They aren't all happy to be sex objects, but they're used to it.
	<<case "YouthPreferentialist">>
		They treated their young slaves very well. Several of them are still here. Virgins have been carefully preserved, but have learned to use their mouths through experience.
	<<case "Pastoralist">>
		Their herd of cow girls was progressing nicely, though more progress had been made on milk production than on training. Several of them are still here.
	<<case "PhysicalIdealist">>
		Their slaves worked as prostitutes, but mostly to fund a program of muscle building for all of them, which was nearing completion. Several of them are still here.
	<<case "ChattelReligionist">>
		They were recruiting a stable of slave whores by targeting people with religious complexes that made them particularly vulnerable to recruitment. Several of them are still here.
	<<case "RomanRevivalist">>
		The only one of their slaves left is the bodyguard. She should be very willing to transfer her loyalty to you, as her new owner.
	<<case "AztecRevivalist">>
		They maintained a combination of disobedient slaves, deemed incorrigible and blood priestesses. Since they offer themselves as slaves willingly, one has remained loyal to the owner of the arcology.
	<<case "EgyptianRevivalist">>
		They kept a harem of beautiful slave girls, who have been well-treated and well-trained. They should be very willing to serve you in turn.
	<<case "EdoRevivalist">>
		They put considerable effort into creating modern slave geisha, elegant Japanese slaves who were assigned to serve the public. Several of them are still here.
	<<case "ArabianRevivalist">>
		They trained slaves personally, and never kept slaves for very long. The slaves they left are all partway through being trained.
	<<case "ChineseRevivalist">>
		The only one of their slaves left is the Head Girl. She should be willing to transfer her loyalty to you, as her proper superior.
	<<case "Eugenics">>
		The only one of their slaves left is an absolute beauty of a girl. She is too smart for her own good and will likely not trust you.
	<<case "Repopulationist">>
		They kept a personal stable of slaves for breeding purposes. Several of them are still here. They've been kept heavily pregnant, and are used to being used whilst so.
	<<case "HedonisticDecadence">>
		Their slaves were heavily pampered; free to lie about, fuck, and eat as much as they wanted. Several of them are still here, too lazy and spoiled to leave. They eagerly paw at you upon your arrival, begging for their bellies to be filled with food and for a good, hard fucking.
	<<default>>
		ERROR: bad arcology type
	<</switch>>
<<else>>
	They could not get all of their personal effects away. Since they <<if $targetArcology.type == "Multiculturalist">>tried to sample different kinds of sexual slavery<<else>>did not have the time in control of the arcology to develop a specific stable of sex slaves<</if>>, their slaves were quite varied.
<</if>>

<<set $heroSlaves = $heroSlaves.shuffle()>>
<<set _valueGiven = 0>>
<<if $cheatMode == 1>>
	<<include [[Cheatmode Database]]>>
<<elseif $saveImported == 1>>
<<elseif ($targetArcology.type != "New") && ($targetArcology.type != "Multiculturalist")>>
	<<for $j = 0; $j < 5; $j++>>
	<<if _valueOwed - _valueGiven <= 5000>><<break>><</if>>
	<<switch $targetArcology.type>>
	<<case "Supremacist">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $fixedRace = $arcologies[0].FSSupremacistRace>><<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(-25,-45), $activeSlave.health = random(0,15)>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.skill.oral = random(15,35), $activeSlave.skill.anal = random(15,35)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.skill.vaginal = random(15,35)>>
		<</if>>
		<<set $activeSlave.skill.entertainment = random(15,35)>>
		<<set $activeSlave.clothes = "uncomfortable straps", $activeSlave.collar = "uncomfortable leather", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "please you">>
	<<case "Subjugationist">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $fixedRace = $arcologies[0].FSSubjugationistRace>><<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(-25,-45), $activeSlave.health = random(0,15)>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.skill.oral = random(15,35), $activeSlave.skill.anal = random(15,35)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.skill.vaginal = random(15,35)>>
		<</if>>
		<<set $activeSlave.skill.whoring = random(15,35)>>
		<<set $activeSlave.clothes = "uncomfortable straps", $activeSlave.collar = "uncomfortable leather", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "whore">>
	<<case "GenderRadicalist">>
		<<set $activeSlaveOneTimeMaxAge = 25>>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave("XY")>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(15,-15), $activeSlave.health = 100>>
		<<set $activeSlave.face = random(0,55)>>
		<<set $activeSlave.boobs += 100*random(2,4)>>
		<<set $activeSlave.butt += random(1,2)>>
		<<set $activeSlave.attrXY = random(70,90), $activeSlave.attrXX = 0>>
		<<set $activeSlave.skill.oral = random(35,65), $activeSlave.skill.anal = random(35,65), $activeSlave.skill.whoring = random(35,65)>>
		<<run SoftenSexualFlaw($activeSlave)>>
		<<set $activeSlave.clothes = "uncomfortable straps", $activeSlave.collar = "stylish leather", $activeSlave.shoes = "heels">>
		<<set $activeSlave.assignment = "whore">>
	<<case "GenderFundamentalist">>
		<<set $activeSlaveOneTimeMinAge = $fertilityAge>>
		<<set $activeSlaveOneTimeMaxAge = 25>>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave("XX")>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(-25,-45), $activeSlave.health = random(55,65)>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.preg = random(1,40), $activeSlave.lactation = 1, $activeSlave.lactationDuration = 2>>
		<<run SetBellySize($activeSlave)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.skill.vaginal = random(15,35)>>
		<</if>>
		<<set $activeSlave.clothes = "a nice maid outfit", $activeSlave.collar = "tight steel", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "be a servant">>
	<<case "Paternalist">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(55,65), $activeSlave.health = random(55,65)>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.intelligence = random(0,100), $activeSlave.intelligenceImplant = 30>>
		<<set $activeSlave.skill.entertainment = random(15,35)>>
		<<set $activeSlave.clothes = "conservative clothing", $activeSlave.collar = "none", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "be a servant">>
	<<case "Degradationist">>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = 25, $activeSlave.trust = -25, $activeSlave.health = random(0,15)>>
		<<set $activeSlave.fuckdoll = 100>>
		<<set $activeSlave.career = "a Fuckdoll">>
		<<set $activeSlave.fetish = "mindbroken">>
		<<set $activeSlave.boobs += 100*random(10,20)>>
		<<set $activeSlave.butt += random(2,3)>>
		<<set $activeSlave.lips = random(2,4)>>
		<<set $activeSlave.weight = random(-15,15)>>
		<<set $activeSlave.skill.oral = 0, $activeSlave.skill.anal = 0, $activeSlave.skill.vaginal = 0, $activeSlave.skill.entertainment = 0, $activeSlave.skill.whoring = 0>>
		<<set $activeSlave.behavioralFlaw = "none", $activeSlave.sexualFlaw = "none">>
		<<set $activeSlave.clothes = "a Fuckdoll suit">>
		<<set $activeSlave.assignment = "please you">>
	<<case "AssetExpansionist">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(-15,15), $activeSlave.health = random(25,45)>>
		<<set $activeSlave.chem = 50>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.boobs += 100*random(10,20)>>
		<<set $activeSlave.butt += random(2,3)>>
		<<set $activeSlave.lips += random(0,1)>>
		<<if $activeSlave.balls > 0>><<set $activeSlave.balls++>><</if>>
		<<if $activeSlave.dick > 0>><<set $activeSlave.dick++>><</if>>
		<<set $activeSlave.weight = random(15,90)>>
		<<set $activeSlave.skill.oral = random(15,35), $activeSlave.skill.anal = 0, $activeSlave.anus = 0>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.skill.vaginal = random(15,35)>>
		<</if>>
		<<set $activeSlave.skill.entertainment = random(15,35)>>
		<<set $activeSlave.clothes = "slutty jewelry", $activeSlave.collar = "pretty jewelry", $activeSlave.shoes = "heels">>
		<<set $activeSlave.assignment = "please you">>
	<<case "SlimnessEnthusiast">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(55,65), $activeSlave.health = random(55,65)>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.boobs = 100*random(1,4)>>
		<<set $activeSlave.butt = random(1,2)>>
		<<set $activeSlave.weight = random(-25,-15)>>
		<<set $activeSlave.skill.oral = random(15,35), $activeSlave.skill.anal = 0, $activeSlave.anus = 0>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.skill.vaginal = random(15,35)>>
		<</if>>
		<<set $activeSlave.skill.entertainment = random(15,35)>>
		<<set $activeSlave.clothes = "a leotard", $activeSlave.collar = "pretty jewelry", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "please you">>
	<<case "TransformationFetishist">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(-15,15), $activeSlave.health = random(-15,0)>>
		<<set $activeSlave.faceImplant = random(40,70)>>
		<<set $activeSlave.face = Math.trunc($activeSlave.face+$activeSlave.faceImplant/2,-100,100)>>
		<<set $activeSlave.boobsImplant = 200*random(4,8)>>
		<<set $activeSlave.boobs += $activeSlave.boobsImplant>>
		<<set $activeSlave.buttImplant = random(2,4)>>
		<<set $activeSlave.butt += $activeSlave.buttImplant>>
		<<set $activeSlave.lipsImplant = random(1,2)>>
		<<set $activeSlave.lips = Math.trunc($activeSlave.lipsImplant+2,-3,3)>>
		<<set $activeSlave.weight = random(-25,-15)>>
		<<set $activeSlave.skill.oral = random(15,35), $activeSlave.skill.anal = random(15,35)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.skill.vaginal = random(15,35)>>
		<</if>>
		<<set $activeSlave.clothes = "a string bikini", $activeSlave.collar = "shock punishment", $activeSlave.shoes = "extreme heels">>
		<<set $activeSlave.assignment = "whore">>
	<<case "BodyPurist">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(55,65), $activeSlave.trust = random(25,45), $activeSlave.health = 100>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.weight = random(-5,5)>>
		<<set $activeSlave.muscles = random(10,25)>>
		<<set $activeSlave.skill.oral = random(15,35), $activeSlave.skill.anal = random(15,35)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.skill.vaginal = random(15,35)>>
		<</if>>
		<<set $activeSlave.clothes = "a nice maid outfit", $activeSlave.collar = "pretty jewelry", $activeSlave.shoes = "heels">>
		<<set $activeSlave.assignment = "be a servant">>
	<<case "MaturityPreferentialist">>
		<<set $activeSlaveOneTimeMinAge = 36>>
		<<set $activeSlaveOneTimeMaxAge = 39>>
		<<set $one_time_age_overrides_pedo_mode = 1>>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(55,65), $activeSlave.trust = random(-15,15), $activeSlave.health = random(25,45)>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.boobs += 100*random(1,4)>>
		<<set $activeSlave.butt += random(1,2)>>
		<<set $activeSlave.weight = random(-5,90)>>
		<<set $activeSlave.skill.oral = random(15,35), $activeSlave.skill.anal = random(15,35)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.skill.vaginal = random(15,35)>>
		<</if>>
		<<run SoftenBehavioralFlaw($activeSlave)>>
		<<set $activeSlave.clothes = "a slutty maid outfit", $activeSlave.collar = "pretty jewelry", $activeSlave.shoes = "heels">>
		<<set $activeSlave.assignment = "be a servant">>
	<<case "YouthPreferentialist">>
		<<set $activeSlaveOneTimeMaxAge = 19>>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(55,65), $activeSlave.health = random(25,45)>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.boobs = 100*random(1,4)>>
		<<set $activeSlave.butt = random(1,3)>>
		<<set $activeSlave.weight = random(-25,25)>>
		<<set $activeSlave.skill.oral = random(15,35), $activeSlave.skill.anal = 0, $activeSlave.anus = 0>>
		<<if $activeSlave.vagina > -1>><<set $activeSlave.skill.vaginal = 0, $activeSlave.vagina = 0>><</if>>
		<<set $activeSlave.skill.entertainment = random(15,35)>>
		<<set $activeSlave.clothes = "a schoolgirl outfit", $activeSlave.collar = "pretty jewelry", $activeSlave.shoes = "heels">>
		<<set $activeSlave.assignment = "be a servant">>
	<<case "Pastoralist">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(-25,-45), $activeSlave.health = random(25,45)>>
		<<set $activeSlave.boobs += 100*random(10,20)>>
		<<if $activeSlave.balls > 0>><<set $activeSlave.balls++>><</if>>
		<<set $activeSlave.lactation = 2, $activeSlave.lactationDuration = 2>>
		<<set $activeSlave.clothes = "Western clothing", $activeSlave.collar = "leather with cowbell", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "get milked">>
	<<case "PhysicalIdealist">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(25,45), $activeSlave.health = 100>>
		<<set $activeSlave.muscles = random(50,100)>>
		<<set $activeSlave.skill.oral = random(15,35), $activeSlave.skill.anal = random(15,35)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.skill.vaginal = random(15,35)>>
		<</if>>
		<<set $activeSlave.skill.whoring = random(15,35)>>
		<<set $activeSlave.clothes = "body oil", $activeSlave.collar = "none", $activeSlave.shoes = "none">>
		<<set $activeSlave.assignment = "whore">>
	<<case "ChattelReligionist">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(55,65), $activeSlave.trust = random(55,65), $activeSlave.health = random(0,15)>>
		<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
		<<set $activeSlave.skill.whoring = random(10,20)>>
		<<set $activeSlave.behavioralFlaw = "none", $activeSlave.behavioralQuirk = "sinful">>
		<<set $activeSlave.clothes = "a chattel habit", $activeSlave.collar = "heavy gold", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "whore">>
	<<case "RomanRevivalist">>
		<<set $activeSlaveOneTimeMaxAge = 19>>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = 100, $activeSlave.trust = random(55,65), $activeSlave.health = 100>>
		<<set $activeSlave.face = random(0,55)>>
		<<set $activeSlave.muscles = random(25,50)>>
		<<set $activeSlave.skill.combat = 1>>
		<<set $activeSlave.behavioralFlaw = "none", $activeSlave.behavioralQuirk = "fitness">>
		<<set $activeSlave.behavioralFlaw = "none">>
		<<set $activeSlave.clothes = "a toga", $activeSlave.collar = "pretty jewelry", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "guard you", $Bodyguard = $activeSlave>>
	<<case "AztecRevivalist">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $fixedRace = "latina">>
		<<set $fixedNationality = "Mexican">>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.accent = 0>>
		<<set $activeSlave.devotion = 75, $activeSlave.trust = 75, $activeSlave.health = random(-20,20)>>
		<<set $activeSlave.muscles = random(50,75)>>
		<<set $activeSlave.skill.combat = 1>>
		<<set $activeSlave.behavioralFlaw = "malicious", $activeSlave.behavioralQuirk = "none">>
		<<set $activeSlave.clothes = "a huipil", $activeSlave.collar = "pretty jewelry", $activeSlave.shoes = "none">>
		<<set $activeSlave.assignment = "be your Head Girl", $HeadGirl = $activeSlave>>
	<<case "EgyptianRevivalist">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(25,45), $activeSlave.health = random(25,45)>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.skill.oral = random(15,35), $activeSlave.skill.anal = random(15,35)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.skill.vaginal = random(15,35)>>
		<</if>>
		<<set $activeSlave.skill.entertainment = random(15,35)>>
		<<run SoftenSexualFlaw($activeSlave)>>
		<<set $activeSlave.clothes = "slutty jewelry", $activeSlave.collar = "ancient Egyptian", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "please you">>
	<<case "EdoRevivalist">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $fixedRace = "asian">>
		<<set $fixedNationality = "Japanese">>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.accent = 0>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(25,45), $activeSlave.health = random(25,45)>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.intelligence = random(0,100), $activeSlave.intelligenceImplant = 30>>
		<<set $activeSlave.skill.entertainment = 100>>
		<<set $activeSlave.clothes = "a kimono", $activeSlave.collar = "satin choker", $activeSlave.shoes = "heels">>
		<<set $activeSlave.assignment = "serve the public">>
	<<case "ArabianRevivalist">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(-15,15), $activeSlave.health = random(25,45)>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.intelligence = random(-15,80), $activeSlave.intelligenceImplant = 0>>
		<<set $activeSlave.clothes = "harem gauze", $activeSlave.collar = "uncomfortable leather", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "take classes">>
	<<case "ChineseRevivalist">>
		<<set $activeSlaveOneTimeMinAge = 36>>
		<<set $activeSlaveOneTimeMaxAge = 38>>
		<<set $one_time_age_overrides_pedo_mode = 1>>
		<<set $oneTimeDisableDisability = 1>>
		<<set $fixedRace = "asian">>
		<<set $fixedNationality = "Chinese">>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = random(55,65), $activeSlave.trust = random(25,45), $activeSlave.health = random(25,45)>>
		<<set $activeSlave.face = random(0,55)>>
		<<set $activeSlave.accent = 0>>
		<<set $activeSlave.intelligence = 100, $activeSlave.intelligenceImplant = 30>>
		<<set $activeSlave.skill.oral = 100, $activeSlave.skill.anal = 100>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.skill.vaginal = 100>>
		<</if>>
		<<set $activeSlave.skill.entertainment = 100, $activeSlave.skill.whoring = 100>>
		<<run SoftenBehavioralFlaw($activeSlave)>>
		<<run SoftenSexualFlaw($activeSlave)>>
		<<set $activeSlave.clothes = "a slutty qipao", $activeSlave.collar = "pretty jewelry", $activeSlave.shoes = "heels">>
		<<set $activeSlave.assignment = "be your Head Girl", $HeadGirl = $activeSlave>>
	<<case "Eugenics">>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave()>>
		<<set $activeSlave.devotion = -100, $activeSlave.trust = -100, $activeSlave.health = random(80,90)>>
		<<set $activeSlave.intelligence = 100>>
		<<set $activeSlave.intelligenceImplant = 30>>
		<<set $activeSlave.face = 100>>
		<<set $activeSlave.faceShape = "sensual">>
		<<set $activeSlave.skill.oral = random(35,75), $activeSlave.skill.anal = random(35,75)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.skill.vaginal = random(35,75)>>
		<</if>>
		<<set $activeSlave.skill.entertainment = random(15,35)>>
		<<set $activeSlave.skill.whoring = 0>>
		<<run SoftenSexualFlaw($activeSlave)>>
		<<set $activeSlave.clothes = "a ball gown", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "rest">>
	<<case "Repopulationist">>
		<<set $activeSlaveOneTimeMinAge = $fertilityAge+3>>
		<<set $activeSlaveOneTimeMaxAge = 25>>
		<<set $one_time_age_overrides_pedo_mode = 1>>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave("XX")>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(-25,-45), $activeSlave.health = random(55,65)>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.preg = random(10,40), $activeSlave.pregType = random(3,8), $activeSlave.lactation = 1, $activeSlave.lactationDuration = 2>>
		<<run SetBellySize($activeSlave)>>
		<<set $activeSlave.counter.birthsTotal = 5>>
		<<set $activeSlave.bellySag = 20, $activeSlave.bellySagPreg = 20>>
		<<if $activeSlave.vagina > -1>>
			<<set $activeSlave.vagina = 4>>
			<<set $activeSlave.skill.vaginal = random(15,35)>>
		<</if>>
		<<set $activeSlave.clothes = "a nice maid outfit", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "please you">>
	<<case "HedonisticDecadence">>
		<<set $activeSlaveOneTimeMaxAge = 25>>
		<<set $oneTimeDisableDisability = 1>>
		<<set $activeSlave = GenerateNewSlave("XX")>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(-25,-45), $activeSlave.health = random(-20,20)>>
		<<set $activeSlave.face = random(15,40)>>
		<<set $activeSlave.boobs += 100*random(3,6)>>
		<<set $activeSlave.butt += random(2,5)>>
		<<set $activeSlave.weight = random(100,200)>>
		<<set $activeSlave.skill.oral = random(15,35), $activeSlave.skill.anal = random(15,35), $activeSlave.anus = 2>>
		<<if $activeSlave.vagina > -1>><<set $activeSlave.skill.vaginal = random(15,35), $activeSlave.vagina = 3>><</if>>
		<<set $activeSlave.skill.entertainment = 0>>
		<<set $activeSlave.energy = random(60,80)>>
		<<set $activeSlave.behavioralFlaw = "gluttonous">>
		<<set $activeSlave.clothes = "attractive lingerie", $activeSlave.shoes = "flats">>
		<<set $activeSlave.diet = "fattening">>
		<<set $activeSlave.livingRules = "luxurious">>
		<<set $activeSlave.assignment = "rest">>
	<<default>>
		ERROR: bad arcology type
	<</switch>>
	<<set $activeSlave.origin = "You acquired her along with the arcology.", $activeSlave.career = "a slave">>
	<<set $slaveCost = slaveCost($activeSlave)>>
	<<if ["AztecRevivalist", "ChineseRevivalist", "Eugenics"].includes($targetArcology.type)>>
		<<set _valueGiven += $slaveCost*4>>
	<<else>>
		<<set _valueGiven += $slaveCost>>
	<</if>>
	<<run newSlave($activeSlave)>>
	<</for>>
<<else>>
	<<for $j = 0; $j < $heroSlaves.length; $j++>>
	<<if _valueOwed - _valueGiven <= 5000>>
		<<break>>
	<</if>>
	<<set $activeSlave = App.Utils.getHeroSlave($heroSlaves[$j], $baseHeroSlave)>>
	<<run $heroSlaves.splice($j,1)>>
	<<set $slaveCost = slaveCost($activeSlave)>>
	<<if _valueGiven + $slaveCost < _valueOwed*2>>
		<<run nationalityToAccent($activeSlave)>>
		<<set $activeSlave.oldDevotion = $activeSlave.devotion>>
		<<set $activeSlave.oldTrust = $activeSlave.trust>>
		<<set _valueGiven += $slaveCost>>
		<<run newSlave($activeSlave)>>
		<<setLocalPronouns $activeSlave>>
		<<if $activeSlave.fetish == "mindbroken">>
			$activeSlave.slaveName is, sadly, not mentally competent, and is wandering through the penthouse at the moment.
		<<elseif $activeSlave.amp == 1>>
			$activeSlave.slaveName is a quadruple amputee and is quite helpless, so you can attend to $him at your leisure.
		<<elseif $activeSlave.devotion < -50>>
			$activeSlave.slaveName is quite rebellious and was attempting to escape, so I have locked $him in the slave quarters.
		<<elseif $activeSlave.devotion < -20>>
			$activeSlave.slaveName resists my orders and was considering escape, so I have locked $him in the slave quarters.
		<<elseif $activeSlave.devotion <= 20>>
			$activeSlave.slaveName is reasonably obedient, and is waiting for you in the dormitory, I believe in the hope of making a good impression.
		<<elseif $activeSlave.energy > 95>>
			$activeSlave.slaveName is a remarkable sexual addict, and I believe $he will be very happy to meet you.
		<<elseif $activeSlave.fetish == "pregnancy">>
			<<if $activeSlave.bellyPreg >= 500>>
				$activeSlave.slaveName is currently in the dormitory masturbating over $his growing pregnancy, and <<if $PC.belly >= 5000>>will certainly be eager to meet you<<else>>I believe $he will be happy to show it to you<</if>>.
			<<else>>
				$activeSlave.slaveName is currently in the dormitory examining $himself to try to discern $his fertility, and I believe $he will be <<if $PC.belly >= 5000>>eager to get acquainted with you<<else>>happy to meet you<</if>>.
			<</if>>
		<<elseif $activeSlave.belly >= 5000>> /*had to be placed after pregnancy or it would intercept*/
			$activeSlave.slaveName is currently in the dormitory massaging $his greatly distended belly.
		<<elseif $activeSlave.fetish == "buttslut">>
			$activeSlave.slaveName is currently in the dormitory masturbating anally, and I believe $he will be happy to meet you.
		<<elseif $activeSlave.fetish == "cumslut">>
			$activeSlave.slaveName is currently in the dormitory exhibiting oral fixation, and I believe $he will be happy to meet you.
		<<elseif $activeSlave.fetish == "boobs">>
			$activeSlave.slaveName is currently in the dormitory playing with $his nipples, and I believe $he will be happy to meet you.
		<<elseif $activeSlave.fetish == "humiliation">>
			$activeSlave.slaveName is currently in the entryway flashing passersby, and I believe $he will be happy to meet you.
		<<elseif $activeSlave.fetish == "submissive">>
			$activeSlave.slaveName is currently in the dormitory, experimenting with self-bondage using the sheets; I believe $he will be happy to meet you.
		<<elseif $activeSlave.fetish == "dom">>
			$activeSlave.slaveName is currently in the exercise area keeping fit; $he likes to take an active role sexually and is using this down time to work out.
		<<elseif $activeSlave.fetish == "sadist">>
			$activeSlave.slaveName is currently outside your office; $he enjoys being superior to other slaves and I believe $he means to ingratiate $himself to you.
		<<elseif $activeSlave.fetish == "masochist">>
			$activeSlave.slaveName is a sexual masochist; $he is currently in the bathroom, experimenting with auto-flagellation with a wet towel.
		<<else>>
			$activeSlave.slaveName is currently outside your office, and I believe $he is attempting to maintain sexual arousal to make a good first impression on you.
		<</if>>
	<</if>>
	<</for>>
<</if>>
<<if _valueOwed-_valueGiven > 0>>
	There are some valuables present, worth <<print cashFormat(_valueOwed-_valueGiven)>>.
	<<run cashX((_valueOwed-_valueGiven), "event", $activeSlave)>>
<</if>>
//

/* RELATIONSHIP MUTUALITY CHECK, OLDMENTAL */

<<set $averageTrust = 0>>
<<set $averageDevotion = 0>>
<<set _slavesContributing = 0>>
<<for $i = 0; $i < $slaves.length; $i++>>
	<<if $slaves[$i].relation != 0>>
		<<set $seed = $slaveIndices[$slaves[$i].relationTarget]>>
		<<if (def $seed && $slaves[$seed].relationTarget != $slaves[$i].ID) || (ndef $seed)>>
			<<set $slaves[$i].relation = 0>>
			<<set $slaves[$i].relationTarget = 0>>
			<<goto "Acquisition">>
		<</if>>
	<</if>>
	<<set $slaves[$i].oldDevotion = $slaves[$i].devotion>>
	<<set $slaves[$i].oldTrust = $slaves[$i].trust>>
	/* AVERAGE VALUES UPDATE */
	<<if $slaves[$i].assignmentVisible == 1>>
		<<set $averageTrust += $slaves[$i].trust, $averageDevotion += $slaves[$i].devotion, _slavesContributing += 1>>
	<<else>>
		<<if $slaves[$i].assignment != "be confined in the cellblock">>
		<<if $slaves[$i].assignment != "be confined in the arcade">>
		<<if ($slaves[$i].assignment != "work in the dairy") || ($dairyRestraintsSetting < 2)>>
			<<set $averageTrust += $slaves[$i].trust*0.5, $averageDevotion += $slaves[$i].devotion*0.5, _slavesContributing += 0.5>>
		<</if>>
		<</if>>
		<</if>>
	<</if>>
<</for>>
<<if $familyTesting == 1>>
	<<set $slaves.forEach(function(s) { s.sisters = 0; s.daughters = 0; })>>
	<<set $PC.daughters = 0, $PC.sisters = 0>>
	<<for _fp = 0; _fp < $slaves.length; _fp++>>
		<<if ($slaves[_fp].mother == -1 || $slaves[_fp].father == -1)>>
			<<set $PC.daughters++>>
		<</if>>
		<<if areSisters($slaves[_fp], $PC) > 0>>
			<<set $PC.sisters++>>
		<</if>>
		<<for _fpt = 0; _fpt < $slaves.length; _fpt++>>
			<<if ($slaves[_fpt].mother == $slaves[_fp].ID) || ($slaves[_fpt].father == $slaves[_fp].ID)>>
				<<set $slaves[_fp].daughters++>>
			<</if>>
			<<if areSisters($slaves[_fpt], $slaves[_fp]) > 0>>
				<<set $slaves[_fp].sisters++>>
			<</if>>
		<</for>>
	<</for>>
<</if>>
<<if _slavesContributing != 0>>
	<<set $averageTrust = $averageTrust/_slavesContributing>>
	<<set $averageDevotion = $averageDevotion/_slavesContributing>>
<</if>>
<<set $enduringTrust = $averageTrust>>
<<set $enduringDevotion = $averageDevotion>>

<<link "Continue">>
	<<set $ui = "main">>
	<<if $terrain == "urban">>
		<<set $minimumSlaveCost = 2000>>
		<<set $slaveCostFactor = 0.85>>
		<<set $menialSupplyFactor = 30000>>
		<<set $menialDemandFactor = -30000>>
	<<elseif $terrain == "marine">>
		<<set $minimumSlaveCost = 2500>>
		<<set $slaveCostFactor = 1>>
	<<else>>
		<<set $minimumSlaveCost = 3000>>
		<<set $slaveCostFactor = 1.15>>
		<<set $menialDemandFactor = 30000>>
		<<set $menialSupplyFactor = -30000>>
	<</if>>
	<>
	<<goto "Main">>
<</link>>


code:
:: Agent Company [nobr]

<<set $nextButton = "Continue", $nextLink = "AS Dump", $returnTo = "Neighbor Interact", _ID = $activeSlave.ID>>

<<= assignJob($activeSlave, "live with your agent")>>

<<set $reservedChildren = FetusGlobalReserveCount("incubator")>>
<<set $reservedChildrenNursery = FetusGlobalReserveCount("nursery")>>

<<if $activeSlave.rivalry > 0>>
	<<set _i = $slaveIndices[$activeSlave.rivalryTarget]>>
	<<if def _i>>
		<<set $slaves[_i].rivalry = 0, $slaves[_i].rivalryTarget = 0>>
	<<else>>
		@@.red;Error, activeSlave rival not found.@@
	<</if>>
	<<set $activeSlave.rivalry = 0, $activeSlave.rivalryTarget = 0>>
<</if>>

<<for _i = 0; _i < $arcologies.length; _i++>>
	<<if $subSlave.ID == $arcologies[_i].leaderID>>
		<<set $activeArcology = $arcologies[_i]>>
	<</if>>
<</for>>

<<setLocalPronouns $subSlave 2>>

Working in $activeArcology.name's penthouse office, $subSlave.slaveName gets a video call from you. Naturally, _his2 personal assistant program has been instructed to give these the highest priority, and your face appears in front of _him2 immediately. _He2 greets you properly, and asks you what _he2 can do to serve you. You tell _him2 you're planning to send one of your slaves over to _his2 arcology to assist _him2. Exchanges of this kind are neither unusual nor particularly interesting, so a slight look of perplexity clouds $subSlave.slaveName's face as _he2 wonders why this merits a personal call. Normally, <<if $HeadGirl != 0>>$HeadGirl.slaveName<<else>>$assistantName<</if>> would handle it with _him2 directly.

_His2 question is answered when you bring $activeSlave.slaveName in close, putting $him in $subSlave.slaveName's view. $subSlave.slaveName's <<= App.Desc.eyeColor($subSlave)>> eyes fly open with pleased surprise, but before _he2 can speak, $activeSlave.slaveName goes first.
<<if !canTalk($activeSlave)>>
	Unable to speak $himself, $he simply makes a heart shape with $his hands in view of the video call, and blows $his <<if $activeSlave.relationship == 4>>lover<<else>>wife<</if>> a kiss.
<<else>>
	<<run Enunciate($activeSlave)>>
	"Hi <<if $activeSlave.relationship == 4>>lover<<else>><<s>>weetheart<</if>>," $he <<say>>s in a syrupy tone. "Mi<<ss>> me?"
<</if>>

$subSlave.slaveName smiles back at $him, glowing with pleasure, and responds with exaggerated arousal.

<<run Enunciate($subSlave)>>

<<switch $subSlave.fetish>>
<<case "submissive">>
	"Looking forward to <<s>>leeping in your arm<<s>>, babe," the submissive
<<case "cumslut">>
	"Can't wait to ki<<ss>> you, babe," the orally fixated
<<case "humiliation">>
	"Can't wait to take you right in the middle of the pla<<z>>a here," the exhibitionist
<<case "buttslut">>
	"I can't wait to fuck you in your hot little a<<ss>>," the anally fixated
<<case "boobs">>
	"Looking forward to feeling your brea<<s>>t<<s>> again," the boob-loving
<<case "pregnancy">>
	"Can't wait to <<sh>>are all the pregnant girl<<s>> here with you," the impregnation fetishist
<<case "dom">>
	"Looking forward to <<sh>>oving you fa<<c>>edown, bitch," the dominant
<<case "sadist">>
	"Looking forward to making you bite the pillow again, bitch," the sadistic
<<case "masochist">>
	"Can't wait to feel you hurt me again, babe," the masochistic
<<default>>
	"Babe, I can't wait to give you a hug and tell you about $activeArcology.name," the loving
<</switch>>
leader of an entire arcology <<say>>s.


code:
App.Data.Facilities.arcologyAgent = {
	baseName: "arcology",
	genericName: null,
	jobs: {
		agentsSlave: {
			position: "agent's toy",
			assignment: "live with your agent",
			publicSexUse: true,
			fuckdollAccepted: false
		}
	},
	defaultJob: "agentsSlave",
	manager: {
		position: "agent",
		assignment: "be your agent",
		careers: "an arcology owner",
		skill: "headGirl",
		publicSexUse: true,
		fuckdollAccepted: false,
		broodmotherAccepted: false,
		shouldWalk: true,
		shouldSee: true,
		shouldHear: true,
		shouldTalk: true,
		shouldThink: true,
		requiredDevotion: 21
	}
};

App.Entity.Facilities.AgentJob = class extends App.Entity.Facilities.ManagingJob {
	/**
	* @param {App.Entity.SlaveState} slave
	* @returns {string[]}
	*/
	canEmploy(slave) {
		let r = super.canEmploy(slave);
		if (slave.intelligence + slave.intelligenceImplant <= 15) {
			r.push(`${slave.slaveName} is not intelligent enough to be your agent.`);
		}
		return r;
	}
};

App.Entity.facilities.arcologyAgent = new App.Entity.Facilities.Facility(
	App.Data.Facilities.arcologyAgent,
	new App.Entity.Facilities.AgentJob()
);


code:
:: Agent Retrieve [silently]

<<set _ID = $activeArcology.leaderID>>

<<set _i = $slaveIndices[_ID]>>
<<if def _i>>
	<<= removeJob($slaves[_i], "be your agent")>>
<</if>>

<<set $activeArcology.leaderID = 0, $activeArcology.government = "your trustees">>

<<goto "Neighbor Interact">>


code:
:: Agent Select [nobr]

<<set $nextButton = "Back", $nextLink = "Neighbor Interact", $showEncyclopedia = 1, $encyclopedia = "Agents">>
''Appoint an Agent from your devoted slaves:''

<<= App.UI.SlaveList.slaveSelectionList(
		s => (s.fuckdoll === 0 && s.devotion > 20 && s.intelligence + s.intelligenceImplant > 15 && s.intelligenceImplant >= 15 && canWalk(s) && canSee(s) && canHear(s) && canTalk(s) && s.broodmother < 2 && (s.breedingMark !== 1 || State.variables.propOutcome === 0)),
		(slave, index) => App.UI.passageLink(SlaveFullName(slave), 'Agent Workaround', `$i = ${index}`),
		s => App.Entity.facilities.arcologyAgent.manager.slaveHasExperience(s)
	)>>


code:
:: Agent Workaround [nobr]

<<set $nextButton = "Continue", $nextLink = "Neighbor Interact", _ID = $slaves[$i].ID>>

<<= assignJob($slaves[$i], "be your agent")>>

<<set $reservedChildren = FetusGlobalReserveCount("incubator")>>
<<set $reservedChildrenNursery = FetusGlobalReserveCount("nursery")>>

<<if $slaves[$i].rivalry > 0>>
	<<set _i = $slaveIndices[$slaves[$i].rivalryTarget]>>
	<<if def _i>>
		<<set $slaves[_i].rivalry = 0, $slaves[_i].rivalryTarget = 0>>
	<<else>>
		@@.red;Error, rival not found.@@
	<</if>>
	<<set $slaves[$i].rivalry = 0, $slaves[$i].rivalryTarget = 0>>
<</if>>

<<if $slaves[$i].relationship > 0 && $slaves[$i].relationship < 4>>
	<<set _i = $slaveIndices[$slaves[$i].relationshipTarget]>>
	<<if def _i>>
		<<set $slaves[_i].relationship = 0, $slaves[_i].relationshipTarget = 0>>
	<<else>>
		@@.red;Error, relationshipTarget not found.@@
	<</if>>
	<<set $slaves[$i].relationship = 0, $slaves[$i].relationshipTarget = 0>>
<</if>>

<<set $activeArcology.leaderID = _ID, $activeArcology.government = "your agent">>

<<set $desc = SlaveTitle($slaves[$i])>>
<<setLocalPronouns $slaves[$i]>>

You order $slaves[$i].slaveName to come into your office for orders. The devoted $desc has no prior warning that this is anything unusual, and from the <<if $slaves[$i].energy > 95>>horny glint<<else>>glow of sexual availability<</if>> in $his <<= App.Desc.eyeColor($slaves[$i])>> eyes as $he <<if canWalk($slaves[$i])>>enters<<else>>is helped in<</if>>, $he <<if $slaves[$i].energy > 95>>seems to be hoping<<else>>wouldn't mind hearing<</if>> that you've called $him in for a quick fuck. In fact, the matter at hand is about as far as it could possibly be from that, on the spectrum of interactions between <<= properMaster()>> and slave.

You offer $him, without preamble, agency on your behalf in $activeArcology.name. As a $woman of intelligence, $he knows the basics of such an arrangement, but $he's stunned into silence by the offer, so you outline it briefly. Having a slave lead an arcology would be too much, even for the most open minded of Free Cities societies. So, $he would be freed, albeit subject to a set of private, restrictive contracts that would allow you to recall $him if you wish, and require $him to follow your directions, if you give $him any. But other than that, $he would be the effective leader of an entire arcology. It's an unusual arrangement, but one that's becoming more common as multiple arcologies come under united control.

$He's intelligent and confident of $his place within society as a valued slave, and knows that with your resources behind $him, this is likely something $he's capable of succeeding at. Nevertheless, $his feelings are obviously mixed. It will be a challenge,
<<switch $slaves[$i].fetish>>
<<case "submissive">>
	especially for a sexual submissive like $him.
<<case "cumslut">>
	and $he'll have to find dominant ways to sate $his oral appetites.
<<case "humiliation">>
	especially for a humiliation addict like $him.
<<case "buttslut">>
	though $he'll probably be able to live $his anal life vicariously by buttfucking others.
<<case "boobs">>
	but $he'll have a practically infinite procession of breasts to judge and fondle.
<<case "pregnancy">>
	but the potential for impregnation of hundreds of slaves excites $him.
<<case "dom">>
	but the prospect of having more slaves at $his whim than even $he could possibly use is incredibly exciting to $him.
<<case "sadist">>
	but the prospect of having more slaves at $his whim than even $he could possibly break is incredibly exciting to $him.
<<case "masochist">>
	especially for a masochist like $him.
<<default>>
	though one $he's willing to take on.
<</switch>>
It will mean that $he'll see much less of you, something such a devoted slave may struggle with. Oppressed by the confusion and strength of $his feelings, $he begins to cry.

"Thank you, <<Master $slaves[$i]>>," $he gasps out. "I'll do my be<<s>>t."


code:
:: AS Dump

<<if (ndef $activeSlave) || ($activeSlave == 0)>>

	@@.red;ERROR:@@ AS Dump, activeSlave invalid, returnTo is '$returnTo', previous passage was '<<print previous()>>'. Please report this.

	<<link "Continue">><<goto $returnTo>><</link>> | [[Go Back|previous()]]

<<else>>

	<<silently>>

	<<set _SL = $slaves.length, _ID = $activeSlave.ID>>

	<<if $i >= 0 && $i < _SL && $slaves[$i].ID == _ID>> /* shortcut if $i is already pointing to this slave */
		<<set $slaves[$i] = $activeSlave>>
	<<else>>
		<<set $i = $slaveIndices[_ID]>> /* find $i if exists */
		<<if ndef $i>> /* not found, so new slave */
			<<run newSlave($activeSlave)>>
		<<else>>
			<<set $slaves[$i] = $activeSlave>>
		<</if>>
	<</if>>

	<<switch _ID>>
		<<case $HeadGirl.ID>><<set $HeadGirl = $activeSlave>>
		<<case $Recruiter.ID>><<set $Recruiter = $activeSlave>>
		<<case $Bodyguard.ID>><<set $Bodyguard = $activeSlave>>
		<<case $Madam.ID>><<set $Madam = $activeSlave>>
		<<case $DJ.ID>><<set $DJ = $activeSlave>>
		<<case $Milkmaid.ID>><<set $Milkmaid = $activeSlave>>
		<<case $Farmer.ID>><<set $Farmer = $activeSlave>>
		<<case $Schoolteacher.ID>><<set $Schoolteacher = $activeSlave>>
		<<case $Attendant.ID>><<set $Attendant = $activeSlave>>
		<<case $Matron.ID>><<set $Matron = $activeSlave>>
		<<case $Nurse.ID>><<set $Nurse = $activeSlave>>
		<<case $Stewardess.ID>><<set $Stewardess = $activeSlave>>
		<<case $Wardeness.ID>><<set $Wardeness = $activeSlave>>
		<<case $Concubine.ID>><<set $Concubine = $activeSlave>>
		<<case $Collectrix.ID>><<set $Collectrix = $activeSlave>>
		<<case $Matron.ID>><<set $Matron = $activeSlave>>
	<</switch>>

	<<run clearSummaryCache($activeSlave)>>

	<</silently>>

	<<goto $returnTo>>

<</if>>


code:
:: custom Slaves Database

<<set _i = 1000000>>