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

📄 mech.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 5 页
字号:
        }        // can't twist while prone        if (!canChangeSecondaryFacing()) {            return getFacing();        }        // otherwise, twist once in the appropriate direction        final int rotate = (dir + (6 - getFacing())) % 6;        return rotate >= 3 ? (getFacing() + 5) % 6 : (getFacing() + 1) % 6;    }        public boolean hasRearArmor(int loc) {        return loc == LOC_CT || loc == LOC_RT || loc == LOC_LT;    }        /**     * Returns the amount of armor in the location specified.  Mech version,     * handles rear armor.     */    public int getArmor(int loc, boolean rear) {        if (rear && hasRearArmor(loc)) {            return rearArmor[loc];        }		return super.getArmor(loc, rear);    }    /**     * Returns the original amount of armor in the location specified.  Mech version,     * handles rear armor.     */    public int getOArmor(int loc, boolean rear) {        if (rear && hasRearArmor(loc)) {            return orig_rearArmor[loc];        }		return super.getOArmor(loc, rear);    }    /**     * Sets the amount of armor in the location specified.  Mech version, handles     * rear armor.     */    public void setArmor(int val, int loc, boolean rear) {        if (rear && hasRearArmor(loc)) {            rearArmor[loc] = val;        } else {            super.setArmor(val, loc, rear);        }    }    /**     * Initializes the rear armor on the mech. Sets the original and starting point     * of the armor to the same number.     */      public void initializeRearArmor(int val, int loc) {        orig_rearArmor[loc] = val;        setArmor(val, loc, true);      }          /**     * Returns the Compute.ARC that the weapon fires into.     */    public int getWeaponArc(int wn) {        final Mounted mounted = getEquipment(wn);        // rear mounted?        if (mounted.isRearMounted()) {            return Compute.ARC_REAR;        }        // front mounted        switch(mounted.getLocation()) {        case LOC_HEAD :        case LOC_CT :        case LOC_RT :        case LOC_LT :        case LOC_RLEG :        case LOC_LLEG :            return Compute.ARC_FORWARD;        case LOC_RARM :            return getArmsFlipped() ? Compute.ARC_REAR : Compute.ARC_RIGHTARM;        case LOC_LARM :            return getArmsFlipped() ? Compute.ARC_REAR : Compute.ARC_LEFTARM;        default :            return Compute.ARC_360;        }    }    /**     * Returns true if this weapon fires into the secondary facing arc.  If     * false, assume it fires into the primary.     */    public boolean isSecondaryArcWeapon(int weaponId) {        // leg-mounted weapons fire into the primary arc, always        if (getEquipment(weaponId).getLocation() == LOC_RLEG || getEquipment(weaponId).getLocation() == LOC_LLEG) {            return false;        }        // other weapons into the secondary        return true;    }        /**     * Rolls up a hit location     */    public HitData rollHitLocation(int table, int side) {        return rollHitLocation(table, side, LOC_NONE, IAimingModes.AIM_MODE_NONE);    }         public HitData rollHitLocation(int table, int side, int aimedLocation, int aimingMode) {        int roll = -1;                if ((aimedLocation != LOC_NONE) &&            (aimingMode == IAimingModes.AIM_MODE_TARG_COMP)) {                return new HitData(aimedLocation, side == ToHitData.SIDE_REAR, true);                       }                if ((aimedLocation != LOC_NONE) &&            (aimingMode == IAimingModes.AIM_MODE_IMMOBILE)) {            roll = Compute.d6(2);                        if ((5 < roll) && (roll < 9)) {                return new HitData(aimedLocation, side == ToHitData.SIDE_REAR, true);            }        }        if(table == ToHitData.HIT_NORMAL || table == ToHitData.HIT_PARTIAL_COVER) {            roll = Compute.d6(2);            try {                PrintWriter pw = PreferenceManager.getClientPreferences().getMekHitLocLog();                if ( pw != null ) {                    pw.print( table );                    pw.print( "\t" );                    pw.print( side );                    pw.print( "\t" );                    pw.println( roll );                }            } catch ( Throwable thrown ) {                thrown.printStackTrace();            }            if(side == ToHitData.SIDE_FRONT) {                // normal front hits                if(game.getOptions().booleanOption("quad_hit_location")                        && isProne()) {                    switch( roll ) {                    case 2:                        if ((crew.hasEdgeRemaining() && crew.getOptions().booleanOption("edge_when_tac"))                             && !game.getOptions().booleanOption("no_tac")) {                            crew.decreaseEdge();                            HitData result =  rollHitLocation(table, side, aimedLocation, aimingMode);                            result.setUndoneLocation(tac(table, side, Mech.LOC_CT, false));                            return result;                        } // if                        return tac(table, side, Mech.LOC_CT, false);                    case 3:                        return new HitData(Mech.LOC_RLEG);                    case 4:                    case 5:                        return new HitData(Mech.LOC_RARM);                    case 6:                        return new HitData(Mech.LOC_RT);                    case 7:                        return new HitData(Mech.LOC_CT);                    case 8:                        return new HitData(Mech.LOC_LT);                    case 9:                    case 10:                        return new HitData(Mech.LOC_LARM);                    case 11:                        return new HitData(Mech.LOC_LLEG);                    case 12:                        if (crew.hasEdgeRemaining()                                && crew.getOptions().booleanOption("edge_when_headhit")) {                            crew.decreaseEdge();                            HitData result =  rollHitLocation(table, side, aimedLocation, aimingMode);                            result.setUndoneLocation(new HitData(Mech.LOC_HEAD));                            return result;                        } // if                        return new HitData(Mech.LOC_HEAD);                    }                } else {                    switch( roll ) {                    case 2:                         if ((crew.hasEdgeRemaining() && crew.getOptions().booleanOption("edge_when_tac"))                                && !game.getOptions().booleanOption("no_tac")) {                            crew.decreaseEdge();                            HitData result = rollHitLocation(table, side, aimedLocation, aimingMode);                            result.setUndoneLocation(tac(table, side, Mech.LOC_CT, false));                            return result;                        } // if                        return tac(table, side, Mech.LOC_CT, false);                    case 3:                    case 4:                        return new HitData(Mech.LOC_RARM);                    case 5:                        return new HitData(Mech.LOC_RLEG);                    case 6:                        return new HitData(Mech.LOC_RT);                    case 7:                        return new HitData(Mech.LOC_CT);                    case 8:                        return new HitData(Mech.LOC_LT);                    case 9:                        return new HitData(Mech.LOC_LLEG);                    case 10:                    case 11:                        return new HitData(Mech.LOC_LARM);                    case 12:                        if (crew.hasEdgeRemaining()                                && crew.getOptions().booleanOption("edge_when_headhit")) {                            crew.decreaseEdge();                            HitData result =  rollHitLocation(table, side, aimedLocation, aimingMode);                            result.setUndoneLocation(new HitData(Mech.LOC_HEAD));                            return result;                        } // if                        return new HitData(Mech.LOC_HEAD);                    }                }            }            else if(side == ToHitData.SIDE_LEFT) {                // normal left side hits                switch( roll ) {                case 2:                    if ((crew.hasEdgeRemaining() && crew.getOptions().booleanOption("edge_when_tac"))                            && !game.getOptions().booleanOption("no_tac")) {                        crew.decreaseEdge();                        HitData result = rollHitLocation(table, side, aimedLocation, aimingMode);                        result.setUndoneLocation(tac(table, side, Mech.LOC_LT, false));                        return result;                    } // if                    return tac(table, side, Mech.LOC_LT, false);                case 3:                    return new HitData(Mech.LOC_LLEG);                case 4:                case 5:                    return new HitData(Mech.LOC_LARM);                case 6:                    return new HitData(Mech.LOC_LLEG);                case 7:                    return new HitData(Mech.LOC_LT);                case 8:                    return new HitData(Mech.LOC_CT);                case 9:                    return new HitData(Mech.LOC_RT);                case 10:                    return new HitData(Mech.LOC_RARM);                case 11:                    return new HitData(Mech.LOC_RLEG);                case 12:                    if (crew.hasEdgeRemaining()                             && crew.getOptions().booleanOption("edge_when_headhit") ) {                        crew.decreaseEdge();                        HitData result =  rollHitLocation(table, side, aimedLocation, aimingMode);                        result.setUndoneLocation(new HitData(Mech.LOC_HEAD));                        return result;                    } // if                    return new HitData(Mech.LOC_HEAD);                }            }            else if(side == ToHitData.SIDE_RIGHT) {                // normal right side hits                switch( roll ) {                case 2:                    if ((crew.hasEdgeRemaining() && crew.getOptions().booleanOption("edge_when_tac"))                            && !game.getOptions().booleanOption("no_tac")) {                        crew.decreaseEdge();                        HitData result = rollHitLocation(table, side, aimedLocation, aimingMode);                        result.setUndoneLocation(tac(table, side, Mech.LOC_RT, false));                        return result;                    } // if                    return tac(table, side, Mech.LOC_RT, false);                case 3:                    return new HitData(Mech.LOC_RLEG);                case 4:                case 5:                    return new HitData(Mech.LOC_RARM);                case 6:                    return new HitData(Mech.LOC_RLEG);                case 7:                    return new HitData(Mech.LOC_RT);                case 8:                    return new HitData(Mech.LOC_CT);                case 9:                    return new HitData(Mech.LOC_LT);                case 10:                    return new HitData(Mech.LOC_LARM);                case 11:                    return new HitData(Mech.LOC_LLEG);                case 12:                    if (crew.hasEdgeRemaining()                             && crew.getOptions().booleanOption("edge_when_headhit")) {                        crew.decreaseEdge();                        HitData result =  rollHitLocation(table, side, aimedLocation, aimingMode);                        result.setUndoneLocation(new HitData(Mech.LOC_HEAD));                        return result;                    } // if                    return new HitData(Mech.LOC_HEAD);                }            }            else if(side == ToHitData.SIDE_REAR) {                // normal rear hits                if(game.getOptions().booleanOption("quad_hit_location")                        && isProne()) {                    switch( roll ) {                    case 2:                        if ((crew.hasEdgeRemaining() && crew.getOptions().booleanOption("edge_when_tac"))                                && !game.getOptions().booleanOption("no_tac")) {                            crew.decreaseEdge();                            HitData result = rollHitLocation(table, side, aimedLocation, aimingMode);                            result.setUndoneLocation(tac(table, side, Mech.LOC_CT, true));                            return result;                        } // if                        return tac(table, side, Mech.LOC_CT, true);                    case 3:                        return new HitData(Mech.LOC_RARM, true);                    case 4:                    case 5:                        return new HitData(Mech.LOC_RLEG, true);                    case 6:                        return new HitData(Mech.LOC_RT, true);                    case 7:                        return new HitData(Mech.LOC_CT, true);                    case 8:                        return new HitData(Mech.LOC_LT, true);                    case 9:                    case 10:                        return new HitData(Mech.LOC_LLEG, true);                    case 11:                        return new HitData(Mech.LOC_LARM, true);                    case 12:                        if (crew.hasEdgeRemaining()                                 && crew.getOptions().booleanOption("edge_when_headhit")) {                            crew.decreaseEdge();                            HitData result =  rollHitLocation(table, side, aimedLocation, aimingMode);                            result.setUndoneLocation(new HitData(Mech.LOC_HEAD, true));                            return result;                        } // if                        return new HitData(Mech.LOC_HEAD, true);                    }                } else {                    switch( roll ) {                    case 2:                        if ((crew.hasEdgeRemaining() && crew.getOptions().booleanOption("edge_when_tac"))                                && !game.getOptions().booleanOption("no_tac")) {                            crew.decreaseEdge();                            HitData result = rollHitLocation(table, side, aimedLocation, aimingMode);                            result.setUndoneLocation(tac(table, side, Mech.LOC_CT, true));                            return result;                        } // if                        return tac(table, side, Mech.LOC_CT, true);                    case 3:                    case 4:                        return new HitData(Mech.LOC_RARM, true);

⌨️ 快捷键说明

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