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

Force calculations getting massively screwed up in Wakanda mod #12001

Open
1 task done
SpacedOutChicken opened this issue Jul 21, 2024 · 2 comments · May be fixed by #12035
Open
1 task done

Force calculations getting massively screwed up in Wakanda mod #12001

SpacedOutChicken opened this issue Jul 21, 2024 · 2 comments · May be fixed by #12035
Labels

Comments

@SpacedOutChicken
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

Game Version

4.12.12-patch2

Describe the bug

Something about the Black Panther unit in my Wakanda for Unciv mod is messing up the force calculator. The unit itself has a base strength of 20, but it scales with era (maximum strength bonus is 400% during the Future era). Building this unit causes the force calculator to give the civilization a strength of over 800,000. The unit is not actually that overwhelmingly strong.

Steps to Reproduce

  1. Enable Wakanda for Unciv mod
  2. Build the Sacred Mound, causing the Black Panther unit to appear
  3. Wait one turn for the force calculator to catch up to the changes made
  4. The force displayed will now be unreasonably large

Screenshots

Screenshot (212)

Link to save file

https://github.com/SpacedOutChicken/Wakanda-for-Unciv

Operating System

Windows

Additional Information

No response

@SomeTroglodyte
Copy link
Collaborator

Seems like an overarching problem, not limited to era conditionals:

UniqueType.Strength -> {
if (unique.params[0].toInt() <= 0) continue
if (unique.conditionals.any { it.type == UniqueType.ConditionalVsUnits }) { // Bonus vs some units - a quarter of the bonus
power *= (unique.params[0].toInt() / 4f).toPercent()
} else if (
unique.conditionals.any {
it.type == UniqueType.ConditionalVsCity // City Attack - half the bonus
|| it.type == UniqueType.ConditionalAttacking // Attack - half the bonus
|| it.type == UniqueType.ConditionalDefending // Defense - half the bonus
|| it.type == UniqueType.ConditionalFightingInTiles
} // Bonus in terrain or feature - half the bonus
) {
power *= (unique.params[0].toInt() / 2f).toPercent()
} else {
power *= (unique.params[0].toInt()).toPercent() // Static bonus
}
}

... Any conditional not special-cased in that if (bad - should be when) decision tree is ignored and the Strength bonus evaluated as if unconditional, thus multiplying like rabbits.
Simplest would be testing unique.conditionals.isEmpty and only applying full bonus in that case, dropping the else (so zero bonus if no known conditional recognized). Better would be to think of a system to force conditionals that can apply to Strength to define a power calculation weight.

@SomeTroglodyte
Copy link
Collaborator

Actually, adding a new metamodifier <Weight for AI force calculation = [amount]> or somesuch, then deprecating the big if might be the best answer...? ... PR done. If it is merged, I'd add <Weight for AI force calculation = [100]%> to the medieval one, which gives the BP ~500 points...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants