📄 mech.java
字号:
public int getRunMPwithoutMASC(boolean gravity) { return super.getRunMP(gravity)-(getArmorType()==EquipmentType.T_ARMOR_HARDENED?1:0); } public int getOriginalRunMPwithoutMASC() { return super.getRunMP(false)-(getArmorType()==EquipmentType.T_ARMOR_HARDENED?1:0); } /** * Returns this entity's running/flank mp as a string. */ public String getRunMPasString() { if (hasArmedMASC()) { return getRunMPwithoutMASC() + "(" + getRunMP() + ")"; } return Integer.toString(getRunMP()); } /** * Depends on engine type */ public int getRunHeat() { return engine.getRunHeat(); } /** * This mech's jumping MP modified for missing jump jets */ public int getJumpMP() { int jump = 0; if ( this.hasShield() && this.getNumberOfShields(MiscType.S_SHIELD_LARGE) > 0) return 0; for (Mounted mounted : getMisc()) { if (mounted.getType().hasFlag(MiscType.F_JUMP_JET) && !mounted.isDestroyed() && !mounted.isBreached()) { jump++; } else if (mounted.getType().hasFlag(MiscType.F_JUMP_BOOSTER) && !mounted.isDestroyed() && !mounted.isBreached()) { jump = getOriginalJumpMP(); break; } } return applyGravityEffectsOnMP(jump); } /** * Returns the type of jump jet system the mech has. */ public int getJumpType() { if (jumpType == JUMP_UNKNOWN) { jumpType = JUMP_NONE; for (Object oMount : miscList) { Mounted m = (Mounted)oMount; if (m.getType().hasFlag(MiscType.F_JUMP_JET)) { if ((m.getType().getTechLevel() == TechConstants.T_IS_LEVEL_3) || (m.getType().getTechLevel() == TechConstants.T_CLAN_LEVEL_3)) { jumpType = JUMP_IMPROVED; } else { jumpType = JUMP_STANDARD; } break; } else if (m.getType().hasFlag(MiscType.F_JUMP_BOOSTER)) { jumpType = JUMP_BOOSTER; break; } } } return jumpType; } /** * We need to override this here, because mechs generate heat when jumping. */ public int getJumpHeat(int movedMP) { switch (getJumpType()) { case JUMP_IMPROVED: return engine.getJumpHeat(movedMP/2 + movedMP%2); case JUMP_BOOSTER: case JUMP_DISPOSABLE: case JUMP_NONE: return 0; default: return engine.getJumpHeat(movedMP); } } /** * Returns this mech's jumping MP, modified for missing & underwater jets and gravity. */ public int getJumpMPWithTerrain() { if (getPosition() == null || getJumpType() == JUMP_BOOSTER) { return getJumpMP(); } int waterLevel = 0; if (!isOffBoard()) { waterLevel = game.getBoard().getHex(getPosition()).terrainLevel(Terrains.WATER); } if (waterLevel <= 0 || getElevation() >= 0) { return getJumpMP(); } else if (waterLevel > 1) { return 0; } else { // waterLevel == 1 return applyGravityEffectsOnMP(torsoJumpJets()); } } /** * Returns the number of (working) jump jets mounted in the torsos. */ public int torsoJumpJets() { int jump = 0; for (Mounted mounted : getMisc()) { if (mounted.getType().hasFlag(MiscType.F_JUMP_JET) && !mounted.isDestroyed() && !mounted.isBreached() && locationIsTorso(mounted.getLocation())) { jump++; } } return jump; } /** * Returns the elevation of this entity. Mechs do funny stuff in the * middle of a DFA. */ public int getElevation() { int cElev = super.getElevation(); if (!isMakingDfa()) { return cElev; } // otherwise, we are one elevation above our hex or the target's hex, // whichever is higher int tElev = game.getBoard().getHex(displacementAttack.getTargetPos()).floor(); return Math.max(cElev, tElev) + 1; } /** * Return the height of this mech above the terrain. */ public int height() { IHex posHex = game.getBoard().getHex(getPosition()); return (isProne() || ((posHex != null) && (posHex.containsTerrain(Terrains.BUILDING)))) ? 0 : 1; } /** * Adds heat sinks to the engine. Uses clan/normal depending on the * currently set techLevel */ public void addEngineSinks(int totalSinks, boolean dblSinks) { addEngineSinks(totalSinks, dblSinks, isClan()); } /** * Adds heat sinks to the engine. Adds either the engine capacity, or * the entire number of heat sinks, whichever is less */ public void addEngineSinks(int totalSinks, boolean dblSinks, boolean clan) { // this relies on these being the correct internalNames for these items EquipmentType sinkType; if (dblSinks) { sinkType = EquipmentType.get(clan ? "CLDoubleHeatSink" : "ISDoubleHeatSink"); } else { sinkType = EquipmentType.get("Heat Sink"); } if (sinkType == null) { System.out.println("Mech: can't find heat sink to add to engine"); } int toAllocate = Math.min(totalSinks, getEngine().integralHeatSinkCapacity()); if (toAllocate == 0 && getEngine().isFusion()) { System.out.println("Mech: not putting any heat sinks in the engine?!?!"); } for (int i = 0; i < toAllocate; i++) { try { addEquipment(new Mounted(this, sinkType), Mech.LOC_NONE, false); } catch (LocationFullException ex) { // um, that's impossible. } } } /** * Returns extra heat generated by engine crits */ public int getEngineCritHeat() { int engineCritHeat = 0; if (!isShutDown() && getEngine().isFusion()) { engineCritHeat += 5 * getHitCriticals(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_ENGINE, Mech.LOC_CT); engineCritHeat += 5 * getHitCriticals(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_ENGINE, Mech.LOC_LT); engineCritHeat += 5 * getHitCriticals(CriticalSlot.TYPE_SYSTEM, Mech.SYSTEM_ENGINE, Mech.LOC_RT); } return engineCritHeat; } /** * Returns the number of heat sinks, functional or not. */ public int heatSinks() { int sinks = 0; for (Mounted mounted : getMisc()) { EquipmentType etype= mounted.getType(); if (etype.hasFlag(MiscType.F_HEAT_SINK) || etype.hasFlag(MiscType.F_DOUBLE_HEAT_SINK)) { sinks++; } } return sinks; } /** * Returns the about of heat that the entity can sink each * turn. */ public int getHeatCapacity() { int capacity = 0; int activeCount = getActiveSinks(); for (Mounted mounted : getMisc()) { if(activeCount <= 0) break; if (mounted.isDestroyed() || mounted.isBreached()) { continue; } if (mounted.getType().hasFlag(MiscType.F_HEAT_SINK)) { capacity++; activeCount--; } else if(mounted.getType().hasFlag(MiscType.F_DOUBLE_HEAT_SINK)) { activeCount--; capacity += 2; } } return capacity; } /** * Returns the about of heat that the entity can sink each * turn, factoring for water. */ public int getHeatCapacityWithWater() { if(hasLaserHeatSinks()) { return getHeatCapacity(); } return getHeatCapacity() + Math.min(sinksUnderwater(), 6); } /** * Gets the number of heat sinks that are underwater. */ private int sinksUnderwater() { if (getPosition() == null || isOffBoard()) { return 0; } IHex curHex = game.getBoard().getHex(getPosition()); // are we even in water? is it depth 1+ if (curHex.terrainLevel(Terrains.WATER) <= 0 || getElevation() >= 0) { return 0; } // are we entirely underwater? if (isProne() || curHex.terrainLevel(Terrains.WATER) >= 2) { return getHeatCapacity(); } // okay, count leg sinks int sinksUnderwater = 0; for (Mounted mounted : getMisc()) { if (mounted.isDestroyed() || mounted.isBreached() || !locationIsLeg(mounted.getLocation())) { continue; } if (mounted.getType().hasFlag(MiscType.F_HEAT_SINK)) { sinksUnderwater++; } else if (mounted.getType().hasFlag(MiscType.F_DOUBLE_HEAT_SINK)) { sinksUnderwater += 2; } } return sinksUnderwater; } /** * Returns the name of the type of movement used. * This is mech-specific. */ public String getMovementString(int mtype) { switch(mtype) { case IEntityMovementType.MOVE_SKID : return "Skidded"; case IEntityMovementType.MOVE_NONE : return "None"; case IEntityMovementType.MOVE_WALK : return "Walked"; case IEntityMovementType.MOVE_RUN : return "Ran"; case IEntityMovementType.MOVE_JUMP : return "Jumped"; default : return "Unknown!"; } } /** * Returns the name of the type of movement used. * This is mech-specific. */ public String getMovementAbbr(int mtype) { switch(mtype) { case IEntityMovementType.MOVE_SKID : return "S"; case IEntityMovementType.MOVE_NONE : return "N"; case IEntityMovementType.MOVE_WALK : return "W"; case IEntityMovementType.MOVE_RUN : return "R"; case IEntityMovementType.MOVE_JUMP : return "J"; default : return "?"; } } public boolean canChangeSecondaryFacing() { return !isProne(); } /** * Can this mech torso twist in the given direction? */ public boolean isValidSecondaryFacing(int dir) { int rotate = dir - getFacing(); if (canChangeSecondaryFacing()) { return rotate == 0 || rotate == 1 || rotate == -1 || rotate == -5; } return rotate == 0; } /** * Return the nearest valid direction to torso twist in */ public int clipSecondaryFacing(int dir) { if (isValidSecondaryFacing(dir)) { return dir;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -