Package megamek.common.equipment
Class AmmoType
java.lang.Object
megamek.common.equipment.EquipmentType
megamek.common.equipment.AmmoType
- All Implemented Interfaces:
ITechnology
- Direct Known Subclasses:
BombType,SmallWeaponAmmoType
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumstatic enumstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Set<AmmoType.AmmoTypeEnum> Contains the set ofAmmoTypes which could share ammo (e.g., SRM 2 and SRM 6, both fire SRM rounds), and conceptually can share ammo.protected AmmoType.AmmoTypeEnumprotected AmmoTypeprotected booleanprotected intstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final AmmoTypeFlagstatic final EnumSet<AmmoType.Munitions> protected intstatic final Stringstatic final Stringstatic final EnumSet<AmmoType.Munitions> protected EnumSet<AmmoType.Munitions> protected intprotected RangeTypeprotected intstatic final EnumSet<AmmoType.Munitions> protected intFields inherited from class megamek.common.equipment.EquipmentType
allTypes, bv, BV_VARIABLE, cost, COST_VARIABLE, CRITICAL_SLOTS_VARIABLE, criticalSlots, endTurnModes, explosive, flags, hittable, instantModeSwitch, internalName, lookupHash, modes, name, namesVector, omniFixedOnly, rulesRefs, shortName, sortingName, spreadable, structureAbbreviations, structureCosts, structureNames, 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, VARIABLE, YAML_VERSIONFields inherited from interface megamek.common.interfaces.ITechnology
DATE_ES, DATE_NONE, DATE_PS -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidAdds equipment flags to the YAML data map.booleanAerospace units cannot use specialty munitions except Artemis and LBX cluster (but not standard).booleancanAeroUse(boolean option) Aerospace units cannot use specialty munitions except Artemis and LBX cluster (but not standard).booleancanBeInterceptedBy(WeaponMounted amsWeapon, GameOptions gameOptions) Deprecated, for removal: This API element is subject to removal in a future version.static booleanstatic booleanstatic booleancanSwitchToAmmo(WeaponMounted weapon, AmmoType otherAmmo) Whether the given weapon can switch to the given ammo typebooleanWe need a way to quickly determine if a given ammo type / munition counts as "Flak"booleanequalsAmmoTypeOnly(Object other) When comparingAmmoTypes, look at the ammoType only.doubleReturns the base ammo type, if any.intintAnalog to WeaponType.getFireTNRoll(), but based on munitions.doubleUsed by units that are constructed using per-shot weights (BA and ProtoMeks).doublegetKgPerShotBV(int shots) getMunitionsFor(AmmoType.AmmoTypeEnum ammoType) Get the name of the mutator of this ammo type.static AmmoTypegetOneshotAmmo(Mounted<?> mounted) intintgetShots()intConstructs a map containing the YAML-serializable data for this equipment type.protected StringReturns the YAML type name for this equipment type.booleanbooleanhasFlag(EquipmentFlag flag) Returns true when this EquipmentType has the given flag.static voidbooleanis(AmmoType.AmmoTypeEnum ammoType) Gets a value indicating whether this is a certain ammo type.static booleanisAmmoValid(AmmoType ammoType, WeaponType weaponType) Checks to ensure that the given ammunition type is compatible with the given weapon type.static booleanisAmmoValid(Mounted<?> ammo, WeaponType weaponType) Checks to ensure that the given ammo can be used with the given weapon type.booleanbooleanisCompatibleWith(AmmoType other) Gets a value indicating whether thisAmmoTypeis compatible with anotherAmmoType.booleanbooleanDeprecated.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.equipment.EquipmentType
addEndTurnMode, addLookupName, addLookupName, addMode, addType, allTypes, canBeMountedOnBaDwp, clearLookupNames, clearModes, equals, get, get, getAllStructureCodeName, getAllTypes, getArmorFromName, getArmorType, getArmorTypeName, getArmorTypeName, getBaseAvailability, getBaseBV, getBaseCost, getBaseCriticalSlots, getBaseTonnage, getBV, getCommonDate, getCost, getCost, getDesc, getDesc, getEquipDateAsString, getExtinctionDate, getExtinctionDate, getExtinctionDate, getFlags, getHeat, getInternalName, getIntroductionDate, getIntroductionDate, getIntroductionDate, getLookupCollisions, getMode, getModes, getModesCount, getModesCount, getName, getName, getNames, getNumCriticalSlots, getNumCriticalSlots, getProductionDate, getProductionDate, getPrototypeDate, getPrototypeDate, getRawCost, getReintroductionDate, getReintroductionDate, getReintroductionDate, getRulesRefs, getShortName, getShortName, getSortingName, getStaticTechLevel, getStructureCost, getStructureFromName, getStructureTechAdvancement, getStructureType, getStructureTypeAbbrev, getStructureTypeName, getStructureTypeName, getSupportVeeSlots, getTankSlots, getTechAdvancement, getTechBase, getTechLevel, getTechLevel, getTechLevels, getTechRating, getToHitModifier, getToHitModifierAtRange, getTonnage, getTonnage, getTonnage, getTonnage, hasAnyFlag, hasAnyFlag, hasFlag, hashCode, hasHitModifiersByRange, hasInstantModeSwitch, hasModes, hasModeType, is, isAnyOf, isArmorType, isC3Equipment, isClan, isExplosive, isExplosive, isHittable, isIntroLevel, isMixedTech, isNextTurnModeSwitch, isOmniFixedOnly, isSpreadable, isStructureType, isUnofficial, isVariableBV, isVariableCost, isVariableCriticalSlots, isVariableSize, isVariableTonnage, matchesName, relevantToTargetingComputer, removeMode, setFlags, setInstantModeSwitch, setInternalName, setModes, variableMaxSize, variableStepSizeMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface megamek.common.interfaces.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 ofAmmoTypes 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
-
INCENDIARY_MOD
- See Also:
-
INCENDIARY_MOD_SHORTNAME
- See Also:
-
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
-
getMutatorName
Get the name of the mutator of this ammo type. If this is the "standard" ammo type for the weapon, returns null.- Returns:
- A string like "Inferno", or null
-
getMunitionsFor
-
getBaseAmmo
Returns the base ammo type, if any. -
equalsAmmoTypeOnly
When comparingAmmoTypes, look at the ammoType only.- Parameters:
other- theObjectto compare to this one.- Returns:
trueif the other is anAmmoTypeobject of the sameammoTypeas this object. N.B. different munition types are still equal.
-
isCompatibleWith
Gets a value indicating whether thisAmmoTypeis compatible with anotherAmmoType.this roughly means the same ammo type and munition type, but not rack size.
- Parameters:
other- The otherAmmoTypeto determine compatibility with.
-
getAmmoType
-
getToHitModifier
public int getToHitModifier() -
hasFlag
Description copied from class:EquipmentTypeReturns 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:
hasFlagin 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
@Deprecated(since="0.51.0", forRemoval=true) public boolean canBeInterceptedBy(@Nullable WeaponMounted amsWeapon, @Nullable GameOptions gameOptions) Deprecated, for removal: This API element is subject to removal in a future version.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.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-MountedWeapon/Item- Returns:
- the first usable ammo type for the given one shot launcher
-
initializeTypes
public static void initializeTypes() -
toString
- Overrides:
toStringin 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
-
isEligibleForBeingArmored
public boolean isEligibleForBeingArmored()- Overrides:
isEligibleForBeingArmoredin classEquipmentType- Returns:
- True if this equipment type is eligible for being an armored component, TO:AUE p.95
-
getYamlTypeName
Description copied from class:EquipmentTypeReturns the YAML type name for this equipment type. Subclasses should override this to return their specific type name.- Overrides:
getYamlTypeNamein classEquipmentType- Returns:
- The YAML type name (e.g., "weapon", "ammo", "misc", "armor")
-
addFlags
Description copied from class:EquipmentTypeAdds equipment flags to the YAML data map. Subclasses should override this to add type-specific flags.- Overrides:
addFlagsin classEquipmentType- Parameters:
data- The YAML data map to add flags to
-
getYamlData
Description copied from class:EquipmentTypeConstructs a map containing the YAML-serializable data for this equipment type. Subclasses should override this method to add type-specific data.- Overrides:
getYamlDatain classEquipmentType- Returns:
- A map containing the YAML-serializable data for this equipment type.
-