Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/MegaMek/megamek.git
Browse files Browse the repository at this point in the history
  • Loading branch information
HammerGS committed Apr 1, 2020
2 parents 82d3723 + 8c8e935 commit cfefdfc
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 39 deletions.
Binary file added megamek/data/images/units/dropships/Aqueduct.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added megamek/data/images/units/dropships/Lee.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions megamek/data/images/units/mechset.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3643,6 +3643,7 @@ exact "Zeus-X ZEU-X4" "mechs/Zeus-X ZEU-X4.png"

#Dropships
chassis "Achilles" "dropships/achilles.png"
chassis "Aqueduct Liquid Carrier" "dropships/Aqueduct.png"
chassis "Aurora" "dropships/Aurora.png"
chassis "Avenger" "dropships/Avenger.png"
chassis "Behemoth" "dropships/Behemoth.png"
Expand Down Expand Up @@ -3674,6 +3675,7 @@ exact "Leopard (Pocket Warship)" "dropships/leopard.png"
exact "Leopard (PA)" "dropships/leopard.png"
exact "Leopard CV (2581)" "dropships/Leopard CV.png"
exact "Leopard CV (3054)" "dropships/Leopard CV.png"
chassis "Lee" "dropships/Lee.png"
chassis "Mammoth" "dropships/Mammoth.png"
chassis "Manatee" "dropships/Manatee.png"
chassis "Mercer" "dropships/Mercer.png"
Expand All @@ -3682,6 +3684,9 @@ exact "Merlin Ngake" "defaults/dropship_spheroid.png"
exact "Merlin R1" "defaults/dropship_spheroid.png"
chassis "Monarch" "dropships/Monarch.png"
chassis "Mule" "dropships/Mule.png"
chassis "Pentagon" "dropships/PentagonStandard.png"
chassis "Princess Luxury Liner" "dropships/PrincessLuxuryLiner_Standard.png"
exact "Princess Luxury Liner (Cargo)" "dropships/PrincessLuxuryLiner_Cargo.png"
chassis "Overlord" "dropships/overlord.png"
chassis "Outpost" "dropships/Outpost.png"
chassis "Saturn Patrol Ship" "dropships/Saturn Patrol Ship.png"
Expand Down
3 changes: 2 additions & 1 deletion megamek/docs/history.txt
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ VERSION HISTORY:
+ PR #1805: Adding BV Calculation to ChatLounge Entity Right Click
+ Data: New Sprites adding Icewind Metals Shadow Cats and Pendragon.
+ Data: Grasslands Map Pack (Thanks SimonLandmine for converting)

+ Issue #1797: Fix bot freeze when evaluating infantry moves against support vehicles and BA equipped with infantry weapons
+ PR #1810: Bot units with LRMs will no longer be stuck in indirect fire mode

v0.47.4 (2020-2-09 2200 UTC)
+ PR #1626: Add LargeCraft Roles to RatGen
Expand Down
42 changes: 38 additions & 4 deletions megamek/src/megamek/client/bot/princess/FireControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -1846,13 +1846,25 @@ FiringPlan getFullFiringPlan(final Entity shooter,
continue;
}


final double toHitThreshold = ammoConservation.get(weapon);
final WeaponFireInfo shoot = buildWeaponFireInfo(shooter, target, weapon, game, false);
final double toHitThreshold = ammoConservation.get(weapon);
WeaponFireInfo shoot = buildWeaponFireInfo(shooter, target, weapon, game, false);

// if we're below the threshold, try switching missile modes
if (shoot.getProbabilityToHit() <= toHitThreshold) {

int updatedMissileMode = switchMissileMode(weapon);

if (updatedMissileMode > -1) {
shoot = buildWeaponFireInfo(shooter, target, weapon, game, false);
shoot.setUpdatedFiringMode(updatedMissileMode);
}
}

if ((shoot.getProbabilityToHit() > toHitThreshold)) {
myPlan.add(shoot);
continue;
}
}

owner.log(getClass(), METHOD_NAME, LogLevel.DEBUG,
"\nTo Hit Chance (" + DECF.format(shoot.getProbabilityToHit()) + ") for " + weapon.getName() +
" is less than threshold (" + DECF.format(toHitThreshold) + ")");
Expand Down Expand Up @@ -3273,4 +3285,26 @@ public SearchlightAttackAction getSearchLightAction(Entity shooter, FiringPlan p

return null;
}

