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

Unit sell value does not account for price multipliers #1497

Closed
RAldrich opened this issue Feb 19, 2020 · 3 comments · Fixed by #1515
Closed

Unit sell value does not account for price multipliers #1497

RAldrich opened this issue Feb 19, 2020 · 3 comments · Fixed by #1515

Comments

@RAldrich
Copy link
Contributor

Environment

  • MekHQ 0.47.4
  • Linux Java 8

Description

Dropship sell values are not being computed correctly, they're low by several orders of magnitude. For example: a basic Mule dropship has a MegaMekLab / buy value of ~173 million, but the sell value is only ~3 million.

This throws off all campaign finance calculations.

Looking at Unit.java, I suspect that the dropship's parts (in particular but not limited to the engines) are not being added correctly. There are several places where parts are added for SmallCraft and Jumpships, but not Dropships.

Files

Mule_Correct_Price

Mule_Hanger_Price

Mule_Sell_Price

@RAldrich
Copy link
Contributor Author

Never mind my speculation about parts not getting added: Dropship extends SmallCraft (which seems like an odd design decision, but /shrug) so the conditions gating the engine parts should be returning true.

@RAldrich
Copy link
Contributor Author

Ok did some digging, and I think the culprit is that getSellValue() doesn't take into account the x28 (spheroid) or x36 (aerodyne) cost modifier that the MegaMekLab / getBuyCost() calculations do. Accounting for that and the 0.5 used parts multiplier explains gets you pretty close (but not exactly) to the sell price.

I assume this is unintended behavior? I would expect the campaign options "used equipment" modifiers to be the only thing making the sell price lower than the buy cost.

For reference:

mule_parts_dump.txt

mule_cost_breakdown.txt

@RAldrich
Copy link
Contributor Author

Further investigation shows that this is probably a more general issue of the sell price not accounting for price multipliers of any kind. That generally includes unit weight, but also things like Mech quirks or the premium placed on omni-units.

If all you're doing is selling units than this isn't a huge deal because you can manually edit the transaction to whatever you want. But because the sell value is the basis for most other monthly finances (including contract pay and the various upkeep cost types) it has a wider impact.

@RAldrich RAldrich changed the title Dropship sell value being calculated incorrectly. Unit sell value does not account for price multipliers Feb 20, 2020
RAldrich added a commit to RAldrich/mekhq that referenced this issue Feb 22, 2020
Fix MegaMek#1497

When computing construction costs, the final cost of many units is scaled by a multiplier.
Generally this is related to the unit's weight class or type (e.g. aerodyne dropships cost 36 times
the sum of their components costs).

This change causes getSellValue() to take this into consideration, generally resulting in higher
sell prices. Ideally the sell value of a perfect condition, undamaged Unit would match it's buy cost.
This change doesn't get all the way there (things like SI are still not accounted for), but this is
a step towards that goal that doesn't require a major redesign of the Entity cost calculation methods.
sixlettervariables added a commit that referenced this issue Feb 25, 2020
#1497: Scale Unit sell values by their Entity's price multiplier
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant