From 53137e0ae18323171d94ccab6ab1dfe7e1493f70 Mon Sep 17 00:00:00 2001 From: Cmdr McDonald Date: Sat, 14 Jan 2017 09:52:31 +0000 Subject: [PATCH] Add falloff for weapons --- ChangeLog.md | 1 + src/app/components/DamageDealt.jsx | 24 +++++++++++++----------- src/app/components/HardpointSlot.jsx | 1 + src/app/components/ModificationsMenu.jsx | 4 +++- src/app/shipyard/Module.js | 14 ++++++++++++++ src/app/utils/CompanionApiUtils.js | 3 +++ 6 files changed, 35 insertions(+), 12 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index 69c1bded..98a65f5d 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -1,5 +1,6 @@ #2.2.9 * Use SSL-enabled server for shortlinks + * Add falloff for weapons #2.2.8 * Fix issue where filling all internals with cargo racks would include restricted slots diff --git a/src/app/components/DamageDealt.jsx b/src/app/components/DamageDealt.jsx index 01ba84b2..f11fff69 100644 --- a/src/app/components/DamageDealt.jsx +++ b/src/app/components/DamageDealt.jsx @@ -104,18 +104,20 @@ export default class DamageDealt extends TranslatedComponent { for (let i = 0; i < ship.hardpoints.length; i++) { if (ship.hardpoints[i].m) { const m = ship.hardpoints[i].m; - const classRating = `${m.class}${m.rating}${m.missile ? '/' + m.missile : ''}`; - const effectiveness = m.getPiercing() >= against.properties.hardness ? 1 : m.getPiercing() / against.properties.hardness; - const effectiveDps = m.getDps() * effectiveness; - const effectiveSDps = m.getClip() ? (m.getClip() * m.getDps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload()) * effectiveness : effectiveDps; + if (m.getDamage() && m.grp !== 'po') { + const classRating = `${m.class}${m.rating}${m.missile ? '/' + m.missile : ''}`; + const effectiveness = m.getPiercing() >= against.properties.hardness ? 1 : m.getPiercing() / against.properties.hardness; + const effectiveDps = m.getDps() * effectiveness; + const effectiveSDps = m.getClip() ? (m.getClip() * m.getDps() / m.getRoF()) / ((m.getClip() / m.getRoF()) + m.getReload()) * effectiveness : effectiveDps; - weapons.push({ id: i, - mount: m.mount, - name: m.name || m.grp, - classRating, - effectiveDps, - effectiveSDps, - effectiveness }); + weapons.push({ id: i, + mount: m.mount, + name: m.name || m.grp, + classRating, + effectiveDps, + effectiveSDps, + effectiveness }); + } } } diff --git a/src/app/components/HardpointSlot.jsx b/src/app/components/HardpointSlot.jsx index cc1d80ac..e4d75d6e 100644 --- a/src/app/components/HardpointSlot.jsx +++ b/src/app/components/HardpointSlot.jsx @@ -74,6 +74,7 @@ export default class HardpointSlot extends Slot { { m.getDps() && m.getEps() ?
{translate('DPE')}: {formats.f1(m.getDps() / m.getEps())}
: null } { m.getRoF() ?
{translate('ROF')}: {formats.f1(m.getRoF())}{u.ps}
: null } { m.getRange() ?
{translate('range')} {formats.f1(m.getRange() / 1000)}{u.km}
: null } + { m.getFalloff() ?
{translate('falloff')} {formats.f1(m.getFalloff() / 1000)}{u.km}
: null } { m.getShieldBoost() ?
+{formats.pct1(m.getShieldBoost())}
: null } { m.getAmmo() ?
{translate('ammunition')}: {formats.int(m.getClip())}/{formats.int(m.getAmmo())}
: null } { m.getPiercing() ?
{translate('piercing')}: {formats.int(m.getPiercing())}
: null } diff --git a/src/app/components/ModificationsMenu.jsx b/src/app/components/ModificationsMenu.jsx index f38c8b1e..1a56180f 100644 --- a/src/app/components/ModificationsMenu.jsx +++ b/src/app/components/ModificationsMenu.jsx @@ -39,7 +39,9 @@ export default class ModificationsMenu extends TranslatedComponent { let list = []; for (let modName of Modifications.validity[m.grp]) { - list.push(); + if (Modifications.modifications[modName].type != 'hidden') { + list.push(); + } } return { list }; diff --git a/src/app/shipyard/Module.js b/src/app/shipyard/Module.js index 37879de6..36911b33 100755 --- a/src/app/shipyard/Module.js +++ b/src/app/shipyard/Module.js @@ -286,6 +286,20 @@ export default class Module { return this._getModifiedValue('range'); } + /** + * Get the falloff for this module, taking in to account modifications + * @return {Number} the falloff of this module + */ + getFalloff() { + if (this.getModValue('fallofffromrange')) { + return this.getRange(); + } else { + const falloff = this._getModifiedValue('falloff'); + const range = this.getRange(); + return (falloff > range ? range : falloff); + } + } + /** * Get the range (in terms of seconds, for FSDI) for this module, taking in to account modifications * @return {Number} the range of this module diff --git a/src/app/utils/CompanionApiUtils.js b/src/app/utils/CompanionApiUtils.js index 11030548..234ed48d 100644 --- a/src/app/utils/CompanionApiUtils.js +++ b/src/app/utils/CompanionApiUtils.js @@ -305,6 +305,9 @@ function _addModifications(module, modifiers, blueprint, grade) { } else if (modifiers.modifiers[i].name === 'mod_weapon_burst_rof') { // For some reason this is a non-normalised percentage (i.e. 12.23% is 12.23 value rather than 0.1223 as everywhere else), so fix that here module.setModValue('burstrof', modifiers.modifiers[i].value * 100); + } else if (modifiers.modifiers[i].name === 'mod_weapon_falloffrange_from_range') { + // Obtain the falloff value directly from the range + module.setModValue('fallofffromrange', 1); } else { // Look up the modifiers to find what we need to do const modifierActions = Modifications.modifierActions[modifiers.modifiers[i].name];