Production Limits & Production Value
I am working on a mod for Revised that has a 10%/turn upkeep cost. The easiest way to achieve this is multiplying all purchase costs and production values by 10 (and add the 10% upkeep cost).
The problem is that the number of units that can be placed at a factory is also being multiplied by 10.
I have tried doing it this way but it didn't work.
<attachment name="territoryAttachment" attachTo="Caucasus" javaClass="games.strategy.triplea.attachments.TerritoryAttachment" type="territory"> <option name="productionOnly" value="40"/><option name="unitProduction" value="4"/> </attachment>
I have tried a number of permutations of this, but nothing worked.
In Pact of Steel, the code reference is:
production values: the PU production of the territory. also sets unitProduction to the same value. (If setting unitProduction separately, please set "production" before setting "unitProduction") productionOnly values: this sets "production" without setting "unitProduction" unitProduction values: unitProduction defaults to whatever "production" is, so please set it after you set "production" If using property, "Damage From Bombing Done To Units Instead Of Territories", damage will be done to an individual Unit instead of a Territory. "unitProduction" lets you set the unit production potential of a territory, separate from the production. This means a territory with unitProduction = 2 will be able to produce 2 units there, regardless of if production is 0 or 20. (The damage potential of these units will normally be 2x the unitProduction, but this can be set individually by creative use of maxDamage and canProduceXUnits)
Am I doing something wrong here?
SlendyMcTendies last edited by SlendyMcTendies
@rogercooper Just off the top of my head, it sounds like you might need to keep a small list of variables that calculate this upkeep cost somehow and apply them to something like this:
<!--if Germans have at least 1 Infantry on the board, the condition is True--> <attachment name="conditionAttachment_InfantryPresent_Germans" attachTo="Germans" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="unitPresence" value="infantry" count="1-+"/> </attachment> <!--if our Condition is True, fire this trigger--> <attachment name="triggerAttachment_InfantryUpkeep_Germans" attachTo="Germans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="trigger" value="conditionAttachment_InfantryPresent_Germans"/> <option name="when" value="after:germansPlace"/> <!--fire after Place Phase, which is effectively the end of the turn--> <option name="resource" value="YourResource"/> <!--Target YourResource to be modified--> <option name="resourceCount" value="-$CalculationVariable$"/><!--Subtract our 10% Upkeep Cost--> </attachment>
Another Option: In Pact of Steel's documentation there's a section describing how to use the "each" keyword within conditions and triggers. I'm sure you could find a way to take 10% of the cost of each unit and apply it to this "each" keyword.
Sadly I'm rather tired and can't offer much more help at the moment. I'll make sure to follow up on this if either you don't figure it out or another kind soul hasn't chimed in by the time I'm fully coherent again.
After thinking about it more, unless each of your units cleanly divides by 10 into a whole number, upkeep seems like it is going to be extremely difficult to write for.
Unless there's a cool trick I'm not aware of (and there probably is, I've only been working with TripleA for a week) it looks like you'll have to account for every reasonable count of each unit that could be deployed by a player, manually decide what the cost for that count of units is going to be (as a whole number), and then apply a modification to their resource pool in a similar manner to the example I gave above.
If there's a way to perform calculations and rounding within the xml file, that would make things a bit easier, but it will still probably be tedious to write.
Using 'productionOnly' set the PUs of a territory when there is to be no unit production in that territory. To set PUs different from unit set 'production' prior to 'unitProduction':
<!-- 'productionOnly' is not used --> <option name="production" value="40"/> <option name="unitProduction" value ="4"/>
Hope this helps...
@wc_sumpton Does not work. I have tried a number of different ways of doing this without success. I suspect that "unitProduction" is not implemented correctly in TripleA.
I just checked using 'Pack of Steel 2'. Changing all capitals to half production:
<attachment name="territoryAttachment" attachTo="Russia" javaClass="games.strategy.triplea.attachments.TerritoryAttachment" type="territory"> <option name="production" value="8"/> <option name="capital" value="Russians"/> <option name="victoryCity" value="1"/> <option name="unitProduction" value="4"/> </attachment>
Even though I was able to purchase 8 Infantry units, I was only allowed to place 4 of them in Russia. So it seems to be working correctly.
@wc_sumpton I tried this, but it did not work. Maybe the unusually high number is causing a problem. Here is the way it is coded now:
<attachment name="territoryAttachment" attachTo="Caucasus" javaClass="games.strategy.triplea.attachments.TerritoryAttachment" type="territory"> <option name="production" value="40"/><option name="unitProduction" value="4"/> </attachment>
I am going to post it to github as is, I assume that the bug will be fixed at some point and human players should not take advantage of it.
Sorry it took so long to reply (Elden Ring is taking all my time).
For "production" and "unitProduction" to work then property "Damage From Bombing Done To Units Instead Of Territories" will need to be set to "true".
If you do a quick search for "unitProduction" you will find that there have been many discussions about this. May a request should be made to remove this requirement, or create a new property the deals only with "production".
@wc_sumpton TripleA has too many properties which must be set for another property to work and I generally poorly documented. I will try to fix.
Good luck on Elden Ring.
@wc_sumpton Works perfectly. I plan to have 10% upkeep cost scenarios for all the boardgame conversions.