Skip to content

Commit

Permalink
Merge pull request #6070 from kuronekochomusuke/disableAutoEjectForCl…
Browse files Browse the repository at this point in the history
…anMeks

default autoeject to disabled for clan meks
  • Loading branch information
SJuliez authored Oct 7, 2024
2 parents 693da04 + fbca76b commit 89a48df
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 28 deletions.
17 changes: 10 additions & 7 deletions megamek/src/megamek/common/Game.java
Original file line number Diff line number Diff line change
Expand Up @@ -1216,13 +1216,16 @@ public synchronized void addEntity(Entity entity, boolean genEvent) {
}

// And... lets get this straight now.
if ((entity instanceof Mek)
&& getOptions().booleanOption(OptionsConstants.RPG_CONDITIONAL_EJECTION)) {
((Mek) entity).setAutoEject(true);
((Mek) entity).setCondEjectAmmo(!entity.hasCase() && !entity.hasCASEII());
((Mek) entity).setCondEjectEngine(true);
((Mek) entity).setCondEjectCTDest(true);
((Mek) entity).setCondEjectHeadshot(true);
if (entity instanceof Mek mek) {
if (getOptions().booleanOption(OptionsConstants.RPG_CONDITIONAL_EJECTION)) {
mek.setAutoEject(true);
mek.setCondEjectAmmo(!entity.hasCase() && !entity.hasCASEII());
mek.setCondEjectEngine(true);
mek.setCondEjectCTDest(true);
mek.setCondEjectHeadshot(true);
} else {
mek.setAutoEject(!entity.hasCase() && !entity.hasCASEII());
}
}

if (genEvent) {
Expand Down
30 changes: 16 additions & 14 deletions megamek/src/megamek/common/MULParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -1214,24 +1214,26 @@ private void setCrewAttributes(final @Nullable GameOptions options, final Entity
// Set the crew for this entity.
entity.setCrew(crew);

if (attributes.containsKey(ATTR_AUTOEJECT) && !attributes.get(ATTR_AUTOEJECT).isBlank()) {
((Mek) entity).setAutoEject(Boolean.parseBoolean(attributes.get(ATTR_AUTOEJECT)));
}
if (entity instanceof Mek mek) {
if (attributes.containsKey(ATTR_AUTOEJECT) && !attributes.get(ATTR_AUTOEJECT).isBlank()) {
mek.setAutoEject(Boolean.parseBoolean(attributes.get(ATTR_AUTOEJECT)));
}

if (attributes.containsKey(ATTR_CONDEJECTAMMO) && !attributes.get(ATTR_CONDEJECTAMMO).isBlank()) {
((Mek) entity).setCondEjectAmmo(Boolean.parseBoolean(attributes.get(ATTR_CONDEJECTAMMO)));
}
if (attributes.containsKey(ATTR_CONDEJECTAMMO) && !attributes.get(ATTR_CONDEJECTAMMO).isBlank()) {
mek.setCondEjectAmmo(Boolean.parseBoolean(attributes.get(ATTR_CONDEJECTAMMO)));
}

if (attributes.containsKey(ATTR_CONDEJECTENGINE) && !attributes.get(ATTR_CONDEJECTENGINE).isBlank()) {
((Mek) entity).setCondEjectEngine(Boolean.parseBoolean(attributes.get(ATTR_CONDEJECTENGINE)));
}
if (attributes.containsKey(ATTR_CONDEJECTENGINE) && !attributes.get(ATTR_CONDEJECTENGINE).isBlank()) {
mek.setCondEjectEngine(Boolean.parseBoolean(attributes.get(ATTR_CONDEJECTENGINE)));
}

if (attributes.containsKey(ATTR_CONDEJECTCTDEST) && !attributes.get(ATTR_CONDEJECTCTDEST).isBlank()) {
((Mek) entity).setCondEjectCTDest(Boolean.parseBoolean(attributes.get(ATTR_CONDEJECTCTDEST)));
}
if (attributes.containsKey(ATTR_CONDEJECTCTDEST) && !attributes.get(ATTR_CONDEJECTCTDEST).isBlank()) {
mek.setCondEjectCTDest(Boolean.parseBoolean(attributes.get(ATTR_CONDEJECTCTDEST)));
}

if (attributes.containsKey(ATTR_CONDEJECTHEADSHOT) && !attributes.get(ATTR_CONDEJECTHEADSHOT).isBlank()) {
((Mek) entity).setCondEjectHeadshot(Boolean.parseBoolean(attributes.get(ATTR_CONDEJECTHEADSHOT)));
if (attributes.containsKey(ATTR_CONDEJECTHEADSHOT) && !attributes.get(ATTR_CONDEJECTHEADSHOT).isBlank()) {
mek.setCondEjectHeadshot(Boolean.parseBoolean(attributes.get(ATTR_CONDEJECTHEADSHOT)));
}
}
}
}
Expand Down
7 changes: 0 additions & 7 deletions megamek/src/megamek/common/MekFileParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -504,13 +504,6 @@ else if (m.getType().hasFlag(MiscType.F_APOLLO)) {
}
}

if ((ent instanceof Mek) && (m.getType().hasFlag(MiscType.F_CASE) || m.getType().hasFlag(MiscType.F_CASEII)
|| m.getType().hasFlag(MiscType.F_CASEP)

)) {
((Mek) ent).setAutoEject(false);
}

if ((ent instanceof Mek)
&& m.getType().hasFlag(
MiscType.F_ACTUATOR_ENHANCEMENT_SYSTEM)) {
Expand Down

0 comments on commit 89a48df

Please sign in to comment.