Allow construction upgrades to be placed when the construction limit is reached#14553
Draft
VictoryFirst1 wants to merge 2 commits into
Draft
Allow construction upgrades to be placed when the construction limit is reached#14553VictoryFirst1 wants to merge 2 commits into
VictoryFirst1 wants to merge 2 commits into
Conversation
…is reached When trying to place a construction that consumes a construction in a territory, while both having the same constructionType, and maxConstructionPerTerritory is reached at the time of placing, the engine prevents the placement of the new construction, even though the old construction will be consumed, thus resulting in no net gain of the number of constructions with that constructionType. Example, the factory_upgrade unit in WWII Global 1940. This unit is labeled as 'factory', and consumes 'factory_minor' which is also labeled as 'factory'. When maxFactoriesPerTerritory is '1', the factory_upgrade cannot be placed because territories with a minor factory have the maxFactoriesPerTerritory limit reached. This PR will allow placement of the factory_upgrade unit in this specific situation. A check is made if the new construction consumes a construction in that territory with the same constructionType. If so, the cap is increased by 1 when trying to place this unit.
Changed the consumptionBonus from 1 to "existingCount". This way, when you have multiple units in the territory that can be consumed, you can place the new units in a single prompt. Otherwise, you would only be able to place one unit at a time. Pretty time-consuming when you have like 6. (example, trenches that can be upgraded by bunkers). Thanks to @Cernelius for this suggestion.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When trying to place a construction that consumes a construction with the same constructionType in a territory, and maxConstructionsPerTypePerTerr is temporarily violated because the sum of the old constructions and the new constructions exceeds this value, the engine prevents the placement of the new construction(s), even though the old construction(s) will be consumed, and resulting in no net gain of the number of constructions with that constructionType. Thus the engine should allow this as the maxConstructionsPerTypePerTerr is not technically exceeded.
Example, the factory_upgrade unit in WWII Global 1940. This unit is has constructionType 'factory', and consumes 'factory_minor' which is also labeled as 'factory'. When maxFactoriesPerTerritory is '1', the factory_upgrade cannot be placed because territories with a minor factory have the maxFactoriesPerTerritory limit reached.
This PR will allow placement of the factory_upgrade unit in this specific situation. A check is made if the new construction consumes a construction in that territory with the same constructionType. If so, the cap is increased by
1the number of existing units in the territory with that constructionType when trying to place this unit.Another example, you have units called "trench" and "bunker", both having constructionType "defensive_structure". "Bunker" consumes one "trench" during placement. Let's say maxConstructionsPerTypePerTerr is 6. If you have 4 trenches in a territory, the engine would formerly allow you to place only 2 bunkers in the territory. Then, there are 2 bunkers and 2 trenches in the territory, and the engine would allow you to place 2 more bunkers. If there were 6 trenches in the territory, the engine would prevent you from placing any bunkers in the territory at all.
With the PR, in the case of 4 trenches in the territory. the limit is increased to 10. Whatever the cap is, is increased by the existing number of units with that constructionType in the territory (in this case, 4 trenches). This allows you to place 6 bunkers in the territory, which is more than the required 4. When you try to place more than 4 bunkers, the engine will prevent this and show a warning message that there aren't enough units to consume.
Attempts to fix: #3359.
Notes to Reviewer
In the cases of the trenches/bunkers, ideal would be if the limit was equal to the sum of
So in the example above with the trenches/bunkers, best would be if the new cap was 8, because you could realistically only place 4 bunkers in the territory, resulting in a temporary max of 8 units. However, I don't know how to do this, so that's why I simply used "existingCount" to increase the cap with, as that will guarantee you will have enough placement slots to place all your units with a single prompt.