How can I change unit properties with game options?



  • I'd like to have a game option that players can select at the start of the game, and if the box is checked, then artillery, tanks, and jeeps all get <option name="isMarine" value="-1">. The idea is that players can choose whether or not they want to have amphibious assaults with heavy equipment be penalized, just like they would choose shore bombardment options.

    I was able to create the custom game option in the map options dialog box:

    	<property name="Penalize Heavy Equipment During Amphibious Assault" value="true" editable="true">
    		<boolean/>
    	</property>
    

    And I was able to create a condition that uses gameProperty to check whether the dialog box is marked true...

    <attachment name="Penalize" attachTo="tank" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="unitType">
      <option name="gameProperty" value="Penalize Heavy Equipment During Amphibious Assault"/>
    </attachment>
    

    But I don't know what kind of trigger to use to actually add in the new stats for isMarine. The examples in POS 2 all seem to be geared around player attachments, rather than unit attachments. Any suggestions?



  • @Jason-Green-Lowe

    		<attachment name="triggerAttachmentuniquename" attachTo="nation" javaClass="TriggerAttachment" type="player">
    			<option name="unitType" value="unit"/>
    			<option name="unitAttachmentName" value="UnitAttachment" count="unitAttachment"/>
    			<option name="unitProperty" value="isMarine" count="-1"/>
    		</attachment>	
    

    You will have to do it for each 'nation' you want it to go on. (player is just saying what kind of attachment it is)
    Value="unit" is the specific unit getting the ability. I think you can do a colon seperated list, or a variable. last two lines should stay the same i think.

    You will need a trigger condition in there too. I assume it will have something to do with the game property, but i am not sure.

    edit: will need a condition, not trigger


  • Moderators

    yea this would be the condition

    <option name="conditions" value="tank"/>

    when the option is on it'll fire

    edit oops I mean Penalize not tank 🙂



  • Thanks! Seems like a good start.



  • @Jason-Green-Lowe I assume the message disappearing means you figured it out?



  • I forgot to replace "unit" with "tank," I'm not sure it's working, but at least it's not crashing. Still testing.



  • This line is still hard for me to understand:

    		<option name="unitAttachmentName" value="UnitAttachment" count="unitAttachment"/>
    

    Can you explain what that's doing?



  • Yeah, the code isn't throwing any errors, but it's also not having any effect -- the tank is still attacking at its normal value on amphibious assault. Not sure what's wrong. I feel like my trigger isn't adequately linked to my condition -- how does the trigger know when to go off?

    	<attachment name="PenalizeGermanTank" attachTo="Germans" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
    		<option name="gameProperty" value="Penalize Heavy Equipment During Amphibious Assault"/>
    	</attachment>
    	<attachment name="triggerAttachmentPenalizeGermanTank" attachTo="Germans" javaClass="TriggerAttachment" type="player">
    		<option name="unitType" value="tank"/>
    		<option name="unitAttachmentName" value="UnitAttachment" count="unitAttachment"/>
    		<option name="unitProperty" value="isMarine" count="-3"/>
    	</attachment>


  • OK, fixed it. Thanks for the help! It's working now. It's a medium-sized pain to have to add a separate condition and trigger for each unit for each country, but I can get it done.

    	<attachment name="PenalizeGermanTank" attachTo="Germans" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player">
    		<option name="gameProperty" value="Penalize Heavy Equipment During Amphibious Assault"/>
    	</attachment>
    	<attachment name="triggerAttachmentPenalizeGermanTank" attachTo="Germans" javaClass="TriggerAttachment" type="player">
    	    <option name="conditions" value="PenalizeGermanTank"/>
    		<option name="unitType" value="tank"/>
    		<option name="unitAttachmentName" value="UnitAttachment" count="unitAttachment"/>
    		<option name="unitProperty" value="isMarine" count="-3"/>
    	</attachment>


  • @Jason-Green-Lowe said in How can I change unit properties with game options?:

    OK, fixed it. Thanks for the help! It's working now. It's a medium-sized pain to have to add a separate condition and trigger for each unit for each country, but I can get it done.

    I am guessing you will only need to use one condition for everything. And i think it would be worth trying a colon separated list for the unitType. That might help you not have to do as much. Might not either.



  • Different units have slightly different penalties, because I'm trying to set all the heavy equipment's attack values equal to 1. I was able to double up on the halftrack and jeep, since they both attack at 2, normally. Anyway, done now. Thanks again for the help! 🙂



  • @Jason-Green-Lowe Good luck with the rest of it!


  • Admin

    FWIW, being able to specify unit stats at the start of a game is something I've wanted to build in for some time. Having to do triggers to get the same effect is clearly a workaround, so I'm sorry you're having to go through that pain. Hopefully some time in 2021 this will be a built in feature.


Log in to reply