megamek.common
Class Compute

java.lang.Object
  extended by megamek.common.Compute

public class Compute
extends java.lang.Object

The compute class is designed to provide static methods for mechs and other entities moving, firing, etc.


Field Summary
static int ARC_360
           
static int ARC_AFT
           
static int ARC_EAST
           
static int ARC_FORWARD
           
static int ARC_LEFT_BROADSIDE
           
static int ARC_LEFT_SPHERE_GROUND
           
static int ARC_LEFTARM
           
static int ARC_LEFTSIDE
           
static int ARC_LEFTSIDE_SPHERE
           
static int ARC_LEFTSIDEA_SPHERE
           
static int ARC_LWING
           
static int ARC_LWINGA
           
static int ARC_MAINGUN
           
static int ARC_NORTH
           
static int ARC_NOSE
           
static int ARC_REAR
           
static int ARC_RIGHT_BROADSIDE
           
static int ARC_RIGHT_SPHERE_GROUND
           
static int ARC_RIGHTARM
           
static int ARC_RIGHTSIDE
           
static int ARC_RIGHTSIDE_SPHERE
           
static int ARC_RIGHTSIDEA_SPHERE
           
static int ARC_RWING
           
static int ARC_RWINGA
           
static int ARC_TURRET
           
static int ARC_WEST
           
static int LEVEL_ELITE
           
static int LEVEL_GREEN
           
static int LEVEL_REGULAR
           
static int LEVEL_VETERAN
           
static int METHOD_CONSTANT
           
static int METHOD_TAHARQA
           
static int METHOD_TW
           
static int TYPE_CLAN
           
static int TYPE_IS
           
static int TYPE_MD
           
static int WEAPON_CLUSTER_BALLISTIC
           
static int WEAPON_CLUSTER_MISSILE
           
static int WEAPON_CLUSTER_MISSILE_1D6
           
static int WEAPON_CLUSTER_MISSILE_2D6
           
static int WEAPON_CLUSTER_MISSILE_3D6
           
static int WEAPON_DIRECT_FIRE
           
static int WEAPON_PULSE
           
 
Constructor Summary
Compute()
           
 
Method Summary
static int calculateClusterHitTableAmount(int roll, int rackSize)
           
static boolean canMoveOnPavement(IGame game, Coords src, Coords dest, MovePath movePath)
          Can movement between the two coordinates be on pavement (which includes roads and bridges)?
static boolean canPhysicalTarget(IGame game, int entityId, Targetable target)
           
static boolean canSee(IGame game, Entity ae, Targetable target)
          Slightly misnamed.
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
static java.util.ArrayList<Coords> coordsAtRange(Coords centre, int range)
          Gets a ring of hexes at a specified distance from the centre
static int d6()
          Wrapper to random#d6()
static int d6(int dice)
          Wrapper to random#d6(n)
static int dialDownDamage(Mounted weapon, WeaponType wtype)
          Method computes how much damage a dial down weapon has done
static int dialDownDamage(Mounted weapon, WeaponType wtype, int range)
          Method computes how much damage a dial down weapon has done
static int dialDownHeat(Mounted weapon, WeaponType wtype)
          Method computes how much heat a dial down weapon generates
static int dialDownHeat(Mounted weapon, WeaponType wtype, int range)
          Method computes how much heat a dial down weapon generates
static int directBlowInfantryDamage(double damage, int mos, int damageType, boolean isNonInfantryAgainstMechanized)
          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
static int effectiveDistance(IGame game, Entity attacker, Targetable target)
          Finds the effective distance between an attacker and a target.
static int effectiveDistance(IGame game, Entity attacker, Targetable target, boolean useGroundDistance)
          Finds the effective distance between an attacker and a target.
static Entity findSpotter(IGame game, Entity attacker, Targetable target)
          Finds the best spotter for the attacker.
static java.util.ArrayList<Entity> getAdjacentEntitiesAlongAttack(Coords aPos, Coords tPos, IGame game)
           
static int getAffaDamageFor(Entity entity)
          Damage that a mech does with a accidental fall from above.
static double getAmmoAdjDamage(IGame cgame, WeaponAttackAction atk)
          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
static double getAngelECMFieldSize(Entity ae, Coords a, Coords b)
           
static ToHitData getAttackerMovementModifier(IGame game, int entityId)
          Modifier to attacks due to attacker movement
static ToHitData getAttackerMovementModifier(IGame game, int entityId, EntityMovementType movement)
          Modifier to attacks due to attacker movement
static ToHitData getAttackerTerrainModifier(IGame game, int entityId)
          Modifier to attacks due to attacker terrain
