mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 14:45:35 +00:00
fix super cap, nan with no shield
This commit is contained in:
4755
package-lock.json
generated
4755
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -140,8 +140,8 @@ export default class ShipSummaryTable extends TranslatedComponent {
|
|||||||
<td>{int(sgMetrics && sgMetrics.generator ? sgMetrics.total / sgMetrics.explosive.total : 0)}</td>
|
<td>{int(sgMetrics && sgMetrics.generator ? sgMetrics.total / sgMetrics.explosive.total : 0)}</td>
|
||||||
<td>{int(sgMetrics && sgMetrics.generator ? sgMetrics.total / sgMetrics.kinetic.total : 0 )}</td>
|
<td>{int(sgMetrics && sgMetrics.generator ? sgMetrics.total / sgMetrics.kinetic.total : 0 )}</td>
|
||||||
<td>{int(sgMetrics && sgMetrics.generator ? sgMetrics.total / sgMetrics.thermal.total : 0 )}</td>
|
<td>{int(sgMetrics && sgMetrics.generator ? sgMetrics.total / sgMetrics.thermal.total : 0 )}</td>
|
||||||
<td>{formats.time(sgMetrics.recover)}</td>
|
<td>{sgMetrics && sgMetrics.recover ? formats.time(sgMetrics.recover) : 0}</td>
|
||||||
<td>{formats.time(sgMetrics.recharge)}</td>
|
<td>{sgMetrics && sgMetrics.recharge ? formats.time(sgMetrics.recharge) : 0}</td>
|
||||||
</tr>
|
</tr>
|
||||||
</tbody>
|
</tbody>
|
||||||
<thead>
|
<thead>
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ export function totalJumpRange(mass, fsd, fuel) {
|
|||||||
* @param {number} multiplier Shield multiplier for ship (1 + shield boosters if any)
|
* @param {number} multiplier Shield multiplier for ship (1 + shield boosters if any)
|
||||||
* @return {number} Approximate shield strengh in MJ
|
* @return {number} Approximate shield strengh in MJ
|
||||||
*/
|
*/
|
||||||
export function shieldStrength(mass, baseShield, sg, multiplier) {
|
export function shieldStrength(mass, baseShield, sg, multiplier, ship) {
|
||||||
// sg might be a module or a template; handle either here
|
// sg might be a module or a template; handle either here
|
||||||
let minMass = sg instanceof Module ? sg.getMinMass() : sg.minmass;
|
let minMass = sg instanceof Module ? sg.getMinMass() : sg.minmass;
|
||||||
let optMass = sg instanceof Module ? sg.getOptMass() : sg.optmass;
|
let optMass = sg instanceof Module ? sg.getOptMass() : sg.optmass;
|
||||||
@@ -55,7 +55,17 @@ export function shieldStrength(mass, baseShield, sg, multiplier) {
|
|||||||
let minMul = sg instanceof Module ? sg.getMinMul() : sg.minmul;
|
let minMul = sg instanceof Module ? sg.getMinMul() : sg.minmul;
|
||||||
let optMul = sg instanceof Module ? sg.getOptMul() : sg.optmul;
|
let optMul = sg instanceof Module ? sg.getOptMul() : sg.optmul;
|
||||||
let maxMul = sg instanceof Module ? sg.getMaxMul() : sg.maxmul;
|
let maxMul = sg instanceof Module ? sg.getMaxMul() : sg.maxmul;
|
||||||
|
if (ship) {
|
||||||
|
for (const i of ship.hardpoints) {
|
||||||
|
if (!i.maxClass) {
|
||||||
|
if (i.grp === 'sb' || (i.m && i.m.grp === 'sb')) {
|
||||||
|
if (!isNaN(i.m.getModValue('optmul'))) {
|
||||||
|
optMul += i.m.getModValue('optmul') / 10000;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
let xnorm = Math.min(1, (maxMass - mass) / (maxMass - minMass));
|
let xnorm = Math.min(1, (maxMass - mass) / (maxMass - minMass));
|
||||||
let exponent = Math.log((optMul - minMul) / (maxMul - minMul)) / Math.log(Math.min(1, (maxMass - optMass) / (maxMass - minMass)));
|
let exponent = Math.log((optMul - minMul) / (maxMul - minMul)) / Math.log(Math.min(1, (maxMass - optMass) / (maxMass - minMass)));
|
||||||
let ynorm = Math.pow(xnorm, exponent);
|
let ynorm = Math.pow(xnorm, exponent);
|
||||||
@@ -351,7 +361,7 @@ export function shieldMetrics(ship, sys) {
|
|||||||
boosterKinDmg = boosterKinDmg > 0.7 ? boosterKinDmg : 0.7 - (0.7 - boosterKinDmg) / 2;
|
boosterKinDmg = boosterKinDmg > 0.7 ? boosterKinDmg : 0.7 - (0.7 - boosterKinDmg) / 2;
|
||||||
boosterThermDmg = boosterThermDmg > 0.7 ? boosterThermDmg : 0.7 - (0.7 - boosterThermDmg) / 2;
|
boosterThermDmg = boosterThermDmg > 0.7 ? boosterThermDmg : 0.7 - (0.7 - boosterThermDmg) / 2;
|
||||||
|
|
||||||
const generatorStrength = this.shieldStrength(ship.hullMass, ship.baseShieldStrength, shieldGenerator, 1);
|
const generatorStrength = this.shieldStrength(ship.hullMass, ship.baseShieldStrength, shieldGenerator, 1, ship);
|
||||||
const boostersStrength = generatorStrength * boost;
|
const boostersStrength = generatorStrength * boost;
|
||||||
|
|
||||||
// Recover time is the time taken to go from 0 to 50%. It includes a 16-second wait before shields start to recover
|
// Recover time is the time taken to go from 0 to 50%. It includes a 16-second wait before shields start to recover
|
||||||
|
|||||||
@@ -241,7 +241,7 @@ export default class Ship {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// TODO Not accurate if the ship has modified shield boosters
|
// TODO Not accurate if the ship has modified shield boosters
|
||||||
return Calc.shieldStrength(this.hullMass, this.baseShieldStrength, sg, 1 + (multiplierDelta || 0));
|
return Calc.shieldStrength(this.hullMass, this.baseShieldStrength, sg, 1 + (multiplierDelta || 0), this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -49,7 +49,6 @@ export function trader (ship, shielded, standardOpts) {
|
|||||||
if (canMount(ship, slot, 'sg')) { // Assuming largest slot can hold an eligible shield
|
if (canMount(ship, slot, 'sg')) { // Assuming largest slot can hold an eligible shield
|
||||||
const shield = ModuleUtils.findInternal('sg', slot.maxClass, 'A')
|
const shield = ModuleUtils.findInternal('sg', slot.maxClass, 'A')
|
||||||
if (shield && shield.maxmass > ship.hullMass) {
|
if (shield && shield.maxmass > ship.hullMass) {
|
||||||
console.log(shield)
|
|
||||||
ship.use(slot, shield)
|
ship.use(slot, shield)
|
||||||
ship.setSlotEnabled(slot, true)
|
ship.setSlotEnabled(slot, true)
|
||||||
usedSlots.push(slot)
|
usedSlots.push(slot)
|
||||||
@@ -414,4 +413,3 @@ export function racer (ship) {
|
|||||||
// ship.standard[5].m.blueprint.grade = 5;
|
// ship.standard[5].m.blueprint.grade = 5;
|
||||||
// setBest(ship, ship.standard[5].m);
|
// setBest(ship, ship.standard[5].m);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user