📄 misctype.java
字号:
/** * MegaMek - * Copyright (C) 2000,2001,2002,2003,2004,2005 Ben Mazur (bmazur@sev.org) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the Free * Software Foundation; either version 2 of the License, or (at your option) * any later version. * * This program is distributed in the hope that it will be useful, but * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * for more details. *//** * MiscType.java * * Created on April 2, 2002, 12:15 PM */package megamek.common;/** * * @author Ben * @version */public class MiscType extends EquipmentType { // equipment flags (okay, like every type of equipment has its own flag) public static final long F_HEAT_SINK = 0x000000001L; public static final long F_DOUBLE_HEAT_SINK = 0x000000002L; public static final long F_JUMP_JET = 0x000000004L; public static final long F_CASE = 0x000000008L; public static final long F_MASC = 0x000000010L; public static final long F_TSM = 0x000000020L; public static final long F_LASER_HEAT_SINK = 0x000000040L; public static final long F_C3S = 0x000000080L; public static final long F_C3I = 0x000000100L; public static final long F_ARTEMIS = 0x000000200L; public static final long F_ECM = 0x000000400L; public static final long F_TARGCOMP = 0x000000800L; public static final long F_ANGEL_ECM = 0x000001000L; public static final long F_BAP = 0x000002000L; public static final long F_BOARDING_CLAW = 0x000004000L; public static final long F_VACUUM_PROTECTION = 0x000008000L; public static final long F_ASSAULT_CLAW = 0x000010000L; public static final long F_FIRE_RESISTANT = 0x000020000L; public static final long F_STEALTH = 0x000040000L; public static final long F_MINE = 0x000080000L; public static final long F_TOOLS = 0x000100000L; public static final long F_MAGNETIC_CLAMP = 0x000200000L; public static final long F_PARAFOIL = 0x000400000L; public static final long F_FERRO_FIBROUS = 0x000800000L; public static final long F_ENDO_STEEL = 0x001000000L; public static final long F_AP_POD = 0x002000000L; public static final long F_SEARCHLIGHT = 0x004000000L; public static final long F_CLUB = 0x008000000L; public static final long F_HAND_WEAPON = 0x010000000L; public static final long F_COWL = 0x020000000L; public static final long F_JUMP_BOOSTER = 0x040000000L; public static final long F_HARJEL = 0x080000000L; public static final long F_UMU = 0x100000000L; public static final long F_COOLANT_SYSTEM = 0x200000000L; public static final long F_SPIKES = 0x400000000L; // Secondary Flags for Physical Weapons public static final int S_CLUB = 0x00000001; // BMR public static final int S_TREE_CLUB = 0x00000002; // BMR public static final int S_HATCHET = 0x00000004; // BMR public static final int S_SWORD = 0x00000008; // BMR public static final int S_MACE_THB = 0x00000010; // Tac Handbook version public static final int S_CLAW_THB = 0x00000020; // Not used yet, but... Hey, it's all for fun. public static final int S_MACE = 0x00000040; // Solaris 7 public static final int S_DUAL_SAW = 0x00000080; // Solaris 7 public static final int S_FLAIL = 0x00000100; // Solaris 7 public static final int S_PILE_DRIVER = 0x00000200; // Solaris 7 public static final int S_SHIELD_SMALL = 0x00000400; // Solaris 7 public static final int S_SHIELD_MEDIUM = 0x00000800; // Solaris 7 public static final int S_SHIELD_LARGE = 0x00001000; // Solaris 7 public static final int S_LANCE = 0x00002000; // Solaris 7 public static final int S_VIBRO_SMALL = 0x00004000; // Solaris 7 public static final int S_VIBRO_MEDIUM = 0x00008000; // Solaris 7 public static final int S_VIBRO_LARGE = 0x00010000; // Solaris 7 public static final int S_WRECKING_BALL = 0x00020000; // Solaris 7 public static final int S_BACKHOE = 0x00040000; // Miniatures Rulebook public static final int S_COMBINE = 0x00080000; // Miniatures Rulebook; TODO public static final int S_CHAINSAW = 0x00100000; // Miniatures Rulebook public static final int S_ROCK_CUTTER = 0x00200000; // Miniatures Rulebook; TODO public static final int S_BUZZSAW = 0x00400000; // Unbound; public static final String S_ACTIVE_SHIELD = "Active"; public static final String S_PASSIVE_SHIELD = "Passive"; public static final String S_NO_SHIELD = "None"; // Secondary damage for hand weapons. // These are differentiated from Physical Weapons using the F_CLUB flag // because the following weapons are treated as a punch attack, while // the above weapons are treated as club or hatchet attacks. // these are subtypes of F_HAND_WEAPON public static final int S_CLAW = 0x00000001; // Solaris 7 public static final int S_MINING_DRILL = 0x00000002; // Miniatures Rulebook; TODO // Secondary flags for infantry tools public static final int S_VIBROSHOVEL = 0x00000001; // can fortify hexes public static final int S_DEMOLITION_CHARGE = 0x00000002; // can demolish buildings public static final int S_BRIDGE_KIT = 0x00000004; // can build a bridge public static final int S_MINESWEEPER = 0x00000008; // can clear mines public static final int S_HEAVY_ARMOR = 0x00000010; // Secondary flags for MASC public static final int S_SUPERCHARGER = 0x00000001; public static final int T_TARGSYS_UNKNOWN = -1; public static final int T_TARGSYS_STANDARD = 0; public static final int T_TARGSYS_TARGCOMP = 1; public static final int T_TARGSYS_LONGRANGE = 2; public static final int T_TARGSYS_SHORTRANGE = 3; public static final int T_TARGSYS_VARIABLE_RANGE = 4; public static final int T_TARGSYS_ANTI_AIR = 5; public static final int T_TARGSYS_MULTI_TRAC = 6; public static final int T_TARGSYS_MULTI_TRAC_II = 7; public static final int T_TARGSYS_HEAT_SEEKING_THB = 8; public static final String[] targSysNames = {"Standard Targeting System", "Targeting Computer", "Long-Range Targeting System", "Short-Range Targeting System", "Variable-Range Taretting System", "Anti-Air Targeting System", "Multi-Trac Targeting System", "Multi-Trac II Targeting System"}; //New stuff for shields protected int baseDamageAbsorptionRate = 0; protected int baseDamageCapacity = 0; protected int damageTaken = 0; /** Creates new MiscType */ public MiscType() { } public boolean isShield(){ if ( this.hasFlag(MiscType.F_CLUB) && (this.hasSubType(MiscType.S_SHIELD_LARGE) || this.hasSubType((MiscType.S_SHIELD_MEDIUM)) || this.hasSubType(MiscType.S_SHIELD_SMALL)) ) return true; //else return false; } public boolean isVibroblade(){ if ( this.hasFlag(MiscType.F_CLUB) && (this.hasSubType(MiscType.S_VIBRO_LARGE) || this.hasSubType((MiscType.S_VIBRO_MEDIUM)) || this.hasSubType(MiscType.S_VIBRO_SMALL)) ) return true; //else return false; } public float getTonnage(Entity entity) { if (tonnage != TONNAGE_VARIABLE) { return tonnage; } // check for known formulas if (hasFlag(F_JUMP_JET)) { if ((getTechLevel() == TechConstants.T_IS_LEVEL_3) || (getTechLevel() == TechConstants.T_CLAN_LEVEL_3)) { if (entity.getWeight() <= 55.0) { return 1.0f; } else if (entity.getWeight() <= 85.0) { return 2.0f; } else { return 4.0f; } } if (entity.getWeight() <= 55.0) { return 0.5f; } else if (entity.getWeight() <= 85.0) { return 1.0f; } else { return 2.0f; } } else if (hasFlag(F_UMU)) { if (entity.getWeight() <= 55.0) { return 0.5f; } else if (entity.getWeight() <= 85.0) { return 1.0f; } else { return 2.0f; } } else if (hasFlag(F_CLUB) && (hasSubType(S_HATCHET) || hasSubType(S_MACE_THB))) { return (float)Math.ceil(entity.getWeight() / 15.0); } else if (hasFlag(F_CLUB) && hasSubType(S_LANCE)) { return (float)Math.ceil(entity.getWeight() / 20.0); } else if (hasFlag(F_CLUB) && hasSubType(S_SWORD)) { return (float)(Math.ceil(entity.getWeight() / 20.0 * 2.0) / 2.0); } else if (hasFlag(F_CLUB) && hasSubType(S_MACE)) { return (float)(Math.ceil(entity.getWeight() / 10.0)); } else if (hasFlag(F_MASC)) { if (hasSubType(S_SUPERCHARGER)) { Engine e = entity.getEngine(); if(e == null) return 0.0f; return (float)(Math.ceil(e.getWeightEngine() / 10.0 * 2.0) / 2.0); } if (entity.isClan()) { return Math.round(entity.getWeight() / 25.0f); } return Math.round(entity.getWeight() / 20.0f); } else if (hasFlag(F_TARGCOMP)) { // based on tonnage of direct_fire weaponry double fTons = 0.0; for (Mounted m : entity.getWeaponList()) { WeaponType wt = (WeaponType)m.getType(); if (wt.hasFlag(WeaponType.F_DIRECT_FIRE)) { fTons += wt.getTonnage(entity); } } if (entity.isClan()) { return (float)Math.ceil(fTons / 5.0f); } return (float)Math.ceil(fTons / 4.0f); } else if ( EquipmentType.getArmorTypeName(T_ARMOR_FERRO_FIBROUS).equals(internalName) ) { double tons = 0.0; if ( entity.isClanArmor()) { tons = entity.getTotalOArmor() / ( 16 * 1.2 ); } else { tons = entity.getTotalOArmor() / ( 16 * 1.12 ); } tons = Math.ceil( tons * 2.0 ) / 2.0; return (float) tons; } else if ( EquipmentType.getArmorTypeName(T_ARMOR_LIGHT_FERRO).equals(internalName) ) { double tons = entity.getTotalOArmor() / (16*1.06); tons = Math.ceil( tons * 2.0 ) / 2.0; return (float) tons; } else if ( EquipmentType.getArmorTypeName(T_ARMOR_HEAVY_FERRO).equals(internalName) ) { double tons = entity.getTotalOArmor() / (16*1.24); tons = Math.ceil( tons * 2.0 ) / 2.0; return (float) tons; } else if ( EquipmentType.getStructureTypeName(T_STRUCTURE_ENDO_STEEL).equals(internalName) ) { double tons = 0.0; tons = Math.ceil( entity.getWeight() / 10.0 ) / 2.0; return (float) tons; } else if ( EquipmentType.getStructureTypeName(T_STRUCTURE_ENDO_PROTOTYPE).equals(internalName) ) { double tons = 0.0; tons = Math.ceil( entity.getWeight() / 10.0 ) / 2.0; return (float) tons; } else if ( EquipmentType.getStructureTypeName(T_STRUCTURE_REINFORCED).equals(internalName) ) { double tons = 0.0; tons = Math.ceil( entity.getWeight() / 10.0 ) * 2.0; return (float) tons; } else if ( EquipmentType.getStructureTypeName(T_STRUCTURE_COMPOSITE).equals(internalName) ) { double tons = 0.0; tons = Math.ceil( entity.getWeight() / 10.0 ) / 2.0; return (float) tons; } else if (hasFlag(F_VACUUM_PROTECTION)) { return (float)Math.ceil(entity.getWeight() / 10.0); } else if (hasFlag(F_JUMP_BOOSTER)) { return (float)(Math.ceil(entity.getWeight() * entity.getOriginalJumpMP() / 10.0) / 2.0); } else if (hasFlag(F_HAND_WEAPON) && hasSubType(S_CLAW)) { return (int)Math.ceil(entity.getWeight() / 15); } // okay, I'm out of ideas return 1.0f; } public int getCriticals(Entity entity) { if (criticals != CRITICALS_VARIABLE) { return criticals; } // check for known formulas if (hasFlag(F_CLUB) && (hasSubType(S_HATCHET) || hasSubType(S_SWORD) || hasSubType(S_MACE_THB))) { return (int)Math.ceil(entity.getWeight() / 15.0); } else if (hasFlag(F_CLUB) && hasSubType(S_LANCE)) { return (int)Math.ceil(entity.getWeight() / 20.0); }else if (hasFlag(F_CLUB) && hasSubType(S_MACE)) { return (int)Math.ceil(entity.getWeight() / 10.0); } else if (hasFlag(F_MASC)) { if (entity.isClan()) { return Math.round(entity.getWeight() / 25.0f); } return Math.round(entity.getWeight() / 20.0f); } else if (hasFlag(F_TARGCOMP)) { // based on tonnage of direct_fire weaponry double fTons = 0.0; for (Mounted m : entity.getWeaponList()) { WeaponType wt = (WeaponType)m.getType(); if (wt.hasFlag(WeaponType.F_DIRECT_FIRE)) { fTons += wt.getTonnage(entity); } } if (entity.isClan()) { return (int)Math.ceil(fTons / 5.0f); } return (int)Math.ceil(fTons / 4.0f); } else if ( EquipmentType.getArmorTypeName(EquipmentType.T_ARMOR_FERRO_FIBROUS).equals(internalName) ) { if ( entity.isClanArmor() ) { return 7; } return 14; } else if ( EquipmentType.getStructureTypeName(T_STRUCTURE_ENDO_STEEL).equals(internalName) ) { if ( entity.isClan() ) { return 7; } return 14; } else if (hasFlag(F_JUMP_BOOSTER)) { return (entity instanceof QuadMech) ? 8 : 4; // all slots in all legs } else if (hasFlag(F_HAND_WEAPON) && hasSubType(S_CLAW)) { return (int)Math.ceil(entity.getWeight() / 15); } // right, well I'll just guess then return 1; } public double getBV(Entity entity) { if (bv != BV_VARIABLE) { return bv; } // check for known formulas if (hasFlag(F_CLUB) && hasSubType(S_HATCHET)) { return Math.ceil(entity.getWeight() / 5.0) * 1.5; } else if (hasFlag(F_CLUB) && hasSubType(S_MACE_THB)) { return Math.ceil(entity.getWeight() / 5.0) * 1.5; } else if (hasFlag(F_CLUB) && hasSubType(S_LANCE)) { return Math.ceil(entity.getWeight() / 5.0) * 1.0; } else if (hasFlag(F_CLUB) && hasSubType(S_MACE)) { return Math.ceil(entity.getWeight() / 4.0); } else if (hasFlag(F_CLUB) && hasSubType(S_SWORD)) { return (Math.ceil(entity.getWeight() / 10.0) + 1.0) * 1.725; } else if (hasFlag(F_TARGCOMP)) { // 20% of direct_fire weaponry BV (half for rear-facing) double fFrontBV = 0.0, fRearBV = 0.0; for (Mounted m : entity.getWeaponList()) { WeaponType wt = (WeaponType)m.getType(); if (wt.hasFlag(WeaponType.F_DIRECT_FIRE)) { if (m.isRearMounted()) { fRearBV += wt.getBV(entity); } else { fFrontBV += wt.getBV(entity); } } } if (fFrontBV > fRearBV) { return fFrontBV * 0.2 + fRearBV * 0.1; } return fRearBV * 0.2 + fFrontBV * 0.1; } else if (hasFlag(F_HAND_WEAPON) && hasSubType(S_CLAW)) { return (Math.ceil(entity.getWeight() / 7.0)) * 1.275; } // maybe it's 0 return 0; } /** * Add all the types of misc eq we can create to the list */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -