mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-09 22:55:35 +00:00
Added jitter for hardpoints
This commit is contained in:
@@ -44,6 +44,7 @@ export default class HardpointSlot extends Slot {
|
|||||||
let validMods = Modifications.validity[m.grp] || [];
|
let validMods = Modifications.validity[m.grp] || [];
|
||||||
let showModuleResistances = Persist.showModuleResistances();
|
let showModuleResistances = Persist.showModuleResistances();
|
||||||
|
|
||||||
|
console.log('Jitter is ' + m.getJitter());
|
||||||
return <div className='details' draggable='true' onDragStart={drag} onDragEnd={drop}>
|
return <div className='details' draggable='true' onDragStart={drag} onDragEnd={drop}>
|
||||||
<div className={'cb'}>
|
<div className={'cb'}>
|
||||||
<div className={'l'}>
|
<div className={'l'}>
|
||||||
@@ -67,6 +68,7 @@ export default class HardpointSlot extends Slot {
|
|||||||
{ m.getRange() ? <div className={'l'}>{translate('range')} {formats.f1(m.getRange() / 1000)}{u.km}</div> : null }
|
{ m.getRange() ? <div className={'l'}>{translate('range')} {formats.f1(m.getRange() / 1000)}{u.km}</div> : null }
|
||||||
{ m.getShieldBoost() ? <div className={'l'}>+{formats.pct1(m.getShieldBoost())}</div> : null }
|
{ m.getShieldBoost() ? <div className={'l'}>+{formats.pct1(m.getShieldBoost())}</div> : null }
|
||||||
{ m.getAmmo() ? <div className={'l'}>{translate('ammunition')}: {formats.int(m.getClip())}/{formats.int(m.getAmmo())}</div> : null }
|
{ m.getAmmo() ? <div className={'l'}>{translate('ammunition')}: {formats.int(m.getClip())}/{formats.int(m.getAmmo())}</div> : null }
|
||||||
|
{ m.getJitter() ? <div className={'l'}>{translate('jitter')}: {formats.f2(m.getJitter())}°</div> : null }
|
||||||
{ showModuleResistances && m.getExplosiveResistance() ? <div className='l'>{translate('explres')}: {formats.pct(m.getExplosiveResistance())}</div> : null }
|
{ showModuleResistances && m.getExplosiveResistance() ? <div className='l'>{translate('explres')}: {formats.pct(m.getExplosiveResistance())}</div> : null }
|
||||||
{ showModuleResistances && m.getKineticResistance() ? <div className='l'>{translate('kinres')}: {formats.pct(m.getKineticResistance())}</div> : null }
|
{ showModuleResistances && m.getKineticResistance() ? <div className='l'>{translate('kinres')}: {formats.pct(m.getKineticResistance())}</div> : null }
|
||||||
{ showModuleResistances && m.getThermalResistance() ? <div className='l'>{translate('thermres')}: {formats.pct(m.getThermalResistance())}</div> : null }
|
{ showModuleResistances && m.getThermalResistance() ? <div className='l'>{translate('thermres')}: {formats.pct(m.getThermalResistance())}</div> : null }
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ import NumberEditor from 'react-number-editor';
|
|||||||
/**
|
/**
|
||||||
* Modification
|
* Modification
|
||||||
*/
|
*/
|
||||||
export default class ModificationsMenu extends TranslatedComponent {
|
export default class Modification extends TranslatedComponent {
|
||||||
|
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
ship: React.PropTypes.object.isRequired,
|
ship: React.PropTypes.object.isRequired,
|
||||||
@@ -24,7 +24,7 @@ export default class ModificationsMenu extends TranslatedComponent {
|
|||||||
constructor(props, context) {
|
constructor(props, context) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {};
|
this.state = {};
|
||||||
this.state.value = this.props.m.getModValue(this.props.name) / 100 || 0;
|
this.state.value = this.props.name === 'jitter' ? this.props.m.getModValue(this.props.name) / 10000 : this.props.m.getModValue(this.props.name) / 100 || 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -32,7 +32,9 @@ export default class ModificationsMenu extends TranslatedComponent {
|
|||||||
* @param {Number} value The value to set
|
* @param {Number} value The value to set
|
||||||
*/
|
*/
|
||||||
_updateValue(value) {
|
_updateValue(value) {
|
||||||
let scaledValue = Math.floor(Number(value) * 100);
|
const name = this.props.name;
|
||||||
|
|
||||||
|
let scaledValue = name === 'jitter' ? Math.floor(Number(value) * 10000) : Math.floor(Number(value) * 100);
|
||||||
// Limit to +1000% / -100%
|
// Limit to +1000% / -100%
|
||||||
if (scaledValue > 100000) {
|
if (scaledValue > 100000) {
|
||||||
scaledValue = 100000;
|
scaledValue = 100000;
|
||||||
@@ -44,7 +46,6 @@ export default class ModificationsMenu extends TranslatedComponent {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let m = this.props.m;
|
let m = this.props.m;
|
||||||
let name = this.props.name;
|
|
||||||
let ship = this.props.ship;
|
let ship = this.props.ship;
|
||||||
ship.setModification(m, name, scaledValue);
|
ship.setModification(m, name, scaledValue);
|
||||||
|
|
||||||
|
|||||||
@@ -516,4 +516,11 @@ export default class Module {
|
|||||||
return this._getModifiedValue('cells');
|
return this._getModifiedValue('cells');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the jitter for this module, taking in to account modifications
|
||||||
|
* @return {Number} the jitter for this module
|
||||||
|
*/
|
||||||
|
getJitter() {
|
||||||
|
return this._getModifiedValue('jitter', true);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -359,11 +359,6 @@ function _addModifications(module, modifiers) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Jitter is in degrees not % so need to divide it by 100 to obtain the correct number
|
|
||||||
if (module.getModValue('jitter')) {
|
|
||||||
module.setModValue('jitter', module.getModValue('jitter') / 100);
|
|
||||||
}
|
|
||||||
|
|
||||||
// FD uses interval between bursts internally, so we need to translate this to a real rate of fire
|
// FD uses interval between bursts internally, so we need to translate this to a real rate of fire
|
||||||
if (module.getModValue('rof')) {
|
if (module.getModValue('rof')) {
|
||||||
module.setModValue('rof', ((1 / (1 + module.getModValue('rof') / 10000)) - 1) * 10000);
|
module.setModValue('rof', ((1 / (1 + module.getModValue('rof') / 10000)) - 1) * 10000);
|
||||||
|
|||||||
Reference in New Issue
Block a user