code:
:: StoryJS [script]

/*config.history.tracking = false;*/
window.variableAsNumber = function(x, defaultValue, minValue, maxValue) {
	x = Number(x)
	if (x != x) {//NaN
		return defaultValue || 0;//In case the default value was not supplied.
	}
	if (x < minValue) {//Works even if minValue is undefined.
		return minValue;
	}
	if (x > maxValue) {//Works even if maxValue is undefined.
		return maxValue;
	}
	return x;
};
window.isSexuallyPure = function(slave) {
	if (!slave) {
		return null;
	}
	if (slave.vagina < 1 && slave.anus < 1 && !slave.analCount && !slave.vaginalCount && !slave.oralCount) {
		return true;
	} else {
		return false;
	}
};
if (typeof interpolate == "undefined") {
	var interpolate = function(x0,y0,x1,y1,x) {
		if(x <= x0) {
			return y0;
		} else if(x >= x1) {
			return y1;
		} else {
			return (x - x0) * ((y1 - y0) / (x1 - x0)) + y0;
		}
	};
	window.interpolate = interpolate;
}
config.history.maxStates = 1;

config.saves.autosave = "autosave";
window.isFullyPotent = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.dick > 0 && slave.balls > 0 && slave.hormones <= 0) {
		return true;
	} else {
		return false;
	}
};

/* mousetrap v1.5.3 craig.is/killing/mice */
(function(C,r,g){function t(a,b,h){a.addEventListener?a.addEventListener(b,h,!1):a.attachEvent("on"+b,h)}function x(a){if("keypress"==a.type){var b=String.fromCharCode(a.which);a.shiftKey||(b=b.toLowerCase());return b}return l[a.which]?l[a.which]:p[a.which]?p[a.which]:String.fromCharCode(a.which).toLowerCase()}function D(a){var b=[];a.shiftKey&&b.push("shift");a.altKey&&b.push("alt");a.ctrlKey&&b.push("ctrl");a.metaKey&&b.push("meta");return b}function u(a){return"shift"==a||"ctrl"==a||"alt"==a||
"meta"==a}function y(a,b){var h,c,e,g=[];h=a;"+"===h?h=["+"]:(h=h.replace(/\+{2}/g,"+plus"),h=h.split("+"));for(e=0;e<h.length;++e)c=h[e],z[c]&&(c=z[c]),b&&"keypress"!=b&&A[c]&&(c=A[c],g.push("shift")),u(c)&&g.push(c);h=c;e=b;if(!e){if(!k){k={};for(var m in l)95<m&&112>m||l.hasOwnProperty(m)&&(k[l[m]]=m)}e=k[h]?"keydown":"keypress"}"keypress"==e&&g.length&&(e="keydown");return{key:c,modifiers:g,action:e}}function B(a,b){return null===a||a===r?!1:a===b?!0:B(a.parentNode,b)}function c(a){function b(a){a=
a||{};var b=!1,n;for(n in q)a[n]?b=!0:q[n]=0;b||(v=!1)}function h(a,b,n,f,c,h){var g,e,l=[],m=n.type;if(!d._callbacks[a])return[];"keyup"==m&&u(a)&&(b=[a]);for(g=0;g<d._callbacks[a].length;++g)if(e=d._callbacks[a][g],(f||!e.seq||q[e.seq]==e.level)&&m==e.action){var k;(k="keypress"==m&&!n.metaKey&&!n.ctrlKey)||(k=e.modifiers,k=b.sort().join(",")===k.sort().join(","));k&&(k=f&&e.seq==f&&e.level==h,(!f&&e.combo==c||k)&&d._callbacks[a].splice(g,1),l.push(e))}return l}function g(a,b,n,f){d.stopCallback(b,
b.target||b.srcElement,n,f)||!1!==a(b,n)||(b.preventDefault?b.preventDefault():b.returnValue=!1,b.stopPropagation?b.stopPropagation():b.cancelBubble=!0)}function e(a){"number"!==typeof a.which&&(a.which=a.keyCode);var b=x(a);b&&("keyup"==a.type&&w===b?w=!1:d.handleKey(b,D(a),a))}function l(a,c,n,f){function e(c){return function(){v=c;++q[a];clearTimeout(k);k=setTimeout(b,1E3)}}function h(c){g(n,c,a);"keyup"!==f&&(w=x(c));setTimeout(b,10)}for(var d=q[a]=0;d<c.length;++d){var p=d+1===c.length?h:e(f||
y(c[d+1]).action);m(c[d],p,f,a,d)}}function m(a,b,c,f,e){d._directMap[a+":"+c]=b;a=a.replace(/\s+/g," ");var g=a.split(" ");1<g.length?l(a,g,b,c):(c=y(a,c),d._callbacks[c.key]=d._callbacks[c.key]||[],h(c.key,c.modifiers,{type:c.action},f,a,e),d._callbacks[c.key][f?"unshift":"push"]({callback:b,modifiers:c.modifiers,action:c.action,seq:f,level:e,combo:a}))}var d=this;a=a||r;if(!(d instanceof c))return new c(a);d.target=a;d._callbacks={};d._directMap={};var q={},k,w=!1,p=!1,v=!1;d._handleKey=function(a,
c,e){var f=h(a,c,e),d;c={};var k=0,l=!1;for(d=0;d<f.length;++d)f[d].seq&&(k=Math.max(k,f[d].level));for(d=0;d<f.length;++d)f[d].seq?f[d].level==k&&(l=!0,c[f[d].seq]=1,g(f[d].callback,e,f[d].combo,f[d].seq)):l||g(f[d].callback,e,f[d].combo);f="keypress"==e.type&&p;e.type!=v||u(a)||f||b(c);p=l&&"keydown"==e.type};d._bindMultiple=function(a,b,c){for(var d=0;d<a.length;++d)m(a[d],b,c)};t(a,"keypress",e);t(a,"keydown",e);t(a,"keyup",e)}var l={8:"backspace",9:"tab",13:"enter",16:"shift",17:"ctrl",18:"alt",
20:"capslock",27:"esc",32:"space",33:"pageup",34:"pagedown",35:"end",36:"home",37:"left",38:"up",39:"right",40:"down",45:"ins",46:"del",91:"meta",93:"meta",224:"meta"},p={106:"*",107:"+",109:"-",110:".",111:"/",186:";",187:"=",188:",",189:"-",190:".",191:"/",192:"`",219:"[",220:"\\",221:"]",222:"'"},A={"~":"`","!":"1","@":"2","#":"3",$:"4","%":"5","^":"6","&":"7","*":"8","(":"9",")":"0",_:"-","+":"=",":":";",'"':"'","<":",",">":".","?":"/","|":"\\"},z={option:"alt",command:"meta","return":"enter",
escape:"esc",plus:"+",mod:/Mac|iPod|iPhone|iPad/.test(navigator.platform)?"meta":"ctrl"},k;for(g=1;20>g;++g)l[111+g]="f"+g;for(g=0;9>=g;++g)l[g+96]=g;c.prototype.bind=function(a,b,c){a=a instanceof Array?a:[a];this._bindMultiple.call(this,a,b,c);return this};c.prototype.unbind=function(a,b){return this.bind.call(this,a,function(){},b)};c.prototype.trigger=function(a,b){if(this._directMap[a+":"+b])this._directMap[a+":"+b]({},a);return this};c.prototype.reset=function(){this._callbacks={};this._directMap=
{};return this};c.prototype.stopCallback=function(a,b){return-1<(" "+b.className+" ").indexOf(" mousetrap ")||B(b,this.target)?!1:"INPUT"==b.tagName||"SELECT"==b.tagName||"TEXTAREA"==b.tagName||b.isContentEditable};c.prototype.handleKey=function(){return this._handleKey.apply(this,arguments)};c.init=function(){var a=c(r),b;for(b in a)"_"!==b.charAt(0)&&(c[b]=function(b){return function(){return a[b].apply(a,arguments)}}(b))};c.init();C.Mousetrap=c;"undefined"!==typeof module&&module.exports&&(module.exports=
c);"function"===typeof define&&define.amd&&define(function(){return c})})(window,document);

