public void setLinkedBy(Mounted linker) { if ((linker != null) && (linker.getLinked() != this)) { // liar return; } linkedBy = linker; }
public void setCrossLinkedBy(Mounted linker) { if ((linker != null) && (linker.getLinked() != this)) { // liar return; } crossLinkedBy = linker; }
/** * */ protected void checkAmmo(WeaponAttackAction waa, IGame g) { Entity ae = waa.getEntity(g); Mounted weapon = ae.getEquipment(waa.getWeaponId()); Mounted ammo = weapon.getLinked(); if (ammo == null || ammo.getUsableShotsLeft() < 1) { ae.loadWeaponWithSameAmmo(weapon); ammo = weapon.getLinked(); } }
protected void getMountedAmmo() { final String METHOD_NAME = "getMountedAmmo()"; for (int wId : weapon.getBayWeapons()) { Mounted bayW = ae.getEquipment(wId); // check the currently loaded ammo 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!"); } } }
/** * When fighters are removed it is necessary to unlink all ammo to the * squadron's weapons and reload it to ensure that ammo from the removed * fighter does not remain linked */ // TODO: Evaluate for removal @SuppressWarnings("unused") private void reloadAllWeapons() { for (Mounted weapon : getTotalWeaponList()) { if ((((WeaponType) weapon.getType()).getAmmoType() != AmmoType.T_NA) && (null != weapon.getLinked()) && (weapon.getLinked().getType() instanceof AmmoType)) { weapon.unlink(); } } }
/** * */ protected void checkAmmo(WeaponAttackAction waa, IGame g) { Entity ae = waa.getEntity(g); Mounted m = ae.getEquipment(waa.getWeaponId()); for (int wId : m.getBayWeapons()) { Mounted weapon = ae.getEquipment(wId); Mounted ammo = weapon.getLinked(); if (ammo == null || ammo.getUsableShotsLeft() < 1) { ae.loadWeaponWithSameAmmo(weapon); ammo = weapon.getLinked(); } } }
@Override protected int getCapMisMod() { int mod = 0; for (int wId : weapon.getBayWeapons()) { int curr_mod = 0; Mounted bayW = ae.getEquipment(wId); // check the currently loaded ammo Mounted bayWAmmo = bayW.getLinked(); AmmoType atype = (AmmoType) bayWAmmo.getType(); curr_mod = getCritMod(atype); if (curr_mod > mod) { mod = curr_mod; } } return mod; }
@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(); }
/** * 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_COOLANT) { return new FluidGunCoolHandler(toHit, waa, game, server); } return super.getCorrectHandler(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_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_NARC_EX) || (atype.getMunitionType() == AmmoType.M_EXPLOSIVE)) { return new NarcExplosiveHandler(toHit, waa, game, server); } return new NarcHandler(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.hasFlag(AmmoType.F_TELE_MISSILE) && game.getBoard().inSpace()) return new KillerWhaleTHandler(toHit, waa, game, server); return new KillerWhaleHandler(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.hasFlag(AmmoType.F_TELE_MISSILE) && game.getBoard().inSpace()) { return new TeleMissileHandler(toHit, waa, game, server); } return new KillerWhaleHandler(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.hasFlag(AmmoType.F_TELE_MISSILE) && game.getBoard().inSpace()) return new BarracudaTHandler(toHit, waa, game, server); return new BarracudaHandler(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.hasFlag(AmmoType.F_TELE_MISSILE) && game.getBoard().inSpace()) { return new TeleMissileHandler(toHit, waa, game, server); } return new AR10Handler(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.hasFlag(AmmoType.F_TELE_MISSILE) && game.getBoard().inSpace()) return new WhiteSharkTHandler(toHit, waa, game, server); return new WhiteSharkHandler(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.hasFlag(AmmoType.F_TELE_MISSILE) && game.getBoard().inSpace()) { return new TeleMissileHandler(toHit, waa, game, server); } return new CapitalMissileHandler (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 ((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); } }