Skip to content

Commit b4cf7e4

Browse files
committed
Added "Glass Jaw" SPA
- Introduced a new ability `Glass Jaw (Unofficial)` to the default SPA XML file. - Description: `-2 Toughness, Fatigue gain is doubled.` - XP cost is set to `-300`, providing a penalty for the associated flaw.
1 parent 0d69cda commit b4cf7e4

File tree

10 files changed

+1005
-880
lines changed

10 files changed

+1005
-880
lines changed

MekHQ/data/universe/defaultspa.xml

+8
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,14 @@
464464
</ability>
465465

466466
<!-- Misc SPA -->
467+
<ability>
468+
<lookupName>flaw_glass_jaw</lookupName>
469+
<displayName>Glass Jaw (Unofficial)</displayName>
470+
<desc>-2 Toughness, Fatigue gain is doubled.</desc>
471+
<xpCost>-300</xpCost>
472+
<weight>2</weight>
473+
<skillPrereq/>
474+
</ability>
467475
<ability>
468476
<lookupName>eagle_eyes</lookupName>
469477
<xpCost>100</xpCost>

MekHQ/src/mekhq/campaign/ResolveScenarioTracker.java

+194-142
Large diffs are not rendered by default.

MekHQ/src/mekhq/campaign/personnel/Person.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,10 @@
3232
import static java.lang.Math.round;
3333
import static megamek.codeUtilities.MathUtility.clamp;
3434
import static megamek.common.Compute.randomInt;
35-
import static mekhq.campaign.personnel.enums.BloodGroup.getRandomBloodGroup;
3635
import static megamek.common.enums.SkillLevel.REGULAR;
36+
import static mekhq.campaign.personnel.PersonnelOptions.FLAW_GLASS_JAW;
3737
import static mekhq.campaign.personnel.SkillType.S_ADMIN;
38+
import static mekhq.campaign.personnel.enums.BloodGroup.getRandomBloodGroup;
3839

3940
import java.io.PrintWriter;
4041
import java.time.LocalDate;
@@ -4792,6 +4793,12 @@ public boolean isRightTechTypeFor(final IPartWork part) {
47924793
return doctorId;
47934794
}
47944795