Mousetrap.bind("enter", function () {
	$("#story-caption #endWeekButton a.macro-link").trigger("click");
});
Mousetrap.bind("space", function () {
	$("#story-caption #nextButton a.macro-link").trigger("click");
});
Mousetrap.bind("c", function () {
	$("#story-caption #manageArcology a.macro-link").trigger("click");
});
Mousetrap.bind("p", function () {
	$("#story-caption #managePenthouse a.macro-link").trigger("click");
});
Mousetrap.bind("left", function () {
	$("#prevSlave a.macro-link").trigger("click");
	$("#prevRule a.macro-link").trigger("click");
});
Mousetrap.bind("q", function () {
	$("#prevSlave a.macro-link").trigger("click");
	$("#prevRule a.macro-link").trigger("click");
});
Mousetrap.bind("shift+left", function () {
	$("#firstRule a.macro-link").trigger("click");
});
Mousetrap.bind("shift+q", function () {
	$("#firstRule a.macro-link").trigger("click");
});
Mousetrap.bind("right", function () {
	$("#nextSlave a.macro-link").trigger("click");
	$("#nextRule a.macro-link").trigger("click");
});
Mousetrap.bind("shift+right", function () {
	$("#lastRule a.macro-link").trigger("click");
});
Mousetrap.bind("e", function () {
	$("#nextSlave a.macro-link").trigger("click");
	$("#nextRule a.macro-link").trigger("click");
});
Mousetrap.bind("shift+e", function () {
	$("#lastRule a.macro-link").trigger("click");
});
Mousetrap.bind("f", function () {
	$("#walkpast a.macro-link").trigger("click");
});
Mousetrap.bind("h", function () {
	$("#manageHG a.macro-link").trigger("click");
});
Mousetrap.bind("s", function () {
	$("#buySlaves a.macro-link").trigger("click");
});
Mousetrap.bind("a", function () {
	$("#managePA a.macro-link").trigger("click");
});
Mousetrap.bind("b", function () {
	$("#manageBG a.macro-link").trigger("click");
});
Mousetrap.bind("r", function () {
	$("#manageRecruiter a.macro-link").trigger("click");
});
Mousetrap.bind("o", function () {
	$("#story-caption #optionsButton a.macro-link").trigger("click");
});
Mousetrap.bind("y", function () {
	$("#story-caption #policyButton a.macro-link").trigger("click");
});
Mousetrap.bind("f", function () {
	$("#story-caption #FSButton a.macro-link").trigger("click");
});
Mousetrap.bind("l", function () {
	$("#story-caption #LanguageButton a.macro-link").trigger("click");
});
Mousetrap.bind("t", function () {
	$("#story-caption #PAOButton a.macro-link").trigger("click");
});
Mousetrap.bind("u", function () {
	$("#story-caption #URButton a.macro-link").trigger("click");
});
Mousetrap.bind("w", function () {
	$("#story-caption #WARButton a.macro-link").trigger("click");
});

/**
 * BoobGenerator namespace.
 */
if (typeof BoobGenerator == "undefined") {
	var BoobGenerator = {
		rollBreast: function (modif) {
			var volume = [0, 300, 500, 650, 800, 1000, 1200, 1400, 1600, 1800, 2050, 2300, 2600, 2900, 3250, 3600, 3950, 4300, 4700, 5100, 5500, 5900];
			var volume_dist = [90000, 470000, 720000, 840000, 908574, 947759, 970151, 982946, 990258, 994436, 996824, 998188, 998968, 999414, 999669, 999814, 999897, 999945, 999972, 999987, 999995, 1000000];
			var randomRoll = Math.floor(Math.random() * 1000000) + 1
			var actualSize = 0
			while (randomRoll > volume_dist[actualSize]) {
				actualSize = actualSize + 1
			}
			var minorSizeAdjustment = 0
			if (Math.random()<.5) {
				minorSizeAdjustment = (Math.floor(Math.random() * 2) + 1) * 50
			}
			var volResult = volume[actualSize] + minorSizeAdjustment + modif
			if (volResult < 0) {volResult = 0}
			return volResult
		}
	};
	// Raise namespace scope to Global.
	window.BoobGenerator = BoobGenerator;
};

/**
 * Slave checker namespace.
 */
if (typeof SlaveStatsChecker == "undefined") {
	var SlaveStatsChecker = {
		checkForLisp: function (slave) {
				/* Begin mod section: toggle whether slaves lisp. */
				if (SugarCube.State.variables.disableLisping == 1) {
					return false;
				}
				/* End mod section: toggle whether slaves lisp. */
				return ((slave.lips > 70) || (slave.lipsPiercing + slave.tonguePiercing > 2))
			}
	};
	// Raise namespace scope to Global.
	window.SlaveStatsChecker = SlaveStatsChecker;
};

if (typeof FertilityAge == "undefined") {
	var FertilityAge = {
		setAge: function (age) {
			age = Number(age)
				if (age != age) {
					return 13;
				} else {
				return age
			}
		}
	};
	// Raise namespace scope to Global.
	window.FertilityAge = FertilityAge;
};

window.canGetPregnant = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.pubertyXX == 0){
		return false;
	} else if (slave.physicalAge >= 47) {
		return false;
	} else if (slave.inflation != 0) {
		return false;
	} else if (slave.bellyImplant != 0) {
		return false;
	} else if (slave.preg != 0) {
		return false;
	} else if ((slave.mpreg == 1) && (canDoAnal(slave) == true)) {
		return true;
	} else if (slave.ovaries != 1) {
		return false;
	} else if (canDoVaginal(slave) == false) {
		return false;
	} else {
		return true;
	}
};

window.isFertile = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.pubertyXX == 0) {
		return false;
	} else if (slave.physicalAge >= 47) {
		return false;
	} else if (slave.inflation != 0) {
		return false;
	} else if (slave.bellyImplant != 0) {
		return false;
	} else if (slave.preg > 0) {
		return false;
	} else if (slave.preg < -1) {
		return false;
	} else if (slave.mpreg == 1) {
		return true;
	} else if (slave.ovaries != 1) {
		return false;
	} else {
		return true;
	}
};

window.canBreed = function(slave1, slave2) {
	if (slave1.eggType == slave2.ballType) {
		return true;
	} else {
		return false;
	}
};

//hyperpreg size 2
window.hyperBellyTwo = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.preg > 30 && slave.pregType >= 20) {
		return true;
	} else if (slave.bellyImplant >= 32000) {
		return true;
	} else {
		return false;
	}
};

window.hyperPregBellyTwo = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.preg > 30 && slave.pregType >= 20) {
		return true;
	} else {
		return false;
	}
};

//hyperpreg size 1
window.hyperBellyOne = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.preg > 20 && slave.pregType >= 20) {
		return true;
	} else if (slave.preg > 30 && slave.pregType >= 10) {
		return true;
	} else if (slave.bellyImplant >= 16000) {
		return true;
	} else {
		return false;
	}
};

window.hyperPregBellyOne = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.preg > 20 && slave.pregType >= 20) {
		return true;
	} else if (slave.preg > 30 && slave.pregType >= 10) {
		return true;
	} else {
		return false;
	}
};

//full term belly
window.hugeBelly = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.preg > 0 && slave.pregType >= 20) {
		return true;
	} else if (slave.preg > 10 && slave.pregType >= 10) {
		return true;
	} else if (slave.preg > 30) {
		return true;
	} else if (slave.inflation >= 3) {
		return true;
	} else if (slave.bellyImplant >= 8000) {
		return true;
	} else {
		return false;
	}
};

window.hugeBellyPreg = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.preg > 0 && slave.pregType >= 20) {
		return true;
	} else if (slave.preg > 10 && slave.pregType >= 10) {
		return true;
	} else if (slave.preg > 30) {
		return true;
	} else {
		return false;
	}
};

//is the slave's belly big enough to get in the way
window.bigBellyPreg = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.preg > 0 && slave.pregType >= 20) {
		return true;
	} else if (slave.preg > 10 && slave.pregType >= 10) {
		return true;
	} else if (slave.preg > 20) {
		return true;
	} else {
		return false;
	}
};

window.bigBelly = function(slave) {
	if (!slave) {
		return null;
	} else if (bigBellyPreg(slave) == true) {
		return true;
	} else if (slave.inflation > 2) {
		return true;
	} else if (slave.bellyImplant > 8000) {
		return true;
	} else {
		return false;
	}
};

window.canAchieveErection = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.dick < 7 && slave.dick > 0 && (slave.balls > 0 ? slave.hormones <= 0 : slave.hormones < 0)) {
		return true;
	} else {
		return false;
	}
};

window.canPenetrate = function(slave) {
	if (!slave) {
		return null;
	} else if (canAchieveErection(slave) == false) {
		return false;
	} else if (slave.dickAccessory == "chastity") {
		return false;
	} else if (slave.dickAccessory == "combined chastity") {
		return false;
	} else if (slave.dick > 7) {
		return false;
	}
	return true;
};

window.canSee = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.eyes > -2) {
		return true;
	} else {
		return false;
	}
};

