Skip to content
Snippets Groups Projects
Commit de9e78ee authored by svornost's avatar svornost
Browse files

Make disloyal units rebel correctly again.

parent 83183220
No related branches found
No related tags found
No related merge requests found
......@@ -4,12 +4,6 @@ App.SecExp.generator = (function() {
rebellion,
};
function loyaltyCheck(squad) {
if ((squad.loyalty < 10 && random(1, 100) <= 70) || (squad.loyalty < 33 && random(1, 100) <= 30) || (squad.loyalty < 66 && random(1, 100) <= 10)) {
rebellingID.push(squad.ID);
}
}
function shared() {
V.SecExp.war = V.SecExp.war || {};
V.SecExp.war.commander = "assistant";
......@@ -221,7 +215,7 @@ App.SecExp.generator = (function() {
V.SecExp.rebellions.lastEncounterWeeks++;
} else {
const isSlaveRebellion = V.slaveRebellion === 1;
let weekMod, rebellingID = [];
let weekMod;
if (V.week <= 30) {
weekMod = 0.75 + (0.01+(V.week/200));
} else if (V.week <= 60) {
......@@ -241,23 +235,18 @@ App.SecExp.generator = (function() {
const rebelPercent = 0.3 * authFactor;
const irregularPercent = 0.2 * repFactor;
for (const unit of V.slaveUnits) {
loyaltyCheck(unit);
}
for (const unit of V.militiaUnits) {
loyaltyCheck(unit);
}
for (const unit of V.mercUnits) {
loyaltyCheck(unit);
}
const isDisloyal = (squad) => ((squad.loyalty < 10 && random(1, 100) <= 70) || (squad.loyalty < 33 && random(1, 100) <= 30) || (squad.loyalty < 66 && random(1, 100) <= 10));
const baseValue = Math.trunc((isSlaveRebellion ? V.ASlaves : V.ACitizens) * rebelPercent * weekMod) + random(-100, 100);
const highestValue = isSlaveRebellion ? V.ASlaves : V.ACitizens;
V.SecExp.war.attacker.troops = Math.clamp(baseValue, 50, highestValue);
V.SecExp.war.attacker.equip = Math.clamp(V.SecExp.edicts.weaponsLaw + random((isSlaveRebellion ? -2 : -1), 1), 0, 4);
V.SecExp.war.irregulars = Math.clamp(Math.trunc(V.ACitizens * irregularPercent * weekMod) + random(-100, 100), 50, V.ACitizens);
V.SecExp.war.engageRule = 0;
V.SecExp.war.rebellingID = rebellingID;
V.SecExp.war.rebellingID = [].concat(
V.slaveUnits.filter(isDisloyal).map(u => u.ID),
V.militiaUnits.filter(isDisloyal).map(u => u.ID),
V.mercUnits.filter(isDisloyal).map(u => u.ID)
);
}
}
})();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment