Package megamek.common

Examples of megamek.common.CriticalSlot


            // Walk through the slots in this location.
            for (int loop = 0; loop < entity.getNumberOfCriticals(loc); loop++) {

                // Get this slot.
                CriticalSlot slot = entity.getCritical(loc, loop);

                // Did we get a slot?
                if (null == slot) {

                    // Nope. Record missing actuators on Biped Mechs.
                    if (isMech && !entity.entityIsQuad()
                            && ((loc == Mech.LOC_RARM) || (loc == Mech.LOC_LARM))
                            && ((loop == 2) || (loop == 3))) {
                        output.append("<slot index=\"");
                        output.append(String.valueOf(loop + 1));
                        output.append("\" type=\"Empty\"/>");
                    }

                } else {

                    // Yup. If the equipment isn't a system, get it.
                    Mounted mount = null;
                    if (CriticalSlot.TYPE_EQUIPMENT == slot.getType()) {
                        mount = entity.getEquipment(slot.getIndex());
                    }

                    // Format the slot.
                    output.append(formatSlot(slot, mount));
View Full Code Here


    public int countCriticalSlotsFromEquipInLocation(Entity entity, int eNum,
            int location) {
        int count = 0;
        for (int slots = 0; slots < entity.getNumberOfCriticals(location); slots++) {
            CriticalSlot slot = entity.getCritical(location, slots);
            if ((slot == null) || (slot.getType() == CriticalSlot.TYPE_SYSTEM)) {
                continue;
            } else if (slot.getType() == CriticalSlot.TYPE_EQUIPMENT) {
                if (slot.getIndex() == eNum) {
                    count++;
                }
            } else {
                // Ignore this?
            }
View Full Code Here

    public float getArmoredComponentWeight() {
        float weight = 0.0f;

        for (int location = Mech.LOC_HEAD; location <= Mech.LOC_LLEG; location++) {
            for (int slot = 0; slot < mech.getNumberOfCriticals(location); slot++) {
                CriticalSlot cs = mech.getCritical(location, slot);
                if ((cs != null) && cs.isArmored()) {
                    weight += 0.5f;

                    if ((cs.getType() == CriticalSlot.TYPE_SYSTEM) && (cs.getIndex() == Mech.SYSTEM_COCKPIT)) {
                        weight += 0.5f;
                    }
                }
            }
        }
View Full Code Here

                    // Make sure that we have crit spot to hit
                    if (chp.entity instanceof Mech
                            || chp.entity instanceof Protomech) {

                        // Is this a torso weapon slot?
                        CriticalSlot cs = null;
                        if (chp.entity instanceof Protomech
                                && Protomech.LOC_TORSO == ch.loc
                                && (Protomech.SYSTEM_TORSO_WEAPON_A == ch.slot || Protomech.SYSTEM_TORSO_WEAPON_B == ch.slot)) {
                            cs = new CriticalSlot(CriticalSlot.TYPE_SYSTEM,
                                    ch.slot);
                        }
                        // Is this a valid slot number?
                        else if (ch.slot < 0
                                || ch.slot > chp.entity
                                        .getNumberOfCriticals(ch.loc)) {
                            System.out.println("\n\tInvalid Slot Specified "
                                    + ch.loc + ":" + (ch.slot + 1));
                        }
                        // Get the slot from the entity.
                        else {
                            cs = chp.entity.getCritical(ch.loc, ch.slot);
                        }

                        // Ignore invalid, unhittable, and damaged slots.
                        if (null == cs || !cs.isHittable()) {
                            System.out.println("\n\tSlot not hittable "
                                    + ch.loc + ":" + (ch.slot + 1));
                        } else {
                            System.out
                                    .print("[s.applyCriticalHit(chp.entity, ch.loc, cs, false)]");
                            s.applyCriticalHit(chp.entity, ch.loc, cs, false);
                        }
                    }
                    // Handle Tanks differently.
                    else if (chp.entity instanceof Tank) {
                        if (ch.slot < 0 || ch.slot >= 6) {
                            System.out.println("\n\tInvalid Slot Specified "
                                    + ch.loc + ":" + (ch.slot + 1));
                        } else {
                            CriticalSlot cs = new CriticalSlot(
                                    CriticalSlot.TYPE_SYSTEM, ch.slot + 1);
                            System.out
                                    .print("[s.applyCriticalHit(chp.entity, ch.loc, cs, false)]");
                            s.applyCriticalHit(chp.entity, Entity.NONE, cs,
                                    false);
                        }

                    } // End have-tank

                } // End have-valid-location

            } // Handle the next critical hit

            // Print a line between hit plans.
            System.out.println();

        } // Handle the next critical hit plan

        // Loop throught Set Ammo To
        for (int saSpot = 0, saCount = m_vSetAmmoTo.size(); saSpot < saCount; saSpot++) {
            SetAmmoPlan sap = m_vSetAmmoTo.elementAt(saSpot);
            System.out.println("Applying Ammo Adjustment to "
                    + sap.entity.getShortName());

            for (int sapSpot = 0, sapCount = sap.ammoSetTo.size(); sapSpot < sapCount; sapSpot++) {
                // Get the ScritHit
                SetAmmoTo sa = sap.ammoSetTo.elementAt(sapSpot);

                // Only can be done against Mechs
                if (sap.entity instanceof Mech) {
                    if (sa.slot < sap.entity.getNumberOfCriticals(sa.loc)) {
                        // Get the piece of Eqipment and Check to make sure it
                        // is
                        // a ammo item then set its amount!
                        CriticalSlot cs = sap.entity.getCritical(sa.loc,
                                sa.slot);
                        if (!(cs == null)) {
                            Mounted ammo = sap.entity.getEquipment(sap.entity
                                    .getCritical(sa.loc, sa.slot).getIndex());
                            if (ammo.getType() instanceof AmmoType) {
View Full Code Here

        for (int x = 0; x < e.locations(); x++) {
            sb.append(StringUtil.makeLength(e.getLocationName(x), 12)).append(
                    ": ");
            int nCount = 0;
            for (int y = 0; y < e.getNumberOfCriticals(x); y++) {
                CriticalSlot cs = e.getCritical(x, y);
                if (cs == null)
                    continue;
                nCount++;
                if (nCount == 7) {
                    sb.append(CommonConstants.NL);
                    sb.append("              ");
                } else if (nCount > 1) {
                    sb.append(",");
                }
                if (cs.getType() == CriticalSlot.TYPE_SYSTEM) {
                    if (cs.isHit() || cs.isDestroyed() || cs.isMissing()) {
                        sb.append("*");
                    }
                    if (e instanceof Mech) {
                        sb.append(((Mech) e).getSystemName(cs.getIndex()));
                    } else if (e instanceof Protomech) {
                        sb.append(Protomech.systemNames[cs.getIndex()]);
                    }
                } else if (cs.getType() == CriticalSlot.TYPE_EQUIPMENT) {
                    Mounted m = e.getEquipment(cs.getIndex());
                    sb
                            .append(cs.isHit() ? "*" : "").append(cs.isDestroyed() ? "*" : "").append(cs.isBreached() ? "x" : "").append(m.getDesc()); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
                }
            }
            sb.append(CommonConstants.NL);
        }
        return sb.toString();
View Full Code Here

            weapon.setJammed(false);
            weapon.setHit(true);
            int wlocation = weapon.getLocation();
            weapon.setDestroyed(true);
            for (int i = 0; i < ae.getNumberOfCriticals(wlocation); i++) {
                CriticalSlot slot1 = ae.getCritical(wlocation, i);
                if ((slot1 == null) || (slot1.getType() != CriticalSlot.TYPE_SYSTEM)) {
                    continue;
                }
                Mounted mounted = ae.getEquipment(slot1.getIndex());
                if (mounted.equals(weapon)) {
                    ae.hitAllCriticals(wlocation, i);
                    break;
                }
            }
View Full Code Here

        for (int i = 0; i < getEntity().locations(); i++) {
            String locationName = getEntity().getLocationName(i);
            buff.append(locationName + ":");
            buff.append("\n");
            for (int j = 0; j < getEntity().getNumberOfCriticals(i); j++) {
                CriticalSlot slot = getEntity().getCritical(i, j);
                if (slot == null) {
                    buff.append(Integer.toString(j) + ". -Emtpy-");
                    buff.append("\n");
                } else if (slot.getType() == CriticalSlot.TYPE_SYSTEM) {
                    if (isMech()) {
                        buff.append(Integer.toString(j));
                        buff.append(". ");
                        buff.append(((Mech) getEntity()).getSystemName(slot
                                .getIndex()));
                        buff.append("\n");
                    } else {
                        buff.append(Integer.toString(j)
                                + ". UNKNOWN SYSTEM NAME");
                        buff.append("\n");
                    }
                } else if (slot.getType() == CriticalSlot.TYPE_EQUIPMENT) {
                    Mounted m = getEntity().getEquipment(slot.getIndex());

                    buff.append(Integer.toString(j) + ". "
                            + m.getType().getInternalName());
                    buff.append("\n");
                }
View Full Code Here

            if (dieRoll < rollTarget) {
                // Oops, we ruined our day...
                int wlocation = weapon.getLocation();
                weapon.setDestroyed(true);
                for (int i = 0; i < ae.getNumberOfCriticals(wlocation); i++) {
                    CriticalSlot slot1 = ae.getCritical(wlocation, i);
                    if ((slot1 == null)
                            || (slot1.getType() != CriticalSlot.TYPE_SYSTEM)) {
                        continue;
                    }
                    Mounted mounted = ae.getEquipment(slot1.getIndex());
                    if (mounted.equals(weapon)) {
                        ae.hitAllCriticals(wlocation, i);
                    }
                }
                // Bug 1066147 : damage is *not* like an ammo explosion,
                // but it *does* get applied directly to the IS.
                r.choose(false);
                vPhaseReport.addElement(r);
                vPhaseReport.addAll(server.damageEntity(ae, new HitData(
                        wlocation), 10, false, DamageType.NONE, true));
                r = new Report(3185);
                r.subject = subjectId;
                vPhaseReport.addElement(r);
            } else {
                r.choose(true);
                vPhaseReport.addElement(r);
            }
        }
        // resolve roll for charged capacitor
        if (weapon.hasChargedCapacitor()) {
            if (roll == 2) {
                r = new Report(3178);
                r.subject = ae.getId();
                r.indent();
                vPhaseReport.add(r);
                // Oops, we ruined our day...
                int wlocation = weapon.getLocation();
                weapon.setDestroyed (true);
                for (int i=0; i<ae.getNumberOfCriticals(wlocation); i++) {
                    CriticalSlot slot = ae.getCritical (wlocation, i);
                    if ((slot == null) || (slot.getType() == CriticalSlot.TYPE_SYSTEM)) {
                        continue;
                    }
                    //Only one Crit needs to be damaged.
                    Mounted mounted = ae.getEquipment(slot.getIndex());
                    if (mounted.equals(weapon)) {
                        slot.setDestroyed(true);
                        break;
                    }
                }
            }
        }
View Full Code Here

                HashMap<Integer, CriticalSlot> crits = new HashMap<Integer, CriticalSlot>();
                Vector<Report> vReport = new Vector<Report>();
                if (((Mech) entity).checkForMASCFailure(md, vReport, crits)) {
                    addReport(vReport);
                    for (Integer loc : crits.keySet()) {
                        CriticalSlot cs = crits.get(loc);
                        addReport(applyCriticalHit(entity, loc, cs, true));
                    }
                    // do any PSR immediately
                    addReport(resolvePilotingRolls(entity));
                    game.resetPSRs(entity);
View Full Code Here

            }
            DamageType damageType = DamageType.NONE;
            addReport(damageEntity(te, hit, damage, false, damageType, false, false, throughFront));
            if (target instanceof VTOL) {
                // destroy rotor
                addReport(applyCriticalHit(te, VTOL.LOC_ROTOR, new CriticalSlot(CriticalSlot.TYPE_SYSTEM, VTOL.CRIT_ROTOR_DESTROYED), false));
            }
            //check for extending retractable blades
            if(paa.isBladeExtended(paa.getArm())) {
                addNewLines();
                r = new Report(4455);
View Full Code Here

TOP

Related Classes of megamek.common.CriticalSlot

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.