mirror of
https://github.com/EDCD/coriolis.git
synced 2025-12-08 22:33:24 +00:00
Fix for engineered modules in SLEF imports from Inara.
This commit is contained in:
@@ -95,49 +95,49 @@ export function shipFromLoadoutJSON(json) {
|
|||||||
throw 'Unknown bulkheads "' + module.Item + '"';
|
throw 'Unknown bulkheads "' + module.Item + '"';
|
||||||
}
|
}
|
||||||
ship.bulkheads.enabled = true;
|
ship.bulkheads.enabled = true;
|
||||||
if (module.Engineering) _addModifications(ship.bulkheads.m, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level, module.Engineering.ExperimentalEffect);
|
if (module.Engineering) _addModifications(ship.bulkheads.m, module.Engineering.Modifiers, module.Engineering.Quality, module.Engineering.BlueprintName, module.Engineering.Level, module.Engineering.ExperimentalEffect);
|
||||||
break;
|
break;
|
||||||
case 'powerplant':
|
case 'powerplant':
|
||||||
const powerplant = _moduleFromFdName(module.Item);
|
const powerplant = _moduleFromFdName(module.Item);
|
||||||
ship.use(ship.standard[0], powerplant, true);
|
ship.use(ship.standard[0], powerplant, true);
|
||||||
ship.standard[0].enabled = module.On;
|
ship.standard[0].enabled = module.On;
|
||||||
ship.standard[0].priority = module.Priority;
|
ship.standard[0].priority = module.Priority;
|
||||||
if (module.Engineering) _addModifications(powerplant, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level, module.Engineering.ExperimentalEffect);
|
if (module.Engineering) _addModifications(powerplant, module.Engineering.Modifiers, module.Engineering.Quality, module.Engineering.BlueprintName, module.Engineering.Level, module.Engineering.ExperimentalEffect);
|
||||||
break;
|
break;
|
||||||
case 'mainengines':
|
case 'mainengines':
|
||||||
const thrusters = _moduleFromFdName(module.Item);
|
const thrusters = _moduleFromFdName(module.Item);
|
||||||
ship.use(ship.standard[1], thrusters, true);
|
ship.use(ship.standard[1], thrusters, true);
|
||||||
ship.standard[1].enabled = module.On;
|
ship.standard[1].enabled = module.On;
|
||||||
ship.standard[1].priority = module.Priority;
|
ship.standard[1].priority = module.Priority;
|
||||||
if (module.Engineering) _addModifications(thrusters, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level, module.Engineering.ExperimentalEffect);
|
if (module.Engineering) _addModifications(thrusters, module.Engineering.Modifiers, module.Engineering.Quality, module.Engineering.BlueprintName, module.Engineering.Level, module.Engineering.ExperimentalEffect);
|
||||||
break;
|
break;
|
||||||
case 'frameshiftdrive':
|
case 'frameshiftdrive':
|
||||||
const frameshiftdrive = _moduleFromFdName(module.Item);
|
const frameshiftdrive = _moduleFromFdName(module.Item);
|
||||||
ship.use(ship.standard[2], frameshiftdrive, true);
|
ship.use(ship.standard[2], frameshiftdrive, true);
|
||||||
ship.standard[2].enabled = module.On;
|
ship.standard[2].enabled = module.On;
|
||||||
ship.standard[2].priority = module.Priority;
|
ship.standard[2].priority = module.Priority;
|
||||||
if (module.Engineering) _addModifications(frameshiftdrive, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level, module.Engineering.ExperimentalEffect);
|
if (module.Engineering) _addModifications(frameshiftdrive, module.Engineering.Modifiers, module.Engineering.Quality, module.Engineering.BlueprintName, module.Engineering.Level, module.Engineering.ExperimentalEffect);
|
||||||
break;
|
break;
|
||||||
case 'lifesupport':
|
case 'lifesupport':
|
||||||
const lifesupport = _moduleFromFdName(module.Item);
|
const lifesupport = _moduleFromFdName(module.Item);
|
||||||
ship.use(ship.standard[3], lifesupport, true);
|
ship.use(ship.standard[3], lifesupport, true);
|
||||||
ship.standard[3].enabled = module.On === true;
|
ship.standard[3].enabled = module.On === true;
|
||||||
ship.standard[3].priority = module.Priority;
|
ship.standard[3].priority = module.Priority;
|
||||||
if (module.Engineering) _addModifications(lifesupport, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level, module.Engineering.ExperimentalEffect);
|
if (module.Engineering) _addModifications(lifesupport, module.Engineering.Modifiers, module.Engineering.Quality, module.Engineering.BlueprintName, module.Engineering.Level, module.Engineering.ExperimentalEffect);
|
||||||
break;
|
break;
|
||||||
case 'powerdistributor':
|
case 'powerdistributor':
|
||||||
const powerdistributor = _moduleFromFdName(module.Item);
|
const powerdistributor = _moduleFromFdName(module.Item);
|
||||||
ship.use(ship.standard[4], powerdistributor, true);
|
ship.use(ship.standard[4], powerdistributor, true);
|
||||||
ship.standard[4].enabled = module.On;
|
ship.standard[4].enabled = module.On;
|
||||||
ship.standard[4].priority = module.Priority;
|
ship.standard[4].priority = module.Priority;
|
||||||
if (module.Engineering) _addModifications(powerdistributor, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level, module.Engineering.ExperimentalEffect);
|
if (module.Engineering) _addModifications(powerdistributor, module.Engineering.Modifiers, module.Engineering.Quality, module.Engineering.BlueprintName, module.Engineering.Level, module.Engineering.ExperimentalEffect);
|
||||||
break;
|
break;
|
||||||
case 'radar':
|
case 'radar':
|
||||||
const sensors = _moduleFromFdName(module.Item);
|
const sensors = _moduleFromFdName(module.Item);
|
||||||
ship.use(ship.standard[5], sensors, true);
|
ship.use(ship.standard[5], sensors, true);
|
||||||
ship.standard[5].enabled = module.On;
|
ship.standard[5].enabled = module.On;
|
||||||
ship.standard[5].priority = module.Priority;
|
ship.standard[5].priority = module.Priority;
|
||||||
if (module.Engineering) _addModifications(sensors, module.Engineering.Modifiers, module.Engineering.BlueprintName, module.Engineering.Level, module.Engineering.ExperimentalEffect);
|
if (module.Engineering) _addModifications(sensors, module.Engineering.Modifiers, module.Engineering.Quality, module.Engineering.BlueprintName, module.Engineering.Level, module.Engineering.ExperimentalEffect);
|
||||||
break;
|
break;
|
||||||
case 'fueltank':
|
case 'fueltank':
|
||||||
const fueltank = _moduleFromFdName(module.Item);
|
const fueltank = _moduleFromFdName(module.Item);
|
||||||
@@ -224,7 +224,7 @@ export function shipFromLoadoutJSON(json) {
|
|||||||
|
|
||||||
for (const i of modsToAdd) {
|
for (const i of modsToAdd) {
|
||||||
if (i.json.Engineering) {
|
if (i.json.Engineering) {
|
||||||
_addModifications(i.coriolisMod, i.json.Engineering.Modifiers, i.json.Engineering.BlueprintName, i.json.Engineering.Level, i.json.Engineering.ExperimentalEffect);
|
_addModifications(i.coriolisMod, i.json.Engineering.Modifiers, i.json.Engineering.Quality, i.json.Engineering.BlueprintName, i.json.Engineering.Level, i.json.Engineering.ExperimentalEffect);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// We don't have any information on it so guess it's priority 5 and disabled
|
// We don't have any information on it so guess it's priority 5 and disabled
|
||||||
@@ -241,12 +241,13 @@ export function shipFromLoadoutJSON(json) {
|
|||||||
* Add the modifications for a module
|
* Add the modifications for a module
|
||||||
* @param {Module} module the module
|
* @param {Module} module the module
|
||||||
* @param {Object} modifiers the modifiers
|
* @param {Object} modifiers the modifiers
|
||||||
|
* @param {float} quality quality of the modifiers 0 to 1
|
||||||
* @param {Object} blueprint the blueprint of the modification
|
* @param {Object} blueprint the blueprint of the modification
|
||||||
* @param {Object} grade the grade of the modification
|
* @param {Object} grade the grade of the modification
|
||||||
* @param {Object} specialModifications special modification
|
* @param {Object} specialModifications special modification
|
||||||
*/
|
*/
|
||||||
function _addModifications(module, modifiers, blueprint, grade, specialModifications) {
|
function _addModifications(module, modifiers, quality, blueprint, grade, specialModifications) {
|
||||||
if (!modifiers) return;
|
if (!modifiers && !quality) return;
|
||||||
let special;
|
let special;
|
||||||
if (specialModifications) {
|
if (specialModifications) {
|
||||||
if (specialModifications == 'special_plasma_slug') {
|
if (specialModifications == 'special_plasma_slug') {
|
||||||
@@ -268,36 +269,54 @@ function _addModifications(module, modifiers, blueprint, grade, specialModificat
|
|||||||
module.blueprint.special = special;
|
module.blueprint.special = special;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (const i in modifiers) {
|
if (modifiers) {
|
||||||
// Some special modifications
|
for (const i in modifiers) {
|
||||||
// Look up the modifiers to find what we need to do
|
// Some special modifications
|
||||||
const findMod = val => Object.keys(Modifications.modifierActions).find(elem => elem.toString().toLowerCase().replace(/(outfittingfieldtype_|persecond)/igm, '') === val.toString().toLowerCase().replace(/(outfittingfieldtype_|persecond)/igm, ''));
|
// Look up the modifiers to find what we need to do
|
||||||
const modifierActions = Modifications.modifierActions[findMod(modifiers[i].Label)];
|
const findMod = val => Object.keys(Modifications.modifierActions).find(elem => elem.toString().toLowerCase().replace(/(outfittingfieldtype_|persecond)/igm, '') === val.toString().toLowerCase().replace(/(outfittingfieldtype_|persecond)/igm, ''));
|
||||||
// TODO: Figure out how to scale this value.
|
const modifierActions = Modifications.modifierActions[findMod(modifiers[i].Label)];
|
||||||
if (!!modifiers[i].LessIsGood) {
|
// TODO: Figure out how to scale this value.
|
||||||
|
if (!!modifiers[i].LessIsGood) {
|
||||||
|
|
||||||
}
|
|
||||||
let value = (modifiers[i].Value / modifiers[i].OriginalValue * 100 - 100) * 100;
|
|
||||||
if (value === Infinity) {
|
|
||||||
value = modifiers[i].Value * 100;
|
|
||||||
}
|
|
||||||
if (modifiers[i].Label.search('DamageFalloffRange') >= 0) {
|
|
||||||
value = (modifiers[i].Value / module.range - 1) * 100;
|
|
||||||
}
|
|
||||||
if (modifiers[i].Label.search('Resistance') >= 0) {
|
|
||||||
value = (modifiers[i].Value * 100) - (modifiers[i].OriginalValue * 100);
|
|
||||||
}
|
|
||||||
if (modifiers[i].Label.search('ShieldMultiplier') >= 0 || modifiers[i].Label.search('DefenceModifierHealthMultiplier') >= 0) {
|
|
||||||
value = ((100 + modifiers[i].Value) / (100 + modifiers[i].OriginalValue) * 100 - 100) * 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Carry out the required changes
|
|
||||||
for (const action in modifierActions) {
|
|
||||||
if (isNaN(modifierActions[action])) {
|
|
||||||
module.setModValue(action, modifierActions[action]);
|
|
||||||
} else {
|
|
||||||
module.setModValue(action, value, true);
|
|
||||||
}
|
}
|
||||||
|
let value = (modifiers[i].Value / modifiers[i].OriginalValue * 100 - 100) * 100;
|
||||||
|
if (value === Infinity) {
|
||||||
|
value = modifiers[i].Value * 100;
|
||||||
|
}
|
||||||
|
if (modifiers[i].Label.search('DamageFalloffRange') >= 0) {
|
||||||
|
value = (modifiers[i].Value / module.range - 1) * 100;
|
||||||
|
}
|
||||||
|
if (modifiers[i].Label.search('Resistance') >= 0) {
|
||||||
|
value = (modifiers[i].Value * 100) - (modifiers[i].OriginalValue * 100);
|
||||||
|
}
|
||||||
|
if (modifiers[i].Label.search('ShieldMultiplier') >= 0 || modifiers[i].Label.search('DefenceModifierHealthMultiplier') >= 0) {
|
||||||
|
value = ((100 + modifiers[i].Value) / (100 + modifiers[i].OriginalValue) * 100 - 100) * 100;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Carry out the required changes
|
||||||
|
for (const action in modifierActions) {
|
||||||
|
if (isNaN(modifierActions[action])) {
|
||||||
|
module.setModValue(action, modifierActions[action]);
|
||||||
|
} else {
|
||||||
|
module.setModValue(action, value, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (quality) {
|
||||||
|
if (module.blueprint.grades) {
|
||||||
|
const features = module.blueprint.grades[Number(grade)].features;
|
||||||
|
Object.keys(features).map(featureKey => {
|
||||||
|
/*
|
||||||
|
Here we compute the value to use for this feature based on the range and quality.
|
||||||
|
We do this by finding the difference between the low and high ends of the range.
|
||||||
|
This gives us the maximum increase at 100% quality. Then we multiply this number by
|
||||||
|
the quality to determine the actual increase. Lastly we add the actual increase to
|
||||||
|
the low end of the range back in to determine the final value.
|
||||||
|
Value = ((High End of Range - Low End of Range) * Quality) + Low End of Range
|
||||||
|
*/
|
||||||
|
let value = (((features[featureKey][1] * 100) - (features[featureKey][0] * 100) * Number(quality)) + (features[featureKey][0] * 100)) * 100;
|
||||||
|
module.setModValue(featureKey, value, true);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user