Building multiple unit types with productionPerXTerritories?
-
Hello! I'm making a mod of the 11 Nation WW2v3 (Anniversary Edition), and I'm trying to get some more interesting armies for the Minor Axis Powers, Sowjets Puppet States, France, Dutch, and Chinese, all of which use noPUproduction. I want them to be able to diversify their PU-less production as they expand and control more territories -- so if you only have 2 territories, you just get an infantry, but if you have 3 territories, you get some infantry and some artillery, that kind of thing.
The problem I'm having is that TripleA seems to only be recognizing and using whichever productionperXTerritories property comes last in my code. For example, if I type:
<attachment name="rulesAttachment" attachTo="Sowjets_Puppet_States" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="productionPerXTerritories" value="infantry" count="2"/> <option name="placementAnyTerritory" value="true"/> <option name="placementCapturedTerritory" value="true"/> <option name="placementPerTerritory" value="3"/> </attachment> <attachment name="rulesAttachment" attachTo="Sowjets_Puppet_States" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="productionPerXTerritories" value="artillery" count="3"/> <option name="placementAnyTerritory" value="true"/> <option name="placementCapturedTerritory" value="true"/> <option name="placementPerTerritory" value="3"/> </attachment>
then the game ignores the infantry and only awards free artillery to the Sowjets Puppet States. I've tried writing value="3:artillery" instead of value="artillery" count="3", and I've tried putting both productionperXTerritories statements in the same attachment block, but neither of those was effective.
Anyone have any other ideas or advice?
-
@jason-green-lowe hmm ... maybe try using a condition to activate each rulesAttachment separately ?
-
@beelee Interesting. Can you say more about what that means, or how to do that?
-
@jason-green-lowe so try using a condition/trigger. Triggers aren't used anymore but I think they still work. This from POS2
<attachment name="triggerAttachmentChinese4_ChineseOverrunTheirBorders" attachTo="Chinese" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
<option name="conditions" value="conditionAttachmentChinese4"/>
<option name="uses" value="1"/>
<option name="players" value="Chinese"/>
<option name="playerAttachmentName" value="RulesAttachment" count="rulesAttachment"/>
<option name="playerProperty" value="movementRestrictionTerritories" count="-reset-"/>
<option name="playerProperty" value="movementRestrictionType" count="disallowed"/>
<option name="playerProperty" value="productionPerXTerritories" count="-reset-3:infantry"/>
<option name="playerProperty" value="productionPerXTerritories" count="10:transport"/>
<option name="playerProperty" value="placementAnySeaZone" count="true"/>
</attachment> -
According to PoS2, you should be able to place multiple 'productionPerXTerritories' together, so add artillery production to the infantry:
<attachment name="rulesAttachment" attachTo="Sowjets_Puppet_States" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="productionPerXTerritories" value="infantry" count="2"/> <!-- artillery added --> <option name="productionPerXTerritories" value="artillery" count="3"/> <option name="placementAnyTerritory" value="true"/> <option name="placementCapturedTerritory" value="true"/> <option name="placementPerTerritory" value="3"/> </attachment>
If this does not work, then a bug request may need to be created.
Cheers...
-
@beelee I tried using the code from PoS 2, but I am getting an error message. Perhaps there is a problem with my syntax, although I tried to copy PoS 2 as closely as possible. Any other suggestions?
<attachment name="conditionAttachmentPuppet" attachTo="Sowjets_Puppet_States" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="alliedOwnershipTerritories" value="Novosibirsk" count="1"/> </attachment> <attachment name="triggerAttachmentPuppet" attachTo="Sowjets_Puppet_States" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachmentPuppet"/> <option name="uses" value="1"/> <option name="players" value="Sowjets_Puppet_States"/> <option name="playerAttachmentName" value="RulesAttachment" count="rulesAttachment"/> <option name="playerProperty" value="movementRestrictionTerritories" count="-reset-"/> <option name="playerProperty" value="movementRestrictionType" count="disallowed"/> <option name="playerProperty" value="productionPerXTerritories" count="-reset-2:infantry"/> <option name="playerProperty" value="productionPerXTerritories" count="3:artillery"/> <option name="playerProperty" value="productionPerXTerritories" count="4:transport"/> <option name="playerProperty" value="productionPerXTerritories" count="5:submarine"/> <option name="playerProperty" value="placementAnyTerritory" count="true"/> <option name="playerProperty" value="placementAnySeaZone" count="true"/> </attachment>
Text of Error Message:
Rules & Conditions: No rule attachment for:Sowjets_Puppet_States with name: rulesAttachment java.lang.IllegalStateException: Rules & Conditions: No rule attachment for:Sowjets_Puppet_States with name: rulesAttachment@wc_sumpton I tried your suggestion before my original post. That's what I meant by:
"I've tried putting both productionperXTerritories statements in the same attachment block." I'm open to other advice if you have any. -
@jason-green-lowe hmm ... maybe try adding the trigger/condition after the rulesAttachment. So in WCs example you'd have "conditions" above the productionPerXTerritories ? Maybe ?
Idk that doesn't seem quite right. wc will know
So rulesAttachment would be first
Edit
Ahh I see. You're trying to -reset- yea Idk have to wait for the smarter than me man lol -
@beelee Adding the trigger and the condition "after the rulesAttachment" sounds like the kind of thing the error message is trying to get me to do, but I have no idea how to it.
From my point of view, the problem is that a simple rulesAttachment ought to work just fine, without any conditions or triggers. I'm not trying to set custom rules that only kick in after a condition is met...on the contrary, I always want these custom rules to apply when people are playing my mod.
Because the simple rulesAttachment isn't working, I tried your suggestion to use the condition+trigger syntax instead, but that gives me an error message saying that the software couldn't find a rulesAttachment. Well, duh, of course it can't find a rulesAttachment, because there isn't one; I replaced the rulesAttachment with a condition and a trigger.
As far as the -reset- thing, that's not critical to my plans. I tried removing it, but I got the same error message anyway.
-
@jason-green-lowe well bummer. No easy fix. wc is "The Man" or one of them anyway, for triplea xml code though
He'll chime back in
-
@jason-green-lowe does ading this below the first line of rulesAttachment work ?
<option name="conditions" value="conditionAttachmentPuppet"/>
<attachment name="rulesAttachment" attachTo="Sowjets_Puppet_States" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
<option name="productionPerXTerritories" value="infantry" count="2"/>
<!-- artillery added -->
<option name="productionPerXTerritories" value="artillery" count="3"/>
<option name="placementAnyTerritory" value="true"/>
<option name="placementCapturedTerritory" value="true"/>
<option name="placementPerTerritory" value="3"/>
</attachment> -
@beelee So you keep talking about "after the rulesAttachment" or "below the first line of rulesAttachment," but that is not making any sense to me, because I don't know of any location in my document called "rulesAttachment."
To the best of my knowledge, there is not a rulesAttachment section of the document; there are just many attachments spread throughout the document, some of which are rulesAttachments.
Most of the code that you've suggested that I add to the file "below the first line of rulesAttachment" is itself a rulesAttachment, unless I am misunderstanding something.
I'm attaching my entire code file in case that helps us communicate better. The relevant lines are 1617 through 1632. Maybe you can tell me at what line number I should insert your code. WW2v3-1939-11N-custom.xml
-
@jason-green-lowe here is wc's suggestion
<attachment name="rulesAttachment" attachTo="Sowjets_Puppet_States" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
<option name="productionPerXTerritories" value="infantry" count="2"/>
<!-- artillery added -->
<option name="productionPerXTerritories" value="artillery" count="3"/>
<option name="placementAnyTerritory" value="true"/>
<option name="placementCapturedTerritory" value="true"/>
<option name="placementPerTerritory" value="3"/>
</attachment>I was thinking try adding the condition to activate it here
<attachment name="rulesAttachment" attachTo="Sowjets_Puppet_States" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
<option name="conditions" value="conditionAttachmentPuppet"/>
<option name="productionPerXTerritories" value="infantry" count="2"/>
<!-- artillery added -->
<option name="productionPerXTerritories" value="artillery" count="3"/>
<option name="placementAnyTerritory" value="true"/>
<option name="placementCapturedTerritory" value="true"/>
<option name="placementPerTerritory" value="3"/>
</attachment>But it doesn't seem to activate regardless so ... probably wouldn't work
-
Sorry, but I will not be able to help until after work. Will review xml then.
Cheers...
-
Hi all. Let's step back for a minute and do a little testing. First off @Jason-Green-Lowe requested to use multiple 'productionPerXTerritories' to grant different units for 'purchaseNoPU' players.
So I tested multiple 'productionPerXTerritories' giving player 'X' 1 infantry for every 2 territories, and 1 artillery for every 3 territories owned. The results were as I expected: 1 territory owned no units were given. 2 territories received 1 infantry, 3 territories received 1 infantry and 1 artillery, and 4 territories received 2 infantry and 1 artillery.
After reviewing @Jason-Green-Lowe xml I see many 'rulesAttachment' for each affected player. This will not work because each are named 'rulesAttachment', thus each player can have only one, and the game will select the last one on the list.
My suggestion, remove all the 'rulesAttachment' and the errant 'triggerAttachmentSowjets_Puppet_States1' and 'conditionAttachmentSowjets_Puppet_States1'. Then create 1 'rulesAttachment' for player "Sowjets_Puppet_States":
<attachment name="rulesAttachment" attachTo="Sowjets_Puppet_States" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="productionPerXTerritories" value="infantry" count="2"/> <!-- Commented out for testing <option name="productionPerXTerritories" value="artillery" count="3"/> <option name="productionPerXTerritories" value="transport" count="4"/> <option name="productionPerXTerritories" value="submarine" count="5"/> --> <option name="placementAnyTerritory" value="true"/> <option name="placementCapturedTerritory" value="true"/> <option name="placementPerTerritory" value="3"/> </attachment>
Test this, and if it works, move the comment line down and test again.
As for the problem with the trigger/condition that is a discussion for another time.
Hope this is helpful... have fun!
Cheers...
-
@wc_sumpton Thank you! This works exactly as intended. I appreciate both the solution and the fact that you took the time to explain what was going wrong and how to fix it! I feel much better now and I should be able to finish my mod.