Unit Option When Damaged Change Into Different Unit (Weakened Battleships)
-
@hepps It would only work that way if the damaged BB unit had say max HP of 2 instead of 3. The reason is it would only carry over the damage of the unit being replaced (if 'keepDamage'=true) which would only be bombing damage in your case. So you'd end up with a damaged BB unit with 1 bombing damage and 0 hit point damage.
-
@redrum Ah ok. So you would then have to have 4 different types of damaged unit, causing all kinds of issues with unit changing and re-changing depending on the damage taken... that does present an issue.
-
@hepps So using both types of damage on multi hit units is probably not a realistic goal.
-
@hepps Agree. There would need to be further thought and logic to better handle units that can take both types of damage. Probably something like a damageConvert unit option which would translate bombing damage to HP and vice-versa. So say if a BB had 3 HP and 15 max bombing damage then you could have a 1-to-5 damage conversion ratio so it is damaged evenly (ex. if it takes 5 bombing damage then would take 1 HP damage).
You'd also have to think about how repair would work as well (again some conversion ratio so both are repaired at the same time or separate repairs). It gets pretty complicated pretty quickly.
-
@redrum Agreed.
Probably best if those two conversions were independent of one another.
-
@hepps Initial PR to address the damage (not repair) portion of this feature: https://github.com/triplea-game/triplea/pull/2689
Tested it by editing TWW to add unit, unit image, and below unit attachments:
<attachment name="unitAttachment" attachTo="germanBattleship" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <option name="movement" value="2"/> <option name="attack" value="7"/> <option name="defense" value="8"/> <option name="canBombard" value="true"/> <option name="isSea" value="true"/> <option name="hitPoints" value="2"/> <option name="bombard" value="6"/> <option name="requiresUnits" value="germanDocks:germanFactory"/> <option name="consumesUnits" value="1:germanHull"/> <option name="whenHitPointsDamagedChangesInto" value="1:true:germanBattleshipDamaged"/> </attachment> <attachment name="unitAttachment" attachTo="germanBattleshipDamaged" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <option name="movement" value="1"/> <option name="attack" value="3"/> <option name="defense" value="4"/> <option name="canBombard" value="true"/> <option name="isSea" value="true"/> <option name="hitPoints" value="2"/> <option name="bombard" value="3"/> </attachment> -
@redrum AWESOME!!!!!
-
Initial PR merged and can be tested on https://github.com/triplea-game/triplea/releases/tag/1.9.0.0.7804
-
Second PR to address repairing them: https://github.com/triplea-game/triplea/pull/2691
Tested with this XML:
<attachment name="unitAttachment" attachTo="germanBattleship" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <option name="movement" value="2"/> <option name="attack" value="7"/> <option name="defense" value="8"/> <option name="canBombard" value="true"/> <option name="isSea" value="true"/> <option name="hitPoints" value="2"/> <option name="bombard" value="6"/> <option name="requiresUnits" value="germanDocks:germanFactory"/> <option name="consumesUnits" value="1:germanHull"/> <option name="whenHitPointsDamagedChangesInto" value="1:true:germanBattleshipDamaged"/> </attachment> <attachment name="unitAttachment" attachTo="germanBattleshipDamaged" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <option name="movement" value="1"/> <option name="attack" value="3"/> <option name="defense" value="4"/> <option name="canBombard" value="true"/> <option name="isSea" value="true"/> <option name="hitPoints" value="2"/> <option name="bombard" value="3"/> <option name="whenHitPointsRepairedChangesInto" value="0:true:germanBattleship"/> </attachment> -
@redrum So pumped!

