/** * Checks to see if this point defense/AMS bay can engage a capital missile * This should return true. Only when handling capital missile attacks can this be false. */ protected boolean canEngageCapitalMissile(Mounted counter) { if (counter.getBayWeapons().size() < 2) { return false; } else { return true; } }
/** * Checks to see if this point defense/AMS bay can engage a capital missile * This should return true. Only when handling capital missile attacks can this be false. */ protected boolean canEngageCapitalMissile(Mounted counter) { if (counter.getBayWeapons().size() < 2) { return false; } else { return true; } }
/** * Checks to see if this point defense/AMS bay can engage a capital missile * This should return true. Only when handling capital missile attacks can this be false. */ protected boolean canEngageCapitalMissile(Mounted counter) { if (counter.getBayWeapons().size() < 2) { return false; } else { return true; } }
/** * Checks to see if this point defense/AMS bay can engage a capital missile * This should return true. Only when handling capital missile attacks can this be false. */ protected boolean canEngageCapitalMissile(Mounted counter) { if (counter.getBayWeapons().size() < 2) { return false; } else { return true; } }
/** * return the bay of the current weapon * * @param bayID * @return */ public Mounted whichBay(int bayID) { for (Mounted m : getWeaponBayList()) { for (int wId : m.getBayWeapons()) { // find the weapon and determine if it is there if (wId == bayID) { return m; } } } return null; }
protected void getMountedAmmo() { final String METHOD_NAME = "getMountedAmmo()"; for (int wId : weapon.getBayWeapons()) { Mounted bayW = ae.getEquipment(wId); // check the currently loaded ammo bayWAmmo = bayW.getLinked(); if (bayWAmmo == null) {// Can't happen. w/o legal ammo, the weapon // *shouldn't* fire. logDebug(METHOD_NAME, "Handler can't find any ammo! Oh no!"); } } }
private int calcBayDamageAndHeat() { int damage = 0; for (int wId : weapon.getBayWeapons()) { Mounted bayW = ae.getEquipment(wId); WeaponType bayWType = ((WeaponType) bayW.getType()); damage += (int) bayWType.getShortAV(); ae.heatBuildup += bayW.getCurrentHeat(); missileArmor = bayWType.missileArmor; } return damage; }
@Override protected int getCapMisMod() { int mod = 0; for (int wId : weapon.getBayWeapons()) { int curr_mod = 0; Mounted bayW = ae.getEquipment(wId); // check the currently loaded ammo Mounted bayWAmmo = bayW.getLinked(); AmmoType atype = (AmmoType) bayWAmmo.getType(); curr_mod = getCritMod(atype); if (curr_mod > mod) { mod = curr_mod; } } return mod; }
@Override protected int getCapMisMod() { int mod = 0; for (int wId : weapon.getBayWeapons()) { int curr_mod = 0; Mounted bayW = ae.getEquipment(wId); // check the currently loaded ammo Mounted bayWAmmo = bayW.getLinked(); AmmoType atype = (AmmoType) bayWAmmo.getType(); curr_mod = getCritMod(atype); if (curr_mod > mod) { mod = curr_mod; } } return mod; }
/** * Method that collects the linked ammo type for a weapon bay * We need this to pass through to server without using the ammo * in the process */ private AmmoType getBayAmmoType() { final String METHOD_NAME = "getBayAmmoType()"; AmmoType at = null; for (int wId : weapon.getBayWeapons()) { Mounted bayW = ae.getEquipment(wId); // check the currently loaded ammo Mounted bayWAmmo = bayW.getLinked(); if (bayWAmmo == null) { logDebug(METHOD_NAME, "Handler can't find any ammo! Oh no!"); continue; } //Once we have some ammo to send to the server, stop looking at = (AmmoType) bayWAmmo.getType(); break; } return at; }
@Override public int getMaxRange(Mounted weapon) { int mrange = RANGE_SHORT; Entity ae = weapon.getEntity(); if(null != ae) { for (int wId : weapon.getBayWeapons()) { Mounted bayW = ae.getEquipment(wId); WeaponType bayWType = (WeaponType) bayW.getType(); if (bayWType.getMaxRange(bayW) > mrange) { mrange = bayWType.getMaxRange(bayW); } } } return mrange; } }
@Override protected void useAmmo() { getMountedAmmo(); Mounted bayW = bayWAmmo.getLinkedBy(); int shots = (bayW.getCurrentShots() * weapon.getBayWeapons().size()); for (int i = 0; i < shots; i++) { if (null == bayWAmmo || bayWAmmo.getUsableShotsLeft() < 1) { // try loading something else ae.loadWeaponWithSameAmmo(bayW); bayWAmmo = bayW.getLinked(); } if (null != bayWAmmo) { bayWAmmo.setShotsLeft(bayWAmmo.getBaseShotsLeft() - 1); } } }
@Override public StringBuffer printWeapon() { if (!getEntity().usesWeaponBays()) { return super.printWeapon(); } StringBuffer buffer = new StringBuffer(); for (Mounted m : getEntity().getWeaponBayList()) { buffer.append(m.getName()).append(" ") .append(getLocationAbbr(m.getLocation())); if (m.isRearMounted()) { buffer.append(" (R)"); } buffer.append("\n"); for (Integer wNum : m.getBayWeapons()) { final Mounted w = getEntity().getEquipment(wNum); buffer.append(" ").append(StringUtil.makeLength(w.getName(), getPrintSize() - 25)).append(w.getType().getTonnage(getEntity())) .append("\n"); } for (Integer aNum : m.getBayAmmo()) { final Mounted a = getEntity().getEquipment(aNum); double weight = ceil(a.getType().getTonnage(getEntity()) * a.getBaseShotsLeft() / ((AmmoType)a.getType()).getShots(), Ceil.HALFTON); buffer.append(" ").append(StringUtil.makeLength(a.getName(), getPrintSize() - 25)).append(weight).append("\n"); } } return buffer; }
public boolean hasLinkedMGA(Mounted mounted) { for (Mounted m : getWeaponList()) { if ((m.getLocation() == mounted.getLocation()) && m.getType().hasFlag(WeaponType.F_MGA) && !(m.isDestroyed() || m.isBreached()) && m.getBayWeapons().contains(getEquipmentNum(mounted)) && m.getType().hasModes() && m.curMode().equals("Linked")) { return true; } } return false; }
/** * */ protected void checkAmmo(WeaponAttackAction waa, IGame g) { Entity ae = waa.getEntity(g); Mounted m = ae.getEquipment(waa.getWeaponId()); for (int wId : m.getBayWeapons()) { Mounted weapon = ae.getEquipment(wId); Mounted ammo = weapon.getLinked(); if (ammo == null || ammo.getUsableShotsLeft() < 1) { ae.loadWeaponWithSameAmmo(weapon); ammo = weapon.getLinked(); } } }
@Override protected void useAmmo() { final String METHOD_NAME = "useAmmo()"; for (int wId : weapon.getBayWeapons()) { Mounted bayW = ae.getEquipment(wId); // check the currently loaded ammo Mounted bayWAmmo = bayW.getLinked(); if (bayWAmmo == null) {// Can't happen. w/o legal ammo, the weapon // *shouldn't* fire. logDebug(METHOD_NAME, "Handler can't find any ammo! Oh no!"); } int shots = bayW.getCurrentShots(); for (int i = 0; i < shots; i++) { if (null == bayWAmmo || bayWAmmo.getUsableShotsLeft() < 1) { // try loading something else ae.loadWeaponWithSameAmmo(bayW); bayWAmmo = bayW.getLinked(); } if (null != bayWAmmo) { bayWAmmo.setShotsLeft(bayWAmmo.getBaseShotsLeft() - 1); } } } }
@Override protected void useAmmo() { final String METHOD_NAME = "useAmmo()"; for (int wId : weapon.getBayWeapons()) { Mounted bayW = ae.getEquipment(wId); // check the currently loaded ammo Mounted bayWAmmo = bayW.getLinked(); if (bayWAmmo == null) {// Can't happen. w/o legal ammo, the weapon // *shouldn't* fire. logDebug(METHOD_NAME, "Handler can't find any ammo! Oh no!"); } int shots = bayW.getCurrentShots(); for (int i = 0; i < shots; i++) { if (null == bayWAmmo || bayWAmmo.getUsableShotsLeft() < 1) { // try loading something else ae.loadWeaponWithSameAmmo(bayW); bayWAmmo = bayW.getLinked(); } if (null != bayWAmmo) { bayWAmmo.setShotsLeft(bayWAmmo.getBaseShotsLeft() - 1); } } } }
@Override protected void addHeat() { // Only add heat for first shot in strafe if (isStrafing && !isStrafingFirstShot()) { return; } if (!(toHit.getValue() == TargetRoll.IMPOSSIBLE)) { if (game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_HEAT_BY_BAY)) { for (int wId : weapon.getBayWeapons()) { Mounted m = ae.getEquipment(wId); ae.heatBuildup += m.getCurrentHeat(); } } else { int loc = weapon.getLocation(); boolean rearMount = weapon.isRearMounted(); if (!ae.hasArcFired(loc, rearMount)) { ae.heatBuildup += ae.getHeatInArc(loc, rearMount); ae.setArcFired(loc, rearMount); } } } }
/** * We need to check whether the weapon is mounted in LOC_AFT in addition to * isRearMounted() */ @Override public int getBattleForceTotalHeatGeneration(boolean allowRear) { int totalHeat = 0; for (Mounted mount : getWeaponList()) { WeaponType weapon = (WeaponType) mount.getType(); if (weapon instanceof BayWeapon) { for (int index : mount.getBayWeapons()) { totalHeat += ((WeaponType) (getEquipment(index).getType())).getHeat(); } } if (weapon.hasFlag(WeaponType.F_ONESHOT) || (allowRear && !mount.isRearMounted() && mount.getLocation() != LOC_AFT) || (!allowRear && (mount.isRearMounted() || mount.getLocation() == LOC_AFT))) { continue; } totalHeat += weapon.getHeat(); } return totalHeat; }
/** * Returns how many shots the weapon is using */ public int getCurrentShots() { WeaponType wtype = (WeaponType) getType(); int nShots = getNumShots(wtype, curMode(), false); // sets number of shots for MG arrays if (wtype.hasFlag(WeaponType.F_MGA)) { nShots = 0; for(int eqn : getBayWeapons()) { Mounted m = entity.getEquipment(eqn); if(null == m) { continue; } if ((m.getLocation() == getLocation()) && !m.isDestroyed() && !m.isBreached() && m.getType().hasFlag(WeaponType.F_MG) && (((WeaponType) m.getType()).getRackSize() == ((WeaponType) getType()) .getRackSize())) { nShots++; } } } return nShots; }