window.canWalk = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.amp == 1)  {
		return false;
	} else if (slave.boobs > 9000+(slave.muscles*100) && slave.physicalAge >= 18) {
		return false;
	} else if (slave.boobs > 5000+(slave.muscles*10) && slave.physicalAge <= 3) {
		return false;
	} else if (slave.boobs > 7000+(slave.muscles*20) && slave.physicalAge <= 12) {
		return false;
	} else if (slave.boobs > 9000+(slave.muscles*50) && slave.physicalAge < 18) {
		return false;
	} else if (slave.dick >= 15+(slave.muscles*.2) && slave.physicalAge <= 3) {
		return false;
	} else if (slave.dick >= 30+(slave.muscles*.3) && slave.physicalAge <= 12) {
		return false;
	} else if (slave.dick >= 68+(slave.muscles*.4)) {
		return false;
	} else if (slave.balls >= 30+(slave.muscles*.3) && slave.physicalAge <= 3) {
		return false;
	} else if (slave.balls >= 60+(slave.muscles*.5) && slave.physicalAge <= 12) {
		return false;
	} else if (slave.balls >= 90+(slave.muscles*.7)) {
		return false;
	} else if (slave.butt > 10 && slave.physicalAge <= 3) {
		return false;
	} else if (slave.butt > 14 && slave.physicalAge <= 12) {
		return false;
	} else if (slave.preg > 20 && slave.physicalAge >= 13 && slave.pregType >= 20 && slave.height < 150) {
		return false;
	} else if (slave.preg > 30 && slave.physicalAge >= 13 && slave.pregType >= 20 && (!slave.height >= 185 || !slave.muscles > 1)) {
		return false;
	} else if (slave.preg > 20 && slave.physicalAge <= 3 && slave.pregType >= 10) {
		return false;
	} else if (slave.preg > 20 && slave.physicalAge <= 12 && slave.pregType >= 20) {
		return false;
	} else if (slave.bellyImplant > 31000+(slave.muscles*100) && slave.physicalAge >= 18) {
		return false;
	} else if (slave.bellyImplant > 31000+(slave.muscles*80) && slave.physicalAge >= 13) {
		return false;
	} else if (slave.bellyImplant > 12000+(slave.muscles*50) && slave.physicalAge <= 3) {
		return false;
	} else if (slave.bellyImplant > 16000+(slave.muscles*20) && slave.physicalAge <= 12) {
		return false;
	} else if (slave.heels == 0) {
		return true;
	} else if (slave.shoes == "heels") {
		return true;
	} else if (slave.shoes == "extreme heels") {
		return true;
	} else if (slave.shoes == "boots") {
		return true;
	} else {
		return false;
	}
};

window.canTalk = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.accent > 2)  {
		return false;
	} else if (slave.voice == 0) {
		return false;
	} else if (slave.lips > 95) {
		return false;
	} else {
		return true;
	}
};

window.canDoAnal = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.vaginalAccessory == "anal chastity") {
		return false;
	} else if (slave.dickAccessory == "anal chastity") {
		return false;
	} else if (slave.vaginalAccessory == "combined chastity") {
		return false;
	} else if (slave.dickAccessory == "combined chastity") {
		return false;
	}
	return true;
};

window.canDoVaginal = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.vagina < 0) {
		return false;
	} else if (slave.vaginalAccessory == "chastity belt") {
		return false;
	} else if (slave.vaginalAccessory == "combined chastity") {
		return false;
	}
	return true;
};

window.tooBigBreasts = function(slave){
	if (!slave) {
		return null;
	} else if (slave.boobs > 9000+(slave.muscles*100) && slave.physicalAge >= 18) {
		return true;
	} else if (slave.boobs > 5000+(slave.muscles*10) && slave.physicalAge <= 3) {
		return true;
	} else if (slave.boobs > 7000+(slave.muscles*20) && slave.physicalAge <= 12) {
		return true;
	} else if (slave.boobs > 9000+(slave.muscles*50) && slave.physicalAge < 18) {
		return true;
	} else {
		return false;
	}
};

window.tooBigBelly = function(slave){
	if (!slave) {
		return null;
	} else if (slave.preg > 20 && slave.physicalAge >= 18 && slave.pregType >= 20 && slave.height < 150) {
		return true;
	} else if (slave.preg > 30 && slave.physicalAge >= 18 && slave.pregType >= 20 && (!slave.height >= 185 || !slave.muscles > 1)) {
		return true;
	} else if (slave.preg > 20 && slave.physicalAge <= 3 && slave.pregType >= 10) {
		return true;
	} else if (slave.preg > 20 && slave.physicalAge <= 12 && slave.pregType >= 20) {
		return true;
	} else if (slave.bellyImplant > 31000+(slave.muscles*100) && slave.physicalAge >= 18) {
		return true;
	} else if (slave.bellyImplant > 31000+(slave.muscles*80) && slave.physicalAge >= 13) {
		return true;
	} else if (slave.bellyImplant > 12000+(slave.muscles*20) && slave.physicalAge <= 3) {
		return true;
	} else if (slave.bellyImplant > 16000+(slave.muscles*50) && slave.physicalAge <= 12) {
		return true;
	} else {
		return false;
	}
};

window.tooBigBalls = function(slave){
	if (!slave) {
		return null;
	} else if (slave.balls >= 30+(slave.muscles*.3) && slave.physicalAge <= 3) {
		return true;
	} else if (slave.balls >= 60+(slave.muscles*.5) && slave.physicalAge <= 12) {
		return true;
	} else if (slave.balls >= 90+(slave.muscles*.7)) {
		return true;
	} else {
		return false;
	}
};

window.tooBigDick = function(slave){
	if (!slave) {
		return null;
	} else if (slave.dick >= 15+(slave.muscles*.2) && slave.physicalAge <= 3) {
		return true;
	} else if (slave.dick >= 30+(slave.muscles*.3) && slave.physicalAge <= 12) {
		return true;
	} else if (slave.dick >= 68+(slave.muscles*.4)) {
		return true;
	} else {
		return false;
	}
};

window.tooBigButt = function(slave){
	if (!slave) {
		return null;
	} else if (slave.butt > 10 && slave.physicalAge <= 3) {
		return true;
	} else if (slave.butt > 14 && slave.physicalAge <= 12) {
		return true;
	} else {
		return false;
	}
};

/*
window.sameTParent = function(slave1, slave2) {
	if ((slave1.mother == slave2.father || slave1.father == slave2.mother) && (slave1.mother != 0 && slave1.mother != -2 && slave1.father != 0 && slave1.father != -2)) {
		return true; //testtest catches the case if a mother is a father or a father a mother
	} else {
		return false;
	}
};
*/

// testtest catches the case if a mother is a father or a father a mother
window.sameTParent = function(slave1, slave2) {
	if (slave1.mother == slave2.father && slave1.father == slave2.mother && slave1.mother != 0 && slave1.mother != -2 && slave1.father != 0 && slave1.father != -2 && slave1.mother != slave1.father) {
		return 2;
	} else if ((slave1.mother == slave2.father || slave1.father == slave2.mother) && slave1.mother != 0 && slave1.mother != -2 && slave2.mother != 0 && slave2.mother != -2 && slave1.mother != slave1.father) {
		return 3;
	} else {
		return 0;
	}
};

window.sameDad = function(slave1, slave2){
	if ((slave1.father == slave2.father) && (slave1.father != 0 && slave1.father != -2)) {
		return true;
	} else {
		return false;
	}
};

window.sameMom = function(slave1, slave2){
	if ((slave1.mother == slave2.mother) && (slave1.mother != 0 && slave1.mother != -2)) {
		return true;
	} else {
		return false;
	}
};

window.areTwins = function(slave1, slave2) {
	if (sameDad(slave1, slave2) == false) {
		return false;
	} else if (sameMom(slave1, slave2) == false) {
		return false;
	} else if (slave1.actualAge == slave2.actualAge && slave1.birthWeek == slave2.birthWeek) {
		return true;
	} else {
		return false;
	}
};

/*
//3 = half-sisters, 2 = sisters, 1 = twins, 0 = not related
window.areSisters = function(c1, c2) {
	if(c1.ID == c2.ID) {
		return 0;
	}
	var sib = 4;
	if(sameMom(c1, c2)) {
		sib -= 1;
	}
	if(sameDad(c1, c2)) {
	   sib -=1;
	}
	if (sib == 2 && c1.actualAge == c2.actualAge && c1.birthWeek == c2.birthWeek) {
		sib -= 1;
	}
	if(sib == 4) {
		return 0
	} else {
		return sib;
	}
}
*/

window.areSisters = function(slave1, slave2) {
	if (slave1.ID == slave2.ID) {
		return 0; //you are not your own sister
	} else if ((slave1.father != 0 && slave1.father != -2) || (slave1.mother != 0 && slave1.mother != -2)) {
		if (sameDad(slave1, slave2) == false && sameMom(slave1, slave2) == true) {
			return 3; //half sisters
		} else if (sameDad(slave1, slave2) == true && sameMom(slave1, slave2) == false) {
			return 3; //half sisters
		} else if (sameTParent(slave1, slave2) == 3) {
			return 3; //half sisters
		} else if (sameTParent(slave1, slave2) == 2) {
			return 2; //sisters
		} else if (sameDad(slave1, slave2) == true && sameMom(slave1, slave2) == true) {
			if (slave1.actualAge == slave2.actualAge && slave1.birthWeek == slave2.birthWeek) {
				return 1; //twins
			} else {
				return 2; //sisters
			}
		} else {
			return 0; //not related
		}
	} else {
		return 0; //not related
	}
};

window.totalRelatives = function(slave) {
	var relatives = 0;
	if (slave.mother > 0) {
		relatives += 1
	}
	if (slave.father > 0) {
		relatives += 1
	}
	if (slave.daughters > 0) {
		relatives += slave.daughters
	}
	if (slave.sisters > 0) {
		relatives += slave.sisters
	}
	return relatives
};

