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

📄 battlearmor.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
    /**     * Most Infantry can not enter water.     */    public boolean isHexProhibited(IHex hex) {        // Oh, HELL no!        // This needs to be fixed.        // *grumbles*        if(hex.terrainLevel(Terrains.WATER) > 0 && !hex.containsTerrain(Terrains.ICE)                 && !this.getModel().equals(CLAN_WATER_ELEMENTAL))            return true;        return super.isHexProhibited(hex);    }    /**     * Returns the name of the type of movement used.     * This is Infantry-specific.     */    public String getMovementString(int mtype) {        switch(mtype) {        case IEntityMovementType.MOVE_NONE :            return "None";        case IEntityMovementType.MOVE_WALK :        case IEntityMovementType.MOVE_RUN :            return "Walked";        case IEntityMovementType.MOVE_VTOL_WALK :        case IEntityMovementType.MOVE_VTOL_RUN :            return "Flew";        case IEntityMovementType.MOVE_JUMP :            return "Jumped";        default :            return "Unknown!";        }    }    /**     * Returns the abbreviation of the type of movement used.     * This is Infantry-specific.     */    public String getMovementAbbr(int mtype) {        switch(mtype) {        case IEntityMovementType.MOVE_NONE :            return "N";        case IEntityMovementType.MOVE_WALK :            return "W";        case IEntityMovementType.MOVE_RUN :            return "R";        case IEntityMovementType.MOVE_JUMP :            return "J";        case IEntityMovementType.MOVE_VTOL_WALK :        case IEntityMovementType.MOVE_VTOL_RUN :            return "F";        default :            return "?";        }    }    /**     * Battle Armor units can only get hit in undestroyed troopers.     */    public HitData rollHitLocation(int table, int side, int aimedLocation, int aimingMode) {        return rollHitLocation(table, side);    }              public HitData rollHitLocation( int table, int side ) {        // If this squad was killed, target trooper 1 (just because).        if ( this.isDoomed() ) return new HitData( 1 );        // Pick a random number between 1 and 6.        int loc = Compute.d6();        if(game.getOptions().booleanOption("ba_criticals")           && loc == 6) {           return new HitData( Compute.d6(), false, HitData.EFFECT_CRITICAL );        }        // Pick a new random number if that trooper is dead or never existed.        // Remember that there's one more location than the number of troopers.        // In http://forums.classicbattletech.com/index.php/topic,43203.0.html,        // "previously destroyed includes the current phase" for rolling hits on a squad,        // modifying previous ruling in the AskThePM FAQ.        while ( loc >= this.locations() ||                IArmorState.ARMOR_NA == this.getInternal(loc) ||                IArmorState.ARMOR_DESTROYED == this.getInternal(loc) ||                (IArmorState.ARMOR_DOOMED == this.getInternal(loc) && !isDoomed())) {            loc = Compute.d6();        }        // Hit that trooper.        return new HitData( loc );    }    /**     * For level 3 rules, each trooper occupies a specific location     * precondition: hit is a location covered by BA     */    public HitData getTrooperAtLocation(HitData hit, Entity transport) {        if(game.getOptions().booleanOption("maxtech_mechanized_ba") &&           transport instanceof Mech) {            int loc = 99;            switch(hit.getLocation()) {                case Mech.LOC_RT:                    if(hit.isRear())                        loc = 3;                    else                        loc = 1;                    break;                case Mech.LOC_LT:                    if(hit.isRear())                        loc = 4;                    else                        loc = 2;                    break;                case Mech.LOC_CT:                    loc = 5;                    break;            }            if(loc < locations())                return new HitData(loc);        }        //otherwise roll a random location        return rollHitLocation( ToHitData.HIT_NORMAL, ToHitData.SIDE_FRONT );    }    /**     * Battle Armor units don't transfer damage.     */    public HitData getTransferLocation(HitData hit) {        // If any trooper lives, the unit isn't destroyed.        for ( int loop = 1; loop < this.locations(); loop++ ) {            if ( 0 < this.getInternal(loop) ) {                return new HitData(Entity.LOC_NONE);            }        }        // No surviving troopers, so we're toast.        return new HitData(Entity.LOC_DESTROYED);    }    /**     * Battle Armor units use default behavior for armor and internals.     *     * @see     megamek.common.Infantry#isPlatoon()     */    protected boolean isPlatoon() { return false; }    /**     * Battle Armor units have no armor on their squad location.     *     * @see     megamek.common.Infantry#getArmor( int, boolean )     */    public int getArmor( int loc, boolean rear ) {        if ( BattleArmor.LOC_SQUAD != loc ) {            return super.getArmor( loc, rear );        }        return IArmorState.ARMOR_NA;    }    /**     * Battle Armor units have no armor on their squad location.     *     * @see     megamek.common.Infantry#getOArmor( int, boolean )     */    public int getOArmor( int loc, boolean rear ) {        if ( BattleArmor.LOC_SQUAD != loc ) {            return super.getOArmor( loc, rear );        }        return IArmorState.ARMOR_NA;    }    /**     * Battle Armor units have no internals on their squad location.     *     * @see     megamek.common.Infantry#getInternal( int )     */    public int getInternal( int loc ) {        if ( BattleArmor.LOC_SQUAD != loc ) {            return super.getInternal( loc );        }        return IArmorState.ARMOR_NA;    }    /**     * Battle Armor units have no internals on their squad location.     *     * @see     megamek.common.Infantry#getOInternal( int )     */    public int getOInternal( int loc ) {        if ( BattleArmor.LOC_SQUAD != loc ) {            return super.getOInternal( loc );        }        return IArmorState.ARMOR_NA;    }    /**     * Set the troopers in the unit to the appropriate values.     */    public void autoSetInternal() {        // No troopers in the squad location.        this.initializeInternal(IArmorState.ARMOR_NA, LOC_SQUAD);        // Initialize the troopers.        for (int loop = 1; loop < this.locations(); loop++) {            this.initializeInternal(1, loop);        }        // Set the initial number of troopers that can shoot        // to one less than the number of locations in the unit.        this.troopersShooting = this.locations() - 1;    }        /**     * Mounts the specified equipment in the specified location.     */    protected void addEquipment(Mounted mounted, int loc, boolean rearMounted)        throws LocationFullException {        // Implement parent's behavior.        super.addEquipment(mounted, loc, rearMounted);        // Add the piece equipment to our slots.        addCritical(loc, new CriticalSlot(CriticalSlot.TYPE_EQUIPMENT,                                           getEquipmentNum(mounted),                                           true));        // Is the item a stealth equipment?        // TODO: what's the *real* extreme range modifier?        String name = mounted.getType().getInternalName();        if (BattleArmor.STEALTH.equals(name)) {            this.isStealthy = true;            this.shortStealthMod  = 0;            this.mediumStealthMod = 1;            this.longStealthMod   = 2;            this.stealthName = "basic stealth";        } else if (BattleArmor.ADVANCED_STEALTH.equals(name)) {            this.isStealthy = true;            this.shortStealthMod  = 1;            this.mediumStealthMod = 1;            this.longStealthMod   = 2;            this.stealthName = "standard stealth";        } else if (BattleArmor.EXPERT_STEALTH.equals(name)) {            this.isStealthy = true;            this.shortStealthMod  = 1;            this.mediumStealthMod = 2;            this.longStealthMod   = 3;            this.stealthName = "improved stealth";        } else if (BattleArmor.MIMETIC_CAMO.equals(name)) {            this.isMimetic = true;        } else if (BattleArmor.SIMPLE_CAMO.equals(name)) {            this.isSimpleCamo = true;        }    }    /**     * Battle Armor units have as many critical slots as they need to     * hold their equipment.     */    protected int[] getNoOfSlots() {        if ( !this.isInitialized || this.isClan() ) {            return CLAN_NUM_OF_SLOTS;        }        return IS_NUM_OF_SLOTS;    }        /**     * Trooper's equipment dies when they do.     */    public boolean hasHittableCriticals(int loc) {        if ( LOC_SQUAD == loc ) return false;        return super.hasHittableCriticals( loc );    }    /**     * Calculates the battle value of this platoon.     */    public int calculateBattleValue() {        double bv = myBV;        // Adjust for missing troopers        bv = bv * getInternalRemainingPercent();        // Possibly adjust for TAG and Arrow IV.        if (getsTagBVPenalty()) {            bv += 200;        }        if (getsHomingBVPenalty()) {            bv += 200;        }        // Adjust BV for crew skills.        double pilotFactor = crew.getBVSkillMultiplier();        int finalBV = (int)Math.round(bv);        int retVal = (int)Math.round(finalBV * pilotFactor);        return retVal;    }    /**     * Prepare the entity for a new round of action.     */        public void newRound(int roundNumber)    {        // Perform all base-class behavior.        super.newRound(roundNumber);        // If we're equipped with a Magnetic Mine        // launcher, turn it to single shot mode.        for (Mounted m:getMisc()) {            EquipmentType equip = m.getType();            if ( BattleArmor.MINE_LAUNCHER.equals(equip.getInternalName()) ) {                m.setMode("Single");            }        }    }    /**     * Update the unit to reflect damages taken in this phase.     */    public void applyDamage() {        super.applyDamage();        troopersShooting = this.getTotalInternal();    }    /**     * Get the number of men in the unit (before damage is applied).     *     * @see     megamek.common.Infantry#getShootingStrength     */    public int getShootingStrength() { return troopersShooting; }    /**     * Sets the battle value of this unit.  Please note that the BV     * of all Battle Armor units is dictated by the BMRr, page 155.     *     * @param   bv - the <code>int</code> battle value of this unit.     */    public void setBattleValue( int bv ) { myBV = bv; }    public void setCost( int inC ) { myCost = inC; }        /**     * Determines if the battle armor unit is burdened with un-jettisoned     * equipment.  This can prevent the unit from jumping or using their     * special Anti-Mek attacks.     *     * @return  <code>true</code> if the unit hasn't jettisoned its     *          equipment yet, <code>false</code> if it has.     */    public boolean isBurdened() {

⌨️ 快捷键说明

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