4796+
public int getTotalToughness() {
4797+
boolean hasGlassJaw = getOptions().booleanOption(FLAW_GLASS_JAW);
4798+
4799+
return toughness + (hasGlassJaw ? -2 : 0);
4800+
}
4801+
47954802
public int getToughness() {
47964803
return toughness;
47974804
}
@@ -4866,10 +4873,10 @@ public void diagnose(final Campaign campaign, final int hits) {
48664873
public int getAbilityTimeModifier(final Campaign campaign) {
48674874
int modifier = 100;
48684875
if (campaign.getCampaignOptions().isUseToughness()) {
4869-
if (getToughness() == 1) {
4876+
if (getTotalToughness() == 1) {
48704877
modifier -= 10;
48714878
}
4872-
if (getToughness() > 1) {
4879+
if (getTotalToughness() > 1) {
48734880
modifier -= 15;
48744881
}
48754882
} // TODO: Fully implement this for advanced healing

MekHQ/src/mekhq/campaign/personnel/PersonnelOptions.java

+24-24
Original file line numberDiff line numberDiff line change
@@ -27,21 +27,24 @@
2727
*/
2828
package mekhq.campaign.personnel;
2929

30-
import megamek.common.annotations.Nullable;
31-
import megamek.common.options.*;
32-
import megamek.logging.MMLogger;
33-
3430
import java.util.Enumeration;
3531
import java.util.Hashtable;
3632
import java.util.List;
3733
import java.util.Vector;
3834

35+
import megamek.common.annotations.Nullable;
36+
import megamek.common.options.AbstractOptionsInfo;
37+
import megamek.common.options.IBasicOptionGroup;
38+
import megamek.common.options.IOption;
39+
import megamek.common.options.IOptionGroup;
40+
import megamek.common.options.IOptionInfo;
41+
import megamek.common.options.OptionsConstants;
42+
import megamek.common.options.PilotOptions;
43+
import megamek.logging.MMLogger;
44+
3945
/**
40-
* An extension of PilotOptions that adds MekHQ-specific SPAs and edge triggers
41-
* for support and command
42-
* actions. Display names and descriptions are taken from SpecialAbility when
43-
* present, otherwise
44-
* from the MM option.
46+
* An extension of PilotOptions that adds MekHQ-specific SPAs and edge triggers for support and command actions. Display
47+
* names and descriptions are taken from SpecialAbility when present, otherwise from the MM option.
4548
*
4649
* @author Neoancient
4750
*/
@@ -59,6 +62,7 @@ public class PersonnelOptions extends PilotOptions {
5962
public static final String TECH_ENGINEER = "tech_engineer";
6063
public static final String TECH_FIXER = "tech_fixer";
6164
public static final String TECH_MAINTAINER = "tech_maintainer";
65+
public static final String FLAW_GLASS_JAW = "flaw_glass_jaw";
6266

6367
@Override
6468
public void initialize() {
@@ -67,7 +71,7 @@ public void initialize() {
6771
IBasicOptionGroup l3a = null;
6872
IBasicOptionGroup edge = null;
6973
IBasicOptionGroup md = null;
70-
for (Enumeration<IBasicOptionGroup> e = getOptionsInfoImp().getGroups(); e.hasMoreElements();) {
74+
for (Enumeration<IBasicOptionGroup> e = getOptionsInfoImp().getGroups(); e.hasMoreElements(); ) {
7175
final IBasicOptionGroup group = e.nextElement();
7276
if ((null == l3a) && group.getKey().equals(PilotOptions.LVL3_ADVANTAGES)) {
7377
l3a = group;
@@ -102,6 +106,7 @@ public void initialize() {
102106
addOption(l3a, TECH_ENGINEER, false);
103107
addOption(l3a, TECH_FIXER, false);
104108
addOption(l3a, TECH_MAINTAINER, false);
109+
addOption(l3a, FLAW_GLASS_JAW, false);
105110

106111
addOption(edge, EDGE_MEDICAL, true);
107112
addOption(edge, EDGE_REPAIR_BREAK_PART, true);
@@ -122,8 +127,8 @@ public void initialize() {
122127
break;
123128
default:
124129
throw new IllegalStateException(
125-
"Unexpected value in mekhq/campaign/personnel/PersonnelOptions.java/initialize: "
126-
+ option.getGroup());
130+
"Unexpected value in mekhq/campaign/personnel/PersonnelOptions.java/initialize: " +
131+
option.getGroup());
127132
}
128133
}
129134
}
@@ -143,7 +148,7 @@ protected void addOption(IBasicOptionGroup group, String name, int type, Object
143148
* Returns the options of the given category that this pilot has
144149
*/
145150
public Enumeration<IOption> getOptions(String grpKey) {
146-
for (Enumeration<IOptionGroup> i = getGroups(); i.hasMoreElements();) {
151+
for (Enumeration<IOptionGroup> i = getGroups(); i.hasMoreElements(); ) {
147152
IOptionGroup group = i.nextElement();
148153

149154
if (group.getKey().equalsIgnoreCase(grpKey)) {
@@ -165,7 +170,7 @@ public void acquireAbility(final String type, final String name, final @Nullable
165170
if (null != spa) {
166171
toRemove = spa.getRemovedAbilities();
167172
}
168-
for (Enumeration<IOption> i = getOptions(type); i.hasMoreElements();) {
173+
for (Enumeration<IOption> i = getOptions(type); i.hasMoreElements(); ) {
169174
IOption ability = i.nextElement();
170175
if (ability.getName().equals(name)) {
171176
ability.setValue(value);
@@ -185,11 +190,9 @@ protected AbstractOptionsInfo getOptionsInfoImp() {
185190
}
186191

187192
/**
188-
* Custom IOptionsInfo class that allows adding additional options to the base
189-
* MegaMek
190-
* options before finalizing and also holds a hash of IOptionInfo objects for
191-
* the abilities
192-
* so we can provide names and descriptions for the MekHQ-specific options.
193+
* Custom IOptionsInfo class that allows adding additional options to the base MegaMek options before finalizing and
194+
* also holds a hash of IOptionInfo objects for the abilities so we can provide names and descriptions for the
195+
* MekHQ-specific options.
193196
*
194197
* @author Neoancient
195198
*/
@@ -224,11 +227,8 @@ private void setOptionInfo(String name) {
224227
}
225228

226229
/**
227-
* Access to ability names and descriptions from <code>SpecialAbility</code> if
228-
* the ability
229-
* has an entry, otherwise checks for the ability the MM PilotOptions class. If
230-
* not found
231-
* in either place, returns the lookup key instead.
230+
* Access to ability names and descriptions from <code>SpecialAbility</code> if the ability has an entry, otherwise
231+
* checks for the ability the MM PilotOptions class. If not found in either place, returns the lookup key instead.
232232
*
233233
* @author Neoancient
234234
*/

MekHQ/src/mekhq/campaign/personnel/education/TrainingCombatTeams.java

+4-9
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
package mekhq.campaign.personnel.education;
2929

3030
import static java.lang.Math.round;
31+
import static mekhq.campaign.personnel.PersonnelOptions.FLAW_GLASS_JAW;
3132
import static mekhq.campaign.personnel.SkillType.EXP_GREEN;
3233
import static mekhq.utilities.ReportingUtilities.CLOSING_SPAN_TAG;
3334
import static mekhq.utilities.ReportingUtilities.spanOpeningWithCustomColor;
@@ -76,14 +77,6 @@ public class TrainingCombatTeams {
7677
private static final String BUNDLE_NAME = "mekhq.resources.Education";
7778
private static ResourceBundle resources = ResourceBundle.getBundle(BUNDLE_NAME, MekHQ.getMHQOptions().getLocale());
7879

79-
/**
80-
* Represents the fatigue gained by combat team members during training.
81-
*
82-
* <p>This is currently set to 3 which, when factoring in fatigue recovery, will result in a
83-
* gain of 2 Fatigue per week.</p>
84-
*/
85-
private final static int FATIGUE_GAIN = 2;
86-
8780
/**
8881
* Processes all training combat teams in the campaign.
8982
*
@@ -177,8 +170,10 @@ private static void performTraining(Campaign campaign, Force force, Person comma
177170

178171
for (Person trainee : unit.getActiveCrew()) {
179172
if (campaign.getCampaignOptions().isUseFatigue()) {
173+
int fatigueChangeRate = campaign.getCampaignOptions().getFatigueRate();
174+
boolean hasGlassJaw = trainee.getOptions().booleanOption(FLAW_GLASS_JAW);
180175

181-
trainee.changeFatigue(FATIGUE_GAIN);
176+
trainee.changeFatigue(fatigueChangeRate * (hasGlassJaw ? 4 : 2));
182177
}
183178

184179
if (commander.getUnit().getActiveCrew().contains(trainee)) {

0 commit comments

Comments
 (0)