⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mech.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
                usedMASC = true;                r = new Report(2365);                r.subject = this.getId();                r.addDesc(this);                r.add(equip.getName());                vDesc.addElement(r);                r = new Report(2370);                r.subject = this.getId();                r.indent();                r.add(getMASCTarget());                r.add(nRoll);                if (nRoll < getMASCTarget()) {                    // uh oh                    bFailure = true;                    r.choose(false);                    vDesc.addElement(r);                    if(((MiscType)(equip.getType())).hasSubType(MiscType.S_SUPERCHARGER)) {                        // do the damage - engine crits                        int hits = 0;                        int roll = Compute.d6(2);                        r = new Report(6310);                        r.subject = getId();                        r.add(roll);                        r.newlines = 0;                        vDesc.addElement(r);                        if (roll <= 7) {                            //no effect                            r = new Report(6005);                            r.subject = getId();                            r.newlines = 0;                            vDesc.addElement(r);                        } else if (roll >= 8 && roll <= 9) {                            hits = 1;                            r = new Report(6315);                            r.subject = getId();                            r.newlines = 0;                            vDesc.addElement(r);                        } else if (roll >= 10 && roll <= 11) {                            hits = 2;                            r = new Report(6320);                            r.subject = getId();                            r.newlines = 0;                            vDesc.addElement(r);                        } else if (roll == 12) {                            hits = 3;                            r = new Report(6325);                            r.subject = getId();                            r.newlines = 0;                            vDesc.addElement(r);                        }                        for(int i=0;i<12 && hits > 0;i++) {                            CriticalSlot cs = getCritical(LOC_CT, i);                            if(cs.getType() == CriticalSlot.TYPE_SYSTEM && cs.getIndex() == SYSTEM_ENGINE) {                                vCriticals.add(new Integer(LOC_CT));                                vCriticals.add(cs);                                //vDesc.addAll(server.applyCriticalHit(this, LOC_CT, cs, true));                                hits--;                            }                        }                    } else {                        // do the damage.  Rules say 'effects identical as if you took 2 hip crits'.                         // We'll just do the hip crits                        vCriticals.add(new Integer(LOC_RLEG));                        vCriticals.add(getCritical(LOC_RLEG, 0));                        vCriticals.add(new Integer(LOC_LLEG));                        vCriticals.add(getCritical(LOC_LLEG, 0));                        //getCritical(LOC_RLEG, 0).setDestroyed(true);                        //getCritical(LOC_LLEG, 0).setDestroyed(true);                        if (this instanceof QuadMech) {                            //getCritical(LOC_RARM, 0).setDestroyed(true);                            //getCritical(LOC_LARM, 0).setDestroyed(true);                        vCriticals.add(new Integer(LOC_RARM));                        vCriticals.add(getCritical(LOC_RARM, 0));                        vCriticals.add(new Integer(LOC_LARM));                        vCriticals.add(getCritical(LOC_LARM, 0));                        }                    }                    if (equip.getType().hasFlag(MiscType.F_MASC)) {                        equip.setDestroyed(true);                        equip.setMode("Off");                    }                } else {                    r.choose(true);                    vDesc.addElement(r);                }            }            return bFailure;        }        return false;    }    /**     * OmniMechs have handles for Battle Armor squads to latch onto. Please     * note, this method should only be called during this Mech's construction.     * <p/>     * Overrides <code>Entity#setOmni(boolean)</code>     */    public void setOmni( boolean omni ) {        // Perform the superclass' action.        super.setOmni( omni );        // Add BattleArmorHandles to OmniMechs.        if ( omni && !hasBattleArmorHandles()) {            this.addTransporter( new BattleArmorHandles() );        }    }    /**     * Returns the number of locations in the entity     */    public int locations() {        return NUM_MECH_LOCATIONS;    }        /**     * Override Entity#newRound() method.     */    public void newRound(int roundNumber) {        // Walk through the Mech's miscellaneous equipment before        // we apply our parent class' newRound() functionality        // because Mek Stealth is set by the Entity#newRound() method.        for (Mounted m : getMisc()) {            MiscType mtype = (MiscType) m.getType();            // Stealth can not be turned on if it's ECM is destroyed.            if (Mech.STEALTH.equals(mtype.getInternalName())                    && m.getLinked().isDestroyed()                    && m.getLinked().isBreached()) {                m.setMode("Off");            }        } // Check the next piece of equipment.        super.newRound(roundNumber);        // If MASC was used last turn, increment the counter,        // otherwise decrement.  Then, clear the counter         if (usedMASC) {            nMASCLevel++;            bMASCWentUp = true;        } else {            nMASCLevel = Math.max(0, nMASCLevel - 1);            if (bMASCWentUp) {                nMASCLevel = Math.max(0, nMASCLevel - 1);                bMASCWentUp = false;            }        }        // Clear the MASC flag         usedMASC = false;        setSecondaryFacing(getFacing());        // set heat sinks        sinksOn = sinksOnNextRound;        // update cockpit status        cockpitStatus = cockpitStatusNextRound;    } // End public void newRound()    /**     * Returns true if the location in question is a torso location     */    public boolean locationIsTorso(int loc) {        return loc == LOC_CT || loc == LOC_RT || loc == LOC_LT;    }        /**     * Returns true if the location in question is a leg     */    public boolean locationIsLeg(int loc) {        return loc == LOC_LLEG || loc == LOC_RLEG;    }                                        /**     * Count the number of destroyed or breached legs on the mech     */    public int countBadLegs() {        int badLegs = 0;        for (int i = 0; i < locations(); i++) {            badLegs += (locationIsLeg(i) && isLocationBad(i)) ? 1 : 0;        }        return badLegs;    }    /**     * Returns true if the entity has a hip crit.     */    public boolean hasHipCrit() {        for ( int loc = 0; loc < NUM_MECH_LOCATIONS; loc++ ) {            if ( legHasHipCrit( loc ) ) {                return true;            }        }        return false;    }    /**     * Return true is the location is a leg and has a hip crit     */       public boolean legHasHipCrit(int loc) {        if (isLocationBad(loc)) {            return false;        }                  if (locationIsLeg(loc)) {            return (getGoodCriticals(CriticalSlot.TYPE_SYSTEM,                                     Mech.ACTUATOR_HIP, loc) == 0);        }                return false;    }        /**     * Count non-hip leg actuator crits     */    public int countLegActuatorCrits(int loc) {        if (isLocationBad(loc)) {            return 0;        }                  int legCrits = 0;                if (locationIsLeg(loc)) {            if (getGoodCriticals(CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_UPPER_LEG, loc) == 0) {                legCrits++;            }            if (getGoodCriticals(CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_LOWER_LEG, loc) == 0) {                legCrits++;            }            if (getGoodCriticals(CriticalSlot.TYPE_SYSTEM, Mech.ACTUATOR_FOOT, loc) == 0) {                legCrits++;            }        }        return legCrits;    }    public boolean hasCompositeStructure() {        return (getStructureType() == EquipmentType.T_STRUCTURE_COMPOSITE);    }    public boolean hasReinforcedStructure() {        return (getStructureType() == EquipmentType.T_STRUCTURE_REINFORCED);    }    public boolean hasMASC() {        for (Mounted mEquip : getMisc()) {            MiscType mtype = (MiscType) mEquip.getType();            if (mtype.hasFlag(MiscType.F_MASC)) {                return true;            }        }        return false;    }    public Mounted getMASC() {        for (Mounted m : getMisc()) {            MiscType mtype = (MiscType)m.getType();            if (mtype.hasFlag(MiscType.F_MASC) && m.isReady()) {                return m;            }        }        return null;    }    /**     * Checks if a mech has an armed MASC system. Note     *  that the mech will have to exceed its normal run to actually     *  engage the MASC system     */    public boolean hasArmedMASC() {        for (Mounted m : getEquipment()){            if (!m.isDestroyed() && !m.isBreached() && m.getType() instanceof MiscType &&                m.getType().hasFlag(MiscType.F_MASC)                && m.curMode().equals("Armed")) {                return true;            }        }        return false;    }        /**     * Same     */    public boolean hasTSM() {        for (Mounted m : getEquipment()){            if (m.getType() instanceof MiscType && m.getType().hasFlag(MiscType.F_TSM)) {                return true;            }        }        return false;    }    public boolean hasStealth() {        for (Mounted mEquip : getMisc()) {            MiscType mtype = (MiscType) mEquip.getType();            if ( mtype.hasFlag(MiscType.F_STEALTH) ) {                // The Mek has Stealth Armor or null signature system.                return true;            }        }        return false;    }    /**     * Depends on engine type     */    public int getStandingHeat() {        return engine.getStandingHeat();    }    public void setEngine(Engine e) {        engine = e;        if (e.engineValid) {            setOriginalWalkMP(calculateWalk());        }    }    protected int calculateWalk() {        return getEngine().getRating() / (int)this.weight;    }    /**     * Depends on engine type     */    public int getWalkHeat() {        return engine.getWalkHeat();    }    /**     * Potentially adjust runMP for MASC     */        public int getRunMP(boolean gravity) {        if (hasArmedMASC()) {            return (getWalkMP(gravity) * 2)-(getArmorType()==EquipmentType.T_ARMOR_HARDENED?1:0);        }        return super.getRunMP(gravity)-(getArmorType()==EquipmentType.T_ARMOR_HARDENED?1:0);    }    /**     * Returns run MP without considering MASC     */

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -