From b0ccbb209af209f1580e2ac2b3d828eaa4043a15 Mon Sep 17 00:00:00 2001 From: Jones <Jones> Date: Sat, 21 Dec 2019 13:10:54 +0100 Subject: [PATCH] Documentation, fixes, turning stuff on --- devNotes/Useful JS Function Documentation.txt | 13 +++++ slave variables documentation - Pregmod.txt | 33 ++++++++++++- src/endWeek/illness.js | 47 +++++++++++++------ src/uncategorized/fullReport.tw | 3 +- src/uncategorized/saLongTermEffects.tw | 2 + src/uncategorized/slaveAssignmentsReport.tw | 1 + 6 files changed, 82 insertions(+), 17 deletions(-) diff --git a/devNotes/Useful JS Function Documentation.txt b/devNotes/Useful JS Function Documentation.txt index 602967b8311..0ad822b466e 100644 --- a/devNotes/Useful JS Function Documentation.txt +++ b/devNotes/Useful JS Function Documentation.txt @@ -287,6 +287,19 @@ UtilJS [script] getSlaveTrustClass(slave) - returns the trust of the target as text. e.g. if (slave.trust < -95) return 'extremely-terrified'; +Health Functions: + +setHealth(slave, condition, shortDamage, longDamage, illness, tired) - Sets the health (primarily) of new slaves, it helps ensure the desired values do not immediately kill the slave and corrects them if needed + +improveCondition(slave, value) - Basic way to improve the health of a slave, this updates the slave's 'condition' value and their overall 'health' value. + +healthDamage(slave, value) - Basic way to reduce the health of a slave, this updates the slave's 'shortDamage' value and their overall 'health' value. + +healthPenalty(slave) - Checks illness and tired state in order to provide the slave with a productivity penalty. + +illness(slave) - A start of the 'end week loop' function to see if a slave has gotten ill this week, or perhaps recovered, got worse, etc. + +endWeekHealthDamage - An end of the 'end week loop' function to move shortDamage to the appropriate longer term variables and such. Sex Functions: diff --git a/slave variables documentation - Pregmod.txt b/slave variables documentation - Pregmod.txt index 4bd49fb8953..034451081d2 100644 --- a/slave variables documentation - Pregmod.txt +++ b/slave variables documentation - Pregmod.txt @@ -971,9 +971,38 @@ has had facial surgery to reduce age 0 - no 1 - yes -health: +health.condition: -slave's health +slave's general fitness. Ranges from -100 to 100+ + +health.shortDamage: + +slave's accumulated temporary health damage. Healed simply by time, curatives and job with no/light duties. Reduces condition and if large enough also increases longDamage. + +health.longDamage: + +slave's accumulated permanent health damage + +health.illness: + +slave's illness state +0 - Not ill +1 - A little under the weather, not really ill but still a minor penalty which most likely clears up the following week +2 - Slightly ill, small penalty and can be treated at the clinic +3 - ill, medium penalty and can be treated at the clinic +4 - very ill, large penalty and can be treated at the clinic +5 - terribly ill, crippling penalty and can be treated at the clinic + +health.tired: + +slave's level of exhaustion +0 - 50 - No effect +51 - 80 - Tired, small penalty to productivity and increase in devotion/fear +81 - 100 - Exhausted, medium penalty to productivity and increase in devotion/fear + +health.health: + +slave's overall health taking into account condition minus damages -90- - On the edge of death -90 - -51 - Extremely unhealthy -50 - -21 - Unhealthy diff --git a/src/endWeek/illness.js b/src/endWeek/illness.js index 877fb6d6063..72b14dcac5f 100644 --- a/src/endWeek/illness.js +++ b/src/endWeek/illness.js @@ -24,9 +24,9 @@ window.illness = function illness(slave) { } if (random < 6) { // There is always a 5% chance of a slave feeling worse if (H.illness > 0) { - H.illness += 1 + Math.trunc((slave.chem + jsRandom(1, 50) + 15) / 100); // Illness progresses with 1, unless chem > 35, then there's a chance for 2 + H.illness += 1 + Math.trunc((slave.chem / 10 + jsRandom(1, 50) + 15) / 100); // Illness progresses with 1, unless chem > 350, then there's a chance for 2 if (H.illness > 5) { - H.condition -= 20 * (H.illness - 5); // Condition penalty for going over maximum illness, very dangerous + healthDamage(slave, 20 * (H.illness - 5)); // Condition penalty for going over maximum illness, very dangerous H.illness = 5; } } else { @@ -36,13 +36,13 @@ window.illness = function illness(slave) { H.illness -= 1; if (H.illness < 0) { H.illness = 0; - H.condition += 5; + improveCondition(slave, 5); } - } else if ((H.condition - H.longDamage - H.shortDamage * 1.25 + (Math.min(Math.trunc((slave.age - 18) / 3)), 0)) / 3 + random + assignBonus + nurseEffectiveness(slave) < 30 / Math.clamp(slave.curatives + 1, 1, 2)) { // Chance of getting ill 30% at complete default, 20% with a favourable assignment, 15% with curatives or preventatives, 10% with both measures active and a small benefit from effective Nurse screening + } else if ((Math.min(H.condition - H.longDamage - H.shortDamage * 1.25, 50) + (Math.min(Math.trunc((slave.age - 18) / 3)), 0)) / 3 + random + assignBonus + nurseEffectiveness(slave) < 30 / Math.min(slave.curatives + 1, 2)) { // Chance of getting ill 30% at complete default, 20% with a favourable assignment, 15% with curatives or preventatives, 10% with both measures active and a small benefit from effective Nurse screening if (H.illness > 0) { - H.illness += 1 + Math.trunc((slave.chem + jsRandom(1, 50) + 15) / 100); + H.illness += 1 + Math.trunc((slave.chem / 10 + jsRandom(1, 50) + 15) / 100); if (H.illness > 5) { - H.condition -= 20 * (H.illness - 5); + healthDamage(slave, 20 * (H.illness - 5)); H.illness = 5; } } else { @@ -78,7 +78,7 @@ window.healthPenalty = function healthPenalty(slave) { window.getIll = function getIll(slave) { // Once a new illness is rolled this determines how bad it is initially, chem levels seriously increase the chances of a higher initial value const H = slave.health; - const illness = jsRandom(1, 6) + jsRandom(1, 6) + jsRandom(1, 6) - Math.trunc(H.chem / 15); + const illness = jsRandom(1, 6) + jsRandom(1, 6) + jsRandom(1, 6) - Math.trunc(H.chem / 150); if (illness < 4) { H.illness = 5; // 1.8% chance } else if (illness < 5) { @@ -98,7 +98,7 @@ window.nurseEffectiveness = function nurseEffectiveness(slave) { // A better nur const clinicUpgrade = 1; // Creating a purchasable upgrade to increase the amount of slaves the nurse can handle -- TODO const clinicScreening = 1; // Assumes the clinic is set to screening all slaves to improve their chances of staying healthy. Turning it off would allow the nurse to focus on just her patients in the clinic -- TODO if (V.Nurse !== 0) { - let nurseEffectiveness = Math.trunc((V.Nurse.skill.nurse * clinicUpgrade / Math.min((V.CliniciIDs.length * 10 + (V.slaves.length * 2) * clinicScreening), 1)) * 20); + let nurseEffectiveness = Math.trunc((V.Nurse.skill.nurse * clinicUpgrade / Math.max((V.CliniciIDs.length * 10 + (V.slaves.length * 2) * clinicScreening), 1)) * 20); if (H.illness > 1 && slave.assignment === "get treatment in the clinic") { if (nurseEffectiveness < 20) { return nurseEffectiveness; @@ -153,7 +153,7 @@ window.endWeekHealthDamage = function endWeekHealthDamage(slave) { // Run at the chemToShort += 1; } slave.chem -= chemToShort; - H.shortDamage += chemToShort * 2; + H.shortDamage += Math.max(Math.trunc(chemToShort * 0.2), 2); } // dealing with illness @@ -232,8 +232,8 @@ Carcinogens illness > 5 -- 3 11.6% illness > 4 -- 4 2.8% illness = 3 or 4 -- 5 1.8% - Carcinogens substract Math.trunc(chem / 15) from the dice rolls for a max of -6 at >= 90 - There should be a natural decay of carcinogens every week of 10% of the level. But at the price of 2 short term damage per point of chem. + Carcinogens substract Math.trunc(chem / 150) from the dice rolls for a max of -6 at >= 90 + There should be a natural decay of carcinogens every week of 10% of the level. But at the price of 0.2 short term damage per point of chem. Add carcinogen damage to serious medical procedures due to use of potent pharmaceuticals during them. */ @@ -242,6 +242,7 @@ window.tired = function tired(slave) { const H = slave.health; let livingRules = 0; let assignment = 0; + let reward = 0; let muscles; let health; let tiredChange; @@ -259,7 +260,7 @@ window.tired = function tired(slave) { } else if (slave.assignment === "serve in the master suite" || slave.assignment === "please you") { assignment -= normalRandInt(5); // Reduces tired by an average of 5 points while on a relatively easy assignment } else if (slave.assignment === "rest in the spa") { - assignment -= Math.trunc(normalRandInt(40, 3) / (2 - V.spaUpgrade)); // Reduces tired by an average of 20 points while in the spa, 40 points with the upgraded spa + assignment -= normalRandInt(20, 1.5) * (V.spaUpgrade + 1); // Reduces tired by an average of 20 points while in the spa, 40 points with the upgraded spa if (V.Attendant !== 0) { assignment -= Math.trunc(V.Attendant.skill.attendant / 10); // Maximum of 10 extra points of negative tiredness due to attendant skill } @@ -267,6 +268,24 @@ window.tired = function tired(slave) { assignment = normalRandInt(20, 2); // Increases tired by an average of 20 points while on a demanding assignment } + // Rewards + if (V.spaSpots > 0 && slave.assignment !== "rest in the spa" && (slave.rules.reward === "relaxation" || slave.rules.reward === "situational")) { + if (slave.rules.reward === "relaxation") { // Considering the strength of the reward + reward = -2; + } else { + reward = -1; + } + if (slave.devotion > 50) { // Considering how often the slave gets rewarded + reward *= 3; + } else if (slave.devotion > 20) { + reward *= 2; + } else if (slave.devotion < -20 || slave.trust >= -20) { + reward = 0; + } + V.spaSpots -= reward; // Reducing the available space in the spa depending on how often the slave can be found there + reward = Math.min(normalRandInt(reward), 0) * (V.spaUpgrade + 1); + } + // Muscles if (slave.muscles < 50) { muscles = -Math.trunc((slave.muscles / 10) * (1 + normalRandInt(0, 5) / 100)); // Being weak increases tiredness, building muscles eventually reduces tiredness @@ -275,9 +294,9 @@ window.tired = function tired(slave) { } // Health - health = Math.trunc((H.condition / 20 - H.shortDamage / 2) * (1 + normalRandInt(0, 5) / 100)); // Current condition reduces tiredness, health damage increases tiredness + health = Math.trunc((H.shortDamage / 2 - H.condition / 20) * (1 + normalRandInt(0, 5) / 100)); // Current condition reduces tiredness, health damage increases tiredness - tiredChange = livingRules + assignment + muscles + health; + tiredChange = livingRules + assignment + reward + muscles + health; H.tired += tiredChange; }; diff --git a/src/uncategorized/fullReport.tw b/src/uncategorized/fullReport.tw index 3a7d29884a2..5a1b63cc537 100644 --- a/src/uncategorized/fullReport.tw +++ b/src/uncategorized/fullReport.tw @@ -8,6 +8,7 @@ <</if>> /* 000-250-006 */ +<<run illness($slaves[$i])>> <<setLocalPronouns $slaves[$i]>> <<switch $slaves[$i].assignment>> @@ -97,4 +98,4 @@ <</if>> <</for>> -<<include "SA devotion">> +<<include "SA devotion">> \ No newline at end of file diff --git a/src/uncategorized/saLongTermEffects.tw b/src/uncategorized/saLongTermEffects.tw index 6861bfed9a2..85272b27d06 100644 --- a/src/uncategorized/saLongTermEffects.tw +++ b/src/uncategorized/saLongTermEffects.tw @@ -8630,6 +8630,8 @@ <</if>> <</if>> +<<run endWeekHealthDamage($slaves[$i])>> + <<if $slaves[$i].burst == 1>> <<set $burstee = 1>> <<else>> diff --git a/src/uncategorized/slaveAssignmentsReport.tw b/src/uncategorized/slaveAssignmentsReport.tw index 7c1ba7c2a5b..ec1afc6a2d4 100644 --- a/src/uncategorized/slaveAssignmentsReport.tw +++ b/src/uncategorized/slaveAssignmentsReport.tw @@ -792,6 +792,7 @@ $sexDemandResult.topClass = Math.trunc((($NPCSexSupply.topClass + $slaveJobValue <<if $slaves[$i].bellyPain != 0>> <<set $slaves[$i].bellyPain = 0>> <</if>> + /* preg speed and advance*/ <<if $slaves[$i].preg > 0>> -- GitLab