diff --git a/devNotes/Useful JS Function Documentation.txt b/devNotes/Useful JS Function Documentation.txt index 38ab1c21a0884244f72b7f94e28bb459cef52e47..4c85aa3bc1b94c90092265880080414451b19365 100644 --- a/devNotes/Useful JS Function Documentation.txt +++ b/devNotes/Useful JS Function Documentation.txt @@ -403,8 +403,6 @@ releaseRestricted - returns true if the slave has some kind of rule limiting the Other Functions: UtilJS [script] - html5passage(passage_function) - circumvents SugarCube, allowing a plain HTML5 UI within it - cmToInchString() - takes an integer e.g. $activeSlave.hLength, returns a string in the format 10 inches cmToFootInchString() - takes an integer e.g. $activeSlave.height, returns a string in the format 6'5" diff --git a/src/Mods/SecExp/buildings/securityHQ.tw b/src/Mods/SecExp/buildings/securityHQ.tw index 923858dec71c985be142530a20243b979f0a45dc..0cbcb456dbc800ab81446d4d1acfc427a4645de6 100644 --- a/src/Mods/SecExp/buildings/securityHQ.tw +++ b/src/Mods/SecExp/buildings/securityHQ.tw @@ -292,7 +292,7 @@ Considering the current upgrades the maximum level of crime is <<print App.SecEx <<if $SecExp.core.authority > 10000>> <<if $SecExp.buildings.secHub.upgrades.readiness.rapidPlatforms == 0>> <br>[[Build rapid deployment platforms|securityHQ][cashX(-Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount), "capEx"), $SecExp.buildings.secHub.upgrades.readiness.rapidPlatforms = 1]] - <br>//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase readiness by 2, but will require 5 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.// + <br>//Costs <<print cashFormat(Math.trunc(10000*$upgradeMultiplierArcology*_HistoryDiscount))>>. Will increase readiness by 2, but will require 10 extra slaves in the headquarters and increases upkeep. The remaining slaves will be more efficient in dealing with crime.// <<else>> <br>You have built rapid deployment platforms able to equip and deploy units within very limited time windows. <</if>> diff --git a/src/Mods/SecExp/js/Unit.js b/src/Mods/SecExp/js/Unit.js index fc260d1845aea941be88b26ef935437eb3c2b0f1..d98249b95d1dd4a71e78061a3187e36597104f47 100644 --- a/src/Mods/SecExp/js/Unit.js +++ b/src/Mods/SecExp/js/Unit.js @@ -150,15 +150,24 @@ App.SecExp.unit = (function() { /** Repairs unit if needed. * @param {object} [input] the unit to be checked. */ - function fixBroken(input) { - input.SF = input.SF || 0; - if (!jsDef(input.ID)) { - input.ID = genID(); + function fixBroken(unit, squad) { + squad.SF = squad.SF || 0; + if (!jsDef(squad.ID)) { + squad.ID = genID(); + } + squad.cyber = squad.cyber || 0; + squad.commissars = squad.commissars || 0; + squad.maxTroops = squad.maxTroops || 30; + squad.troops = Math.clamp(squad.troops, 0, squad.maxTroops); + if (squad.platoonName.contains('undefined')) { + if (unit === 'slaves') { + squad.platoonName = squad.platoonName.replace('undefined', 'slave platoon'); + } else if (unit === 'militia') { + squad.platoonName = squad.platoonName.replace('undefined', "citizens' platoon"); + } else if (unit === 'mercs') { + squad.platoonName = squad.platoonName.replace('undefined', 'mercenary platoon'); + } } - input.cyber = input.cyber || 0; - input.commissars = input.commissars || 0; - input.maxTroops = Math.min(30, input.maxTroops); - input.troops = Math.clamp(input.troops, 0, input.maxTroops); } /** Creates the requested unit object. @@ -175,6 +184,14 @@ App.SecExp.unit = (function() { if (type !== 'slaves') { V.SecExp.units[type].free = V.SecExp.units[type].free || updater.free || 0; } + + if (type === 'slaves') { + V.SecExp.units.slaves.defaultName = V.SecExp.units.slaves.defaultName || "slave platoon"; + } else if (type === 'militia') { + V.SecExp.units.militia.defaultName = V.SecExp.units.militia.defaultName || "citizens' platoon"; + } else if (type === 'mercs') { + V.SecExp.units.mercs.defaultName = V.SecExp.units.mercs.defaultName || "mercenary platoon"; + } } return; } diff --git a/src/Mods/SecExp/js/secExp.js b/src/Mods/SecExp/js/secExp.js index ed05ff7e046ee1415793087cdb27493e1bd7dc83..dd291f5f0044d223dba52a88e274a71d530d7b95 100644 --- a/src/Mods/SecExp/js/secExp.js +++ b/src/Mods/SecExp/js/secExp.js @@ -724,7 +724,7 @@ App.SecExp.battle = (function() { * @returns {number} */ function activeUnits() { - return V.SecExp.units.bots.active + App.SecExp.unit.humanSquads().length; + return (jsDef(V.SecExp.units.bots.active) ? V.SecExp.units.bots.active : 0) + App.SecExp.unit.humanSquads().length; } /** Get maximum active units diff --git a/src/Mods/SecExp/js/secExpBC.js b/src/Mods/SecExp/js/secExpBC.js index cb7bda64b44101245e36bbd39828f13670845be9..618acf65d8395bdd8912c2d678a33711f1def854 100644 --- a/src/Mods/SecExp/js/secExpBC.js +++ b/src/Mods/SecExp/js/secExpBC.js @@ -88,12 +88,10 @@ App.SecExp.generalBC = function() { } App.SecExp.unit.gen('slaves', {count: V.createdSlavesUnits, killed: V.slavesTotalCasualties, squads: V.slaveUnits}); - V.SecExp.units.slaves.defaultName = V.SecExp.units.slaves.defaultName || "slave platoon"; App.SecExp.unit.gen('militia', { count: V.createdMilitiaUnits, killed: V.militiaTotalCasualties, squads: V.militiaUnits, free: V.militiaFreeManpower }); - V.SecExp.units.militia.defaultName = V.SecExp.units.militia.defaultName || "citizens' platoon"; if (jsDef(V.SecExp.defaultNames) && (V.SecExp.defaultNames.milita || V.SecExp.defaultNames.militia)) { V.SecExp.units.militia.defaultName = V.SecExp.defaultNames.milita || V.SecExp.defaultNames.militia; delete V.SecExp.defaultNames.milita; delete V.SecExp.defaultNames.militia; @@ -102,7 +100,6 @@ App.SecExp.generalBC = function() { App.SecExp.unit.gen('mercs', { count: V.createdMercUnits, killed: V.mercTotalCasualties, squads: V.mercUnits, free: V.mercFreeManpower }); - V.SecExp.units.mercs.defaultName = V.SecExp.units.mercs.defaultName || "mercenary platoon"; if (V.SecExp.units.mercs.free === 0) { if (V.mercenaries === 1) { V.SecExp.units.mercs.free = 15; @@ -111,8 +108,10 @@ App.SecExp.generalBC = function() { } } - for (const squad of App.SecExp.unit.humanSquads()) { - App.SecExp.unit.fixBroken(squad); + for (const unit of App.SecExp.unit.list().slice(1)) { + for (const squad of V.SecExp.units[unit].squads) { + App.SecExp.unit.fixBroken(unit, squad); + } } if (V.SecExp.defaultNames) { diff --git a/src/Mods/SecExp/js/securityReport.js b/src/Mods/SecExp/js/securityReport.js index 8a7ee5f3cdefbd59afa6460868b075015062c068..cd09fdd56205eb3b3e0f7e35a5b759b6f2ed86c3 100644 --- a/src/Mods/SecExp/js/securityReport.js +++ b/src/Mods/SecExp/js/securityReport.js @@ -508,6 +508,10 @@ App.SecExp.securityReport = function() { } } } + + if (V.SecExp.settings.battle.enabled > 0) { + App.SecExp.generator.attack(); + } const frag = new DocumentFragment(); $(frag).append(...App.Events.spaceSentences(r)); diff --git a/src/Mods/SpecialForce/SpecialForce.js b/src/Mods/SpecialForce/SpecialForce.js index 63742edcebd37cc1d1f4ca3969f5c7a79edc1c84..5baccbb55ea4d8145856a443ef0e40edc1d3fd01 100644 --- a/src/Mods/SpecialForce/SpecialForce.js +++ b/src/Mods/SpecialForce/SpecialForce.js @@ -1443,6 +1443,7 @@ App.SF.AAR = function(endWeekCall = 1) { r += `<br>These activities have, overall, <span class='green'>improved your arcology's prosperity.</span>`; r += ` The goods procured by ${V.SF.Lower} after accounting for the spoils retained by individual soldiers were `; + V.SF.lastWeeksProfit = V.SF.lastWeeksProfit || 1; if (profit > 0) { r += `<span class='green'>more than sufficient to cover expenses.</span> Excess material and human assets totaling <span class='yellowgreen'>${cashFormat(profit)}</span> (after liquidation) and paying expenses were transferred to your accounts.`; if (V.economy < 100) { @@ -1452,6 +1453,8 @@ App.SF.AAR = function(endWeekCall = 1) { r += `<span class='red'>barely enough to cover expenses.</span> More growth will be needed to ensure profitability, <span class='yellow'>hopefully purchasing more upgrades will help.</span>`; r += ` Per the estimates that ${App.SF.SFC()} provides, an additional <span class='yellowgreen'>${cashFormat(profit)}</span> is required for sufficient cover.`; } + r += `An difference of ${profit/V.SF.lastWeeksProfit}% since last week`; + V.SF.lastWeeksProfit = profit; r += ` ${capSF} managed to recruit ${FNG} new soldiers this week, and your reputation has <span class='green'>increased through the improvement of trade security.</span>`; r += `<h3>Your instructions to ${App.SF.SFC()}:</h3>`; diff --git a/src/Mods/SpecialForce/WeeklyChoices.tw b/src/Mods/SpecialForce/WeeklyChoices.tw index f4295fb8b0cbaad016f44122ae056305d5583592..82eb5a01dfb9fde87b6c7d29cd3d50d8afd4e283 100644 --- a/src/Mods/SpecialForce/WeeklyChoices.tw +++ b/src/Mods/SpecialForce/WeeklyChoices.tw @@ -67,11 +67,15 @@ <span id="result3"> <br><br>What do you want to do with The Colonel in the HQ? <br><<link "Talk" "Firebase">> - <<set $SF.Colonel.Talk = 2, $SF.Colonel.Status += 3, $SF.FS.Tension -= _colonelTalkTensionRuction>> + <<replace "#result3">> + <<set $SF.Colonel.Talk = 2, $SF.Colonel.Status += 3, $SF.FS.Tension -= _colonelTalkTensionRuction>> + <</replace>> <</link>> <br><<link "Learn" "Firebase">> - <<set $SF.Colonel.Talk = 3,$SF.Colonel.Status += 1, $SF.FS.Tension -= _colonelTalkTensionRuction>> + <<replace "#result3">> + <<set $SF.Colonel.Talk = 3,$SF.Colonel.Status += 1, $SF.FS.Tension -= _colonelTalkTensionRuction>> + <</replace>> <</link>> <<if $SF.Colonel.Status >= 45>> <br> diff --git a/src/npc/surgery/bodySwap/bodySwap.js b/src/npc/surgery/bodySwap/bodySwap.js index e2542c084a676f6711a6e81ec2aa23d09a0813c7..ee9e342304bafc05e2b98066e0f474833236ef21 100644 --- a/src/npc/surgery/bodySwap/bodySwap.js +++ b/src/npc/surgery/bodySwap/bodySwap.js @@ -144,7 +144,7 @@ globalThis.bodySwap = function(soul, body, fromGenepool) { soul.haircuts = body.haircuts; soul.ovaryAge = body.ovaryAge; soul.readyOva = body.readyOva; - soul.womb = body.womb; // this is array assigned by reference, if slave body that is ${body} will be still used anywhere in code (not discarded) — it's WRONG (they now technically share one womb object). Please tell me about it then. But if old body body just discarded — it's no problem then. + soul.womb = body.womb; // this is array assigned by reference, if the slave body that is ${body} will be still used anywhere in code (not discarded) — it's WRONG (they now technically share one womb object). Please tell me about it then. But if the previous slave body is just discarded — it's no problem then. soul.pregAdaptation = body.pregAdaptation; soul.geneMods = body.geneMods; soul.NCSyouthening = body.NCSyouthening; diff --git a/src/uncategorized/scheduledEvent.tw b/src/uncategorized/scheduledEvent.tw index a3e1f99e31e51562dd44c08f9dd459393e88a8df..3c89102b59a279e15d5abfcb7e000c647865c36e 100644 --- a/src/uncategorized/scheduledEvent.tw +++ b/src/uncategorized/scheduledEvent.tw @@ -75,15 +75,11 @@ <<set $fcnn.push("...evidence of a planned slave uprising, executed all of their arcology's several thousand...")>> <</if>> -<<if $secExpEnabled > 0 && $SecExp.settings.battle.enabled > 0>> - <<= App.SecExp.generator.attack()>> -<</if>> - <<if $rivalOwner == -1>> <<goto "P rival initiation">> <<elseif $secExpEnabled > 0 && $foughtThisWeek === 0 && ($slaveRebellion === 1 || $citizenRebellion === 1)>> <<goto "rebellionOptions">> -<<elseif $secExpEnabled > 0 && $foughtThisWeek === 0 && $attackThisWeek == 1>> +<<elseif $secExpEnabled > 0 && $foughtThisWeek === 0 && jsDef($SecExp.war)>> <<goto "attackOptions">> <<elseif $PC.labor == 1>> <<goto "SE Player Birth">>