TripleA Logo TripleA Forum
    • TripleA Website
    • Categories
    • Recent
    • Popular
    • Users
    • Groups
    • Tags
    • Register
    • Login

    Unit Option When Damaged Change Into Different Unit (Weakened Battleships)

    Scheduled Pinned Locked Moved Feature Requests & Ideas
    83 Posts 11 Posters 42.6k Views 10 Watching
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • redrumR Offline
      redrum Admin
      last edited by redrum

      Initial PR merged and can be tested on https://github.com/triplea-game/triplea/releases/tag/1.9.0.0.7804

      TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

      1 Reply Last reply Reply Quote 1
      • redrumR Offline
        redrum Admin
        last edited by redrum

        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>
        

        TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

        HeppsH 1 Reply Last reply Reply Quote 2
        • HeppsH Offline
          Hepps Moderators @redrum
          last edited by

          @redrum So pumped!

          0_1513385693652_Limping back to harbour.jpg

          "A joyous heart sours with the burden of expectation"
          Hepster

          redrumR 1 Reply Last reply Reply Quote 0
          • redrumR Offline
            redrum Admin @Hepps
            last edited by

            @hepps Nice. Those are looking good.

            TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

            redrumR 1 Reply Last reply Reply Quote 0
            • redrumR Offline
              redrum Admin @redrum
              last edited by

              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

              TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

              General_ZodG 1 Reply Last reply Reply Quote 0
              • General_ZodG Offline
                General_Zod Moderators @redrum
                last edited by

                @redrum @hepps First of all very cool feature. Does the battle calculator give an accurate outcome when these units are involved?

                redrumR 1 Reply Last reply Reply Quote 1
                • redrumR Offline
                  redrum Admin @General_Zod
                  last edited by

                  @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.

                  TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                  1 Reply Last reply Reply Quote 0
                  • alkexrA Offline
                    alkexr
                    last edited by

                    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>
                    

                    "For the world is changing: I feel it in the water, I feel it in the earth, and I smell it in the air."

                    HeppsH 1 Reply Last reply Reply Quote 0
                    • HeppsH Offline
                      Hepps Moderators @alkexr
                      last edited by

                      @alkexr ๐Ÿ˜ƒ

                      "A joyous heart sours with the burden of expectation"
                      Hepster

                      1 Reply Last reply Reply Quote 0
                      • FrostionF Offline
                        Frostion Admin
                        last edited by

                        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
                        

                        Map maker of: Star Wars: Galactic War + Star Wars: Tatooine War + Caribbean Trade War + Dragon War + Age of Tribes + Star Trek: Dilithium War + Iron War + Iron War: Europe + Warcraft: War Heroes

                        redrumR 1 Reply Last reply Reply Quote 0
                        • HeppsH Offline
                          Hepps Moderators
                          last edited by

                          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.

                          "A joyous heart sours with the burden of expectation"
                          Hepster

                          FrostionF 1 Reply Last reply Reply Quote 0
                          • redrumR Offline
                            redrum Admin @Frostion
                            last edited by

                            @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"/>
                            

                            TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                            1 Reply Last reply Reply Quote 0
                            • FrostionF Offline
                              Frostion Admin
                              last edited by

                              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! ๐Ÿ˜„

                              Map maker of: Star Wars: Galactic War + Star Wars: Tatooine War + Caribbean Trade War + Dragon War + Age of Tribes + Star Trek: Dilithium War + Iron War + Iron War: Europe + Warcraft: War Heroes

                              alkexrA 1 Reply Last reply Reply Quote 0
                              • alkexrA Offline
                                alkexr @Frostion
                                last edited by

                                Can units still be changed into other units when they are already dead? Didn't work for me last time I was experimenting. It would be tremendously useful if it was possible.

                                "For the world is changing: I feel it in the water, I feel it in the earth, and I smell it in the air."

                                C 1 Reply Last reply Reply Quote 0
                                • FrostionF Offline
                                  Frostion Admin
                                  last edited by

                                  @alkexr I cannot give you answer yet, as I have only just gotten my XML to work and have not really tested the Dragon out. If it works as I hope, the dragon has X HP and when they are killed it turns into a corpse. I cross my fingers. If not, I think I will make a request about a whenKilledTurnsInto feature ๐Ÿ˜

                                  Map maker of: Star Wars: Galactic War + Star Wars: Tatooine War + Caribbean Trade War + Dragon War + Age of Tribes + Star Trek: Dilithium War + Iron War + Iron War: Europe + Warcraft: War Heroes

                                  1 Reply Last reply Reply Quote 0
                                  • C Offline
                                    Cernel Moderators @alkexr
                                    last edited by

                                    @alkexr I tried it too, but it doesn't work. It would be really cool if it does. @Frostion There is no need to add any other property, just the unit should not be killed if it can turn into another one at the current damage (that would be set equal to the total hitpoints).

                                    Also I believe it would be clearer if the option would talk in terms of remaining hitpoints, rather than current damage.

                                    1 Reply Last reply Reply Quote 0
                                    • C Offline
                                      Cernel Moderators @Hepps
                                      last edited by Cernel

                                      @Hepps I definitely prefer the current way to the alternative approach. The alternative approach is seriously limited in both influencing only 3 stats (the 3 main ones) and not allowing you to freely change the visual of the unit. Main case is that you may want to lower or remove the AA ability from a damaged unit.

                                      The other cool thing that the current approach allows is having a unit able to absorb damage each combat round, by turning the damaged unit into the undamaged version of itself (for example, you can say that this unit absorbs/prevents 1 damage per round, healing at the end of each combat round).

                                      HeppsH 1 Reply Last reply Reply Quote 0
                                      • HeppsH Offline
                                        Hepps Moderators @Cernel
                                        last edited by

                                        @Cernel A simple work around to these issues is to give the unit +1 more hit point and have the last HP turn into a infrastructure unit that has neither combat values nor movement. Thus enabling you to create a corpse unit that could... under the right conditions be turned into a subsequently different unit upon capture by a specfic required unit.

                                        I have not tested this... but I have to assume it would work. Getting hung up on how many remaining HP a unit has is kind of the real hurdle to making this work.

                                        "A joyous heart sours with the burden of expectation"
                                        Hepster

                                        1 Reply Last reply Reply Quote 0
                                        • redrumR Offline
                                          redrum Admin
                                          last edited by

                                          @alkexr @Frostion As Cernel stated, it doesn't work if the unit is dies (out of hit points) as dying overrides the check to damaged changes into. This could probably be changed and shouldn't be too difficult though I probably won't have time this week.

                                          @Cernel I consider doing remaining hit points rather than damaged but most existing properties check damage so decided to go with that for consistency.

                                          @Hepps That can work though I believe you'd need a player enforced rule to ban taking the final hit point during casualty selection.

                                          TripleA Developer with a Passion for AI: https://forums.triplea-game.org/topic/105/ai-development-discussion-and-feedback

                                          HeppsH 1 Reply Last reply Reply Quote 1
                                          • HeppsH Offline
                                            Hepps Moderators @redrum
                                            last edited by

                                            @redrum Again while I haven't tested it.... the final hit point should be a moot point since once the unit hits the infrastructure level it should not be selectable as a casualty.

                                            "A joyous heart sours with the burden of expectation"
                                            Hepster

                                            redrumR 1 Reply Last reply Reply Quote 0

                                            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
                                            • 1
                                            • 2
                                            • 3
                                            • 4
                                            • 5
                                            • 2 / 5
                                            • First post
                                              Last post
                                            Copyright ยฉ 2016-2018 TripleA-Devs | Powered by NodeBB Forums