Problem: When a ship is laying a minefield, it shows all the torpedoes requested as being converted to mines and computes fuel use based on this. This is done even when fewer torpedoes will get the minefield to the maximum available size. Before: getMineLayTorps: function (ship) { var torps = ship.ammo; var fc = ship.friendlycode.toLowerCase(); if (fc.substr(0, 2) == "md") { if (fc == "mdh") torps = Math.floor(ship.ammo / 2); else if (fc == "mdq") torps = Math.floor(ship.ammo / 4); else { var mdVal = fc.replace("md", ""); try { //md1 - md0 var amt = parseInt(mdVal); if (amt == 0) amt = 10; amt = amt * 10; if (amt < torps) torps = amt; } catch (err) { } } } return torps; }, After: getMineLayTorps: function (ship) { var torps = ship.ammo; var fc = ship.friendlycode.toLowerCase(); if (fc.substr(0, 2) == "md") { if (fc == "mdh") torps = Math.floor(ship.ammo / 2); else if (fc == "mdq") torps = Math.floor(ship.ammo / 4); else { var mdVal = fc.replace("md", ""); try { //md1 - md0 var amt = parseInt(mdVal); if (amt == 0) amt = 10; amt = amt * 10; if (amt < torps) torps = amt; } catch (err) { } } } // The 'torps' variable is now the number of torpedoes requested // to be layed, up to the number the ship has. It is now time // to determine exactly how many can be layed, so that correct // information is displayed to the user, and used to estimate // fuel usage. // Determine if we are inside of one of our minefields var isWeb = (ship.mission == 8); var minefield = null; var closest = 10000.0; var closestField = null; for (var j = 0; j < minefields.length; j++) { var closestField = minefields[j]; if (closestField.isweb == isWeb && closestField.ownerid == ship.ownerid) { var dist = Math.dist(ship.x, ship.y, closestField.x, closestField.y); if (dist < closest) { minefield = closestField; closest = dist; } if (closest == 0) break; } } // If we're in the closest minefield, we'll be expanding it var newField = true; if (minefield != null) { if (closest <= minefield.radius) newField = false; } // Determine the maximum size of a minefield var max = 10000; if (vgap.advActive(48)) max = 22500; // Calculate number of mines requested var units = 0; units = torps * ship.torpedoid * ship.torpedoid); //robots lay 4 times more if (vgap.player.raceid == 9) units = units * 4; // Check for minefield size if (newField == false) { // If minefield exceeds maximum size, recalculate the number // of torpedoes to be used. if ((minefield.units + units) > max) { units = max - minefield.units; //robots lay 4 times more if (vgap.player.raceid == 9) units = units / 4.0; // This could be either 'ceil' or 'floor', depending on // what the Host does. torps = ceil((1.0 * units) / (ship.torpedoid * ship.torpedoid)); } } else { // If new minefield is larger than maximum size, recalculate // the number of torpedoes to be used. if (units > max) { units = max; //robots lay 4 times more if (vgap.player.raceid == 9) units = units / 4.0; // This could be either 'ceil' or 'floor', depending on // what the Host does. torps = ceil((1.0 * units) / (ship.torpedoid * ship.torpedoid)); } } return torps; },