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

📄 mounted.java

📁 MegaMek is a networked Java clone of BattleTech, a turn-based sci-fi boardgame for 2+ players. Fight
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
            } else if (this.curMode().equals("6-shot")) {                nShots = 6;            }        }        return nShots;    }    public boolean isPendingDump() {        return m_bPendingDump;    }    public void setPendingDump(boolean b) {        m_bPendingDump = b;    }    public boolean isDumping() {        return m_bDumping;    }    public void setDumping(boolean b) {        m_bDumping = b;    }        public boolean isRapidfire() {        return rapidfire;    }        public void setRapidfire(boolean rapidfire) {        this.rapidfire = rapidfire;    }    /**     * Checks to see if the current ammo for this weapon is hotloaded     * @return <code>true</code> if ammo is hotloaded or <code>false</code> if not     */    public boolean isHotLoaded(){             boolean isHotLoaded = false;                if ( this.getType() instanceof WeaponType ){            Mounted link = this.getLinked();            if ( link == null || !(link.getType() instanceof AmmoType) || link.getShotsLeft() <= 0)                return false;                                        isHotLoaded = this.getLinked().hotloaded;                        //Check to see if the ammo has its mode set to hotloaded.            //This is for vehicles that can change hotload status during combat.            if ( !isHotLoaded && this.getLinked().getType().hasModes() && this.getLinked().curMode().equals("HotLoad") )                isHotLoaded = true;                        return isHotLoaded;        }            if ( this.getType() instanceof AmmoType && this.getShotsLeft() > 0){            isHotLoaded = this.hotloaded;                        //Check to see if the ammo has its mode set to hotloaded.            //This is for vehicles that can change hotload status during combat.            if ( !isHotLoaded && this.getType().hasModes() && this.curMode().equals("HotLoad") )                isHotLoaded = true;                        return isHotLoaded;        }                return false;    }        /**     * Sets the hotloading parameter for this weapons ammo.     * @param hotload     */    public void setHotLoad(boolean hotload){                if ( this.getType() instanceof WeaponType ){            Mounted link = this.getLinked();            if ( link == null ||  !(link.getType() instanceof AmmoType) )                return;            if ( ((AmmoType)link.getType()).hasFlag(AmmoType.F_HOTLOAD) )                link.hotloaded = hotload;        }        if ( this.getType() instanceof AmmoType ){            if ( ((AmmoType)this.getType()).hasFlag(AmmoType.F_HOTLOAD) )                this.hotloaded = hotload;        }                }        public int getLocation() {        return location;    }    public int getSecondLocation() {        if (bSplit) {            return secondLocation;        }        return -1;    }        public boolean isRearMounted() {        return rearMounted;    }    public void setLocation(int location) {        setLocation(location, false);    }    public void setSecondLocation(int location) {        setSecondLocation(location, false);    }        public void setLocation(int location, boolean rearMounted) {        this.location = location;        this.rearMounted = rearMounted;    }    public void setSecondLocation(int location, boolean rearMounted) {        this.secondLocation = location;        this.rearMounted = rearMounted;    }        public Mounted getLinked() {        return linked;    }    public Mounted getLinkedBy() {        return linkedBy;    }    public void setLinked(Mounted linked) {        this.linked = linked;        linked.setLinkedBy(this);    }    // should only be called by setLinked()    // in the case of a many-to-one relationship (like ammo) this is meaningless    protected void setLinkedBy(Mounted linker) {        if (linker.getLinked() != this) {            // liar            return;        }        linkedBy = linker;    }    public int getFoundCrits() {        return nFoundCrits;    }    public void setFoundCrits(int n) {        nFoundCrits = n;    }    public boolean isSplit() {        return bSplit;    }        public boolean isSplitable() {        return (this.getType() instanceof WeaponType &&            this.getType().hasFlag(WeaponType.F_SPLITABLE));    }    public void setSplit(boolean b) {        bSplit = b;    }    public int getExplosionDamage() {        if (type instanceof AmmoType) {            AmmoType atype = (AmmoType)type;            return atype.getDamagePerShot() * atype.getRackSize() * shotsLeft;        } else if (type instanceof WeaponType) {            WeaponType wtype = (WeaponType)type;            //HACK: gauss rifle damage hardcoding            if (wtype.getAmmoType() == AmmoType.T_GAUSS) {                return 20;            } else if (wtype.getAmmoType() == AmmoType.T_GAUSS_LIGHT) {                return 16;            } else if (wtype.getAmmoType() == AmmoType.T_RAIL_GUN) {                return 22;            } else if (wtype.getAmmoType() == AmmoType.T_GAUSS_HEAVY) {                return 25;            } else if (wtype.getAmmoType() == AmmoType.T_AC_ROTARY ||                       wtype.getAmmoType() == AmmoType.T_AC ||                       wtype.getAmmoType() == AmmoType.T_LAC) {                return wtype.getDamage();            } else if (wtype.getAmmoType() == AmmoType.T_MAGSHOT) {                return 3;            }else if ( this.isHotLoaded() ){                Mounted link = this.getLinked();                AmmoType atype = ((AmmoType) link.getType());                int damage = wtype.getRackSize() * atype.getDamagePerShot();                return damage;            }        }        // um, otherwise, I'm not sure        System.err.println("mounted: unable to determine explosion damage for "                            + getName());        return 0;    }    public boolean isFired() { //has a oneshot weapon been fired?      return fired;    }    public void setFired(boolean val) {      fired=val;    }    /**     * Confirm that the given entity can fire the indicated equipment.     *     * @return  <code>true</code> if the equipment can be fired by the     *          entity; <code>false</code> otherwise.     */    public boolean canFire() {            // Equipment operational?        if ( !isReady() || isBreached() || isMissing() ) {            return false;        }            // Is the entity even active?        if ( entity.isShutDown() || !entity.getCrew().isActive() ) {            return false;        }            // Otherwise, the equipment can be fired.        return true;    }    /**     * Returns false if this ammo should not be loaded.  Checks if the     *    ammo is already destroyed, is being dumped, has been breached, is     *   already used up, or is locationless (oneshot ammo).     */    public boolean isAmmoUsable() {        if (this.destroyed || this.m_bDumping ||            this.useless || this.shotsLeft <= 0 ||            this.location == Entity.LOC_NONE) {            return false;        }		return true;    }        /**     * @return the type of mine this mounted is, or     * <code>-1</code> if it isn't a mine     *      */    public int getMineType() {        return this.mineType;    }        /**     * set the type of mine this should be     * @param mineType     */    public void setMineType(int mineType) {        this.mineType = mineType;    }        /**     * set the vibrabomb sensitivity     * @param vibraSetting the <code>int</code> sensitivity to set     */    public void setVibraSetting(int vibraSetting) {        this.vibraSetting = vibraSetting;    }        /**     * get the vibrabomb sensitivity     * @return the <code>int</code> vibrabomb sensitity this mine is set to.     */    public int getVibraSetting() {        return vibraSetting;    }    public String toString() {        return "megamek.common.Mounted (" + typeName + ")";    }    /**     * Rules state that every time the shield takes a crit its damage absorption     * for each attack is reduced by 1.      * Also for every Arm actuator critted damage absorption is reduced by 1     * and finally if the should is hit the damage absorption is reduced by 2     * making it possble to kill a shield before its gone through its full     * damage capacity.     * @param entity     * @param location     * @return     */    public int getDamageAbsorption(Entity entity, int location){        //Shields can only be used in arms so if you've got a shield in a location        //other then an arm your SOL --Torren.        if ( location != Mech.LOC_RARM && location != Mech.LOC_LARM )            return 0;                int base = baseDamageAbsorptionRate;                for ( int slot = 0; slot < entity.getNumberOfCriticals(location); slot++){            CriticalSlot cs = entity.getCritical(location,slot);                        if ( cs == null )                continue;                        if ( cs.getType() != CriticalSlot.TYPE_EQUIPMENT )                continue;                        Mounted m = entity.getEquipment(cs.getIndex());            EquipmentType type = m.getType();            if (type instanceof MiscType &&((MiscType)type).isShield()) {                if ( cs.isDamaged() )                    base--;            }        }            //Only damaged Actuators should effect the shields absorption rate        //Not missing ones.        if ( entity.hasSystem(Mech.ACTUATOR_SHOULDER, location)                && !entity.hasWorkingSystem(Mech.ACTUATOR_SHOULDER, location) )            base -= 2;            if ( entity.hasSystem(Mech.ACTUATOR_LOWER_ARM, location)                 && !entity.hasWorkingSystem(Mech.ACTUATOR_LOWER_ARM, location) )            base--;        if ( entity.hasSystem(Mech.ACTUATOR_UPPER_ARM, location)                && !entity.hasWorkingSystem(Mech.ACTUATOR_UPPER_ARM, location) )            base--;                return Math.max(0,base);    }        /**     * Rules say every time a shield is critted it loses 5 points from its     * Damage Capacity. basically count down from the top then subtract the amount     * of damage its already take.     * The damage capacity is used to determine if the shield is still viable.     * @param entity     * @param location     * @return damage capacity(no less then 0)     */    public int getCurrentDamageCapacity(Entity entity, int location){        //Shields can only be used in arms so if you've got a shield in a location        //other then an arm your SOL --Torren.        if ( location != Mech.LOC_RARM && location != Mech.LOC_LARM )            return 0;                int base = baseDamageCapacity;            for ( int slot = 0; slot < entity.getNumberOfCriticals(location); slot++){            CriticalSlot cs = entity.getCritical(location,slot);                        if ( cs == null )                continue;                        if ( cs.getType() != CriticalSlot.TYPE_EQUIPMENT )                continue;                        Mounted m = entity.getEquipment(cs.getIndex());            EquipmentType type = m.getType();            if (type instanceof MiscType && ((MiscType)type).isShield()) {                if ( cs.isDamaged() )                    base -= 5;            }        }        return Math.max(0,base-damageTaken);    }    }

⌨️ 快捷键说明

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