Package megamek.common

Examples of megamek.common.ToHitData


     * To-hit number
     */
    public static ToHitData toHit(IGame game, int attackerId, Targetable target) {
        final Entity ae = game.getEntity(attackerId);
        if (ae == null) {
            return new ToHitData(TargetRoll.IMPOSSIBLE, "You can't attack from a null entity!");
        }

        if (!game.getOptions().booleanOption("tacops_grappling")) {
            return new ToHitData(TargetRoll.IMPOSSIBLE, "grappling attack not allowed");
        }

        String impossible = toHitIsImpossible(game, ae, target);
        if ((impossible != null) && !impossible.equals("Locked in Grapple")) {
            return new ToHitData(TargetRoll.IMPOSSIBLE, "impossible");
        }

        ToHitData toHit;

        // non-mechs can't grapple or be grappled
        if (!(ae instanceof Mech) && !(ae instanceof Protomech)) {
            return new ToHitData(TargetRoll.IMPOSSIBLE, "Only mechs and protomechs can be grappled");
        }

        if (ae.getGrappled() != target.getTargetId()) {
            return new ToHitData(TargetRoll.IMPOSSIBLE, "Not grappled");
        }

        // Set the base BTH
        int base = ae.getCrew().getPiloting();

        // Start the To-Hit
        toHit = new ToHitData(base, "base");

        PhysicalAttackAction.setCommonModifiers(toHit, game, ae, target);

        if (ae.isGrappleAttacker()) {
            toHit.addModifier(TargetRoll.AUTOMATIC_SUCCESS, "original attacker");
            return toHit;
        }

        setCommonModifiers(toHit, game, ae, target);

        if (ae instanceof Mech) {
            // damaged or missing actuators
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_SHOULDER, Mech.LOC_LARM)) {
                toHit.addModifier(2, "Left shoulder actuator destroyed");
            }
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_UPPER_ARM, Mech.LOC_LARM)) {
                toHit.addModifier(2, "Left upper arm actuator destroyed");
            }
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_LOWER_ARM, Mech.LOC_LARM)) {
                toHit.addModifier(2, "Left lower arm actuator destroyed");
            }
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_HAND, Mech.LOC_LARM)) {
                toHit.addModifier(1, "Left hand actuator destroyed");
            }

            if (!ae.hasWorkingSystem(Mech.ACTUATOR_SHOULDER, Mech.LOC_RARM)) {
                toHit.addModifier(2, "Right shoulder actuator destroyed");
            }
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_UPPER_ARM, Mech.LOC_RARM)) {
                toHit.addModifier(2, "Right upper arm actuator destroyed");
            }
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_LOWER_ARM, Mech.LOC_RARM)) {
                toHit.addModifier(2, "Right lower arm actuator destroyed");
            }
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_HAND, Mech.LOC_RARM)) {
                toHit.addModifier(1, "Right hand actuator destroyed");
            }
            if ( ae.hasFunctionalArmAES(Mech.LOC_RARM) && ae.hasFunctionalArmAES(Mech.LOC_LARM) ) {
                toHit.addModifier(-1,"AES modifer");
            }
        }
        Entity te = (Entity) target;
        // Weight class difference
        int wmod = te.getWeightClass() - ae.getWeightClass();

        if ((te instanceof Protomech) && !(ae instanceof Protomech)) {
            wmod = ae.getWeightClass() * -1;
        } else if ((ae instanceof Protomech) && !(te instanceof Protomech)) {
            wmod = te.getWeightClass();
        } else if ((te instanceof Protomech) && (ae instanceof Protomech)) {
            wmod = 0;
        }

        if (wmod != 0) {
            toHit.addModifier(wmod, "Weight class difference");
        }
        // done!
        return toHit;
    }
