Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mounted rework #5406

Merged
merged 17 commits into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from 16 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions megamek/src/megamek/client/bot/PhysicalCalculator.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
import megamek.common.actions.KickAttackAction;
import megamek.common.actions.PunchAttackAction;
import megamek.common.actions.PushAttackAction;
import megamek.common.equipment.MiscMounted;
import megamek.common.options.OptionsConstants;

public final class PhysicalCalculator {
Expand Down Expand Up @@ -313,7 +314,7 @@ static PhysicalOption getBestPhysicalAttack(Entity from, Entity to,
int target_arc;
int location_table;
int bestType = PhysicalOption.NONE;
Mounted bestClub = null;
MiscMounted bestClub = null;
boolean targetConvInfantry = false;
boolean fromAptPiloting = from.hasAbility(OptionsConstants.PILOT_APTITUDE_PILOTING);
boolean toAptPiloting = to.hasAbility(OptionsConstants.PILOT_APTITUDE_PILOTING);
Expand Down Expand Up @@ -425,7 +426,7 @@ static PhysicalOption getBestPhysicalAttack(Entity from, Entity to,
}

// Check for mounted club-type weapon or carried improvised club
for (Mounted club : from.getClubs()) {
for (MiscMounted club : from.getClubs()) {
// If the target is a Mech, must determine if it hits full body,
// punch, or kick table
if (to instanceof Mech) {
Expand Down
5 changes: 3 additions & 2 deletions megamek/src/megamek/client/bot/PhysicalOption.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import megamek.common.actions.KickAttackAction;
import megamek.common.actions.PunchAttackAction;
import megamek.common.actions.PushAttackAction;
import megamek.common.equipment.MiscMounted;

/**
* TODO: add more options, pushing, kick both for quad mechs, etc.
Expand Down Expand Up @@ -59,15 +60,15 @@ public class PhysicalOption {
INarcPod i_target;
double expectedDmg;
int type;
Mounted club;
MiscMounted club;

public PhysicalOption(Entity attacker) {
this.attacker = attacker;
this.type = NONE;
}

public PhysicalOption(Entity attacker, Targetable target, double dmg,
int type, Mounted club) {
int type, MiscMounted club) {
this.attacker = attacker;
this.target = target;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@

import megamek.common.*;
import megamek.common.actions.ArtilleryAttackAction;
import megamek.common.equipment.AmmoMounted;
import megamek.common.equipment.WeaponMounted;
import megamek.common.options.OptionsConstants;

/**
Expand Down Expand Up @@ -192,9 +194,9 @@ public void initializeForTargetingPhase() {

private boolean getAmmoTypeAvailable(Entity shooter, AmmoType.Munitions mtype) {
boolean available = false;
for (Mounted weapon: shooter.getWeaponList()){
for (WeaponMounted weapon: shooter.getWeaponList()){
if (weapon.getType().hasFlag(WeaponType.F_ARTILLERY)){
for (Mounted ammo: shooter.getAmmo(weapon)) {
for (AmmoMounted ammo: shooter.getAmmo(weapon)) {
if (((AmmoType) ammo.getType()).getMunitionType().contains(mtype)
&& !weapon.isFired() && ammo.getUsableShotsLeft() > 0) {
available = true;
Expand Down Expand Up @@ -367,19 +369,19 @@ private FiringPlan calculateIndirectArtilleryPlan(Entity shooter, Game game, Pri
// or we have a 1+ top valued coordinates.
// Track ADA WFIs separately.
List<WeaponFireInfo> topValuedADAInfos = new ArrayList<>();
for (Mounted currentWeapon : shooter.getWeaponList()) {
for (WeaponMounted currentWeapon : shooter.getWeaponList()) {
List<WeaponFireInfo> topValuedFireInfos = new ArrayList<>();
double maxDamage = 0;
if (currentWeapon.getType().hasFlag(WeaponType.F_ARTILLERY)) {
WeaponType wType = (WeaponType) currentWeapon.getType();
WeaponType wType = currentWeapon.getType();
int damage = wType.getRackSize(); // crazy, but rack size appears to correspond to given damage values for arty pieces in tacops

// Iterate over all loaded Artillery ammo so we can compare various options
for (final Mounted ammo : shooter.getAmmo(currentWeapon)) {
for (final AmmoMounted ammo : shooter.getAmmo(currentWeapon)) {
// for each enemy unit, evaluate damage value of firing at its hex.
// keep track of top target hexes with the same value and fire at them
boolean isADA = ((AmmoType) ammo.getType()).getMunitionType().contains(AmmoType.Munitions.M_ADA);
boolean isSmoke = ((AmmoType) ammo.getType()).getMunitionType().contains(AmmoType.Munitions.M_SMOKE);
boolean isADA = ammo.getType().getMunitionType().contains(AmmoType.Munitions.M_ADA);
boolean isSmoke = ammo.getType().getMunitionType().contains(AmmoType.Munitions.M_SMOKE);
for (Targetable target : targetSet) {
WeaponFireInfo wfi;
double damageValue = 0.0;
Expand Down Expand Up @@ -499,7 +501,7 @@ private FiringPlan calculateIndirectArtilleryPlan(Entity shooter, Game game, Pri
* @param owner
* @return
*/
private WeaponFireInfo getTAGInfo(Mounted weapon, Entity shooter, Game game, Princess owner) {
private WeaponFireInfo getTAGInfo(WeaponMounted weapon, Entity shooter, Game game, Princess owner) {
WeaponFireInfo retval = null;
double hitOdds = 0.0;

Expand Down
Loading
Loading