Package megamek.common
Class Crew
java.lang.Object
megamek.common.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 int
The number of hits that a pilot can take before he dies.static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final String
static final int
Defines the maximum value a Crew can have in any skillstatic final String
static final String
static final String
static final String
static final String
static final String
static final String
static 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 TypeMethodDescriptionint
Uses the table on TO p206 to calculate the number of crew hits based on percentage of total casualties.void
clearOptions
(String grpKey) int
int
countOptions
(String grpKey) void
boolean
Checks whether a role swap is scheduled for a command-console equipped unit and (if the new pilot is active) performs the swap.int
int
getArtillery
(int pos) int
int
boolean[]
int
int
getCrewFatigue
(int pos) int
int
int
The 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.int
getExternalId
(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) int
Deprecated, for removal: This API element is subject to removal in a future version.since 0.50.04 - No references found in MegaMekgetGender
(int pos) Gender[]
int
int
getGunnery
(int pos) int
int
getGunneryB
(int pos) int
int
getGunneryL
(int pos) int
int
getGunneryM
(int pos) int
getHits()
Used to determine whether the death threshold has been passed.int
getHits
(int pos) int
getName()
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 hasint
int
getPiloting
(int pos) int
getPiloting
(EntityMovementType moveType) LAMs use a different skill in AirMEK mode depending on whether they are grounded or airborne.getPortrait
(int pos) Portrait[]
int
for sensor ops, so these might be easily expanded later for rpgint
getSize()
The size of this crew.getSkillsAsString
(boolean rpgSkills) getSkillsAsString
(boolean showPiloting, boolean rpgSkills) getSkillsAsString
(int pos, boolean rpgSkills) getSkillsAsString
(int pos, boolean showPiloting, boolean rpgSkills) int
getStatusDesc
(int pos) boolean
int
getToughness
(int pos) boolean
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).boolean
Super heavy tripods gain benefits from having a technical officer.boolean
Tripods and QuadVees get special benefits if the dedicated gunner is active.boolean
Tripods and QuadVees get special benefits if the dedicated pilot is active.boolean
void
boolean
isActive()
The crew as a whole is considered active if any member is active.boolean
isActive
(int pos) boolean
boolean
isClanPilot
(int position) boolean
isCustom()
Returns whether this pilot has non-standard piloting or gunnery valuesboolean
isDead()
The crew is considered dead as a whole if all members are dead.boolean
isDead
(int pos) boolean
isDoomed()
Doomed status only applies to the crew as a whole.boolean
Determine if this pilot has abandoned her vehicle.boolean
boolean
The crew as a whole is considered ko this round if all active members are ko this round.boolean
isKoThisRound
(int pos) boolean
isMissing
(int pos) boolean
boolean
The crew is considered unconscious as a whole if none are active and at least one is not dead.boolean
isUnconscious
(int pos) static String
static Object
void
Called after the initiative bonus for the round has been calculated.void
Sets crew state fields back to defaults.void
setArtillery
(int artillery, int pos) void
setBackupGunnerPos
(int pos) void
setBackupPilotPos
(int pos) void
setClanPilot
(boolean clanPilot, int position) void
setCommandBonus
(int bonus) void
setCrewFatigue
(int fatigue, int position) void
setCurrentPilot
(int pos) Set the pilot slot.void
setCurrentSize
(int newSize) Accessor method to set the current crew size.void
setDead
(boolean dead) void
setDead
(boolean dead, int pos) void
setDoomed
(boolean doomed) Doomed status only applies to the crew as a whole.void
setEjected
(boolean abandoned) Specify if this pilot has abandoned her vehicle.void
setExternalIdAsString
(String i, int pos) void
void
setExtraDataForCrewMember
(int crewIndex, Map<String, String> dataMap) void
setFatigue
(int fatigue) Deprecated, for removal: This API element is subject to removal in a future version.since 0.50.04 - No references found in MegaMekvoid
void
setGunnery
(int gunnery) Sets the gunnery skill of the crew's default gunner.void
setGunnery
(int gunnery, int pos) void
setGunneryB
(int gunnery, int pos) void
setGunneryL
(int gunnery, int pos) void
setGunneryM
(int gunnery, int pos) void
setHits
(int hits) Deprecated, for removal: This API element is subject to removal in a future version.by multi-crew cockpits.void
setHits
(int hits, int pos) void
setInitBonus
(int bonus) void
setKoThisRound
(boolean koThisRound) Set ko value for all slots.void
setKoThisRound
(boolean koThisRound, int pos) void
setMissing
(boolean missing, int pos) Allows a unit with a multi-crew cockpit to fielded with less than a full crew.void
void
setNickname
(String nickname, int pos) void
setOptions
(PilotOptions options) void
setPiloting
(int piloting) Sets the piloting skill of the crew's default pilot.void
setPiloting
(int piloting, int pos) void
setPortrait
(Portrait portrait, int pos) void
setSize
(int newSize) Accessor method to set the crew size.void
setSwapConsoleRoles
(boolean swap) Schedules or clears a scheduled swap of roles in a command console-equipped unit.void
setToughness
(int t, int pos) void
setUnconscious
(boolean unconscious) void
setUnconscious
(boolean unconscious, int pos) void
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.writeExtraDataToXMLLine
(int pos)
-
Field Details
-
RANGEMASTER_NONE
- See Also:
-
RANGEMASTER_MEDIUM
- See Also:
-
RANGEMASTER_LONG
- See Also:
-
RANGEMASTER_EXTREME
- See Also:
-
HUMANTRO_NONE
- See Also:
-
HUMANTRO_MEK
- See Also:
-
HUMANTRO_AERO
- See Also:
-
HUMANTRO_VEE
- See Also:
-
HUMANTRO_BA
- See Also:
-
ENVSPC_NONE
- See Also:
-
ENVSPC_FOG
- See Also:
-
ENVSPC_HAIL
- See Also:
-
ENVSPC_LIGHT
- See Also:
-
ENVSPC_RAIN
- See Also:
-
ENVSPC_SNOW
- See Also:
-
ENVSPC_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_BLOODNAME
- 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
-
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
-
getGunnery
public int getGunnery() -
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
- 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:
true
if the pilot has abandoned her vehicle,false
if the pilot is still in the vehicle.
-
setEjected
public void setEjected(boolean abandoned) Specify if this pilot has abandoned her vehicle.- Parameters:
abandoned
- theboolean
value 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) -
getFatigue
Deprecated, for removal: This API element is subject to removal in a future version.since 0.50.04 - No references found in MegaMekThis method is showing 0 references from within MegaMek. If not needed in other projects, it should be removed. -
setFatigue
Deprecated, for removal: This API element is subject to removal in a future version.since 0.50.04 - No references found in MegaMekThis method is showing 0 references from within MegaMek. If not needed in other projects, it should be removed. -
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
-
setHits
Deprecated, for removal: This API element is subject to removal in a future version.by multi-crew cockpits. Replaced bysetHits(int, int)
-
setPiloting
public void setPiloting(int piloting) Sets the piloting skill of the crew's default pilot. -
setGunnery
public void setGunnery(int gunnery) Sets the gunnery skill of the crew's default gunner.
-