How do I auto-damage units at the end of a player's turn?
-
So in this game I am working on, there is a tank unit that has 2 HP on offense, but only 1 HP on defense. I was thinking about auto-damaging all tanks at the end of a player's turn. This would essentially turn all tanks into 1 HP if attacked. However, I am having trouble implementing this.
This is my code. I tried to place a tank with 1 damage hit in each territory containing a tank, for one player only, just to test some things.
<attachment foreach="$LandZones$" name="conditionAttachment_Tanks" attachTo="AustroHungarians" javaClass="games.strategy.triplea.attachments.RulesAttachment" type="player"> <option name="directPresenceTerritories" value="$LandZones$" count="1"/> <option name="unitPresence" value="tank" count="1"/> </attachment> <attachment foreach="$LandZones$" name="triggerAttachment_Damage_Tanks" attachTo="AustroHungarians" javaClass="games.strategy.triplea.attachments.TriggerAttachment" type="player"> <option name="conditions" value="conditionAttachment_Tanks"/> <option name="when" value="before:austrohungariansEndTurn"/> <option name="placement" value="@LandZones@:tank" hitsTaken="1" count="1"/> </attachment> <!-- Victory Conditions -->
I got this as a result:
![0_1721476859686_88cdf30b-2209-4144-a9b7-d8a10f750604-image.png](Uploading 100%)
-
The only thing that happened is that one full strength Austrian tank was placed in Ruhr.
-
yea i don't think "hitsTaken" works as an attachment. It only works for placement.
edit
placement as in at game start -
make another request. Maybe it's not hard to add and @Myrd will bust it out
-
There is no attribute "hitTaken" in attachments, only name, value and count. The "hitTaken" attribute can only be used with unitPlacement.
Then again, this coding would not really work, as only 1 tank would be hit. It is the same problem you would have if you were trying to replace the 2-hit unit with a 1-hit unit, because with the xml coding it is very hard to get the number of units that may occupy a single territory.
Sorry
Cheers...
-
Again, I don't think so. As I stated it is very hard to count the number of units that may be located in single territory. TripleA conditions are yes/no, "Is there one or more units located in territory X?", not "How many units are in territory X?". Thus, it would be very difficult to govern how many units the trigger would need to damage.
So, this would be very difficult to explain, prior to coding.
Cheers...
-
Hmm, that's a shame. So there is no way to count the number of units in a territory? My second idea was to change the HP of tanks to "1" and then auto-place a tank_soak unit to each territory containing tanks at the start of a player's turn, so if I have eight tanks sitting somewhere, eight tank_soak units are spawned as well, which can soak up the hits when attacking.
-
@victoryfirst said in How do I auto-damage units at the end of a player's turn?:
So there is no way to count the number of units in a territory?
there is with "unitPresence" but you'd have to make a condition for each one. So a separate condition for 1 unit and, 2 , 3 ... and so on.
Youd also need separate triggers for each one.
Edit
and you'd have to do it for each territoryEdit 2
and for each player -
If you are thinking of using "createsUnitsList" then you have to remember that this will only work during a player's endTurn phase, and is really not a good workaround.
Cheers...
-
Heh heh I see, it's a pain in the ass I think it's handier to just edit then.
-
heh heh just do a few at a time. Start with the high use areas. Maybe do 20 tanks. Once you have it done you can copy paste find and replace for the other players.
I think your idea of adding the hit soakers might work. Have the soakers place before combat move and then remove them after combat
-
could call the soakers "reactiveArmor" lol
-
Nothing deals with hitPoints, techAttachments, territoryEffectsAttachments, unitSupportAttachments. To add something, it would need to be designed in, and would have to account for the unit's combat situation, offence/defense. Both territoryEffectsAttachments and unitSupportAttachments could be modified. But as I stated this would need to be designed.
Cheers...
-
i think you'd need the game to have separate HP values for ATT/DEF just like it does for firepower... and that would lead ro all sorts of problems especially for units that have more than 2 HP... maybe if it was changed so that units full healed each repair phase instead of just 1 HP at a time.
-
@cameron said in How do I auto-damage units at the end of a player's turn?:
maybe if it was changed so that units full healed each repair phase instead of just 1 HP at a time.
There is the "repairUnits" for both the endGame and move delegates. And map properties.
<property name="Units Repair Hits End Turn" value="true" editable="true"> <boolean/> </property> <property name="Units Repair Hits Start Turn" value="false" editable="true"> <boolean/> </property>
Cheers...
-
actually, that makes them heal less...
when i tried:
<property name="Units Repair Hits Start Turn" value="true" editable="false"> <boolean/> </property> <property name="Units Repair Hits End Turn" value="false" editable="false"> <boolean/> </property>
then:
- units healed 0 HP at end of their Turn Complete phase
- units healed 0 HP at end of other players Turn Complete phase
- units healed 1 HP at start of their Combat Move phase
when i tried:
<property name="Units Repair Hits Start Turn" value="true" editable="false"> <boolean/> </property> <property name="Units Repair Hits End Turn" value="true" editable="false"> <boolean/> </property>
then:
- units healed 1 HP at end of their Turn Complete phase
- units healed 0 HP at end of other players Turn Complete phase
- units healed 1 HP at start of their Combat Move phase
when i tried:
<property name="Units Repair Hits Start Turn" value="false" editable="false"> <boolean/> </property> <property name="Units Repair Hits End Turn" value="true" editable="false"> <boolean/> </property>
then:
- units healed 1 HP at end of their Turn Complete phase
- units healed 1 HP at end of other players Turn Complete phase
- units healed ? HP at start of their Combat Move phase [always fully healed before this point but one assumes 0]
EDIT: corrected lazy copy/paste errors