Updates for shield strength

This commit is contained in:
Cmdr McDonald
2016-11-02 14:14:15 +00:00
parent c88e4369c8
commit ba1f11a88b
3 changed files with 65 additions and 50 deletions

View File

@@ -24,30 +24,30 @@ export default class ShipSummaryTable extends TranslatedComponent {
let u = language.units; let u = language.units;
let formats = language.formats; let formats = language.formats;
let { time, int, round, f1, f2, pct } = formats; let { time, int, round, f1, f2, pct } = formats;
let sgClassNames = cn({ warning: ship.sgSlot && !ship.shieldStrength, muted: !ship.sgSlot }); let sgClassNames = cn({ warning: ship.sgSlot && !ship.shield, muted: !ship.sgSlot });
let sgRecover = '-'; let sgRecover = '-';
let sgRecharge = '-'; let sgRecharge = '-';
let hide = tooltip.bind(null, null); let hide = tooltip.bind(null, null);
if (ship.shieldStrength) { if (ship.shield) {
sgRecover = time(ship.calcShieldRecovery()); sgRecover = time(ship.calcShieldRecovery());
sgRecharge = time(ship.calcShieldRecharge()); sgRecharge = time(ship.calcShieldRecharge());
} }
//<th colSpan={3}>{translate('shield resistance')}</th> // <th colSpan={3}>{translate('shield resistance')}</th>
//<th colSpan={3}>{translate('hull resistance')}</th> // <th colSpan={3}>{translate('hull resistance')}</th>
//<th className='lft'>{translate('explosive')}</th> // <th className='lft'>{translate('explosive')}</th>
//<th className='lft'>{translate('kinetic')}</th> // <th className='lft'>{translate('kinetic')}</th>
//<th className='lft'>{translate('thermal')}</th> // <th className='lft'>{translate('thermal')}</th>
//<th className='lft'>{translate('explosive')}</th> // <th className='lft'>{translate('explosive')}</th>
//<th className='lft'>{translate('kinetic')}</th> // <th className='lft'>{translate('kinetic')}</th>
//<th className='lft'>{translate('thermal')}</th> // <th className='lft'>{translate('thermal')}</th>
//<td>{pct(ship.shieldExplRes)}</td> // <td>{pct(ship.shieldExplRes)}</td>
//<td>{pct(ship.shieldKinRes)}</td> // <td>{pct(ship.shieldKinRes)}</td>
//<td>{pct(ship.shieldThermRes)}</td> // <td>{pct(ship.shieldThermRes)}</td>
//<td>{pct(ship.hullExplRes)}</td> // <td>{pct(ship.hullExplRes)}</td>
//<td>{pct(ship.hullKinRes)}</td> // <td>{pct(ship.hullKinRes)}</td>
//<td>{pct(ship.hullThermRes)}</td> // <td>{pct(ship.hullThermRes)}</td>
return <div id='summary'> return <div id='summary'>
<table id='summaryTable'> <table id='summaryTable'>
<thead> <thead>
@@ -89,7 +89,7 @@ export default class ShipSummaryTable extends TranslatedComponent {
<td>{f1(ship.totalEps)}</td> <td>{f1(ship.totalEps)}</td>
<td>{f1(ship.totalHps)}</td> <td>{f1(ship.totalHps)}</td>
<td>{int(ship.armour)}</td> <td>{int(ship.armour)}</td>
<td className={sgClassNames}>{int(ship.shieldStrength)} {u.MJ} { ship.shieldMultiplier > 1 && ship.shieldStrength > 0 ? <u>({formats.rPct(ship.shieldMultiplier)})</u> : null }</td> <td className={sgClassNames}>{int(ship.shield)} {u.MJ}</td>
<td className={sgClassNames}>{sgRecover}</td> <td className={sgClassNames}>{sgRecover}</td>
<td className={sgClassNames}>{sgRecharge}</td> <td className={sgClassNames}>{sgRecharge}</td>
<td>{ship.hullMass} {u.T}</td> <td>{ship.hullMass} {u.T}</td>

View File

@@ -307,11 +307,11 @@ export default class Module {
} }
/** /**
* Get the shield reinforcement for this module, taking in to account modifications * Get the shield multiplier for this module, taking in to account modifications
* @return {Number} the shield reinforcement of this module * @return {Number} the shield multiplier of this module
*/ */
getShieldReinforcement() { getShieldMultiplier() {
return this._getModifiedValue('shieldreinforcement'); return this._getModifiedValue('shieldmul');
} }
/** /**

View File

@@ -210,10 +210,11 @@ export default class Ship {
* @return {Number} Recovery time in seconds * @return {Number} Recovery time in seconds
*/ */
calcShieldRecovery() { calcShieldRecovery() {
if (this.shieldStrength && this.sgSlot) { if (this.shield > 0) {
let brokenRegenRate = 1 + this.sgSlot.m.getModValue('brokenregen'); let sgSlot = this.findInternalByGroup('sg');
let brokenRegenRate = 1 + sgSlot.m.getModValue('brokenregen');
// 50% of shield strength / recovery recharge rate + 15 second delay before recharge starts // 50% of shield strength / recovery recharge rate + 15 second delay before recharge starts
return ((this.shieldStrength / 2) / (this.sgSlot.m.recover * brokenRegenRate)) + 15; return ((this.shield / 2) / (sgSlot.m.recover * brokenRegenRate)) + 15;
} }
return 0; return 0;
} }
@@ -225,10 +226,11 @@ export default class Ship {
* @return {Number} 50 - 100% Recharge time in seconds * @return {Number} 50 - 100% Recharge time in seconds
*/ */
calcShieldRecharge() { calcShieldRecharge() {
if (this.shieldStrength && this.sgSlot) { if (this.shield > 0) {
let regenRate = 1 + this.sgSlot.m.getModValue('regen'); let sgSlot = this.findInternalByGroup('sg');
let regenRate = 1 + sgSlot.m.getModValue('regen');
// 50% -> 100% recharge time, Bi-Weave shields charge at 1.8 MJ/s // 50% -> 100% recharge time, Bi-Weave shields charge at 1.8 MJ/s
return (this.shieldStrength / 2) / ((this.sgSlot.m.grp == 'bsg' ? 1.8 : 1) * regenRate); return (this.shield / 2) / ((sgSlot.m.grp == 'bsg' ? 1.8 : 1) * regenRate);
} }
return 0; return 0;
} }
@@ -241,12 +243,16 @@ export default class Ship {
*/ */
calcShieldStrengthWith(sg, multiplierDelta) { calcShieldStrengthWith(sg, multiplierDelta) {
if (!sg) { if (!sg) {
if (!this.sgSlot) { let sgSlot = this.findInternalByGroup('sg');
if (!sgSlot) {
return 0; return 0;
} }
sg = this.sgSlot.m; sg = sgSlot.m;
} }
return Calc.shieldStrength(this.hullMass, this.baseShieldStrength, sg, this.shieldMultiplier + (multiplierDelta || 0));
// TODO obtain shieldMultiplier
//return Calc.shieldStrength(this.hullMass, this.baseShieldStrength, sg, this.shieldMultiplier + (multiplierDelta || 0));
return Calc.shieldStrength(this.hullMass, this.baseShieldStrength, sg, 0 + (multiplierDelta || 0));
} }
/** /**
@@ -444,7 +450,7 @@ export default class Ship {
this.updateJumpStats(); this.updateJumpStats();
} else if (name == 'shieldmul') { } else if (name == 'shieldmul') {
m.setModValue(name, value); m.setModValue(name, value);
this.updateShieldStrength(); this.updateShield();
} else if (name == 'hullboost') { } else if (name == 'hullboost') {
m.setModValue(name, value); m.setModValue(name, value);
this.updateArmour(); this.updateArmour();
@@ -475,7 +481,7 @@ export default class Ship {
this.cargoCapacity = 0; this.cargoCapacity = 0;
this.ladenMass = 0; this.ladenMass = 0;
this.armour = this.baseArmour; this.armour = this.baseArmour;
this.shieldMultiplier = 1; this.shield = this.baseShieldStrength;
this.totalCost = this.m.incCost ? this.m.discountedCost : 0; this.totalCost = this.m.incCost ? this.m.discountedCost : 0;
this.unladenMass = this.hullMass; this.unladenMass = this.hullMass;
this.totalDps = 0; this.totalDps = 0;
@@ -558,7 +564,7 @@ export default class Ship {
if (comps) { if (comps) {
this.updatePower() this.updatePower()
.updateJumpStats() .updateJumpStats()
.updateShieldStrength() .updateShield()
.updateArmour() .updateArmour()
.updateTopSpeed(); .updateTopSpeed();
} }
@@ -695,11 +701,8 @@ export default class Ship {
if (slot.m) { if (slot.m) {
this.priorityBands[slot.priority][powerUsageType(slot, slot.m)] += enabled ? slot.m.getPowerUsage() : - slot.m.getPowerUsage(); this.priorityBands[slot.priority][powerUsageType(slot, slot.m)] += enabled ? slot.m.getPowerUsage() : - slot.m.getPowerUsage();
if (ModuleUtils.isShieldGenerator(slot.m.grp)) { if (ModuleUtils.isShieldGenerator(slot.m.grp) || slot.m.grp == 'sb') {
this.updateShieldStrength(); this.updateShield();
} else if (slot.m.grp == 'sb') {
this.shieldMultiplier += slot.m.getShieldMul() * (enabled ? 1 : -1);
this.updateShieldStrength();
} }
if (slot.m.dps) { if (slot.m.dps) {
this.totalDps += slot.m.dps * (enabled ? 1 : -1); this.totalDps += slot.m.dps * (enabled ? 1 : -1);
@@ -754,6 +757,8 @@ export default class Ship {
let armourChange = (slot == this.bulkheads) || (n && n.grp == 'hr') || (old && old.grp == 'hr'); let armourChange = (slot == this.bulkheads) || (n && n.grp == 'hr') || (old && old.grp == 'hr');
let shieldChange = (n && n.grp == 'bsg') || (old && old.grp == 'bsg') || (n && n.grp == 'psg') || (old && old.grp == 'psg') || (n && n.grp == 'sg') || (old && old.grp == 'sg') || (n && n.grp == 'sb') || (old && old.grp == 'sb');
if (old) { // Old modul now being removed if (old) { // Old modul now being removed
switch (old.grp) { switch (old.grp) {
case 'ft': case 'ft':
@@ -762,9 +767,6 @@ export default class Ship {
case 'cr': case 'cr':
this.cargoCapacity -= old.cargo; this.cargoCapacity -= old.cargo;
break; break;
case 'sb':
this.shieldMultiplier -= slot.enabled ? old.getShieldMul() : 0;
break;
} }
if (slot.incCost && old.cost) { if (slot.incCost && old.cost) {
@@ -801,9 +803,6 @@ export default class Ship {
case 'cr': case 'cr':
this.cargoCapacity += n.cargo; this.cargoCapacity += n.cargo;
break; break;
case 'sb':
this.shieldMultiplier += slot.enabled ? n.getShieldMul() : 0;
break;
} }
if (slot.incCost && n.cost) { if (slot.incCost && n.cost) {
@@ -834,11 +833,13 @@ export default class Ship {
this.updatePower(); this.updatePower();
} }
if (armourChange) { if (armourChange) {
this.updateArmour();
}
if (shieldChange) {
this.updateShield();
} }
this.updateArmour();
this.updateTopSpeed(); this.updateTopSpeed();
this.updateJumpStats(); this.updateJumpStats();
this.updateShieldStrength();
} }
return this; return this;
} }
@@ -875,12 +876,26 @@ export default class Ship {
} }
/** /**
* Update Shield strength * Update shield
* @return {this} The ship instance (for chaining operations) * @return {this} The ship instance (for chaining operations)
*/ */
updateShieldStrength() { updateShield() {
this.sgSlot = this.findInternalByGroup('sg'); // Find Shield Generator slot Index if any // Base shield from generator
this.shieldStrength = this.sgSlot && this.sgSlot.enabled ? Calc.shieldStrength(this.hullMass, this.baseShieldStrength, this.sgSlot.m, this.shieldMultiplier) : 0; let baseShield = 0;
let sgSlot = this.findInternalByGroup('sg');
if (sgSlot && sgSlot.enabled) {
baseShield = Calc.shieldStrength(this.hullMass, this.baseShieldStrength, sgSlot.m, 1);
}
let shield = baseShield;
// Shield from boosters
for (let slot of this.hardpoints) {
if (slot.m && slot.m.grp == 'sb') {
shield += baseShield * slot.m.getShieldMultiplier();
}
}
this.shield = shield;
return this; return this;
} }