public AmmoStorage(int tonnage, EquipmentType et, int shots, Campaign c) { super(tonnage, et, -1, c); this.shots = shots; if(null != type && type instanceof AmmoType) { this.munition = ((AmmoType)type).getMunitionType(); } }
public AmmoBin(int tonnage, EquipmentType et, int equipNum, int shots, boolean singleShot, boolean omniPodded, Campaign c) { super(tonnage, et, equipNum, omniPodded, c); this.shotsNeeded = shots; this.oneShot = singleShot; this.checkedToday = false; if(null != type && type instanceof AmmoType) { this.munition = ((AmmoType)type).getMunitionType(); } if(null != name) { this.name += " Bin"; } }
protected double updateAVforAmmo(double current_av, AmmoType atype, WeaponType bayWType, int range, int wId) { if (atype.getMunitionType() == AmmoType.M_CLUSTER) { current_av = Math.floor(0.6 * current_av); } return current_av; } }
public static boolean canDeliverMinefield(AmmoType at) { if ((at != null) && ((at.getAmmoType() == T_LRM) || (at.getAmmoType() == AmmoType.T_LRM_IMP) || (at.getAmmoType() == AmmoType.T_MML)) && ((at.getMunitionType() == M_THUNDER) || (at.getMunitionType() == M_THUNDER_INFERNO) || (at.getMunitionType() == M_THUNDER_AUGMENTED) || (at.getMunitionType() == M_THUNDER_VIBRABOMB) || (at.getMunitionType() == M_THUNDER_ACTIVE))) { return true; } return false; }
@Override protected boolean usesClusterTable() { return ((AmmoType) ammo.getType()).getMunitionType() == AmmoType.M_CLUSTER; }
@Override protected boolean usesClusterTable() { return ((AmmoType) ammo.getType()).getMunitionType() == AmmoType.M_FLAK; }
private boolean hasMunitionType(long munition) { if (myEntity.getAmmo().size() < 1) { return false; } for (Mounted ammo : myEntity.getAmmo()) { if (((AmmoType) ammo.getType()).getMunitionType() == munition) { return true; } } return false; }
public void changeMunition(EquipmentType type) { if (type instanceof AmmoType) { munition = ((AmmoType) type).getMunitionType(); this.type = type; this.name = type.getName(); this.typeName = type.getInternalName(); updateConditionFromEntity(false); } }
public void changeMunition(long m) { this.munition = m; for (AmmoType atype : Utilities.getMunitionsFor(unit.getEntity(),(AmmoType)type, CampaignOptions.TECH_EXPERIMENTAL)) { if (atype.getMunitionType() == munition) { type = atype; break; } } updateConditionFromEntity(false); }
public void restoreMunitionType() { for (AmmoType atype : Utilities.getMunitionsFor(unit.getEntity(),(AmmoType)type, CampaignOptions.TECH_EXPERIMENTAL)) { if (atype.getMunitionType() == munition && atype.getInternalName().equals(type.getInternalName())) { type = atype; break; } } }
@Override protected AttackHandler getCorrectHandler(ToHitData toHit, WeaponAttackAction waa, IGame game, Server server) { AmmoType atype = (AmmoType) game.getEntity(waa.getEntityId()) .getEquipment(waa.getWeaponId()).getLinked().getType(); if (atype.getMunitionType() == AmmoType.M_AIRBURST) { return new MekMortarAirburstHandler(toHit, waa, game, server); } else if (atype.getMunitionType() == AmmoType.M_ANTI_PERSONNEL) { return new MekMortarAntiPersonnelHandler(toHit, waa, game, server); } else if (atype.getMunitionType() == AmmoType.M_FLARE) { return new MekMortarFlareHandler(toHit, waa, game, server); } else if (atype.getMunitionType() == AmmoType.M_SEMIGUIDED) { // Semi-guided works like shaped-charge, but can benefit from tag return new MekMortarHandler(toHit, waa, game, server); } else if (atype.getMunitionType() == AmmoType.M_SMOKE_WARHEAD) { return new MekMortarSmokeHandler(toHit, waa, game, server); } // If it doesn't match other types, it's the default armor-piercing return new MekMortarHandler(toHit, waa, game, server); }
/** * Tries to load the specified weapon with the specified ammo. Returns true * if successful, false otherwise. */ public boolean loadWeaponWithSameAmmo(Mounted mounted, Mounted mountedAmmo) { AmmoType atype = (AmmoType) mountedAmmo.getType(); Mounted oldammo = mounted.getLinked(); if ((oldammo != null) && (!((AmmoType) oldammo.getType()).equals(atype) || (((AmmoType) oldammo .getType()).getMunitionType() != atype .getMunitionType()))) { return false; } return loadWeapon(mounted, mountedAmmo); }
@Override protected AttackHandler getCorrectHandler(ToHitData toHit, WeaponAttackAction waa, IGame game, Server server) { AmmoType atype = (AmmoType) game.getEntity(waa.getEntityId()) .getEquipment(waa.getWeaponId()).getLinked().getType(); if ((atype.getMunitionType() == AmmoType.M_NARC_EX) || (atype.getMunitionType() == AmmoType.M_EXPLOSIVE)) { return new NarcExplosiveHandler(toHit, waa, game, server); } return new NarcHandler(toHit, waa, game, server); } }
@Override public boolean isSamePartType(Part part) { if (part instanceof AmmoStorage) { if (getType() instanceof BombType) { return ((EquipmentPart)part).getType() instanceof BombType && ((BombType)getType()).getBombType() == ((BombType)((EquipmentPart)part).getType()).getBombType(); } else { return ((AmmoType)getType()).getMunitionType() == ((AmmoType)((AmmoStorage)part).getType()).getMunitionType() && ((AmmoType)getType()).equals( (Object)((EquipmentPart)part).getType()); } } return 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; }
public int getFullShots() { int fullShots = ((AmmoType)type).getShots(); if(unit != null) { Mounted m = unit.getEntity().getEquipment(equipmentNum); if(null != m && m.getOriginalShots() > 0) { fullShots = m.getOriginalShots(); } } if(null != unit && unit.getEntity() instanceof Protomech) { //if protomechs are using alternate munitions then cut in half if(((AmmoType)type).getMunitionType() != AmmoType.M_STANDARD) { fullShots = fullShots / 2; } } if(oneShot) { fullShots = 1; } return fullShots; }
@Override protected AttackHandler getCorrectHandler(ToHitData toHit, WeaponAttackAction waa, IGame game, Server server) { AmmoType atype = (AmmoType) game.getEntity(waa.getEntityId()) .getEquipment(waa.getWeaponId()).getLinked().getType(); if (atype.getMunitionType() == AmmoType.M_CLUSTER) { return new PrototypeLBXHandler(toHit, waa, game, server); } return new PrototypeACWeaponHandler(toHit, waa, game, server); } }
@Override protected AttackHandler getCorrectHandler(ToHitData toHit, WeaponAttackAction waa, IGame game, Server server) { AmmoType atype = (AmmoType) game.getEntity(waa.getEntityId()) .getEquipment(waa.getWeaponId()).getLinked().getType(); if (atype.getMunitionType() == AmmoType.M_COOLANT) { return new FluidGunCoolHandler(toHit, waa, game, server); } return super.getCorrectHandler(toHit, waa, game, server); } }
@Override public void updateConditionFromEntity(boolean checkForDestruction) { if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted) { long currentMuniType = 0; if(mounted.getType() instanceof AmmoType) { currentMuniType = ((AmmoType)mounted.getType()).getMunitionType(); } if(currentMuniType == getMunitionType()) { shotsNeeded = (getFullShots() - mounted.getBaseShotsLeft()) * getNumTroopers(); } else { //we have a change of munitions shotsNeeded = getFullShots() * getNumTroopers(); } } } }
@Override protected AttackHandler getCorrectHandler(ToHitData toHit, WeaponAttackAction waa, IGame game, Server server) { AmmoType atype = (AmmoType) game.getEntity(waa.getEntityId()) .getEquipment(waa.getWeaponId()).getLinked().getType(); if ((game.getEntity(waa.getEntityId()).getEquipment(waa.getWeaponId()) .curMode().equals("Heat"))) { return new VehicleFlamerHeatHandler(toHit, waa, game, server); } else if (atype.getMunitionType() == AmmoType.M_COOLANT) { return new VehicleFlamerCoolHandler(toHit, waa, game, server); } else { return new VehicleFlamerHandler(toHit, waa, game, server); } }