window.mutualChildren = function(slave1, slave2, slaves) {
	return slaves.filter(function(s) { return s.ID != slave1.ID && s.ID != slave2.ID && ((s.mother == slave1.ID && s.father == slave2.ID) || (s.mother == slave2.ID && s.father == slave1.ID)); }).length;
}

if (typeof DairyRestraintsSetting == "undefined") {
	var DairyRestraintsSetting = {
		setSetting: function (setting) {
			setting = Number(setting)
			return setting
		}
	};
	// Raise namespace scope to Global.
	window.DairyRestraintsSetting = DairyRestraintsSetting;
};

window.isSlaveAvailable = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.assignment == "be your agent") {
		return false;
	} else if (slave.assignment == "live with your agent") {
		return false;
	} else if (slave.assignment == "work in the dairy" && DairyRestraintsSetting >= 2) {
		return false;
	} else {
		return true;
	}
};

window.relationTargetWord = function(slave) {
	if (!slave) {
		return null;
	} else if (slave.relation == "daughter") {
		return "mother";
	} else if (slave.relation == "mother") {
		return "daughter";
	}
	return slave.relation;
};

window.ruleApplied = function(slave, ID) {
	if (!slave) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	} else {
		for(var d=0; d < slave.currentRules.length; ++d){
			if(slave.currentRules[d] == ID){
				return true;
			}
		}return false;
	}
};

window.ruleAssignment = function(applyAssignment, assignment) {
	for(var d=0; d < applyAssignment.length; ++d){
		if(applyAssignment[d] == assignment){

			return true;
		}
	}return false;
};

window.ruleFacility = function(applyFacility, facility) {
	for(var d=0; d < applyFacility.length; ++d){
		if(applyFacility[d] == facility){
			return true;
		}
	}return false;
};

window.ruleExcludeSlaveFacility = function(rule, slave) {
	if (!slave) {
		return null;
	}else if (!rule) {
		return null;
	}else if (!rule.excludeFacility) {
		return false;
	} else {
		for(var d=0; d < rule.excludeFacility.length; ++d){
			if(rule.excludeFacility[d] == "hgsuite"){
				if(slave.assignment == "live with your Head Girl" ){
					return true;
				}
				else if(slave.assignment == "be your Head Girl"){
					return true;
				}
			}
			else if(rule.excludeFacility[d] == "arcade"){
				if (slave.assignment == "be confined in the arcade" ){
					return true;
				}
			}
			else if(rule.excludeFacility[d] == "mastersuite"){
				if(slave.assignment == "serve in the master suite" ){
					return true;
				}
				else if(slave.assignment == "be your Concubine"){
					return true;
				}
			}
			else if(rule.excludeFacility[d] == "clinic"){
				if(slave.assignment == "get treatment in the clinic" ){
					return true;
				}
				else if(slave.assignment == "be the Nurse"){
					return true;
				}
			}
			else if(rule.excludeFacility[d] == "spa"){
				if(slave.assignment == "rest in the spa" ){
					return true;
				}
				else if(slave.assignment == "be the Attendant"){
					return true;
				}
			}
			else if(rule.excludeFacility[d] == "brothel"){
				if(slave.assignment == "work in the brothel" ){
					return true;
				}
				else if(slave.assignment == "be the Madam"){
					return true;
				}
			}
			else if(rule.excludeFacility[d] == "club"){
				if(slave.assignment == "serve in the club" ){
					return true;
				}
				else if(slave.assignment == "be the DJ"){
					return true;
				}
			}
			else if(rule.excludeFacility[d] == "dairy"){
				if (slave.assignment == "work in the dairy"){
					return true;
				}
				else if(slave.assignment == "be the Milkmaid"){
					return true;
				}
			}
			else if(rule.excludeFacility[d] == "servantsquarters"){
				if(slave.assignment == "work as a servant"){
					return true;
				}
				else if(slave.assignment == "be the Stewardess"){
					return true;
				}
			}
			else if(rule.excludeFacility[d] == "schoolroom"){
				if(slave.assignment == "learn in the schoolroom" ){
					return true;
				}
				else if(slave.assignment == "be the Schoolteacher"){
					return true;
				}
			}
			else if(rule.excludeFacility[d] == "cellblock"){
				if(slave.assignment == "be confined in the cellblock" ){
					return true;
				}
				else if(slave.assignment == "be the Wardeness"){
					return true;
				}
			}
		}
	}
};

window.ruleAppliedToSlaveFacility = function(rule, slave) {
	if (!slave) {
		return null;
	}else if (!rule) {
		return null;
	}else if (!rule.facility) {
		return false;
	} else {
		for(var d=0; d < rule.facility.length; ++d){
			if(rule.facility[d] == "hgsuite"){
				if(slave.assignment == "live with your Head Girl" ){
					return true;
				}
				else if((rule.excludeSpecialSlaves != true) && (slave.assignment == "be your Head Girl")){
					return true;
				}
			}
			else if(rule.facility[d] == "arcade"){
				if(slave.assignment == "be confined in the arcade" ){
					return true;
				}
			}
			else if(rule.facility[d] == "mastersuite"){
				if(slave.assignment == "serve in the master suite" ){
					return true;
				}
				else if((rule.excludeSpecialSlaves != true) && (slave.assignment == "be your Concubine")){
					return true;
				}
			}
			else if(rule.facility[d] == "clinic"){
				if(slave.assignment == "get treatment in the clinic" ){
					return true;
				}
				else if((rule.excludeSpecialSlaves != true) && (slave.assignment == "be the Nurse")){
					return true;
				}
			}
			else if(rule.facility[d] == "spa"){
				if(slave.assignment == "rest in the spa" ){
					return true;
				}
				else if((rule.excludeSpecialSlaves != true) && (slave.assignment == "be the Attendant")){
					return true;
				}
			}
			else if(rule.facility[d] == "brothel"){
				if(slave.assignment == "work in the brothel" ){
					return true;
				}
				else if((rule.excludeSpecialSlaves != true) && (slave.assignment == "be the Madam")){
					return true;
				}
			}
			else if(rule.facility[d] == "club"){
				if(slave.assignment == "serve in the club" ){
					return true;
				}
				else if((rule.excludeSpecialSlaves != true) && (slave.assignment == "be the DJ")){
					return true;
				}
			}
			else if(rule.facility[d] == "dairy"){
				if (slave.assignment == "work in the dairy"){
					return true;
				}
				else if((rule.excludeSpecialSlaves != true) && (slave.assignment == "be the Milkmaid")){
					return true;
				}
			}
			else if(rule.facility[d] == "servantsquarters"){
				if(slave.assignment == "work as a servant" ){
					return true;
				}
				else if((rule.excludeSpecialSlaves != true) && (slave.assignment == "be the Stewardess")){
					return true;
				}
			}
			else if(rule.facility[d] == "schoolroom"){
				if(slave.assignment == "learn in the schoolroom" ){
					return true;
				}
				else if((rule.excludeSpecialSlaves != true) && (slave.assignment == "be the Schoolteacher")){
					return true;
				}
			}
			else if(rule.facility[d] == "cellblock"){
				if(slave.assignment == "be confined in the cellblock" ){
					return true;
				}
				else if((rule.excludeSpecialSlaves != true) && (slave.assignment == "be the Wardeness")){
					return true;
				}
			}
		}return false;
	}
};

window.ruleSlaveSelected = function(slave, rule) {
	if (!slave) {
		return null;
	}else if (!rule) {
		return null;
	}else if (!rule.selectedSlaves) {
		return false;
	} else {
		for(var d=0; d < rule.selectedSlaves.length; ++d){
			if(slave.ID == rule.selectedSlaves[d]){
				return true;
			}
		}return false;
	}
};

window.ruleSlaveExcluded = function(slave, rule) {
	if (!slave) {
		return null;
	}else if (!rule) {
		return null;
	}else if (!rule.excludedSlaves) {
		return false;
	} else {
		for(var d=0; d < rule.excludedSlaves.length; ++d){
			if(slave.ID == rule.excludedSlaves[d]){
				return true;
			}
		}return false;
	}
};
window.hasSurgeryRule = function(slave, rules) {
	if (!slave) {
		return false;
	}else if (!rules) {
		return false;
	}else if (!slave.currentRules) {
		return false;
	}else {
		for(var d=rules.length-1; d >= 0; --d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].autoSurgery > 0){
						return true;
					}
				}
			}
		}return false;
	}
};

window.lastPregRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return false;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].preg == -1){
						return rules[d];
					}
				}
			}
		}return null;
	}
};

window.hasHColorRule = function(slave, rules) {
	if (!slave) {
		return false;
	}else if (!rules) {
		return false;
	}else if (!slave.currentRules) {
		return false;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].hColor != "no default setting"){
						return true;
					}
				}
			}
		}return false;
	}
};

window.hasHStyleRule = function(slave, rules) {
	if (!slave) {
		return false;
	}else if (!rules) {
		return false;
	}else if (!slave.currentRules) {
		return false;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].hStyle != "no default setting"){
						return true;
					}
				}
			}
		}return false;
	}
};

