Package megamek.common
Class AmmoType
java.lang.Object
megamek.common.EquipmentType
megamek.common.AmmoType
- All Implemented Interfaces:
ITechnology
- Direct Known Subclasses:
BombType
,SmallWeaponAmmoType
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enum
static enum
static enum
Nested classes/interfaces inherited from interface megamek.common.ITechnology
ITechnology.AvailabilityValue, ITechnology.Era, ITechnology.Faction, ITechnology.FactionAffiliation, ITechnology.TechBase, ITechnology.TechRating
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Set<AmmoType.AmmoTypeEnum>
Contains the set ofAmmoType
s which could share ammo (e.g., SRM 2 and SRM 6, both fire SRM rounds), and conceptually can share ammo.protected AmmoType.AmmoTypeEnum
protected AmmoType
protected boolean
protected int
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final AmmoTypeFlag
static final EnumSet<AmmoType.Munitions>
protected int
static final EnumSet<AmmoType.Munitions>
protected EnumSet<AmmoType.Munitions>
protected int
protected RangeType
protected int
static final EnumSet<AmmoType.Munitions>
protected int
Fields inherited from class megamek.common.EquipmentType
allTypes, bv, BV_VARIABLE, cost, COST_VARIABLE, criticals, CRITICALS_VARIABLE, endTurnModes, explosive, flags, hittable, instantModeSwitch, internalName, lookupHash, modes, name, namesVector, omniFixedOnly, rulesRefs, shortName, sortingName, spreadable, structureCosts, structureNames, subType, svslots, T_ARMOR_AEROSPACE, T_ARMOR_ALUM, T_ARMOR_ANTI_PENETRATIVE_ABLATION, T_ARMOR_BA_FIRE_RESIST, T_ARMOR_BA_MIMETIC, T_ARMOR_BA_REACTIVE, T_ARMOR_BA_REFLECTIVE, T_ARMOR_BA_STANDARD, T_ARMOR_BA_STANDARD_ADVANCED, T_ARMOR_BA_STANDARD_PROTOTYPE, T_ARMOR_BA_STEALTH, T_ARMOR_BA_STEALTH_BASIC, T_ARMOR_BA_STEALTH_IMP, T_ARMOR_BA_STEALTH_PROTOTYPE, T_ARMOR_BALLISTIC_REINFORCED, T_ARMOR_COMMERCIAL, T_ARMOR_EDP, T_ARMOR_FERRO_ALUM_PROTO, T_ARMOR_FERRO_FIBROUS, T_ARMOR_FERRO_FIBROUS_PROTO, T_ARMOR_FERRO_LAMELLOR, T_ARMOR_HARDENED, T_ARMOR_HEAT_DISSIPATING, T_ARMOR_HEAVY_ALUM, T_ARMOR_HEAVY_FERRO, T_ARMOR_HEAVY_INDUSTRIAL, T_ARMOR_IMPACT_RESISTANT, T_ARMOR_INDUSTRIAL, T_ARMOR_LC_FERRO_CARBIDE, T_ARMOR_LC_FERRO_IMP, T_ARMOR_LC_LAMELLOR_FERRO_CARBIDE, T_ARMOR_LIGHT_ALUM, T_ARMOR_LIGHT_FERRO, T_ARMOR_PATCHWORK, T_ARMOR_PRIMITIVE, T_ARMOR_PRIMITIVE_AERO, T_ARMOR_PRIMITIVE_FIGHTER, T_ARMOR_REACTIVE, T_ARMOR_REFLECTIVE, T_ARMOR_STANDARD, T_ARMOR_STANDARD_PROTOMEK, T_ARMOR_STEALTH, T_ARMOR_STEALTH_VEHICLE, T_ARMOR_SV_BAR_10, T_ARMOR_SV_BAR_2, T_ARMOR_SV_BAR_3, T_ARMOR_SV_BAR_4, T_ARMOR_SV_BAR_5, T_ARMOR_SV_BAR_6, T_ARMOR_SV_BAR_7, T_ARMOR_SV_BAR_8, T_ARMOR_SV_BAR_9, T_ARMOR_UNKNOWN, T_STRUCTURE_COMPOSITE, T_STRUCTURE_ENDO_COMPOSITE, T_STRUCTURE_ENDO_PROTOTYPE, T_STRUCTURE_ENDO_STEEL, T_STRUCTURE_INDUSTRIAL, T_STRUCTURE_REINFORCED, T_STRUCTURE_STANDARD, T_STRUCTURE_UNKNOWN, TA_NONE, TA_STANDARD_STRUCTURE, tankslots, techAdvancement, toHitModifier, tonnage, TONNAGE_VARIABLE
Fields inherited from interface megamek.common.ITechnology
DATE_ES, DATE_NONE, DATE_PS
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
Aerospace units cannot use specialty munitions except Artemis and LBX cluster (but not standard).boolean
canAeroUse
(boolean option) Aerospace units cannot use specialty munitions except Artemis and LBX cluster (but not standard).boolean
canBeInterceptedBy
(WeaponMounted amsWeapon, GameOptions gameOptions) Checks if this ammo can be intercepted by AMS (or PD).static boolean
static boolean
static boolean
canSwitchToAmmo
(WeaponMounted weapon, AmmoType otherAmmo) Whether the given weapon can switch to the given ammo typeboolean
We need a way to quickly determine if a given ammo type / munition counts as "Flak"boolean
equalsAmmoTypeOnly
(Object other) When comparingAmmoType
s, look at the ammoType only.double
Returns the base ammo type, if any.int
int
Analog to WeaponType.getFireTNRoll(), but based on munitions.double
Used by units that are constructed using per-shot weights (BA and ProtoMeks).double
getKgPerShotBV
(int shots) getMunitionsFor
(AmmoType.AmmoTypeEnum ammoType) static AmmoType
getOneshotAmmo
(Mounted<?> mounted) int
int
getShots()
int
Constructs a map containing the YAML-serializable data for this equipment type.boolean
boolean
hasFlag
(EquipmentFlag flag) Returns true when this EquipmentType has the given flag.static void
boolean
is
(AmmoType.AmmoTypeEnum ammoType) Gets a value indicating whether this is a certain ammo type.static boolean
isAmmoValid
(AmmoType ammoType, WeaponType weaponType) Checks to ensure that the given ammunition type is compatible with the given weapon type.static boolean
isAmmoValid
(Mounted<?> ammo, WeaponType weaponType) Checks to ensure that the given ammo can be used with the given weapon type.boolean
boolean
boolean
isCompatibleWith
(AmmoType other) Gets a value indicating whether thisAmmoType
is compatible with anotherAmmoType
.boolean
Deprecated, for removal: This API element is subject to removal in a future version.since 0.50.06, the rules that don't allow some ammo for clan units should be based on tech access/availability, not a hardcoded list of ammo types.toString()
Methods inherited from class megamek.common.EquipmentType
addEndTurnMode, addLookupName, addMode, addSubType, addType, allTypes, clearModes, equals, get, getAllStructureCodeName, getAllTypes, getArmorType, getArmorTypeName, getArmorTypeName, getBaseAvailability, getBV, getCommonDate, getCost, getCost, getCriticals, getCriticals, getDesc, getDesc, getEquipDateAsString, getExtinctionDate, getExtinctionDate, getExtinctionDate, getFlags, getHeat, getInternalName, getIntroductionDate, getIntroductionDate, getIntroductionDate, getMode, getModes, getModesCount, getModesCount, getName, getName, getNames, getProductionDate, getProductionDate, getPrototypeDate, getPrototypeDate, getRawCost, getReintroductionDate, getReintroductionDate, getReintroductionDate, getRulesRefs, getShortName, getShortName, getSortingName, getStaticTechLevel, getStructureCost, getStructureTechAdvancement, getStructureType, getStructureTypeName, getStructureTypeName, getSubType, getSupportVeeSlots, getTankSlots, getTechAdvancement, getTechBase, getTechLevel, getTechLevel, getTechLevels, getTechRating, getToHitModifier, getTonnage, getTonnage, getTonnage, getTonnage, hasAnyFlag, hasAnySubType, hasFlag, hashCode, hasInstantModeSwitch, hasModes, hasModeType, hasSubType, is, isAnyOf, isArmorType, isC3Equipment, isClan, isExplosive, isExplosive, isHittable, isIntroLevel, isMixedTech, isNextTurnModeSwitch, isOmniFixedOnly, isSpreadable, isStructureType, isUnofficial, isVariableBV, isVariableCost, isVariableCriticals, isVariableSize, isVariableTonnage, removeMode, setFlags, setInstantModeSwitch, setInternalName, setModes, setSubType, variableMaxSize, variableStepSize, writeEquipmentAmmoDatabase, writeEquipmentDatabase, writeEquipmentExtendedDatabase, writeEquipmentMiscDatabase, writeEquipmentWeaponDatabase
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface megamek.common.ITechnology
calcEraAvailability, calcEraAvailability, calcYearAvailability, calcYearAvailability, calcYearAvailability, findMinimumRulesLevel, findMinimumRulesLevel, getAdvancedRange, getAdvancedRange, getCodeFromIOAbbr, getCodeFromMMAbbr, getCommonDate, getEraAvailabilityName, getEraAvailabilityName, getExperimentalRange, getExperimentalRange, getExtinctionRange, getExtinctionRange, getFullRatingName, getFullRatingName, getProductionDate, getPrototypeDate, getSimpleLevel, getSimpleLevel, getSimpleLevel, getStandardRange, getStandardRange, getTechRatingName, isAvailableIn, isAvailableIn, isAvailableIn, isExtinct, isExtinct, isExtinct, isLegal, isLegal
-
Field Details
-
ALLOWED_BY_TYPE
Contains the set ofAmmoType
s which could share ammo (e.g., SRM 2 and SRM 6, both fire SRM rounds), and conceptually can share ammo. -
F_MG
-
F_BATTLEARMOR
-
F_PROTOMEK
-
F_HOTLOAD
-
F_ENCUMBERING
-
F_MML_LRM
-
F_AR10_WHITE_SHARK
-
F_AR10_KILLER_WHALE
-
F_AR10_BARRACUDA
-
F_NUCLEAR
-
F_SANTA_ANNA
-
F_PEACEMAKER
-
F_TELE_MISSILE
-
F_CAP_MISSILE
-
F_SPACE_BOMB
-
F_GROUND_BOMB
-
F_MML_SRM
-
F_OTHER_BOMB
-
F_CRUISE_MISSILE
-
F_SCREEN
-
F_INTERNAL_BOMB
-
SMOKE_MUNITIONS
-
FLARE_MUNITIONS
-
MINE_MUNITIONS
-
damagePerShot
protected int damagePerShot -
rackSize
protected int rackSize -
ammoType
-
munitionType
-
shots
protected int shots -
base
-
blastRadius
-
heat
protected int heat -
range
-
tech
protected int tech -
capital
protected boolean capital
-
-
Constructor Details
-
AmmoType
public AmmoType()
-
-
Method Details
-
getMunitionsFor
-
getBaseAmmo
Returns the base ammo type, if any. -
equalsAmmoTypeOnly
When comparingAmmoType
s, look at the ammoType only.- Parameters:
other
- theObject
to compare to this one.- Returns:
true
if the other is anAmmoType
object of the sameammoType
as this object. N.B. different munition types are still equal.
-
isCompatibleWith
Gets a value indicating whether thisAmmoType
is compatible with anotherAmmoType
.this roughly means the same ammo type and munition type, but not rack size.
- Parameters:
other
- The otherAmmoType
to determine compatibility with.
-
getAmmoType
-
getToHitModifier
public int getToHitModifier() -
hasFlag
Description copied from class:EquipmentType
Returns true when this EquipmentType has the given flag. NOTE: Even though EquipmentFlags are enums, checking e.g. a WeaponType if it has a MiscTypeFlag may return an incorrect true result, as the actual test is made using EquipmentBitSet, i.e. a number comparison.Example: EquipmentType.get("BAArmoredGlove").hasFlag(WeaponType.F_VGL) returns true, as WeaponType.F_VGL has the same ordinal as MiscType.F_ARMORED_GLOVE. Therefore, always make sure to test only MiscTypes against MiscTypeFlags, WeaponTypes against WeaponTypeFlags and AmmoTypes against AmmoTypeFlags. This method will log a warning if the rule is not followed.
- Overrides:
hasFlag
in classEquipmentType
- Parameters:
flag
- The EquipmentFlag to check- Returns:
- True when this EquipmentType has the given flag
- See Also:
-
getFireTN
public int getFireTN()Analog to WeaponType.getFireTNRoll(), but based on munitions. See TO:AR pg 42- Returns:
- TN Roll
-
is
Gets a value indicating whether this is a certain ammo type.- Parameters:
ammoType
- The ammo type to compare against.
-
canBeInterceptedBy
public boolean canBeInterceptedBy(@Nullable WeaponMounted amsWeapon, @Nullable GameOptions gameOptions) Checks if this ammo can be intercepted by AMS (or PD). TODO: rules need to be checked- Parameters:
amsWeapon
- The AMS weapon to check against, if null an AMS is assumed to be available.gameOptions
- The game options, used to check for special rules. If null, standard rules are assumed.- Returns:
- true if this ammo is affected by AMS, false otherwise
-
countsAsFlak
public boolean countsAsFlak()We need a way to quickly determine if a given ammo type / munition counts as "Flak"Note, not _is_ Flak (as in the case of M_FLAK) but can be considered Flak by TW/TO/IO rules.
Arrow IV missiles with M_CLUSTER, M_ADA, or M_STANDARD (not M_HOMING) count as Flak (TO:AU&E pp166-167, 224)
- Returns:
- counts true if this ammo can be considered Flak in some situations
-
getMunitionType
-
notAllowedByClanRules
Deprecated, for removal: This API element is subject to removal in a future version.since 0.50.06, the rules that don't allow some ammo for clan units should be based on tech access/availability, not a hardcoded list of ammo types. As soon as the tech rules for munition variations are working completely then this will be removed.- Returns:
- true if this munition type is not allowed by clan rules
-
getDamagePerShot
public int getDamagePerShot() -
getRackSize
public int getRackSize() -
getShots
public int getShots() -
getAmmoRatio
public double getAmmoRatio() -
isCapital
public boolean isCapital() -
hasCustomKgPerShot
public boolean hasCustomKgPerShot() -
getKgPerShot
public double getKgPerShot()Used by units that are constructed using per-shot weights (BA and ProtoMeks). Some ammo is defined in the rules rounded to a set number of decimal places.- Returns:
- KG per Shot
-
canAeroUse
public boolean canAeroUse()Aerospace units cannot use specialty munitions except Artemis and LBX cluster (but not standard). ATM ER and HE rounds are considered standard munitions. AR10 missiles are designed for aerospace units and all munition types are available.- Returns:
- true if the munition can be used by aerospace units
-
canAeroUse
public boolean canAeroUse(boolean option) Aerospace units cannot use specialty munitions except Artemis and LBX cluster (but not standard). ATM ER and HE rounds are considered standard munitions. AR10 missiles are designed for aerospace units and all munition types are available.- Parameters:
option
- True if unofficial game option allowing alternate munitions for artillery bays is enabled- Returns:
- true if the munition can be used by aerospace units
-
getOneshotAmmo
- Parameters:
mounted
-Mounted
Weapon/Item- Returns:
- the first usable ammo type for the given one shot launcher
-
initializeTypes
public static void initializeTypes() -
toString
- Overrides:
toString
in classEquipmentType
-
canClearMinefield
-
canDeliverMinefield
-
getKgPerShotBV
public double getKgPerShotBV(int shots) - Returns:
- The battle value for ProtoMek or BA ammo loads.
-
getBaseName
-
getSubMunitionName
-
isAmmoValid
Checks to ensure that the given ammo can be used with the given weapon type. Performs the following tests:
ammo
!= null
Mounted.getType()
instanceofAmmoType
Mounted.isAmmoUsable()
isAmmoValid(AmmoType, WeaponType)
.- Parameters:
ammo
- The ammunition to be tested.weaponType
- The weapon the ammo is to be used with.- Returns:
- TRUE if the ammo and weapon are compatible.
-
isAmmoValid
Checks to ensure that the given ammunition type is compatible with the given weapon type. Performs the following tests:
ammoType
!= null
getAmmoType()
==WeaponType.getAmmoType()
getRackSize()
==WeaponType.getRackSize()
- Parameters:
ammoType
- The type of ammo to be tested.weaponType
- The type of weapon the ammo is to be used with.- Returns:
- TRUE if the ammo type and weapon type are compatible.
-
canSwitchToAmmo
Whether the given weapon can switch to the given ammo type- Parameters:
weapon
- The weapon being consideredotherAmmo
- The other ammo type being considered- Returns:
- true/false - null arguments or linked ammo bin for the weapon result in false
-
isArmorable
public boolean isArmorable()- Overrides:
isArmorable
in classEquipmentType
- Returns:
- True if this equipment type is eligible for being an armored component, TO:AUE p.95
-
getYamlData
Description copied from class:EquipmentType
Constructs a map containing the YAML-serializable data for this equipment type.- Overrides:
getYamlData
in classEquipmentType
- Returns:
- A map containing the YAML-serializable data for this equipment type.
-