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; }
public static boolean compareMounted (Mounted a, Mounted b) { if (!a.getType().equals(b.getType())) return false; if (!a.getClass().equals(b.getClass())) return false; if (!a.getName().equals(b.getName())) return false; if (a.getLocation()!=b.getLocation()) return false; return true; }
@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); } } }
public Mounted addEquipment(EquipmentType etype, int loc, boolean rearMounted, int baMountLoc, boolean isArmored, boolean isTurreted, boolean isSponsonTurreted, boolean isPintleTurreted, boolean isOmniPodded) throws LocationFullException { Mounted mounted = new Mounted(this, etype); mounted.setArmored(isArmored); mounted.setBaMountLoc(baMountLoc); mounted.setMechTurretMounted(isTurreted); mounted.setSponsonTurretMounted(isSponsonTurreted); mounted.setPintleTurretMounted(isPintleTurreted); mounted.setOmniPodMounted(isOmniPodded); addEquipment(mounted, loc, rearMounted); return mounted; }
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; }
/** * indicate whether this is bodymounted for BAs */ public Mounted addEquipment(EquipmentType etype, int loc, boolean rearMounted, int baMountLoc, boolean dwpMounted) throws LocationFullException { Mounted mounted = new Mounted(this, etype); mounted.setBaMountLoc(baMountLoc); mounted.setDWPMounted(dwpMounted); addEquipment(mounted, loc, rearMounted); return mounted; }
if (mounted.getLocation() == loc) { mounted.restore(); mounted.changeAmmoType((AmmoType) newLoad); mounted.setShotsLeft(shotsVal); mounted.restore(); mounted.getQuirks().getOption(quirkName) .setValue(value); } catch (Exception e) { while (st.hasMoreTokens() && i <= BattleArmor.LOC_TROOPER_6) { String tmiss = st.nextToken(); mounted.setMissingForTrooper(i, Boolean.parseBoolean(tmiss)); i++; mounted.setDestroyed(hitFlag || destFlag); mounted.setRepairable(repairFlag); mounted.setRapidfire(Boolean.parseBoolean(rfmg)); if (mounted.getType() instanceof AmmoType) { mounted.changeAmmoType((AmmoType) newLoad); mounted.setShotsLeft(shotsVal);
Mounted mounted = null; if (mountIndex >= row.ammoMounts.size()) { mounted = new Mounted(entity, row.munitions.get(i)); try { entity.addEquipment(mounted, row.bay.getLocation(), row.bay.isRearMounted()); row.bay.addAmmoToBay(entity.getEquipmentNum(mounted)); } catch (LocationFullException e) { DefaultMmLogger.getInstance().error(BayMunitionsChoicePanel.class, mounted.changeAmmoType(row.munitions.get(i)); mounted.setShotsLeft(shots); int slots = (int) Math.ceil((double) shots / row.munitions.get(i).getShots()); mounted.setOriginalShots(slots * row.munitions.get(i).getShots()); mounted.setAmmoCapacity(slots * row.munitions.get(i).getTonnage(entity)); remainingWeight -= mounted.getAmmoCapacity(); mountIndex++; mount.setAmmoCapacity(0); mount.setOriginalShots(0); mount.setShotsLeft(0); mountIndex++; AmmoType at = (AmmoType) m.getType(); m.setAmmoCapacity(m.getAmmoCapacity() + remainingWeight); m.setOriginalShots((int) Math.floor(m.getAmmoCapacity() / (at.getShots() * at.getTonnage(entity))));
if ((mounted.getLinkedBy() != null) && mounted.getLinkedBy().isOneShot()){ continue; if (mounted.getAmmoCapacity() == 0) { continue; if (mounted.getLocation() == Entity.LOC_NONE) { continue; String[] row = { mounted.getName(), entity.getLocationAbbr(mounted.getLocation()), String.valueOf(mounted.getBaseShotsLeft()), "" }; if (entity.isOmni()) { row[3] = mounted.isOmniPodMounted()? Messages.getString("MechView.Pod") : //$NON-NLS-1$ Messages.getString("MechView.Fixed"); //$NON-NLS-1$ if (mounted.isDestroyed()) { ammoTable.addRowWithBgColor("red", row); } else if (mounted.getUsableShotsLeft() < 1) { ammoTable.addRowWithBgColor("yellow", row); } else {
if (!weapon.canFire()) { return new ToHitData(TH_WEAP_CANNOT_FIRE); final WeaponType weaponType = (WeaponType) weapon.getType(); if (AmmoType.T_NA != weaponType.getAmmoType()) { if (null == weapon.getLinked()) { return new ToHitData(TH_WEAP_NO_AMMO); if (0 == weapon.getLinked().getUsableShotsLeft()) { return new ToHitData(TH_WEAP_NO_AMMO); if ((Mech.LOC_LARM == weapon.getLocation() || Mech.LOC_RARM == weapon.getLocation()) && shooter.isLocationBad(weapon.getLocation())) { return new ToHitData(TH_WEAP_ARM_PROP); if ((Mech.LOC_LLEG == weapon.getLocation()) || (Mech.LOC_RLEG == weapon.getLocation())) { return new ToHitData(TH_WEAP_PRONE_LEG); if (Infantry.LEG_ATTACK.equals(weapon.getType().getInternalName())) { toHit.append(getLegAttackBaseToHit(shooter, targetEntity, game)); toHit.append(getInfantryRangeMods(distance, (InfantryWeapon) weapon.getType(), isShooterInfantry ? ((Infantry) shooter).getSecondaryWeapon() : null, ILocationExposureStatus.WET == shooter.getLocationStatus(weapon.getLocation()))); && (null != weapon.getLinked()) && (weapon.getLinked().getType() instanceof AmmoType)) { final AmmoType ammoType = (AmmoType) weapon.getLinked().getType(); if ((null != ammoType) && (0 != ammoType.getToHitModifier())) {
@Override public void loadBin() { int shots = Math.min(getAmountAvailable(), shotsNeeded); int shotsPerTrooper = shots / getNumTroopers(); shots = shotsPerTrooper * getNumTroopers(); if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted) { if(mounted.getType().equals(type) && ((AmmoType)mounted.getType()).getMunitionType() == getMunitionType()) { //just a simple reload mounted.setShotsLeft(mounted.getBaseShotsLeft() + shotsPerTrooper); } else { //loading a new type of ammo unload(); mounted.changeAmmoType((AmmoType)type); mounted.setShotsLeft(shotsPerTrooper); } } } changeAmountAvailable(-1 * shots, (AmmoType)type); shotsNeeded -= shots; }
output.append("System"); } else { output.append(mount.getType().getInternalName()); if (mount.isRearMounted()) { output.append("\" isRear=\"true"); if (mount.isMechTurretMounted()) { output.append("\" isTurreted=\"true"); if (mount.getType() instanceof AmmoType) { output.append("\" shots=\""); output.append(String.valueOf(mount.getBaseShotsLeft())); if (mount.getEntity().usesWeaponBays()) { output.append("\" capacity=\"") .append(String.valueOf(mount.getAmmoCapacity())); if ((mount.getType() instanceof WeaponType) && (mount.getType()).hasFlag(WeaponType.F_ONESHOT)) { output.append("\" munition=\""); output.append(mount.getLinked().getType().getInternalName()); if (mount.isRapidfire()) { output.append("\" rfmg=\"true"); if (mount.countQuirks() > 0) { output.append("\" quirks=\""); output.append(String.valueOf(mount.getQuirkList("::"))); if(mount.isAnyMissingTroopers()) {
@Override public void updateConditionFromEntity(boolean checkForDestruction) { if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted) { capacity = mounted.getAmmoCapacity(); type = mounted.getType(); if(mounted.isMissing() || mounted.isDestroyed()) { mounted.setShotsLeft(0); return; } shotsNeeded = getFullShots() - mounted.getBaseShotsLeft(); } } }
if (mount.getType().hasFlag(WeaponType.F_B_POD)) { message.append(entity.getLocationName(mount.getLocation())) .append(' ').append(mount.getName()); JCheckBox pod = new JCheckBox(message.toString()); panPods.add(pod); if (mount.canFire()) { && (mount.getLocation() != Mech.LOC_CT) && (mount.getLocation() != Mech.LOC_LLEG) && (mount.getLocation() != Mech.LOC_RLEG)) { if (entity instanceof QuadMech) { if ((mount.getLocation() != Mech.LOC_LARM) || (mount.getLocation() != Mech.LOC_RARM)) { pod.setEnabled(false); && (mount.isRearMounted() || (mount.getLocation() == Mech.LOC_CT) || (mount.getLocation() == Mech.LOC_LLEG) || (mount .getLocation() == Mech.LOC_RLEG))) { pod.setEnabled(false); } else {
/** * Set the retractable blade in the given location as extended Takes the * first piece of appropriate equipment */ public void extendBlade(int loc) { for (Mounted m : getEquipment()) { if ((m.getLocation() == loc) && !m.isDestroyed() && !m.isBreached() && (m.getType() instanceof MiscType) && m.getType().hasFlag(MiscType.F_CLUB) && m.getType().hasSubType(MiscType.S_RETRACTABLE_BLADE)) { m.setMode("extended"); return; } } }
if (newmount.getType() instanceof WeaponType) { WeaponType weap = (WeaponType) newmount.getType(); if (bayMount == null) { try { damage *= 10; if (!newBay && ((bayDamage + damage) <= 700) && (bayMount.isRearMounted() == rearMount) && (weap.getAtClass() == ((WeaponType) bayMount.getType()).getAtClass()) && !(((WeaponType) bayMount.getType()).isSubCapital() && !weap.isSubCapital())) { bayMount.addWeaponToBay(a.getEquipmentNum(newmount)); bayDamage += damage; } else { throw new EntityLoadingException(ex.getMessage()); bayMount.addWeaponToBay(a.getEquipmentNum(newmount)); if (newmount.getType() instanceof AmmoType) { bayMount.addAmmoToBay(a.getEquipmentNum(newmount));
@Override public void updateConditionFromPart() { if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted) { mounted.setHit(false); mounted.setDestroyed(false); mounted.setRepairable(true); mounted.changeAmmoType((AmmoType) type); unit.repairSystem(CriticalSlot.TYPE_EQUIPMENT, equipmentNum); mounted.setShotsLeft(getFullShots() - shotsNeeded); mounted.setAmmoCapacity(capacity); } } }
if(m.getLocation() == Entity.LOC_NONE) { if (m.isWeaponGroup()) { continue; if (m.getType() instanceof InfantryAttack) { continue; if(!m.getType().isHittable()) { if(!(m.getType() instanceof MiscType)) { continue; if(!(((MiscType)m.getType()).hasFlag(MiscType.F_BA_MANIPULATOR) || ((MiscType)m.getType()).hasFlag(MiscType.F_BA_MEA) || ((MiscType)m.getType()).hasFlag(MiscType.F_AP_MOUNT))) { continue; if(m.getType() instanceof AmmoType) { int eqnum = entity.getEquipmentNum(m); Part apart = ammoParts.get(eqnum); int fullShots = ((AmmoType)m.getType()).getShots(); boolean oneShot = false; if(m.getLocation() == Entity.LOC_NONE) { fullShots = 1; oneShot = true; apart = new BattleArmorAmmoBin((int)entity.getWeight(), m.getType(), eqnum, ((BattleArmor)entity).getSquadSize() * (fullShots - m.getBaseShotsLeft()), oneShot, campaign); } else if (entity.usesWeaponBays()) {
@Override protected void useAmmo() { checkAmmo(); if (ammo == null) {// Can't happen. w/o legal ammo, the weapon // *shouldn't* fire. System.out.println("Handler can't find any ammo! Oh no!"); } if (ammo.getUsableShotsLeft() <= 0) { ae.loadWeaponWithSameAmmo(weapon); ammo = weapon.getLinked(); } ammo.setShotsLeft(ammo.getBaseShotsLeft() - 1); super.useAmmo(); }
if (!weapon.canFire()) { return new ToHitData(TH_WEAP_CANNOT_FIRE); if (AmmoType.T_NA != ((WeaponType) weapon.getType()).ammoType) { if (null == weapon.getLinked()) { return new ToHitData(TH_WEAP_NO_AMMO); if (0 == weapon.getLinked().getUsableShotsLeft()) { return new ToHitData(TH_WEAP_NO_AMMO);