destroysPUs Causing Error
-
I’m trying to implement a feature mimicking the World War II Global 1940 Balance Mod3 XML whereby on hand PUs are captured for the first time a capital is taken, but after that the PUs are destroyed. In other words, so that the attacker can’t repeatedly take the defenders cash for a capital that keeps trading hands. This is done by turning on the destroysPUs property via a trigger after the first time a capital is taken.
Here’s a sample from the XML which I took from Balance Mod which is replicated for all Attacker/Defender combinations:
<attachment name="triggerFrenchDestroyPUsGermans" attachTo="French" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachment_French_1_Lose_France"/> <option name="uses" value="1"/> <option name="when" value="after:germansBattle"/> <option name="players" value="French"/> <option name="playerAttachmentName" value="PlayerAttachment" count="playerAttachment"/> <option name="playerProperty" value="destroysPUs" count="true"/> </attachment>
When the Germans take the French capital however, the game crashes with the below error:
"No player attachment for:French with name:playerAttachment
java.lang.IllegalStateException: No player attachment for:French with name:playerAttachment"
Oddly, the game is stable if a couple of the capitals are captured, but the majority will crash it with a similar error.
I’m struggling to understand what the issue is, especially because it’s fine for some capitals and not others. Does anyone have any suggestions what my problem might be? I’m guessing it’s simple but so far it’s eluding me.
Thanks, in advance.
-
@Contango yea I had some trouble adding that also. A lot going on. I have these two triggers for France and Germany for PlayerAttachments
<attachment name="triggerGermansDestroyPUsFrench" attachTo="Germans" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
<option name="conditions" value="conditionAttachment_Germans_1_Lose_Germany1"/>
<option name="uses" value="1"/>
<option name="when" value="after:frenchBattle"/>
<option name="players" value="Germans"/>
<option name="playerAttachmentName" value="PlayerAttachment" count="playerAttachment"/>
<option name="playerProperty" value="destroysPUs" count="true"/>
</attachment><attachment name="triggerFrenchDestroyPUsGermans" attachTo="French" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player">
<option name="conditions" value="conditionAttachment_French_1_Lose_France1"/>
<option name="uses" value="1"/>
<option name="when" value="after:germansBattle"/>
<option name="players" value="French"/>
<option name="playerAttachmentName" value="PlayerAttachment" count="playerAttachment"/>
<option name="playerProperty" value="destroysPUs" count="true"/>
</attachment>So the triggers are worded a little oddly if you weren't the one originally doing it. At any rate, the second trigger is the one that kills the French PUs after Germany whacks France. It is attached to "French" and then you have the playerAttachment stuff
<option name="playerAttachmentName" value="PlayerAttachment" count="playerAttachment"/>
So double check your player attachments for France. If they look ok check the conditions that fire the trigger.
Edit
Ahh...just reread your post. Looks as if you have the correct trigger. I'll do some testing see if I can replicate the problem. -
Hmm...I just tried it and it worked for me. Can you post a save and what map this is for ?
You could aslo try searching this in the xml and see if you see anything weird
<option name="players" value="French"/>
<option name="playerAttachmentName" value="PlayerAttachment" count="playerAttachment"/>also check the condition is before the trigger
conditionAttachment_French_1_Lose_France
-
Thanks for the suggestions, they helped me figure it out.
The problem was that I didn't realize the playerAttachment needed to be defined somewhere. (if that's the right terminology). It was defined for a couple of the nations for other purposes (UK for sharing tech, and Japan for kamikaze strikes) but most of them were missing it. For example:
<attachment name="playerAttachment" attachTo="French" javaClass="games.strategy.triplea.attachments.PlayerAttachment" type="player"> <option name="destroysPUs" value="false"/> </attachment>
So, that's why it was stable for some nation's capitals and not others.
-
@Contango right on i had forgot about that. Glad you got it working