/**
* Attempts to switch the current weapon's firing mode between direct and indirect
* or vice versa. Returns -1 if the mode switch fails, or the weapon mode index if it succeeds.
* @return Mode switch result.
*/
private int switchMissileMode(Mounted weapon) {
// check that we're operating a missile weapon that can switch direct/indirect modes
// don't bother checking non-missile weapons
if (weapon.getType().hasFlag(Weapon.F_MISSILE) &&
weapon.getType().hasModeType(Weapon.MODE_MISSILE_INDIRECT)) {

// if we are able to switch the weapon to indirect fire mode, do so and try again
if (!weapon.curMode().equals(Weapon.MODE_MISSILE_INDIRECT)) {
return weapon.setMode(Weapon.MODE_MISSILE_INDIRECT);
} else {
return weapon.setMode("");
}
}

return -1;
}
}
11 changes: 10 additions & 1 deletion megamek/src/megamek/client/bot/princess/InfantryFireControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.ArrayList;
import java.util.List;

import megamek.common.BattleArmor;
import megamek.common.Compute;
import megamek.common.Entity;
import megamek.common.IGame;
Expand Down Expand Up @@ -115,8 +116,16 @@ public double getMaxDamageAtRange(final MovePath shooterPath, final MovePath tar

// case 1
if (weaponType.hasFlag(WeaponType.F_INFANTRY)) {
int infantryCount = 1;

if (shooter.isConventionalInfantry()) {
infantryCount = shooter.getInternal(Infantry.LOC_INFANTRY);
} else if (shooter instanceof BattleArmor) {
infantryCount = ((BattleArmor) shooter).getNumberActiverTroopers();
}

maxInfantryWeaponDamage += ((InfantryWeapon) weaponType).getInfantryDamage()
* ((Infantry) shooter).getInternal(Infantry.LOC_INFANTRY);
* infantryCount;
// field guns can't fire if the infantry unit has done anything
// other than turning
} else if (targetIsActualInfantry && fieldGunsDoDamage) {
Expand Down
34 changes: 2 additions & 32 deletions megamek/src/megamek/client/bot/princess/WeaponFireInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
import megamek.common.annotations.Nullable;
import megamek.common.logging.LogLevel;
import megamek.common.options.OptionsConstants;
import megamek.common.weapons.Weapon;
import megamek.common.weapons.capitalweapons.CapitalMissileWeapon;

/**
Expand Down Expand Up @@ -521,19 +520,9 @@ void initDamage(@Nullable final MovePath shooterPath,
} else {
setToHit(calcToHit());
}

// If we can't hit, set everything zero and return..
if (12 < getToHit().getValue()) {
int indirectMode = switchMissileMode();

if(indirectMode > -1) {
setUpdatedFiringMode(indirectMode);
initDamage(shooterPath, assumeUnderFlightPath, guess, bombPayload);
getWeapon().setMode(""); // make sure to reset the weapon firing mode
return;
}

owner.log(getClass(), METHOD_NAME, LogLevel.DEBUG, msg.append("\n\tImpossible toHit: ")
owner.log(getClass(), METHOD_NAME, LogLevel.DEBUG, msg.append("\n\tImpossible toHit: ")
.append(getToHit().getValue()).toString());
setProbabilityToHit(0);
setMaxDamage(0);
Expand Down Expand Up @@ -631,25 +620,6 @@ void initDamage(@Nullable final MovePath shooterPath,
}
}

/**
* Attempts to switch the current weapon's firing mode between direct and indirect
* or vice versa. Returns -1 if the mode switch fails, or the weapon mode index if it succeeds.
* @return Mode switch result.
*/
int switchMissileMode() {
//if we've already switched before, don't do it again
if(getUpdatedFiringMode() != null) {
return -1;
}

// if we are able to switch the weapon to indirect fire mode, do so and try again
if(!getWeapon().curMode().equals(Weapon.MODE_MISSILE_INDIRECT)) {
return getWeapon().setMode(Weapon.MODE_MISSILE_INDIRECT);
} else {
return getWeapon().setMode("");
}
}

WeaponAttackAction getWeaponAttackAction() {
final String METHOD_NAME = "getWeaponAttackAction(IGame)";
owner.methodBegin(getClass(), METHOD_NAME);
Expand Down Expand Up @@ -700,4 +670,4 @@ public Integer getUpdatedFiringMode() {
public void setUpdatedFiringMode(int mode) {
updatedFiringMode = mode;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ public void run(MovePath startingEdge) {

// now that we've got all our possible destinations, make sure to try every possible rotation,
// since facing matters for field guns and if using the "dig in" and "vehicle cover" tacops rules.
List<MovePath> rotatedPaths = new ArrayList<>();

for(MovePath path : infantryPaths) {
infantryPaths.addAll(AeroPathUtil.generateValidRotations(path));
rotatedPaths.addAll(AeroPathUtil.generateValidRotations(path));
}

infantryPaths.addAll(rotatedPaths);

// add "flee" option if we haven't done anything else
if(startingEdge.getFinalCoords().isOnBoardEdge(game.getBoard()) &&
startingEdge.getStepVector().size() == 0) {
Expand Down

0 comments on commit cfefdfc

Please sign in to comment.