:: Remove activeSlave [nobr silently]

<<set _ID = $activeSlave.ID, _SL = $slaves.length, _x = $slaves.findIndex(function(s) { return s.ID == _ID; })>>

<<if _ID == $PC.pregSource>>
	<<set $PC.pregSource = 0>>
<</if>>
<<if $activeSlave.reservedChildren > 0>>
	<<set $reservedChildren -= $activeSlave.reservedChildren>>
<</if>>
<<if $PC.mother == _ID>>
	<<set $PC.mother = $missingParentID>>
	<<set _missingID = 1>>
<</if>>
<<if $PC.father == _ID>>
	<<set $PC.father = $missingParentID>>
	<<set _missingID = 1>>
<</if>>
<<if $PC.sisters > 0>>
	<<if areSisters($PC, $activeSlave) > 0>>
		<<set $PC.sisters-->>
	<</if>>
<</if>>
<<if $PC.daughters > 0>>
	<<if $activeSlave.father == -1 || $activeSlave.mother == -1>>
		<<set $PC.daughters-->>
	<</if>>
<</if>>

<<if _x >= 0 && _x < _SL>>
	<<for _y = 0; _y < _SL; _y++>>
		<<if _ID == $slaves[_y].pregSource>>
			<<set $slaves[_y].pregSource = 0>>
		<</if>>
		<<if $activeSlave.daughters > 0>>
			<<if $slaves[_y].mother == _ID>>
				<<set $slaves[_y].mother = $missingParentID>>
			<</if>>
			<<if $slaves[_y].father == _ID>>
				<<set $slaves[_y].father = $missingParentID>>
			<</if>>
			<<if $incubator > 0>>
				<<for _z = 0; _z < $tanks.length; _z++>>
					<<if _ID == $tanks[_z].mother>>
						<<set $tanks[_z].mother = $missingParentID>>
					<</if>>
					<<if _ID == $tanks[_z].father>>
						<<set $tanks[_z].father = $missingParentID>>
					<</if>>
				<</for>>
			<</if>>
			<<set _missingID = 1>>
		<</if>>
		<<if $activeSlave.mother > 0 || $activeSlave.father > 0>>
			<<if $activeSlave.mother == $slaves[_y].ID || $activeSlave.father == $slaves[_y].ID>>
				<<set $slaves[_y].daughters-->>
			<</if>>
		<</if>>
		<<if $activeSlave.sisters > 0>>
			<<if areSisters($activeSlave, $slaves[_y]) > 0>>
				<<set $slaves[_y].sisters-->>
			<</if>>
		<</if>>
		<<if $slaves[_y].ID == $activeSlave.relationTarget>>
			<<set $slaves[_y].relation = 0, $slaves[_y].relationTarget = 0>>
		<</if>>
		<<if $slaves[_y].milkSource != 0>>
			<<if $slaves[_y].milkSource == _ID>>
				<<set $slaves[_y].milkSource =0, $slaves[_y].inflation = 0, $slaves[_y].inflationType = "none", $slaves[_y].inflationMethod = 0>>
			<</if>>
		<</if>>
		<<if $slaves[_y].cumSource != 0>>
			<<if $slaves[_y].cumSource == _ID>>
				<<set $slaves[_y].cumSource = 0, $slaves[_y].inflation = 0, $slaves[_y].inflationType = "none", $slaves[_y].inflationMethod = 0>>
			<</if>>
		<</if>>
		<<if $slaves[_y].ID == $activeSlave.relationshipTarget>>
			<<set $slaves[_y].relationship = 0, $slaves[_y].relationshipTarget = 0>>
		<</if>>
		<<if $slaves[_y].ID == $activeSlave.rivalryTarget>>
			<<set $slaves[_y].rivalry = 0, $slaves[_y].rivalryTarget = 0>>
		<</if>>
	<</for>>

	/* remove from Pit fighters list, if needed */
	<<set $fighterIDs.delete(_ID)>>

	/* remove from Coursing Association, if needed */
	<<if $Lurcher != 0 && $Lurcher.ID == _ID>>
		<<set $Lurcher = 0>>
	<</if>>

	<<if _ID == $personalAttention>>
		<<if $PC.career == "escort">>
			<<set $personalAttention = "whoring">>
		<<elseif $PC.career == "servant">>
			<<set $personalAttention = "upkeep">>
		<<else>>
			<<set $personalAttention = "business">>
		<</if>>
	<</if>>

	/% Remove from facility array or leadership role, if needed %/
	<<removeJob $activeSlave $activeSlave.assignment>>

	<<set _o = $organs.findIndex(function(s) { return s.ID == $activeSlave.ID; })>>
	<<if _o != -1>>
		<<set $organs.deleteAt(_o)>>
	<</if>>
	<<set _o = $limbs.findIndex(function(s) { return s.ID == $activeSlave.ID; })>>
	<<if _o != -1>>
		<<set $limbs.deleteAt(_o)>>
	<</if>>
	
	<<set _dump = $slaves.deleteAt(_x), _SL--, $activeSlave = 0>>
	
	<<if _missingID == 1>>
		<<set $missingParentID-->>
	<</if>>
<</if>>
