Skip to content
Snippets Groups Projects
Commit 1b81e6d1 authored by Pregmodder's avatar Pregmodder
Browse files

Merge branch 'fix' into 'pregmod-master'

Ensure that slaves do not die during multiImplant

Closes #834

See merge request pregmodfan/fc-pregmod!4819
parents f1705e61 baf269a8
No related branches found
No related tags found
No related merge requests found
...@@ -5,6 +5,27 @@ You head down to your <<if $surgeryUpgrade == 1>>heavily upgraded and customized ...@@ -5,6 +5,27 @@ You head down to your <<if $surgeryUpgrade == 1>>heavily upgraded and customized
/* builds a list for each slave and adds the appropriate organs to it */ /* builds a list for each slave and adds the appropriate organs to it */
<<for _i = 0; _i < $slaves.length; _i++>> <<for _i = 0; _i < $slaves.length; _i++>>
<<set $activeSlave = $slaves[_i]>> <<set $activeSlave = $slaves[_i]>>
/* count for estimating health impact */
<<set _organCount = $completedOrgans.filter(o => o.ID == $activeSlave.ID).length>>
<<set _prostheticCount = $adjustProsthetics.filter(p => p.slaveID == $activeSlave.ID && p.workLeft <= 0).length>>
/* since we already have count, skip slaves that don't need work */
<<if _organCount + _prostheticCount < 1>>
<<continue>>
<</if>>
/*
Ensures that a slave can never die during the execution of this passage.
Calculation based on worst case, so when changing worst case change it here too.
*/
<<if $activeSlave.health - (_organCount * 40 + _prostheticCount * 20) < -75>>
<br><hr>
@@.red;Estimated health impact too great; $activeSlave.slaveName skipped.@@
<<continue>>
<</if>>
/* start actual work */
<<if _organCount > 0>> /* check _organCount */
<<setLocalPronouns $activeSlave>> <<setLocalPronouns $activeSlave>>
<<set _slaveOrgans = { <<set _slaveOrgans = {
penis: 0, penis: 0,
...@@ -980,19 +1001,16 @@ You head down to your <<if $surgeryUpgrade == 1>>heavily upgraded and customized ...@@ -980,19 +1001,16 @@ You head down to your <<if $surgeryUpgrade == 1>>heavily upgraded and customized
<</if>> <</if>>
<</if>> <</if>>
/* finished checking _slaveOrgans */ /* finished checking _slaveOrgans */
<</if>> /* check _organCount closed */
/* start prosthetics */ /* start prosthetics */
<<if $adjustProstheticsCompleted > 0>> <<if _prostheticCount > 0>>
<<for _k = 0; _k < $adjustProsthetics.length; _k++>> <<for _k = 0; _k < $adjustProsthetics.length; _k++>>
<<set _p = $adjustProsthetics[_k]>> <<set _p = $adjustProsthetics[_k]>>
<<if _p.slaveID == $activeSlave.ID && _p.workLeft <= 0>> <<if _p.slaveID == $activeSlave.ID && _p.workLeft <= 0>>
<<set $adjustProsthetics.splice(_k, 1), _k-->> <<set $adjustProsthetics.splice(_k, 1), _k-->>
<<set $activeSlave.readyProsthetics.push({id: _p.id})>> <<set $activeSlave.readyProsthetics.push({id: _p.id})>>
<br><hr> <br><hr>
<<if $activeSlave.health < -40>>
@@.red;Slave unhealthy: Skipping Slave@@
<<continue>>/* no break so that all prosthetics will be checked */
<</if>>
<<switch _p.id>> <<switch _p.id>>
<<case "ocular">> <<case "ocular">>
<<if $activeSlave.eyes < -1>> <<if $activeSlave.eyes < -1>>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment