/** * 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; } }
@Override protected int calcDamagePerHit() { if ((target instanceof Infantry) && !(target instanceof BattleArmor)) { double toReturn = Compute.directBlowInfantryDamage( wtype.getRackSize(), bDirect ? toHit.getMoS() / 3 : 0, wtype.getInfantryDamageClass(), ((Infantry) target).isMechanized(), toHit.getThruBldg() != null, ae.getId(), calcDmgPerHitReport); if (bGlancing) { toReturn /= 2; } return (int) Math.floor(toReturn); } return 1; }
@Override protected int calcDamagePerHit() { if ((target instanceof Infantry) && !(target instanceof BattleArmor)) { double toReturn = Compute.directBlowInfantryDamage( wtype.getRackSize() * 2, bDirect ? toHit.getMoS() / 3 : 0, wtype.getInfantryDamageClass(), ((Infantry) target).isMechanized(), toHit.getThruBldg() != null, ae.getId(), calcDmgPerHitReport); if (bGlancing) { toReturn /= 2; } return (int) Math.floor(toReturn); } return 1; }
@Override protected int calcDamagePerHit() { if (target instanceof Infantry && !(target instanceof BattleArmor)) { double toReturn = Compute.directBlowInfantryDamage( wtype.getRackSize() * 2, bDirect ? toHit.getMoS() / 3 : 0, wtype.getInfantryDamageClass(), ((Infantry) target).isMechanized(), toHit.getThruBldg() != null, ae.getId(), calcDmgPerHitReport); if (bGlancing) { toReturn /= 2; } return (int) Math.floor(toReturn); } return 2; }
@Override protected int calcDamagePerHit() { if ((target instanceof Infantry) && !(target instanceof BattleArmor)) { double toReturn = Compute.directBlowInfantryDamage( wtype.getRackSize(), bDirect ? toHit.getMoS() / 3 : 0, wtype.getInfantryDamageClass(), ((Infantry) target).isMechanized(), toHit.getThruBldg() != null, ae.getId(), calcDmgPerHitReport); if (bGlancing) { toReturn /= 2; } return (int) Math.floor(toReturn); } return 2; }
@Override protected int calcHits(Vector<Report> vPhaseReport) { // conventional infantry gets hit in one lump // BAs can't mount LBXs if ((target instanceof Infantry) && !(target instanceof BattleArmor)) { return 1; } int shotMod = getClusterModifiers(true); shotMod -= 1; int shotsHit = allShotsHit() ? wtype.getRackSize() : Compute .missilesHit(wtype.getRackSize(), shotMod); Report r = new Report(3325); r.subject = subjectId; r.add(shotsHit); r.add(sSalvoType); r.add(toHit.getTableDesc()); r.newlines = 0; vPhaseReport.addElement(r); r = new Report(3345); r.subject = subjectId; vPhaseReport.addElement(r); bSalvo = true; return shotsHit; }
@Override protected int calcDamagePerHit() { if (target instanceof Infantry && !(target instanceof BattleArmor)) { double toReturn = Compute.directBlowInfantryDamage( wtype.getRackSize() * 3, bDirect ? toHit.getMoS() / 3 : 0, wtype.getInfantryDamageClass(), ((Infantry) target).isMechanized(), toHit.getThruBldg() != null, ae.getId(), calcDmgPerHitReport); if (bGlancing) { toReturn /= 2; } return (int) Math.floor(toReturn); } return 3; }
@Override protected int calcDamagePerHit() { if ((target instanceof Infantry) && !(target instanceof BattleArmor)) { double toReturn = Compute.directBlowInfantryDamage( wtype.getRackSize(), bDirect ? toHit.getMoS() / 3 : 0, wtype.getInfantryDamageClass(), ((Infantry) target).isMechanized(), toHit.getThruBldg() != null, ae.getId(), calcDmgPerHitReport); if (bGlancing) { toReturn /= 2; } return (int) Math.floor(toReturn); } return 2; }
toReturn = wtype.getRackSize(); if (bDirect) { toReturn += toHit.getMoS() / 3;
@Override protected int calcDamagePerHit() { if ((target instanceof Infantry) && !(target instanceof BattleArmor)) { double toReturn = wtype.getRackSize(); toReturn = Compute.directBlowInfantryDamage( toReturn, bDirect ? toHit.getMoS() / 3 : 0, wtype.getInfantryDamageClass(), ((Infantry) target).isMechanized(), toHit.getThruBldg() != null, ae.getId(), calcDmgPerHitReport); if (bGlancing) { toReturn /= 2; } toReturn = Math.ceil(toReturn); return (int) toReturn; } return 1; }
@Override protected int calcDamagePerHit() { if (target instanceof Infantry && !(target instanceof BattleArmor)) { int toReturn = Compute.directBlowInfantryDamage( wtype.getRackSize(), bDirect ? toHit.getMoS() / 3 : 0, wtype.getInfantryDamageClass(), ((Infantry) target).isMechanized(), toHit.getThruBldg() != null, ae.getId(), calcDmgPerHitReport); return toReturn; } return 1; }
@Override protected int calcDamagePerHit() { if ((target instanceof Infantry) && !(target instanceof BattleArmor)) { int toReturn = Compute.directBlowInfantryDamage( wtype.getRackSize() * 2, bDirect ? toHit.getMoS() / 3 : 0, wtype.getInfantryDamageClass(), ((Infantry) target).isMechanized(), toHit.getThruBldg() != null, ae.getId(), calcDmgPerHitReport); return toReturn; } return 2; }
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);
@Override protected int calcDamagePerHit() { if ((target instanceof Infantry) && !(target instanceof BattleArmor)) { int missiles = waa.isSwarmingMissiles() ? waa.getSwarmMissiles() : wtype.getRackSize(); double toReturn = Compute.directBlowInfantryDamage( missiles, bDirect ? toHit.getMoS() / 3 : 0, wtype.getInfantryDamageClass(), ((Infantry) target).isMechanized(), toHit.getThruBldg() != null, ae.getId(), calcDmgPerHitReport); if (bGlancing) { toReturn /= 2; } return (int) Math.floor(toReturn); } return 1; }
/** * Returns how many shots the weapon is using */ public int getCurrentShots() { WeaponType wtype = (WeaponType) getType(); int nShots = getNumShots(wtype, curMode(), false); // sets number of shots for MG arrays if (wtype.hasFlag(WeaponType.F_MGA)) { nShots = 0; for(int eqn : getBayWeapons()) { Mounted m = entity.getEquipment(eqn); if(null == m) { continue; } if ((m.getLocation() == getLocation()) && !m.isDestroyed() && !m.isBreached() && m.getType().hasFlag(WeaponType.F_MG) && (((WeaponType) m.getType()).getRackSize() == ((WeaponType) getType()) .getRackSize())) { nShots++; } } } return nShots; }
/** * 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; }
@Override protected int calcDamagePerHit() { double toReturn; AmmoType atype = (AmmoType) ammo.getType(); if (atype.getMunitionType() == AmmoType.M_HIGH_EXPLOSIVE) { sSalvoType = " high-explosive missile(s) "; toReturn = 3; } else if (atype.getMunitionType() == AmmoType.M_EXTENDED_RANGE) { sSalvoType = " extended-range missile(s) "; toReturn = 1; } else { toReturn = 2; } if ((target instanceof Infantry) && !(target instanceof BattleArmor)) { toReturn = Compute.directBlowInfantryDamage( wtype.getRackSize(), bDirect ? toHit.getMoS() / 3 : 0, wtype.getInfantryDamageClass(), ((Infantry) target).isMechanized(), toHit.getThruBldg() != null, ae.getId(), calcDmgPerHitReport); if (bGlancing) { toReturn /= 2; } } return (int) toReturn; }
protected boolean hasViableWeapons() { int totalDmg = 0; boolean hasRangeSixPlus = false; List<Mounted> weaponList = getTotalWeaponList(); for (Mounted weapon : weaponList) { if (weapon.isCrippled()) { continue; } WeaponType type = (WeaponType) weapon.getType(); if (type.getDamage() == WeaponType.DAMAGE_VARIABLE) { } else if (type.getDamage() == WeaponType.DAMAGE_ARTILLERY) { return true; } else if (type.getDamage() == WeaponType.DAMAGE_BY_CLUSTERTABLE) { totalDmg += type.getRackSize(); } else if (type.getDamage() == WeaponType.DAMAGE_SPECIAL) { if (type instanceof ISBAPopUpMineLauncher) { totalDmg += 4; } } else { totalDmg += type.getDamage(); } if (type.getLongRange() >= 6) { hasRangeSixPlus = true; } } return (totalDmg >= 5) || hasRangeSixPlus; }
/** * 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; }