📄 compute.java
字号:
toHit.addModifier(1, "spotter walked"); } else if (movement == IEntityMovementType.MOVE_RUN || movement == IEntityMovementType.MOVE_VTOL_RUN || movement == IEntityMovementType.MOVE_SKID) { toHit.addModifier(2, "spotter ran"); } else if (movement == IEntityMovementType.MOVE_JUMP) { toHit.addModifier(3, "spotter jumped"); } return toHit; } /** * Modifier to physical attack BTH due to pilot advantages */ public static void modifyPhysicalBTHForAdvantages(Entity attacker, Entity target, ToHitData toHit, IGame game) { if (attacker.getCrew().getOptions().booleanOption("melee_specialist") && attacker instanceof Mech && getAttackerMovementModifier(game, attacker.getId()).getValue() > 0) { toHit.addModifier(-1, "melee specialist"); } // Mek targets that are dodging are harder to hit. if (target != null && target instanceof Mech && target.getCrew().getOptions() .booleanOption("dodge_maneuver") && (target.dodging )) { toHit.addModifier(2, "target is dodging"); } } /** * Modifier to attacks due to target movement */ public static ToHitData getTargetMovementModifier(IGame game, int entityId) { Entity entity = game.getEntity(entityId); ToHitData toHit = getTargetMovementModifier( entity.delta_distance, ((entity.moved == IEntityMovementType.MOVE_JUMP) || (entity.moved == IEntityMovementType.MOVE_VTOL_RUN) || (entity.moved == IEntityMovementType.MOVE_VTOL_WALK)), game.getOptions().booleanOption("maxtech_target_modifiers"), entity.moved == IEntityMovementType.MOVE_VTOL_RUN || entity.moved == IEntityMovementType.MOVE_VTOL_WALK || entity.getMovementMode() == IEntityMovementMode.VTOL); // Did the target skid this turn? if (entity.moved == IEntityMovementType.MOVE_SKID) { toHit.addModifier(2, "target skidded"); } return toHit; } /** * Target movement modifer for the specified delta_distance */ public static ToHitData getTargetMovementModifier(int distance, boolean jumped, boolean maxtech, boolean isVTOL) { ToHitData toHit = new ToHitData(); if (!maxtech) { if (distance >= 3 && distance <= 4) { toHit.addModifier(1, "target moved 3-4 hexes"); } else if (distance >= 5 && distance <= 6) { toHit.addModifier(2, "target moved 5-6 hexes"); } else if (distance >= 7 && distance <= 9) { toHit.addModifier(3, "target moved 7-9 hexes"); } else if (distance >= 10) { toHit.addModifier(4, "target moved 10+ hexes"); } } else { if (distance >= 3 && distance <= 4) { toHit.addModifier(1, "target moved 3-4 hexes"); } else if (distance >= 5 && distance <= 6) { toHit.addModifier(2, "target moved 5-6 hexes"); } else if (distance >= 7 && distance <= 9) { toHit.addModifier(3, "target moved 7-9 hexes"); } else if (distance >= 10 && distance <= 13) { toHit.addModifier(4, "target moved 10-13 hexes"); } else if (distance >= 14 && distance <= 18) { toHit.addModifier(5, "target moved 14-18 hexes"); } else if (distance >= 19 && distance <= 24) { toHit.addModifier(6, "target moved 19-24 hexes"); } else if (distance >= 25) { toHit.addModifier(7, "target moved 25+ hexes"); } } if (jumped) { if (isVTOL) { toHit.addModifier(1, "target VTOL used MPs"); } else toHit.addModifier(1, "target jumped"); } return toHit; } /** * Modifier to attacks due to attacker terrain */ public static ToHitData getAttackerTerrainModifier(IGame game, int entityId) { final Entity attacker = game.getEntity(entityId); final IHex hex = game.getBoard().getHex(attacker.getPosition()); ToHitData toHit = new ToHitData(); // Only BattleMechs in water get the terrain penalty for firing! if (hex.terrainLevel(Terrains.WATER) > 0 && attacker.getElevation() < 0 && (attacker instanceof Mech)) { toHit.addModifier(1, "attacker in water"); } return toHit; } /** * Modifier to attacks due to target terrain TODO:um....should VTOLs get * modifiers for smoke, etc. */ public static ToHitData getTargetTerrainModifier(IGame game, Targetable t) { return getTargetTerrainModifier(game, t, 0); } public static ToHitData getTargetTerrainModifier(IGame game, Targetable t, int eistatus) { Entity entityTarget = null; IHex hex = game.getBoard().getHex(t.getPosition()); if (t.getTargetType() == Targetable.TYPE_ENTITY) { entityTarget = (Entity) t; if (hex == null) { entityTarget.setPosition(game.getEntity(entityTarget.getId()) .getPosition()); hex = game.getBoard().getHex( game.getEntity(entityTarget.getId()).getPosition()); } } boolean isVTOL = ((entityTarget != null) && (hex != null)) && (entityTarget.absHeight() >= 2); ToHitData toHit = new ToHitData(); // Smoke and woods. With L3, the effects STACK. int woodsLevel = hex.terrainLevel(Terrains.WOODS); int jungleLevel = hex.terrainLevel(Terrains.JUNGLE); String woodsText = "woods"; if(woodsLevel < jungleLevel) { woodsLevel = jungleLevel; woodsText = "jungle"; } if(woodsLevel == 1) { woodsText = "target in light " + woodsText; } else if (woodsLevel == 2) { woodsText = "target in heavy " + woodsText; } else if (woodsLevel == 3) { woodsText = "target in ultra heavy " + woodsText; } if (!game.getOptions().booleanOption("maxtech_fire")) { // L2 if (hex.containsTerrain(Terrains.SMOKE)) { if (eistatus > 0) { toHit.addModifier(1, "target in smoke"); } else { toHit.addModifier(2, "target in smoke"); } } else if (hex.terrainLevel(Terrains.GEYSER) == 2) { if (eistatus > 0) { toHit.addModifier(1, "target in erupting geyser"); } else { toHit.addModifier(2, "target in erupting geyser"); } } else { if (!isVTOL && !(t.getTargetType() == Targetable.TYPE_HEX_CLEAR || t.getTargetType() == Targetable.TYPE_HEX_IGNITE || t.getTargetType() == Targetable.TYPE_HEX_BOMB || t.getTargetType() == Targetable.TYPE_HEX_ARTILLERY || t.getTargetType() == Targetable.TYPE_MINEFIELD_DELIVER)) { if (woodsLevel == 1 && eistatus != 2) { toHit.addModifier(1, woodsText); } else if (woodsLevel > 1) { if (eistatus > 0) { toHit.addModifier(woodsLevel - 1, woodsText); } else { toHit.addModifier(woodsLevel, woodsText); } } } } } else { // L3 if (hex.terrainLevel(Terrains.SMOKE) == 1) { toHit.addModifier(1, "target in light smoke"); } else if (hex.terrainLevel(Terrains.SMOKE) > 1) { if (eistatus > 0) { toHit.addModifier(1, "target in heavy smoke"); } else { toHit.addModifier(2, "target in heavy smoke"); } } if (hex.terrainLevel(Terrains.GEYSER) == 2) { if (eistatus > 0) { toHit.addModifier(1, "target in erupting geyser"); } else { toHit.addModifier(2, "target in erupting geyser"); } } if (!isVTOL && !(t.getTargetType() == Targetable.TYPE_HEX_CLEAR || t.getTargetType() == Targetable.TYPE_HEX_IGNITE || t.getTargetType() == Targetable.TYPE_HEX_BOMB || t.getTargetType() == Targetable.TYPE_HEX_ARTILLERY || t.getTargetType() == Targetable.TYPE_MINEFIELD_DELIVER)) { if (woodsLevel == 1 && eistatus != 2) { toHit.addModifier(1, woodsText); } else if (woodsLevel > 1) { if (eistatus > 0) { toHit.addModifier(woodsLevel - 1, woodsText); } else { toHit.addModifier(woodsLevel, woodsText); } } } } // only entities get remaining terrain bonuses // TODO: should this be changed for buildings??? if (entityTarget == null) { return toHit; } else if (entityTarget.isMakingDfa()) { // you don't get terrain modifiers in midair // should be abstracted more into a 'not on the ground' // flag for vtols and such return toHit; } // -1 bonus only against BattleMechs in water! if (hex.terrainLevel(Terrains.WATER) > 0 && entityTarget.getElevation() < 0 && (entityTarget instanceof Mech)) { toHit.addModifier(-1, "target in water"); } if (entityTarget.isStuck()) { toHit.addModifier(-2, "target stuck in swamp"); } return toHit; } /** * Returns the weapon attack out of a list that has the highest expected * damage */ public static WeaponAttackAction getHighestExpectedDamage(IGame g, Vector vAttacks) { float fHighest = -1.0f; WeaponAttackAction waaHighest = null; for (int x = 0, n = vAttacks.size(); x < n; x++) { WeaponAttackAction waa = (WeaponAttackAction) vAttacks.elementAt(x); float fDanger = getExpectedDamage(g, waa); if (fDanger > fHighest) { fHighest = fDanger; waaHighest = waa; } } return waaHighest; } // store these as constants since the tables will never change private static float[] expectedHitsByRackSize = { 0.0f, 1.0f, 1.58f, 2.0f, 2.63f, 3.17f, 4.0f, 4.49f, 4.98f, 5.47f, 6.31f, 7.23f, 8.14f, 8.59f, 9.04f, 9.5f, 10.1f, 10.8f, 11.42f, 12.1f, 12.7f }; /** * Determines the expected damage of a weapon attack, based on to-hit, salvo * sizes, etc. */ public static float getExpectedDamage(IGame g, WeaponAttackAction waa) { boolean use_table = false; AmmoType loaded_ammo = new AmmoType(); Entity attacker = g.getEntity(waa.getEntityId()); Infantry inf_attacker = new Infantry(); BattleArmor ba_attacker = new BattleArmor(); Mounted weapon = attacker.getEquipment(waa.getWeaponId()); Mounted lnk_guide; ToHitData hitData = waa.toHit(g); if (attacker instanceof BattleArmor) { ba_attacker = (BattleArmor) g.getEntity(waa.getEntityId()); } if ((attacker instanceof Infantry) && !(attacker instanceof BattleArmor)) { inf_attacker = (Infantry) g.getEntity(waa.getEntityId()); } float fDamage = 0.0f; WeaponType wt = (WeaponType) weapon.getType(); if (hitData.getValue() == ToHitData.IMPOSSIBLE || hitData.getValue() == ToHitData.AUTOMATIC_FAIL) { return 0.0f; } float fChance = 0.0f; if (hitData.getValue() == ToHitData.AUTOMATIC_SUCCESS) { fChance = 1.0f; } else { fChance = (float) oddsAbove(hitData.getValue()) / 100.0f; } // Missiles, L
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -