/** * @param t * @param w * @param g */ public UltraWeaponHandler(ToHitData t, WeaponAttackAction w, IGame g, Server s) { super(t, w, g, s); twoRollsUltra = game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_UAC_TWOROLLS) && ((wtype.getAmmoType() == AmmoType.T_AC_ULTRA) || (wtype .getAmmoType() == AmmoType.T_AC_ULTRA_THB)); }
@Override protected boolean doChecks(Vector<Report> vPhaseReport) { if ((roll == 2) && (howManyShots == 2) && !(ae instanceof Infantry)) { Report r = new Report(); r.subject = subjectId; weapon.setJammed(true); isJammed = true; if ((wtype.getAmmoType() == AmmoType.T_AC_ULTRA) || (wtype.getAmmoType() == AmmoType.T_AC_ULTRA_THB)) { r.messageId = 3160; } else { r.messageId = 3170; } vPhaseReport.addElement(r); } return false; }
/** * Returns true if the entity has an RAC which is jammed and not destroyed * As of 5/22/2012 also returns true if there is a jammed and not destroyed * Ultra AC and the unofficial options is enabled. Jammed ACs and LACs can * also be unjammed if rapid-fire ACs is turned on. */ public boolean canUnjamRAC() { for (Mounted mounted : getTotalWeaponList()) { WeaponType wtype = (WeaponType) mounted.getType(); if ((wtype.getAmmoType() == AmmoType.T_AC_ROTARY) && mounted.isJammed() && !mounted.isDestroyed()) { return true; } if (((wtype.getAmmoType() == AmmoType.T_AC_ULTRA) || (wtype.getAmmoType() == AmmoType.T_AC_ULTRA_THB) || (wtype.getAmmoType() == AmmoType.T_AC) || (wtype.getAmmoType() == AmmoType.T_LAC) || (wtype.getAmmoType() == AmmoType.T_AC_IMP) || (wtype.getAmmoType() == AmmoType.T_PAC)) && mounted.isJammed() && !mounted.isDestroyed() && game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_UNJAM_UAC)) { return true; } } return false; }
/** * Attempts to load all weapons with ammo */ public void loadAllWeapons() { for (Mounted mounted : getTotalWeaponList()) { WeaponType wtype = (WeaponType) mounted.getType(); if (wtype.getAmmoType() != AmmoType.T_NA) { loadWeapon(mounted); } } }
/** * Worker function that creates a series of weapon ammo choice panels that allow the user to pick a particular ammo bin for an * ammo-using weapon with matching ammo. */ private void setupWeaponAmmoChoice() { GridBagLayout gbl = new GridBagLayout(); panWeaponAmmoSelector.setLayout(gbl); for(Mounted weapon : entity.getWeaponList()) { WeaponType weaponType = weapon.getType() instanceof WeaponType ? (WeaponType) weapon.getType() : null; // don't deal with bay or grouped weapons for now if(weaponType == null || weaponType.getAmmoType() == AmmoType.T_NA) { continue; } WeaponAmmoChoicePanel ammoChoicePanel = new WeaponAmmoChoicePanel(weapon); panWeaponAmmoSelector.add(ammoChoicePanel, GBC.eol()); m_vWeaponAmmoChoice.add(ammoChoicePanel); } }
@Override protected boolean doChecks(Vector<Report> vPhaseReport) { if (((roll <= 4) && (howManyShots == 2)) || ((roll == 2) && (howManyShots == 1))) { Report r = new Report(); r.subject = subjectId; weapon.setJammed(true); if (wtype.getAmmoType() == AmmoType.T_AC_ULTRA) { r.messageId = 3160; weapon.setHit(true); } else { r.messageId = 3170; } vPhaseReport.addElement(r); return true; } return false; } }
/** * Force rapid fire mode to the highest level on RAC and UAC - this is for * aeros */ public void setRapidFire() { for (Mounted m : getTotalWeaponList()) { WeaponType wtype = (WeaponType) m.getType(); if (wtype.getAmmoType() == AmmoType.T_AC_ROTARY) { m.setMode("6-shot"); m.setModeSwitchable(false); } else if (wtype.getAmmoType() == AmmoType.T_AC_ULTRA) { m.setMode("Ultra"); m.setModeSwitchable(false); } } }
public int getMaxRange(Mounted weapon) { if(null != weapon) { if (getAmmoType() == AmmoType.T_ATM) { AmmoType atype = (AmmoType) weapon.getLinked().getType(); if ((atype.getAmmoType() == AmmoType.T_ATM) && (atype.getMunitionType() == AmmoType.M_EXTENDED_RANGE)) { return RANGE_EXT; } else if ((atype.getAmmoType() == AmmoType.T_ATM) && (atype.getMunitionType() == AmmoType.M_HIGH_EXPLOSIVE)) { return RANGE_SHORT; } } if (getAmmoType() == AmmoType.T_MML) { AmmoType atype = (AmmoType) weapon.getLinked().getType(); if (atype.hasFlag(AmmoType.F_MML_LRM) || (getAmmoType() == AmmoType.T_LRM_TORPEDO)) { return RANGE_LONG; } else { return RANGE_SHORT; } } } return maxRange; }
/** * 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; } }
/** * Checks to ensure that the given ammunition type is compatible with the given weapon type. Performs the following * tests:<br/> * {@code ammoType} != null<br/> * {@link AmmoType#getAmmoType()} == {@link WeaponType#getAmmoType()}<br/> * {@link AmmoType#getRackSize()} == {@link WeaponType#getRackSize()} * * @param ammoType The type of ammo to be tested. * @param weaponType The type of weapon the ammo is to be used with. * @return TRUE if the ammo type and weapon type are compatible. */ public static boolean isAmmoValid(AmmoType ammoType, WeaponType weaponType) { if (ammoType == null) { return false; } if (ammoType.getAmmoType() != weaponType.getAmmoType()) { return false; } if (ammoType.getRackSize() != weaponType.getRackSize()) { return false; } return true; } }
@Before public void setUp() { Mockito.when(mockAC5.getAmmoType()).thenReturn(AmmoType.T_AC); Mockito.when(mockAC5.getRackSize()).thenReturn(5); Mockito.when(mockPPC.getAmmoType()).thenReturn(AmmoType.T_NA); Mockito.when(mockSRM4.getAmmoType()).thenReturn(AmmoType.T_SRM); Mockito.when(mockSRM4.getRackSize()).thenReturn(4);
/** * When fighters are removed it is necessary to unlink all ammo to the * squadron's weapons and reload it to ensure that ammo from the removed * fighter does not remain linked */ // TODO: Evaluate for removal @SuppressWarnings("unused") private void reloadAllWeapons() { for (Mounted weapon : getTotalWeaponList()) { if ((((WeaponType) weapon.getType()).getAmmoType() != AmmoType.T_NA) && (null != weapon.getLinked()) && (weapon.getLinked().getType() instanceof AmmoType)) { weapon.unlink(); } } }
for(Mounted ammoBin : weapon.getEntity().getAmmo()) { if((ammoBin.getLocation() != Entity.LOC_NONE) && ((WeaponType) weapon.getType()).getAmmoType() == ((AmmoType) ammoBin.getType()).getAmmoType()) { matchingAmmoBins.add(ammoBin);
@Override public int getBattleForceTotalHeatGeneration(boolean allowRear) { int totalHeat = 0; // finish the max heat calculations if (this.getJumpMP() > 0) { totalHeat += getJumpHeat(getJumpMP()); } else if (!isIndustrial() && hasEngine()) { totalHeat += getEngine().getRunHeat(this); } for (Mounted mount : getWeaponList()) { WeaponType weapon = (WeaponType) mount.getType(); if (weapon.hasFlag(WeaponType.F_ONESHOT) || (allowRear && !mount.isRearMounted()) || (!allowRear && mount.isRearMounted())) { continue; } if (weapon.getAmmoType() == AmmoType.T_AC_ROTARY) { totalHeat += weapon.getHeat() * 6; } else if (weapon.getAmmoType() == AmmoType.T_AC_ULTRA || weapon.getAmmoType() == AmmoType.T_AC_ULTRA_THB) { totalHeat += weapon.getHeat() * 2; } else { totalHeat += weapon.getHeat(); } } if (hasWorkingMisc(MiscType.F_STEALTH, -1)) { totalHeat += 10; } return totalHeat; }
/** * Attempts to reload any empty weapons with the first ammo found */ public void reloadEmptyWeapons() { // try to reload weapons for (Mounted mounted : getTotalWeaponList()) { WeaponType wtype = (WeaponType) mounted.getType(); if (wtype.getAmmoType() != AmmoType.T_NA) { if ((mounted.getLinked() == null) || (mounted.getLinked().getUsableShotsLeft() <= 0) || mounted.getLinked().isDumping()) { loadWeaponWithSameAmmo(mounted); } } } }
/** * One gunner is required for each capital weapon and each six standard scale weapons, rounding up * @return The vessel's minimum gunner requirements. */ public static int requiredGunners(Aero aero) { if (!aero.isLargeCraft() && !aero.hasETypeFlag(Entity.ETYPE_SMALL_CRAFT)) { return 0; } int capitalWeapons = 0; int stdWeapons = 0; for (Mounted m : aero.getTotalWeaponList()) { if (m.getType() instanceof BayWeapon) { continue; } if ((((WeaponType)m.getType()).getLongRange() <= 1) // MML range depends on ammo, and getLongRange() returns 0 && (((WeaponType) m.getType()).getAmmoType() != AmmoType.T_MML)) { continue; } if (((WeaponType)m.getType()).isCapital() || (m.getType() instanceof ScreenLauncherWeapon)) { capitalWeapons++; } else { stdWeapons++; } } return capitalWeapons + (int)Math.ceil(stdWeapons / 6.0); }
/** * 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 ba 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; }
/** * 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; }
/** * Tries to load the specified weapon with the specified ammo. Returns true * if successful, false otherwise. */ public boolean loadWeapon(Mounted mounted, Mounted mountedAmmo) { boolean success = false; WeaponType wtype = (WeaponType) mounted.getType(); AmmoType atype = (AmmoType) mountedAmmo.getType(); if (mountedAmmo.isAmmoUsable() && !wtype.hasFlag(WeaponType.F_ONESHOT) && (atype.getAmmoType() == wtype.getAmmoType()) && (atype.getRackSize() == wtype.getRackSize())) { mounted.setLinked(mountedAmmo); success = true; } else if (wtype.hasFlag(WeaponType.F_DOUBLE_ONESHOT) && (mountedAmmo.getLocation() == Entity.LOC_NONE)) { // Make sure this ammo is in the chain, then move it to the head. for (Mounted current = mounted; current != null; current = current.getLinked()) { if (current == mountedAmmo) { current.getLinkedBy().setLinked(current.getLinked()); current.setLinked(mounted.getLinked()); mounted.setLinked(current); return true; } } } return success; }