/** * Get the number of shots in the mount. * * @return the <code>int</code> number of shots in the mount. */ int getShotsLeft() { return m_mounted.getBaseShotsLeft(); }
ProtomechMunitionChoicePanel(Mounted m, ArrayList<AmmoType> vTypes) { super(m, vTypes, null); m_origAmmo = (AmmoType) m.getType(); m_origShotsLeft = m.getBaseShotsLeft(); }
private static String formatAmmo(Entity e) { StringBuffer sb = new StringBuffer(1024); for (Mounted ammo : e.getAmmo()) { sb.append(ammo.getName()); sb.append(": ").append(ammo.getBaseShotsLeft()) .append(CommonConstants.NL); } return sb.toString(); }
private String getAmmo() { StringBuffer sAmmo = new StringBuffer(); if (entity.getAmmo().size() < 1) { return ""; } sAmmo.append(String.format("%1$-30s %2$3s %3$5s\n", "Ammo", "Loc", "Shots")); sAmmo.append("----------------------------------------\n"); for (Mounted mounted : entity.getAmmo()) { sAmmo.append(String.format("%1$-30s %2$3s %3$5d\n", mounted.getName(), entity.getLocationAbbr(mounted.getLocation()), mounted.getBaseShotsLeft())); } sAmmo.append("\n"); return sAmmo.toString(); }
public void unloadSingle() { int shots = Math.min(getCurrentShots(), ((AmmoType) type).getShots()); AmmoType curType = (AmmoType)type; if (null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted && mounted.getType() instanceof AmmoType) { shots = Math.min(mounted.getBaseShotsLeft(), shots); mounted.setShotsLeft(mounted.getBaseShotsLeft() - shots); curType = (AmmoType)mounted.getType(); } } shotsNeeded += shots; if(shots > 0) { changeAmountAvailable(shots, curType); } }
@Override public StringBuffer printAmmo(StringBuffer buff, int posLoc, int posWeight) { for (Mounted m : getEntity().getAmmo()) { AmmoType mt = (AmmoType) m.getType(); buff.append(StringUtil.makeLength(mt.getName(), 20)); buff.append(" ").append( StringUtil.makeLength(getLocationAbbr(m.getLocation()), getPrintSize() - 5 - 20)) .append(TestEntity.makeWeightString( Math.ceil(mt.getKgPerShot() * m.getBaseShotsLeft()) / 1000.0)).append("\n"); } return buff; }
public void loadBinSingle() { int shots = Math.min(getAmountAvailable(), Math.min(shotsNeeded, ((AmmoType) type).getShots())); if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted && mounted.getType() instanceof AmmoType) { mounted.setShotsLeft(mounted.getBaseShotsLeft() + shots); } } changeAmountAvailable(-1 * shots, (AmmoType)type); shotsNeeded -= shots; }
@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(); } ammo.setShotsLeft(ammo.getBaseShotsLeft() - 1); super.useAmmo(); }
@Override public double getWeightAmmo() { double weight = 0.0; for (Mounted m : getEntity().getAmmo()) { // One Shot Ammo if (m.getLocation() == Entity.LOC_NONE) { continue; } AmmoType mt = (AmmoType) m.getType(); int slots = (int)Math.ceil(m.getBaseShotsLeft() / mt.getShots()); weight += mt.getTonnage(getEntity()) * slots; } return weight; }
@Override public double getWeightAmmo() { double weight = 0.0; for (Mounted m : getEntity().getAmmo()) { if (!m.isOneShotAmmo()) { AmmoType mt = (AmmoType) m.getType(); weight += ceil(mt.getKgPerShot() * m.getBaseShotsLeft() / 1000, Ceil.KILO); } } return weight; }
@Override public double getWeightAmmo() { double weight = 0.0; for (Mounted m : getEntity().getAmmo()) { // One Shot Ammo if (m.getLocation() == Entity.LOC_NONE) { continue; } AmmoType mt = (AmmoType) m.getType(); int slots = (int)Math.ceil(m.getBaseShotsLeft() / mt.getShots()); weight += ceil(mt.getTonnage(getEntity()) * slots, Ceil.HALFTON); } return weight; }
@Override protected int getCurrentShots() { int shots = getFullShots() * getNumTroopers() - shotsNeeded; //replace with actual entity values if entity not null because the previous number will not //be correct for ammo swaps if(null != unit && null != unit.getEntity()) { Mounted m = unit.getEntity().getEquipment(equipmentNum); if(null != m) { shots = m.getBaseShotsLeft() * getNumTroopers(); } } return shots; }
@Override protected void useAmmo() { getMountedAmmo(); Mounted bayW = bayWAmmo.getLinkedBy(); int shots = (bayW.getCurrentShots() * weapon.getBayWeapons().size()); for (int i = 0; i < shots; i++) { if (null == bayWAmmo || bayWAmmo.getUsableShotsLeft() < 1) { // try loading something else ae.loadWeaponWithSameAmmo(bayW); bayWAmmo = bayW.getLinked(); } if (null != bayWAmmo) { bayWAmmo.setShotsLeft(bayWAmmo.getBaseShotsLeft() - 1); } } }
@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(); } }
@Override public void updateConditionFromEntity(boolean checkForDestruction) { if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted) { capacity = mounted.getAmmoCapacity(); type = mounted.getType(); if(mounted.isMissing() || mounted.isDestroyed()) { mounted.setShotsLeft(0); return; } shotsNeeded = getFullShots() - mounted.getBaseShotsLeft(); } } }
@Override public void updateConditionFromEntity(boolean checkForDestruction) { if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted) { if(mounted.isMissing() || mounted.isDestroyed()) { mounted.setShotsLeft(0); remove(false); return; } if (type == mounted.getType()) { shotsNeeded = getFullShots() - mounted.getBaseShotsLeft(); } } } }
@Override public void unload() { int shots = 0; AmmoType curType = (AmmoType)type; if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted) { shots = mounted.getBaseShotsLeft() * getNumTroopers(); mounted.setShotsLeft(0); curType = (AmmoType)mounted.getType(); } } shotsNeeded = getFullShots() * getNumTroopers(); if(shots > 0) { changeAmountAvailable(shots, curType); } }
public void unload() { //FIXME: the following won't work for proto and Dropper bins if they //are not attached to a unit. Currently the only place AmmoBins are loaded //off of units is for refits, which neither of those units can do, but we //may want to think about not having refits load ammo bins but rather reserve //some AmmoStorage instead if we implement customization of these units int shots = getFullShots() - shotsNeeded; AmmoType curType = (AmmoType)type; if(null != unit) { Mounted mounted = unit.getEntity().getEquipment(equipmentNum); if(null != mounted && mounted.getType() instanceof AmmoType) { shots = mounted.getBaseShotsLeft(); mounted.setShotsLeft(0); curType = (AmmoType)mounted.getType(); } } shotsNeeded = getFullShots(); if(shots > 0) { changeAmountAvailable(shots, curType); } }
@Override protected void useAmmo() { final String METHOD_NAME = "useAmmo()"; for (int wId : weapon.getBayWeapons()) { Mounted bayW = ae.getEquipment(wId); // check the currently loaded ammo Mounted bayWAmmo = bayW.getLinked(); if (bayWAmmo == null) {// Can't happen. w/o legal ammo, the weapon // *shouldn't* fire. logDebug(METHOD_NAME, "Handler can't find any ammo! Oh no!"); } int shots = bayW.getCurrentShots(); for (int i = 0; i < shots; i++) { if (null == bayWAmmo || bayWAmmo.getUsableShotsLeft() < 1) { // try loading something else ae.loadWeaponWithSameAmmo(bayW); bayWAmmo = bayW.getLinked(); } if (null != bayWAmmo) { bayWAmmo.setShotsLeft(bayWAmmo.getBaseShotsLeft() - 1); } } } }
@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(); } } } }