From 26097a1248b7909393377a5f7fe081e7f87a1e16 Mon Sep 17 00:00:00 2001 From: humungusluver <82497-humungusluver@users.noreply.gitgud.io> Date: Mon, 10 Feb 2025 21:41:25 -0500 Subject: [PATCH 1/2] add way to dispatch preg events into saPregnancy and add preg chance scaling to whoring and public sluts --- src/endWeek/saPregnancy.js | 31 +++++++++++++++++------------ src/endWeek/saServeThePublic.js | 29 +++++++++++++++++++++++++++ src/endWeek/saSharedVariables.js | 34 ++++++++++++++++++++++++++++++++ src/endWeek/saWhore.js | 29 +++++++++++++++++++++++++++ 4 files changed, 110 insertions(+), 13 deletions(-) diff --git a/src/endWeek/saPregnancy.js b/src/endWeek/saPregnancy.js index cbb57dcb8d0..548bfcf03b1 100644 --- a/src/endWeek/saPregnancy.js +++ b/src/endWeek/saPregnancy.js @@ -797,7 +797,10 @@ App.SlaveAssignment.pregnancy = function saPregnancy(slave) { if (isFertile(slave)) { needToBreed(slave); } - if (canGetPregnant(slave) && ((slave.assignment === Job.DAIRY && V.dairyPregSetting === 0) || slave.assignment !== Job.DAIRY)) { + const pregEvent = App.EndWeek.saVars.getRandomPregEvent(slave); + if (canGetPregnant(slave) && pregEvent) { + runPregEvent(pregEvent.fatherId, pregEvent.message, pregEvent.callback); + } else if (canGetPregnant(slave) && ((slave.assignment === Job.DAIRY && V.dairyPregSetting === 0) || slave.assignment !== Job.DAIRY)) { impregnation(slave); } if (slave.ovaImplant === OvaryImplantType.ASEXUAL && isFertile(slave) && (slave.preg === 0 || (slave.preg >= 0 && slave.geneticQuirks.superfetation === 2))) { @@ -842,6 +845,19 @@ App.SlaveAssignment.pregnancy = function saPregnancy(slave) { } } + /** + * @param {number} fatherId + * @param {string} message + * @param {(slave: FC.SlaveState) => void | undefined} callback + */ + function runPregEvent(fatherId, message, callback) { + r.push(message); + knockMeUp(slave, 100, 2, fatherId); + if (callback) { + callback(slave); + } + } + /** * @param {FC.SlaveState} slave */ @@ -1984,18 +2000,7 @@ App.SlaveAssignment.pregnancy = function saPregnancy(slave) { case Job.PUBLIC: case Job.WHORE: case Job.BROTHEL: - if (slave.eggType === "human") { - if (slave.pregKnown === 0) { - r.push(`Due to all the citizens cumming in ${his} fertile`); - if (slave.mpreg === 1) { - r.push(`ass,`); - } else { - r.push(`pussy,`); - } - r.push(`<span class="pregnant">${he} has become pregnant.</span>`); - } - knockMeUp(slave, 100, 2, -2); - } + // Handled now via preg events within their respective RAs. break; case Job.GLORYHOLE: case Job.ARCADE: diff --git a/src/endWeek/saServeThePublic.js b/src/endWeek/saServeThePublic.js index 0ae79ae25b8..5228182ea26 100644 --- a/src/endWeek/saServeThePublic.js +++ b/src/endWeek/saServeThePublic.js @@ -45,6 +45,7 @@ App.SlaveAssignment.serveThePublic = function saServeThePublic(slave) { if (V.showVignettes === 1) { assignmentVignette(slave); } + pregnancy(slave); return r; @@ -1571,4 +1572,32 @@ App.SlaveAssignment.serveThePublic = function saServeThePublic(slave) { } } } + + /** + * Checks for pregnancy + * @param {FC.SlaveState} slave + */ + function pregnancy(slave) { + if (!canGetPregnant(slave) || slave.eggType !== "human") { + return; + } + const fertileUseCount = slave.mpreg === 1 ? analUse : vaginalUse; + if (fertileUseCount < 1) { + return; + } + const pregChance = Math.log(fertileUseCount + 1) * (V.reproductionFormula ? 10 : 7.5); + if (jsRandom(0, 99) < pregChance) { + let citizenDesc = `a citizen`; + if (fertileUseCount > 100) { + citizenDesc = `masses of citizens`; + } else if (fertileUseCount > 50) { + citizenDesc = `a great deal of citizens`; + } else if (fertileUseCount > 10) { + citizenDesc = `several citizens`; + } else if (fertileUseCount > 1) { + citizenDesc = `citizens`; + } + App.EndWeek.saVars.addPregEvent(slave, -2, `Due to ${citizenDesc} cumming in ${his} fertile ${slave.mpreg === 1 ? anusDesc(slave, true) : vaginaDesc(slave, true)}, <span class="pregnant">${he} has become pregnant.</span>`); + } + } }; diff --git a/src/endWeek/saSharedVariables.js b/src/endWeek/saSharedVariables.js index 6f3c5f18b69..a5d7605ebb3 100644 --- a/src/endWeek/saSharedVariables.js +++ b/src/endWeek/saSharedVariables.js @@ -73,6 +73,14 @@ App.EndWeek.SASharedVariables = class { this.facilitySpots = { servantsQuarters: 0 }; + /** + * Object that stores pregnancy events from the Slave Assignment reports report to use in saPregnancy. + * Can store multiple events and will randomly pick one. + * Key of the object should be the slave id. + * Includes an optional callback that can be used to increment sex act counts or update stats. + * @type {{[key: number]: { message: string, fatherId: number, callback: (slave: FC.SlaveState) => void | undefined }[]}} + */ + this.pregnancy = {}; } /** Compute shared subslave ratio (subslaves per ordinary slave) */ @@ -84,4 +92,30 @@ App.EndWeek.SASharedVariables = class { } return subCount / (V.dormitoryPopulation + V.roomsPopulation - subCount); } + + /** + * Helper to add a preg event to the facility pregnancy object. + * @param {FC.SlaveState} slave + * @param {number} fatherId + * @param {string} message + * @param {(slave: FC.SlaveState) => void | undefined} callback + */ + addPregEvent(slave, fatherId, message, callback=undefined) { + if (this.pregnancy[slave.ID]) { + this.pregnancy[slave.ID] = [...this.pregnancy[slave.ID], {message, fatherId, callback}]; + } else { + this.pregnancy[slave.ID] = [{message, fatherId, callback}]; + } + } + + /** + * @param {FC.SlaveState} slave + */ + getRandomPregEvent(slave) { + const events = this.pregnancy[slave.ID]; + if (!events) { + return null; + } + return jsEither(events); + } }; diff --git a/src/endWeek/saWhore.js b/src/endWeek/saWhore.js index 8ce549723f7..c6ec805db23 100644 --- a/src/endWeek/saWhore.js +++ b/src/endWeek/saWhore.js @@ -53,6 +53,7 @@ App.SlaveAssignment.whore = function(slave) { if (V.showVignettes === 1) { assignmentVignette(slave); } + pregnancy(slave); return r; @@ -1661,4 +1662,32 @@ App.SlaveAssignment.whore = function(slave) { incomeStats.rep += Math.trunc(FuckResult * vignette.effect * 0.1); } } + + /** + * Checks for pregnancy + * @param {FC.SlaveState} slave + */ + function pregnancy(slave) { + if (!canGetPregnant(slave) || slave.eggType !== "human") { + return; + } + const fertileUseCount = slave.mpreg === 1 ? analUse : vaginalUse; + if (fertileUseCount < 1) { + return; + } + const pregChance = Math.log(fertileUseCount + 1) * (V.reproductionFormula ? 10 : 7.5); + if (jsRandom(0, 99) < pregChance) { + let customerDesc = `a customer`; + if (fertileUseCount > 100) { + customerDesc = `scores of customers`; + } else if (fertileUseCount > 50) { + customerDesc = `many customers`; + } else if (fertileUseCount > 10) { + customerDesc = `several customers`; + } else if (fertileUseCount > 1) { + customerDesc = `customers`; + } + App.EndWeek.saVars.addPregEvent(slave, -2, `Due to ${customerDesc} cumming in ${his} fertile ${slave.mpreg === 1 ? anusDesc(slave, true) : vaginaDesc(slave, true)}, <span class="pregnant">${he} has become pregnant.</span>`); + } + } }; -- GitLab From 2be5ff413656d288dbe1933d0c7959c3c8f116fe Mon Sep 17 00:00:00 2001 From: humungusluver <82497-humungusluver@users.noreply.gitgud.io> Date: Tue, 11 Feb 2025 07:59:50 -0500 Subject: [PATCH 2/2] update preg event to priortize universal rules --- src/endWeek/saPregnancy.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/endWeek/saPregnancy.js b/src/endWeek/saPregnancy.js index 548bfcf03b1..fefa6200480 100644 --- a/src/endWeek/saPregnancy.js +++ b/src/endWeek/saPregnancy.js @@ -797,10 +797,7 @@ App.SlaveAssignment.pregnancy = function saPregnancy(slave) { if (isFertile(slave)) { needToBreed(slave); } - const pregEvent = App.EndWeek.saVars.getRandomPregEvent(slave); - if (canGetPregnant(slave) && pregEvent) { - runPregEvent(pregEvent.fatherId, pregEvent.message, pregEvent.callback); - } else if (canGetPregnant(slave) && ((slave.assignment === Job.DAIRY && V.dairyPregSetting === 0) || slave.assignment !== Job.DAIRY)) { + if (canGetPregnant(slave) && ((slave.assignment === Job.DAIRY && V.dairyPregSetting === 0) || slave.assignment !== Job.DAIRY)) { impregnation(slave); } if (slave.ovaImplant === OvaryImplantType.ASEXUAL && isFertile(slave) && (slave.preg === 0 || (slave.preg >= 0 && slave.geneticQuirks.superfetation === 2))) { @@ -913,6 +910,8 @@ App.SlaveAssignment.pregnancy = function saPregnancy(slave) { } /** + * Priority is universal rules -> pregEvent from SAs if present -> general preg logic + * * @param {FC.SlaveState} slave */ function impregnation(slave) { @@ -920,6 +919,7 @@ App.SlaveAssignment.pregnancy = function saPregnancy(slave) { let Stud = getSlave(V.StudID); // May be undefined! const studIgnoresRules = (Stud && V.universalRulesImpregnation === "Stud" && Stud.career === "a breeding bull" && Stud.fetish === Fetish.MINDBROKEN && canMove(Stud)); const pussy = (slave.mpreg === 1 ? "asspussy" : "pussy"); + const impregEvent = App.EndWeek.saVars.getRandomPregEvent(slave); let satisfiedPregFetish = 0; let StudVaginal = 0; let rapeAddsFlaw = 0; @@ -1947,6 +1947,8 @@ App.SlaveAssignment.pregnancy = function saPregnancy(slave) { } else { knockMeUp(slave, 100, 2, -2); } + } else if (impregEvent) { + runPregEvent(impregEvent.fatherId, impregEvent.message, impregEvent.callback); } else if (conceptionSeed > (50 - (V.reproductionFormula * 10))) { switch (slave.assignment) { case Job.REST: -- GitLab