@Override protected boolean isTbolt() { if (wtype.hasFlag(WeaponType.F_LARGEMISSILE)) { return true; } return false; } }
@Override // For AntiShip missiles, which behave more like Thunderbolts than capital missiles except for this // All other thunderbolt type large missiles should be unable to score a critical hit here protected int getCapMisMod() { if (wtype.hasFlag(WeaponType.F_ANTI_SHIP)) { return 11; } else { return 20; } }
public int getFireTN() { if (hasFlag(F_NO_FIRES)) { return TargetRoll.IMPOSSIBLE; } else if (hasFlag(F_FLAMER)) { return 4; } else if (hasFlag(F_PLASMA)) { return 2; } else if (hasFlag(F_PLASMA_MFUK)) { return 2; } else if (hasFlag(F_INFERNO)) { return 2; } else if (hasFlag(F_INCENDIARY_NEEDLES)) { return 6; } else if (hasFlag(F_PPC) || hasFlag(F_LASER)) { return 7; } else { return 9; } }
public boolean hasTAG() { for (Mounted m : getWeaponList()) { WeaponType equip = (WeaponType) (m.getType()); if ((equip != null) && (equip.hasFlag(WeaponType.F_TAG))) { return true; } } return false; }
private void setupRapidfireMGs() { GridBagLayout gbl = new GridBagLayout(); panRapidfireMGs.setLayout(gbl); for (Mounted m : entity.getWeaponList()) { WeaponType wtype = (WeaponType) m.getType(); if (!wtype.hasFlag(WeaponType.F_MG)) { continue; } RapidfireMGPanel rmp = new RapidfireMGPanel(m); panRapidfireMGs.add(rmp, GBC.eol()); m_vMGs.add(rmp); } }
private boolean hasWeaponFlag(BigInteger weaponFlag) { if (myEntity.getWeaponList().size() < 1) { return false; } for (Mounted wpn : myEntity.getWeaponList()) { if (((WeaponType) wpn.getType()).hasFlag(weaponFlag)) { return true; } } return false; }
public boolean usedTag() { for (Mounted weapon : getWeaponList()) { WeaponType wtype = (WeaponType) weapon.getType(); if (weapon.isUsedThisRound() && wtype.hasFlag(WeaponType.F_TAG)) { return true; } } return false; }
protected void useAmmo() { if (wtype.hasFlag(WeaponType.F_DOUBLE_ONESHOT)) { ArrayList<Mounted> chain = new ArrayList<>(); for (Mounted current = weapon.getLinked(); current != null; current = current.getLinked()) { chain.add(current); } if (!chain.isEmpty()) { chain.sort((m1, m2) -> Integer.compare(m2.getUsableShotsLeft(), m1.getUsableShotsLeft())); weapon.setLinked(chain.get(0)); for (int i = 0; i < chain.size() - 1; i++) { chain.get(i).setLinked(chain.get(i + 1)); } chain.get(chain.size() - 1).setLinked(null); if (weapon.getLinked().getUsableShotsLeft() == 0) { weapon.setFired(true); } } } else if (wtype.hasFlag(WeaponType.F_ONESHOT)) { weapon.setFired(true); } setDone(); }
public void engineFix() { engineHit = false; unlockTurret(); for (Mounted m : getWeaponList()) { WeaponType wtype = (WeaponType) m.getType(); if (wtype.hasFlag(WeaponType.F_ENERGY)) { m.setBreached(false); // not destroyed, just // unpowered } } }
public boolean isDiveBomb(IGame game) { return ((WeaponType) getEntity(game).getEquipment(getWeaponId()).getType()).hasFlag(WeaponType.F_DIVE_BOMB); }
/** * Check if the entity has an arbitrary type of weapon * * @param flag A WeaponType.F_XXX * @param secondary A WeaponType.S_XXX or -1 for don't care * @return true if at least one ready item. */ public boolean hasWorkingWeapon(BigInteger flag, long secondary) { for (Mounted m : weaponList) { if ((m.getType() instanceof WeaponType) && m.isReady()) { WeaponType type = (WeaponType) m.getType(); if (type.hasFlag(flag) && ((secondary == -1) || type.hasSubType(secondary))) { return true; } } } return false; }
public boolean isEligibleForTargetingPhase() { if (isAssaultDropInProgress()) { return false; } for (Mounted mounted : getWeaponList()) { WeaponType wtype = (WeaponType) mounted.getType(); if ((wtype != null) && (wtype.hasFlag(WeaponType.F_ARTILLERY))) { return true; } //Bearings-only capital missiles fire during the targeting phase if ((wtype instanceof TeleOperatedMissileBayWeapon) || (wtype instanceof CapitalMissileBayWeapon) || (wtype instanceof AR10BayWeapon)) { if (mounted.isInBearingsOnlyMode()) { return true; } } } return false; }
public int getAltitudeLoss(IGame game) { if (isAirToGround(game)) { if (((WeaponType) getEntity(game).getEquipment(getWeaponId()).getType()).hasFlag(WeaponType.F_DIVE_BOMB)) { return 2; } if (((WeaponType) getEntity(game).getEquipment(getWeaponId()).getType()).hasFlag(WeaponType.F_ALT_BOMB)) { return 0; } if (isStrafing) { return 0; } else { return 1; } } return 0; }
@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 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(); } if (roll >= toHit.getValue()) { ammo.setShotsLeft(ammo.getBaseShotsLeft() - 1); if (wtype.hasFlag(WeaponType.F_ONESHOT)) { weapon.setFired(true); } setDone(); } }
public boolean isEligibleForOffboard() { // if you're charging, no shooting if (isUnjammingRAC() || isCharging() || isMakingDfa()) { return false; } // if you're offboard, no shooting if (isOffBoard() || isAssaultDropInProgress()) { return false; } for (Mounted mounted : getWeaponList()) { WeaponType wtype = (WeaponType) mounted.getType(); if ((wtype != null) && (wtype.hasFlag(WeaponType.F_TAG) && mounted.isReady())) { return true; } } return false;// only things w/ tag are }
/** * apply the effects of an "engine hit" crit */ public void engineHit() { engineHit = true; immobilize(); lockTurret(getLocTurret()); lockTurret(getLocTurret2()); for (Mounted m : getWeaponList()) { WeaponType wtype = (WeaponType) m.getType(); if (wtype.hasFlag(WeaponType.F_ENERGY) // Chemical lasers still work even after an engine hit. && !(wtype instanceof CLChemicalLaserWeapon) // And presumably vehicle flamers should, too; we can always // remove this again if ruled otherwise. && !(wtype instanceof VehicleFlamerWeapon)) { m.setBreached(true); // not destroyed, just unpowered } } }
/** * need to check bay location before loading ammo */ @Override public boolean loadWeapon(Mounted mounted, Mounted mountedAmmo) { boolean success = false; WeaponType wtype = (WeaponType) mounted.getType(); AmmoType atype = (AmmoType) mountedAmmo.getType(); if (mounted.getLocation() != mountedAmmo.getLocation()) { return success; } if (mountedAmmo.isAmmoUsable() && !wtype.hasFlag(WeaponType.F_ONESHOT) && (atype.getAmmoType() == wtype.getAmmoType()) && (atype.getRackSize() == wtype.getRackSize())) { mounted.setLinked(mountedAmmo); success = true; } return success; }
/** * need to check bay location before loading ammo */ @Override public boolean loadWeapon(Mounted mounted, Mounted mountedAmmo) { boolean success = false; WeaponType wtype = (WeaponType) mounted.getType(); AmmoType atype = (AmmoType) mountedAmmo.getType(); if (mounted.getLocation() != mountedAmmo.getLocation()) { return success; } // for large craft, ammo must be in the same bay Mounted bay = whichBay(getEquipmentNum(mounted)); if ((bay != null) && !bay.ammoInBay(getEquipmentNum(mountedAmmo))) { return success; } if (mountedAmmo.isAmmoUsable() && !wtype.hasFlag(WeaponType.F_ONESHOT) && (atype.getAmmoType() == wtype.getAmmoType()) && (atype.getRackSize() == wtype.getRackSize())) { mounted.setLinked(mountedAmmo); success = true; } return success; }
@Override public double getWeightPowerAmp() { if (getEntity().isSupportVehicle() && (getEntity().getWeight() < 5)) { return 0; } if (!engine.isFusion() && (engine.getEngineType() != Engine.FISSION)) { double weight = 0; for (Mounted m : tank.getWeaponList()) { WeaponType wt = (WeaponType) m.getType(); if (wt.hasFlag(WeaponType.F_ENERGY) && !(wt instanceof CLChemicalLaserWeapon) && !(wt instanceof VehicleFlamerWeapon)) { weight += wt.getTonnage(tank); } if ((m.getLinkedBy() != null) && (m.getLinkedBy().getType() instanceof MiscType) && m.getLinkedBy().getType(). hasFlag(MiscType.F_PPC_CAPACITOR)) { weight += ((MiscType)m.getLinkedBy().getType()).getTonnage(tank); } } return TestEntity.ceil(weight / 10, getWeightCeilingPowerAmp()); } return 0; }