Package megamek.common

Examples of megamek.common.PilotingRollData


     *            The target <code>Entity</code>
     * @return The <code>PilotingRollData</code>
     */
    private PilotingRollData getKickPushPSR(Entity psrEntity, Entity attacker, Entity target, String reason) {
        int mod = 0;
        PilotingRollData psr = new PilotingRollData(psrEntity.getId(), mod, reason);
        if (game.getOptions().booleanOption("tacops_physical_psr")) {

            switch (target.getWeightClass()) {
            case EntityWeightClass.WEIGHT_LIGHT:
                mod = 1;
                break;
            case EntityWeightClass.WEIGHT_MEDIUM:
                mod = 0;
                break;
            case EntityWeightClass.WEIGHT_HEAVY:
                mod = -1;
                break;
            case EntityWeightClass.WEIGHT_ASSAULT:
                mod = -2;
                break;
            }
            String reportStr;
            if (mod > 0) {
                reportStr = ("weight class modifier +")+mod;
            } else {
                reportStr = ("weight class modifier ")+mod;
            }
            psr.addModifier(mod, reportStr, false);
        }
        return psr;
    }
View Full Code Here


                if ((entity instanceof Dropship) || (entity instanceof Jumpship)) {
                    // only check for a possible control roll
                    if (entity.heat > 0) {
                        int bonus = (int) Math.ceil(entity.heat / 100.0);
                        game.addControlRoll(new PilotingRollData(entity.getId(), bonus, "used too much heat"));
                        entity.heat = 0;
                    }
                    continue;
                }

                int autoShutDownHeat = 30;
                boolean mtHeat = game.getOptions().booleanOption("tacops_heat");
                if (mtHeat) {
                    autoShutDownHeat = 50;
                }

                // heat effects: start up
                if ((entity.heat < autoShutDownHeat) && entity.isShutDown()) {
                    // only start up if not shut down by taser
                    if (entity.getTaserShutdownRounds() == 0) {
                        if (entity.heat < 14) {
                            // automatically starts up again
                            entity.setShutDown(false);
                            r = new Report(5045);
                            r.subject = entity.getId();
                            r.addDesc(entity);
                            addReport(r);
                        } else {
                            // roll for startup
                            int startup = 4 + (entity.heat - 14) / 4 * 2;
                            if (mtHeat) {
                                startup -= 5;
                                switch (entity.crew.getPiloting()) {
                                case 0:
                                case 1:
                                    startup -= 2;
                                    break;
                                case 2:
                                case 3:
                                    startup -= 1;
                                    break;
                                case 6:
                                case 7:
                                    startup += 1;
                                    break;
                                }
                            }
                            int suroll = Compute.d6(2);
                            r = new Report(5050);
                            r.subject = entity.getId();
                            r.addDesc(entity);
                            r.add(startup);
                            r.add(suroll);
                            if (suroll >= startup) {
                                // start 'er back up
                                entity.setShutDown(false);
                                r.choose(true);
                            } else {
                                r.choose(false);
                            }
                            addReport(r);
                        }
                    } else {
                        // if we're shutdown by a BA taser, we might activate
                        // again
                        if (entity.isBATaserShutdown()) {
                            int roll = Compute.d6(2);
                            if (roll >= 8) {
                                entity.setTaserShutdownRounds(0);
                                entity.setShutDown(false);
                                entity.setBATaserShutdown(false);
                            }
                        }
                    }
                }

                // heat effects: shutdown!
                else if ((entity.heat >= 14) && !entity.isShutDown()) {
                    if (entity.heat >= autoShutDownHeat) {
                        r = new Report(5055);
                        r.subject = entity.getId();
                        r.addDesc(entity);
                        addReport(r);
                        // okay, now mark shut down
                        entity.setShutDown(true);
                    } else if (entity.heat >= 14) {
                        int shutdown = 4 + (entity.heat - 14) / 4 * 2;
                        if (mtHeat) {
                            shutdown -= 5;
                            switch (entity.crew.getPiloting()) {
                            case 0:
                            case 1:
                                shutdown -= 2;
                                break;
                            case 2:
                            case 3:
                                shutdown -= 1;
                                break;
                            case 6:
                            case 7:
                                shutdown += 1;
                                break;
                            }
                        }
                        int sdroll = Compute.d6(2);
                        r = new Report(5060);
                        r.subject = entity.getId();
                        r.addDesc(entity);
                        r.add(shutdown);
                        r.add(sdroll);
                        if (sdroll >= shutdown) {
                            // avoided
                            r.choose(true);
                            addReport(r);
                        } else {
                            // shutting down...
                            r.choose(false);
                            addReport(r);
                            // okay, now mark shut down
                            entity.setShutDown(true);
                        }
                    }
                }

                // heat effects: control effects (must make it unless already
                // random moving)
                if ((entity.heat >= 5) && !a.isRandomMove()) {
                    int controlavoid = 5 + (entity.heat >= 10 ? 1 : 0) + (entity.heat >= 15 ? 1 : 0) + (entity.heat >= 20 ? 1 : 0) + (entity.heat >= 25 ? 2 : 0);
                    int controlroll = Compute.d6(2);
                    r = new Report(9210);
                    r.subject = entity.getId();
                    r.addDesc(entity);
                    r.add(controlavoid);
                    r.add(controlroll);
                    if (controlroll >= controlavoid) {
                        // in control
                        r.choose(true);
                        addReport(r);
                    } else {
                        // out of control
                        r.choose(false);
                        addReport(r);
                        // if not already out of control, this may lead to
                        // elevation decline
                        if (!a.isOutControl() && game.getBoard().inAtmosphere()) {
                            int loss = Compute.d6(1);
                            r = new Report(9366);
                            r.newlines = 0;
                            r.subject = entity.getId();
                            r.addDesc(entity);
                            r.add(loss);
                            addReport(r);
                            // check for crash
                            if ((a.getElevation() - loss) <= game.getBoard().getHex(a.getPosition()).ceiling()) {
                                a.setElevation(0);
                                addReport(processCrash(entity, a.getCurrentVelocity()));
                            } else {
                                a.setElevation(a.getElevation() - loss);
                            }
                        }
                        // force unit out of control through heat
                        a.setOutCtrlHeat(true);
                        a.setRandomMove(true);
                    }
                } //End of Entity Instance of Aero

                // heat effects: ammo explosion!
                if (entity.heat >= 19) {
                    int boom = 4 + (entity.heat >= 23 ? 2 : 0) + (entity.heat >= 28 ? 2 : 0);
                    if (mtHeat) {
                        boom += (entity.heat >= 35 ? 2 : 0) + (entity.heat >= 40 ? 2 : 0) + (entity.heat >= 45 ? 2 : 0);
                        // Last line is a crutch; 45 heat should be no roll
                        // but automatic explosion.
                    }
                    int boomroll = Compute.d6(2);
                    r = new Report(5065);
                    r.subject = entity.getId();
                    r.addDesc(entity);
                    r.add(boom);
                    r.add(boomroll);
                    if (boomroll >= boom) {
                        // mech is ok
                        r.choose(true);
                        addReport(r);
                    } else {
                        // boom!
                        r.choose(false);
                        addReport(r);
                        addReport(explodeAmmoFromHeat(entity));
                    }
                }

                // heat effects: pilot damage
                if (entity.heat >= 21) {
                    int ouch = 6 + (entity.heat >= 27 ? 3 : 0);
                    int ouchroll = Compute.d6(2);
                    r = new Report(5075);
                    r.subject = entity.getId();
                    r.addDesc(entity);
                    r.add(ouch);
                    r.add(ouchroll);
                    if (ouchroll >= ouch) {
                        // pilot is ok
                        r.choose(true);
                        addReport(r);
                    } else {
                        // pilot is hurting
                        r.choose(false);
                        addReport(r);
                        addReport(damageCrew(entity, 1));
                    }
                }

                // The pilot may have just expired.
                if ((entity.crew.isDead() || entity.crew.isDoomed()) && !entity.crew.isEjected()) {
                    r = new Report(5080);
                    r.subject = entity.getId();
                    r.addDesc(entity);
                    addReport(r);
                    addReport(destroyEntity(entity, "pilot death", true));
                }

                continue;
            }

            // heat doesn't matter for non-mechs
            if (!(entity instanceof Mech)) {
                entity.heatBuildup = 0;
                entity.heatFromExternal = 0;

                if (entity.infernos.isStillBurning()) {
                    doFlamingDamage(entity);
                }
                if (entity.getTaserShutdownRounds() == 0) {
                    entity.setShutDown(false);
                    entity.setBATaserShutdown(false);
                } else {
                    // if we're shutdown by a BA taser, we might activate
                    // again
                    if (entity.isBATaserShutdown()) {
                        int roll = Compute.d6(2);
                        if (roll >= 8) {
                            entity.setTaserShutdownRounds(0);
                            entity.setShutDown(false);
                            entity.setBATaserShutdown(false);
                        }
                    }
                }

                continue;
            }
            // Meks gain heat from inferno hits.
            if (entity.infernos.isStillBurning()) {
                int infernoHeat = entity.infernos.getHeat();
                entity.heatFromExternal += infernoHeat;
                r = new Report(5010);
                r.subject = entity.getId();
                r.add(infernoHeat);
                addReport(r);
            }

            // should we even bother?
            if (entity.isDestroyed() || entity.isDoomed() || entity.crew.isDoomed() || entity.crew.isDead()) {
                continue;
            }

            // engine hits add a lot of heat, provided the engine is on
            entity.heatBuildup += entity.getEngineCritHeat();

            // If a Mek had an active Stealth suite, add 10 heat.
            if ((entity instanceof Mech) && entity.isStealthOn()) {
                entity.heatBuildup += 10;
                r = new Report(5015);
                r.subject = entity.getId();
                addReport(r);
            }

            //void sig adds 10 heat
            if ((entity instanceof Mech) && entity.isVoidSigActive()) {
                entity.heatBuildup += 10;
                r = new Report(5016);
                r.subject = entity.getId();
                addReport(r);
            }

            //null sig adds 10 heat
            if ((entity instanceof Mech) && entity.isNullSigActive()) {
                entity.heatBuildup += 10;
                r = new Report(5017);
                r.subject = entity.getId();
                addReport(r);
            }

            //chameleon polarization field adds 6
            if ((entity instanceof Mech) && entity.isChameleonShieldActive()) {
                entity.heatBuildup += 6;
                r = new Report(5014);
                r.subject = entity.getId();
                addReport(r);
            }

            // If a Mek is in extreme Temperatures, add or subtract one
            // heat per 10 degrees (or fraction of 10 degrees) above or
            // below 50 or -30 degrees Celsius
            if ((entity instanceof Mech) && (game.getPlanetaryConditions().getTemperatureDifference(50, -30) != 0) && !((Mech) entity).hasLaserHeatSinks()) {
                if (game.getPlanetaryConditions().getTemperature() > 50) {
                    entity.heatFromExternal += game.getPlanetaryConditions().getTemperatureDifference(50, -30);
                    r = new Report(5020);
                    r.subject = entity.getId();
                    r.add(game.getPlanetaryConditions().getTemperatureDifference(50, -30));
                    addReport(r);
                } else {
                    entity.heatFromExternal -= game.getPlanetaryConditions().getTemperatureDifference(50, -30);
                    r = new Report(5025);
                    r.subject = entity.getId();
                    r.add(game.getPlanetaryConditions().getTemperatureDifference(50, -30));
                    addReport(r);
                }
            }

            // Add +5 Heat if the hex you're in is on fire
            // and was on fire for the full round.
            if (entityHex != null) {
                if (entityHex.containsTerrain(Terrains.FIRE) && (entityHex.getFireTurn() > 0)
                        && (entity.getElevation() <= 1)) {
                    entity.heatFromExternal += 5;
                    r = new Report(5030);
                    r.subject = entity.getId();
                    addReport(r);
                }
                int magma = entityHex.terrainLevel(Terrains.MAGMA);
                if ((magma > 0) && (entity.getElevation() == 0)) {
                    entity.heatFromExternal += 5 * magma;
                    r = new Report(5032);
                    r.subject = entity.getId();
                    r.add(5 * magma);
                    addReport(r);
                }
            }

            // Check the mech for vibroblades if so then check to see if any
            // are active and what heat they will produce.
            if (entity.hasVibroblades()) {
                int vibroHeat = 0;

                vibroHeat = entity.getActiveVibrobladeHeat(Mech.LOC_RARM);
                vibroHeat += entity.getActiveVibrobladeHeat(Mech.LOC_LARM);

                if (vibroHeat > 0) {
                    r = new Report(5018);
                    r.subject = entity.getId();
                    r.add(vibroHeat);
                    addReport(r);
                    entity.heatBuildup += vibroHeat;
                }
            }

            int capHeat = 0;
            for (Mounted m : entity.getEquipment()) {
                if (m.hasChargedCapacitor() && !m.isUsedThisRound()) {
                    capHeat += 5;
                }
            }
            if (capHeat > 0) {
                r = new Report(5019);
                r.subject = entity.getId();
                r.add(capHeat);
                addReport(r);
                entity.heatBuildup += capHeat;
            }

            // Add heat from external sources to the heat buildup
            entity.heatBuildup += Math.min(15, entity.heatFromExternal);
            entity.heatFromExternal = 0;

            // if heatbuildup is negative due to temperature, set it to 0
            // for prettier turnreports
            if (entity.heatBuildup < 0) {
                entity.heatBuildup = 0;
            }

            // add the heat we've built up so far.
            entity.heat += entity.heatBuildup;

            // how much heat can we sink?
            int tosink = entity.getHeatCapacityWithWater();


            if ( entity.getCoolantFailureAmount() > 0 ){
                int failureAmount = entity.getCoolantFailureAmount();
                r = new Report(5520);
                r.subject = entity.getId();
                r.add(failureAmount);
                tosink -= failureAmount;
            }

            // should we use a coolant pod?
            int safeHeat = entity.hasInfernoAmmo() ? 9 : 13;
            int possibleSinkage = ((Mech) entity).getNumberOfSinks() - entity.getCoolantFailureAmount();
            for (Mounted m : entity.getEquipment()) {
                if (m.getType() instanceof AmmoType) {
                    AmmoType at = (AmmoType) m.getType();
                    if ((at.getAmmoType() == AmmoType.T_COOLANT_POD) && m.isAmmoUsable()) {
                        EquipmentMode mode = m.curMode();
                        if (mode.equals("dump")) {
                            r = new Report(5260);
                            r.subject = entity.getId();
                            addReport(r);
                            m.setShotsLeft(0);
                            tosink += possibleSinkage;
                            break;
                        }
                        if (mode.equals("safe") && (entity.heat - tosink > safeHeat)) {
                            r = new Report(5265);
                            r.subject = entity.getId();
                            addReport(r);
                            m.setShotsLeft(0);
                            tosink += possibleSinkage;
                            break;
                        }
                        if (mode.equals("efficient") && (entity.heat - tosink >= possibleSinkage)) {
                            r = new Report(5270);
                            r.subject = entity.getId();
                            addReport(r);
                            m.setShotsLeft(0);
                            tosink += possibleSinkage;
                            break;
                        }
                    }
                }
            }

            tosink = Math.min(tosink, entity.heat);
            entity.heat -= tosink;
            r = new Report(5035);
            r.subject = entity.getId();
            r.addDesc(entity);
            r.add(entity.heatBuildup);
            r.add(tosink);
            r.add(entity.heat);
            addReport(r);
            entity.heatBuildup = 0;

            // Does the unit have inferno ammo?
            if (entity.hasInfernoAmmo()) {

                // Roll for possible inferno ammo explosion.
                if (entity.heat >= 10) {
                    int boom = 4 + (entity.heat >= 14 ? 2 : 0) + (entity.heat >= 19 ? 2 : 0) + (entity.heat >= 23 ? 2 : 0) + (entity.heat >= 28 ? 2 : 0);
                    int boomroll = Compute.d6(2);
                    r = new Report(5040);
                    r.subject = entity.getId();
                    r.addDesc(entity);
                    r.add(boom);
                    r.add(boomroll);

                    if (boomroll >= boom) {
                        // avoided
                        r.choose(true);
                        addReport(r);
                    } else {
                        r.choose(false);
                        addReport(r);
                        addReport(explodeInfernoAmmoFromHeat(entity));
                    }
                }
            } // End avoid-inferno-explosion
            int autoShutDownHeat;
            boolean mtHeat;

            if (game.getOptions().booleanOption("tacops_heat")) {
                autoShutDownHeat = 50;
                mtHeat = true;
            } else {
                autoShutDownHeat = 30;
                mtHeat = false;
            }
            // heat effects: start up
            if ((entity.heat < autoShutDownHeat) && entity.isShutDown() && !entity.isStalled()) {
                if (entity.getTaserShutdownRounds() == 0) {
                    if (entity.heat < 14) {
                        // automatically starts up again
                        entity.setShutDown(false);
                        r = new Report(5045);
                        r.subject = entity.getId();
                        r.addDesc(entity);
                        addReport(r);
                    } else {
                        // roll for startup
                        int startup = 4 + (entity.heat - 14) / 4 * 2;
                        if (mtHeat) {
                            startup -= 5;
                            switch (entity.crew.getPiloting()) {
                            case 0:
                            case 1:
                                startup -= 2;
                                break;
                            case 2:
                            case 3:
                                startup -= 1;
                                break;
                            case 6:
                            case 7:
                                startup += 1;
                            }
                            if (entity instanceof QuadMech) {
                                startup -= 2;
                            }
                        }
                        int suroll = Compute.d6(2);
                        r = new Report(5050);
                        r.subject = entity.getId();
                        r.addDesc(entity);
                        r.add(startup);
                        r.add(suroll);
                        if (suroll >= startup) {
                            // start 'er back up
                            entity.setShutDown(false);
                            r.choose(true);
                        } else {
                            r.choose(false);
                        }
                        addReport(r);
                    }
                } else {
                    // if we're shutdown by a BA taser, we might activate
                    // again
                    if (entity.isBATaserShutdown()) {
                        int roll = Compute.d6(2);
                        if (roll >= 7) {
                            entity.setTaserShutdownRounds(0);
                            entity.setShutDown(false);
                            entity.setBATaserShutdown(false);
                        }
                    }
                }
            }

            // heat effects: shutdown!
            // Don't shut down if you just restarted.
            else if ((entity.heat >= 14) && !entity.isShutDown()) {
                if (entity.heat >= autoShutDownHeat) {
                    r = new Report(5055);
                    r.subject = entity.getId();
                    r.addDesc(entity);
                    addReport(r);
                    // add a piloting roll and resolve immediately
                    game.addPSR(new PilotingRollData(entity.getId(), 3, "reactor shutdown"));
                    addReport(resolvePilotingRolls());
                    // okay, now mark shut down
                    entity.setShutDown(true);
                } else if (entity.heat >= 14) {
                    int shutdown = 4 + (entity.heat - 14) / 4 * 2;
                    if (mtHeat) {
                        shutdown -= 5;
                        switch (entity.crew.getPiloting()) {
                        case 0:
                        case 1:
                            shutdown -= 2;
                            break;
                        case 2:
                        case 3:
                            shutdown -= 1;
                            break;
                        case 6:
                        case 7:
                            shutdown += 1;
                        }
                        if (entity instanceof QuadMech) {
                            shutdown -= 2;
                        }
                    }
                    int sdroll = Compute.d6(2);
                    r = new Report(5060);
                    r.subject = entity.getId();
                    r.addDesc(entity);
                    r.add(shutdown);
                    r.add(sdroll);
                    if (sdroll >= shutdown) {
                        // avoided
                        r.choose(true);
                        addReport(r);
                    } else {
                        // shutting down...
                        r.choose(false);
                        addReport(r);
                        // add a piloting roll and resolve immediately
                        game.addPSR(new PilotingRollData(entity.getId(), 3, "reactor shutdown"));
                        addReport(resolvePilotingRolls());
                        // okay, now mark shut down
                        entity.setShutDown(true);
                    }
                }
View Full Code Here

            final Entity entity = i.nextElement();
            if (entity instanceof Mech) {
                // if this mech has 20+ damage, add another roll to the list.
                if (entity.damageThisPhase >= 20) {
                    if (game.getOptions().booleanOption("tacops_taking_damage")) {
                        PilotingRollData damPRD = new PilotingRollData(entity.getId());
                        int damMod = entity.damageThisPhase / 20;
                        damPRD.addModifier(damMod, damMod*20+"+ damage");
                        int weightMod = 0;
                        if (game.getOptions().booleanOption("tacops_physical_psr")) {
                            switch (entity.getWeightClass()) {
                            case EntityWeightClass.WEIGHT_LIGHT:
                                weightMod = 1;
                                break;
                            case EntityWeightClass.WEIGHT_MEDIUM:
                                weightMod = 0;
                                break;
                            case EntityWeightClass.WEIGHT_HEAVY:
                                weightMod = -1;
                                break;
                            case EntityWeightClass.WEIGHT_ASSAULT:
                                weightMod = -2;
                                break;
                            }
                            // the weight class PSR modifier is not cumulative
                            damPRD.addModifier(weightMod, "weight class modifier", false);
                        }game.addPSR(damPRD);
                    } else {
                        game.addPSR(new PilotingRollData(entity.getId(), 1, "20+ damage"));
                    }
                }
            }
            if ((entity instanceof Aero) && game.getBoard().inAtmosphere()) {
                // if this aero has any damage, add another roll to the list.
                if (entity.damageThisPhase > 0) {
                    if(!game.getOptions().booleanOption("atmospheric_control")) {
                        int damMod = entity.damageThisPhase / 20;
                        StringBuffer reportStr = new StringBuffer();
                        reportStr.append(entity.damageThisPhase).append(" damage +").append(damMod);
                        PilotingRollData damPRD = new PilotingRollData(entity.getId(), damMod, reportStr.toString());
                        game.addControlRoll(damPRD);
                    } else {
                        //was the damage threshold exceeded this round?
                        if(((Aero)entity).wasCritThresh()) {
                            PilotingRollData damThresh = new PilotingRollData(entity.getId(), 0, "damage threshold exceeded");
                            game.addControlRoll(damThresh);
                        }
                    }
                }
            }
View Full Code Here

            return vPhaseReport;
        }
        Report r;

        // first, do extreme gravity PSR, because non-mechs do these, too
        PilotingRollData rollTarget = null;
        for (Enumeration<PilotingRollData> i = game.getExtremeGravityPSRs(); i.hasMoreElements();) {
            final PilotingRollData roll = i.nextElement();
            if (roll.getEntityId() != entity.getId()) {
                continue;
            }
            // found a roll, use it (there can be only 1 per entity)
            rollTarget = roll;
            game.resetExtremeGravityPSRs(entity);
        }
        if ((rollTarget != null) && (rollTarget.getValue() != TargetRoll.CHECK_FALSE)) {
            // okay, print the info
            r = new Report(2180);
            r.subject = entity.getId();
            r.addDesc(entity);
            r.add(rollTarget.getLastPlainDesc());
            vPhaseReport.add(r);
            // roll
            final int diceRoll = Compute.d6(2);
            r = new Report(2190);
            r.subject = entity.getId();
            r.add(rollTarget.getValueAsString());
            r.add(rollTarget.getDesc());
            r.add(diceRoll);
            if (diceRoll < rollTarget.getValue()) {
                r.choose(false);
                vPhaseReport.add(r);
                // walking and running, 1 damage per MP used more than we would
                // have normally
                if ((entity.moved == IEntityMovementType.MOVE_WALK) || (entity.moved == IEntityMovementType.MOVE_VTOL_WALK) || (entity.moved == IEntityMovementType.MOVE_RUN) || (entity.moved == IEntityMovementType.MOVE_VTOL_RUN)) {
                    if (entity instanceof Mech) {
                        int j = entity.mpUsed;
                        int damage = 0;
                        while (j > entity.getRunMP(false, false)) {
                            j--;
                            damage++;
                        }
                        // Wee, direct internal damage
                        vPhaseReport.addAll(doExtremeGravityDamage(entity, damage));
                    } else if (entity instanceof Tank) {
                        // if we got a pavement bonus, take care of it
                        int k = entity.gotPavementBonus ? 1 : 0;
                        if (!entity.gotPavementBonus) {
                            int j = entity.mpUsed;
                            int damage = 0;
                            while (j > entity.getRunMP(false, false) + k) {
                                j--;
                                damage++;
                            }
                            vPhaseReport.addAll(doExtremeGravityDamage(entity, damage));
                        }
                    }
                }
                // jumping
                if ((entity.moved == IEntityMovementType.MOVE_JUMP) && (entity instanceof Mech)) {
                    // low g, 1 damage for each hex jumped further than
                    // possible normally
                    if (game.getPlanetaryConditions().getGravity() < 1) {
                        int j = entity.mpUsed;
                        int damage = 0;
                        while (j > entity.getJumpMP(false)) {
                            j--;
                            damage++;
                        }
                        // Wee, direct internal damage
                        vPhaseReport.addAll(doExtremeGravityDamage(entity, damage));
                    }
                    // high g, 1 damage for each MP we have less than normally
                    else if (game.getPlanetaryConditions().getGravity() > 1) {
                        int damage = entity.getWalkMP(false, false) - entity.getWalkMP();
                        // Wee, direct internal damage
                        vPhaseReport.addAll(doExtremeGravityDamage(entity, damage));
                    }
                }
                // failed a PSR, check for ICE engine stalling
                entity.doCheckEngineStallRoll(vPhaseReport);
            } else {
                r.choose(true);
                vPhaseReport.add(r);
            }
        }
        // non mechs and prone mechs can now return
        if (!(entity instanceof Mech) || entity.isProne() || (entity.isHullDown() && entity.canGoHullDown()) ) {
            return vPhaseReport;
        }

        // Mechs with UMU float and don't have to roll???
        if (entity instanceof Mech) {
            IHex hex = game.getBoard().getHex(dest);
            int water = hex.terrainLevel(Terrains.WATER);
            if ((water > 0) && (entity.getElevation() != -hex.depth()) && ((entity.getElevation() < 0) || ((entity.getElevation() == 0) && (hex.terrainLevel(Terrains.BRIDGE_ELEV) != 0) && !hex.containsTerrain(Terrains.ICE))) && !entity.isMakingDfa()) {
                // mech is floating in water....
                if (entity.hasUMU()) {
                    return vPhaseReport;
                }
                game.addPSR(new PilotingRollData(entity.getId(), TargetRoll.AUTOMATIC_FAIL, "lost buoyancy"));
            }
        }
        // add all cumulative mods from other rolls to each PSR
        // holds all rolls to make
        Vector<PilotingRollData> rolls = new Vector<PilotingRollData>();
        // holds the initial reason for each roll
        StringBuffer reasons = new StringBuffer();
        PilotingRollData base = entity.getBasePilotingRoll();
        entity.addPilotingModifierForTerrain(base);
        for (Enumeration<PilotingRollData> i = game.getPSRs(); i.hasMoreElements();) {
            PilotingRollData psr = i.nextElement();
            if (psr.getEntityId() != entity.getId()) {
                continue;
            }
            // found a roll
            if (reasons.length() > 0) {
                reasons.append("; ");
            }
            reasons.append(psr.getPlainDesc());
            PilotingRollData toUse = entity.getBasePilotingRoll();
            entity.addPilotingModifierForTerrain(toUse);
            toUse.append(psr);
            // now, append all other roll's cumulative mods, not the non-cumulative
            // ones
            for (Enumeration<PilotingRollData> j = game.getPSRs(); j.hasMoreElements();) {
                final PilotingRollData other = j.nextElement();
                if ((other.getEntityId() != entity.getId()) || other.equals(psr)) {
                    continue;
                }
                toUse.append(other, false);
            }
            rolls.add(toUse);
        }
        // any rolls needed?
        if (rolls.size() == 0) {
            return vPhaseReport;
        }
        // is our base roll impossible?
        if ((base.getValue() == TargetRoll.AUTOMATIC_FAIL) || (base.getValue() == TargetRoll.IMPOSSIBLE)) {
            r = new Report(2275);
            r.subject = entity.getId();
            r.addDesc(entity);
            r.add(rolls.size());
            r.add(base.getDesc()); // international issue
            vPhaseReport.add(r);
            if (moving) {
                vPhaseReport.addAll(doEntityFallsInto(entity, src, dest, base));
            } else if ( (entity instanceof Mech)
                    && game.getOptions().booleanOption("tacops_falling_expanded")
                    && (entity.getCrew().getPiloting() < 6)
                    && !entity.isHullDown()
                    && entity.canGoHullDown()){
                if ( entity.isHullDown() && entity.canGoHullDown() ){
                    r = new Report (2317);
                    r.subject = entity.getId();
                    r.add(entity.getDisplayName());
                    vPhaseReport.add(r);
                }else{
                    vPhaseReport.addAll(doEntityFall(entity, base));
                }
            } else {
                vPhaseReport.addAll(doEntityFall(entity, base));
            }
            // failed a PSR, check for ICE engine stalling
            entity.doCheckEngineStallRoll(vPhaseReport);
            return vPhaseReport;
        }
        // loop thru rolls we do have to make...
        r = new Report(2280);
        r.subject = entity.getId();
        r.addDesc(entity);
        r.add(rolls.size());
        r.add(reasons.toString()); // international issue
        vPhaseReport.add(r);
        r = new Report(2285);
        r.subject = entity.getId();
        r.add(base.getValueAsString());
        r.add(base.getDesc()); // international issue
        vPhaseReport.add(r);
        for (int i = 0; i < rolls.size(); i++) {
            PilotingRollData roll = rolls.elementAt(i);
            r = new Report(2290);
            r.subject = entity.getId();
            r.indent();
            r.newlines = 0;
            r.add(i + 1);
            r.add(roll.getDesc()); // international issue
            vPhaseReport.add(r);
            if ((roll.getValue() == TargetRoll.AUTOMATIC_FAIL) || (roll.getValue() == TargetRoll.IMPOSSIBLE)) {
                r = new Report(2295);
                r.subject = entity.getId();
                vPhaseReport.add(r);
                if (moving) {
                    vPhaseReport.addAll(doEntityFallsInto(entity, src, dest, roll));
                } else {
                    if ( (entity instanceof Mech)
                            && game.getOptions().booleanOption("tacops_falling_expanded")
                            && (entity.getCrew().getPiloting() < 6)
                            && !entity.isHullDown()
                            && entity.canGoHullDown()){
                        if ( entity.isHullDown() && entity.canGoHullDown() ){
                            r = new Report (2317);
                            r.subject = entity.getId();
                            r.add(entity.getDisplayName());
                            vPhaseReport.add(r);
                        }else{
                            vPhaseReport.addAll(doEntityFall(entity, roll));
                        }
                    }else {
                        vPhaseReport.addAll(doEntityFall(entity, roll));
                    }
                }
                // failed a PSR, check for ICE engine stalling
                entity.doCheckEngineStallRoll(vPhaseReport);
                return vPhaseReport;
            } else {
                int diceRoll = Compute.d6(2);
                r = new Report(2300);
                r.add(roll.getValueAsString());
                r.add(diceRoll);
                r.subject = entity.getId();
                if (diceRoll < roll.getValue()) {
                    r.choose(false);
                    vPhaseReport.add(r);
                    if (moving) {
                        vPhaseReport.addAll(doEntityFallsInto(entity, src, dest, roll));
                    } else {
                        if ( (entity instanceof Mech)
                                && game.getOptions().booleanOption("tacops_falling_expanded")
                                && (entity.getCrew().getPiloting() < 6)
                                && !entity.isHullDown()
                                && entity.canGoHullDown()){
                            if ( (entity.getCrew().getPiloting() > 1) && (roll.getValue() - diceRoll < 2)){
                                entity.setHullDown(true);
                            }else if ( (entity.getCrew().getPiloting() <= 1) && (roll.getValue() - diceRoll < 3) ){
                                entity.setHullDown(true);
                            }
                            if ( entity.isHullDown() && entity.canGoHullDown() ){
                                r = new Report (2317);
                                r.subject = entity.getId();
View Full Code Here

            if (!a.isRandomMove()) {

                // find control rolls and make them
                Vector<PilotingRollData> rolls = new Vector<PilotingRollData>();
                StringBuffer reasons = new StringBuffer();
                PilotingRollData base = e.getBasePilotingRoll();
                for (Enumeration<PilotingRollData> j = game.getControlRolls(); j.hasMoreElements();) {
                    final PilotingRollData modifier = j.nextElement();
                    if (modifier.getEntityId() != e.getId()) {
                        continue;
                    }
                    // found a roll, add it
                    rolls.addElement(modifier);
                    if (reasons.length() > 0) {
                        reasons.append("; ");
                    }
                    reasons.append(modifier.getCumulativePlainDesc());
                    base.append(modifier);
                }
                // any rolls needed?
                if (rolls.size() > 0) {
                    // loop thru rolls we do have to make...
                    r = new Report(9310);
                    r.subject = e.getId();
                    r.addDesc(e);
                    r.add(rolls.size());
                    r.add(reasons.toString()); // international issue
                    vReport.add(r);
                    r = new Report(2285);
                    r.subject = e.getId();
                    r.add(base.getValueAsString());
                    r.add(base.getDesc()); // international issue
                    vReport.add(r);
                    for (int j = 0; j < rolls.size(); j++) {
                        PilotingRollData modifier = rolls.elementAt(j);
                        PilotingRollData target = base;
                        r = new Report(2290);
                        r.subject = e.getId();
                        r.indent();
                        r.newlines = 0;
                        r.add(j + 1);
                        r.add(modifier.getPlainDesc()); // international issue
                        vReport.add(r);
                        int diceRoll = Compute.d6(2);
                        // different reports depending on out-of-control status
                        if (a.isOutControl()) {
                            r = new Report(9360);
                            r.subject = e.getId();
                            r.add(target.getValueAsString());
                            r.add(diceRoll);
                            if (diceRoll < (target.getValue() - 5)) {
                                r.choose(false);
                                vReport.add(r);
                                a.setRandomMove(true);
                            } else {
                                r.choose(true);
                                vReport.add(r);
                            }
                        } else {
                            r = new Report(9315);
                            r.subject = e.getId();
                            r.add(target.getValueAsString());
                            r.add(diceRoll);
                            r.newlines = 1;
                            if (diceRoll < target.getValue()) {
                                r.choose(false);
                                vReport.add(r);
                                a.setOutControl(true);
                                // do we have random movement?
                                if ((target.getValue() - diceRoll) > 5) {
                                    r = new Report(9365);
                                    r.newlines = 0;
                                    r.subject = e.getId();
                                    vReport.add(r);
                                    a.setRandomMove(true);
                                }
                                // if on the atmospheric map, then lose altitude
                                // and check
                                // for crash
                                if (game.getBoard().inAtmosphere()) {
                                    int loss = Compute.d6(1);
                                    r = new Report(9366);
                                    r.newlines = 0;
                                    r.subject = e.getId();
                                    r.addDesc(e);
                                    r.add(loss);
                                    vReport.add(r);
                                    // check for crash
                                    if ((a.getElevation() - loss) <= game.getBoard().getHex(a.getPosition()).ceiling()) {
                                        a.setElevation(game.getBoard().getHex(a.getPosition()).surface());
                                        vReport.addAll(processCrash(e, a.getCurrentVelocity()));
                                    } else {
                                        a.setElevation(a.getElevation() - loss);
                                    }
                                }
                            } else {
                                r.choose(true);
                                vReport.add(r);
                            }
                        }
                    }
                }
            }

            // if they were out-of-control to start with, give them a chance to
            // regain control
            if (canRecover) {
                PilotingRollData base = e.getBasePilotingRoll();
                // is our base roll impossible?
                if ((base.getValue() == TargetRoll.AUTOMATIC_FAIL) || (base.getValue() == TargetRoll.IMPOSSIBLE)) {
                    // report something
                    r = new Report(9340);
                    r.subject = e.getId();
                    r.addDesc(e);
                    r.add(base.getDesc()); // international issue
                    vReport.add(r);
                    return vReport;
                }
                r = new Report(9345);
                r.subject = e.getId();
                r.addDesc(e);
                r.add(base.getDesc()); // international issue
                vReport.add(r);
                int diceRoll = Compute.d6(2);
                r = new Report(9350);
                r.subject = e.getId();
                r.add(base.getValueAsString());
                r.add(diceRoll);
                if (diceRoll < base.getValue()) {
                    r.choose(false);
                    vReport.add(r);
                } else {
                    r.choose(true);
                    vReport.add(r);
View Full Code Here

     *
     * @param entity
     *            the <code>Entity</code> for which to resolve it
     */
    public void doAssaultDrop(Entity entity) {
        PilotingRollData psr;
        if (entity instanceof Mech) {
            psr = entity.getBasePilotingRoll();
        } else {
            psr = new PilotingRollData(entity.getId(), 4, "landing assault drop");
        }
        int roll = Compute.d6(2);
        // check for a safe landing
        Report r = new Report(2380);
        r.subject = entity.getId();
        r.add(entity.getDisplayName(), true);
        r.add(psr.getValueAsString());
        r.add(roll);
        r.choose(roll >= psr.getValue());
        addReport(r);
        if (roll < psr.getValue()) {
            int fallHeight = psr.getValue() - roll;
            // determine where we really land
            int distance = Compute.d6(fallHeight);
            Coords c = Compute.scatterAssaultDrop(entity.getPosition(), fallHeight);
            r = new Report(2385);
            r.subject = entity.getId();
View Full Code Here

TOP

Related Classes of megamek.common.PilotingRollData

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.