static int getConsciousnessNumber(int hit)
          Returns the consciousness roll number
static ToHitData getDamageWeaponMods(Entity attacker, Mounted weapon)
          Adds any damage modifiers from arm critical hits or sensor damage.
static double getECCMFieldSize(Entity ae, Coords a, Coords b)
          This method returns the highest number of enemy ECCM fields of ae between points a and b
static double getECMFieldSize(Entity ae, Coords a, Coords b)
          This method returns the highest number of enemy ECM fields of ae between points a and b
static Coords getFinalPosition(Coords curpos, int[] v)
          STUFF FOR VECTOR MOVEMENT CALCULATIONS
static int getGhostTargetNumber(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. -1 if no Ghost Targets
static WeaponAttackAction getHighestExpectedDamage(IGame g, java.util.Vector<WeaponAttackAction> vAttacks, boolean assumeHit)
          Returns the weapon attack out of a list that has the highest expected damage
static ToHitData getImmobileMod(Targetable target)
           
static ToHitData getImmobileMod(Targetable target, int aimingAt, int aimingMode)
           
static ToHitData getInfantryRangeMods(int distance, InfantryWeapon wpn)
           
static int getLargeCraftECM(Entity ae, Coords a, Coords b)
          Check for the total number of fighter/small craft ECM bubbles in space along the path from a to b
static ToHitData getLegAttackBaseToHit(Entity attacker, Entity defender, IGame game)
          Get the base to-hit number of a Leg Attack by the given attacker upon the given defender
static Coords getMissedChargeDisplacement(IGame game, int entityId, Coords src, int direction)
          Gets a hex to displace a missed charge to.
static int getNetVelocity(Coords src, Aero te, int avel, int tvel)
          Get the net velocity of two aeros for ramming attacks
static Coords getPreferredDisplacement(IGame game, int entityId, Coords src, int direction)
          Gets a preferred displacement.
static ToHitData getProneMods(IGame game, Entity attacker, int weaponId)
          Gets the modifiers, if any, that the mech receives from being prone.
static int[] getRandomSkills(int method, int type, int level, boolean isVee)
           
static ToHitData getRangeMods(IGame game, Entity ae, int weaponId, Targetable target)
          Determines the to-hit modifier due to range for an attack with the specified parameters.
static ToHitData getSecondaryTargetMod(IGame game, Entity attacker, Targetable target)
          Determines if the current target is a secondary target, and if so, returns the appropriate modifier.
static ToHitData getSecondaryTargetMod(IGame game, Entity attacker, Targetable target, boolean isSwarm)
           
static int getSensorBracket(int check)
          returns the brackets for sensor checks
static int getSmallCraftECM(Entity ae, Coords a, Coords b)
          Check for the total number of fighter/small craft ECM bubbles in space along the path from a to b
static ToHitData getSpaceBombBaseToHit(Entity attacker, Entity defender, IGame game)
          Get the base to-hit number of a space bomb attack by the given attacker upon the given defender
static ToHitData getSpotterMovementModifier(IGame game, int entityId)
          Modifier to attacks due to spotter movement
static ToHitData getSpotterMovementModifier(IGame game, int entityId, EntityMovementType movement)
          Modifier to attacks due to spotter movement
static ToHitData getSwarmMekBaseToHit(Entity attacker, Entity defender, IGame game)
          Get the base to-hit number of a Swarm Mek by the given attacker upon the given defender.
static Entity getSwarmMissileTarget(IGame game, int aeId, Entity te, int weaponId)
          Gets a new target for a flight of swarm missiles that was just shot at an entity and has missiles left
static ToHitData getTargetMovementModifier(IGame game, int entityId)
          Modifier to attacks due to target movement
static ToHitData getTargetMovementModifier(int distance, boolean jumped, boolean isVTOL)
          Target movement modifer for the specified delta_distance
static ToHitData getTargetTerrainModifier(IGame game, Targetable t)
          Modifier to attacks due to target terrain TODO:um....should VTOLs get modifiers for smoke, etc.
static ToHitData getTargetTerrainModifier(IGame game, Targetable t, int eistatus)
           
static ToHitData getTargetTerrainModifier(IGame game, Targetable t, int eistatus, boolean attackerInSameBuilding)
           
static Coords getValidDisplacement(IGame 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 boolean inDeadZone(IGame game, Entity ae, Targetable target)
           
static boolean inSensorRange(IGame game, Entity ae, Targetable target)
          Checks to see whether the target is within sensor range (but not necessarily LoS or visual range)
static boolean inVisualRange(IGame game, Entity ae, Targetable target)
          checks to see whether the target is within visual range of the entity, but not necessarily LoS
static boolean isAffectedByAngelECM(Entity ae, Coords a, Coords b)
          This method checks to see if a line from a to b is affected by an Angel ECM field of the enemy of ae
static boolean isAffectedByECCM(Entity ae, Coords a, Coords b)
          This method checks to see if a line from a to b is affected by an ECCM field of the enemy of ae
static boolean isAffectedByECM(Entity ae, Coords a, Coords b)
          This method checks to see if a line from a to b is affected by an ECM field of the enemy of ae
static boolean isAirToAir(Entity attacker, Targetable target)
           
static boolean isAirToGround(Entity attacker, Targetable target)
           
static boolean isEnemyIn(IGame game, Entity entity, Coords coords, boolean onlyMechs, boolean ignoreInfantry, int enLowEl)
          Returns true if there is any unit that is an enemy of the specified unit in the specified hex.
static boolean isGroundToAir(Entity attacker, Targetable target)
           
static boolean isGroundToGround(Entity attacker, Targetable target)
           
static boolean isInArc(Coords src, int facing, Coords dest, int arc)
          Returns true if the target is in the specified arc.
static boolean isInArc(IGame game, int attackerId, int weaponId, Targetable t)
          Checks to see if a target is in arc of the specified weapon, on the specified entity
static boolean isInBuilding(IGame game, Entity entity)
          Determine if the given unit is inside of a building at the given coordinates.
static boolean isInBuilding(IGame game, Entity entity, Coords coords)
          Determine if the given unit is inside of a building at the given coordinates.
(package private) static boolean isInBuilding(IGame game, int entityElev, Coords coords)
           
static boolean isInSameBuilding(IGame game, Entity attacker, Targetable target)
          Determines whether the attacker and the target are in the same building.
static boolean isPilotingSkillNeeded(IGame game, int entityId, Coords src, Coords dest, EntityMovementType movementType, boolean isTurning, boolean prevStepIsOnPavement, int srcElevation, int destElevation, MovePath path)
           
static boolean isThroughFrontHex(IGame game, Coords src, Entity t)
          Returns true if the line between source Coords and target goes through the hex in front of the attacker
static boolean isValidDisplacement(IGame game, int entityId, Coords src, Coords dest)
          Can the defending unit be displaced from the source to the destination?
static boolean isValidDisplacement(IGame game, int entityId, Coords src, int direction)
          Can the defending unit be displaced from the source to the destination?
static int missilesHit(int missiles)
          Maintain backwards compatability.
static int missilesHit(int missiles, int nMod)
          Maintain backwards compatability.
static int missilesHit(int missiles, int nMod, boolean hotloaded)
          Maintain backwards compatability.
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.
static void modifyPhysicalBTHForAdvantages(Entity attacker, Entity target, ToHitData toHit, IGame game)
          Modifier to physical attack BTH due to pilot advantages
static double oddsAbove(int n)
          Returns the odds that a certain number or above will be rolled on 2d6.
static int randomInt(int maxValue)
          Wrapper to random#randomInt(n)
static int roundsUntilReturn(IGame game, Entity en)
          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
static boolean sameVectors(int[] v1, int[] v2)
          compare two vectors and determine if they are the same
static Coords scatter(Coords coords, int margin)
          scatter from a hex according, roll d6 to choose scatter direction
static Coords scatterAssaultDrop(Coords coords, int margin)
          scatter from hex according to atmospheric drop rules d6 for direction, 1d6 per point of MOF
static Coords scatterDirectArty(Coords coords)
          scatter from hex according to direct fire artillery rules (1d6 of scatter distance)
static Coords scatterDiveBombs(Coords coords)
          scatter from hex according to dive bombing rules (1d6 of scatter distance)
static void setRNG(int type)
          Sets the RNG to the desired type
static int spinUpCannon(IGame cgame, WeaponAttackAction atk)
          If this is an ultra or rotary cannon, lets see about 'spinning it up' for extra damage
static Entity stackingViolation(IGame game, Entity entering, Coords coords, Entity transport)
          When compiling an unloading step, both the transporter and the unloaded unit probably occupy some other position on the board.
static Entity stackingViolation(IGame game, int enteringId, Coords coords)
          Returns an entity if the specified entity would cause a stacking violation entering a hex, or returns null if it would not.
static int targetSideTable(Coords inPosition, Targetable target)
           
static int targetSideTable(Entity attacker, Targetable target)
           
static int targetSideTable(Entity attacker, Targetable target, int called)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARC_360

public static final int ARC_360
See Also:
Constant Field Values

ARC_FORWARD

public static final int ARC_FORWARD
See Also:
Constant Field Values

ARC_LEFTARM

public static final int ARC_LEFTARM
See Also:
Constant Field Values

ARC_RIGHTARM

public static final int ARC_RIGHTARM
See Also:
Constant Field Values

ARC_REAR

public static final int ARC_REAR
See Also:
Constant Field Values

ARC_LEFTSIDE

public static final int ARC_LEFTSIDE
See Also:
Constant Field Values

ARC_RIGHTSIDE

public static final int ARC_RIGHTSIDE
See Also:
Constant Field Values

ARC_MAINGUN

public static final int ARC_MAINGUN
See Also:
Constant Field Values

ARC_NORTH

public static final int ARC_NORTH
See Also:
Constant Field Values

ARC_EAST

public static final int ARC_EAST
See Also:
Constant Field Values

ARC_WEST

public static final int ARC_WEST
See Also:
Constant Field Values

ARC_NOSE

public static final int ARC_NOSE
See Also:
Constant Field Values

ARC_LWING

public static final int ARC_LWING
See Also:
Constant Field Values

ARC_RWING

public static final int ARC_RWING
See Also:
Constant Field Values

ARC_LWINGA

public static final int ARC_LWINGA
See Also:
Constant Field Values

ARC_RWINGA

public static final int ARC_RWINGA
See Also:
Constant Field Values

ARC_LEFTSIDE_SPHERE

public static final int ARC_LEFTSIDE_SPHERE
See Also:
Constant Field Values

ARC_RIGHTSIDE_SPHERE

public static final int ARC_RIGHTSIDE_SPHERE
See Also:
Constant Field Values

ARC_LEFTSIDEA_SPHERE

public static final int ARC_LEFTSIDEA_SPHERE
See Also:
Constant Field Values

ARC_RIGHTSIDEA_SPHERE

public static final int ARC_RIGHTSIDEA_SPHERE
See Also:
Constant Field Values

ARC_LEFT_BROADSIDE

public static final int ARC_LEFT_BROADSIDE
See Also:
Constant Field Values

ARC_RIGHT_BROADSIDE

public static final int ARC_RIGHT_BROADSIDE
See Also:
Constant Field Values

ARC_AFT

public static final int ARC_AFT
See Also:
Constant Field Values

ARC_LEFT_SPHERE_GROUND

public static final int ARC_LEFT_SPHERE_GROUND
See Also:
Constant Field Values

ARC_RIGHT_SPHERE_GROUND

public static final int ARC_RIGHT_SPHERE_GROUND
See Also:
Constant Field Values

ARC_TURRET

public static final int ARC_TURRET
See Also:
Constant Field Values

TYPE_IS

public static final int TYPE_IS
See Also:
Constant Field Values

TYPE_CLAN

public static final int TYPE_CLAN
See Also:
Constant Field Values

TYPE_MD

public static final int TYPE_MD
See Also:
Constant Field Values

LEVEL_GREEN

public static final int LEVEL_GREEN
See Also:
Constant Field Values

LEVEL_REGULAR

public static final int LEVEL_REGULAR
See Also:
Constant Field Values

LEVEL_VETERAN

public static final int LEVEL_VETERAN
See Also:
Constant Field Values

LEVEL_ELITE

public static final int LEVEL_ELITE
See Also:
Constant Field Values

METHOD_TW

public static final int METHOD_TW
See Also:
Constant Field Values

METHOD_TAHARQA

public static final int METHOD_TAHARQA
See Also:
Constant Field Values

METHOD_CONSTANT

public static final int METHOD_CONSTANT
See Also:
Constant Field Values

WEAPON_DIRECT_FIRE

public static final int WEAPON_DIRECT_FIRE
See Also:
Constant Field Values

WEAPON_CLUSTER_BALLISTIC

public static final int WEAPON_CLUSTER_BALLISTIC
See Also:
Constant Field Values

WEAPON_PULSE

public static final int WEAPON_PULSE
See Also:
Constant Field Values

WEAPON_CLUSTER_MISSILE

public static final int WEAPON_CLUSTER_MISSILE
See Also:
Constant Field Values

WEAPON_CLUSTER_MISSILE_1D6

public static final int WEAPON_CLUSTER_MISSILE_1D6
See Also:
Constant Field Values

WEAPON_CLUSTER_MISSILE_2D6

public static final int WEAPON_CLUSTER_MISSILE_2D6
See Also:
Constant Field Values

WEAPON_CLUSTER_MISSILE_3D6

public static final int WEAPON_CLUSTER_MISSILE_3D6
See Also:
Constant Field Values
Constructor Detail

Compute

public Compute()
Method Detail

d6

public static int d6(int dice)
Wrapper to random#d6(n)


d6

public static int d6()
Wrapper to random#d6()


randomInt

public static int randomInt(int maxValue)
Wrapper to random#randomInt(n)


setRNG

public static void setRNG(int type)
Sets the RNG to the desired type


oddsAbove

public static double oddsAbove(int n)
Returns the odds that a certain number or above will be rolled on 2d6.


stackingViolation

public static Entity stackingViolation(IGame game,
                                       int enteringId,
                                       Coords coords)
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.


stackingViolation

public static Entity stackingViolation(IGame game,
                                       Entity entering,
                                       Coords coords,
                                       Entity transport)
When compiling an unloading step, both the transporter and the unloaded unit probably occupy some other position on the board.


isEnemyIn

public static boolean isEnemyIn(IGame game,
                                Entity entity,
                                Coords coords,
                                boolean onlyMechs,
                                boolean ignoreInfantry,
                                int enLowEl)
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 currenly making a DFA.


isPilotingSkillNeeded

public static boolean isPilotingSkillNeeded(IGame game,
                                            int entityId,
                                            Coords src,
                                            Coords dest,
                                            EntityMovementType movementType,
                                            boolean isTurning,
                                            boolean prevStepIsOnPavement,
                                            int srcElevation,
                                            int destElevation,
                                            MovePath path)
Returns:
true if a piloting skill roll is needed to traverse the terrain

isValidDisplacement

public static boolean isValidDisplacement(IGame game,
                                          int entityId,
                                          Coords src,
                                          int direction)
Can the defending unit be displaced from the source to the destination?


isValidDisplacement

public static boolean isValidDisplacement(IGame game,
                                          int entityId,
                                          Coords src,
                                          Coords dest)
Can the defending unit be displaced from the source to the destination?


getValidDisplacement

public static Coords getValidDisplacement(IGame 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.

Returns:
valid displacement coords, or null if none

getPreferredDisplacement

public static Coords getPreferredDisplacement(IGame game,
                                              int entityId,
                                              Coords src,
                                              int direction)
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(IGame 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

public static Entity findSpotter(IGame game,
                                 Entity attacker,
                                 Targetable target)
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.


getImmobileMod

public static ToHitData getImmobileMod(Targetable target)

getImmobileMod

public static ToHitData getImmobileMod(Targetable target,
                                       int aimingAt,
                                       int aimingMode)

getRangeMods

public static ToHitData getRangeMods(IGame game,
                                     Entity ae,
                                     int weaponId,
                                     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

getInfantryRangeMods

public static ToHitData getInfantryRangeMods(int distance,
                                             InfantryWeapon wpn)

effectiveDistance

public static int effectiveDistance(IGame game,
                                    Entity attacker,
                                    Targetable target)
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

effectiveDistance

public static int effectiveDistance(IGame game,
                                    Entity attacker,
                                    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

getProneMods

public static ToHitData getProneMods(IGame game,
                                     Entity attacker,
                                     int weaponId)
Gets the modifiers, if any, that the mech receives from being prone.

Returns:
any applicable modifiers due to being prone

getDamageWeaponMods

public static ToHitData getDamageWeaponMods(Entity attacker,
                                            Mounted weapon)
Adds any damage modifiers from arm critical hits or sensor damage.

Returns:
Any applicable damage modifiers

getSecondaryTargetMod

public static ToHitData getSecondaryTargetMod(IGame game,
                                              Entity attacker,
                                              Targetable target)
Determines if the current target is a secondary target, and if so, returns the appropriate modifier.

Returns:
The secondary target modifier.

getSecondaryTargetMod

public static ToHitData getSecondaryTargetMod(IGame game,
                                              Entity attacker,
                                              Targetable target,
                                              boolean isSwarm)

getAffaDamageFor

public static int getAffaDamageFor(Entity entity)
Damage that a mech does with a accidental fall from above.


getAttackerMovementModifier

public static ToHitData getAttackerMovementModifier(IGame game,
                                                    int entityId)
Modifier to attacks due to attacker movement


getAttackerMovementModifier

public static ToHitData getAttackerMovementModifier(IGame game,
                                                    int entityId,
                                                    EntityMovementType movement)
Modifier to attacks due to attacker movement


getSpotterMovementModifier

public static ToHitData getSpotterMovementModifier(IGame game,
                                                   int entityId)
Modifier to attacks due to spotter movement


getSpotterMovementModifier

public static ToHitData getSpotterMovementModifier(IGame game,
                                                   int entityId,
                                                   EntityMovementType movement)
Modifier to attacks due to spotter movement


modifyPhysicalBTHForAdvantages

public static void modifyPhysicalBTHForAdvantages(Entity attacker,
                                                  Entity target,
                                                  ToHitData toHit,
                                                  IGame game)
Modifier to physical attack BTH due to pilot advantages


getTargetMovementModifier

public static ToHitData getTargetMovementModifier(IGame game,
                                                  int entityId)
Modifier to attacks due to target movement


getTargetMovementModifier

public static ToHitData getTargetMovementModifier(int distance,
                                                  boolean jumped,
                                                  boolean isVTOL)
Target movement modifer for the specified delta_distance


getAttackerTerrainModifier

public static ToHitData getAttackerTerrainModifier(IGame game,
                                                   int entityId)
Modifier to attacks due to attacker terrain


getTargetTerrainModifier

public static ToHitData getTargetTerrainModifier(IGame game,
                                                 Targetable t)
Modifier to attacks due to target terrain TODO:um....should VTOLs get modifiers for smoke, etc.


getTargetTerrainModifier

public static ToHitData getTargetTerrainModifier(IGame game,
                                                 Targetable t,
                                                 int eistatus)

getTargetTerrainModifier

public static ToHitData getTargetTerrainModifier(IGame game,
                                                 Targetable t,
                                                 int eistatus,
                                                 boolean attackerInSameBuilding)

getHighestExpectedDamage

public static WeaponAttackAction getHighestExpectedDamage(IGame g,
                                                          java.util.Vector<WeaponAttackAction> vAttacks,
                                                          boolean assumeHit)
Returns the weapon attack out of a list that has the highest expected damage


getAmmoAdjDamage

public static double getAmmoAdjDamage(IGame cgame,
                                      WeaponAttackAction atk)
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

public static int spinUpCannon(IGame cgame,
                               WeaponAttackAction atk)
If this is an ultra or rotary cannon, lets see about 'spinning it up' for extra damage

Returns:
the int ID of weapon mode

isInArc

public static boolean isInArc(IGame game,
                              int attackerId,
                              int weaponId,
                              Targetable t)
Checks to see if a target is in arc of the specified weapon, on the specified entity


isThroughFrontHex

public static boolean isThroughFrontHex(IGame game,
                                        Coords src,
                                        Entity t)
Returns true if the line between source Coords and target goes through the hex in front of the attacker


isInArc

public static boolean isInArc(Coords src,
                              int facing,
                              Coords dest,
                              int arc)
Returns true if the target is in the specified arc.

Parameters:
src - the attacker coordinate
facing - the appropriate attacker sfacing
dest - the target coordinate
arc - the arc

inVisualRange

public static boolean inVisualRange(IGame game,
                                    Entity ae,
                                    Targetable target)
checks to see whether the target is within visual range of the entity, but not necessarily LoS


inSensorRange

public static boolean inSensorRange(IGame game,
                                    Entity ae,
                                    Targetable target)
Checks to see whether the target is within sensor range (but not necessarily LoS or visual range)


canSee

public static boolean canSee(IGame game,
                             Entity ae,
                             Targetable target)
Slightly misnamed. Checks to see if the target is visible to the unit, either visually or through sensors


getSensorBracket

public static int getSensorBracket(int check)
returns the brackets for sensor checks


targetSideTable

public static int targetSideTable(Coords inPosition,
                                  Targetable target)

targetSideTable

public static int targetSideTable(Entity attacker,
                                  Targetable target)

targetSideTable

public static int targetSideTable(Entity attacker,
                                  Targetable target,
                                  int called)

missilesHit

public static int missilesHit(int missiles)
Maintain backwards compatability.

Parameters:
missiles - - the int number of missiles in the pack.

missilesHit

public static int missilesHit(int missiles,
                              int nMod)
Maintain backwards compatability.

Parameters:
missiles -
nMod -
Returns:

missilesHit

public static int missilesHit(int missiles,
                              int nMod,
                              boolean hotloaded)
Maintain backwards compatability.

Parameters:
missiles -
nMod -
hotloaded -
Returns:

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 - - the int number of missiles in the pack.
nMod - - the int modifier to the roll for number of missiles that hit.
hotloaded - - roll 3d6 take worst 2
streak - - force a roll of 11 on the cluster table
advancedAMS - - the roll can now go below 2, indicating no damage

calculateClusterHitTableAmount

public static int calculateClusterHitTableAmount(int roll,
                                                 int rackSize)

getConsciousnessNumber

public static int getConsciousnessNumber(int hit)
Returns the consciousness roll number

Parameters:
hit - - the int number of the crew hit currently being rolled.
Returns:
The int number that must be rolled on 2d6 for the crew to stay conscious.

isAffectedByECM

public static boolean isAffectedByECM(Entity ae,
                                      Coords a,
                                      Coords b)
This method checks to see if a line from a to b is affected by an ECM field of the enemy of ae

Parameters:
ae -
a -
b -
Returns:

isAffectedByECCM

public static boolean isAffectedByECCM(Entity ae,
                                       Coords a,
                                       Coords b)
This method checks to see if a line from a to b is affected by an ECCM field of the enemy of ae

Parameters:
ae -
a -
b -
Returns:

getECMFieldSize

public static double getECMFieldSize(Entity ae,
                                     Coords a,
                                     Coords b)
This method returns the highest number of enemy ECM fields of ae between points a and b

Parameters:
ae -
a -
b -
Returns:

getECCMFieldSize

public static double getECCMFieldSize(Entity ae,
                                      Coords a,
                                      Coords b)
This method returns the highest number of enemy ECCM fields of ae between points a and b

Parameters:
ae -
a -
b -
Returns:

isAffectedByAngelECM

public static boolean isAffectedByAngelECM(Entity ae,
                                           Coords a,
                                           Coords b)
This method checks to see if a line from a to b is affected by an Angel ECM field of the enemy of ae

Parameters:
ae -
a -
b -
Returns:
count that shows if you are in an friendly ECCM field positive number means you are in an friendly ECCM field Negative number means you are in a enemy ECM field 0 means you are not effect by enemy or friendly fields.

getAngelECMFieldSize

public static double getAngelECMFieldSize(Entity ae,
                                          Coords a,
                                          Coords b)

getGhostTargetNumber

public static int getGhostTargetNumber(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. -1 if no Ghost Targets


getSmallCraftECM

public static int getSmallCraftECM(Entity ae,
                                   Coords a,
                                   Coords b)
Check for the total number of fighter/small craft ECM bubbles in space along the path from a to b


getLargeCraftECM

public static int getLargeCraftECM(Entity ae,
                                   Coords a,
                                   Coords b)
Check for the total number of fighter/small craft ECM bubbles in space along the path from a to b


getSpaceBombBaseToHit

public static ToHitData getSpaceBombBaseToHit(Entity attacker,
                                              Entity defender,
                                              IGame game)
Get the base to-hit number of a space bomb attack by the given attacker upon the given defender

Parameters:
attacker - - the Entity conducting the leg attack.
defender - - the Entity being attacked.
Returns:
The base ToHitData of the attack.

getLegAttackBaseToHit

public static ToHitData getLegAttackBaseToHit(Entity attacker,
                                              Entity defender,
                                              IGame game)
Get the base to-hit number of a Leg Attack by the given attacker upon the given defender

Parameters:
attacker - - the Entity conducting the leg attack.
defender - - the Entity being attacked.
Returns:
The base ToHitData of the attack.

getSwarmMekBaseToHit

public static ToHitData getSwarmMekBaseToHit(Entity attacker,
                                             Entity defender,
                                             IGame game)
Get the base to-hit number of a Swarm Mek by the given attacker upon the given defender.

Parameters:
attacker - - the Entity swarming.
defender - - the Entity being swarmed.
Returns:
The base ToHitData of the mek.

canPhysicalTarget

public static boolean canPhysicalTarget(IGame game,
                                        int entityId,
                                        Targetable target)

canMoveOnPavement

public static boolean canMoveOnPavement(IGame game,
                                        Coords src,
                                        Coords dest,
                                        MovePath movePath)
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.

Parameters:
game - - the IGame object.
src - - the Coords being left.
dest - - the Coords being entered.
entity - - the Entity that is moving
Returns:
true if movement between src and dest can be on pavement; false otherwise.

isInSameBuilding

public static boolean isInSameBuilding(IGame game,
                                       Entity attacker,
                                       Targetable target)
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

public static boolean isInBuilding(IGame game,
                                   Entity entity)
Determine if the given unit is inside of a building at the given coordinates.

Parameters:
game - - the IGame object. This value may be null.
entity - - the Entity to be checked. This value may be null.
Returns:
true if the entity is inside of the building at those coordinates. false if 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 is null .

isInBuilding

public static boolean isInBuilding(IGame game,
                                   Entity entity,
                                   Coords coords)
Determine if the given unit is inside of a building at the given coordinates.

Parameters:
game - - the IGame object. This value may be null.
entity - - the Entity to be checked. This value may be null.
coords - - the Coords of the building hex. This value may be null.
Returns:
true if the entity is inside of the building at those coordinates. false if 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 is null .

isInBuilding

static boolean isInBuilding(IGame game,
                            int entityElev,
                            Coords coords)

scatterDiveBombs

public static Coords scatterDiveBombs(Coords coords)
scatter from hex according to dive bombing rules (1d6 of scatter distance)

Parameters:
coords - The Coords to scatter from
Returns:
the Coords scattered to

scatterDirectArty

public static Coords scatterDirectArty(Coords coords)
scatter from hex according to direct fire artillery rules (1d6 of scatter distance)

Parameters:
coords - The Coords to scatter from
Returns:
the Coords scattered to

scatter

public static Coords scatter(Coords coords,
                             int margin)
scatter from a hex according, roll d6 to choose scatter direction

Parameters:
coords - The Coords to scatter from
margin - the int margin of failure, scatter distance will be the margin of failure
Returns:
the Coords scattered to

scatterAssaultDrop

public static Coords scatterAssaultDrop(Coords coords,
                                        int margin)
scatter from hex according to atmospheric drop rules d6 for direction, 1d6 per point of MOF

Parameters:
coords - The Coords to scatter from
margin - the int margin of failure
Returns:
the Coords scattered to

coordsAtRange

public static java.util.ArrayList<Coords> coordsAtRange(Coords centre,
                                                        int range)
Gets a ring of hexes at a specified distance from the centre

Parameters:
centre - The centre point of the ring
range - The radius of the ring

getSwarmMissileTarget

public static Entity getSwarmMissileTarget(IGame game,
                                           int aeId,
                                           Entity te,
                                           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 -
aeId - The attacking Entity
te - The Entity that was shot at.
weaponId - The int ID of the launcher used to fire this volley
Returns:
the new target Entity. May return null if no new target available

getRandomSkills

public static int[] getRandomSkills(int method,
                                    int type,
                                    int level,
                                    boolean isVee)

getFinalPosition

public static Coords getFinalPosition(Coords curpos,
                                      int[] v)
STUFF FOR VECTOR MOVEMENT CALCULATIONS


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

Parameters:
v -
facing -
Returns:

sameVectors

public static boolean sameVectors(int[] v1,
                                  int[] v2)
compare two vectors and determine if they are the same

Parameters:
v1 -
v2 -
Returns:

getNetVelocity

public static int getNetVelocity(Coords src,
                                 Aero te,
                                 int avel,
                                 int tvel)
Get the net velocity of two aeros for ramming attacks


directBlowInfantryDamage

public static int directBlowInfantryDamage(double damage,
                                           int mos,
                                           int damageType,
                                           boolean isNonInfantryAgainstMechanized)
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

Parameters:
damage -
mos -
damageType -
Returns:

dialDownDamage

public static int dialDownDamage(Mounted weapon,
                                 WeaponType wtype)
Method computes how much damage a dial down weapon has done

Parameters:
weapon -
wtype -

dialDownDamage

public static int dialDownDamage(Mounted weapon,
                                 WeaponType wtype,
                                 int range)
Method computes how much damage a dial down weapon has done

Parameters:
weapon -
wtype -
range -
Returns:
new damage

dialDownHeat

public static int dialDownHeat(Mounted weapon,
                               WeaponType wtype)
Method computes how much heat a dial down weapon generates

Parameters:
weapon -
wtype -
Returns:
Heat, minimum of 1;

dialDownHeat

public static int dialDownHeat(Mounted weapon,
                               WeaponType wtype,
                               int range)
Method computes how much heat a dial down weapon generates

Parameters:
weapon -
wtype -
range -
Returns:
Heat, minimum of 1;

getAdjacentEntitiesAlongAttack

public static java.util.ArrayList<Entity> getAdjacentEntitiesAlongAttack(Coords aPos,
                                                                         Coords tPos,
                                                                         IGame game)
Parameters:
ae - - attacking entity
te - - targeted entity
Returns:
a vector of all the entities that are adjacent to the targeted entity and would fall along the angle of attack

isAirToGround

public static boolean isAirToGround(Entity attacker,
                                    Targetable target)

isAirToAir

public static boolean isAirToAir(Entity attacker,
                                 Targetable target)

isGroundToAir

public static boolean isGroundToAir(Entity attacker,
                                    Targetable target)

isGroundToGround

public static boolean isGroundToGround(Entity attacker,
                                       Targetable target)

roundsUntilReturn

public static int roundsUntilReturn(IGame game,
                                    Entity en)
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

Parameters:
en -
velocity -
Returns:
number of rounds until return (-1 if never)

inDeadZone

public static boolean inDeadZone(IGame game,
                                 Entity ae,
                                 Targetable target)