-
@hepps Nice. Those are looking good.
-
Second PR merged so all changes can be tested in this or later releases: https://github.com/triplea-game/triplea/releases/tag/1.9.0.0.7850
-
-
@general_zod That is an excellent question, that I actually don't know the answer to. I believe that it should since it actually does simulate battles. It would be interesting to make a very small test to prove or disprove it though.
-
Now that I think of it...
<attachment name="unitAttachment" attachTo="hydraHead" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <option name="movement" value="0"/> <option name="attack" value="3"/> <option name="defense" value="3"/> <option name="whenHitPointsDamagedChangesInto" value="2:false:hydraHead"/> </attachment> -
-
I canβt get this code work. Is it only for isSea? (I hope not
)
I am trying to get my XML to work after the implementation of new units.
I would like this Dragon unit to turn into a corpse when its HPs are gone. Should this not be possible also?My code looks like this:
<attachment name="unitAttachment" attachTo="Red-Dragon" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <option name="movement" value="3"/> <option name="attack" value="8"/> <option name="defense" value="6"/> <option name="isAir" value="true"/> <option name="hitPoints" value="3"/> <option name="repairsUnits" value="1:Red-Dragon"/> <option name="whenHitPointsDamagedChangesInto" value="3:false:Red-Dragon-Corpse" count="1"/> <option name="offensiveAttackAA" value="1"/> <option name="attackAA" value="1"/> <option name="offensiveAttackAAmaxDieSides" value="10"/> <option name="attackAAmaxDieSides" value="10"/> <option name="maxAAattacks" value="8"/> <option name="maxRoundsAA" value="1"/> <option name="isAAforCombatOnly" value="true"/> <option name="typeAA" value="Fire"/> <option name="mayOverStackAA" value="true"/> <option name="targetsAA" value="FAKE-INF"/> </attachment> <attachment name="unitAttachment" attachTo="Red-Dragon-Corpse" javaClass="games.strategy.triplea.attachments.UnitAttachment" type="unitType"> <option name="isInfrastructure" value="true"/> <option name="createsResourcesList" value="25:Gold"/> </attachment>Error looks like this:
feb. 24, 2019 8:46:37 PM games.strategy.engine.framework.ui.DefaultGameChooserEntry fullyParseGameData SEVERE: Could not parse:file:/C:/Users/David-Corsair/triplea/downloadedMaps/world_of_war_heroes/games/world_of_war_heroes.xml games.strategy.engine.data.GameParseException: map name: 'file:/C:/Users/David-Corsair/triplea/downloadedMaps/world_of_war_heroes/games/world_of_war_heroes.xml', game name: 'World of War Heroes', Unexpected Exception while setting values for attachmentUnitAttachment attached to:UnitType{name=Red-Dragon} with name:unitAttachment at games.strategy.engine.data.GameParser.newGameParseException(GameParser.java:121) at games.strategy.engine.data.GameParser.setValues(GameParser.java:1274) at games.strategy.engine.data.GameParser.parseAttachments(GameParser.java:1224) at games.strategy.engine.data.GameParser.parseMapDetails(GameParser.java:211) at games.strategy.engine.data.GameParser.parse(GameParser.java:110) at games.strategy.engine.data.GameParser.parse(GameParser.java:104) at games.strategy.engine.data.GameParser.parse(GameParser.java:91) at games.strategy.engine.framework.ui.DefaultGameChooserEntry.fullyParseGameData(DefaultGameChooserEntry.java:53) at games.strategy.engine.framework.startup.ui.panels.main.game.selector.GameSelectorPanel.lambda$selectGameFile$6(GameSelectorPanel.java:284) at games.strategy.engine.framework.ui.background.BackgroundTaskRunner.lambda$runInBackground$0(BackgroundTaskRunner.java:51) at games.strategy.engine.framework.ui.background.BackgroundTaskRunner$1.doInBackground(BackgroundTaskRunner.java:129) at javax.swing.SwingWorker$1.call(Unknown Source) at java.util.concurrent.FutureTask.run(Unknown Source) at javax.swing.SwingWorker.run(Unknown Source) at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Caused by: games.strategy.engine.data.MutableProperty$InvalidValueException: failed to set string property value to '1:3:false:Red-Dragon-Corpse' at games.strategy.engine.data.MutableProperty.setStringValue(MutableProperty.java:64) at games.strategy.engine.data.MutableProperty.setValue(MutableProperty.java:88) at games.strategy.engine.data.GameParser.setValues(GameParser.java:1270) ... 15 more Caused by: games.strategy.engine.data.GameParseException: setWhenHitPointsDamagedChangesInto must have damage:translateAttributes:unitType for: UnitAttachment attached to:UnitType{name=Red-Dragon} with name:unitAttachment at games.strategy.triplea.attachments.UnitAttachment.setWhenHitPointsDamagedChangesInto(UnitAttachment.java:419) at games.strategy.engine.data.MutableProperty.setStringValue(MutableProperty.java:60) ... 17 more -
Just look at TWW 3..0
It all works perfectly. Should work of any type of unit. The one thing that is tricky is the names of the unit images you need in the unit folder.
But if you look at that then you should be good to go.
-
@Frostion said in Unit Option When Damaged Change Into Different Unit (Weakened Battleships):
setWhenHitPointsDamagedChangesInto
You have 1 too many parameters. If you remove the count="1" then it should work. So should be like this:
<option name="whenHitPointsDamagedChangesInto" value="3:false:Red-Dragon-Corpse"/> -
Ahh ... yes. With the new pictures and the changing of...
<option name="whenHitPointsDamagedChangesInto" value="3:false:Red-Dragon-Corpse" count="1"/>
to
<option name="whenHitPointsDamagedChangesInto" value="3:false:Red-Dragon-Corpse"/>
... it seems to work.
Thanks to you guys!
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
