@Override protected String getArcAbbr(Mounted m) { final String[][] arcs = aero.isSpheroid() ? SPHEROID_ARCS : AERODYNE_ARCS; switch (m.getLocation()) { case Aero.LOC_NOSE: return arcs[0][0]; case Aero.LOC_RWING: return arcs[m.isRearMounted() ? 2 : 1][0]; case Aero.LOC_LWING: return arcs[m.isRearMounted() ? 2 : 1][1]; case Aero.LOC_AFT: return arcs[3][0]; } return super.getArcAbbr(m); }
public boolean hasWeaponInArc(int loc, boolean rearMount) { boolean hasWeapons = false; for (Mounted weap : getWeaponList()) { if ((weap.getLocation() == loc) && (weap.isRearMounted() == rearMount)) { hasWeapons = true; } } return hasWeapons; }
public boolean isRearFacing() { if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted) { return mounted.isRearMounted(); } } return false; }
@Override protected String formatLocationTableEntry(Entity entity, Mounted mounted) { String loc = entity.getLocationAbbr(mounted.getLocation()); if (mounted.isRearMounted()) { loc += "(R)"; } return loc; } }
public boolean isRearFacing() { if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted) { return mounted.isRearMounted(); } } return false; }
protected double locationMultiplier(Entity en, int loc, Mounted mount) { return en.getAlphaStrikeLocationMultiplier(loc, mount.getLocation(), mount.isRearMounted()); }
protected double locationMultiplier(Entity en, int loc, Mounted mount) { return en.getBattleForceLocationMultiplier(loc, mount.getLocation(), mount.isRearMounted()); }
/** * Returns the Compute.ARC that the weapon fires into. */ @Override public int getWeaponArc(int wn) { final Mounted mounted = getEquipment(wn); // rear mounted? if (mounted.isRearMounted()) { return Compute.ARC_REAR; } // front mounted switch (mounted.getLocation()) { case LOC_TORSO: return Compute.ARC_FORWARD; case LOC_RARM: return Compute.ARC_RIGHTARM; case LOC_LARM: return Compute.ARC_LEFTARM; case LOC_MAINGUN: return Compute.ARC_MAINGUN; default: return Compute.ARC_360; } }
/** * Provide weapon groups for capital fighters. For capital fighter purposes * we use Aero locations. */ @Override public Map<String, Integer> groupWeaponsByLocation() { Map<String, Integer> groups = new HashMap<>(); for (Mounted mounted : getTotalWeaponList()) { int loc = LOC_CAPITAL_WINGS; if ((loc == Mech.LOC_CT) || (loc == Mech.LOC_HEAD)) { loc = LOC_CAPITAL_NOSE; } if (mounted.isRearMounted() || (loc == Mech.LOC_LLEG) || (loc == Mech.LOC_RLEG)) { loc = LOC_CAPITAL_AFT; } String key = mounted.getType().getInternalName() + ":" + loc; if (null == groups.get(key)) { groups.put(key, mounted.getNWeapons()); } else { groups.put(key, groups.get(key) + mounted.getNWeapons()); } } return groups; }
/** * Iterate through current weapons and count the number in each capital * fighter location. * * @return A map with keys in the format "weaponName:loc", with the number * of weapons of that type in that location as the value. */ @Override public Map<String, Integer> groupWeaponsByLocation() { Map<String, Integer> groups = new HashMap<>(); for (Mounted mounted : getTotalWeaponList()) { int loc = mounted.getLocation(); if (isFighter() && ((loc == Aero.LOC_RWING) || (loc == Aero.LOC_LWING))) { loc = Aero.LOC_WINGS; } if (mounted.isRearMounted()) { loc = Aero.LOC_AFT; } String key = mounted.getType().getInternalName() + ":" + loc; if (null == groups.get(key)) { groups.put(key, mounted.getNWeapons()); } else { groups.put(key, groups.get(key) + mounted.getNWeapons()); } } return groups; }
public int getHeatInArc(int location, boolean rearMount) { int arcHeat = 0; for (Mounted mounted : getTotalWeaponList()) { // is the weapon usable? if (mounted.isDestroyed() || mounted.isJammed()) { continue; } if ((mounted.getLocation() == location) && (mounted.isRearMounted() == rearMount)) { arcHeat += mounted.getCurrentHeat(); } } return arcHeat; }
@Override public int getBattleForceTotalHeatGeneration(int location) { int totalHeat = 0; for (Mounted mount : getWeaponList()) { WeaponType weapon = (WeaponType) mount.getType(); if (weapon.hasFlag(WeaponType.F_ONESHOT) || getBattleForceLocationMultiplier(location, mount.getLocation(), mount.isRearMounted()) == 0) { continue; } totalHeat += weapon.getHeat(); } return totalHeat; }
@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 = a.getType().getTonnage(getEntity()) * a.getBaseShotsLeft() / ((AmmoType)a.getType()).getShots(); buffer.append(" ").append(StringUtil.makeLength(a.getName(), getPrintSize() - 25)).append(weight).append("\n"); } } return buffer; }
/** * 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; }
@Override protected String formatLocationTableEntry(Entity entity, Mounted mounted) { String str = null; if (mounted.getLocation() == Aero.LOC_RWING) { str = "TROView.RS"; } else if (mounted.getLocation() == Aero.LOC_LWING) { str = "TROView.LS"; } else { return aero.getLocationName(mounted.getLocation()); } if (!aero.isSpheroid()) { str += "Wing"; } if (mounted.isRearMounted()) { str += "R"; } return Messages.getString(str); }
/** * Worker function that takes an entity, a location, an ammo type string and the critical index * of a weapons bay in the given location and attempts to add the ammo type there. * @param entity The entity we're working on loading * @param loc The location index on the entity * @param type The ammo type string * @param bayIndex The crit index of the bay where we want to load the ammo on the location where the bay is * @return A generated critical slot entry */ private void addExtraAmmoToBay(Entity entity, int loc, String type, String bayIndex) { // here, we need to do the following: // 1: get the bay to which this ammo belongs, and add it to said bay // 2: add the ammo to the entity as a "new" piece of equipment // 3: add the ammo to a crit slot on the bay's location int bayCritIndex = Integer.parseInt(bayIndex); Mounted bay = entity.getCritical(loc, bayCritIndex - 1).getMount(); Mounted ammo = new Mounted(entity, AmmoType.get(type)); try { entity.addEquipment(ammo, loc, bay.isRearMounted()); } catch(LocationFullException lfe) { // silently swallow it, since dropship locations have about a hundred crit slots } bay.addAmmoToBay(entity.getEquipmentNum(ammo)); }
/** * Returns the Compute.ARC that the weapon fires into. */ @Override public int getWeaponArc(int wn) { final Mounted mounted = getEquipment(wn); // B-Pods need to be special-cased, the have 360 firing arc if ((mounted.getType() instanceof WeaponType) && mounted.getType().hasFlag(WeaponType.F_B_POD)) { return Compute.ARC_360; } // rear mounted? if (mounted.isRearMounted()) { return Compute.ARC_REAR; } // front mounted switch (mounted.getLocation()) { case LOC_HEAD: case LOC_CT: case LOC_RT: case LOC_LT: case LOC_RLEG: case LOC_LLEG: case LOC_LARM: case LOC_RARM: return Compute.ARC_FORWARD; default: return Compute.ARC_360; } }
/** * return the first bay of the right type in the right location with enough * damage to spare * * @param wtype * @param loc * @param rearMount * @return */ public Mounted getFirstBay(WeaponType wtype, int loc, boolean rearMount) { int weapDamage = wtype.getRoundShortAV(); if (wtype.isCapital()) { weapDamage *= 10; } for (Mounted m : getWeaponBayList()) { BayWeapon bay = (BayWeapon) m.getType(); int damage = bay.getRoundShortAV() + weapDamage; if ((bay.getAtClass() == wtype.getAtClass()) && (m.getLocation() == loc) && (m.isRearMounted() == rearMount) && (damage <= 700)) { return m; } } return null; }
protected void addHeat() { // Only add heat for first shot in strafe if (isStrafing && !isStrafingFirstShot()) { return; } if (!(toHit.getValue() == TargetRoll.IMPOSSIBLE)) { if (ae.usesWeaponBays() && !game.getOptions().booleanOption(OptionsConstants.ADVAERORULES_HEAT_BY_BAY)) { int loc = weapon.getLocation(); boolean rearMount = weapon.isRearMounted(); if (!ae.hasArcFired(loc, rearMount)) { ae.heatBuildup += ae.getHeatInArc(loc, rearMount); ae.setArcFired(loc, rearMount); } } else { ae.heatBuildup += (weapon.getCurrentHeat()); } } }
@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); } } } }