📄 protomech.java
字号:
return new HitData(Protomech.LOC_RARM); case 12: return new HitData(Protomech.LOC_HEAD); } return null; } /** * Protos can't transfer crits. */ public boolean canTransferCriticals(int loc) { return false; } /** * Gets the location that excess damage transfers to */ public HitData getTransferLocation(HitData hit) { switch (hit.getLocation()) { case LOC_NMISS: return new HitData(LOC_NONE); case LOC_LARM: case LOC_LEG: case LOC_RARM: case LOC_HEAD: case LOC_MAINGUN: return new HitData(LOC_TORSO, hit.isRear()); case LOC_TORSO: default: return new HitData(LOC_DESTROYED); } } /** * Gets the location that is destroyed recursively */ public int getDependentLocation(int loc) { return LOC_NONE; } /** * Sets the internal structure for the pmech. * * @param head * head * @param torso * center torso * @param arm * right/left arm * @param legs * right/left leg * @param mainGun * main gun */ public void setInternal(int head, int torso, int arm, int legs, int mainGun) { initializeInternal(head, LOC_HEAD); initializeInternal(torso, LOC_TORSO); initializeInternal(arm, LOC_RARM); initializeInternal(arm, LOC_LARM); initializeInternal(legs, LOC_LEG); initializeInternal(mainGun, LOC_MAINGUN); } /** * Set the internal structure to the appropriate value for the pmech's * weight class */ public void autoSetInternal() { int mainGunIS = hasMainGun() ? 1 : IArmorState.ARMOR_NA; switch ((int) weight) { // H, TSO,ARM,LEGS,MainGun case 2: setInternal(1, 2, 1, 2, mainGunIS); break; case 3: setInternal(1, 3, 1, 2, mainGunIS); break; case 4: setInternal(1, 4, 1, 3, mainGunIS); break; case 5: setInternal(1, 5, 1, 3, mainGunIS); break; case 6: setInternal(2, 6, 2, 4, mainGunIS); break; case 7: setInternal(2, 7, 2, 4, mainGunIS); break; case 8: setInternal(2, 8, 2, 5, mainGunIS); break; case 9: setInternal(2, 9, 2, 5, mainGunIS); break; } } /** * Creates a new mount for this equipment and adds it in. */ public Mounted addEquipment(EquipmentType etype, int loc) throws LocationFullException { return addEquipment(etype, loc, false, -1); } public Mounted addEquipment(EquipmentType etype, int loc, boolean rearMounted) throws LocationFullException { Mounted mounted = new Mounted(this, etype); addEquipment(mounted, loc, rearMounted, -1); return mounted; } public Mounted addEquipment(EquipmentType etype, int loc, boolean rearMounted, int shots) throws LocationFullException { Mounted mounted = new Mounted(this, etype); addEquipment(mounted, loc, rearMounted, shots); return mounted; } /** * Mounts the specified weapon in the specified location. */ protected void addEquipment(Mounted mounted, int loc, boolean rearMounted, int shots) throws LocationFullException { if (mounted.getType() instanceof AmmoType) { // Damn protomech ammo; nasty hack, should be cleaner if (-1 != shots) { mounted.setShotsLeft(shots); super.addEquipment(mounted, loc, rearMounted); return; } } if (mounted.getType() instanceof WeaponType) { switch (loc) { case LOC_HEAD: case LOC_LEG: case LOC_NMISS: throw new LocationFullException("Weapon " + mounted.getName() + " can't be mounted in " + getLocationAbbr(loc)); case LOC_MAINGUN: if (bHasMainGun) { throw new LocationFullException("Already has Main Gun"); } bHasMainGun = true; mounted.setLocation(loc, rearMounted); equipmentList.add(mounted); weaponList.add(mounted); break; case LOC_LARM: if (bHasLArmGun) { throw new LocationFullException("Already has LArm Gun"); } bHasLArmGun = true; mounted.setLocation(loc, rearMounted); equipmentList.add(mounted); weaponList.add(mounted); break; case LOC_RARM: if (bHasRArmGun) { throw new LocationFullException("Already has RArm Gun"); } bHasRArmGun = true; mounted.setLocation(loc, rearMounted); equipmentList.add(mounted); weaponList.add(mounted); break; case LOC_TORSO: if (bHasTorsoAGun) { if (bHasTorsoBGun) { throw new LocationFullException( "Already has both torso guns"); } bHasTorsoBGun = true; mounted.setLocation(loc, rearMounted); equipmentList.add(mounted); weaponList.add(mounted); TorsoBGunNum = getEquipmentNum(mounted); } else { bHasTorsoAGun = true; mounted.setLocation(loc, rearMounted); equipmentList.add(mounted); weaponList.add(mounted); TorsoAGunNum = getEquipmentNum(mounted); } break; } } else { super.addEquipment(mounted, loc, rearMounted); } } /** * Calculates the battle value of this pmech. UNIMPLEMENTED and UNCOMPLETE. * */ public int calculateBattleValue() { // Was our battle value set at construction? if (myBV > 0) { // Adjust BV for crew skills. double pilotFactor = crew.getBVSkillMultiplier(); return (int) (pilotFactor * myBV); } double dbv = 0; // defensive battle value double obv = 0; // offensive bv // total armor points dbv += getTotalArmor(); // total internal structure dbv += getTotalInternal() / 2; // add defensive equipment double dEquipmentBV = 0; for (Mounted mounted : getEquipment()) { EquipmentType etype = mounted.getType(); // don't count destroyed equipment if (mounted.isDestroyed()) continue; if ((etype instanceof WeaponType && etype.hasFlag(WeaponType.F_AMS)) || (etype instanceof AmmoType && ((AmmoType) etype) .getAmmoType() == AmmoType.T_AMS) || etype.hasFlag(MiscType.F_ECM)) { dEquipmentBV += etype.getBV(this); } } dbv += dEquipmentBV; dbv += weight; // adjust for target movement modifier int tmmRan = Compute.getTargetMovementModifier(getOriginalRunMP(), false, false, false).getValue(); if (tmmRan > 5) { tmmRan = 5; } double[] tmmFactors = { 1.0, 1.1, 1.2, 1.3, 1.4, 1.5 }; dbv *= (tmmFactors[tmmRan] + .1); double weaponBV = 0; // figure out base weapon bv double weaponsBVFront = 0; double weaponsBVRear = 0; for (Mounted mounted : getWeaponList()) { WeaponType wtype = (WeaponType) mounted.getType(); double dBV = wtype.getBV(this); // don't count destroyed equipment if (mounted.isDestroyed()) continue; // don't count AMS, it's defensive if (wtype.hasFlag(WeaponType.F_AMS)) { continue; } weaponsBVFront += dBV; } if (weaponsBVFront > weaponsBVRear) { weaponBV += weaponsBVFront; weaponBV += (weaponsBVRear * 0.5); } else { weaponBV += weaponsBVRear; weaponBV += (weaponsBVFront * 0.5); } // add ammo bv double ammoBV = 0; for (Mounted mounted : getAmmo()) { AmmoType atype = (AmmoType) mounted.getType(); // don't count depleted ammo if (mounted.getShotsLeft() == 0) continue; // don't count AMS, it's defensive if (atype.getAmmoType() == AmmoType.T_AMS) { continue; } ammoBV += atype.getBV(this); } weaponBV += ammoBV; // adjust further for speed factor double speedFactor = getOriginalRunMP() - 5; speedFactor /= 10; speedFactor++; speedFactor = Math.pow(speedFactor, 1.2); speedFactor = Math.round(speedFactor * 100) / 100.0; obv = weaponBV * speedFactor; // Possibly adjust for TAG and Arrow IV. if (getsTagBVPenalty()) { dbv += 200; } if (getsHomingBVPenalty()) { dbv += 200; } // and then factor in pilot double pilotFactor = crew.getBVSkillMultiplier(); // return (int)Math.round((dbv + obv) * pilotFactor); int finalBV = (int) Math.round(dbv + obv); int retVal = (int) Math.round((finalBV) * pilotFactor); return retVal; } public Vector victoryReport() { Vector vDesc = new Vector(); Report r = new Report(7025); r.type = Report.PUBLIC; r.addDesc(this); vDesc.addElement(r); r = new Report(7030); r.type = Report.PUBLIC; r.newlines = 0; vDesc.addElement(r); vDesc.addAll(crew.getDescVector(true)); r = new Report(7070, Report.PUBLIC); r.add(getKillNumber()); vDesc.addElement(r); if(isDestroyed()) { Entity killer = game.getEntity(killerId); if(killer == null) { killer = game.getOutOfGameEntity(killerId); } if(killer != null) { r = new Report(7072, Report.PUBLIC); r.addDesc(killer); } else { r = new Report(7073, Report.PUBLIC); } vDesc.addElement(r); } r.newlines = 2; return vDesc; } public int getMaxElevationChange() { return 1; } public int getArmor(int loc, boolean rear) { if (loc == LOC_NMISS) { return IArmorState.ARMOR_NA; } return super.getArmor(loc, rear); } public int getInternal(int loc) { if (loc == LOC_NMISS) { return IArmorState.ARMOR_NA; } return super.getInternal(loc); } protected String[] getLocationAbbrs() { return LOCATION_ABBRS; } public String getLocationAbbr(int loc) { if (loc == LOC_NMISS) { return "a near miss"; } return super.getLocationAbbr(loc); } /** * 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; } /* * * Not every Protomech has a main gun. */ public boolean hasMainGun() { return !m_bHasNoMainGun; } /* * * Not every Protomech has a main gun. */ public void setHasMainGun(boolean b) { m_bHasNoMainGun = !b; } /** * Returns the number of locations in the entity */ public int locations() { if (m_bHasNoMainGun) { return NUM_PMECH_LOCATIONS - 1; } return NUM_PMECH_LOCATIONS; } /** * Protomechs have no piloting skill (set to 5 for BV purposes) */ public void setCrew(Pilot p) { super.setCrew(p); this.getCrew().setPiloting(5); } public boolean canCharge() { // Protos can't Charge return false; } public boolean canDFA() { // Protos can't DFA return false; } /** * @return The cost in C-Bills of the ProtoMech in question. */ public double getCost() { double retVal = 0; // Add the cockpit, a constant cost. retVal += 500000; // Add life support, a constant cost. retVal += 75000; // Sensor cost is based on tonnage. retVal += 2000*weight; // Musculature cost is based on tonnage. retVal += 2000*weight; // Internal Structure cost is based on tonnage. retVal += 400*weight; // Arm actuators are based on tonnage. // Their cost is listed separately? retVal += 2*180*weight; // Leg actuators are based on tonnage. retVal += 540*weight; // Engine cost is based on tonnage and rating. if (getEngine() != null) retVal += (5000*weight*getEngine().getRating())/75; // Jump jet cost is based on tonnage and jump MP. retVal += weight*getJumpMP()*getJumpMP()*200; // Heat sinks is constant per sink. //FIXME // Protos in MM currently don't keep track of sinks, so we can't do this. //retVal += 2000*getHeatCapacity(); // Armor is linear on the armor value of the Protomech retVal += getTotalArmor()*625; // Add in equipment cost. //FIXME // Finally, apply the Final ProtoMech Cost Multiplier retVal *= 1+(weight/100.0); return retVal; } public boolean doomedInVacuum() { return false; } public boolean hasActiveEiCockpit() { return (super.hasActiveEiCockpit() && (getCritsHit(LOC_HEAD) == 0)); } public boolean canAssaultDrop() { return true; } public boolean isNuclearHardened() { return true; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -