Package megamek.common.units
Class Crew
java.lang.Object
megamek.common.units.Crew
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
LAMPilot
Health status, skills, and miscellanea for an Entity crew.
While vehicle and vessel crews are treated as a single collective, with one set of skills, some multi-crew cockpits (Tripod, QuadVee, dual, command console) require tracking the health and skills of each crew member independently. These are referred to as "slots" and the slot number corresponds to an array index for the appropriate field.
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intThe number of hits that a pilot can take before he dies.static final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final intDefines the maximum value a Crew can have in any skillstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final Stringstatic final String -
Constructor Summary
ConstructorsConstructorDescriptionCreates a nameless P5/G4 crew of the given size.Crew(CrewType crewType, String name, int size, int gunneryL, int gunneryM, int gunneryB, int piloting, Gender gender, boolean clanPilot, Map<Integer, Map<String, String>> extraData) Crew(CrewType crewType, String name, int size, int gunnery, int piloting, Gender gender, boolean clanPilot, Map<Integer, Map<String, String>> extraData) -
Method Summary
Modifier and TypeMethodDescriptionintintintintintThe part of the effective gunnery that comes from the gamemaster's temporary modifier: effective minus stored, zero while no modifier is active.intintappliedPilotingModifier(EntityMovementType moveType) intUses the table on TO p206 to calculate the number of crew hits based on percentage of total casualties.voidclearOptions(String grpKey) intintcountOptions(String grpKey) voidbooleanChecks whether a role swap is scheduled for a command-console equipped unit and (if the new pilot is active) performs the swap.intintgetArtillery(int pos) intintboolean[]intintgetCrewFatigue(int pos) intintintThe current size of this crew.getDesc()Overall crew description, using the name of the first crew member in the case of multi-crew cockpits.getDesc(int pos) getDescVector(boolean gunneryOnly) Crew summary report used for victory phase.intgetExternalId(int pos) Use the first assigned slot as a general id for the crew.getExternalIdAsString(int pos) getExtraDataForCrewMember(int crewIndex) getExtraDataValue(int crewIndex, String key) getGender(int pos) Gender[]intintgetGunnery(int pos) intintgetGunneryB(int pos) intintgetGunneryL(int pos) intintgetGunneryM(int pos) intgetHits()Used to determine whether the death threshold has been passed.intgetHits(int pos) intgetName()getName(int pos) getNameAndRole(int pos) String[]getNames()getNickname(int pos) String[]getOptionList(String sep, String grpKey) Returns a string of all the option "codes" for this pilot, for a given group, using sep as the separatorgetOptions(String grpKey) Returns the options of the given category that this pilot hasintintgetPiloting(int pos) intgetPiloting(EntityMovementType moveType) LAMs use a different skill in AirMEK mode depending on whether they are grounded or airborne.getPortrait(int pos) Portrait[]intfor sensor ops, so these might be easily expanded later for rpgintgetSize()The size of this crew.The gamemaster-set temporary change to this crew's effective skills.getSkillsAsString(boolean rpgSkills) getSkillsAsString(boolean showPiloting, boolean rpgSkills) getSkillsAsString(int pos, boolean rpgSkills) Deprecated, for removal: This API element is subject to removal in a future version.getSkillsAsString(int pos, boolean showPiloting, boolean rpgSkills) intgetStatusDesc(int pos) booleanintgetToughness(int pos) booleanCockpit command console provides commander init bonus if both crew members are active (also requires advanced fire control and heavy/assault unit, which is not checked here).booleanSuper heavy tripods gain benefits from having a technical officer.booleanTripods and QuadVees get special benefits if the dedicated gunner is active.booleanTripods and QuadVees get special benefits if the dedicated pilot is active.booleanbooleanhasPendingConRoll(int pos) booleanvoidbooleanisActive()The crew as a whole is considered active if any member is active.booleanisActive(int pos) booleanbooleanisClanPilot(int position) booleanbooleanisCustom()Returns whether this pilot has non-standard piloting or gunnery valuesbooleanisDead()The crew is considered dead as a whole if all members are dead.booleanisDead(int pos) booleanisDoomed()Doomed status only applies to the crew as a whole.booleanDetermine if this pilot has abandoned her vehicle.booleanbooleanThe crew as a whole is considered ko this round if all active members are ko this round.booleanisKoThisRound(int pos) booleanisMissing(int pos) booleanbooleanThe crew is considered unconscious as a whole if none are active and at least one is not dead.booleanisUnconscious(int pos) static Stringstatic Objectprotected intprotected intprotected intprotected intprotected intprotected intprotected intrawPiloting(EntityMovementType moveType) voidCalled after the initiative bonus for the round has been calculated.voidSets crew state fields back to defaults.voidNot used yet, but if we need to clear pending con rolls.voidsetArtillery(int artillery, int pos) voidsetBackupGunnerPos(int pos) voidsetBackupPilotPos(int pos) voidsetClanPilot(boolean clanPilot, int position) voidsetCommandBonus(int bonus) voidsetCrewFatigue(int fatigue, int position) voidsetCurrentPilot(int pos) Set the pilot slot.voidsetCurrentSize(int newSize) Accessor method to set the current crew size.voidsetDead(boolean dead) voidsetDead(boolean dead, int pos) voidsetDoomed(boolean doomed) Doomed status only applies to the crew as a whole.voidsetEjected(boolean abandoned) Specify if this pilot has abandoned her vehicle.voidsetExternalIdAsString(String i, int pos) voidvoidsetExtraDataForCrewMember(int crewIndex, Map<String, String> dataMap) voidvoidsetGunnery(int gunnery, int pos) voidsetGunneryB(int gunnery, int pos) voidsetGunneryL(int gunnery, int pos) voidsetGunneryM(int gunnery, int pos) voidsetHits(int hits, int pos) voidsetInitBonus(int bonus) voidsetKoThisRound(boolean koThisRound) Set ko value for all slots.voidsetKoThisRound(boolean koThisRound, int pos) voidsetMissing(boolean missing, int pos) Allows a unit with a multi-crew cockpit to fielded with less than a full crew.voidvoidsetNickname(String nickname, int pos) voidsetOptions(PilotOptions options) voidsetPendingConRolls(boolean pendingConRolls, int crewPos) voidsetPiloting(int piloting, int pos) voidsetPortrait(Portrait portrait, int pos) voidsetSize(int newSize) Accessor method to set the crew size.voidsetSwapConsoleRoles(boolean swap) Schedules or clears a scheduled swap of roles in a command console-equipped unit.voidsetToughness(int t, int pos) voidsetUnconscious(boolean unconscious) voidsetUnconscious(boolean unconscious, int pos) voidWhen assigning skills randomly, we want to make sure the skills are assigned to the most appropriate position in crews where the pilot and gunner are separate.writeExtraDataToXMLLine(int pos)
-
Field Details
-
RANGEMASTER_NONE
- See Also:
-
RANGEMASTER_MEDIUM
- See Also:
-
RANGEMASTER_LONG
- See Also:
-
RANGEMASTER_EXTREME
- See Also:
-
HUMAN_TRO_NONE
- See Also:
-
HUMAN_TRO_MEK
- See Also:
-
HUMAN_TRO_AERO
- See Also:
-
HUMAN_TRO_VEE
- See Also:
-
HUMAN_TRO_BA
- See Also:
-
ENVIRONMENT_SPECIALIST_NONE
- See Also:
-
ENVIRONMENT_SPECIALIST_FOG
- See Also:
-
ENVIRONMENT_SPECIALIST_HAIL
- See Also:
-
ENVIRONMENT_SPECIALIST_LIGHT
- See Also:
-
ENVIRONMENT_SPECIALIST_RAIN
- See Also:
-
ENVIRONMENT_SPECIALIST_SNOW
- See Also:
-
ENVIRONMENT_SPECIALIST_WIND
- See Also:
-
SPECIAL_NONE
- See Also:
-
SPECIAL_ENERGY
- See Also:
-
SPECIAL_BALLISTIC
- See Also:
-
SPECIAL_MISSILE
- See Also:
-
MAP_GIVEN_NAME
- See Also:
-
MAP_SURNAME
- See Also:
-
MAP_BLOOD_NAME
- See Also:
-
MAP_PHENOTYPE
- See Also:
-
DEATH
public static final int DEATHThe number of hits that a pilot can take before he dies.- See Also:
-
MAX_SKILL
public static final int MAX_SKILLDefines the maximum value a Crew can have in any skill- See Also:
-
-
Constructor Details
-
Crew
Creates a nameless P5/G4 crew of the given size.- Parameters:
crewType- the crew type to use.
-
Crew
public Crew(CrewType crewType, String name, int size, int gunnery, int piloting, Gender gender, boolean clanPilot, Map<Integer, Map<String, String>> extraData) - Parameters:
crewType- the type of crewname- the name of the crew or commander.size- the crew size.gunnery- the crew's Gunnery skill.piloting- the crew's Piloting or Driving skill.gender- the gender of the crew or commanderclanPilot- if the crew or commander is a clanPilotextraData- any extra data passed to be stored with this Crew.
-
Crew
public Crew(CrewType crewType, String name, int size, int gunneryL, int gunneryM, int gunneryB, int piloting, Gender gender, boolean clanPilot, Map<Integer, Map<String, String>> extraData) - Parameters:
crewType- the type of crew.name- the name of the crew or commander.size- the crew size.gunneryL- the crew's "laser" Gunnery skill.gunneryM- the crew's "missile" Gunnery skill.gunneryB- the crew's "ballistic" Gunnery skill.piloting- the crew's Piloting or Driving skill.gender- the gender of the crew or commanderclanPilot- if the crew or commander is a clanPilotextraData- any extra data passed to be stored with this Crew.
-
-
Method Details
-
getNames
-
getName
-
getName
-
setName
-
getNicknames
-
getNickname
-
getNickname
-
setNickname
-
getGenders
-
getGender
-
getGender
-
hasPendingConRolls
public boolean hasPendingConRolls() -
hasPendingConRoll
public boolean hasPendingConRoll(int pos) -
setPendingConRolls
public void setPendingConRolls(boolean pendingConRolls, int crewPos) -
resetPendingConRolls
public void resetPendingConRolls()Not used yet, but if we need to clear pending con rolls. -
setGender
-
getClanPilots
public boolean[] getClanPilots() -
isClanPilot
public boolean isClanPilot() -
isClanPilot
public boolean isClanPilot(int position) -
setClanPilot
public void setClanPilot(boolean clanPilot, int position) -
getPortraits
-
getPortrait
-
setPortrait
-
getNameAndRole
- Parameters:
pos- The slot index for multi-crewed cockpits- Returns:
- For multi-slot crews, the crew member's name followed by the role. For-slot crews, the crew name only.
-
getSize
public int getSize()The size of this crew.- Returns:
- the number of crew members.
-
getCurrentSize
public int getCurrentSize()The current size of this crew.- Returns:
- the current number of crew members.
-
getCrewType
-
getSlotCount
public int getSlotCount()- Returns:
- The number of crew members that are tracked individually
-
getSkillModifiers
The gamemaster-set temporary change to this crew's effective skills. Always present; when no change is active it leaves every skill untouched.- Returns:
- the crew's temporary skill modifiers, never
null
-
getGunnery
public int getGunnery() -
appliedGunneryModifier
public int appliedGunneryModifier()The part of the effective gunnery that comes from the gamemaster's temporary modifier: effective minus stored, zero while no modifier is active. Lets a to-hit breakdown show the gamemaster's intervention as a line of its own instead of silently folding it into the skill number. Each gunnery variant has an applied modifier of its own, because the clamp to the skill range can eat a different part of the delta for each. -
appliedGunneryLModifier
public int appliedGunneryLModifier()- See Also:
-
appliedGunneryMModifier
public int appliedGunneryMModifier()- See Also:
-
appliedGunneryBModifier
public int appliedGunneryBModifier()- See Also:
-
appliedArtilleryModifier
public int appliedArtilleryModifier()- See Also:
-
appliedPilotingModifier
public int appliedPilotingModifier()- See Also:
-
appliedPilotingModifier
- See Also:
-
rawGunnery
protected int rawGunnery() -
rawGunneryL
protected int rawGunneryL() -
rawGunneryM
protected int rawGunneryM() -
rawGunneryB
protected int rawGunneryB() -
rawArtillery
protected int rawArtillery() -
rawPiloting
protected int rawPiloting() -
rawPiloting
-
getGunnery
public int getGunnery(int pos) -
getGunneryL
public int getGunneryL() -
getGunneryL
public int getGunneryL(int pos) -
getGunneryM
public int getGunneryM() -
getGunneryM
public int getGunneryM(int pos) -
getGunneryB
public int getGunneryB() -
getGunneryB
public int getGunneryB(int pos) -
getArtillery
public int getArtillery() -
getArtillery
public int getArtillery(int pos) -
getPiloting
public int getPiloting() -
getPiloting
public int getPiloting(int pos) -
getPiloting
LAMs use a different skill in AirMEK mode depending on whether they are grounded or airborne. -
getSkillsAsString
- Returns:
- a String showing the overall skills in the format gunnery/piloting
-
getSkillsAsString
- Parameters:
showPiloting- if false, only the gunnery skill is shown (used for ProtoMeks; may be ignored for other unit types)- Returns:
- a String showing the overall skills in the format gunnery/piloting
-
getSkillsAsString
@Deprecated(since="0.51.0", forRemoval=true) public String getSkillsAsString(int pos, boolean rpgSkills) Deprecated, for removal: This API element is subject to removal in a future version.- Returns:
- a String showing the skills for a particular slot in the format gunnery/piloting
-
getSkillsAsString
- Parameters:
showPiloting- if false, only the gunnery skill is shown (used for ProtoMeks; may be ignored for other unit types)- Returns:
- a String showing the skills for a particular slot in the format gunnery/piloting
-
getHits
public int getHits()Used to determine whether the death threshold has been passed. As the crew is not dead until each crew member slot is dead, we return the lowest value.- Returns:
- The damage level of the least damaged crew member.
-
calculateHits
public int calculateHits()Uses the table on TO p206 to calculate the number of crew hits based on percentage of total casualties. Used for ejection, boarding actions and such- Returns:
- The number of crew hits
-
getHits
public int getHits(int pos) -
getInitBonus
public int getInitBonus() -
getCommandBonus
public int getCommandBonus() -
setSize
public void setSize(int newSize) Accessor method to set the crew size.- Parameters:
newSize- The new size of this crew.
-
setCurrentSize
public void setCurrentSize(int newSize) Accessor method to set the current crew size.- Parameters:
newSize- The new size of this crew.
-
setGunnery
public void setGunnery(int gunnery, int pos) -
setGunneryL
public void setGunneryL(int gunnery, int pos) -
setGunneryM
public void setGunneryM(int gunnery, int pos) -
setGunneryB
public void setGunneryB(int gunnery, int pos) -
setArtillery
public void setArtillery(int artillery, int pos) -
setPiloting
public void setPiloting(int piloting, int pos) -
setHits
public void setHits(int hits, int pos) -
setInitBonus
public void setInitBonus(int bonus) -
setCommandBonus
public void setCommandBonus(int bonus) -
isUnconscious
public boolean isUnconscious()The crew is considered unconscious as a whole if none are active and at least one is not dead.- Returns:
- Whether at least one crew member is alive but none are conscious.
-
isUnconscious
public boolean isUnconscious(int pos) -
setUnconscious
public void setUnconscious(boolean unconscious) -
setUnconscious
public void setUnconscious(boolean unconscious, int pos) -
isDead
public boolean isDead()The crew is considered dead as a whole if all members are dead.- Returns:
- Whether all members of the crew are dead.
-
isDead
public boolean isDead(int pos) -
setDead
public void setDead(boolean dead) -
setDead
public void setDead(boolean dead, int pos) -
isMissing
public boolean isMissing(int pos) - Returns:
- Whether the unit was fielded without a crew member in the slot.
-
setMissing
public void setMissing(boolean missing, int pos) Allows a unit with a multi-crew cockpit to fielded with less than a full crew. Does not apply to collective crew (vehicles, infantry, large craft). -
isDoomed
public boolean isDoomed()Doomed status only applies to the crew as a whole.- Returns:
- Whether the crew is scheduled to die at the end of the phase.
-
setDoomed
public void setDoomed(boolean doomed) Doomed status only applies to the crew as a whole.- Parameters:
doomed- Whether the crew is scheduled to die at the end of the phase.
-
isActive
public boolean isActive()The crew as a whole is considered active if any member is active.- Returns:
- Whether the crew has at least one active member.
-
isActive
public boolean isActive(int pos) -
isKoThisRound
public boolean isKoThisRound()The crew as a whole is considered ko this round if all active members are ko this round.- Returns:
- true if all active members of the crew as knocked out this round
-
isKoThisRound
public boolean isKoThisRound(int pos) -
setKoThisRound
public void setKoThisRound(boolean koThisRound) Set ko value for all slots.- Parameters:
koThisRound- Whether the crew will go unconscious during this round.
-
setKoThisRound
public void setKoThisRound(boolean koThisRound, int pos) -
setOptions
-
getOptions
-
clearOptions
-
countOptions
public int countOptions() -
countOptions
-
getOptions
Returns the options of the given category that this pilot has -
getOptionList
Returns a string of all the option "codes" for this pilot, for a given group, using sep as the separator -
parseAdvantageName
-
parseAdvantageValue
-
getDesc
Overall crew description, using the name of the first crew member in the case of multi-crew cockpits. -
getDesc
-
getDescVector
Crew summary report used for victory phase.- Parameters:
gunneryOnly- Do not show the piloting skill
-
isCustom
public boolean isCustom()Returns whether this pilot has non-standard piloting or gunnery values -
hasEdgeRemaining
public boolean hasEdgeRemaining() -
decreaseEdge
public void decreaseEdge() -
isEjected
public boolean isEjected()Determine if this pilot has abandoned her vehicle.- Returns:
trueif the pilot has abandoned her vehicle,falseif the pilot is still in the vehicle.
-
setEjected
public void setEjected(boolean abandoned) Specify if this pilot has abandoned her vehicle.- Parameters:
abandoned- thebooleanvalue to set.
-
getSensorOps
public int getSensorOps()for sensor ops, so these might be easily expanded later for rpg -
isPilotingFatigued
public boolean isPilotingFatigued() -
isGunneryFatigued
public boolean isGunneryFatigued() -
getStatusDesc
- Returns:
- A description of the status of a single crew member
-
setExternalIdAsString
-
getExternalIdAsString
-
getExternalIdAsString
Use the first assigned slot as a general id for the crew.- Returns:
- The id of the first slot that is not set to "-1"
-
getExternalId
public int getExternalId(int pos) -
getToughness
public int getToughness(int pos) -
setToughness
public void setToughness(int t, int pos) -
getCrewFatigue
public int getCrewFatigue(int pos) -
setCrewFatigue
public void setCrewFatigue(int fatigue, int position) -
incrementFatigueCount
public void incrementFatigueCount() -
resetGameState
public void resetGameState()Sets crew state fields back to defaults. Used by MekHQ to clear game state. -
rollGunnerySkill
-
rollPilotingSkill
-
getCurrentPilotIndex
public int getCurrentPilotIndex() -
getCurrentGunnerIndex
public int getCurrentGunnerIndex() -
getBackupPilotPos
public int getBackupPilotPos() -
setBackupPilotPos
public void setBackupPilotPos(int pos) -
getBackupGunnerPos
public int getBackupGunnerPos() -
setBackupGunnerPos
public void setBackupGunnerPos(int pos) -
setCurrentPilot
public void setCurrentPilot(int pos) Set the pilot slot. If a multi-crew cockpit uses the same crew member as both pilot and gunner (i.e. cockpit command console), sets the gunner as well.- Parameters:
pos- The slot index to set as pilot.
-
sortRandomSkills
public void sortRandomSkills()When assigning skills randomly, we want to make sure the skills are assigned to the most appropriate position in crews where the pilot and gunner are separate. We're going to do it the simpler way and reassign the piloting and gunnery skills individually, resulting in a more specialized crew. -
hasDedicatedPilot
public boolean hasDedicatedPilot()Tripods and QuadVees get special benefits if the dedicated pilot is active.- Returns:
- Whether a Mek has a separate pilot who is active.
-
hasDedicatedGunner
public boolean hasDedicatedGunner()Tripods and QuadVees get special benefits if the dedicated gunner is active.- Returns:
- Whether a Mek has a separate gunner who is active.
-
hasActiveTechOfficer
public boolean hasActiveTechOfficer()Super heavy tripods gain benefits from having a technical officer.- Returns:
- Whether the tech officer is alive and conscious.
-
hasActiveCommandConsole
public boolean hasActiveCommandConsole()Cockpit command console provides commander init bonus if both crew members are active (also requires advanced fire control and heavy/assault unit, which is not checked here). Though the positions are named "pilot" and "commander" they can switch positions in the end phase of any turn so we need to check whichever is not currently acting as pilot.- Returns:
- Whether the unit has a commander that is not also acting as pilot currently or in the previous turn.
-
resetActedFlag
public void resetActedFlag()Called after the initiative bonus for the round has been calculated. -
getSwapConsoleRoles
public boolean getSwapConsoleRoles()- Returns:
- Whether the crew members in a command console-equipped unit are scheduled to swap roles at the end of the turn.
-
setSwapConsoleRoles
public void setSwapConsoleRoles(boolean swap) Schedules or clears a scheduled swap of roles in a command console-equipped unit.- Parameters:
swap- true for crew slots in a command console to swap roles at the end of the turn, otherwise false
-
doConsoleRoleSwap
public boolean doConsoleRoleSwap()Checks whether a role swap is scheduled for a command-console equipped unit and (if the new pilot is active) performs the swap. The swap flag is cleared regardless of whether a swap took place.- Returns:
- True if a swap was performed, otherwise false.
-
setExtraData
-
setExtraDataForCrewMember
-
getExtraData
-
getExtraDataForCrewMember
-
getExtraDataValue
-
writeExtraDataToXMLLine
-
isCrewTypeNone
public boolean isCrewTypeNone()
-