diff --git a/devNotes/Useful JS Function Documentation.txt b/devNotes/Useful JS Function Documentation.txt index 65831888e7235dae8158fdc1d867b42933920385..0bf3273d18366301b75c1efb80e23d3eda189649 100644 --- a/devNotes/Useful JS Function Documentation.txt +++ b/devNotes/Useful JS Function Documentation.txt @@ -24,6 +24,8 @@ TatScore(slave) - Returns int representing degree of tattooing. Higher means mor canImproveIntelligence(slave) - Returns if slave intelligence can be improved with Psychostimulants +canImproveHeight(slave) - Returns if slave height can be improved with growth stimulants + sameAssignmentP(slave, slave) - Returns if slaves are on the same assignment. haveRelationP(slave1, slave2) - Returns if slave1 is related to second slave2. (NOT extended family mode compliant). diff --git a/src/facilities/nursery/childInteract.tw b/src/facilities/nursery/childInteract.tw index 2f0b3b13de85fcb40ceb422bdc84319b2969452d..cd5b2e7cfbfc9d2cd38fb79ed2c59d645179774c 100644 --- a/src/facilities/nursery/childInteract.tw +++ b/src/facilities/nursery/childInteract.tw @@ -1161,7 +1161,7 @@ FIXME: <</if>> <</if>> <<if $growthStim>> - <<if $activeChild.height < 274 && $activeChild.height < Math.clamp((Height.mean($activeChild) * 1.25),0,274)>> + <<if canImproveHeight($activeChild)>> | <<link "Growth Stimulants">> <<set $activeChild.drugs = "growth stimulants">> <<SlaveInteractDrugs>> diff --git a/src/js/DefaultRules.js b/src/js/DefaultRules.js index aa83b7541b6a4914bdc1e0bffa8c7f99939f4f2e..84bd8cab1febd0b62aa1605695931605be5c64de 100644 --- a/src/js/DefaultRules.js +++ b/src/js/DefaultRules.js @@ -1277,7 +1277,7 @@ window.DefaultRules = (function() { break; case "growth stimulants": - if (!(slave.height < 274 && slave.height < Math.clamp((Height.mean(slave) * 1.25), 0, 274))) { + if (!canImproveHeight(slave)) { flag = false; } break; @@ -1307,8 +1307,7 @@ window.DefaultRules = (function() { break; case "psychostimulants": { - let origIntel = V.genePool.find(s => s.ID === slave.ID).intelligence; - if (!((slave.intelligence < 100) && (slave.intelligence < origIntel + 15))) { + if (!canImproveIntelligence(slave)) { flag = false; } } break; diff --git a/src/js/assayJS.js b/src/js/assayJS.js index c4835e1eba9eca7def98e3c5f48e950c2d060917..156cb431186a41d633178306729427a07e8c5916 100644 --- a/src/js/assayJS.js +++ b/src/js/assayJS.js @@ -12,10 +12,26 @@ window.sameAssignmentP = function sameAssignmentP(A, B) { * @returns {boolean} */ window.canImproveIntelligence = function canImproveIntelligence(slave) { - let origIntel = V.genePool.find(function(s) { return s.ID == slave.ID; }).intelligence - return (slave.intelligence < origIntel+15) && (slave.intelligence < 100) + let origIntel = V.genePool.find(function(s) { return s.ID === slave.ID; }).intelligence; + return (slave.intelligence < origIntel+15) && (slave.intelligence < 100); }; +/** + * @param {App.Entity.SlaveState} slave + * @returns {boolean} + */ +window.canImproveHeight = function canImproveHeight(slave) { + if (slave.height >= 274) { + return false; + } + let maxHeight = Math.trunc(Math.clamp((Height.mean(slave) * 1.25), 0, 274)); /* max achievable height is expected height plus 25% */ + + if (slave.geneticQuirks.dwarfism === 2 && slave.geneticQuirks.gigantism !== 2) { + maxHeight = Math.min(maxHeight, 160); + } + + return slave.height < maxHeight; +}; /** * @param {App.Entity.SlaveState} slave diff --git a/src/uncategorized/saDrugs.tw b/src/uncategorized/saDrugs.tw index cc4ee86fb15d96969a79ff3ec9a7c67524dcb5df..a2f61e1a4bba3e68735e4b11c719456ca87ebe10 100644 --- a/src/uncategorized/saDrugs.tw +++ b/src/uncategorized/saDrugs.tw @@ -1465,11 +1465,7 @@ /* DRUG EXPIRY */ <<switch $slaves[$i].drugs>> <<case "growth stimulants">> - <<set _maxHeight = Math.trunc(Math.clamp((Height.mean($slaves[$i]) * 1.25),0,274))>> /*max achievable height is expected height plus 25%*/ - <<if $slaves[$i].geneticQuirks.dwarfism == 2 && $slaves[$i].geneticQuirks.gigantism != 2>> - <<set _maxHeight = Math.min(_maxHeight, 160)>> - <</if>> - <<if $slaves[$i].height >= _maxHeight>> + <<if !canImproveHeight($slaves[$i])>> $His body has already grown far past $his natural limits; further injections of stimulants will have no effect. @@.yellow;$His drug regimen has been ended.@@ <<set $slaves[$i].height = Math.clamp($slaves[$i].height,0,_maxHeight), $slaves[$i].drugs = "no drugs">> <</if>> diff --git a/src/uncategorized/saLiveWithHG.tw b/src/uncategorized/saLiveWithHG.tw index 2d27fbaf14d988426b806cedc48e93ba1d1a01cb..28847752d9ddd4960e193c7b9f39cfdcaa2e68b8 100644 --- a/src/uncategorized/saLiveWithHG.tw +++ b/src/uncategorized/saLiveWithHG.tw @@ -883,7 +883,7 @@ <<elseif ($HeadGirl.fetishKnown == 1) && ($HeadGirl.fetish == "cumslut") && $slaves[$i].balls < 10 && $slaves[$i].balls > 0 && $slaves[$i].dick > 0>> $HeadGirl.slaveName gives $slaves[$i].slaveName testicle injections, since _he2 wants $slaves[$i].slaveName shooting bigger loads. <<set $slaves[$i].drugs = "testicle enhancement">> - <<elseif ($HeadGirl.fetishKnown == 1) && ($HeadGirl.fetish == "masochist" || $HeadGirl.fetish == "submissive") && $slaves[$i].geneticQuirks.dwarfism == 2 && $slaves[$i].geneticQuirks.gigantism != 2 && $slaves[$i].height < Math.clamp((Height.mean($slaves[$i]) * 1.25),0,274)>> + <<elseif ($HeadGirl.fetishKnown == 1) && ($HeadGirl.fetish == "masochist" || $HeadGirl.fetish == "submissive") && canImproveHeight($slaves[$i])>> $HeadGirl.slaveName has a subconscious need to be hurt by the biggest, strongest $girl possible, so $he gives $slaves[$i].slaveName injections of growth stimulants to make $him grow taller. <<set $slaves[$i].drugs = "growth stimulants">> <<elseif ($HeadGirl.fetishKnown == 1) && ($HeadGirl.fetish == "boobs") && ($slaves[$i].boobs < 8000)>> diff --git a/src/uncategorized/slaveInteract.tw b/src/uncategorized/slaveInteract.tw index f5276ac54f716a65541bf1ecf2daa1f59f56a568..076fc739f09927e53467dac6c3d95a51bb77f2a9 100644 --- a/src/uncategorized/slaveInteract.tw +++ b/src/uncategorized/slaveInteract.tw @@ -1106,7 +1106,7 @@ <</if>> <</if>> <<if $growthStim == 1>> - <<if ($activeSlave.height < 274 || ($activeSlave.height < 160 && $activeSlave.geneticQuirks.dwarfism == 2 && $activeSlave.geneticQuirks.gigantism != 2)) && $activeSlave.height < Math.clamp((Height.mean($activeSlave) * 1.25),0,274)>> + <<if canImproveHeight($activeSlave)>> | <<link "Growth stimulants">><<set $activeSlave.drugs = "growth stimulants">><<SlaveInteractDrugs>><</link>> <<else>> | Growth stimulants diff --git a/src/utility/miscWidgets.tw b/src/utility/miscWidgets.tw index bc92127207face99afe4770c1761f813156e90e8..f3da165af47a59c3c9c5ca3e04958326f9ced0f0 100644 --- a/src/utility/miscWidgets.tw +++ b/src/utility/miscWidgets.tw @@ -207,7 +207,7 @@ Call as <<SlaveInteractDrugs>> <</if>> <</if>> <<if $growthStim == 1>> - <<if ($activeSlave.height < 274 || ($activeSlave.height < 160 && $activeSlave.geneticQuirks.dwarfism == 2 && $activeSlave.geneticQuirks.gigantism != 2)) && $activeSlave.height < Math.clamp((Height.mean($activeSlave) * 1.25),0,274)>> + <<if canImproveHeight($activeSlave)>> | <<link "Growth Stimulants">><<set $activeSlave.drugs = "growth stimulants">><<SlaveInteractDrugs>><</link>> <<else>> | Growth Stimulants