/** * Common functionality that applies the panel's current ammo bin choice to the panel's weapon. */ public void applyChoice() { entity.loadWeapon(m_mounted, matchingAmmoBins.get(ammoBins.getSelectedIndex())); } }
/** * Tries to load the specified weapon with the first available ammo of the * same munition type as currently in use. If this fails, use first ammo. */ public void loadWeaponWithSameAmmo(Mounted mounted) { for (Mounted mountedAmmo : getAmmo()) { if (loadWeaponWithSameAmmo(mounted, mountedAmmo)) { return; } } // fall back to use any ammo loadWeapon(mounted); }
/** * Tries to load the specified weapon with the first available ammo */ public void loadWeapon(Mounted mounted) { for (Mounted mountedAmmo : getAmmo()) { if (loadWeapon(mounted, mountedAmmo)) { break; } } }
protected void checkAmmo() { ammo = weapon.getLinked(); if (ammo == null) { ae.loadWeapon(weapon); ammo = weapon.getLinked(); } }
/** * 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); } } }
/** * 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 void useAmmo() { int shotsNeedFiring; setDone(); checkAmmo(); howManyShots = weapon.getCurrentShots(); int total = ae.getTotalAmmoOfType(ammo.getType()); if (total <= howManyShots) { howManyShots = total; } shotsNeedFiring = howManyShots; if (ammo.getUsableShotsLeft() == 0) { ae.loadWeapon(weapon); ammo = weapon.getLinked(); // there will be some ammo somewhere, otherwise shot will not have // been fired. } while (shotsNeedFiring > ammo.getUsableShotsLeft()) { shotsNeedFiring -= ammo.getBaseShotsLeft(); ammo.setShotsLeft(0); ae.loadWeapon(weapon); ammo = weapon.getLinked(); } ammo.setShotsLeft(ammo.getBaseShotsLeft() - shotsNeedFiring); }
@Override protected void useAmmo() { setDone(); checkAmmo(); int total = ae.getTotalAmmoOfType(ammo.getType()); if ((total > 1) && !weapon.curMode().equals("Single")) { howManyShots = 2; } else { howManyShots = 1; } if (total == 0) { // can't happen? } if (ammo.getUsableShotsLeft() == 0) { ae.loadWeapon(weapon); ammo = weapon.getLinked(); // there will be some ammo somewhere, otherwise shot will not have // been fired. } if (ammo.getUsableShotsLeft() == 1) { ammo.setShotsLeft(0); ae.loadWeapon(weapon); ammo = weapon.getLinked(); // that fired one, do we need to fire another? ammo.setShotsLeft(ammo.getBaseShotsLeft() - ((howManyShots == 2) ? 1 : 0)); } else { ammo.setShotsLeft(ammo.getBaseShotsLeft() - howManyShots); } }
Mounted bWeap = entity.getEquipment(wid); if (bWeap.getType().equals(sWeap.getType())) { entity.loadWeapon(bWeap, mAmmo); entity.loadWeapon(mWeap, mAmmo);
for (int i = 0; i < ammoUsage; i++) { if (ammo.getUsableShotsLeft() <= 0) { ae.loadWeapon(weapon); ammo = weapon.getLinked();
&& ((ammo == null) || (ammo.getUsableShotsLeft() == 0) || ammo.isDumping())) { loadWeapon(weapon); ammo = weapon.getLinked();
if ((null != mountedAmmo) && !shooter.loadWeapon(currentWeapon, mountedAmmo)) { owner.log(getClass(), "loadAmmo(Entity, Targetable)", LogLevel.WARNING, shooter.getDisplayName() + " tried to load " + currentWeapon.getName() + " with ammo " +
ae.loadWeapon(weapon); ammo = weapon.getLinked(); shotsNeedFiring -= ammo.getBaseShotsLeft(); ammo.setShotsLeft(0); ae.loadWeapon(weapon); ammo = weapon.getLinked();
if (shooter.loadWeapon(shooter.getEquipment(atk.getWeaponId()), abin)) { if (abin.getUsableShotsLeft() > 0) { if (shooter.loadWeapon(shooter.getEquipment(atk.getWeaponId()), abin)) { if (abin.getUsableShotsLeft() > 0) { if (shooter.loadWeapon(shooter.getEquipment(atk.getWeaponId()), abin)) { if (abin.getUsableShotsLeft() > 0) { shooter.loadWeapon( shooter.getEquipment(atk.getWeaponId()), abin); shooter.loadWeapon(shooter.getEquipment(atk.getWeaponId()), best_bin); atk.setAmmoId(shooter.getEquipmentNum(best_bin));