window.hasEyeColorRule = function(slave, rules) {
	if (!slave) {
		return false;
	}else if (!rules) {
		return false;
	}else if (!slave.currentRules) {
		return false;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].hStyle != "no default setting"){
						return true;
					}
				}
			}
		}return false;
	}
};

window.lastEyeWearRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].eyewear != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};

window.lastEyeColorRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].eyeColor != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};

window.lastMakeupRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].makeup != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};

window.lastNailsRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].nails != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};

window.lastHColorRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].hColor != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};

window.lastHStyleRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].hStyle != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};

window.lastHLengthRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].hLength != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};

window.lastPubicHColorRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].pubicHColor != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};

window.lastPubicHStyleRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].pubicHStyle != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};

window.lastUnderArmHColorRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].underArmHColor != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};

window.lastUnderArmHStyleRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].underArmHStyle != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};

window.lastNipplesPiercingRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].nipplesPiercing != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastAreolaePiercingRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].areolaePiercing != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastClitPiercingRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].clitPiercing != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastClitSettingRule = function(slave, rules) {
    if (!slave) {
        return null;
    }else if (!rules) {
        return null;
    }else if (!slave.currentRules) {
        return null;
    }else {
        for(var d=rules.length-1; d >= 0;--d){
            for(var e=0; e < slave.currentRules.length;++e){
                if(slave.currentRules[e] == rules[d].ID){
                    if (rules[d].clitSetting != "no default setting"){
                        return rules[d];
                    }
                }
            }
        }return null;
    }
};
window.lastClitSettingXYRule = function(slave, rules) {
    if (!slave) {
        return null;
    }else if (!rules) {
        return null;
    }else if (!slave.currentRules) {
        return null;
    }else {
        for(var d=rules.length-1; d >= 0;--d){
            for(var e=0; e < slave.currentRules.length;++e){
                if(slave.currentRules[e] == rules[d].ID){
                    if (rules[d].clitSettingXY != "no default setting"){
                        return rules[d];
                    }
                }
            }
        }return null;
    }
};
window.lastClitSettingXXRule = function(slave, rules) {
    if (!slave) {
        return null;
    }else if (!rules) {
        return null;
    }else if (!slave.currentRules) {
        return null;
    }else {
        for(var d=rules.length-1; d >= 0;--d){
            for(var e=0; e < slave.currentRules.length;++e){
                if(slave.currentRules[e] == rules[d].ID){
                    if (rules[d].clitSettingXX != "no default setting"){
                        return rules[d];
                    }
                }
            }
        }return null;
    }
};
window.lastClitSettingEnergyRule = function(slave, rules) {
    if (!slave) {
        return null;
    }else if (!rules) {
        return null;
    }else if (!slave.currentRules) {
        return null;
    }else {
        for(var d=rules.length-1; d >= 0;--d){
            for(var e=0; e < slave.currentRules.length;++e){
                if(slave.currentRules[e] == rules[d].ID){
                    if (rules[d].clitSettingEnergy != "no default setting"){
                        return rules[d];
                    }
                }
            }
        }return null;
    }
};
window.lastVaginaPiercingRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].vaginaPiercing != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastDickPiercingRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].dickPiercing != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastAnusPiercingRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].anusPiercing != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastLipsPiercingRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].lipsPiercing != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastTonguePiercingRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].tonguePiercing != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastEarPiercingRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].earPiercing != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastEyebrowPiercingRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].earPiercing != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastNosePiercingRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].nosePiercing != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastNavelPiercingRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].navelPiercing != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastCorsetPiercingRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].corsetPiercing != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastBoobsTatRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].boobsTat != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastButtTatRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].buttTat != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastVaginaTatRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].vaginaTat != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastDickTatRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].dickTat != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastAnusTatRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].anusTat != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastLipsTatRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].lipsTat != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastShouldersTatRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].shouldersTat != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastArmsTatRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].armsTat != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastLegsTatRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].legsTat != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastStampTatRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].stampTat != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};

window.lastLactationSurgeryRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			if (!rules[d].surgery) {
				return null;
			}
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].surgery.lactation != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastLipSurgeryRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			if (!rules[d].surgery) {
				return null;
			}
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].surgery.lips != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastBoobSurgeryRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			if (!rules[d].surgery) {
				return null;
			}
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].surgery.boobs != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};
window.lastButtSurgeryRule = function(slave, rules) {
	if (!slave) {
		return null;
	}else if (!rules) {
		return null;
	}else if (!slave.currentRules) {
		return null;
	}else {
		for(var d=rules.length-1; d >= 0;--d){
			if (!rules[d].surgery) {
				return null;
			}
			for(var e=0; e < slave.currentRules.length;++e){
				if(slave.currentRules[e] == rules[d].ID){
					if (rules[d].surgery.butt != "no default setting"){
						return rules[d];
					}
				}
			}
		}return null;
	}
};

window.checkThresholds = function(number, rule) {
	if (!rule) {
		return null;
	} else {
		if ((rule.thresholdUpper != "none") && (rule.thresholdLower != "none")){
			if (!rule.eqLower && !rule.eqUpper){
				if((number < rule.thresholdUpper) && (number > rule.thresholdLower)){
					return true;
				}
			}
			else if (rule.eqLower && !rule.eqUpper){
				if((number < rule.thresholdUpper) && (number >= rule.thresholdLower)){
					return true;
				}
			}
			else if (!rule.eqLower && rule.eqUpper){
				if((number <= rule.thresholdUpper) && (number > rule.thresholdLower)){
					return true;
				}
			}
			else {
				if((number <= rule.thresholdUpper) && (number >= rule.thresholdLower)){
					return true;
				}
			}
		}
		else if (rule.thresholdUpper != "none"){
			if (!rule.eqUpper) {
				if(number < rule.thresholdUpper){
					return true;
				}
			}
			else{
				if(number <= rule.thresholdUpper){
					return true;
				}
			}
		}
		else if (rule.thresholdLower != "none"){
			if (!rule.eqLower) {
				if(number > rule.thresholdLower){
					return true;
				}
			}
			else{
				if(number >= rule.thresholdLower){
					return true;
				}
			}
		}return false;
	}
};

window.removeFromArray = function(arr, val) {
	for (var i = 0; i < arr.length; i++)
		if (val == arr[i])
			return arr.splice(i,1);
	return null;
};

window.milkAmount = function(slave) {
	var milk;
	var calcs;
	if (!slave) {
		return null;
	} else {
		calcs = slave.boobs-slave.boobsImplant
		if (calcs > 20000) {
			milk = (118+((calcs-20000)/400))
		} else if (calcs > 10000) {
			milk = (78+((calcs-10000)/300))
		} else if (calcs > 5000) {
			milk = (53+((calcs-5000)/200))
		} else if (calcs > 2000) {
			milk = (29+((calcs-2000)/125))
		} else if (calcs > 800) {
			milk = (16+((calcs-800)/80))
		} else {
			milk = (8+((calcs-400)/50))
		}
		if (slave.lactation == 2) {
			milk *= 1.2
		}
		milk += (milk*((slave.devotion-50)/200))
		if (slave.boobsImplant > 200) {
			milk *= 0.9
		}
		calcs = slave.hormones
		if (slave.balls != 0 && calcs > -2) {
			calcs -= 1
		} else if (slave.ovaries != 1 && calcs < 2) {
			calcs += 1
		}
		milk *= (1+(calcs*0.1))
		milk *= (1+(slave.preg/100))
		milk *= (1+(slave.health/50))
		milk *= (1+(slave.weight/500))
		milk *= (1+(slave.lactationAdaptation/500))
		milk = Math.trunc(milk)
		milk = Math.clamp(milk,1,1000000000000000000)
		return milk
	}
};

window.cumAmount = function(slave) {
	var cum = 0;
	var calcs = 0;
	if (!slave) {
		return null;
	} else {
		if (slave.drugs == "testicle enhancement") {
			cum = ((slave.balls*3.5)+1)
		} else if (slave.drugs == "hyper testicle enhancement") {
			cum = ((slave.balls*5)+1)
		} else {
			cum = ((slave.balls*2.5)+1)
		}
		if (slave.prostateImplant == 1) {
			cum *= 1.2
		}
		if (slave.diet == "cum production") {
			cum *= 1.2
		}
		calcs = slave.hormones
		cum *= (1-(calcs*0.1))
		if (slave.scrotum == 0) {
			cum *= 0.8
		}
		if (slave.devotion > 50) {
			cum += (cum*(slave.devotion/100))
		} else if (slave.devotion < -50) {
			cum += (cum*(slave.devotion/100))
		}
		if (slave.health > 50) {
			cum += (cum*(slave.health/50))
		} else if (slave.health < -50) {
			cum += (cum*(slave.health/50))
		}
		if (slave.prostate == 0) {
			cum *= 0.2 // being generous here
		}
		cum = Math.trunc(cum)
		cum = Math.clamp(cum,1,1000000000000000000)
		return cum
	}
};

