Class Compute
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic final intstatic intstatic final intstatic final intThe most a gamemaster can add to or take from a unit's target movement modifier: the whole range of the movement table under the option with the wider one, plus the jump bonus. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanallEnemiesOutsideBlast(Targetable target, Entity attacker, AmmoType ammoType, boolean artillery, boolean flak, boolean asfFlak, Game game) static booleanallowAimedShotWith(WeaponMounted weapon, AimingMode aimingMode) static booleancalcFiringSolution(Game game, Entity ae, Targetable target) If the game is in space, "visual range" represents a firing solution as defined in SO starting on p117 Also, in most cases each target must be detected with sensors before it can be seen, so we need to make sensor rolls for detection.static booleancalcFutureTargetFiringSolution(Game game, Entity attacker, Targetable target, Coords futureTargetPosition) Deprecated, for removal: This API element is subject to removal in a future version.static booleancalcSensorContact(Game game, Entity ae, Targetable target) Determines whether we have an "object" detection as defined in SO's Advanced Sensors rules starting on p117static CoordscalculateArtilleryLead(Coords targetPoint, int direction, int leadAmount) static CoordscalculateArtilleryLead(Game game, Entity ae, Targetable target, boolean homing) static intcalculateClusterHitTableAmount(int roll, int rackSize) static booleancanDetectHidden(Entity detector, int distance, boolean endStep) Lightweight helper for some step evaluation.static booleancanMoveOnPavement(Game game, Coords src, Coords dest, MoveStep moveStep) Can movement between the two coordinates be on pavement (which includes roads and bridges)? If so it will override prohibited terrain, it may change movement costs, and it may lead to skids.static booleancanMoveOnPavement(Hex srcHex, Hex destHex, MoveStep moveStep) Can movement between the two coordinates be on pavement (which includes roads and bridges)? If so it will override prohibited terrain, it may change movement costs, and it may lead to skids.static booleancanPhysicalTarget(Game game, int entityId, Targetable target) static booleancanPointBlankShot(Entity attacker, Entity target) Lightweight helper to determine if a given unit can take a Pointblank shot on anotherstatic booleancanSee(Game game, Entity ae, Targetable target) Checks to see if the target is visible to the unit, always considering sensors.static booleancanSee(Game game, Entity ae, Targetable target, boolean useSensors, LosEffects los, List<ECMInfo> allECMInfo) Checks to see if the target is visible to the unit, if the sensor flag is true then sensors are checked as well.static int[]changeVectors(int[] v, int facing) method to change a set of active vectors for a one-point thrust expenditure in the giving facingstatic intcomputeTotalDamage(List<WeaponMounted> weaponList) static intcomputeTotalDamage(WeaponMounted weapon) static intd6()Wrapper to random#d6()static intd6(int dice) Wrapper to random#d6(n)static intd6(int dice, int keep) Wrapper to random#d6(n)static intdialDownDamage(Mounted<?> weapon, WeaponType weaponType) Method computes how much damage a dial down weapon has donestatic intdialDownDamage(Mounted<?> weapon, WeaponType weaponType, int range) Method computes how much damage a dial down weapon has donestatic intdialDownHeat(Mounted<?> weapon, WeaponType weaponType) Method computes how much heat a dial down weapon generatesstatic intdialDownHeat(Mounted<?> weapon, WeaponType weaponType, int range) Method computes how much heat a dial down weapon generatesstatic intdirectBlowBADamage(double damage, int damageType, BattleArmor target) Returns how much damage a weapon will do against a BattleArmor target if the BattleArmor vs BattleArmor rules on TO pg 109 are in effect.static intdirectBlowInfantryDamage(double damage, int mos, int damageType, boolean isNonInfantryAgainstMechanized, boolean isAttackThruBuilding) static intdirectBlowInfantryDamage(double damage, int mos, int damageType, boolean isNonInfantryAgainstMechanized, boolean isAttackThruBuilding, int attackerId, Vector<Report> vReport) Method replicates the Non-Conventional Damage against Infantry damage table as well as shifting for direct blows.static intdirectBlowInfantryDamage(double damage, int mos, int damageType, boolean isNonInfantryAgainstMechanized, boolean isAttackThruBuilding, int attackerId, Vector<Report> vReport, int mgaSize) Method replicates the Non-Conventional Damage against Infantry damage table as well as shifting for direct blows.static inteffectiveDistance(Game game, Entity attacker, Targetable target) static inteffectiveDistance(Game game, Entity attacker, Targetable target, boolean useGroundDistance) Finds the effective distance between an attacker and a target.static inteffectiveWeaponDistance(Game game, Entity weaponEntity, WeaponMounted weapon, Targetable target) Calculates effective distance from a weapon's firing position to a target, accounting for altitude differences and same-building elevation modifiers.enemiesInsideBlast(Targetable target, Entity attacker, AmmoType ammoType, boolean artillery, boolean flak, boolean asfFlak, Game game) static Entityexposed_findC3Spotter(Game game, Entity attacker, Targetable target) Deprecated.static EntityfindSpotter(Game game, Entity attacker, Targetable target) Finds the best spotter for the attacker.static EntityfindTAGSpotter(Game game, Entity attacker, Targetable target, boolean stopAtFirst) Function that attempts to find one TAG spotter, or the best TAG spotter,static intfiringArcFromVGLFacing(int facing) Converts the facing of a vehicular grenade launcher to the corresponding firing arc.getAcceptableUnloadPositions(List<Coords> candidates, int boardId, Entity unitToUnload, Game game, int elev) static intgetAccidentalFallFromAboveDamageFor(Entity entity, int fallElevation) Damage that a mek does with an accidental fall from above.static intgetADARangeModifier(int distance) static intgetAdditionalNonGunner(Entity entity) Calculates the number of additional non-gunner crew members required by vehicles and advanced aerospace vessels due to specific miscellaneous equipment mounts or special unit features.getAdjacentEntitiesAlongAttack(Coords aPos, Coords tPos, Game game) static intgetAeroCrewNeeds(Entity entity) static doublegetAmmoAdjDamage(Game game, WeaponAttackAction weaponAttackAction) Deprecated, for removal: This API element is subject to removal in a future version.static intgetAstechCrew(Entity entity) static ToHitDatagetAttackerMovementModifier(Game game, int entityId) Modifier to attacks due to attacker movementstatic ToHitDatagetAttackerMovementModifier(Game game, int entityId, EntityMovementType movement) Modifier to attacks due to attacker movementstatic ToHitDatagetAttackerTerrainModifier(Game game, int entityId) Modifier to attacks due to attacker terrainstatic CoordsgetClosestFlightPath(int attackerId, Coords aPos, Entity targetEntity) static intgetClosestFlightPathFacing(int attackerId, Coords aPos, Entity targetEntity) static CoordsgetClosestToFlightPath(Entity flyingEntity, Coords targetPosition) static intgetCombatTechCrew(Entity entity) static intgetCommunicationsCrew(Entity entity) static StringgetDamageTypeString(int damageType, int burstMultiplier) Used to get a human-readable string that represents the passed damage type.static ToHitDatagetDamageWeaponMods(Entity attacker, Mounted<?> weapon) Adds any damage modifiers from arm critical hits or sensor damage.static intgetDoctorCrew(Entity entity) static ToHitDatagetEarnedTargetMovementModifier(Game game, int entityId) Modifier to attacks due to target movement, as the unit earned it by moving this round, before any gamemaster change.static floatgetExpectedDamage(Game g, WeaponAttackAction waa, boolean assumeHit) Determines the expected damage to a weapon attack, based on to-hit, salvo sizes, etc.static floatgetExpectedDamage(Game game, WeaponAttackAction weaponAttackAction, boolean assumeHit, List<ECMInfo> allECMInfo) Determines the expected damage to a weapon attack, based on to-hit, salvo sizes, etc.static CoordsgetFinalPosition(Coords currentPosition, int... v) static intgetFullCrewSize(Entity entity) static intgetGhostTargetNumber(Entity ae, Coords a, Coords b) Check for ECM bubbles in Ghost Target mode along the path from a to b and return the highest target roll.static WeaponAttackActiongetHighestExpectedDamage(Game g, List<WeaponAttackAction> vAttacks, boolean assumeHit) Returns the weapon attack out of a list that has the highest expected damagestatic intgetHighestTwoIntegers(int... values) Returns the sum of the highest two values from the provided list of integer values.static ToHitDatagetImmobileMod(Targetable target) static ToHitDatagetImmobileMod(Targetable target, int aimingAt, AimingMode aimingMode) Gets the ToHitData associated with firing at an immobile target.static ToHitDatagetInfantryRangeMods(int distance, InfantryWeapon primaryWeapon, InfantryWeapon secondaryWeapon, InfantryWeapon disposableWeapon, boolean underwater) Calculate the range modifiers for a conventional infantry attack.static ToHitDatagetLegAttackBaseToHit(Entity attacker, Entity defender, Game game) Get the base to-hit number of a Leg Attack by the given attacker upon the given defendergetLoadableCoords(Entity carrier, Coords position, int boardId) Helper to get the coordinates from which a unit can load other units.static intgetMaxVisualRange(Entity entity, boolean targetIlluminated) static intgetMedicCrew(Entity entity) static intgetMetalInPath(Entity ae, Coords a, Coords b) Check for ferrous metal content in terrain on path from a to b return the total content.static CoordsgetMissedChargeDisplacement(Game game, int entityId, Coords src, int direction) Gets a hex to displace a missed charge to.getMountableUnits(Entity entity, Coords pos, int boardId, int elev, Game game) Returns a list of all adjacent units that can load the given Entity.static intgetNetVelocity(Coords src, Entity te, int attackerVelocity, int targetVelocity) Get the net velocity of two aerospace for ramming attacksstatic CoordsgetPreferredDisplacement(Game game, int entityId, Coords src, int direction) Gets a preferred displacement.static ToHitDatagetProneMods(Game game, Entity attacker, int weaponId) Gets the modifiers, if any, that the mek receives from being prone.static ToHitDatagetRangeMods(Game game, Entity attackingEntity, WeaponMounted weapon, AmmoMounted ammo, Targetable target) Determines the to-hit modifier due to range for an attack with the specified parameters.static ToHitDatagetRangeMods(Game game, Entity attackingEntity, WeaponMounted weapon, AmmoMounted ammo, Targetable target, List<ECMInfo> allECMInfo) Determines the to-hit modifier due to range for an attack with the specified parameters.static ToHitDatagetSecondaryTargetMod(Game game, Entity attacker, Targetable target) Determines if the current target is a secondary target, and if so, returns the appropriate modifier.static WeaponAttackActiongetSecondHighestExpectedDamage(Game g, List<WeaponAttackAction> vAttacks, boolean assumeHit) Returns the weapon attack out of a list that has the second highest expected damage used for engaging multiple salvosstatic intgetSensorBracket(int check) returns the brackets for sensor checksstatic intgetSensorRangeBracket(Entity ae, Targetable target, List<ECMInfo> allECMInfo) gets the sensor range bracket when detecting a particular type of target.static intgetSensorRangeByBracket(Game game, Entity ae, Targetable target, LosEffects los) gets the size of the sensor range bracket when detecting a particular type of target.static Compute.SensorRangeHelpergetSensorRanges(Game game, Entity e) returns the current sensing ranges of the active sensorstatic ToHitDatagetSpaceBombBaseToHit(Entity attacker, Entity defender, Game game) Get the base to-hit number of a space bomb attack by the given attacker upon the given defenderstatic ToHitDatagetSpotterMovementModifier(Game game, int entityId) Modifier to attacks due to spotter movementstatic ToHitDatagetSpotterMovementModifier(Game game, int entityId, EntityMovementType movement) Modifier to attacks due to spotter movementstatic ToHitDatagetStrafingTerrainModifier(Game game, int eiStatus, Hex hex) static intgetSVBaseCrewNeeds(Entity entity) Calculates the base crew requirements for support vehicles.static ToHitDatagetSwarmMekBaseToHit(Entity attacker, Entity defender, Game game) Get the base to-hit number of a Swarm Mek by the given attacker upon the given defender.static EntitygetSwarmMissileTarget(Game game, int aeId, Coords coords, int weaponId) Gets a new target for a flight of swarm missiles that was just shot at an entity and has missiles leftstatic ToHitDatagetTargetMovementModifier(int distance, boolean jumped, boolean airborneNonAerospace, Game game) Target movement modifier for the specified distancestatic ToHitDatagetTargetMovementModifier(Game game, int entityId) Modifier to attacks due to target movement, with any gamemaster change for the round applied on top and the total held between no modifier andmaxTargetMovementModifier(Game).static ToHitDatagetTargetTerrainModifier(Game game, Targetable target) Modifier to attacks due to target terrain TODO:um....should VTOLs get modifiers for smoke, etc.static ToHitDatagetTargetTerrainModifier(Game game, Targetable target, int eiStatus) static ToHitDatagetTargetTerrainModifier(Game game, Targetable target, int eiStatus, boolean attackerInSameBuilding) static ToHitDatagetTargetTerrainModifier(Game game, Targetable targetable, int eiStatus, boolean attackerInSameBuilding, boolean underwaterWeapon) static intgetTargetTotalHP(Game game, Targetable target) Calculates the current theoretical damage absorbable (armor+structure, etc.) by the given target.static intgetTotalDriverNeeds(Entity entity) static intgetTotalGunnerNeeds(Entity entity) Returns the number of required gunners for an entity.static CoordsgetValidDisplacement(Game game, int entityId, Coords src, int direction) Gets a valid displacement, from the hexes around src, as close to the original direction as is possible.static intgetVisualRange(Game game, Entity ae, LosEffects los, boolean targetIlluminated) static booleanhasAnyFiringSolution(Game game, int targetId) Checks to see if an entity is in anyone's firing solutions list Used for visibilitystatic booleanhasSensorContact(Entity detector, int targetId) Checks to see if target entity has already appeared on detector's sensors Used with Naval C3 to determine if detector can fire weapons at @targetstatic booleaninDeadZone(Game game, Entity ae, Targetable target) static booleanindirectAttackImpossible(Game game, Entity ae, Targetable target, WeaponType weaponType, Mounted<?> weapon) Worker function that checks if an indirect attack is impossible for the given passed-in argumentsindividualDice(int number, int faces) Input is in format "ndf", so this can handle 2d6 or 3d10individualRolls(int count, int number, int faces) Input is in format "c ndf", so that this can handle 10 rolls of 3d6static booleaninSensorRange(Game game, LosEffects los, Entity ae, Targetable target, List<ECMInfo> allECMInfo) static booleaninSensorRange(Game game, Entity ae, Targetable target, List<ECMInfo> allECMInfo) Checks to see whether the target is within sensor range (but not necessarily LoS or visual range)static booleaninVisualRange(Game game, LosEffects los, Entity attackingEntity, Targetable target) Determine whether the attacking entity is within visual range of the target.static booleaninVisualRange(Game game, Entity ae, Targetable target) checks to see whether the target is within visual range of the entity, but not necessarily LoSstatic booleanisAcceptableUnloadPosition(Coords position, int boardId, Entity unitToUnload, Game game, int elev) static booleanisAirToAir(Game game, Entity attacker, Targetable target) Returns true when an attack of the given units would be an A2A attack.static booleanisAirToGround(Entity attacker, Targetable target) Returns true when an attack of the attacker against the target is considered an A2G attack, see TW p.242-247.static booleanisAnySensorContact(Game game, int targetId) Deprecated, for removal: This API element is subject to removal in a future version.static booleanisEnemyIn(Game game, Entity entity, Coords coords, boolean onlyMeks, boolean ignoreInfantry, int enLowEl, boolean ignoreHidden) Returns true if there is any unit that is an enemy of the specified unit in the specified hex.static booleanisFlakAttack(Entity attacker, Entity target) static booleanisFlakToHitTarget(Entity attacker, Entity target) Returns whether a flak weapon (LB-X cluster, flak ammo, HAG and the like) gets its to-hit bonus against the target.static booleanisGroundToAir(Entity attacker, Targetable target) static booleanisGroundToGround(Entity attacker, Targetable target) static booleanisInBuilding(Game game, int elevation, Coords coords, int boardId) Returns true when the given place is inside a building, false when the location is not on a board, has no building or the elevation is below the basement or on or above the building.static booleanisInBuilding(Game game, Entity entity) Determine if the given unit is inside a building at the given coordinates.static booleanisInBuilding(Game game, Entity entity, Coords coords) Determine if the given unit is inside a building at the given coordinates.static booleanisInSameBuilding(Game game, Entity attacker, Targetable target) Determines whether the attacker and the target are in the same building.static booleanisInUrbanEnvironment(Game game, Coords unitPOS) static booleanisNonAerospaceOverflight(Entity mover, MoveStep step, boolean endStep) Whether a step is a non-aerospace airborne unit flying over a hex: a unit using VTOL or WiGE movement (VTOLs, WiGEs, LAMs in AirMek mode, powered flight infantry) that is above the terrain of the step's hex and does not end its move there.static booleanisPilotingSkillNeeded(Game game, int entityId, Coords src, Coords dest, EntityMovementType movementType, boolean isTurning, boolean prevStepIsOnPavement, int srcElevation, int destElevation, MoveStep moveStep) static booleanisTargetTagged(Entity attacker, Targetable target, Game game) Worker function to determine if the target has been tagged by the specific attacker.static booleanisTargetTagged(Targetable target, Game game) Worker function to determine if the target has been tagged.static booleanisThroughFrontHex(Coords src, Entity t) Returns true if the line between source Coords and target goes through the hex in front of the attackerstatic booleanisValidDisplacement(Game game, int entityId, Coords src, int direction) Can the defending unit be displaced from the source to the destination?static booleanisValidDisplacement(Game game, int entityId, Coords src, Coords dest) Can the defending unit be displaced from the source to the destination?static intlog2(int number) Fast log2 implementation; throws if number ≤ 0static intThe highest target movement modifier a ground unit can earn in this game: the top of the movement table, +6 or +7 under the MaxTech movement modifiers option, plus the +1 for jumping or being airborne.static intminGamemasterTargetModifier(Game game, int entityId) The largest reduction a gamemaster's target movement modifier change can make on this unit this round: the earned modifier taken back down to the floorgetTargetMovementModifier(Game, int)holds the total to.static intmissilesHit(int missiles) Maintain backwards compatibility.static intmissilesHit(int missiles, int nMod) Maintain backwards compatability.static intmissilesHit(int missiles, int nMod, boolean hotLoaded) Maintain backwards compatability.static intmissilesHit(int missiles, int nMod, boolean hotLoaded, boolean streak, boolean advancedAMS) Roll the number of missiles (or whatever) on the missile hit table, with the specified mod to the roll.static voidmodifyPhysicalBTHForAdvantages(Entity attacker, Entity target, ToHitData toHit, Game game) Modifier to physical attack BTH due to pilot advantagesstatic doubleoddsAbove(int n) Returns the odds that a certain number or above will be rolled on 2d6.static doubleoddsAbove(int n, boolean dropLowest) Returns the odds that a certain number or above will be rolled on 2d6, or on 3d6 drop the lowest if the flag is set.static doubleoddsAsDisplayPercent(double odds) Rounds odds fromoddsAbove(int, boolean)down to one decimal place for display.static floatWrapper to random#randomFloat()static intrandomInt(int maxValue) Generates a number between 0 and max value exclusive (this means maxValue-1).static intrandomIntInclusive(int maxValue) Generates a number between 0 and max value inclusive (this means maxValue).static <T> TrandomListElement(List<T> list) Selects a random element from a liststatic intrandomRealIntInclusive(int maxValue) Generates a number between 1 and max value inclusive (this means maxValue).static booleanrevealsHiddenUnitForPointblankShot(Entity mover, int distance, boolean overflight) Whether a moving enemy reveals a hidden unit in a way that lets it take a point-blank shot (TW p.260).static RollrollD6(int dice) Wrapper to random#d6(n)static RollrollD6(int dice, int keep) Wrapper to random#d6(n)static introundsUntilReturn(Game game, Entity en) This is a homebrew function partially drawn from pg.static booleansameVectors(int[] v1, int[] v2) compare two vectors and determine if they are the samestatic CoordsScatters from a hex in a random direction, rolling 1d6 to pick one of the six straight-line directions.static CoordsscatterAltitudeBombs(Coords coords, int facing, int moF) Scatter from hex according to altitude bombing rules (based on MoF), TW pg 246.static CoordsscatterAssaultDrop(Coords coords, int margin) scatter from hex according to atmospheric drop rules d6 for direction, 1d6 per point of MOFstatic CoordsscatterDirectArty(Coords coords, int moF) scatter from hex according to direct fire artillery rules (based on MoF)static CoordsscatterDiveBombs(Coords coords, int moF) Scatter from hex according to dive-bombing rules (based on MoF), TW pg 246.static voidsetRNG(int type) Sets the RNG to the desired typestatic voidSets the RNG to the specific instance.static intshouldMoveBackHex(Entity e1, Entity e2) Compares the initiative of two aerospace units in the same hex to determine attack angle.static intspinUpCannon(Game game, WeaponAttackAction attackAction) Deprecated.static intspinUpCannon(Game game, WeaponAttackAction attackAction, int spinupThreshold) Determine if autocannon should fire more than one round.static EntitystackingViolation(Game game, int enteringId, Coords coords, boolean climbMode) Returns an entity if the specified entity would cause a stacking violation entering a hex, or returns null if it would not.static EntitystackingViolation(Game game, Entity entering, int elevation, Coords dest, int destBoardId, Entity transport, boolean climbMode, boolean ignoreHidden) Board-aware check used when compiling movepathsstatic EntitystackingViolation(Game game, Entity entering, int elevation, Coords dest, Entity transport, boolean climbMode, boolean ignoreHidden) Returns an entity if the specified entity would cause a stacking violation entering a hex, or returns null if it would not.static EntitystackingViolation(Game game, Entity entering, Coords origPosition, int elevation, Coords dest, int destBoardId, Entity transport, boolean climbMode, boolean ignoreHidden) Returns an entity if the specified entity would cause a stacking violation entering a hex, or returns null if it would not.static EntitystackingViolation(Game game, Entity entering, Coords origPosition, int elevation, Coords dest, Entity transport, boolean climbMode, boolean ignoreHidden) Used by Princess / bots for checking deployment positions.static EntitystackingViolation(Game game, Entity entering, Coords dest, Entity transport, boolean climbMode, boolean ignoreHidden) When compiling an unloading step, both the transporter and the unloaded unit probably occupy some other position on the board.static intturnsTilBOMHit(Game game, Entity ae, Targetable target, int velocity) Get turns for an indirect or off-board round to hit with its current velocitystatic intturnsTilHit(int distance) static voidupdateFiringSolutions(Game game, Entity detector) Updates an entity's firingSolutions, removing any objects that no longer meet criteria for being tracked as targets.static voidupdateSensorContacts(Game game, Entity detector) Updates an entity's sensorContacts, removing any objects that no longer meet criteria for being tracked.static booleanuseSpheroidAtmosphere(Game game, Entity en) Should we treat this entity, in its current state, as if it is a spheroid unit flying in atmosphere?
-
Field Details
-
ARC_360
public static final int ARC_360- See Also:
-
ARC_FORWARD
public static final int ARC_FORWARD- See Also:
-
ARC_LEFT_ARM
public static final int ARC_LEFT_ARM- See Also:
-
ARC_RIGHT_ARM
public static final int ARC_RIGHT_ARM- See Also:
-
ARC_REAR
public static final int ARC_REAR- See Also:
-
ARC_LEFT_SIDE
public static final int ARC_LEFT_SIDE- See Also:
-
ARC_RIGHT_SIDE
public static final int ARC_RIGHT_SIDE- See Also:
-
ARC_MAIN_GUN
public static final int ARC_MAIN_GUN- See Also:
-
ARC_NORTH
public static final int ARC_NORTH- See Also:
-
ARC_EAST
public static final int ARC_EAST- See Also:
-
ARC_WEST
public static final int ARC_WEST- See Also:
-
ARC_NOSE
public static final int ARC_NOSE- See Also:
-
ARC_LEFT_WING
public static final int ARC_LEFT_WING- See Also:
-
ARC_RIGHT_WING
public static final int ARC_RIGHT_WING- See Also:
-
ARC_LEFT_WING_AFT
public static final int ARC_LEFT_WING_AFT- See Also:
-
ARC_RIGHT_WING_AFT
public static final int ARC_RIGHT_WING_AFT- See Also:
-
ARC_LEFT_SIDE_SPHERE
public static final int ARC_LEFT_SIDE_SPHERE- See Also:
-
ARC_RIGHT_SIDE_SPHERE
public static final int ARC_RIGHT_SIDE_SPHERE- See Also:
-
ARC_LEFT_SIDE_AFT_SPHERE
public static final int ARC_LEFT_SIDE_AFT_SPHERE- See Also:
-
ARC_RIGHT_SIDE_AFT_SPHERE
public static final int ARC_RIGHT_SIDE_AFT_SPHERE- See Also:
-
ARC_LEFT_BROADSIDE
public static final int ARC_LEFT_BROADSIDE- See Also:
-
ARC_RIGHT_BROADSIDE
public static final int ARC_RIGHT_BROADSIDE- See Also:
-
ARC_AFT
public static final int ARC_AFT- See Also:
-
ARC_LEFT_SPHERE_GROUND
public static final int ARC_LEFT_SPHERE_GROUND- See Also:
-
ARC_RIGHT_SPHERE_GROUND
public static final int ARC_RIGHT_SPHERE_GROUND- See Also:
-
ARC_TURRET
public static final int ARC_TURRET- See Also:
-
ARC_SPONSON_TURRET_LEFT
public static final int ARC_SPONSON_TURRET_LEFT- See Also:
-
ARC_SPONSON_TURRET_RIGHT
public static final int ARC_SPONSON_TURRET_RIGHT- See Also:
-
ARC_PINTLE_TURRET_LEFT
public static final int ARC_PINTLE_TURRET_LEFT- See Also:
-
ARC_PINTLE_TURRET_RIGHT
public static final int ARC_PINTLE_TURRET_RIGHT- See Also:
-
ARC_PINTLE_TURRET_FRONT
public static final int ARC_PINTLE_TURRET_FRONT- See Also:
-
ARC_PINTLE_TURRET_REAR
public static final int ARC_PINTLE_TURRET_REAR- See Also:
-
ARC_VGL_FRONT
public static final int ARC_VGL_FRONT- See Also:
-
ARC_VGL_RF
public static final int ARC_VGL_RF- See Also:
-
ARC_VGL_RR
public static final int ARC_VGL_RR- See Also:
-
ARC_VGL_REAR
public static final int ARC_VGL_REAR- See Also:
-
ARC_VGL_LR
public static final int ARC_VGL_LR- See Also:
-
ARC_VGL_LF
public static final int ARC_VGL_LF- See Also:
-
ARC_NOSE_WPL
public static final int ARC_NOSE_WPL- See Also:
-
ARC_LEFT_WING_WPL
public static final int ARC_LEFT_WING_WPL- See Also:
-
ARC_RIGHT_WING_WPL
public static final int ARC_RIGHT_WING_WPL- See Also:
-
ARC_LEFT_WING_AFT_WPL
public static final int ARC_LEFT_WING_AFT_WPL- See Also:
-
ARC_RIGHT_WING_AFT_WPL
public static final int ARC_RIGHT_WING_AFT_WPL- See Also:
-
ARC_LEFT_SIDE_SPHERE_WPL
public static final int ARC_LEFT_SIDE_SPHERE_WPL- See Also:
-
ARC_RIGHT_SIDE_SPHERE_WPL
public static final int ARC_RIGHT_SIDE_SPHERE_WPL- See Also:
-
ARC_LEFT_SIDE_AFT_SPHERE_WPL
public static final int ARC_LEFT_SIDE_AFT_SPHERE_WPL- See Also:
-
ARC_RIGHT_SIDE_AFT_SPHERE_WPL
public static final int ARC_RIGHT_SIDE_AFT_SPHERE_WPL- See Also:
-
ARC_AFT_WPL
public static final int ARC_AFT_WPL- See Also:
-
ARC_LEFT_BROADSIDE_WPL
public static final int ARC_LEFT_BROADSIDE_WPL- See Also:
-
ARC_RIGHT_BROADSIDE_WPL
public static final int ARC_RIGHT_BROADSIDE_WPL- See Also:
-
HOMING_RADIUS
public static final int HOMING_RADIUS- See Also:
-
DEFAULT_MAX_VISUAL_RANGE
public static int DEFAULT_MAX_VISUAL_RANGE -
MAX_GAMEMASTER_TARGET_MODIFIER
public static final int MAX_GAMEMASTER_TARGET_MODIFIERThe most a gamemaster can add to or take from a unit's target movement modifier: the whole range of the movement table under the option with the wider one, plus the jump bonus. A larger delta could never do more than reach the floor or the ceiling thatgetTargetMovementModifier(Game, int)holds the total to.- See Also:
-
-
Method Details
-
d6
public static int d6()Wrapper to random#d6() -
d6
public static int d6(int dice) Wrapper to random#d6(n) -
d6
public static int d6(int dice, int keep) Wrapper to random#d6(n) -
rollD6
Wrapper to random#d6(n) -
rollD6
Wrapper to random#d6(n) -
individualDice
Input is in format "ndf", so this can handle 2d6 or 3d10- Parameters:
number- the number of dice to rollfaces- the number of faces on those dice- Returns:
- an Integer list of every dice roll, with index 0 containing the summed result
-
individualRolls
Input is in format "c ndf", so that this can handle 10 rolls of 3d6- Parameters:
count- the count of sets of dice to rollnumber- the number of dice to roll per setfaces- the number of faces per die- Returns:
- an Integer list of every summed dice roll, with index 0 containing the summed result
-
getHighestTwoIntegers
public static int getHighestTwoIntegers(int... values) Returns the sum of the highest two values from the provided list of integer values.This method efficiently computes the top two results without sorting, making it suitable for rules that require selecting the best two dice out of several rolled, such as natural aptitude-empowered skill checks.
Edge cases are handled gracefully:
- If no values are provided, the result is
0. - If only one value is provided, that value is returned.
- If two or more values are provided, the sum of the highest two is returned.
- Parameters:
values- one or more integers- Returns:
- the sum of the highest two values (clamped within Integer Min/Max), or a fallback value for edge cases
- Since:
- 0.50.10
- If no values are provided, the result is
-
randomInt
public static int randomInt(int maxValue) Generates a number between 0 and max value exclusive (this means maxValue-1). e.g. randomInt(3) will generate 0, 1, or 2. -
randomIntInclusive
public static int randomIntInclusive(int maxValue) Generates a number between 0 and max value inclusive (this means maxValue). e.g. randomInt(3) will generate 0, 1, 2 or 3. -
randomRealIntInclusive
public static int randomRealIntInclusive(int maxValue) Generates a number between 1 and max value inclusive (this means maxValue). e.g. randomInt(3) will generate 1, 2 or 3. -
randomFloat
public static float randomFloat()Wrapper to random#randomFloat() -
randomListElement
Selects a random element from a list- Type Parameters:
T- The list type- Parameters:
list- The list of items to select from- Returns:
- An element in the list
- Throws:
IllegalArgumentException- when the given list is empty
-
setRNG
public static void setRNG(int type) Sets the RNG to the desired type -
setRNG
Sets the RNG to the specific instance.- Parameters:
random- A non-null instance ofMMRandomto use for all random number generation.
-
oddsAbove
public static double oddsAbove(int n) Returns the odds that a certain number or above will be rolled on 2d6. -
oddsAbove
public static double oddsAbove(int n, boolean dropLowest) Returns the odds that a certain number or above will be rolled on 2d6, or on 3d6 drop the lowest if the flag is set.- Parameters:
dropLowest- Flag that determines whether 2d6 or 3d6 drop the lowest is used
-
oddsAsDisplayPercent
public static double oddsAsDisplayPercent(double odds) Rounds odds fromoddsAbove(int, boolean)down to one decimal place for display. Rounding down means a roll that can still fail never shows as 100%. For example, a target number of 3 rolled with Natural Aptitude is 99.54%, which shows as 99.5% rather than 100%.One decimal place, not two, because the 2d6 odds are stored to one decimal place: 8 or more is stored as 41.6, so two places would show a false 41.60.
- Parameters:
odds- the odds of success, from 0 to 100- Returns:
- the odds rounded down to one decimal place
-
stackingViolation
Returns an entity if the specified entity would cause a stacking violation entering a hex, or returns null if it would not. The returned entity is the entity causing the violation.The position and elevation for the stacking violation are derived from the Entity represented by the passed Entity ID. By default, ignores hidden units.
- Parameters:
game- The Game instanceenteringId- The gameId of the moving Entitycoords- The hex being enteredclimbMode- The moving Entity's climb mode at the point it enters the destination hex- Returns:
- Entity instance that is causing the violation
-
stackingViolation
public static Entity stackingViolation(Game game, Entity entering, Coords dest, Entity transport, boolean climbMode, boolean ignoreHidden) When compiling an unloading step, both the transporter and the unloaded unit probably occupy some other position on the board.The position and elevation for the stacking violation are derived from the passed Entity.
- Parameters:
game- The Game instanceentering- The Entity entering the hexdest- The hex being enteredtransport- Represents the unit transporting entering, which may affect stacking, can be nullclimbMode- The moving Entity's climb mode at the point it enters the destination hexignoreHidden- true by default.- Returns:
- Entity instance that is causing the violation
-
stackingViolation
public static Entity stackingViolation(Game game, Entity entering, int elevation, Coords dest, Entity transport, boolean climbMode, boolean ignoreHidden) Returns an entity if the specified entity would cause a stacking violation entering a hex, or returns null if it would not. The returned entity is the entity causing the violation.The position is derived from the passed Entity, while the elevation is derived from the passed Entity parameter.
- Parameters:
game- The Game instanceentering- The Entity entering the hexelevation- The elevation of the moving Entitydest- The hex being enteredtransport- Represents the unit transporting entering, which may affect stacking, can be nullclimbMode- The moving Entity's climb mode at the point it enters the destination hexignoreHidden- true by default.- Returns:
- Entity instance that is causing the violation
-
stackingViolation
public static Entity stackingViolation(Game game, Entity entering, Coords origPosition, int elevation, Coords dest, Entity transport, boolean climbMode, boolean ignoreHidden) Used by Princess / bots for checking deployment positions.- Parameters:
game- The Game instanceentering- The Entity entering the hexorigPosition- The coords of the hex the moving Entity is leavingelevation- The elevation of the moving Entitydest- The hex being enteredtransport- Represents the unit transporting entering, which may affect stacking, can be nullclimbMode- The moving Entity's climb mode at the point it enters the destination hexignoreHidden- true by default.- Returns:
- Entity instance that is causing the violation
-
stackingViolation
public static Entity stackingViolation(Game game, Entity entering, int elevation, Coords dest, int destBoardId, Entity transport, boolean climbMode, boolean ignoreHidden) Board-aware check used when compiling movepaths- Parameters:
game- The Game instanceentering- The Entity entering the hexelevation- The elevation of the moving Entitydest- The hex being entereddestBoardId- Allows setting a different board for checking destination hextransport- Represents the unit transporting entering, which may affect stacking, can be nullclimbMode- The moving Entity's climb mode at the point it enters the destination hexignoreHidden- true by default.- Returns:
- Entity instance that is causing the violation
-
stackingViolation
public static Entity stackingViolation(Game game, Entity entering, Coords origPosition, int elevation, Coords dest, int destBoardId, Entity transport, boolean climbMode, boolean ignoreHidden) Returns an entity if the specified entity would cause a stacking violation entering a hex, or returns null if it would not. The returned entity is the entity causing the violation.The position and elevation is derived from the passed Entity parameter.
- Parameters:
game- The Game instanceentering- The Entity entering the hexorigPosition- The coords of the hex the moving Entity is leavingelevation- The elevation of the moving Entitydest- The hex being entereddestBoardId- Allows setting a different board for checking destination hextransport- Represents the unit transporting entering, which may affect stacking, can be nullclimbMode- The moving Entity's climb mode at the point it enters the destination hexignoreHidden- true by default.- Returns:
- Entity instance that is causing the violation
-
isEnemyIn
public static boolean isEnemyIn(Game game, Entity entity, Coords coords, boolean onlyMeks, boolean ignoreInfantry, int enLowEl, boolean ignoreHidden) Returns true if there is any unit that is an enemy of the specified unit in the specified hex. This is only called for stacking purposes, and so does not return true if the enemy unit is currently making a DFA. -
isPilotingSkillNeeded
public static boolean isPilotingSkillNeeded(Game game, int entityId, Coords src, Coords dest, EntityMovementType movementType, boolean isTurning, boolean prevStepIsOnPavement, int srcElevation, int destElevation, MoveStep moveStep) - Returns:
- true if a piloting skill roll is needed to traverse the terrain
-
isValidDisplacement
Can the defending unit be displaced from the source to the destination? -
isValidDisplacement
Can the defending unit be displaced from the source to the destination? -
getValidDisplacement
Gets a valid displacement, from the hexes around src, as close to the original direction as is possible.- Returns:
- valid displacement coords, or null if none
-
getPreferredDisplacement
Gets a preferred displacement. Right now this picks the surrounding hex with the same elevation as original hex, if not available it picks the highest elevation that is a valid displacement. This will preferably not displace into friendly units- Returns:
- valid displacement coords, or null if none
-
getMissedChargeDisplacement
public static Coords getMissedChargeDisplacement(Game game, int entityId, Coords src, int direction) Gets a hex to displace a missed charge to. Picks left or right, first preferring higher hexes, then randomly, or returns the base hex if they're impassible. -
findSpotter
Finds the best spotter for the attacker. The best spotter is the one with the lowest attack modifiers, of course. LOS modifiers and movement are considered. -
isTargetTagged
Worker function to determine if the target has been tagged.- Parameters:
target- The non-entity target to checkgame- The currentGame- Returns:
- Whether the given entity or other targetable is tagged.
-
isTargetTagged
Worker function to determine if the target has been tagged by the specific attacker.- Parameters:
attacker- The attacker.target- The non-entity target to checkgame- The currentGame- Returns:
- Whether the given entity or other targetable is tagged by the specific attacker.
-
getImmobileMod
-
getImmobileMod
@Nullable public static ToHitData getImmobileMod(Targetable target, int aimingAt, AimingMode aimingMode) Gets the ToHitData associated with firing at an immobile target. Returns null if target isn't.Note: all Ranged attack calls *must* go through *.addImmobileMod() or we may get illegal -4 mods. Currently this is the case; all other attack types go through the above simplified method.
- Parameters:
target- The target being considered for firingaimingAt- The location of the unit being aimed ataimingMode- The aiming mode- Returns:
- The relevant ToHitData
-
getRangeMods
public static ToHitData getRangeMods(Game game, Entity attackingEntity, WeaponMounted weapon, AmmoMounted ammo, Targetable target) Determines the to-hit modifier due to range for an attack with the specified parameters. Includes minimum range, infantry 0-range mods, and target stealth mods. Accounts for friendly C3 units.- Returns:
- the modifiers
-
getRangeMods
public static ToHitData getRangeMods(Game game, Entity attackingEntity, WeaponMounted weapon, AmmoMounted ammo, Targetable target, @Nullable List<ECMInfo> allECMInfo) Determines the to-hit modifier due to range for an attack with the specified parameters. Includes minimum range, infantry 0-range mods, and target stealth mods. Accounts for friendly C3 units.For a C3-equipped attacker, the C3 spotter search needs ECM information for every game entity, which is expensive to compute. Callers that evaluate many attacks in a row (bots, to-hit previews) should compute that list once via
ComputeECM.computeAllEntitiesECMInfo(List)and pass it in.- Parameters:
allECMInfo- Precomputed ECM information for all game entities, ornullto compute it on demand- Returns:
- the modifiers
-
getInfantryRangeMods
public static ToHitData getInfantryRangeMods(int distance, InfantryWeapon primaryWeapon, InfantryWeapon secondaryWeapon, @Nullable InfantryWeapon disposableWeapon, boolean underwater) Calculate the range modifiers for a conventional infantry attack.- Parameters:
distance- - range to targetprimaryWeapon- - the weapon used to calculate range -- secondaryWeapon if 2/squad, otherwise primarysecondaryWeapon- - the secondaryWeapon weapon, if any. Range zero penalties apply even if primary is used for rangeunderwater- - underwater range is half, rounded down- Returns:
- - all modifiers for range
-
effectiveWeaponDistance
public static int effectiveWeaponDistance(Game game, Entity weaponEntity, WeaponMounted weapon, Targetable target) Calculates effective distance from a weapon's firing position to a target, accounting for altitude differences and same-building elevation modifiers. This is used for entities with multiple firing positions like BuildingEntity.- Parameters:
game- The current gameweaponEntity- The entity with the weaponweapon- The weapon being firedtarget- The target being attacked- Returns:
- The effective distance from the weapon's firing position to the target
-
effectiveDistance
-
effectiveDistance
public static int effectiveDistance(Game game, Entity attacker, @Nullable Targetable target, boolean useGroundDistance) Finds the effective distance between an attacker and a target. Includes the distance bonus if the attacker and target are in the same building and on different levels. Also takes account of altitude differences- Returns:
- the effective distance
-
getClosestFlightPath
@Nullable public static Coords getClosestFlightPath(int attackerId, Coords aPos, Entity targetEntity) - Parameters:
aPos- the attacker's positiontargetEntity- the target entity- Returns:
- the closest position along
targetEntity's flight path toaPos. In the case of multiple equidistance positions, the first one is picked unlesstargetEntity's playerPickedPassThrough position is non-null.
-
getClosestFlightPathFacing
-
getClosestToFlightPath
- Parameters:
flyingEntity- the flyertargetPosition- target- Returns:
- the closest position along
flyingEntity's flight path totargetPosition. In the case of multiple equidistance positions, the first one is picked.
-
exposed_findC3Spotter
@Deprecated public static Entity exposed_findC3Spotter(Game game, Entity attacker, Targetable target) Deprecated.WOR: Need this function to find out where my nova stuff doesn't work. Delete it if nova works but remember to alter the /nova debug server command. -
findTAGSpotter
public static Entity findTAGSpotter(Game game, Entity attacker, Targetable target, boolean stopAtFirst) Function that attempts to find one TAG spotter, or the best TAG spotter,- Parameters:
attacker- should be an artillery unittarget- (if null, do not return a spotter!)stopAtFirst- if we only want to know that there is one, not which is best- Returns:
- The Spotter.
-
getProneMods
Gets the modifiers, if any, that the mek receives from being prone.- Returns:
- any applicable modifiers due to being prone
-
getDamageWeaponMods
Adds any damage modifiers from arm critical hits or sensor damage.- Returns:
- Any applicable damage modifiers
-
getSecondaryTargetMod
Determines if the current target is a secondary target, and if so, returns the appropriate modifier.- Returns:
- The secondary target modifier.
-
getAccidentalFallFromAboveDamageFor
Damage that a mek does with an accidental fall from above. -
getAttackerMovementModifier
Modifier to attacks due to attacker movement -
getAttackerMovementModifier
public static ToHitData getAttackerMovementModifier(Game game, int entityId, EntityMovementType movement) Modifier to attacks due to attacker movement -
getSpotterMovementModifier
Modifier to attacks due to spotter movement -
getSpotterMovementModifier
public static ToHitData getSpotterMovementModifier(Game game, int entityId, EntityMovementType movement) Modifier to attacks due to spotter movement -
modifyPhysicalBTHForAdvantages
public static void modifyPhysicalBTHForAdvantages(Entity attacker, Entity target, ToHitData toHit, Game game) Modifier to physical attack BTH due to pilot advantages -
maxTargetMovementModifier
The highest target movement modifier a ground unit can earn in this game: the top of the movement table, +6 or +7 under the MaxTech movement modifiers option, plus the +1 for jumping or being airborne. A gamemaster's change is held to this ceiling.- Parameters:
game- the game whose options decide the table, ornullfor the standard table- Returns:
- the ceiling of the target movement modifier
-
getTargetMovementModifier
Modifier to attacks due to target movement, with any gamemaster change for the round applied on top and the total held between no modifier andmaxTargetMovementModifier(Game). Aerospace targets take no movement modifier here and so take no gamemaster change either.- Parameters:
game- current gameentityId- targetId- Returns:
- toHitData for the target's movement modifiers
- See Also:
-
minGamemasterTargetModifier
The largest reduction a gamemaster's target movement modifier change can make on this unit this round: the earned modifier taken back down to the floorgetTargetMovementModifier(Game, int)holds the total to. A unit that earned+2by moving can be reduced by2; one that earned nothing, or the-1for standing still, cannot be reduced at all. The damage editor uses this as the bottom of its Target Modifier control, so every reduction it offers applies in full.- Parameters:
game- current gameentityId- targetId- Returns:
- the lowest delta that still changes the modifier, zero or negative
-
getEarnedTargetMovementModifier
Modifier to attacks due to target movement, as the unit earned it by moving this round, before any gamemaster change. The damage editor shows this beside its Target Modifier control, so a gamemaster can see what a reduction has to work with: a unit that earned nothing cannot be taken below nothing.- Parameters:
game- current gameentityId- targetId- Returns:
- toHitData for the target's movement modifiers
-
getTargetMovementModifier
public static ToHitData getTargetMovementModifier(int distance, boolean jumped, boolean airborneNonAerospace, Game game) Target movement modifier for the specified distance- Parameters:
distance- how many hexes did the target unit move?jumped- did the target unit jump?airborneNonAerospace- was the target an airborne, non-aerospace unit?game- current game- Returns:
- toHitData for the target's movement modifiers
- See Also:
-
getAttackerTerrainModifier
Modifier to attacks due to attacker terrain -
getTargetTerrainModifier
Modifier to attacks due to target terrain TODO:um....should VTOLs get modifiers for smoke, etc. -
getTargetTerrainModifier
-
getTargetTerrainModifier
public static ToHitData getTargetTerrainModifier(Game game, Targetable target, int eiStatus, boolean attackerInSameBuilding) -
getTargetTerrainModifier
public static ToHitData getTargetTerrainModifier(Game game, Targetable targetable, int eiStatus, boolean attackerInSameBuilding, boolean underwaterWeapon) -
getStrafingTerrainModifier
-
getTargetTotalHP
Calculates the current theoretical damage absorbable (armor+structure, etc.) by the given target. Used as a measure of the potential durability of the target under fire. -
getHighestExpectedDamage
public static WeaponAttackAction getHighestExpectedDamage(Game g, List<WeaponAttackAction> vAttacks, boolean assumeHit) Returns the weapon attack out of a list that has the highest expected damage -
getSecondHighestExpectedDamage
public static WeaponAttackAction getSecondHighestExpectedDamage(Game g, List<WeaponAttackAction> vAttacks, boolean assumeHit) Returns the weapon attack out of a list that has the second highest expected damage used for engaging multiple salvos -
getExpectedDamage
Determines the expected damage to a weapon attack, based on to-hit, salvo sizes, etc. -
getExpectedDamage
public static float getExpectedDamage(Game game, WeaponAttackAction weaponAttackAction, boolean assumeHit, List<ECMInfo> allECMInfo) Determines the expected damage to a weapon attack, based on to-hit, salvo sizes, etc. -
getAmmoAdjDamage
@Deprecated(since="0.51.0", forRemoval=true) public static double getAmmoAdjDamage(Game game, WeaponAttackAction weaponAttackAction) Deprecated, for removal: This API element is subject to removal in a future version.If the unit is carrying multiple types of ammo for the specified weapon, cycle through them and choose the type best suited to engage the specified target Value returned is expected damage Note that some ammo types, such as infernos, do no damage or have special properties and so the damage is an estimation of effectiveness -
spinUpCannon
Deprecated.If this is an ultra or rotary cannon, lets see about 'spinning it up' for extra damage- Returns:
- the
intID of weapon mode
-
spinUpCannon
Determine if autocannon should fire more than one round. Includes standard ACs if the game option for rapid-fire-mode is enabled.- Parameters:
game- The current gameattackAction- Attack action with weapon attack propertiesspinupThreshold- Maximum to-hit number to consider for rapid fire- Returns:
- the
intID of weapon mode, which is also the number of mode changes from single shot
-
isThroughFrontHex
Returns true if the line between source Coords and target goes through the hex in front of the attacker -
firingArcFromVGLFacing
public static int firingArcFromVGLFacing(int facing) Converts the facing of a vehicular grenade launcher to the corresponding firing arc.- Parameters:
facing- The VGL facing returned byMounted.getFacing()- Returns:
- The firing arc
-
inVisualRange
checks to see whether the target is within visual range of the entity, but not necessarily LoS -
inVisualRange
public static boolean inVisualRange(Game game, LosEffects los, Entity attackingEntity, Targetable target) Determine whether the attacking entity is within visual range of the target. This requires line of sight effects to determine if there are certain intervening obstructions, like smoke, that can reduce visual range. Since repeated LoSEffects computations can be expensive, it is possible to pass in the LosEffects, since they are commonly already computed when this method is called.- Parameters:
game- The currentGame
-
isAnySensorContact
@Deprecated(since="0.51.0", forRemoval=true) public static boolean isAnySensorContact(Game game, int targetId) Deprecated, for removal: This API element is subject to removal in a future version.Checks to see if an entity has already been detected by anyone Used for sensor return icons on board- Parameters:
game- The currentGametargetId- - the ID# of the target entity we're looking for
-
hasSensorContact
Checks to see if target entity has already appeared on detector's sensors Used with Naval C3 to determine if detector can fire weapons at @target- Parameters:
detector- - the entity making a sensor scantargetId- - the entity id of the scan target
-
hasAnyFiringSolution
Checks to see if an entity is in anyone's firing solutions list Used for visibility- Parameters:
game- The currentGametargetId- - the ID # of the target we're firing at
-
updateFiringSolutions
Updates an entity's firingSolutions, removing any objects that no longer meet criteria for being tracked as targets. Also, if the detecting entity no longer meets criteria for having firing solutions, empty the list. We wouldn't want a dead ship to be providing NC3 data, now would we... -
updateSensorContacts
Updates an entity's sensorContacts, removing any objects that no longer meet criteria for being tracked. Also, if the detecting entity no longer meets criteria for having sensor contacts, empty the list. We wouldn't want a dead ship to be providing sensor data, now would we... -
calcFiringSolution
If the game is in space, "visual range" represents a firing solution as defined in SO starting on p117 Also, in most cases each target must be detected with sensors before it can be seen, so we need to make sensor rolls for detection. This should only be used if TacOps sensor rules are in use. This requires line of sight effects to determine if there are certain intervening obstructions, like sensor shadows, asteroids and that sort of thing, that can reduce visual range. Since repeated LoSEffects computations can be expensive, it is possible to pass in the LosEffects, since they are commonly already computed when this method is called.- Parameters:
game- The currentGameae- the entity making a sensor scantarget- the entity we're trying to spot
-
calcFutureTargetFiringSolution
@Deprecated(since="0.51.0", forRemoval=true) public static boolean calcFutureTargetFiringSolution(Game game, Entity attacker, Targetable target, Coords futureTargetPosition) Deprecated, for removal: This API element is subject to removal in a future version. -
calcSensorContact
Determines whether we have an "object" detection as defined in SO's Advanced Sensors rules starting on p117- Parameters:
game- The currentGameae- the entity making a sensor scantarget- the entity we're trying to spot
-
getVisualRange
- Returns:
- visual range in hexes along a specific line of sight
-
getMaxVisualRange
- Returns:
- visual range in hexes given current planetary conditions and no los obstruction
-
inSensorRange
public static boolean inSensorRange(Game game, Entity ae, Targetable target, List<ECMInfo> allECMInfo) Checks to see whether the target is within sensor range (but not necessarily LoS or visual range)- Parameters:
allECMInfo- A collection of ECMInfo for all entities, this value can be null, and it will be computed when it's needed, however passing in the pre-computed collection is much faster
-
inSensorRange
public static boolean inSensorRange(Game game, LosEffects los, Entity ae, Targetable target, List<ECMInfo> allECMInfo) -
canSee
Checks to see if the target is visible to the unit, always considering sensors. -
canSee
public static boolean canSee(Game game, Entity ae, Targetable target, boolean useSensors, LosEffects los, List<ECMInfo> allECMInfo) Checks to see if the target is visible to the unit, if the sensor flag is true then sensors are checked as well. -
getSensorRangeBracket
gets the sensor range bracket when detecting a particular type of target. target may be null here, which gives you the bracket without target entity modifiers- Parameters:
allECMInfo- A collection of ECMInfo for all entities, this value can be null, and it will be computed when it's needed, however passing in the pre-computed collection is much faster
-
getSensorBracket
public static int getSensorBracket(int check) returns the brackets for sensor checks -
getSensorRangeByBracket
public static int getSensorRangeByBracket(Game game, Entity ae, @Nullable Targetable target, @Nullable LosEffects los) gets the size of the sensor range bracket when detecting a particular type of target. target may be null here, which gives you the range without target entity modifiers -
getADARangeModifier
public static int getADARangeModifier(int distance) -
getSensorRanges
returns the current sensing ranges of the active sensor -
shouldMoveBackHex
Compares the initiative of two aerospace units in the same hex to determine attack angle. The attack angle is computed as if the unit with the higher initiative were in its previous hex.- Parameters:
e1- The firstEntityto comparee2- The secondEntityto compare- Returns:
- < 0 if the first unit has a higher initiative, > 0 if the second is higher, or 0 if one of the units is not an aerospace unit, does not have a valid position, or the two units are not in the same hex.
-
missilesHit
public static int missilesHit(int missiles) Maintain backwards compatibility.- Parameters:
missiles- - theintnumber of missiles in the pack.
-
missilesHit
public static int missilesHit(int missiles, int nMod) Maintain backwards compatability. -
missilesHit
public static int missilesHit(int missiles, int nMod, boolean hotLoaded) Maintain backwards compatability. -
missilesHit
public static int missilesHit(int missiles, int nMod, boolean hotLoaded, boolean streak, boolean advancedAMS) Roll the number of missiles (or whatever) on the missile hit table, with the specified mod to the roll.- Parameters:
missiles- - theintnumber of missiles in the pack.nMod- - theintmodifier to the roll for number of missiles that hit.hotLoaded- - roll 3d6 take worst 2streak- - force a roll of 11 on the cluster tableadvancedAMS- - the roll can now go below 2, indicating no damage
-
calculateClusterHitTableAmount
public static int calculateClusterHitTableAmount(int roll, int rackSize) -
getMetalInPath
Check for ferrous metal content in terrain on path from a to b return the total content. -
getGhostTargetNumber
Check for ECM bubbles in Ghost Target mode along the path from a to b and return the highest target roll. -1 if no Ghost Targets -
getSpaceBombBaseToHit
Get the base to-hit number of a space bomb attack by the given attacker upon the given defender- Parameters:
attacker- - theEntityconducting the leg attack.defender- - theEntitybeing attacked.- Returns:
- The base
ToHitDataof the attack.
-
getLegAttackBaseToHit
Get the base to-hit number of a Leg Attack by the given attacker upon the given defender- Parameters:
attacker- - theEntityconducting the leg attack.defender- - theEntitybeing attacked.- Returns:
- The base
ToHitDataof the attack.
-
getSwarmMekBaseToHit
Get the base to-hit number of a Swarm Mek by the given attacker upon the given defender.- Parameters:
attacker- - theEntityswarming.defender- - theEntitybeing swarmed.- Returns:
- The base
ToHitDataof the mek.
-
canPhysicalTarget
-
canMoveOnPavement
Can movement between the two coordinates be on pavement (which includes roads and bridges)? If so it will override prohibited terrain, it may change movement costs, and it may lead to skids. -
canMoveOnPavement
Can movement between the two coordinates be on pavement (which includes roads and bridges)? If so it will override prohibited terrain, it may change movement costs, and it may lead to skids. -
isInSameBuilding
Determines whether the attacker and the target are in the same building.- Returns:
- true if the target can and does occupy the same building, false otherwise.
-
isInBuilding
Determine if the given unit is inside a building at the given coordinates.- Parameters:
game- The currentGame. This value may benull.entity- theEntityto be checked. This value may benull.- Returns:
trueif the entity is inside the building at those coordinates.falseif there is no building at those coordinates or if the entity is on the roof or in the air above the building, or if any input argument isnull
-
isInBuilding
public static boolean isInBuilding(@Nullable Game game, @Nullable Entity entity, @Nullable Coords coords) Determine if the given unit is inside a building at the given coordinates.- Parameters:
game- The currentGame. This value may benull.entity- theEntityto be checked. This value may benull.coords- theCoordsof the building hex. This value may benull.- Returns:
trueif the entity is inside the building at those coordinates.falseif there is no building at those coordinates or if the entity is on the roof or in the air above the building, or if any input argument isnull
-
isInBuilding
public static boolean isInBuilding(@Nullable Game game, int elevation, @Nullable Coords coords, int boardId) Returns true when the given place is inside a building, false when the location is not on a board, has no building or the elevation is below the basement or on or above the building. Note that it is safe to pass in any values for elevation, coords and board ID.- Parameters:
game- The game (not null)elevation- The elevation to testcoords- The coords of the locationboardId- The board ID of the location- Returns:
- True if the given place is inside a building
-
scatterDiveBombs
Scatter from hex according to dive-bombing rules (based on MoF), TW pg 246. The scatter can happen in any direction.- Parameters:
coords- TheCoordsto scatter frommoF- The margin of failure, which determines scatter distance- Returns:
- the
Coordsscattered to and distance (moF)
-
scatterAltitudeBombs
Scatter from hex according to altitude bombing rules (based on MoF), TW pg 246. The scatter only happens in the "front" three facings.- Parameters:
coords- TheCoordsto scatter fromfacing- Direction we were going at the time the bomb was droppedmoF- How badly we failed- Returns:
- the
Coordsscattered to and distance (moF)
-
scatterDirectArty
scatter from hex according to direct fire artillery rules (based on MoF)- Parameters:
coords- TheCoordsto scatter frommoF- The margin of failure, which determines scatter distance- Returns:
- the
Coordsscattered to
-
scatter
Scatters from a hex in a random direction, rolling 1d6 to pick one of the six straight-line directions.- Parameters:
coords- theCoordsto scatter frommargin- the scatter distance in hexes; its magnitude is used, so a negative value (such as a negative margin of failure) scatters the same distance as its positive counterpart. Callers may also pass a fixed distance unrelated to a margin of failure.- Returns:
- the
Coordsscattered to
-
scatterAssaultDrop
scatter from hex according to atmospheric drop rules d6 for direction, 1d6 per point of MOF- Parameters:
coords- TheCoordsto scatter frommargin- theintmargin of failure- Returns:
- the
Coordsscattered to
-
getSwarmMissileTarget
@Nullable public static Entity getSwarmMissileTarget(Game game, int aeId, Coords coords, int weaponId) Gets a new target for a flight of swarm missiles that was just shot at an entity and has missiles left- Parameters:
game- The currentGameaeId- The attackingEntityweaponId- TheintID of the launcher used to fire this volley- Returns:
- the new target
Entity. May return null if no new target available
-
getFinalPosition
-
changeVectors
public static int[] changeVectors(int[] v, int facing) method to change a set of active vectors for a one-point thrust expenditure in the giving facing -
sameVectors
public static boolean sameVectors(int[] v1, int[] v2) compare two vectors and determine if they are the same -
getNetVelocity
Get the net velocity of two aerospace for ramming attacks -
directBlowBADamage
Returns how much damage a weapon will do against a BattleArmor target if the BattleArmor vs BattleArmor rules on TO pg 109 are in effect.- Parameters:
damage- Original weapon damagedamageType- The damage type for BA vs BA damagetarget- The target, used for ensuring the target BA isn't fire-resistant
-
getDamageTypeString
Used to get a human-readable string that represents the passed damage type.- Parameters:
damageType- The damageType constantburstMultiplier- The multiplier for burst damage, used by machine gun arrays against conventional infantry- Returns:
- A string representation of the damage type
-
directBlowInfantryDamage
public static int directBlowInfantryDamage(double damage, int mos, int damageType, boolean isNonInfantryAgainstMechanized, boolean isAttackThruBuilding) -
directBlowInfantryDamage
public static int directBlowInfantryDamage(double damage, int mos, int damageType, boolean isNonInfantryAgainstMechanized, boolean isAttackThruBuilding, int attackerId, Vector<Report> vReport) Method replicates the Non-Conventional Damage against Infantry damage table as well as shifting for direct blows. also adjust for non-infantry damaging mechanized infantry -
computeTotalDamage
- Returns:
- the maximum damage that a set of weapons can generate.
-
computeTotalDamage
- Returns:
- the maximum damage that a weapon can generate.
-
directBlowInfantryDamage
public static int directBlowInfantryDamage(double damage, int mos, int damageType, boolean isNonInfantryAgainstMechanized, boolean isAttackThruBuilding, int attackerId, Vector<Report> vReport, int mgaSize) Method replicates the Non-Conventional Damage against Infantry damage table as well as shifting for direct blows. also adjust for non-infantry damaging mechanized infantry. No mods for Plasma weapons.- Parameters:
damage- The base amount of damagemos- The margin of successdamageType- The damage class of the weapon, used to adjust damage against infantryisNonInfantryAgainstMechanized- Whether this is a non-infantry attack against mechanized infantryisAttackThruBuilding- Whether the attack involves attacker and target both within the same buildingattackerId- The entity id of the attacking unitvReport- The report messages vectormgaSize- For machine gun array attacks, the number of linked weapons. For other weapons this should be 1.- Returns:
- The adjusted damage
-
dialDownDamage
Method computes how much damage a dial down weapon has done- Returns:
- new damage
-
dialDownDamage
Method computes how much damage a dial down weapon has done- Returns:
- new damage
-
dialDownHeat
Method computes how much heat a dial down weapon generates- Returns:
- Heat, minimum of 1;
-
dialDownHeat
Method computes how much heat a dial down weapon generates- Returns:
- Heat, minimum of 1;
-
getAdjacentEntitiesAlongAttack
- Parameters:
aPos- - attacking entitytPos- - targeted entity- Returns:
- a vector of all the entities that are adjacent to the targeted entity and would fall along the angle of attack
-
isInUrbanEnvironment
-
isAirToGround
Returns true when an attack of the attacker against the target is considered an A2G attack, see TW p.242-247. This includes strafing, striking and bombing. Attacks on Hex targets and Entity targets can be A2G attacks. Artillery attacks, even from an airborne aero unit, do not count as A2G attacks. Attacks from spaceborne aerospace do not count as A2G attacks (they may count as O2G attacks). Also note that flying ground units such as VTOLs and WiGEs count as ground targets and so attacks against them may count as A2G attacks.- Parameters:
attacker- The assumed attackertarget- The assumed target- Returns:
- True if the attack would be considered an A2G attack
-
isAirToAir
Returns true when an attack of the given units would be an A2A attack. Checks for null units and if both units are airborne,Entity.isAirborne(). Also checks if they're either on the same map or on connected maps (atmosphere/ground or ground/ground within one atmosphere map).- Parameters:
game- The gameattacker- The attacking unittarget- The target- Returns:
- True when the supposed attack would be an A2A attack
-
isGroundToAir
-
isGroundToGround
-
roundsUntilReturn
This is a homebrew function partially drawn from pg. 40-1 of AT2R that allows units that flee the field for any reason to return after a certain number of rounds It can potentially be expanded to include other conditions- Returns:
- number of rounds until return (-1 if never)
-
inDeadZone
-
getAcceptableUnloadPositions
-
isAcceptableUnloadPosition
-
getMountableUnits
public static List<Entity> getMountableUnits(Entity entity, Coords pos, int boardId, int elev, Game game) Returns a list of all adjacent units that can load the given Entity.- Parameters:
entity- The entity to loadpos- The coordinates of the hex to load fromboardId- The board ID of the hex to load fromelev- The absolute elevation of the unit at the point of loading (surface of the hex + elevation over the surface)game- The game- Returns:
- All adjacent units that can transport the Entity
-
allowAimedShotWith
-
getAeroCrewNeeds
-
getSVBaseCrewNeeds
Calculates the base crew requirements for support vehicles.- Parameters:
entity- The support vehicle- Returns:
- The minimum base crew
-
getTotalGunnerNeeds
Returns the number of required gunners for an entity.- Parameters:
entity- The entity- Returns:
- The number of required gunners
-
getAdditionalNonGunner
Calculates the number of additional non-gunner crew members required by vehicles and advanced aerospace vessels due to specific miscellaneous equipment mounts or special unit features.Crew additions are based on the tonnage or equipment size of certain mounted systems, such as:
- Communications equipment (
F_COMMUNICATIONS): +1 crew per ton of equipment - Field Kitchens (
F_FIELD_KITCHEN): +3 crew per mount - Mobile Field Bases (
F_MOBILE_FIELD_BASE): +5 crew per mount - MASH units (
F_MASH): +5 crew per size unit
For tanks, any additional crew seats (via
getExtraCrewSeats()) are added.If the unit has a drone operating system it requires 0 additional crew. For super-heavy meks, this always returns
1(to represent the Tactical Officer).- Parameters:
entity- The unit for which to calculate the additional crew requirements- Returns:
- The number of additional non-gunner crew required for the given unit
- Communications equipment (
-
getCommunicationsCrew
-
getDoctorCrew
-
getMedicCrew
-
getCombatTechCrew
-
getAstechCrew
-
getFullCrewSize
-
getTotalDriverNeeds
-
useSpheroidAtmosphere
Should we treat this entity, in its current state, as if it is a spheroid unit flying in atmosphere? -
indirectAttackImpossible
public static boolean indirectAttackImpossible(Game game, Entity ae, Targetable target, WeaponType weaponType, Mounted<?> weapon) Worker function that checks if an indirect attack is impossible for the given passed-in arguments -
isFlakAttack
-
isFlakToHitTarget
Returns whether a flak weapon (LB-X cluster, flak ammo, HAG and the like) gets its to-hit bonus against the target. TW p.114 (errata v12.0): flak applies "against a unit that presently has an Altitude or Elevation, or that expended any VTOL or WiGE MP or Thrust Points that turn (even if it landed at the end of that Movement Phase)". A VTOL or WiGE that flew and then landed is therefore still a flak target for the rest of the turn.This is the to-hit check only. Artillery flak, which bursts at the target's height, keeps using
isFlakAttack(Entity, Entity).- Parameters:
attacker- the attacking unittarget- the unit being attacked- Returns:
trueif a flak weapon gets its to-hit bonus against the target
-
turnsTilHit
public static int turnsTilHit(int distance) -
turnsTilBOMHit
Get turns for an indirect or off-board round to hit with its current velocity- Parameters:
ae- Attackertarget- Target hex/entityvelocity- speed of round, default 50 according to WeaponAttackAction
-
calculateArtilleryLead
public static Coords calculateArtilleryLead(Game game, Entity ae, Targetable target, boolean homing) - Parameters:
homing- to determine if we need the homing lead or some other value.- Returns:
- Coordinates to aim at to hit this target while it's on the move (we think).
-
calculateArtilleryLead
- Returns:
- Coordinates to target given this lead and direction
-
canPointBlankShot
Lightweight helper to determine if a given unit can take a Pointblank shot on another- Parameters:
attacker- Prospective Pointblank Shot shootertarget- Prospective Pointblank Shot target- Returns:
- boolean true if shot can be taken legally; false otherwise
-
revealsHiddenUnitForPointblankShot
public static boolean revealsHiddenUnitForPointblankShot(Entity mover, int distance, boolean overflight) Whether a moving enemy reveals a hidden unit in a way that lets it take a point-blank shot (TW p.260).A hidden unit revealed by enemy movement may immediately make the shot, and the rule allows the target to "continue its move after the attack" when it has MP left. That is only possible part way through a move, so a ground unit reveals as it passes rather than only when it stops. Requiring the mover to stop meant walking past a hidden unit did nothing at all.
An airborne aerospace mover is different: it reveals what it flies over, so the range depends on whether it carries an Active Probe.
A VTOL or WiGE flying over a hex does not reveal a unit hidden in that hex (TW errata v12.0, p.260, Airborne Units). It still reveals a unit it passes next to, and one in the hex where it ends its move, as a ground unit would.
- Parameters:
mover- the unit that is movingdistance- hexes between the mover's current step and the hidden unitoverflight-truewhen this step is a VTOL or WiGE flying over the hex without ending its move there; seeisNonAerospaceOverflight(Entity, MoveStep, boolean)- Returns:
trueif the hidden unit is revealed and may take its shot
-
isNonAerospaceOverflight
Whether a step is a non-aerospace airborne unit flying over a hex: a unit using VTOL or WiGE movement (VTOLs, WiGEs, LAMs in AirMek mode, powered flight infantry) that is above the terrain of the step's hex and does not end its move there. Such a unit does not reveal units hidden in the hexes it flies over (TW errata v12.0, p.260, Airborne Units).- Parameters:
mover- the unit that is movingstep- the step being takenendStep-truewhen this is the last step of the move- Returns:
trueif the step flies over its hex
-
canDetectHidden
Lightweight helper for some step evaluation. No side effects.- Parameters:
detector- Entity that will detect a hidden unitdistance- int Distance from detector to hidden entityendStep- boolean whether this detection is occurring at the last step of a move path- Returns:
- true if detector can detect a unit in this situation
-
allEnemiesOutsideBlast
public static boolean allEnemiesOutsideBlast(Targetable target, Entity attacker, AmmoType ammoType, boolean artillery, boolean flak, boolean asfFlak, Game game) -
enemiesInsideBlast
-
log2
Fast log2 implementation; throws if number ≤ 0- Parameters:
number- positive int to get the log2 of- Returns:
- int approximate log2 of number; functionally (Math.floor(log10(10)/log10(2))
- Throws:
IllegalArgumentException
-
getLoadableCoords
Helper to get the coordinates from which a unit can load other units. Not in Entity to avoid bloat. May need extension for different map types but unlikely.- Parameters:
carrier- Entity that will be doing the loadingposition- Coords of hex to use as the center of the carrier; may not match carrier's current position value.boardId- For future use, e.g. low-altitude or multi-board maps- Returns:
- ArrayList of Coords that the carrier entity can legally load units from
-