Building multiple unit types with productionPerXTerritories?
-
@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 thoughHe'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.

Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login