window.randomRelatedSlave = function(slave, filterFunction) {
  if(!slave || !SugarCube) { return undefined; }
  if(typeof filterFunction !==  'function') { filterFunction = function(s, index, array) { return true; }; }
  return SugarCube.State.variables.slaves.filter(filterFunction).shuffle().find(function(s, index, array) {return areSisters(slave, s) || s.mother == slave.ID || s.father == slave.ID || slave.ID == s.mother || slave.ID == s.father; })
}

window.randomRelatedAvailableSlave = function(slave) {
	return randomRelatedSlave(slave, function(s, index, array) { return isSlaveAvailable(s); });
}

window.randomSister = function(slave) {
	return randomRelatedSlave(slave, function(s, index, array) { return areSisters(slave, s); });
}

window.randomTwinSister = function(slave) {
	return randomRelatedSlave(slave, function(s, index, array) { return areSisters(slave, s) == 1; });
}

window.randomAvailableSister = function(slave) {
	return randomRelatedSlave(slave, function(s, index, array) { return isSlaveAvailable(s) && areSisters(slave, s); });
}

window.randomAvailableTwinSister = function(slave) {
	return randomRelatedSlave(slave, function(s, index, array) { return isSlaveAvailable(s) && areSisters(slave, s) == 1; });
}

window.randomDaughter = function(slave) {
	return randomRelatedSlave(slave, function(s, index, array) { return s.mother == slave.ID || s.father == slave.ID; });
}

window.randomAvailableDaughter = function(slave) {
	return randomRelatedSlave(slave, function(s, index, array) { return isSlaveAvailable(s) && (s.mother == slave.ID || s.father == slave.ID); });
}

window.randomParent = function(slave) {
	return randomRelatedSlave(slave, function(s, index, array) { return s.ID == slave.mother || s.ID == slave.father; });
}

window.randomAvailableParent = function(slave) {
	return randomRelatedSlave(slave, function(s, index, array) { return isSlaveAvailable(s) && (s.ID == slave.mother || s.ID == slave.father); });
}

window.totalPlayerRelatives = function(pc) {
	var relatives = 0;
	if (pc.mother > 0) {
		relatives += 1
	}
	if (pc.father > 0) {
		relatives += 1
	}
	if (pc.daughters > 0) {
		relatives += pc.daughters
	}
	if (pc.sisters > 0) {
		relatives += pc.sisters
	}
	return relatives
};

window.ngUpdateGenePool = function(genePool) {
  var transferredSlaveIds = (SugarCube.State.variables.slaves || [])
    .filter(function(s) { return s.ID >= 1200000; })
    .map(function(s) { return s.ID - 1200000; });
  return (genePool || [])
    .filter(function(s) { return transferredSlaveIds.indexOf(s.ID) >= 0; })
    .map(function(s) {
      var result = jQuery.extend(true, {}, s);
      result.ID += 1200000;
      return result;
    });
}

window.toJson = function(obj) {
    var jsontext = JSON.stringify(obj);
    jsontext = jsontext.replace(/^{/,"");
    jsontext = jsontext.replace(/}$/,"");
    return jsontext;
};


code:
:: textboxJS [script]

/* Nicked off greyelf, works for <<replace>> textboxes */
window.setReplaceTextboxMaxLength = function (storyVarName, maxLength) {
	var textboxId = '#textbox-' + Util.slugify(storyVarName);
	$(textboxId)
			.attr('maxlength', maxLength)
			.css({
				'min-width' : 'initial',
				width       : maxLength + 'em',
				padding		: '3px 2px'
			});
};

/* Nicked off TheMadExile, works for non-<<replace>> textboxes */
window.setTextboxMaxLength = function (storyVarName, maxLength) {
	var textboxId = '#textbox-' + Util.slugify(storyVarName);
	postdisplay[textboxId + '-maxlength'] = function (taskName) {
		delete postdisplay[taskName];
		$(textboxId)
			.attr('maxlength', maxLength)
			.css({
				'min-width' : 'initial',
				width       : maxLength + 'em',
				padding		: '3px 2px'
			});
	};
};

repo_name: Qotsafan/fc


code:
:: UtilJS [script]

if(!Array.prototype.findIndex) {
	Array.prototype.findIndex = function(predicate) {
		if (this == null) {
			throw new TypeError('Array.prototype.find called on null or undefined');
		}
		if (typeof predicate !== 'function') {
			throw new TypeError('predicate must be a function');
		}
		var list = Object(this);
		var length = list.length >>> 0;
		var thisArg = arguments[1];
		var value;

		for (var i = 0; i < length; i++) {
			value = list[i];
			if (predicate.call(thisArg, value, i, list)) {
				return i;
			}
		}
		return -1;
	};
};

/*
A categorizer is used to "slice" a value range into distinct categories in an efficient manner.

--- Example ---
Original SugarCube code
<<if _Slave.muscles > 95>>
	Musc++
<<elseif _Slave.muscles > 30>>
	Musc+
<<elseif _Slave.muscles > 5>>
	Toned
<<elseif _Slave.muscles > -6>>
<<elseif _Slave.muscles > -31>>
	@@color:red;weak@@
<<elseif _Slave.muscles > -96>>
	@@color:red;weak+@@
<<else>>
	@@color:red;weak++@@
<</if>>

As a categorizer
<<if ndef $cats>><<set $cats = {}>><</if>>
<<if ndef $cats.muscleCat>>
	<!-- This only gets set once, skipping much of the code evaluation, and can be set outside of the code in an "init" passage for further optimization -->
	<<set $cats.muscleCat = new Categorizer([96, 'Musc++'], [31, 'Musc+'], [6, 'Toned'], [-5, ''], [-30, '@@color:red;weak@@'], [-95, '@@color:red;weak+@@'], [-Infinity, '@@color:red;weak++@@'])>>
<</if>>
<<print $cats.muscleCat.cat(_Slave.muscles)>>
*/
window.Categorizer = function() {
	this.cats = Array.prototype.slice.call(arguments)
		.filter(function(e, i, a) {
			return e instanceof Array && e.length == 2 && typeof e[0] === 'number' && !isNaN(e[0])
				&& a.findIndex(function(val) { return e[0] === val[0]; }) === i; /* uniqueness test */ })
		.sort(function(a, b) { return b[0] - a[0]; /* reverse sort */ });
};
window.Categorizer.prototype.cat = function(val, def) {
	if(typeof val !== 'number' || isNaN(val)) {
		return def;
	}
	var result = this.cats.find(function(e) { return val >= e[0]; });
	return result ? result[1] : def;
};


code:
:: Abort

<<set $nextButton = "Back">>\
<<set $nextLink = "Slave Interact">>\
<<nobr>>
The remote surgery makes aborting a pregnancy quick and efficient. $activeSlave.slaveName is
<<if $activeSlave.fetish == "pregnancy">>
	@@color:red;fundamentally broken.@@ Her entire concept of self and sexuality was wrapped up in the life growing within her, and now it is gone.
	<<set  $activeSlave.fetish to "mindbroken">>
<<elseif $activeSlave.devotion < -50>>
	@@color:mediumorchid;filled with violent, consuming hatred@@. Even though she knew her baby was destined for a slave orphanage, it seems she cared for it and views you as its killer. She is @@color:gold;terrified of your power@@ over her body.
	<<set  $activeSlave.trust -= 10>>
	<<set  $activeSlave.devotion -= 25>>
<<elseif $activeSlave.devotion < -20>>
	@@color:mediumorchid;afflicted by desperate, inconsolable sobbing@@. Even though she knew her baby was destined for a slave orphanage, it seems she cared for it. She is @@color:gold;terrified of your power@@ over her body.
	<<set  $activeSlave.trust -= 10>>
	<<set  $activeSlave.devotion -= 10>>
<<elseif $activeSlave.devotion <= 20>>
	@@color:mediumorchid;consumed by muted weeping and enduring sorrow@@. Even though she knew her baby was destined for a slave orphanage, it seems she cared for it. She is @@color:gold;terrified of your power@@ over her body.
	<<set  $activeSlave.trust -= 10>>
	<<set  $activeSlave.devotion -= 5>>
<<elseif $activeSlave.devotion <= 50>>
	dully obedient. She has been broken to slave life so thoroughly that even this is neither surprising nor affecting. She is @@color:gold;terrified of your power@@ over her body.
	<<set  $activeSlave.trust -= 10>>
<<else>>
	@@color:hotpink;pleased by this stark development@@, since she is so attentive to your will. She also expects she'll be able to fuck better now.
	<<set  $activeSlave.devotion += 4>>
<</if>>

<<set _currentRule to lastPregRule($activeSlave,$defaultRules)>>

<<if ($activeSlave.assignmentVisible == 1) && (_currentRule != null)>><<set $activeSlave.preg = -1>><<else>><<set $activeSlave.preg = 0>><</if>>
<<if $activeSlave.reservedChildren > 0>>
	<<set $reservedChildren -= $activeSlave.reservedChildren>>
<</if>>
<<set $activeSlave.pregType = 0>>
<<set $activeSlave.pregSource = 0>>
<</nobr>>