View Full Code Here


        for (Enumeration<Entity> impactHexHits = game.getEntities(coords);impactHexHits.hasMoreElements();) {
            Entity entity = impactHexHits.nextElement();
            //if fighter squadron all fighters are damaged
            if(entity instanceof FighterSquadron) {
                for(Entity fighter : ((FighterSquadron)entity).getFighters()) {
                    ToHitData toHit = new ToHitData();
                    toHit.setHitTable(ToHitData.HIT_NORMAL);
                    HitData hit = fighter.rollHitLocation(toHit.getHitTable(), ToHitData.SIDE_FRONT);
                    hit.setCapital(false);
                    vPhaseReport.addAll( server.damageEntity(fighter, hit, attackValue));
                    server.creditKill(fighter, ae);
                }
            } else
                ToHitData toHit = new ToHitData();
                toHit.setHitTable(ToHitData.HIT_NORMAL);
                HitData hit = entity.rollHitLocation(toHit.getHitTable(), ToHitData.SIDE_FRONT);
                hit.setCapital(false);
                vPhaseReport.addAll( server.damageEntity(entity, hit, attackValue));
                server.creditKill(entity, ae);
            }
        }
View Full Code Here

            if (target.getTargetType() == Targetable.TYPE_ENTITY
                    && (((Entity)target).getOwnerId() == ae.getOwnerId()
                            || (((Entity)target).getOwner().getTeam() != Player.TEAM_NONE
                                    && ae.getOwner().getTeam() != Player.TEAM_NONE
                                    && ae.getOwner().getTeam() == ((Entity)target).getOwner().getTeam())))
                return new ToHitData(TargetRoll.IMPOSSIBLE, "A friendly unit can never be the target of a direct attack.");
        }

        // Non-mechs can't thrash.
        if (!(ae instanceof Mech)) {
            return new ToHitData(TargetRoll.IMPOSSIBLE,
                    "Only mechs can thrash at infantry");
        }

        // Mech must be prone.
        if (!ae.isProne()) {
            return new ToHitData(TargetRoll.IMPOSSIBLE,
                    "Only prone mechs can thrash at infantry");
        }

        // Can't thrash against non-infantry
        if (te == null || !(te instanceof Infantry)) {
            return new ToHitData(TargetRoll.IMPOSSIBLE,
                    "Can only thrash at infantry");
        }

        // Can't thrash against swarming infantry.
        else if (Entity.NONE != te.getSwarmTargetId()) {
            return new ToHitData(TargetRoll.IMPOSSIBLE,
                    "Can't thrash at swarming infantry");
        }

        // Check range.
        if (target.getPosition() == null
                || ae.getPosition().distance(target.getPosition()) > 0) {
            return new ToHitData(TargetRoll.IMPOSSIBLE,
                    "Target not in same hex");
        }

        if (target.getElevation() != ae.getElevation()) {
            return new ToHitData(TargetRoll.IMPOSSIBLE,
                    "Target not at same elevation");
        }

        // Check terrain.
        IHex hex = game.getBoard().getHex(ae.getPosition());
        if (hex.containsTerrain(Terrains.WOODS)
                || hex.containsTerrain(Terrains.JUNGLE)
                || hex.containsTerrain(Terrains.ROUGH)
                || hex.containsTerrain(Terrains.RUBBLE)
                || hex.containsTerrain(Terrains.FUEL_TANK)
                || hex.containsTerrain(Terrains.BUILDING)) {
            return new ToHitData(TargetRoll.IMPOSSIBLE,
                    "Not a clear or pavement hex.");
        }

        // Can't target woods or a building with a thrash attack.
        if (target.getTargetType() == Targetable.TYPE_BUILDING
                || target.getTargetType() == Targetable.TYPE_BLDG_IGNITE
                || target.getTargetType() == Targetable.TYPE_FUEL_TANK
                || target.getTargetType() == Targetable.TYPE_FUEL_TANK_IGNITE
                || target.getTargetType() == Targetable.TYPE_HEX_CLEAR
                || target.getTargetType() == Targetable.TYPE_HEX_IGNITE) {
            return new ToHitData(TargetRoll.IMPOSSIBLE, "Invalid attack");
        }

        // The Mech can't have fired a weapon this round.
        for (int loop = 0; loop < ae.locations(); loop++) {
            if (ae.weaponFiredFrom(loop)) {
                return new ToHitData(TargetRoll.IMPOSSIBLE,
                        "Weapons fired from " + ae.getLocationName(loop)
                                + " this turn");
            }
        }

        // Mech must have at least one working arm or leg.
        if (ae.isLocationBad(Mech.LOC_RARM) && ae.isLocationBad(Mech.LOC_LARM)
                && ae.isLocationBad(Mech.LOC_RLEG)
                && ae.isLocationBad(Mech.LOC_LLEG)) {
            return new ToHitData(TargetRoll.IMPOSSIBLE,
                    "Mech has no arms or legs to thrash");
        }

        // If the attack isn't impossible, it's automatically successful.
        return new ToHitData(TargetRoll.AUTOMATIC_SUCCESS,
                "thrash attacks always hit");
    }
