diff --git a/js/003-data/gameVariableData.js b/js/003-data/gameVariableData.js index 03f80e106f913acf671bffe82f6138ee3b2d72f8..bc341f73431f8ae4325ccff78a6a7977c046b0ec 100644 --- a/js/003-data/gameVariableData.js +++ b/js/003-data/gameVariableData.js @@ -447,8 +447,6 @@ App.Data.resetOnNGPlus = { smilingManProgress: 0, investedFunds: 0, relationshipLM: 0, - captureRoute: 0, - collaborationRoute: 0, smilingManWeek: 0, globalCrisisWeeks: 0, smilingManFate: 4, @@ -461,12 +459,8 @@ App.Data.resetOnNGPlus = { citizenRebellionEventFires: 0, slaveRebellion: 0, citizenRebellion: 0, - rebellingUnits: [], engageRule: 0, irregulars: 0, - rebellingMilitia: 0, - rebellingSlaves: 0, - rebellingMercs: 0, repairTime: 3, arcRepairTime: 0, garrison: {}, @@ -493,7 +487,6 @@ App.Data.resetOnNGPlus = { /* battle relevant vars */ slaveVictories: [], - slaveIncreasedPrestige: 0, totalKills: 0, battlesCount: 0, majorBattlesCount: 0, @@ -510,16 +503,9 @@ App.Data.resetOnNGPlus = { battleTurns: 0, tacticsSuccessful: 0, leaderWounded: 0, - /* 0=no wound, 1=mute, 2=blind, 3=amputee, 4=health */ gainedCombat: 0, gainedWarfare: 0, - expectedEquip: 0, - estimatedMen: 0, SFIntervention: 0, - carriableSoldiers: 0, - SFatk: 0, - SFdef: 0, - SFhp: 0, rebellingID: [], saveValid: 0, lastSelection: [], @@ -554,10 +540,6 @@ App.Data.resetOnNGPlus = { PCvictories: 0, PClosses: 0, - /* buildings */ - woundType: 0, - /* 0:no wound, 1:mute, 2:blind, 3:amputee, 4<:health */ - reminderEntry: "", reminderWeek: "", lastWeeksCashIncome: {}, diff --git a/src/Mods/SecExp/SecExpBackwardCompatibility.tw b/src/Mods/SecExp/SecExpBackwardCompatibility.tw index 9629e43a9c7a95b6ad6f85a9859d2f632331cf8f..969ce8f11c87a486d9c69e9762075d730c1e3fcd 100644 --- a/src/Mods/SecExp/SecExpBackwardCompatibility.tw +++ b/src/Mods/SecExp/SecExpBackwardCompatibility.tw @@ -366,12 +366,6 @@ <<if ndef $relationshipLM>> <<set $relationshipLM = 0>> <</if>> -<<if ndef $captureRoute>> - <<set $captureRoute = 0>> -<</if>> -<<if ndef $collaborationRoute>> - <<set $collaborationRoute = 0>> -<</if>> <<if ndef $smilingManWeek>> <<set $smilingManWeek = 0>> <</if>> @@ -404,24 +398,12 @@ <<if ndef $citizenRebellion>> <<set $citizenRebellion = 0>> <</if>> -<<if ndef $rebellingUnits>> - <<set $rebellingUnits = []>> -<</if>> <<if ndef $engageRule>> <<set $engageRule = 0>> <</if>> <<if ndef $irregulars>> <<set $irregulars = 0>> <</if>> -<<if ndef $rebellingMilitia>> - <<set $rebellingMilitia = 0>> -<</if>> -<<if ndef $rebellingSlaves>> - <<set $rebellingSlaves = 0>> -<</if>> -<<if ndef $rebellingMercs>> - <<set $rebellingMercs = 0>> -<</if>> <<if ndef $repairTime>> <<set $repairTime = 3>> <</if>> @@ -527,9 +509,6 @@ <<if ndef $slaveVictories>> <<set $slaveVictories = []>> <</if>> -<<if ndef $slaveIncreasedPrestige>> - <<set $slaveIncreasedPrestige = 0>> -<</if>> <<if ndef $totalKills>> <<set $totalKills = 0>> <</if>> @@ -573,7 +552,7 @@ <<set $tacticsSuccessful = 0>> <</if>> <<if ndef $leaderWounded>> - <<set $leaderWounded = 0>> /* 0=no wound, 1=mute, 2=blind, 3=amputee, 4=health */ + <<set $leaderWounded = 0>> <</if>> <<if ndef $gainedCombat>> <<set $gainedCombat = 0>> @@ -581,27 +560,9 @@ <<if ndef $gainedWarfare>> <<set $gainedWarfare = 0>> <</if>> -<<if ndef $expectedEquip>> - <<set $expectedEquip = 0>> -<</if>> -<<if ndef $estimatedMen>> - <<set $estimatedMen = 0>> -<</if>> <<if ndef $SFIntervention>> <<set $SFIntervention = 0>> <</if>> -<<if ndef $carriableSoldiers>> - <<set $carriableSoldiers = 0>> -<</if>> -<<if ndef $SFatk>> - <<set $SFatk = 0>> -<</if>> -<<if ndef $SFdef>> - <<set $SFdef = 0>> -<</if>> -<<if ndef $SFhp>> - <<set $SFhp = 0>> -<</if>> <<if ndef $rebellingID>> <<set $rebellingID = []>> <</if>> diff --git a/src/Mods/SecExp/attackGenerator.tw b/src/Mods/SecExp/attackGenerator.tw index 0a3b0b7c65d205a947becb2c5f46256919fef510..9c9e19961b4a23ef23de86c3dd159cc95354e8bf 100644 --- a/src/Mods/SecExp/attackGenerator.tw +++ b/src/Mods/SecExp/attackGenerator.tw @@ -173,15 +173,4 @@ <</if>> <</if>> <</if>> - - <<set $estimatedMen = Math.round($attackTroops * (1 + either(-1,1) * (random(3,4) - App.SecExp.battle.recon()) * 0.1))>> - <<if App.SecExp.battle.recon() == 3>> - <<set $expectedEquip = $attackEquip + random(-1,1)>> - <<elseif App.SecExp.battle.recon() == 2>> - <<set $expectedEquip = $attackEquip + random(-1,2)>> - <<elseif App.SecExp.battle.recon() == 1>> - <<set $expectedEquip = $attackEquip + random(-2,2)>> - <<else>> - <<set $expectedEquip = $attackEquip + random(-2,3)>> - <</if>> <</if>> \ No newline at end of file diff --git a/src/Mods/SecExp/attackHandler.tw b/src/Mods/SecExp/attackHandler.tw index 10c846cb6b6d27b611d65ca7a78766ff5e444a4e..21134caec5f9fcd3225674bd20f1628b5d1295bc 100644 --- a/src/Mods/SecExp/attackHandler.tw +++ b/src/Mods/SecExp/attackHandler.tw @@ -314,23 +314,6 @@ <<set _mercMod -= 0.2>> <<set _SFMod -= 0.2>> <<set _enemyMod += 0.2>> - <<set $woundType = random(1,10)>> - <<set _i = $slaveIndices[$Bodyguard.ID]>> - <<if $woundType == 1>> - <<set $slaves[_i].voice = 0>> - <<run healthDamage($slaves[$i], 60)>> - <<elseif $woundType == 2>> - <<run eyeSurgery($slaves[_i], "both", "blind"), healthDamage($slaves[$i], 30)>> - <<elseif $woundType == 3>> - <<run removeLimbs($slaves[_i], "all")>> - <<run healthDamage($slaves[$i], 80)>> - <<elseif $woundType >= 4>> - <<if $slaves[_i].health.health >= -60>> - <<run healthDamage($slaves[$i], 30)>> - <<else>> - <<run healthDamage($slaves[$i], -90 - $slaves[$i].health.health)>> - <</if>> - <</if>> <</if>> /* 60% chance of getting combat skill if not already have it */ <<if $Bodyguard.skill.combat == 0 && random(1,100) <= 60>> @@ -439,23 +422,6 @@ <<set _mercMod -= 0.2>> <<set _SFMod -= 0.2>> <<set _enemyMod += 0.2>> - <<set $woundType = random(1,10)>> - <<set _i = $slaveIndices[$HeadGirl.ID]>> - <<if $woundType == 1>> - <<set $slaves[_i].voice = 0>> - <<run healthDamage($slaves[$i], 60)>> - <<elseif $woundType == 2>> - <<set eyeSurgery($slaves[_i], "both", "blind"), healthDamage($slaves[$i], 30)>> - <<elseif $woundType == 3>> - <<run removeLimbs($slaves[_i], "all")>> - <<run healthDamage($slaves[$i], 80)>> - <<elseif $woundType >= 4>> - <<if $slaves[_i].health.health >= -60>> - <<run healthDamage($slaves[$i], 30)>> - <<else>> - <<run healthDamage($slaves[$i], -90 - $slaves[$i].health.health)>> - <</if>> - <</if>> <</if>> /* 60% chance of getting combat skill if not already have it */ <<if $HeadGirl.skill.combat == 0 && random(1,100) <= 60>> @@ -903,13 +869,10 @@ <</for>> <<if $SF.Toggle && $SF.Active >= 1 && $SFIntervention>> - <<set $SFatk = 0>> - <<set $SFdef = 0>> - <<set $SFhp = 0>> - <<run calcSFStatistics()>> - <<set _attack += $SFatk>> - <<set _defense += $SFdef>> - <<set _hp += $SFhp>> + <<set _unit = App.SecExp.getUnit("SF")>> + <<set _attack += _unit.attack>> + <<set _defense += _unit.defense>> + <<set _hp += _unit.hp>> <</if>> /* morale and baseHp calculation */ diff --git a/src/Mods/SecExp/attackOptions.tw b/src/Mods/SecExp/attackOptions.tw index efee7d2cc43bd24fdf76f85be29c55b372aa2669..3f9cf5ba9d181e09cc5c1994fe24246e2a6be603 100644 --- a/src/Mods/SecExp/attackOptions.tw +++ b/src/Mods/SecExp/attackOptions.tw @@ -147,6 +147,8 @@ <</if>> <br><br> __Recon__: +<<set _estimatedMen = normalRandInt($attackTroops, $attackTroops * (4 - App.SecExp.battle.recon()) * 0.05)>> +<<set _expectedEquip = normalRandInt($attackEquip, (4 - App.SecExp.battle.recon()) * 0.25)>> <br> It seems your troops and your adversary will fight <<if $battleTerrain == "rural">> @@ -177,16 +179,16 @@ It seems your troops and your adversary will fight <<else>> Your recon capabilities are almost non-existent. The information collected will be wild guesses at best: <</if>> -approximately <strong><<print $estimatedMen>> men</strong> are coming, they seem to be -<<if $expectedEquip <= 0>> +approximately <strong><<print _estimatedMen>> men</strong> are coming, they seem to be +<<if _expectedEquip <= 0>> <strong>poorly armed</strong>. Old rusty small arms are the norm with just a few barely working civilian vehicles. -<<elseif $expectedEquip == 1>> +<<elseif _expectedEquip == 1>> <strong>lightly armed</strong>, mostly with small arms and some repurposed civilian vehicles with scattered machine gun support. There's no sign of heavy vehicles, artillery or aircraft. -<<elseif $expectedEquip == 2>> +<<elseif _expectedEquip == 2>> <strong>decently armed</strong> with good quality small arms, machine guns and a few mortars. There appear to be some heavy military vehicles coming as well. -<<elseif $expectedEquip == 3>> +<<elseif _expectedEquip == 3>> <strong>well armed</strong> with high quality small arms, snipers, demolitions teams, heavy duty machine guns and mortars. Heavy military vehicles are numerous and a few artillery pieces are accompanying the detachment. -<<elseif $expectedEquip >= 4>> +<<elseif _expectedEquip >= 4>> <strong>extremely well armed</strong> with excellent small arms and specialized teams with heavy duty infantry support weapons. Heavy presence of armored military vehicles, artillery pieces and even some attack helicopters. <</if>> diff --git a/src/Mods/SecExp/attackReport.tw b/src/Mods/SecExp/attackReport.tw index af5af2564a51488ed24bec6bc1949665d83eeb0d..65d8d802a2d4f0c708f50762fa4c6a281439adf2 100644 --- a/src/Mods/SecExp/attackReport.tw +++ b/src/Mods/SecExp/attackReport.tw @@ -14,65 +14,38 @@ <<set _loot = 0>> /* result */ +<<set $battlesCount++>> <<if $majorBattle == 0>> - <<set $battlesCount++>> <<set _majorBattleMod = 1>> - <<if $battleResult == 3>> - <strong>Victory!</strong> - <<set $PClossStreak = 0>> - <<set $PCvictoryStreak += 1>> - <<set $PCvictories++>> - <<elseif $battleResult == -3>> - <strong>Defeat!</strong> - <<set $PClossStreak += 1>> - <<set $PCvictoryStreak = 0>> - <<set $PClosses++>> - <<elseif $battleResult == 2>> - <strong>Partial victory!</strong> - <<set $PCvictories++>> - <<elseif $battleResult == -2>> - <strong>Partial defeat!</strong> - <<set $PClosses++>> - <<elseif $battleResult == -1>> - <strong>We surrendered</strong> - <<set $PClosses++>> - <<elseif $battleResult == 0>> - <strong>Failed bribery!</strong> - <<set $PClosses++>> - <<elseif $battleResult == 1>> - <strong>Successful bribery!</strong> - <<set $PCvictories++>> - <</if>> <<else>> <<set _majorBattleMod = 2>> - <<set $battlesCount++>> <<set $majorBattlesCount++>> - <<if $battleResult == 3>> - <strong>Major victory!</strong> - <<set $PClossStreak = 0>> - <<set $PCvictoryStreak += 1>> - <<set $PCvictories++>> - <<elseif $battleResult == -3>> - <strong>Major Defeat!</strong> - <<set $PClossStreak += 1>> - <<set $PCvictoryStreak = 0>> - <<set $PClosses++>> - <<elseif $battleResult == 2>> - <strong>Partial victory!</strong> - <<set $PCvictories++>> - <<elseif $battleResult == -2>> - <strong>Partial defeat!</strong> - <<set $PClosses++>> - <<elseif $battleResult == -1>> - <strong>We surrendered</strong> - <<set $PClosses++>> - <<elseif $battleResult == 0>> - <strong>Failed bribery!</strong> - <<set $PClosses++>> - <<elseif $battleResult == 1>> - <strong>Successful bribery!</strong> - <<set $PCvictories++>> - <</if>> +<</if>> +<<if $battleResult == 3>> + <strong>Victory!</strong> + <<set $PClossStreak = 0>> + <<set $PCvictoryStreak += 1>> + <<set $PCvictories++>> +<<elseif $battleResult == -3>> + <strong>Defeat!</strong> + <<set $PClossStreak += 1>> + <<set $PCvictoryStreak = 0>> + <<set $PClosses++>> +<<elseif $battleResult == 2>> + <strong>Partial victory!</strong> + <<set $PCvictories++>> +<<elseif $battleResult == -2>> + <strong>Partial defeat!</strong> + <<set $PClosses++>> +<<elseif $battleResult == -1>> + <strong>We surrendered</strong> + <<set $PClosses++>> +<<elseif $battleResult == 0>> + <strong>Failed bribery!</strong> + <<set $PClosses++>> +<<elseif $battleResult == 1>> + <strong>Successful bribery!</strong> + <<set $PCvictories++>> <</if>> <hr> @@ -972,15 +945,18 @@ <<if $gainedCombat == 1>> During the battle, $he had to fight for $his life, giving $him experience in modern combat. $He is now proficient with modern firearms and hand to hand combat. <</if>> - <<if $woundType != 0>> + <<if $leaderWounded == 1>> Unfortunately, @@.red;$he sustained major injuries.@@ - <<if $woundType == 1>> + <<set _woundType = App.SecExp.inflictBattleWound(getSlave($Bodyguard.ID))>> + <<if _woundType == "voice">> A stray bullet hit $his neck. While $he fortunately avoided fatal hemorrhaging, $his vocal cords were irreparably damaged. - <<elseif $woundType == 2>> + <<elseif _woundType == "eyes">> Some shrapnel found $his eyes as their final target, blinding $him permanently. - <<elseif $woundType == 3>> - A grenade landed close to $him, rendering $him a quadruple amputee. - <<elseif $woundType >= 4>> + <<elseif _woundType == "legs">> + A grenade landed close to $him, and $his badly mangled legs had to be amputated. + <<elseif _woundType == "arm">> + A shrapnel blast mangled one of $his arms, which had to be amputated. + <<elseif _woundType == "flesh">> While gravely wounded, it seems $he will be able to fully recover, given enough time. <</if>> Your troops were greatly affected by the loss of their leader. @@ -1003,7 +979,7 @@ <<set $slaves[_j].prestigeDesc = "$He is known as a legendary commander all over the world.">> <</if>> <<set $slaveVictories[_i].victories = 0>> - <<set $slaveIncreasedPrestige = 1>> + $He brought your army to victory so many times that $his @@.green;prestige has increased.@@ <</if>> <</if>> <<break>> @@ -1014,9 +990,6 @@ <<set $slaveVictories.push(_newSlave)>> <</if>> <</if>> - <<if $slaveIncreasedPrestige == 1>> - $He brought your army to victory so many times that $his @@.green;prestige has increased.@@ - <</if>> <<elseif $leadingTroops == "headGirl">> <<setLocalPronouns $HeadGirl>> <<if $auto == 1>>$assistant.name<<else>>You<</if>> decided it will be your Head Girl that leads the troops. @@ -1109,15 +1082,18 @@ <<if $gainedCombat == 1>> During the battle, $he had to fight for $his life, giving $him experience in modern combat. $He is now proficient with modern firearms and hand to hand combat. <</if>> - <<if $woundType != 0>> - Unfortunately, @@.red;$he sustained severe injuries.@@ - <<if $woundType == 1>> + <<if $leaderWounded == 1>> + Unfortunately, @@.red;$he sustained major injuries.@@ + <<set _woundType = App.SecExp.inflictBattleWound(getSlave($Bodyguard.ID))>> + <<if _woundType == "voice">> A stray bullet hit $his neck. While $he fortunately avoided fatal hemorrhaging, $his vocal cords were irreparably damaged. - <<elseif $woundType == 2>> - Some shrapnel found $his eyes as final their target, blinding $him permanently. - <<elseif $woundType == 3>> - A grenade landed close to $him, rendering $him a quadruple amputee. - <<elseif $woundType >= 4>> + <<elseif _woundType == "eyes">> + Some shrapnel found $his eyes as their final target, blinding $him permanently. + <<elseif _woundType == "legs">> + A grenade landed close to $him, and $his badly mangled legs had to be amputated. + <<elseif _woundType == "arm">> + A shrapnel blast mangled one of $his arms, which had to be amputated. + <<elseif _woundType == "flesh">> While gravely wounded, it seems $he will be able to fully recover, given enough time. <</if>> Your troops were greatly affected by the loss of their leader. @@ -1140,7 +1116,7 @@ <<set $slaves[_j].prestigeDesc = "$He is known as a legendary commander all over the world.">> <</if>> <<set $slaveVictories[_i].victories = 0>> - <<set $slaveIncreasedPrestige = 1>> + $He brought your army to victory so many times that $his @@.green;prestige has increased.@@ <</if>> <</if>> <<break>> @@ -1151,9 +1127,6 @@ <<set $slaveVictories.push(_newSlave)>> <</if>> <</if>> - <<if $slaveIncreasedPrestige == 1>> - $He brought your army to victory so many times that $his @@.green;prestige has increased.@@ - <</if>> <<elseif $leadingTroops == "citizen">> <<if $auto == 1>>$assistant.name<<else>>You<</if>> decided to appoint one of your volunteers as the commander. <<if $arcologies[0].FSDegradationist == "unset" && $arcologies[0].FSPaternalist == "unset">> @@ -1533,8 +1506,6 @@ <<run delete $bribeCost>> <<set $leaderWounded = 0>> <<set $gainedWarfare = 0>> -<<set $slaveIncreasedPrestige = 0>> -<<set $woundType = 0>> <<set $tacticsSuccessful = 0>> <<set $attackType = "none">> <<set $chosenTactic = "none">> diff --git a/src/Mods/SecExp/js/Unit.js b/src/Mods/SecExp/js/Unit.js index cd6bdfa02dc88a5f712005ff65046108295eee0e..db2a025f91ae807fd2866e8c0530c9a38bba5dab 100644 --- a/src/Mods/SecExp/js/Unit.js +++ b/src/Mods/SecExp/js/Unit.js @@ -10,13 +10,15 @@ App.SecExp.generateUnitID = function() { }; /** Player unit factory - get a unit based on its type and index - * @param {string} type - "Bots", "Militia", "Slaves", or "Mercs" + * @param {string} type - "Bots", "Militia", "Slaves", "Mercs", or "SF" * @param {number} [index] - must be supplied if type is not "Bots" * @returns {App.SecExp.Unit} */ App.SecExp.getUnit = function(type, index) { if (type === "Bots") { return new App.SecExp.DroneUnit(V.secBots, App.SecExp.BaseDroneUnit); + } else if (type === "SF") { + return new App.SecExp.SFUnit(); } else if (typeof index !== "number") { throw `Bad index for unit type ${type}: ${index}`; } @@ -467,6 +469,40 @@ App.SecExp.HumanUnit = class SecExpHumanUnit extends App.SecExp.Unit { } }; +App.SecExp.troopsFromSF = function() { + if (V.slaveRebellion !== 1 || V.citizenRebellion !== 1) { + // attack: how many troops can we actually carry? + const transportMax = Math.trunc(125 * (V.SF.Squad.GunS + ((V.SF.Squad.AV + V.SF.Squad.TV)/2))); + return Math.min(transportMax, V.SF.ArmySize); + } else { + // rebellion: transport capabilities are irrelevant + return V.SF.ArmySize; + } +}; + +App.SecExp.SFUnit = class SFUnit extends App.SecExp.Unit { + constructor() { + super(null, App.SecExp.BaseSpecialForcesUnit); + this._distancePenalty = (V.slaveRebellion !== 1 || V.citizenRebellion !== 1) ? 0.10 : 0.0; + } + + get attack() { + // ignores base attack? weird. + const attackUpgrades = V.SF.Squad.Armoury + V.SF.Squad.Drugs + V.SF.Squad.AA + V.SF.Squad.AV; + return (0.75 - this._distancePenalty) * attackUpgrades; + } + + get defense() { + // ignores base defense? weird. + const defenseUpgrades = V.SF.Squad.Armoury + V.SF.Squad.Drugs + (V.SF.Squad.AA + V.SF.Squad.TA) / 2 + (V.SF.Squad.AV + V.SF.Squad.TV) / 2; + return (0.5 - this._distancePenalty) * defenseUpgrades; + } + + get hp() { + return this._baseUnit.hp * App.SecExp.troopsFromSF(); + } +}; + App.SecExp.EnemyUnit = class SecExpEnemyUnit extends App.SecExp.Unit { /** @param {FC.SecExp.UnitData} data * @param {BaseUnit} baseUnit diff --git a/src/Mods/SecExp/js/secExp.js b/src/Mods/SecExp/js/secExp.js index 9469924406dcf9161a58a4093ec47c2ccea450ff..d58a4381715773d2f4a484239122ff0d97ba5c20 100644 --- a/src/Mods/SecExp/js/secExp.js +++ b/src/Mods/SecExp/js/secExp.js @@ -211,7 +211,7 @@ App.SecExp.conflict = (function() { } countHumanTroops((u) => u.isDeployed === 1); if (V.SF.Toggle && V.SF.Active >= 1 && V.SFIntervention) { - troops += V.carriableSoldiers; + troops += App.SecExp.troopsFromSF(); } } else { if (V.irregulars > 0) { @@ -222,7 +222,7 @@ App.SecExp.conflict = (function() { } countHumanTroops((u) => u.active === 1 && V.loyalID.includes(u.ID)); if (V.SF.Toggle && V.SF.Active >= 1) { - troops += V.carriableSoldiers; + troops += App.SecExp.troopsFromSF(); } } return troops; @@ -904,3 +904,72 @@ App.SecExp.Manpower = { return this.employedMerc + this.employedMilitia + this.employedSlave; } }; + +App.SecExp.inflictBattleWound = (function() { + /** @typedef {object} Wound + * @property {number} weight + * @property {function(App.Entity.SlaveState):boolean} allowed + * @property {function(App.Entity.SlaveState):void} effects + */ + /** @type { Object<string, Wound> } */ + const wounds = { + eyes: { + weight: 10, + allowed: (s) => canSee(s), + effects: (s) => { clampedDamage(s, 30); eyeSurgery(s, "both", "blind"); } + }, + voice: { + weight: 10, + allowed: (s) => canTalk(s), + effects: (s) => { clampedDamage(s, 60); s.voice = 0; } + }, + legs: { + weight: 5, + allowed: (s) => hasAnyNaturalLegs(s), + effects: (s) => { clampedDamage(s, 80); removeLimbs(s, "left leg"); removeLimbs(s, "right leg"); } + }, + arm: { + weight: 5, + allowed: (s) => hasAnyNaturalArms(s), + effects: (s) => { clampedDamage(s, 60); removeLimbs(s, jsEither(["left arm", "right arm"])); } + }, + flesh: { + weight: 70, + allowed: () => true, + effects: (s) => { clampedDamage(s, 30); } + } + // TODO: add more wound types? destroy prosthetics? + }; + + /** Inflicts a large amount of damage upon a slave without killing them (i.e. leaving their health total above -90) + * @param {App.Entity.SlaveState} slave + * @param {number} magnitude + */ + function clampedDamage(slave, magnitude) { + if ((slave.health.health - magnitude) > -90) { + healthDamage(slave, magnitude); + } else { + healthDamage(slave, 90 + slave.health.health); + } + } + + /** Inflicts a wound upon a slave during a battle. Returns the wound type from the wound table (see above) so it can be described. + * @param {App.Entity.SlaveState} slave + * @returns {string} + */ + function doWound(slave) { + let woundHash = {}; + for (const w of Object.keys(wounds)) { + if (wounds[w].allowed(slave)) { + woundHash[w] = wounds[w].weight; + } + } + /** @type {string} */ + // @ts-ignore - FIXME: hashChoice has bad JSDoc + const wound = hashChoice(woundHash); + wounds[wound].effects(slave); + return wound; + } + + return doWound; +})(); diff --git a/src/Mods/SecExp/rebellionGenerator.tw b/src/Mods/SecExp/rebellionGenerator.tw index 715923a49dc7494746df9b45beb29d16df31b670..cb17b7b64985b00b84490a19aa7287f10395511f 100644 --- a/src/Mods/SecExp/rebellionGenerator.tw +++ b/src/Mods/SecExp/rebellionGenerator.tw @@ -306,8 +306,8 @@ <<set _repFactor = Math.clamp($rep / 20000,0.4,0.6)>> <<set _rebelPercent = 0.3 * _authFactor>> <<set _irregularPercent = 0.2 * _repFactor>> - <<set $attackTroops = Math.clamp(Math.trunc($ASlaves * _rebelPercent + random(-100,100)) * _weekMod,50,$ASlaves)>> - <<set $irregulars = Math.clamp(Math.trunc($ACitizens * _irregularPercent + random(-100,100)) * _weekMod,50,$ACitizens)>> + <<set $attackTroops = Math.clamp(Math.trunc($ASlaves * _rebelPercent * _weekMod) + random(-100,100),50,$ASlaves)>> + <<set $irregulars = Math.clamp(Math.trunc($ACitizens * _irregularPercent * _weekMod) + random(-100,100),50,$ACitizens)>> /* calc if units rebel */ <<for _i = 0; _i < $slaveUnits.length; _i++>> <<if $slaveUnits[_i].loyalty < 10>> @@ -376,8 +376,8 @@ <<set _repFactor = Math.clamp($rep / 20000,0.4,0.6)>> <<set _rebelPercent = 0.3 * _authFactor>> <<set _irregularPercent = 0.2 * _repFactor>> - <<set $attackTroops = Math.clamp(Math.trunc($ACitizens * _rebelPercent + random(-100,100)) * _weekMod,50,$ACitizens)>> - <<set $irregulars = Math.clamp(Math.trunc($ACitizens * _irregularPercent + random(-100,100)) * _weekMod,50,$ACitizens)>> + <<set $attackTroops = Math.clamp(Math.trunc($ACitizens * _rebelPercent * _weekMod) + random(-100,100),50,$ACitizens)>> + <<set $irregulars = Math.clamp(Math.trunc($ACitizens * _irregularPercent * _weekMod) + random(-100,100),50,$ACitizens)>> /* calc if units rebel */ <<for _i = 0; _i < $militiaUnits.length; _i++>> <<if $militiaUnits[_i].loyalty < 10>> diff --git a/src/Mods/SecExp/rebellionHandler.tw b/src/Mods/SecExp/rebellionHandler.tw index 20e41d978aa6933661fa1c69426dd96b900bbc83..2682d53b923997f71f86cae2c302738f0a01d76b 100644 --- a/src/Mods/SecExp/rebellionHandler.tw +++ b/src/Mods/SecExp/rebellionHandler.tw @@ -84,13 +84,10 @@ <</for>> <<if $SF.Toggle && $SF.Active >= 1>> - <<set $SFatk = 0>> - <<set $SFdef = 0>> - <<set $SFhp = 0>> - <<run calcSFStatistics()>> - <<set _attack += $SFatk>> - <<set _defense += $SFdef>> - <<set _hp += $SFhp>> + <<set _unit = App.SecExp.getUnit("SF")>> + <<set _attack += _unit.attack>> + <<set _defense += _unit.defense>> + <<set _hp += _unit.hp>> <</if>> <<set _attack *= _engageMod>> @@ -140,11 +137,12 @@ <</if>> <<set _armyMod = Math.trunc(_armyMod)>> +<<set _rebellingSlaves = 0, _rebellingMilitia = 0, _rebellingMercs = 0>> <<if $slaveRebellion == 1>> - <<set $rebellingSlaves = 1>> + <<set _rebellingSlaves = 1>> <<set _unit = App.SecExp.getIrregularUnit("Slaves", $attackTroops, $attackEquip)>> <<else>> - <<set $rebellingMilitia = 1>> + <<set _rebellingMilitia = 1>> <<set _unit = App.SecExp.getIrregularUnit("Militia", $attackTroops, $attackEquip)>> <</if>> <<set _enemyAttack += _unit.attack * _armyMod>> @@ -153,7 +151,7 @@ <<for _i = 0; _i < $militiaUnits.length; _i++>> <<if $militiaUnits[_i].active == 1 && $rebellingID.includes($militiaUnits[_i].ID)>> - <<set $rebellingMilitia = 1>> + <<set _rebellingMilitia = 1>> <<set $attackTroops += $militiaUnits[_i].troops>> <<set $militiaUnits[_i].loyalty = 0>> <<set _unit = App.SecExp.getUnit("Militia", _i)>> @@ -164,7 +162,7 @@ <</for>> <<for _i = 0; _i < $slaveUnits.length; _i++>> <<if $slaveUnits[_i].active == 1 && $rebellingID.includes($slaveUnits[_i].ID)>> - <<set $rebellingSlaves = 1>> + <<set _rebellingSlaves = 1>> <<set $attackTroops += $slaveUnits[_i].troops>> <<set $slaveUnits[_i].loyalty = 0>> <<set _unit = App.SecExp.getUnit("Slaves", _i)>> @@ -175,7 +173,7 @@ <</for>> <<for _i = 0; _i < $mercUnits.length; _i++>> <<if $mercUnits[_i].active == 1 && $rebellingID.includes($mercUnits[_i].ID)>> - <<set $rebellingMercs = 1>> + <<set _rebellingMercs = 1>> <<set $attackTroops += $mercUnits[_i].troops>> <<set $mercUnits[_i].loyalty = 0>> <<set _unit = App.SecExp.getUnit("Mercs", _i)>> @@ -187,9 +185,9 @@ <<set _enemyMoraleTroopMod = Math.clamp($attackTroops / 100,1,10)>> -<<set _enemyMorale = 1.5 * (App.SecExp.BaseMilitiaUnit.morale * $rebellingMilitia + App.SecExp.BaseSlaveUnit.morale * $rebellingSlaves + App.SecExp.BaseMercUnit.morale * $rebellingMercs) / ($rebellingMilitia + $rebellingSlaves + $rebellingMercs)>> +<<set _enemyMorale = 1.5 * (App.SecExp.BaseMilitiaUnit.morale * _rebellingMilitia + App.SecExp.BaseSlaveUnit.morale * _rebellingSlaves + App.SecExp.BaseMercUnit.morale * _rebellingMercs) / (_rebellingMilitia + _rebellingSlaves + _rebellingMercs)>> <<set _enemyMorale *= _enemyMoraleTroopMod>> -<<set _enemyBaseHp = (App.SecExp.BaseMilitiaUnit.hp * $rebellingMilitia + App.SecExp.BaseSlaveUnit.hp * $rebellingSlaves + App.SecExp.BaseMercUnit.hp * $rebellingMercs) / ($rebellingMilitia + $rebellingSlaves + $rebellingMercs)>> +<<set _enemyBaseHp = (App.SecExp.BaseMilitiaUnit.hp * _rebellingMilitia + App.SecExp.BaseSlaveUnit.hp * _rebellingSlaves + App.SecExp.BaseMercUnit.hp * _rebellingMercs) / (_rebellingMilitia + _rebellingSlaves + _rebellingMercs)>> <<if isNaN(_attack)>> <br>@@.red;Error: attack value reported NaN@@ diff --git a/src/Mods/SecExp/rebellionReport.tw b/src/Mods/SecExp/rebellionReport.tw index 47661795c5aa89473c34174eeab5eba78da79bd0..d6977359a9802640750bdd68027c7636ee5d028a 100644 --- a/src/Mods/SecExp/rebellionReport.tw +++ b/src/Mods/SecExp/rebellionReport.tw @@ -603,26 +603,21 @@ <<set _woundChance *= random(2,4)>> <<if random(1,100) <= _woundChance>> Your Concubine was unfortunately caught in the crossfire and - <<set $woundType = random(1,10)>> - <<if $woundType == 1>> + <<set _woundType = App.SecExp.inflictBattleWound(getSlave($Concubine.ID))>> + <<if _woundType == "voice">> a splinter pierced $his throat, severing $his vocal cords. - <<set $Concubine.voice = 0>> - <<elseif $woundType == 2>> + <<elseif _woundType == "eyes">> a splinter hit $his face, severely damaging $his eyes. - <<run eyeSurgery($Concubine, "both", "blind")>> - <<elseif $woundType == 3>> - an explosion near $him caused the loss of all $his limbs. - <<run removeLimbs($Concubine, "all")>> - <<elseif $woundType >= 4>> + <<elseif _woundType == "legs">> + an explosion near $him caused the loss of both of $his legs. + <<elseif _woundType == "arm">> + an explosion near $him caused the loss of one of $his arms. + <<elseif _woundType == "flesh">> a stray shot severely wounded $him. - <<if $Concubine.health.health >= -60>> - <<run healthDamage($Concubine, 30)>> - <<else>> - <<run healthDamage($Concubine, -90 - $Concubine.health.health)>> - <</if>> <</if>> <</if>> <</if>> + <<setLocalPronouns $Bodyguard>> <<set _woundChance = 0>> <<if $Bodyguard.skill.combat == 1>> <<set _woundChance -= 2>> @@ -664,23 +659,17 @@ <<set _woundChance *= random(2,4)>> <<if random(1,100) <= _woundChance>> During one of the assaults your Bodyguard was hit. - <<set $woundType = random(1,10)>> - <<if $woundType == 1>> - A splinter pierced _his2 throat, severing _his2 vocal cords. - <<set $Bodyguard.voice = 0>> - <<elseif $woundType == 2>> - A splinter hit _his2 face, severely damaging _his2 eyes. - <<run eyeSurgery($Bodyguard, "both", "blind")>> - <<elseif $woundType == 3>> - An explosion near _him2 caused the loss of all _his2 limbs. - <<run removeLimbs($Bodyguard, "all")>> - <<elseif $woundType >= 4>> - A stray shot severely wounded _him2. - <<if $Bodyguard.health.health >= -60>> - <<run healthDamage($Bodyguard, 30)>> - <<else>> - <<run healthDamage($Bodyguard, $Bodyguard.health.health + 90)>> - <</if>> + <<set _woundType = App.SecExp.inflictBattleWound(getSlave($Bodyguard.ID))>> + <<if _woundType == "voice">> + A splinter pierced $his throat, severing $his vocal cords. + <<elseif _woundType == "eyes">> + A splinter hit $his face, severely damaging $his eyes. + <<elseif _woundType == "legs">> + An explosion near $him caused the loss of both of $his legs. + <<elseif _woundType == "arm">> + An explosion near $him caused the loss of one of $his arms. + <<elseif _woundType == "flesh">> + A stray shot severely wounded $him. <</if>> <</if>> The damage to the structure will be @@.red;costly to repair.@@ @@ -772,23 +761,17 @@ <<set _woundChance *= random(2,4)>> <<if random(1,100) <= _woundChance>> Your Concubine was unfortunately caught in the crossfire and - <<set $woundType = random(1,10)>> - <<if $woundType == 1>> + <<set _woundType = App.SecExp.inflictBattleWound(getSlave($Concubine.ID))>> + <<if _woundType == "voice">> a splinter pierced $his throat, severing $his vocal cords. - <<set $Concubine.voice = 0>> - <<elseif $woundType == 2>> + <<elseif _woundType == "eyes">> a splinter hit $his face, severely damaging $his eyes. - <<run eyeSurgery($Concubine, "both", "blind")>> - <<elseif $woundType == 3>> - an explosion near $him caused the loss of all $his limbs. - <<run removeLimbs($Concubine, "all")>> - <<elseif $woundType >= 4>> + <<elseif _woundType == "legs">> + an explosion near $him caused the loss of both of $his legs. + <<elseif _woundType == "arm">> + an explosion near $him caused the loss of one of $his arms. + <<elseif _woundType == "flesh">> a stray shot severely wounded $him. - <<if $Concubine.health.health >= -60>> - <<run healthDamage($Concubine, 30)>> - <<else>> - <<run healthDamage($Concubine, $Concubine.health.health + 90)>> - <</if>> <</if>> <</if>> <</if>> @@ -881,23 +864,17 @@ <<set _woundChance *= random(2,4)>> <<if random(1,100) <= _woundChance>> Your Concubine was unfortunately caught in the crossfire and - <<set $woundType = random(1,10)>> - <<if $woundType == 1>> + <<set _woundType = App.SecExp.inflictBattleWound(getSlave($Concubine.ID))>> + <<if _woundType == "voice">> a splinter pierced $his throat, severing $his vocal cords. - <<set $Concubine.voice = 0>> - <<elseif $woundType == 2>> + <<elseif _woundType == "eyes">> a splinter hit $his face, severely damaging $his eyes. - <<run eyeSurgery($Concubine, "both", "blind")>> - <<elseif $woundType == 3>> - an explosion near $him caused the loss of all $his limbs. - <<run removeLimbs($Concubine, "all")>> - <<elseif $woundType >= 4>> + <<elseif _woundType == "legs">> + an explosion near $him caused the loss of both of $his legs. + <<elseif _woundType == "arm">> + an explosion near $him caused the loss of one of $his arms. + <<elseif _woundType == "flesh">> a stray shot severely wounded $him. - <<if $Concubine.health.health >= -60>> - <<run healthDamage($Concubine, 30)>> - <<else>> - <<run healthDamage($Concubine, -90 - $Concubine.health.health)>> - <</if>> <</if>> <</if>> <</if>> diff --git a/src/Mods/SecExp/unitsRebellionReport.tw b/src/Mods/SecExp/unitsRebellionReport.tw index 4611aabeacb2a5a904ffb8e5baa808866fa27a30..0b897d8b3418b3def6d2825d614c6c78ee59dfad 100644 --- a/src/Mods/SecExp/unitsRebellionReport.tw +++ b/src/Mods/SecExp/unitsRebellionReport.tw @@ -46,200 +46,6 @@ <</for>> participated in the battle without taking any casualties. They remained loyal until the end. <</if>> - <<if $rebellingID.length > 0 && $battleResult != -1>> - <br> - <br> - /* militia */ - <<set _militiaRebelledID = []>> - <<set _militiaManpower = 0>> - <<for _j = 0; _j < $militiaUnits.length; _j++>> - <<if $militiaUnits[_j].active == 1 && $rebellingID.includes($militiaUnits[_j].ID)>> - $militiaUnits[_j].platoonName, - <<set _militiaRebelledID.push($militiaUnits[_j].ID)>> - <<set _militiaManpower += Math.clamp($militiaUnits[_j].troops - random(_averageLosses),0,$militiaUnits[_j].troops)>> - <</if>> - <</for>> - <<if _militiaRebelledID.length > 0>> - had the gall to betray you and join your enemies. - <span id="militiaResult"> - <br><<link "Dissolve the units">> - <<run removeUnits(_militiaRebelledID)>> - <<set $militiaFreeManpower += _militiaManpower>> - <<for _i = 0; _i < $militiaUnits.length; _i++>> - <<if $militiaUnits[_i].active == 1>> - <<set $militiaUnits[_i].loyalty = Math.clamp($militiaUnits[_i].loyalty - random(10,40),0,100)>> - <</if>> - <</for>> - <<replace "#militiaResult">> - <br>Units dissolved. - <</replace>> - <</link>> - <br>//Manpower will be refunded, but will negatively influence the loyalty of the other units// - <br><<link "Purge the dissidents and dissolve the units">> - <<run removeUnits(_militiaRebelledID)>> - <<set $militiaFreeManpower += _militiaManpower * 0.5>> - <<replace "#militiaResult">> - <br>Dissidents purged and units dissolved. - <</replace>> - <</link>> - <br>//Will not influence the loyalty of the other units, but only half the manpower will be refunded.// - <br><<link "Execute them all">> - <<run removeUnits(_militiaRebelledID)>> - <<for _i = 0; _i < $militiaUnits.length; _i++>> - <<if $militiaUnits[_i].active == 1>> - <<set $militiaUnits[_i].loyalty = Math.clamp($militiaUnits[_i].loyalty + random(10,40),0,100)>> - <</if>> - <</for>> - <<replace "#militiaResult">> - <br>Units executed. Dissent will not be tolerated. - <</replace>> - <</link>> - <br>//Will positively influence the loyalty of the other units, but no manpower will be refunded.// - </span> - <</if>> - - /* slaves */ - <<set _slaveRebelledID = []>> - <<set _slaveManpower = 0>> - <br><br> - <<for _j = 0; _j < $slaveUnits.length; _j++>> - <<if $slaveUnits[_j].active == 1 && $rebellingID.includes($slaveUnits[_j].ID)>> - $slaveUnits[_j].platoonName, - <<set _slaveRebelledID.push($slaveUnits[_j].ID)>> - <<set _slaveManpower += Math.clamp($slaveUnits[_j].troops - random(_averageLosses),0,$slaveUnits[_j].troops)>> - <</if>> - <</for>> - <<if _slaveRebelledID.length > 0>> - decided in their blind arrogance to betray you. - <span id="slaveResult"> - <br><<link "Dissolve the units">> - <<run removeUnits(_slaveRebelledID)>> - <<set $menials += _slaveManpower>> - <<for _i = 0; _i < $slaveUnits.length; _i++>> - <<if $slaveUnits[_i].active == 1>> - <<set $slaveUnits[_i].loyalty = Math.clamp($slaveUnits[_i].loyalty - random(10,40),0,100)>> - <</if>> - <</for>> - <<replace "#slaveResult">> - <br>Units dissolved. - <</replace>> - <</link>> - <br>//Manpower will be refunded, but will negatively influence the loyalty of the other units// - <br><<link "Purge the dissidents and dissolve the units">> - <<run removeUnits(_slaveRebelledID)>> - <<set $menials += _slaveManpower * 0.5>> - <<replace "#slaveResult">> - <br>Dissidents purged and units dissolved. - <</replace>> - <</link>> - <br>//Will not influence the loyalty of the other units, but only half the manpower will be refunded.// - <br><<link "Execute them all">> - <<run removeUnits(_slaveRebelledID)>> - <<for _i = 0; _i < $slaveUnits.length; _i++>> - <<if $slaveUnits[_i].active == 1>> - <<set $slaveUnits[_i].loyalty = Math.clamp($slaveUnits[_i].loyalty + random(10,40),0,100)>> - <</if>> - <</for>> - <<replace "#slaveResult">> - <br>Units executed. Dissent will not be tolerated. - <</replace>> - <</link>> - <br>//Will positively influence the loyalty of the other units, but no manpower will be refunded.// - </span> - <</if>> - - /* mercs */ - <<set _mercRebelledID = []>> - <<set _mercManpower = 0>> - <br><br> - <<for _j = 0; _j < $mercUnits.length; _j++>> - <<if $mercUnits[_j].active == 1 && $rebellingID.includes($mercUnits[_j].ID)>> - $mercUnits[_j].platoonName, - <<set _mercRebelledID.push($mercUnits[_j].ID)>> - <<set _mercManpower += Math.clamp($mercUnits[_j].troops - random(_averageLosses),0,$mercUnits[_j].troops)>> - <</if>> - <</for>> - <<if _mercRebelledID.length > 0>> - made the grave mistake of betraying you. - <span id="mercResult"> - <br><<link "Dissolve the units">> - <<run removeUnits(_mercRebelledID)>> - <<set $mercFreeManpower += _mercManpower>> - <<for _i = 0; _i < $mercUnits.length; _i++>> - <<if $mercUnits[_i].active == 1>> - <<set $mercUnits[_i].loyalty = Math.clamp($mercUnits[_i].loyalty - random(10,40),0,100)>> - <</if>> - <</for>> - <<replace "#mercResult">> - <br>Units dissolved. - <</replace>> - <</link>> - <br>//Manpower will be refunded, but will negatively influence the loyalty of the other units// - <br><<link "Purge the dissidents and dissolve the units">> - <<run removeUnits(_mercRebelledID)>> - <<set $mercFreeManpower += _mercManpower * 0.5>> - <<replace "#mercResult">> - <br>Dissidents purged and units dissolved. - <</replace>> - <</link>> - <br>//Will not influence the loyalty of the other units, but only half the manpower will be refunded.// - <br><<link "Execute them all">> - <<run removeUnits(_mercRebelledID)>> - <<for _i = 0; _i < $mercUnits.length; _i++>> - <<if $mercUnits[_i].active == 1>> - <<set $mercUnits[_i].loyalty = Math.clamp($mercUnits[_i].loyalty + random(10,40),0,100)>> - <</if>> - <</for>> - <<replace "#mercResult">> - <br>Units executed. Dissent will not be tolerated. - <</replace>> - <</link>> - <br>//Will positively influence the loyalty of the other units, but no manpower will be refunded.// - </span> - <</if>> - <<elseif $rebellingID.length > 0>> - <<set _militiaRebelledID = []>> - <<for _j = 0; _j < $militiaUnits.length; _j++>> - <<if $militiaUnits[_j].active == 1 && $rebellingID.includes($militiaUnits[_j].ID)>> - <<set _militiaRebelledID.push($militiaUnits[_j].ID)>> - $militiaUnits[_j].platoonName, - <</if>> - <</for>> - <<if _militiaRebelledID.length > 0>> - had the gall to betray you and join your enemies. They participated in the looting following the rebellion, then vanished in the wastes. - <</if>> - <<run cashX(forceNeg(1000 * _militiaRebelledID.length), "war")>> - <br> - <<run removeUnits(_militiaRebelledID)>> - <<set _slaveRebelledID = []>> - <<for _j = 0; _j < $slaveUnits.length; _j++>> - <<if $slaveUnits[_j].active == 1 && $rebellingID.includes($slaveUnits[_j].ID)>> - <<set _slaveRebelledID.push($slaveUnits[_j].ID)>> - $slaveUnits[_j].platoonName, - <</if>> - <</for>> - <<if _slaveRebelledID.length > 0>> - decided in their blind arrogance to betray you. They participated in the looting following the rebellion, then vanished in the wastes. - <</if>> - <<run cashX(forceNeg(1000 * _slaveRebelledID.length), "war")>> - <<run removeUnits(_slaveRebelledID)>> - <br> - <<set _mercRebelledID = []>> - <<set _count = 0>> - <<for _j = 0; _j < $mercUnits.length; _j++>> - <<if $mercUnits[_j].active == 1 && $rebellingID.includes($mercUnits[_j].ID)>> - <<set _mercRebelledID.push($mercUnits[_j].ID)>> - <<set _count++>> - $mercUnits[_j].platoonName, - <</if>> - <</for>> - <<if _mercRebelledID.length > 0>> - made the grave mistake of betraying you. They participated in the looting following the rebellion, then vanished in the wastes. - <</if>> - <<run cashX(forceNeg(1000 * _mercRebelledID.length), "war")>> - <<run removeUnits(_mercRebelledID)>> - <</if>> - <<elseif $losses > 0>> /* if the losses are more than zero */ /* generates a list of randomized losses, from which each unit picks one at random */ @@ -493,201 +299,202 @@ <</if>> <</for>> <</if>> +<<else>> + <br>@@.red;Error: losses are a negative number or NaN@@ +<</if>> + +<<if $rebellingID.length > 0 && $battleResult >= 2>> + /* rebellion win */ <br><br> - <<if $rebellingID.length > 0 && $battleResult >= 2>> - /* win */ - /* militia */ - <<set _militiaRebelledID = []>> - <<set _militiaManpower = 0>> - <<for _j = 0; _j < $militiaUnits.length; _j++>> - <<if $militiaUnits[_j].active == 1 && $rebellingID.includes($militiaUnits[_j].ID)>> - $militiaUnits[_j].platoonName, - <<set _militiaRebelledID.push($militiaUnits[_j].ID)>> - <<set _militiaManpower += Math.clamp($militiaUnits[_j].troops - random(_averageLosses),0,$militiaUnits[_j].troops)>> - <</if>> - <</for>> - <<if _militiaRebelledID.length > 0>> - had the gall to betray you and join your enemies. - <span id="militiaResult"> - <br><<link "Dissolve the units">> - <<run removeUnits(_militiaRebelledID)>> - <<set $militiaFreeManpower += _militiaManpower>> - <<for _i = 0; _i < $militiaUnits.length; _i++>> - <<if $militiaUnits[_i].active == 1>> - <<set $militiaUnits[_i].loyalty = Math.clamp($militiaUnits[_i].loyalty - random(10,40),0,100)>> - <</if>> - <</for>> - <<replace "#militiaResult">> - <br>Units dissolved. - <</replace>> - <</link>> - <br>//Manpower will be refunded, but will negatively influence the loyalty of the other units// - <br><<link "Purge the dissidents and dissolve the units">> - <<run removeUnits(_militiaRebelledID)>> - <<set $militiaFreeManpower += _militiaManpower * 0.5>> - <<replace "#militiaResult">> - <br>Dissidents purged and units dissolved. - <</replace>> - <</link>> - <br>//Will not influence the loyalty of the other units, but only half the manpower will be refunded.// - <br><<link "Execute them all">> - <<run removeUnits(_militiaRebelledID)>> - <<for _i = 0; _i < $militiaUnits.length; _i++>> - <<if $militiaUnits[_i].active == 1>> - <<set $militiaUnits[_i].loyalty = Math.clamp($militiaUnits[_i].loyalty + random(10,40),0,100)>> - <</if>> - <</for>> - <<replace "#militiaResult">> - <br>Units executed. Dissent will not be tolerated. - <</replace>> - <</link>> - <br>//Will positively influence the loyalty of the other units, but no manpower will be refunded.// - </span> + /* militia */ + <<set _militiaRebelledID = []>> + <<set _militiaManpower = 0>> + <<for _j = 0; _j < $militiaUnits.length; _j++>> + <<if $militiaUnits[_j].active == 1 && $rebellingID.includes($militiaUnits[_j].ID)>> + $militiaUnits[_j].platoonName, + <<set _militiaRebelledID.push($militiaUnits[_j].ID)>> + <<set _militiaManpower += Math.clamp($militiaUnits[_j].troops - random(_averageLosses),0,$militiaUnits[_j].troops)>> <</if>> + <</for>> + <<if _militiaRebelledID.length > 0>> + had the gall to betray you and join your enemies. + <span id="militiaResult"> + <br><<link "Dissolve the units">> + <<run $militiaUnits.deleteWith((u) => _militiaRebelledID.includes(u.ID))>> + <<set $militiaFreeManpower += _militiaManpower>> + <<for _i = 0; _i < $militiaUnits.length; _i++>> + <<if $militiaUnits[_i].active == 1>> + <<set $militiaUnits[_i].loyalty = Math.clamp($militiaUnits[_i].loyalty - random(10,40),0,100)>> + <</if>> + <</for>> + <<replace "#militiaResult">> + <br>Units dissolved. + <</replace>> + <</link>> + <br>//Manpower will be refunded, but will negatively influence the loyalty of the other units// + <br><<link "Purge the dissidents and dissolve the units">> + <<run $militiaUnits.deleteWith((u) => _militiaRebelledID.includes(u.ID))>> + <<set $militiaFreeManpower += _militiaManpower * 0.5>> + <<replace "#militiaResult">> + <br>Dissidents purged and units dissolved. + <</replace>> + <</link>> + <br>//Will not influence the loyalty of the other units, but only half the manpower will be refunded.// + <br><<link "Execute them all">> + <<run $militiaUnits.deleteWith((u) => _militiaRebelledID.includes(u.ID))>> + <<for _i = 0; _i < $militiaUnits.length; _i++>> + <<if $militiaUnits[_i].active == 1>> + <<set $militiaUnits[_i].loyalty = Math.clamp($militiaUnits[_i].loyalty + random(10,40),0,100)>> + <</if>> + <</for>> + <<replace "#militiaResult">> + <br>Units executed. Dissent will not be tolerated. + <</replace>> + <</link>> + <br>//Will positively influence the loyalty of the other units, but no manpower will be refunded.// + </span> + <</if>> - /* slaves */ - <<set _slaveRebelledID = []>> - <<set _slaveManpower = 0>> - <br> - <<for _j = 0; _j < $slaveUnits.length; _j++>> - <<if $slaveUnits[_j].active == 1 && $rebellingID.includes($slaveUnits[_j].ID)>> - $slaveUnits[_j].platoonName, - <<set _slaveRebelledID.push($slaveUnits[_j].ID)>> - <<set _slaveManpower += Math.clamp($slaveUnits[_j].troops - random(_averageLosses),0,$slaveUnits[_j].troops)>> - <</if>> - <</for>> - <<if _slaveRebelledID.length > 0>> - decided in their blind arrogance to betray you. - <span id="slaveResult"> - <br><<link "Dissolve the units">> - <<run removeUnits(_slaveRebelledID)>> - <<set $menials += _slaveManpower>> - <<for _i = 0; _i < $militiaUnits.length; _i++>> - <<if $slaveUnits[_i].active == 1>> - <<set $slaveUnits[_i].loyalty = Math.clamp($slaveUnits[_i].loyalty - random(10,40),0,100)>> - <</if>> - <</for>> - <<replace "#slaveResult">> - <br>Units dissolved. - <</replace>> - <</link>> - <br>//Manpower will be refunded, but will negatively influence the loyalty of the other units// - <br><<link "Purge the dissidents and dissolve the units">> - <<run removeUnits(_slaveRebelledID)>> - <<set $menials += _slaveManpower * 0.5>> - <<replace "#slaveResult">> - <br>Dissidents purged and units dissolved. - <</replace>> - <</link>> - <br>//Will not influence the loyalty of the other units, but only half the manpower will be refunded.// - <br><<link "Execute them all">> - <<run removeUnits(_slaveRebelledID)>> - <<for _i = 0; _i < $slaveUnits.length; _i++>> - <<if $slaveUnits[_i].active == 1>> - <<set $slaveUnits[_i].loyalty = Math.clamp($slaveUnits[_i].loyalty + random(10,40),0,100)>> - <</if>> - <</for>> - <<replace "#slaveResult">> - <br>Units executed. Dissent will not be tolerated. - <</replace>> - <</link>> - <br>//Will positively influence the loyalty of the other units, but no manpower will be refunded.// - </span> + /* slaves */ + <<set _slaveRebelledID = []>> + <<set _slaveManpower = 0>> + <br> + <<for _j = 0; _j < $slaveUnits.length; _j++>> + <<if $slaveUnits[_j].active == 1 && $rebellingID.includes($slaveUnits[_j].ID)>> + $slaveUnits[_j].platoonName, + <<set _slaveRebelledID.push($slaveUnits[_j].ID)>> + <<set _slaveManpower += Math.clamp($slaveUnits[_j].troops - random(_averageLosses),0,$slaveUnits[_j].troops)>> <</if>> + <</for>> + <<if _slaveRebelledID.length > 0>> + decided in their blind arrogance to betray you. + <span id="slaveResult"> + <br><<link "Dissolve the units">> + <<run $slaveUnits.deleteWith((u) => _slaveRebelledID.includes(u.ID))>> + <<set $menials += _slaveManpower>> + <<for _i = 0; _i < $militiaUnits.length; _i++>> + <<if $slaveUnits[_i].active == 1>> + <<set $slaveUnits[_i].loyalty = Math.clamp($slaveUnits[_i].loyalty - random(10,40),0,100)>> + <</if>> + <</for>> + <<replace "#slaveResult">> + <br>Units dissolved. + <</replace>> + <</link>> + <br>//Manpower will be refunded, but will negatively influence the loyalty of the other units// + <br><<link "Purge the dissidents and dissolve the units">> + <<run $slaveUnits.deleteWith((u) => _slaveRebelledID.includes(u.ID))>> + <<set $menials += _slaveManpower * 0.5>> + <<replace "#slaveResult">> + <br>Dissidents purged and units dissolved. + <</replace>> + <</link>> + <br>//Will not influence the loyalty of the other units, but only half the manpower will be refunded.// + <br><<link "Execute them all">> + <<run $slaveUnits.deleteWith((u) => _slaveRebelledID.includes(u.ID))>> + <<for _i = 0; _i < $slaveUnits.length; _i++>> + <<if $slaveUnits[_i].active == 1>> + <<set $slaveUnits[_i].loyalty = Math.clamp($slaveUnits[_i].loyalty + random(10,40),0,100)>> + <</if>> + <</for>> + <<replace "#slaveResult">> + <br>Units executed. Dissent will not be tolerated. + <</replace>> + <</link>> + <br>//Will positively influence the loyalty of the other units, but no manpower will be refunded.// + </span> + <</if>> - /* mercs */ - <<set _mercRebelledID = []>> - <<set _mercManpower = 0>> - <br> - <<for _j = 0; _j < $mercUnits.length; _j++>> - <<if $mercUnits[_j].active == 1 && $rebellingID.includes($mercUnits[_j].ID)>> - $mercUnits[_j].platoonName, - <<set _mercRebelledID.push($mercUnits[_j].ID)>> - <<set _mercManpower += Math.clamp($mercUnits[_j].troops - random(_averageLosses),0,$mercUnits[_j].troops)>> - <</if>> - <</for>> - <<if _mercRebelledID.length > 0>> - made the grave mistake of betraying you. - <span id="mercResult"> - <br><<link "Dissolve the units">> - <<run removeUnits(_mercRebelledID)>> - <<set $mercFreeManpower += _mercManpower>> - <<for _i = 0; _i < $militiaUnits.length; _i++>> - <<if $mercUnits[_i].active == 1>> - <<set $mercUnits[_i].loyalty = Math.clamp($mercUnits[_i].loyalty - random(10,40),0,100)>> - <</if>> - <</for>> - <<replace "#mercResult">> - <br>Units dissolved. - <</replace>> - <</link>> - <br>//Manpower will be refunded, but will negatively influence the loyalty of the other units// - <br><<link "Purge the dissidents and dissolve the units">> - <<run removeUnits(_mercRebelledID)>> - <<set $mercFreeManpower += _mercManpower * 0.5>> - <<replace "#mercResult">> - <br>Dissidents purged and units dissolved. - <</replace>> - <</link>> - <br>//Will not influence the loyalty of the other units, but only half the manpower will be refunded.// - <br><<link "Execute them all">> - <<run removeUnits(_mercRebelledID)>> - <<for _i = 0; _i < $mercUnits.length; _i++>> - <<if $mercUnits[_i].active == 1>> - <<set $mercUnits[_i].loyalty = Math.clamp($mercUnits[_i].loyalty + random(10,40),0,100)>> - <</if>> - <</for>> - <<replace "#mercResult">> - <br>Units executed. Dissent will not be tolerated. - <</replace>> - <</link>> - <br>//Will positively influence the loyalty of the other units, but no manpower will be refunded.// - </span> + /* mercs */ + <<set _mercRebelledID = []>> + <<set _mercManpower = 0>> + <br> + <<for _j = 0; _j < $mercUnits.length; _j++>> + <<if $mercUnits[_j].active == 1 && $rebellingID.includes($mercUnits[_j].ID)>> + $mercUnits[_j].platoonName, + <<set _mercRebelledID.push($mercUnits[_j].ID)>> + <<set _mercManpower += Math.clamp($mercUnits[_j].troops - random(_averageLosses),0,$mercUnits[_j].troops)>> <</if>> - - /* loss */ - <<elseif $rebellingID.length > 0>> - <<set _militiaRebelledID = []>> - <<for _j = 0; _j < $militiaUnits.length; _j++>> - <<if $militiaUnits[_j].active == 1 && $rebellingID.includes($militiaUnits[_j].ID)>> - <<set _militiaRebelledID.push($militiaUnits[_j].ID)>> - $militiaUnits[_j].platoonName, - <</if>> - <</for>> - <<if _militiaRebelledID.length > 0>> - had the gall to betray you and join your enemies. They participated in the looting following the battle, then vanished in the wastes. + <</for>> + <<if _mercRebelledID.length > 0>> + made the grave mistake of betraying you. + <span id="mercResult"> + <br><<link "Dissolve the units">> + <<run $mercUnits.deleteWith((u) => _mercRebelledID.includes(u.ID))>> + <<set $mercFreeManpower += _mercManpower>> + <<for _i = 0; _i < $militiaUnits.length; _i++>> + <<if $mercUnits[_i].active == 1>> + <<set $mercUnits[_i].loyalty = Math.clamp($mercUnits[_i].loyalty - random(10,40),0,100)>> + <</if>> + <</for>> + <<replace "#mercResult">> + <br>Units dissolved. + <</replace>> + <</link>> + <br>//Manpower will be refunded, but will negatively influence the loyalty of the other units// + <br><<link "Purge the dissidents and dissolve the units">> + <<run $mercUnits.deleteWith((u) => _mercRebelledID.includes(u.ID))>> + <<set $mercFreeManpower += _mercManpower * 0.5>> + <<replace "#mercResult">> + <br>Dissidents purged and units dissolved. + <</replace>> + <</link>> + <br>//Will not influence the loyalty of the other units, but only half the manpower will be refunded.// + <br><<link "Execute them all">> + <<run $mercUnits.deleteWith((u) => _mercRebelledID.includes(u.ID))>> + <<for _i = 0; _i < $mercUnits.length; _i++>> + <<if $mercUnits[_i].active == 1>> + <<set $mercUnits[_i].loyalty = Math.clamp($mercUnits[_i].loyalty + random(10,40),0,100)>> + <</if>> + <</for>> + <<replace "#mercResult">> + <br>Units executed. Dissent will not be tolerated. + <</replace>> + <</link>> + <br>//Will positively influence the loyalty of the other units, but no manpower will be refunded.// + </span> + <</if>> +<<elseif $rebellingID.length > 0>> + /* rebellion loss */ + <br><br> + <<set _militiaRebelledID = []>> + <<for _j = 0; _j < $militiaUnits.length; _j++>> + <<if $militiaUnits[_j].active == 1 && $rebellingID.includes($militiaUnits[_j].ID)>> + <<set _militiaRebelledID.push($militiaUnits[_j].ID)>> + $militiaUnits[_j].platoonName, <</if>> - <<run cashX(forceNeg(1000 * _militiaRebelledID.length), "war")>> - <br> - <<run removeUnits(_militiaRebelledID)>> - <<set _slaveRebelledID = []>> - <<for _j = 0; _j < $slaveUnits.length; _j++>> - <<if $slaveUnits[_j].active == 1 && $rebellingID.includes($slaveUnits[_j].ID)>> - <<set _slaveRebelledID.push($slaveUnits[_j].ID)>> - $slaveUnits[_j].platoonName, - <</if>> - <</for>> - <<if _slaveRebelledID.length > 0>> - decided in their blind arrogance to betray you. They participated in the looting following the battle, then vanished in the wastes. + <</for>> + <<if _militiaRebelledID.length > 0>> + had the gall to betray you and join your enemies. They participated in the looting following the battle, then vanished in the wastes. + <</if>> + <<run cashX(forceNeg(1000 * _militiaRebelledID.length), "war")>> + <<run $militiaUnits.deleteWith((u) => _militiaRebelledID.includes(u.ID))>> + <br> + <<set _slaveRebelledID = []>> + <<for _j = 0; _j < $slaveUnits.length; _j++>> + <<if $slaveUnits[_j].active == 1 && $rebellingID.includes($slaveUnits[_j].ID)>> + <<set _slaveRebelledID.push($slaveUnits[_j].ID)>> + $slaveUnits[_j].platoonName, <</if>> - <<run cashX(forceNeg(1000 * _slaveRebelledID.length), "war")>> - <<run removeUnits(_slaveRebelledID)>> - <br> - <<set _mercRebelledID = []>> - <<set _count = 0>> - <<for _j = 0; _j < $mercUnits.length; _j++>> - <<if $mercUnits[_j].active == 1 && $rebellingID.includes($mercUnits[_j].ID)>> - <<set _mercRebelledID.push($mercUnits[_j].ID)>> - <<set _count++>> - $mercUnits[_j].platoonName, - <</if>> - <</for>> - <<if _mercRebelledID.length > 0>> - made the grave mistake of betraying you. They participated in the looting following the battle, then vanished in the wastes. + <</for>> + <<if _slaveRebelledID.length > 0>> + decided in their blind arrogance to betray you. They participated in the looting following the battle, then vanished in the wastes. + <</if>> + <<run cashX(forceNeg(1000 * _slaveRebelledID.length), "war")>> + <<run $slaveUnits.deleteWith((u) => _slaveRebelledID.includes(u.ID))>> + <br> + <<set _mercRebelledID = []>> + <<set _count = 0>> + <<for _j = 0; _j < $mercUnits.length; _j++>> + <<if $mercUnits[_j].active == 1 && $rebellingID.includes($mercUnits[_j].ID)>> + <<set _mercRebelledID.push($mercUnits[_j].ID)>> + <<set _count++>> + $mercUnits[_j].platoonName, <</if>> - <<run cashX(forceNeg(1000 * _mercRebelledID.length), "war")>> - <<run removeUnits(_mercRebelledID)>> + <</for>> + <<if _mercRebelledID.length > 0>> + made the grave mistake of betraying you. They participated in the looting following the battle, then vanished in the wastes. <</if>> -<<else>> - <br>@@.red;Error: losses are a negative number or NaN@@ + <<run cashX(forceNeg(1000 * _mercRebelledID.length), "war")>> + <<run $mercUnits.deleteWith((u) => _mercRebelledID.includes(u.ID))>> <</if>> diff --git a/src/Mods/SecExp/widgets/battleWidgets.js b/src/Mods/SecExp/widgets/battleWidgets.js deleted file mode 100644 index 22789549aab0d7dccf8a7f340393877d15cfb71a..0000000000000000000000000000000000000000 --- a/src/Mods/SecExp/widgets/battleWidgets.js +++ /dev/null @@ -1,38 +0,0 @@ -globalThis.calcSFStatistics = function() { - let upgradesSum = V.SF.Squad.Armoury + V.SF.Squad.Drugs + (V.SF.Squad.AA+V.SF.Squad.TA < 1) + (V.SF.Squad.AV+V.SF.Squad.TV); - if (!Number.isInteger(upgradesSum)) { - upgradesSum = jsRandom(10, 15); - } - - if (V.slaveRebellion !== 1 || V.citizenRebellion !== 1) { - /* atk, def */ - V.SFatk = Math.trunc(0.65 * upgradesSum); - V.SFdef = Math.trunc(0.40 * upgradesSum); - /* hp */ - V.carriableSoldiers = 125 * (V.SF.Squad.GunS + ((V.SF.Squad.AV + V.SF.Squad.TV)/2)); - if (!Number.isInteger(V.carriableSoldiers)) { - V.carriableSoldiers = V.SF.ArmySize / 10; - } - if (V.SF.ArmySize > V.carriableSoldiers) { - V.SFhp = V.carriableSoldiers * App.SecExp.BaseSpecialForcesUnit.hp; - } else { - V.carriableSoldiers = V.SF.ArmySize; - V.SFhp = V.carriableSoldiers * App.SecExp.BaseSpecialForcesUnit.hp; - } - } else { - /* atk, def */ - V.SFatk = Math.trunc(0.75 * upgradesSum); - V.SFdef = Math.trunc(0.50 * upgradesSum); - /* hp */ - V.SFhp = V.SF.ArmySize * App.SecExp.BaseSpecialForcesUnit.hp; - } -}; - -/** - * @param {Array<number>} rebellionIDs Array of unit IDs to be removed. - */ -globalThis.removeUnits = function(rebellionIDs) { - V.militiaUnits = V.militiaUnits.filter(unit => !rebellionIDs.includes(unit.ID)); - V.slaveUnits = V.slaveUnits.filter(unit => !rebellionIDs.includes(unit.ID)); - V.mercUnits = V.mercUnits.filter(unit => !rebellionIDs.includes(unit.ID)); -}; diff --git a/src/facilities/statistics.js b/src/facilities/statistics.js index 84bb43cec5961fbb4551124ac725f0c936333646..448b0da00ff0648068614b0ab03032249c2f60de 100644 --- a/src/facilities/statistics.js +++ b/src/facilities/statistics.js @@ -207,7 +207,7 @@ App.Facilities.Brothel.Stats = (function() { } const b = V.facility.brothel; - for (const prop in assureList) { + for (const prop of assureList) { b[prop] = b[prop] || 0; } @@ -307,7 +307,7 @@ App.Facilities.Club.Stats = (function() { } const b = V.facility.club; - for (const prop in assureList) { + for (const prop of assureList) { b[prop] = b[prop] || 0; } @@ -388,7 +388,7 @@ App.Facilities.Arcade.Stats = (function() { } const b = V.facility.arcade; - for (const prop in assureList) { + for (const prop of assureList) { b[prop] = b[prop] || 0; } @@ -454,7 +454,7 @@ App.Facilities.Dairy.Stats = (function() { } const b = V.facility.dairy; - for (const prop in assureList) { + for (const prop of assureList) { b[prop] = b[prop] || 0; } @@ -519,7 +519,7 @@ App.Facilities.Farmyard.Stats = (function() { } const b = V.facility.farmyard; - for (const prop in assureList) { + for (const prop of assureList) { b[prop] = b[prop] || 0; }