code:
:: Acquisition [nobr]

<<if $saveImported == 1>><<set _valueOwed = 5000>><<else>><<set _valueOwed = 50000>><</if>>
<<if $freshPC == 1>>
	<<if $PC.vagina == 1>>
	<<set $PC.births = 0>>
	<<if $PC.career == "servant">>
		<<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>>
		<<for $i = 0; $i < $slaves.length; $i++>>
			<<if $slaves[$i].origin == "She was another of your late master's servants. She spent nine months in your womb, courtesy of your master." ||$slaves[$i].origin == "Your late master took pleasure in using his servants in creative ways. He inseminated you with your own sperm, and nine months later, your daughter was born.">>
			<<set $PC.births += 1>>
			<<set $PC.birthMaster += 1>>
			<</if>>
		<</for>>
	<<elseif $PC.career == "escort">>
		<<for $i = 0; $i < $slaves.length; $i++>>
			<<if $slaves[$i].origin == "She was the result of unprotected sex with a client. He paid you quite well to enjoy your body as you grew heavy with his child." || $slaves[$i].origin == "A client payed you a large sum of credits to prove you could literally fuck yourself. She is the result of that lucrative night.">>
			<<set $PC.births += 1>>
			<<set $PC.birthClient += 1>>
			<</if>>
		<</for>>
	<<else>>
		<<for $i = 0; $i < $slaves.length; $i++>>
			<<if $slaves[$i].mother == -1>>
			<<set $PC.births += 1>>
			<<set $PC.birthOther += 1>>
			<</if>>
		<</for>>
	<</if>>
	<<if $PC.preg > 0>>
		<<if $PC.career == "servant">>
			<<set $PC.pregSource = -3>>
		<<elseif $PC.career == "escort">>
			<<set $PC.pregSource = -2>>
		<</if>>
	<</if>>
<<else>> /*testtest*/
	<<set $PC.pregSource = 0>>
	<<set $PC.mother = 0>>
	<<set $PC.mother = 0>>
	<<set $PC.sisters = 0>>
	<<set $PC.daughters = 0>>
	/*Reserved for player-family setting, unsetting, etc. */
<</if>>

<</if>> /*closes ng*/

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, $PCName, 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 "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.
	<<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 $ageMode == 1>>
	<<include [[Aging Test]]>>
<<elseif $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 $arcologies[0].FSSupremacistLawME = 1>><<include "Generate New Slave">><<set $arcologies[0].FSSupremacistLawME = 0>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(-25,-45), $activeSlave.health = random(0,15)>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.oralSkill = random(15,35), $activeSlave.analSkill = random(15,35)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.vaginalSkill = random(15,35)>>
		<</if>>
		<<set $activeSlave.entertainSkill = random(15,35)>>
		<<set $activeSlave.clothes = "uncomfortable straps", $activeSlave.collar = "uncomfortable leather", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "please you">>
	<<case "Subjugationist">>
		<<set $fixedRace = $activeArcology.FSSubjugationistRace>><<include "Generate New Slave">><<set $fixedRace = 0>>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(-25,-45), $activeSlave.health = random(0,15)>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.oralSkill = random(15,35), $activeSlave.analSkill = random(15,35)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.vaginalSkill = random(15,35)>>
		<</if>>
		<<set $activeSlave.whoreSkill = random(15,35)>>
		<<set $activeSlave.clothes = "uncomfortable straps", $activeSlave.collar = "uncomfortable leather", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "whore">>
	<<case "GenderRadicalist">>
		<<set $activeSlaveOneTimeMaxAge = 25>>
		<<include "Generate XY Slave">>
		<<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.oralSkill = random(35,65), $activeSlave.analSkill = random(35,65), $activeSlave.whoreSkill = random(35,65)>>
		<<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>>
		<<include "Generate XX Slave">>
		<<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,35), $activeSlave.lactation = 1>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.vaginalSkill = random(15,35)>>
		<</if>>
		<<set $activeSlave.clothes = "a nice maid outfit", $activeSlave.collar = "tight steel", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "work as a servant">>
	<<case "Paternalist">>
		<<include "Generate New Slave">>
		<<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(1,3), $activeSlave.intelligenceImplant = 1>>
		<<set $activeSlave.entertainSkill = random(15,35)>>
		<<set $activeSlave.clothes = "conservative clothing", $activeSlave.collar = "none", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "work as a servant">>
	<<case "Degradationist">>
		<<include "Generate New Slave">>
		<<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.oralSkill = 0, $activeSlave.analSkill = 0, $activeSlave.vaginalSkill = 0, $activeSlave.entertainSkill = 0, $activeSlave.whoreSkill = 0>>
		<<set $activeSlave.behavioralFlaw = "none", $activeSlave.sexualFlaw = "none">>
		<<set $activeSlave.clothes = "a Fuckdoll suit">>
		<<set $activeSlave.assignment = "please you">>
	<<case "AssetExpansionist">>
		<<include "Generate New Slave">>
		<<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.oralSkill = random(15,35), $activeSlave.analSkill = 0, $activeSlave.anus = 0>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.vaginalSkill = random(15,35)>>
		<</if>>
		<<set $activeSlave.entertainSkill = random(15,35)>>
		<<set $activeSlave.clothes = "slutty jewelry", $activeSlave.collar = "pretty jewelry", $activeSlave.shoes = "heels">>
		<<set $activeSlave.assignment = "please you">>
	<<case "SlimnessEnthusiast">>
		<<include "Generate New Slave">>
		<<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.oralSkill = random(15,35), $activeSlave.analSkill = 0, $activeSlave.anus = 0>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.vaginalSkill = random(15,35)>>
		<</if>>
		<<set $activeSlave.entertainSkill = random(15,35)>>
		<<set $activeSlave.clothes = "a leotard", $activeSlave.collar = "pretty jewelry", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "please you">>
	<<case "TransformationFetishist">>
		<<include "Generate New Slave">>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(-15,15), $activeSlave.health = random(-15,0)>>
		<<set $activeSlave.faceImplant = random(1,2)>>
		<<set $activeSlave.face = Math.trunc($activeSlave.face+$activeSlave.faceImplant*20,-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.oralSkill = random(15,35), $activeSlave.analSkill = random(15,35)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.vaginalSkill = random(15,35)>>
		<</if>>
		<<set $activeSlave.clothes = "a string bikini", $activeSlave.collar = "shock punishment", $activeSlave.shoes = "extreme heels">>
		<<set $activeSlave.assignment = "whore">>
	<<case "BodyPurist">>
		<<include "Generate New Slave">>
		<<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.muscle = random(10,25)>>
		<<set $activeSlave.oralSkill = random(15,35), $activeSlave.analSkill = random(15,35)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.vaginalSkill = random(15,35)>>
		<</if>>
		<<set $activeSlave.clothes = "a nice maid outfit", $activeSlave.collar = "pretty jewelry", $activeSlave.shoes = "heels">>
		<<set $activeSlave.assignment = "work as a servant">>
	<<case "MaturityPreferentialist">>
		<<set $activeSlaveOneTimeMinAge = 36>>
		<<set $activeSlaveOneTimeMaxAge = 39>>
		<<set $one_time_age_overrides_pedo_mode = 1>>
		<<include "Generate New Slave">>
		<<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.oralSkill = random(15,35), $activeSlave.analSkill = random(15,35)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.vaginalSkill = random(15,35)>>
		<</if>>
		<<SoftenBehavioralFlaw $activeSlave>>
		<<set $activeSlave.clothes = "a slutty maid outfit", $activeSlave.collar = "pretty jewelry", $activeSlave.shoes = "heels">>
		<<set $activeSlave.assignment = "work as a servant">>
	<<case "YouthPreferentialist">>
		<<set $activeSlaveOneTimeMaxAge = 19>>
		<<include "Generate New Slave">>
		<<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.oralSkill = random(15,35), $activeSlave.analSkill = 0, $activeSlave.anus = 0>>
		<<if $activeSlave.vagina > -1>><<set $activeSlave.vaginalSkill = 0, $activeSlave.vagina = 0>><</if>>
		<<set $activeSlave.entertainSkill = random(15,35)>>
		<<set $activeSlave.clothes = "a schoolgirl outfit", $activeSlave.collar = "pretty jewelry", $activeSlave.shoes = "heels">>
		<<set $activeSlave.assignment = "work as a servant">>
	<<case "Pastoralist">>
		<<include "Generate New Slave">>
		<<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>>
		<<set $activeSlave.clothes = "Western clothing", $activeSlave.collar = "leather with cowbell", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "get milked">>
	<<case "PhysicalIdealist">>
		<<include "Generate New Slave">>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(25,45), $activeSlave.health = 100>>
		<<set $activeSlave.muscles = random(50,100)>>
		<<set $activeSlave.oralSkill = random(15,35), $activeSlave.analSkill = random(15,35)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.vaginalSkill = random(15,35)>>
		<</if>>
		<<set $activeSlave.whoreSkill = random(15,35)>>
		<<set $activeSlave.clothes = "body oil", $activeSlave.collar = "none", $activeSlave.shoes = "none">>
		<<set $activeSlave.assignment = "whore">>
	<<case "ChattelReligionist">>
		<<include "Generate New Slave">>
		<<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.whoreSkill = 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>>
		<<include "Generate New Slave">>
		<<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.combatSkill = 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 "EgyptianRevivalist">>
		<<include "Generate New Slave">>
		<<set $activeSlave.devotion = random(25,45), $activeSlave.trust = random(25,45), $activeSlave.health = random(25,45)>>
		<<set $activeSlave.face = random(15,100)>>
		<<set $activeSlave.oralSkill = random(15,35), $activeSlave.analSkill = random(15,35)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.vaginalSkill = random(15,35)>>
		<</if>>
		<<set $activeSlave.entertainSkill = random(15,35)>>
		<<SoftenSexualFlaw $activeSlave>>
		<<set $activeSlave.clothes = "slutty jewelry", $activeSlave.collar = "ancient Egyptian", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "please you">>
	<<case "EdoRevivalist">>
		<<set $fixedRace = "asian">><<include "Generate New Slave">><<set $fixedRace = 0>>
		<<set $activeSlave.nationality = "Japanese">>
		<<NationalityToName $activeSlave>>
		<<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(1,3), $activeSlave.intelligenceImplant = 1>>
		<<set $activeSlave.entertainSkill = 100>>
		<<set $activeSlave.clothes = "a kimono", $activeSlave.collar = "satin choker", $activeSlave.shoes = "heels">>
		<<set $activeSlave.assignment = "serve the public">>
	<<case "ArabianRevivalist">>
		<<include "Generate New Slave">>
		<<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(0,2), $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 $fixedRace = "asian">><<include "Generate New Slave">><<set $fixedRace = 0>>
		<<set $activeSlave.nationality = "Chinese">>
		<<NationalityToName $activeSlave>>
		<<NationalityToAccent $activeSlave>>
		<<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 = 3, $activeSlave.intelligenceImplant = 1>>
		<<set $activeSlave.oralSkill = 100, $activeSlave.analSkill = 100>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina == 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.vaginalSkill = 100>>
		<</if>>
		<<set $activeSlave.entertainSkill = 100, $activeSlave.whoreSkill = 100>>
		<<SoftenBehavioralFlaw $activeSlave>>
		<<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">>
		<<include "Generate New Slave">>
		<<set $activeSlave.devotion = -100, $activeSlave.trust = -100, $activeSlave.health = random(80,90)>>
		<<set $activeSlave.intelligence = 3>>
		<<set $activeSlave.intelligenceImplant = 1>>
		<<set $activeSlave.face = 100>>
		<<set $activeSlave.faceShape = "sensual">>
		<<set $activeSlave.oralSkill = random(35,75), $activeSlave.analSkill = random(35,75)>>
		<<if $activeSlave.vagina > -1>>
			<<if $activeSlave.vagina = 0>><<set $activeSlave.vagina++>><</if>>
			<<set $activeSlave.vaginalSkill = random(35,75)>>
		<</if>>
		<<set $activeSlave.entertainSkill = random(15,35)>>
		<<set $activeSlave.whoreSkill = 0>>
		<<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>>
		<<include "Generate XX Slave">>
		<<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,35),$activeSlave.pregType = random(3,5), $activeSlave.lactation = 1>>
		<<set $activeSlave.birthsTotal = 5>>
		<<set $activeSlave.bellySag = 20>>
		<<if $activeSlave.vagina > -1>>
			<<set $activeSlave.vagina = 4>>
			<<set $activeSlave.vaginalSkill = random(15,35)>>
		<</if>>
		<<set $activeSlave.clothes = "a nice maid outfit", $activeSlave.shoes = "flats">>
		<<set $activeSlave.assignment = "please you">>
	<<default>>
		ERROR: bad arcology type
	<</switch>>
	<<set $activeSlave.origin = "You acquired her along with the arcology.", $activeSlave.career = "a slave">>
	<<slaveCost $activeSlave>>
	<<set _valueGiven += $slaveCost>>
	<<AddSlave $activeSlave>>
	<</for>>