View Full Code Here

    }
   
    public static ToHitData toHit(IGame game, int attackerId, Targetable target, int grappleSide) {
        final Entity ae = game.getEntity(attackerId);
        if (ae == null)
            return new ToHitData(TargetRoll.IMPOSSIBLE, "You can't attack from a null entity!");

        if (!game.getOptions().booleanOption("tacops_grappling"))
            return new ToHitData(TargetRoll.IMPOSSIBLE, "grappling attack not allowed");

        String impossible = toHitIsImpossible(game, ae, target);
        if (impossible != null && !impossible.equals("Locked in Grapple")) {
            return new ToHitData(TargetRoll.IMPOSSIBLE, "impossible");
        }
       
        if (!game.getOptions().booleanOption("friendly_fire")) {
            // a friendly unit can never be the target of a direct attack.
            if (target.getTargetType() == Targetable.TYPE_ENTITY
                    && (((Entity)target).getOwnerId() == ae.getOwnerId()
                            || (((Entity)target).getOwner().getTeam() != Player.TEAM_NONE
                                    && ae.getOwner().getTeam() != Player.TEAM_NONE
                                    && ae.getOwner().getTeam() == ((Entity)target).getOwner().getTeam())))
                return new ToHitData(TargetRoll.IMPOSSIBLE, "A friendly unit can never be the target of a direct attack.");
        }

        IHex attHex = game.getBoard().getHex(ae.getPosition());
        IHex targHex = game.getBoard().getHex(target.getPosition());
        final int attackerElevation = ae.getElevation() + attHex.getElevation();
        // final int attackerHeight = attackerElevation + ae.getHeight();
        final int targetElevation = target.getElevation() + targHex.getElevation();
        // final int targetHeight = targetElevation + target.getHeight();
        ToHitData toHit;

        // non-mechs can't grapple or be grappled
        if ((!(ae instanceof BipedMech) && !(ae instanceof Protomech)) || (!(target instanceof Mech) && !(target instanceof Protomech))) {
            return new ToHitData(TargetRoll.IMPOSSIBLE, "Only biped mechs can grapple 'Mechs and Protomechs");
        }

        Entity te = (Entity) target;
        final boolean counter = ae.getGrappled() != Entity.NONE && !ae.isGrappleAttacker();

        // requires 2 good arms
        if (grappleSide == Entity.GRAPPLE_BOTH ) {

            if ( ae.isLocationBad(Mech.LOC_LARM) || ae.isLocationBad(Mech.LOC_RARM) ) {
                return new ToHitData(TargetRoll.IMPOSSIBLE, "Arm missing");
            }

            if (!ae.hasWorkingSystem(Mech.ACTUATOR_SHOULDER, Mech.LOC_RARM)
                    || !ae.hasWorkingSystem(Mech.ACTUATOR_SHOULDER, Mech.LOC_LARM)) {
                return new ToHitData(TargetRoll.IMPOSSIBLE, "Shoulder missing/destroyed");
            }
        }else if ( grappleSide == Entity.GRAPPLE_LEFT ) {
            if ( ae.isLocationBad(Mech.LOC_LARM) ) {
                return new ToHitData(TargetRoll.IMPOSSIBLE, "Arm missing");
            }

            if (!ae.hasWorkingSystem(Mech.ACTUATOR_SHOULDER, Mech.LOC_LARM)) {
                return new ToHitData(TargetRoll.IMPOSSIBLE, "Shoulder missing/destroyed");
            }
        } else {
            if ( ae.isLocationBad(Mech.LOC_RARM) ) {
                return new ToHitData(TargetRoll.IMPOSSIBLE, "Arm missing");
            }

            if (!ae.hasWorkingSystem(Mech.ACTUATOR_SHOULDER, Mech.LOC_RARM)) {
                return new ToHitData(TargetRoll.IMPOSSIBLE, "Shoulder missing/destroyed");
            }
        }
       
       
        // check range
        final int range = ae.getPosition().distance(target.getPosition());
        if (range != 1 && !counter) {
            return new ToHitData(TargetRoll.IMPOSSIBLE, "Target not in range");
        }

        // check elevation (attacker must be able to enter target hex)
        if (Math.abs(attackerElevation - targetElevation) > ae.getMaxElevationChange()) {
            return new ToHitData(TargetRoll.IMPOSSIBLE, "Target elevation not in range");
        }

        // check facing
        if (!counter && !Compute.isInArc(ae.getPosition(), ae.getFacing(), target.getPosition(), Compute.ARC_FORWARD)) {
            return new ToHitData(TargetRoll.IMPOSSIBLE, "Target not in arc");
        }

        // can't grapple while prone
        if (ae.isProne()) {
            return new ToHitData(TargetRoll.IMPOSSIBLE, "Attacker is prone");
        }
        if (((Entity) target).isProne()) {
            return new ToHitData(TargetRoll.IMPOSSIBLE, "Target is prone");
        }

        // check if attacker has fired any weapons
        if (!counter) {
            for (Mounted mounted : ae.getWeaponList()) {
                if (mounted.isUsedThisRound()) {
                    return new ToHitData(TargetRoll.IMPOSSIBLE, "Fired weapons");
                }
            }
        }

        // already done?
        int atGr = ae.getGrappled();
        int deGr = te.getGrappled();
        if ((atGr != Entity.NONE || deGr != Entity.NONE) && atGr != target.getTargetId() && te.isGrappleAttacker()) {
            return new ToHitData(TargetRoll.IMPOSSIBLE, "Already grappled");
        }

        // Set the base BTH
        int base = ae.getCrew().getPiloting();

        // Start the To-Hit
        toHit = new ToHitData(base, "base");

        setCommonModifiers(toHit, game, ae, target);

        if (ae instanceof Mech && grappleSide == Entity.GRAPPLE_BOTH ) {
            // damaged or missing actuators
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_UPPER_ARM, Mech.LOC_LARM)) {
                toHit.addModifier(2, "Left upper arm actuator destroyed");
            }
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_LOWER_ARM, Mech.LOC_LARM)) {
                toHit.addModifier(2, "Left lower arm actuator destroyed");
            }
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_HAND, Mech.LOC_LARM)) {
                toHit.addModifier(1, "Left hand actuator destroyed");
            }

            if (!ae.hasWorkingSystem(Mech.ACTUATOR_UPPER_ARM, Mech.LOC_RARM)) {
                toHit.addModifier(2, "Right upper arm actuator destroyed");
            }
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_LOWER_ARM, Mech.LOC_RARM)) {
                toHit.addModifier(2, "Right lower arm actuator destroyed");
            }
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_HAND, Mech.LOC_RARM)) {
                toHit.addModifier(1, "Right hand actuator destroyed");
            }

            if ( ae.hasFunctionalArmAES(Mech.LOC_RARM) && ae.hasFunctionalArmAES(Mech.LOC_LARM) ) {
                toHit.addModifier(-1,"AES modifer");
            }

        } else if (ae instanceof Mech && grappleSide == Entity.GRAPPLE_RIGHT ) {
            // damaged or missing actuators
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_UPPER_ARM, Mech.LOC_RARM)) {
                toHit.addModifier(2, "Right upper arm actuator destroyed");
            }
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_LOWER_ARM, Mech.LOC_RARM)) {
                toHit.addModifier(2, "Right lower arm actuator destroyed");
            }
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_HAND, Mech.LOC_RARM)) {
                toHit.addModifier(1, "Right hand actuator destroyed");
            }
            if ( ae.hasFunctionalArmAES(Mech.LOC_RARM)) {
                toHit.addModifier(-1,"AES modifer");
            }

        } else {
            // damaged or missing actuators
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_UPPER_ARM, Mech.LOC_LARM)) {
                toHit.addModifier(2, "Left upper arm actuator destroyed");
            }
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_LOWER_ARM, Mech.LOC_LARM)) {
                toHit.addModifier(2, "Left lower arm actuator destroyed");
            }
            if (!ae.hasWorkingSystem(Mech.ACTUATOR_HAND, Mech.LOC_LARM)) {
                toHit.addModifier(1, "Left hand actuator destroyed");
            }
            if ( ae.hasFunctionalArmAES(Mech.LOC_LARM) ) {
                toHit.addModifier(-1,"AES modifer");
            }

        }

        if ( grappleSide != Entity.GRAPPLE_BOTH && ae instanceof Mech ) {
            Mech attacker = (Mech)ae;
           
            if ( attacker.hasTSM() && attacker.heat >= 9
                    && ( !(te instanceof Mech) || !((Mech)te).hasTSM() || (((Mech)te).hasTSM() && te.heat < 9))) {
                toHit.addModifier(-2, "TSM Active Bonus");
            }
        }
       
        // Weight class difference
        int wmod = te.getWeightClass() - ae.getWeightClass();

        if (te instanceof Protomech && !(ae instanceof Protomech)) {
            wmod = ae.getWeightClass() * -1;
        } else if (ae instanceof Protomech && !(te instanceof Protomech)) {
            wmod = te.getWeightClass();
        } else if (te instanceof Protomech && ae instanceof Protomech) {
            wmod = 0;
        }

        if (wmod != 0) {
            toHit.addModifier(wmod, "Weight class difference");
        }
        // done!
        return toHit;
    }
