# npcbreeder

!! Expects Args0 of a boy and Args1 of Girl
$breedboyl = mid($ARGS[0],1,1)
breedboyn = mid($ARGS[0], 2)
$breedgrll = mid($ARGS[1],1,1)
breedgrln = mid($ARGS[1], 2)

!! {Identifying the male potency.}
if $breedboyl = 'A':
	breedtemp[0] = Astat_spermpot[breedboyn]
elseif $breedboyl = 'B':
	breedtemp[0] = Bstat_spermpot[breedboyn]
elseif $breedboyl = 'C':
	breedtemp[0] = Cstat_spermpot[breedboyn]
end

!! {Exiting for impotent or different species.}
if breedtemp[0] <= 0: exit

!! {Identifying the female fertility.}
if $breedgrll = 'A':
	if Astat_fert[breedgrln] ! 1: exit
	breedtemp[1] = Astat_cyc[breedgrln]
	breedtemp[4] = year - ((Astat_dob[breedgrln] - (Astat_dob[breedgrln] mod 10000)) / 10000)
elseif $breedgrll = 'B':
	if Bstat_fert[breedgrln] ! 1: exit
	Bstat_cyc[breedgrln] = breedtemp[1]
	breedtemp[4] = year - ((Astat_dob[breedgrln] - (Astat_dob[breedgrln] mod 10000)) / 10000)
elseif $breedgrll = 'C':
	if Cstat_fert[breedgrln] ! 1: exit
	Cstat_cyc[breedgrln] = breedtemp[1]
	breedtemp[4] = year - ((Astat_dob[breedgrln] - (Astat_dob[breedgrln] mod 10000)) / 10000)
end
!! {Culling the very young}
if breedtemp[4] < 9: exit

!! {Setting Risk of pregnancy. Roughly 1/3 at 300, 1/900 at 1.}
!! {Initial risk is determined by cycle status. 15-16 is "ovulated" and therefore perfect chance.}
if breedtemp[1] > 24 or breedtemp[1] < 7:
	breedtemp[2] = 1
elseif breedtemp[1] > 17 or breedtemp[1] < 9:
	breedtemp[2] = 5
elseif breedtemp[1] = 9:
	breedtemp[2] = 10
elseif breedtemp[1] = 10:
	breedtemp[2] = 50
elseif breedtemp[1] = 11 or breedtemp[1] > 16:
	breedtemp[2] = 100
elseif breedtemp[1] = 12:
	breedtemp[2] = 200
elseif breedtemp[1] = 13:
	breedtemp[2] = 250
elseif breedtemp[1] = 14:
	breedtemp[2] = 280
else
	breedtemp[2] = 300
end
!! {Adjusting risk of pregnancy based on age. 1% change for each year, with a mean of 26.}
breedtemp[4] = 26 - breedtemp[4]
breedtemp[4] = (breedtemp[2] / 100) * breedtemp[4]
!! {Final chance calcuation}
breedtemp[3] = (breedtemp[0] * (breedtemp[2] + breedtemp[4])

!! {Checking if she got knocked up, and setting the stats if she did.}
if rand(0,9000000) < breedtemp[3]
	if $breedgrll = 'A':
		Astat_fert[breedgrln] = 5
		Astat_cyc[breedgrln] = 1
		$Astat_kidpater[breedgrln] = $ARGS[0]
	elseif $breedgrll = 'B':
		Bstat_fert[breedgrln] = 5
		Bstat_cyc[breedgrln] = 1
		$Bstat_kidpater[breedgrln] = $ARGS[0]
	elseif $breedgrll = 'C':
		Cstat_fert[breedgrln] = 5
		Cstat_cyc[breedgrln] = 1
		$Cstat_kidpater[breedgrln] = $ARGS[0]
	end
end

killvar '$breedgrll'
killvar 'breedgrln'
killvar '$breedboyl'
killvar 'breedboyn'
killvar 'breedtemp'

--- npcbreeder ---------------------------------