<<else>>
	<<for $j = 0; $j < $heroSlaves.length; $j++>>
	<<if _valueOwed - _valueGiven <= 5000>>
		<<break>>
	<</if>>
	<<set $activeSlave = $heroSlaves[$j]>>
	<<set $dump = $heroSlaves.pluck($j,$j)>>
	<<slaveCost $activeSlave>>
	<<if _valueGiven + $slaveCost < _valueOwed*2>>
		<<NationalityToAccent $activeSlave>>
		<<set $activeSlave.oldDevotion = $activeSlave.devotion>>
		<<set $activeSlave.oldTrust = $activeSlave.trust>>
		<<set _valueGiven += $slaveCost>>
		<<AddSlave $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 her at your leisure.
		<<elseif $activeSlave.devotion < -50>>
			$activeSlave.slaveName is quite rebellious and was attempting to escape, so I have locked her in the slave quarters.
		<<elseif $activeSlave.devotion < -20>>
			$activeSlave.slaveName resists my orders and was considering escape, so I have locked her 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 she will be very happy to meet you.
		<<elseif $activeSlave.fetish == "pregnancy" && $activeSlave.preg > 10>>
			$activeSlave.slaveName is currently in the dormitory masturbating over her growing pregnancy.
		<<elseif bigBelly($activeSlave)>>
			$activeSlave.slaveName is currently in the dormitory massaging her greatly distended belly.
		<<elseif $activeSlave.fetish == "buttslut">>
			$activeSlave.slaveName is currently in the dormitory masturbating anally, and I believe she will be happy to meet you.
		<<elseif $activeSlave.fetish == "cumslut">>
			$activeSlave.slaveName is currently in the dormitory exhibiting oral fixation, and I believe she will be happy to meet you.
		<<elseif $activeSlave.fetish == "boobs">>
			$activeSlave.slaveName is currently in the dormitory playing with her nipples, and I believe she will be happy to meet you.
		<<elseif $activeSlave.fetish == "pregnancy">>
			$activeSlave.slaveName is currently in the dormitory examining herself to try to discern her fertility, and I believe she will be happy to meet you.
		<<elseif $activeSlave.fetish == "humiliation">>
			$activeSlave.slaveName is currently in the entryway flashing passersby, and I believe she 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 she will be happy to meet you.
		<<elseif $activeSlave.fetish == "dom">>
			$activeSlave.slaveName is currently in the exercise area keeping fit; she 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; she enjoys being superior to other slaves and I believe she means to ingratiate herself to you.
		<<elseif $activeSlave.fetish == "masochist">>
			$activeSlave.slaveName is a sexual masochist; she is currently in the bathroom, experimenting with auto-flagellation with a wet towel.
		<<else>>
			$activeSlave.slaveName is currently outside your office, and I believe she 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 _valueOwed-_valueGiven>>.
	<<set $cash += _valueOwed-_valueGiven>>
<</if>>
//

/* RELATIONSHIP MUTUALITY CHECK, OLDMENTAL */

<<set $averageTrust = 0>>
<<set $averageDevotion = 0>>
<<set _slavesContributing = 0>>
<<for $i = 0; $i < $slaves.length; $i++>>
	<<if $familyTesting == 1>>
		<<set $slaves[$i].sisters = 0>>
		<<set $slaves[$i].daughters = 0>>
		<<for $j to 0; $j < $slaves.length; $j++>>
			<<if $slaves[$j].mother == $slaves[$i].ID || $slaves[$j].father == $slaves[$i].ID>>
				<<set $slaves[$i].daughters += 1>>
			<</if>>
			<<if areSisters($slaves[$j], $slaves[$i]) > 0>>
				<<set $slaves[$i].sisters++>>
			<</if>>
		<</for>>
	<</if>>
	<<if $slaves[$i].relation != 0>>
	<<set $seed = 0>>
	<<for $j = 0; $j < $slaves.length; $j++>>
		<<if $slaves[$i].relationTarget == $slaves[$j].ID>>
		<<if $slaves[$j].relationTarget == $slaves[$i].ID>>
		<<set $seed = 1>>
		<<break>>
		<</if>>
		<</if>>
	<</for>>
	<<if $seed == 0>>
		<<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>>
<<set $averageTrust = $averageTrust/_slavesContributing>>
<<set $averageDevotion = $averageDevotion/_slavesContributing>>
<<set $enduringTrust = $averageTrust>>
<<set $enduringDevotion = $averageDevotion>>

<<link "Continue">>
	<<set $ui = "main">>
	<<set $fixedNationality = 0>>
	<<if $terrain == "urban">>
		<<set $minimumSlaveCost = 2000>>
		<<set $slaveCostFactor = 0.7>>
	<<elseif $terrain == "marine">>
		<<set $minimumSlaveCost = 2500>>
		<<set $slaveCostFactor = 1>>
	<<else>>
		<<set $minimumSlaveCost = 3000>>
		<<set $slaveCostFactor = 1.3>>
	<</if>>
	<>
	<<goto "Main">>
<</link>>