@Override protected int calcDamagePerHit() { float toReturn = wtype.getDamage(); // area effect damage is double if ((target instanceof Infantry) && !(target instanceof BattleArmor)) { toReturn /= 0.5; } if (bGlancing) { toReturn = (int) Math.floor(toReturn / 2.0); } // System.err.println("Attack is doing " + toReturn + " damage."); return (int) Math.ceil(toReturn); } }
@Override protected int calcDamagePerHit() { float toReturn = wtype.getDamage(); // area effect damage is double if ((target instanceof Infantry) && !(target instanceof BattleArmor)) { toReturn /= 0.5; } if (bGlancing) { toReturn = (int) Math.floor(toReturn / 2.0); } // System.err.println("Attack is doing " + toReturn + " damage."); return (int) Math.ceil(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; }
/** * Method computes how much damage a dial down weapon has done * * @param weapon * @param wtype * @param range * @return new damage */ public static int dialDownDamage(Mounted weapon, WeaponType wtype, int range) { int toReturn = wtype.getDamage(range); if (!wtype.hasModes()) { return toReturn; } String damage = weapon.curMode().getName(); // Vehicle flamers have damage and heat modes so lets make sure this is // an actual dial down Damage. if ((damage.trim().toLowerCase().indexOf("damage") == 0) && (damage.trim().length() > 6)) { toReturn = Integer.parseInt(damage.substring(6).trim()); } return Math.min(wtype.getDamage(range), toReturn); }
public int compare(AttackOption a, AttackOption a1) { if (a.target.getKey().intValue() == a1.target.getKey().intValue()) { WeaponType w = (WeaponType) a.weapon.getType(); WeaponType w1 = (WeaponType) a1.weapon.getType(); if (w.getDamage() == WeaponType.DAMAGE_BY_CLUSTERTABLE) { if (w1.getDamage() == WeaponType.DAMAGE_BY_CLUSTERTABLE) { if (a.expected > a1.expected) { return -1; } return 1; } return 1; } else if (w.getDamage() == WeaponType.DAMAGE_BY_CLUSTERTABLE) { return -1; } else if (a.expected > a1.expected) { return -1; } else { return 1; } } else if (a.target.getKey().equals(primary.getKey())) { return -1; } return 1; } }
/** * Damage calculation for BattleForce and AlphaStrike * @param range - the range in hexes * @return - damage in BattleForce scale */ public double getBattleForceDamage(int range) { double damage = 0; if (range <= getLongRange()) { //Variable damage weapons that cannot reach into the BF long range band use LR damage for the MR band if (getDamage() == DAMAGE_VARIABLE && range == BattleForceElement.MEDIUM_RANGE && getLongRange() < BattleForceElement.LONG_RANGE) { damage = getDamage(BattleForceElement.LONG_RANGE); } else { damage = getDamage(range); } if (range == BattleForceElement.SHORT_RANGE && getMinimumRange() > 0) { damage = adjustBattleForceDamageForMinRange(damage); } if (getToHitModifier() != 0) { damage -= damage * getToHitModifier() * 0.05; } } return damage / 10.0; }
/** * Calculates the maximum damage a unit can do at a given range. Chance to hit is not a factor. * * @param shooter The firing unit. * @param range The range to be checked. * @param useExtremeRange Is the extreme range optional rule in effect? * @return The most damage done at that range. */ // todo cluster and other variable damage. double getMaxDamageAtRange(final Entity shooter, final int range, final boolean useExtremeRange, final boolean useLOSRange) { double maxDamage = 0; // cycle through my weapons for (final Mounted weapon : shooter.getWeaponList()) { final WeaponType weaponType = (WeaponType) weapon.getType(); final int bracket = RangeType.rangeBracket(range, weaponType.getRanges(weapon), useExtremeRange, useLOSRange); if ((RangeType.RANGE_OUT != bracket) && (0 < weaponType.getDamage())) { maxDamage += weaponType.getDamage(); } } return maxDamage; }
/** * Method computes how much heat a dial down weapon generates * * @param weapon * @param wtype * @param range * @return Heat, minimum of 1; */ public static int dialDownHeat(Mounted weapon, WeaponType wtype, int range) { int toReturn = wtype.getHeat(); if (!wtype.hasModes()) { return toReturn; } int damage = wtype.getDamage(range); int newDamage = Compute.dialDownDamage(weapon, wtype, range); toReturn = Math.max(1, wtype.getHeat() - Math.max(0, damage - newDamage)); return toReturn; }
private void setupMediumLaser() { Mockito.when(mockWeaponType.getHeat()).thenReturn(3); Mockito.when(mockWeaponType.getDamage()).thenReturn(5); Mockito.when(mockWeaponType.getShortRange()).thenReturn(3); Mockito.when(mockWeaponType.getMediumRange()).thenReturn(6); Mockito.when(mockWeaponType.getLongRange()).thenReturn(9); Mockito.when(mockWeapon.getDesc()).thenReturn("Medium Laser"); }
private void setupPPC() { Mockito.when(mockWeaponType.getHeat()).thenReturn(10); Mockito.when(mockWeaponType.getDamage()).thenReturn(10); Mockito.when(mockWeaponType.getShortRange()).thenReturn(6); Mockito.when(mockWeaponType.getMediumRange()).thenReturn(12); Mockito.when(mockWeaponType.getLongRange()).thenReturn(18); Mockito.when(mockWeapon.getDesc()).thenReturn("PPC"); }
@Override protected int calcDamagePerHit() { if ((target instanceof Infantry) && !(target instanceof BattleArmor)) { double toReturn = Compute.directBlowInfantryDamage( wtype.getDamage(), bDirect ? toHit.getMoS() / 3 : 0, WeaponType.WEAPON_CLUSTER_BALLISTIC, ((Infantry) target).isMechanized(), toHit.getThruBldg() != null, ae.getId(), calcDmgPerHitReport); if (bGlancing) { toReturn /= 2; } return (int) Math.floor(toReturn); } return 1; }
private void setupCGR() { Mockito.when(mockWeaponType.getHeat()).thenReturn(1); Mockito.when(mockWeaponType.getDamage()).thenReturn(15); Mockito.when(mockWeaponType.getShortRange()).thenReturn(7); Mockito.when(mockWeaponType.getMediumRange()).thenReturn(15); Mockito.when(mockWeaponType.getLongRange()).thenReturn(22); Mockito.when(mockWeapon.getDesc()).thenReturn("Gauss Rifle (C)"); }
/** * Calculate the damage per hit. * * @return an <code>int</code> representing the damage dealt per hit. */ @Override protected int calcDamagePerHit() { double toReturn = wtype.getDamage(); if (bDirect) { toReturn += toHit.getMoS() / 3; } else if (bGlancing) { toReturn = (int) Math.floor(toReturn / 2.0); } if (game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_RANGE) && (nRange > wtype.getRanges(weapon)[RangeType.RANGE_LONG])) { toReturn = (int) Math.floor(toReturn * .75); } if (game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_LOS_RANGE) && (nRange > wtype.getRanges(weapon)[RangeType.RANGE_EXTREME])) { toReturn = (int) Math.floor(toReturn * .5); } return (int) Math.ceil(toReturn); }
@Override protected int calcDamagePerHit() { if (weapon.isRapidfire() && !(target instanceof Infantry)) { // Check for rapid fire Option. Only MGs can be rapidfire. switch (wtype.getDamage()) { case 1: nDamPerHit = Math.max(1, Compute.d6() - 1); break; case 3: nDamPerHit = Compute.d6() + 1; break; default: nDamPerHit = Compute.d6(); break; } numRapidFireHits = nDamPerHit; if (bDirect) { nDamPerHit = Math.min(nDamPerHit + (toHit.getMoS() / 3), nDamPerHit * 2); } if (bGlancing) { nDamPerHit = (int) Math.floor(nDamPerHit / 2.0); } } else { nDamPerHit = super.calcDamagePerHit(); } return nDamPerHit; }
damage = weapon.getDamage(range);
@Override protected int calcDamagePerHit() { double toReturn = wtype.getDamage(nRange); if (game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_RANGE) && nRange > wtype.getRanges(weapon)[RangeType.RANGE_LONG]) { toReturn -= 1; } if (game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_LOS_RANGE) && (nRange > wtype.getRanges(weapon)[RangeType.RANGE_EXTREME])) { toReturn = (int) Math.floor(toReturn * .75); } if (target instanceof Infantry && !(target instanceof BattleArmor)) { toReturn = Compute.directBlowInfantryDamage( toReturn, bDirect ? toHit.getMoS() / 3 : 0, wtype.getInfantryDamageClass(), ((Infantry) target).isMechanized(), toHit.getThruBldg() != null, ae.getId(), calcDmgPerHitReport); } else if (bDirect) { toReturn = Math.min(toReturn + (toHit.getMoS() / 3), toReturn * 2); } if (bGlancing) { toReturn = (int) Math.floor(toReturn / 2.0); } return (int) Math.ceil(toReturn); } }
return TechConstants.getTechName(wp.getTechLevel(gameYear)); case COL_DMG: return wp.getDamage(); case COL_HEAT: return wp.getHeat();
@Override protected int calcDamagePerHit() { double toReturn = wtype.getDamage();
continue; int addToDamage = wtype.getDamage(0); if (addToDamage < 0) { continue;