Skip to content

Commit

Permalink
sortie sim: advanced setting override support fleet chance
Browse files Browse the repository at this point in the history
  • Loading branch information
fourinone41 committed Jun 28, 2024
1 parent f128c34 commit 53cf22e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
17 changes: 16 additions & 1 deletion js/kcsim.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,10 @@ var SIMCONSTS = {
},
eqBonusAAModShip: .75,
eqBonusAAModFleet: 1,
overrideSupportChanceDayN: null,
overrideSupportChanceDayB: null,
overrideSupportChanceNightN: null,
overrideSupportChanceNightB: null,
}
SIMCONSTS.vanguardEvShellDDMod = SIMCONSTS.vanguardEvShellDDModNormal.slice();
SIMCONSTS.vanguardEvTorpDDMod = SIMCONSTS.vanguardEvTorpDDModNormal.slice();
Expand Down Expand Up @@ -3471,7 +3475,18 @@ function sim(F1,F2,Fsupport,LBASwaves,doNB,NBonly,aironly,bombing,noammo,BAPI,no

//support phase
if (Fsupport && (!NBonly || (MECHANICS.LBASBuff && Fsupport.supportType != 1)) && !aironly && alive1.length+subsalive1.length > 0 && alive2.length+subsalive2.length > 0) {
var chance = Fsupport.supportChance(Fsupport.supportBoss);
var chance;
if (SIMCONSTS.overrideSupportChanceDayN != null && SIMCONSTS.overrideSupportChanceDayN !== '' && !NBonly && !Fsupport.supportBoss) {
chance = SIMCONSTS.overrideSupportChanceDayN/100;
} else if (SIMCONSTS.overrideSupportChanceDayB != null && SIMCONSTS.overrideSupportChanceDayB !== '' && !NBonly && Fsupport.supportBoss) {
chance = SIMCONSTS.overrideSupportChanceDayB/100;
} else if (SIMCONSTS.overrideSupportChanceNightN != null && SIMCONSTS.overrideSupportChanceNightN !== '' && NBonly && !Fsupport.supportBoss) {
chance = SIMCONSTS.overrideSupportChanceNightN/100;
} else if (SIMCONSTS.overrideSupportChanceNightB != null && SIMCONSTS.overrideSupportChanceNightB !== '' && NBonly && Fsupport.supportBoss) {
chance = SIMCONSTS.overrideSupportChanceNightB/100;
} else {
chance = Fsupport.supportChance(Fsupport.supportBoss);
}
if (Math.random() < chance) {
supportPhase(Fsupport.ships,alive2,subsalive2,Fsupport.supportType,BAPI,Fsupport.supportBoss);
removeSunk(alive2); removeSunk(subsalive2);
Expand Down
7 changes: 4 additions & 3 deletions js/simulator-ui/convert.js
Original file line number Diff line number Diff line change
Expand Up @@ -944,8 +944,9 @@ window.CONVERT = {
}
if (found) settingsSave[key] = a;
} else {
if (settingsUI[key] != SIMCONSTS.defaults[key]) {
settingsSave[key] = settingsUI[key];
let v = settingsUI[key] === '' ? null : settingsUI[key];
if (v != SIMCONSTS.defaults[key]) {
settingsSave[key] = v;
}
}
}
Expand Down Expand Up @@ -1059,7 +1060,7 @@ window.CONVERT = {
loadSaveSettings(settingsSave,settingsUI) {
for (let key in settingsSave) {
if (key == 'mechanics') continue;
if (settingsUI[key] == null) continue;
if (settingsUI[key] === undefined) continue;
if (Array.isArray(settingsUI[key])) {
for (let i=0; i<settingsUI[key].length; i++) {
if (settingsSave[key][i] != null) settingsUI[key][i] = settingsSave[key][i];
Expand Down
4 changes: 4 additions & 0 deletions js/simulator-ui/ui-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,10 @@ var UI_MAIN = Vue.createApp({
smokeModAirAccF: SIMCONSTS.smokeModAirAccF.slice(),
smokeModAirAccE: SIMCONSTS.smokeModAirAccE.slice(),
enableRangeWeights: SIMCONSTS.enableRangeWeights,
overrideSupportChanceDayN: SIMCONSTS.overrideSupportChanceDayN,
overrideSupportChanceDayB: SIMCONSTS.overrideSupportChanceDayB,
overrideSupportChanceNightN: SIMCONSTS.overrideSupportChanceNightN,
overrideSupportChanceNightB: SIMCONSTS.overrideSupportChanceNightB,
},
settingsFCF: {
los: null,
Expand Down
8 changes: 8 additions & 0 deletions simulator.html
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,14 @@ <h2>Settings</h2>
<a href="https://docs.google.com/spreadsheets/d/1grAtIhlm2YMN9iyvniJA-j1YNCC-SCnA8q6WUi-Ctpg/edit#gid=0">[2]</a>&nbsp;
</div>
</div>
<div v-show="settings.showAdvanced">
<div><span class="subheader">Override Support Fleet Chance:</span></div>
<table>
<tr><td>Normal (Day):</td><td><input type="number" min="0" max="100" v-model="settings.overrideSupportChanceDayN" :class="getClassSetting('overrideSupportChanceDayN')"/>%</td></tr>
<tr><td>Normal (Night):</td><td><input type="number" min="0" max="100" v-model="settings.overrideSupportChanceNightN" :class="getClassSetting('overrideSupportChanceNightN')"/>%</td></tr>
<tr><td>Boss:</td><td><input type="number" min="0" max="100" v-model="settings.overrideSupportChanceDayB" :class="getClassSetting('overrideSupportChanceDayB')"/>%</td></tr>
</table>
</div>
</div>
<div>
<input type="button" value="Restore Defaults" @click="onclickRestoreSettings"/>
Expand Down

0 comments on commit 53cf22e

Please sign in to comment.