View Full Code Here

        this.ammoType = AmmoType.T_NA;
        this.minimumRange = WEAPON_NA;
    }

    public AttackHandler fire(WeaponAttackAction waa, IGame game, Server server) {
        ToHitData toHit = waa.toHit(game);
        // FIXME: SUPER DUPER EVIL HACK: swarm missile handlers must be returned
        // even
        // if the have an impossible to hit, because there might be other
        // targets
        // someone else please please figure out how to do this nice
        AttackHandler ah = getCorrectHandler(toHit, waa, game, server);
        if (ah instanceof LRMSwarmHandler || ah instanceof LRMSwarmIHandler)
            return ah;
        return toHit.getValue() == TargetRoll.IMPOSSIBLE ? null
                : ah;
    }
View Full Code Here

    /**
     * Punch the target!
     */
    void punch() {
        final ToHitData leftArm = PunchAttackAction.toHit(client.game, cen,
                target, PunchAttackAction.LEFT);
        final ToHitData rightArm = PunchAttackAction.toHit(client.game, cen,
                target, PunchAttackAction.RIGHT);
        String title = Messages
                .getString(
                        "PhysicalDisplay.PunchDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$
        String message = Messages.getString(
                "PhysicalDisplay.PunchDialog.message", new Object[] {//$NON-NLS-1$
                        rightArm.getValueAsString(),
                        new Double(Compute.oddsAbove(rightArm.getValue())),
                        rightArm.getDesc(),
                        new Integer(PunchAttackAction.getDamageFor(ce(),
                                PunchAttackAction.RIGHT,
                                (target instanceof Infantry)
                                        && !(target instanceof BattleArmor))),
                        rightArm.getTableDesc(),
                        leftArm.getValueAsString(),
                        new Double(Compute.oddsAbove(leftArm.getValue())),
                        leftArm.getDesc(),
                        new Integer(PunchAttackAction.getDamageFor(ce(),
                                PunchAttackAction.LEFT,
                                (target instanceof Infantry)
                                        && !(target instanceof BattleArmor))),
                        leftArm.getTableDesc() });
        if (clientgui.doYesNoDialog(title, message)) {
            // check for retractable blade that can be extended in each arm
            boolean leftBladeExtend = false;
            boolean rightBladeExtend = false;
            if ((ce() instanceof Mech)
                    && (target instanceof Entity)
                    && clientgui.client.game.getOptions().booleanOption(
                            "tacops_retractable_blades")
                    && (leftArm.getValue() != TargetRoll.IMPOSSIBLE)
                    && ((Mech) ce()).hasRetractedBlade(Mech.LOC_LARM)) {
                leftBladeExtend = clientgui.doYesNoDialog(Messages
                        .getString("PhysicalDisplay.ExtendBladeDialog.title"),
                        Messages.getString(
                                "PhysicalDisplay.ExtendBladeDialog.message",
                                new Object[] { ce().getLocationName(
                                        Mech.LOC_LARM) }));
            }
            if ((ce() instanceof Mech)
                    && (target instanceof Entity)
                    && (rightArm.getValue() != TargetRoll.IMPOSSIBLE)
                    && clientgui.client.game.getOptions().booleanOption(
                            "tacops_retractable_blades")
                    && ((Mech) ce()).hasRetractedBlade(Mech.LOC_RARM)) {
                rightBladeExtend = clientgui.doYesNoDialog(Messages
                        .getString("PhysicalDisplay.ExtendBladeDialog.title"),
                        Messages.getString(
                                "PhysicalDisplay.ExtendBladeDialog.message",
                                new Object[] { ce().getLocationName(
                                        Mech.LOC_RARM) }));
            }
            disableButtons();
            // declare searchlight, if possible
            if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) {
                doSearchlight();
            }

            if ((leftArm.getValue() != TargetRoll.IMPOSSIBLE)
                    && (rightArm.getValue() != TargetRoll.IMPOSSIBLE)) {
                attacks.addElement(new PunchAttackAction(cen, target
                        .getTargetType(), target.getTargetId(),
                        PunchAttackAction.BOTH, leftBladeExtend,
                        rightBladeExtend));
            } else if (leftArm.getValue() < rightArm.getValue()) {
                attacks.addElement(new PunchAttackAction(cen, target
                        .getTargetType(), target.getTargetId(),
                        PunchAttackAction.LEFT, leftBladeExtend,
                        rightBladeExtend));
            } else {
View Full Code Here

    /**
     * Kick the target!
     */
    void kick() {
        ToHitData leftLeg = KickAttackAction.toHit(client.game, cen, target,
                KickAttackAction.LEFT);
        ToHitData rightLeg = KickAttackAction.toHit(client.game, cen, target,
                KickAttackAction.RIGHT);
        ToHitData rightRearLeg = null;
        ToHitData leftRearLeg = null;

        ToHitData attackLeg;
        int attackSide = KickAttackAction.LEFT;
        int value = leftLeg.getValue();
        attackLeg = leftLeg;

        if (value > rightLeg.getValue()) {
            value = rightLeg.getValue();
            attackSide = KickAttackAction.RIGHT;
            attackLeg = rightLeg;
        }
        if (client.game.getEntity(cen) instanceof QuadMech) {
            rightRearLeg = KickAttackAction.toHit(client.game, cen, target,
                    KickAttackAction.RIGHTMULE);
            leftRearLeg = KickAttackAction.toHit(client.game, cen, target,
                    KickAttackAction.LEFTMULE);
            if (value > rightRearLeg.getValue()) {
                value = rightRearLeg.getValue();
                attackSide = KickAttackAction.RIGHTMULE;
                attackLeg = rightRearLeg;
            }
            if (value > leftRearLeg.getValue()) {
                value = leftRearLeg.getValue();
                attackSide = KickAttackAction.LEFTMULE;
                attackLeg = leftRearLeg;
            }
        }
        String title = Messages
                .getString(
                        "PhysicalDisplay.KickDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$
        String message = Messages.getString(
                "PhysicalDisplay.KickDialog.message", new Object[] {//$NON-NLS-1$
                        attackLeg.getValueAsString(),
                        new Double(Compute.oddsAbove(attackLeg.getValue())),
                        attackLeg.getDesc(),
                        KickAttackAction.getDamageFor(ce(), attackSide,
                                (target instanceof Infantry)
                                        && !(target instanceof BattleArmor))
                                + attackLeg.getTableDesc() });
        if (clientgui.doYesNoDialog(title, message)) {
            disableButtons();
            // declare searchlight, if possible
            if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) {
                doSearchlight();
View Full Code Here

    /**
     * Push that target!
     */
    void push() {
        ToHitData toHit = PushAttackAction.toHit(client.game, cen, target);
        String title = Messages
                .getString(
                        "PhysicalDisplay.PushDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$
        String message = Messages.getString(
                "PhysicalDisplay.PushDialog.message", new Object[] {//$NON-NLS-1$
                toHit.getValueAsString(),
                        new Double(Compute.oddsAbove(toHit.getValue())),
                        toHit.getDesc() });
        if (clientgui.doYesNoDialog(title, message)) {
            disableButtons();
            // declare searchlight, if possible
            if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) {
                doSearchlight();
View Full Code Here

    /**
     * Trip that target!
     */
    void trip() {
        ToHitData toHit = TripAttackAction.toHit(client.game, cen, target);
        String title = Messages
                .getString(
                        "PhysicalDisplay.TripDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$
        String message = Messages.getString(
                "PhysicalDisplay.TripDialog.message", new Object[] { //$NON-NLS-1$
                toHit.getValueAsString(),
                        new Double(Compute.oddsAbove(toHit.getValue())),
                        toHit.getDesc() });
        if (clientgui.doYesNoDialog(title, message)) {
            disableButtons();
            // declare searchlight, if possible
            if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) {
                doSearchlight();
View Full Code Here

            breakGrapple();
        }
    }

    private void grapple(boolean counter) {
        ToHitData toHit = GrappleAttackAction.toHit(client.game, cen, target);
        String title = Messages
                .getString(
                        "PhysicalDisplay.GrappleDialog.title", new Object[] { target.getDisplayName() }); //$NON-NLS-1$
        String message = Messages.getString(
                "PhysicalDisplay.GrappleDialog.message", new Object[] { //$NON-NLS-1$
                toHit.getValueAsString(),
                        new Double(Compute.oddsAbove(toHit.getValue())),
                        toHit.getDesc() });
        if (counter) {
            message = Messages
                    .getString(
                            "PhysicalDisplay.CounterGrappleDialog.message", new Object[] { //$NON-NLS-1$
                                    target.getDisplayName(),
                                    toHit.getValueAsString(),
                                    new Double(Compute.oddsAbove(toHit
                                            .getValue())), toHit.getDesc() });
        }
        if (clientgui.doYesNoDialog(title, message)) {
            disableButtons();
            // declare searchlight, if possible
            if (GUIPreferences.getInstance().getAutoDeclareSearchlight()) {
View Full Code Here

TOP

Related Classes of megamek.common.ToHitData

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.