/** * Worker function that refreshes the combo box with "up-to-date" ammo names. */ public void refreshAmmoBinNames() { int selectedIndex = ammoBins.getSelectedIndex(); ammoBins.removeAllItems(); int currentIndex = 0; for(Mounted ammoBin : matchingAmmoBins) { ammoBins.addItem("(" + ammoBin.getEntity().getLocationAbbr(ammoBin.getLocation()) + ") " + ammoBin.getName()); if(m_mounted.getLinked() == ammoBin) { selectedIndex = currentIndex; } currentIndex++; } if(selectedIndex >= 0) { ammoBins.setSelectedIndex(selectedIndex); } validate(); }
/** * Assign APDS systems to the most dangerous incoming missile attacks. This * should only be called once per turn, or AMS will get extra attacks */ public WeaponAttackAction assignAPDS(List<WeaponHandler> vAttacks) { // Shouldn't have null entity, but if we do... if (getEntity() == null) { return null; } // Ensure we only target attacks in our arc & range List<WeaponAttackAction> vAttacksInArc = new Vector<>(vAttacks.size()); for (WeaponHandler wr : vAttacks) { boolean isInArc = Compute.isInArc(getEntity().getGame(), getEntity().getId(), getEntity().getEquipmentNum(this), getEntity().getGame().getEntity(wr.waa.getEntityId())); boolean isInRange = getEntity().getPosition().distance( wr.getWaa().getTarget(getEntity().getGame()).getPosition()) <= 3; if (isInArc && isInRange) { vAttacksInArc.add(wr.waa); } } // find the most dangerous salvo by expected damage WeaponAttackAction waa = Compute.getHighestExpectedDamage(getEntity() .getGame(), vAttacksInArc, true); if (waa != null) { waa.addCounterEquipment(this); return waa; } return null; }
ammoBins.insertItemAt("(" + ammoBin.getEntity().getLocationAbbr(ammoBin.getLocation()) + ") " + selectedAmmoType.getName(), index);
/** * Returns true if this Mounted is an APDS. * @return */ public boolean isAPDS() { if ((getEntity() instanceof BattleArmor) && getType().getInternalName().equals("ISBAAPDS")) { return true; } else if (getType() instanceof WeaponType) { return ((WeaponType)getType()).getAmmoType() == AmmoType.T_APDS; } else { return false; } }
output.append("\" shots=\""); output.append(String.valueOf(mount.getBaseShotsLeft())); if (mount.getEntity().usesWeaponBays()) { output.append("\" capacity=\"") .append(String.valueOf(mount.getAmmoCapacity()));
desc.append(")"); if (getEntity() instanceof BattleArmor) { if (getBaMountLoc() == BattleArmor.MOUNT_LOC_BODY) { desc.append(" (Body)");
at = vAmmo.elementAt(i); if ((at.getRackSize() == wt.getRackSize()) && at.isLegal(mounted.getEntity().getTechLevelYear(), mounted.getType().getTechLevel(mounted.getEntity().getTechLevelYear()), mounted.getEntity().isMixedTech())) { return at; mounted.getType().getTechLevel(3071), at .getTechLevel(3071), false, mounted .getEntity().isMixedTech()))) { 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; } }
weaponName.setText("(" + weapon.getEntity().getLocationAbbr(weapon.getLocation()) + ") " + weapon.getName()); add(weaponName, GBC.std()); for(Mounted ammoBin : weapon.getEntity().getAmmo()) { if((ammoBin.getLocation() != Entity.LOC_NONE) && ((WeaponType) weapon.getType()).getAmmoType() == ((AmmoType) ammoBin.getType()).getAmmoType()) {
srcModel.swapIdx(dragSourceIndex, dragTargetIndex); dragSourceIndex = currentIndex; Entity ent = weap1.getEntity();
private AmmoType getValidAmmoType(IGame game, Mounted mounted, String ammoString) { final Entity e = mounted.getEntity(); final int year = game.getOptions().intOption(OptionsConstants.ALLOWED_YEAR); //$NON-NLS-1$ final EquipmentType currentAmmoType = mounted.getType();
/** * Method that checks to see if our capital missile bay is in waypoint launch mode * Only available in space games * @return */ public boolean isInWaypointLaunchMode() { if ((curMode().equals(Weapon.Mode_CapMissile_Waypoint_Bearing_Ext) || curMode().equals(Weapon.Mode_CapMissile_Waypoint_Bearing_Long) || curMode().equals(Weapon.Mode_CapMissile_Waypoint_Bearing_Med) || curMode().equals(Weapon.Mode_CapMissile_Waypoint_Bearing_Short) || curMode().equals(Weapon.Mode_CapMissile_Waypoint)) && getEntity().isSpaceborne()) { return true; } return false; }
/** * Method that checks to see if our capital missile bay is in bearings-only mode * Only available in space games * @return */ public boolean isInBearingsOnlyMode() { if ((curMode().equals(Weapon.Mode_CapMissile_Bearing_Ext) || curMode().equals(Weapon.Mode_CapMissile_Bearing_Long) || curMode().equals(Weapon.Mode_CapMissile_Bearing_Med) || curMode().equals(Weapon.Mode_CapMissile_Bearing_Short) || curMode().equals(Weapon.Mode_CapMissile_Waypoint_Bearing_Ext) || curMode().equals(Weapon.Mode_CapMissile_Waypoint_Bearing_Long) || curMode().equals(Weapon.Mode_CapMissile_Waypoint_Bearing_Med) || curMode().equals(Weapon.Mode_CapMissile_Waypoint_Bearing_Short)) && getEntity().isSpaceborne()) { return true; } return false; }
/** * Method that adds/removes available capital missile modes as we move between space and atmospheric maps * Called by Entity.setGameOptions(), which is in turn called during a mode change by server. */ //Though we can't currently switch maps, this is needed to ensure space-only modes are removed on ground maps public void setModesForMapType() { //If the entity is not in space, remove these modes, which get set up based on game options in Weapon before game type is known if (!getEntity().isSpaceborne()) { getType().removeMode(Weapon.Mode_CapMissile_Waypoint_Bearing_Ext); getType().removeMode(Weapon.Mode_CapMissile_Waypoint_Bearing_Long); getType().removeMode(Weapon.Mode_CapMissile_Waypoint_Bearing_Med); getType().removeMode(Weapon.Mode_CapMissile_Waypoint_Bearing_Short); getType().removeMode(Weapon.Mode_CapMissile_Waypoint); getType().removeMode(Weapon.Mode_CapMissile_Tele_Operated); getType().removeMode(Weapon.Mode_CapMissile_Bearing_Ext); getType().removeMode(Weapon.Mode_CapMissile_Bearing_Long); getType().removeMode(Weapon.Mode_CapMissile_Bearing_Med); getType().removeMode(Weapon.Mode_CapMissile_Bearing_Short); } /* //Placeholder. This will be used to add the space modes back when we're able to switch maps. if (getEntity().isSpaceborne()) { } */ }
for (Mounted counter : lCounters) { Entity pdEnt = counter.getEntity();
Entity pdEnt = counter.getEntity(); boolean isInArc;
int bayDamage = 0; for(int weaponID : weapon.getBayWeapons()) { Mounted bayWeapon = weapon.getEntity().getEquipment(weaponID); WeaponType weaponType = (WeaponType) bayWeapon.getType(); int maxRange = game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_RANGE) ?
for (Mounted counter : lCounters) { Entity pdEnt = counter.getEntity(); boolean isInArc;
if (isAMS && counter.isAPDS() && !apdsEngaged) { Mounted mAmmo = counter.getLinked(); Entity apdsEnt = counter.getEntity(); boolean isInArc;