Announcement

Collapse
No announcement yet.

[SUPPORT] Advanced Turn Based Tile Toolkit

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Good that you managed to get it working, though it is weird that it required restarting the editor. I'm not at home and cannot currently check the toolkit, but I believe there are three different tilemaps: one containing all walls, one containing all floors and one containing both. I think the third one is tilemap base. In any case, the one containing everything is the one I used to make the entire dungeon, so I knew how it would look with both walls and floor tiles in place. I then made two duplicates: one where I removed all the walls and one where I removed all floor tiles. Then I made the one with just the floor tiles block path trace and the one with only walls to have thicker collision boxes (pointing up towards the camera) and block range trace, so that walls would block visibility. I kept the base tile map in case I needed to go back to it for any reason, but it does not serve any real purpose in the finished toolkit.
    Advanced Turn Based Tile Toolkit (Marketplace - Support)

    Dungeon Crawler Toolkit (Marketplace - Support)

    Discord

    Comment


      Hi!

      A little curious when the next update is coming? We're especially interested in the cover/accuracy system.

      Comment


        Hi there! It's going forward, but a bit slowly. Work has been busy, and in addition I'm getting married in a week and then going on an extended honeymoon, so I'll be pretty occupied for the next few weeks. I have however implemented both a cover and accuracy system that is probably pretty close to what I'll end up including in the update. I'll explain my solution in this post so that anyone who needs a cover system quickly can replicate what I've done.

        First to create some context for the blueprints below, I'm creating a new example map to include features like cover and accuracy. Since I do not consider these features generic enough to include in the base toolkit (to avid it from getting cluttered) I've added these features in child actors of the original actors. The example map has the working title SciFi because of some SciFi themed assets I'm using, so the child actors are called for instance BP_GridManager_SciFi and ATBTT_PlayerController_SciFi. In the blueprints below I will frequently be casting to these child actors to get access to their functions and variables, though if you want to replicate this yourself you might not want to use child actors and could just modify the base actors themselves.

        The goal of my solution for cover is to have everything be pregenerated based on the terrain placed in the level, both to save time for the users and to speed up processing during gameplay.

        For cover I have created a new array called Cover Array in BP_GridManager (or really BP_GridManager_SciFi). This array is a nested array of structs. It is an array of arrays, where each nested array is an array of structs containing an index integer and a cover float. The main array is resized to be the size of the grid. The idea is to have each index of the array represent a tile on the grid and each member within the nested array represent a tile edge of each tile, pointing to which index the edge is facing and what its cover value is (hope that's clear :P ).

        To auto generate cover at the start of the game I have created a new trace channel I call Cover Trace. I then trace between all tiles two times using this trace, one quite low and one quite high. If the high trace is blocked I count this as full cover between tiles (with a high cover value). If the high trace is not blocked, but the low one is I count it as half cover.

        Click image for larger version

Name:	73iRzEY.png
Views:	1
Size:	236.4 KB
ID:	1111498
        Click image for larger version

Name:	fBWy5BS.png
Views:	1
Size:	345.5 KB
ID:	1111499

        I've made the following function to check whether a tile has cover from another tile. If the attacking tile is on the other side of the cover edge, accuracy is always reduced by the same amount, regardless of how far to the side of the cover the attacker is standing. This is both easier to calculate and probably for a player to understand.

        Click image for larger version

Name:	WS8txzW.png
Views:	1
Size:	174.3 KB
ID:	1111500

        For calculating hit chance I want to take into account more factors than just cover, so I have made the following function to take distance and other modifiers into account:

        Click image for larger version

Name:	mHvOzIO.png
Views:	1
Size:	135.0 KB
ID:	1111501

        All functions so far have been contained in BP_GridManager_SciFi. I have also created a new unit child actor currently called Unit_Player_SciFi_Weapon (so called because I'm experimenting with units carrying weapons that can be switched). This unit has new attributes called Accuracy and Dodge. Accuracy is a value between 0 and 1 representing the base percentage chance this unit has to hit another unit with its attack. Dodge is a similar number subtracted from the accuracy of any unit trying to hit it. Here are the nodes I use in the event graph of this unit. These nodes are inserted as part of the Attack Victim event, before Attack Animation, but after all other nodes.

        Click image for larger version

Name:	lJpP3xc.png
Views:	1
Size:	206.7 KB
ID:	1111503

        It is still a work in progress and I have also added more functions for displaying XCOM-style shields for cover and such. What I have described above should still hopefully be enough to get you started. I hope I have explained it well enough, but feel free to ask if you have any questions. Like I said I will probably not have any time to work on this until I return from my honeymoon in August.
        Advanced Turn Based Tile Toolkit (Marketplace - Support)

        Dungeon Crawler Toolkit (Marketplace - Support)

        Discord

        Comment


          Originally posted by Monokkel View Post
          For cover I have created a new array called Cover Array in BP_GridManager (or really BP_GridManager_SciFi). This array is a nested array of structs. It is an array of arrays, where each nested array is an array of structs containing an index integer and a cover float. The main array is resized to be the size of the grid. The idea is to have each index of the array represent a tile on the grid and each member within the nested array represent a tile edge of each tile, pointing to which index the edge is facing and what its cover value is (hope that's clear :P ).
          I had to read that several times...

          Like many following your progress, I'm greatly interested in the cover system. The way you're setting it up has cover precalculated, is it possible to then run the cover traces in game? I'm thinking about when weapons fire or explosives destroy cover during the game, requiring a recalculation of what cover covers what pawns. I assume that if the traces are run during the game there would be a bit of a performance hit on large grids to run so many line traces so you don't want to do it every time a weapon is fired?

          I seem to remember actually that there was a bit of slowdown in XCom whenever cover got destroyed. Could be that they used something similar to your system.

          And congratulations on the wedding and honeymoon Monokkel!
          On the forum, Kev will do.

          Comment


            Thanks! Yeah, it was a bit tricky to explain :P Maybe I can make it a bit clearer. Below are four array elements (of which there would be a number equal to the size of the grid). Each of these contains a nested array (of four elements each in this example, though this would vary depending on the number of edges of each tile). Each of these array elements contain an integer and a float. The integer points to an adjacent tile (the edge being between this tile index and the tile index of the array element in the main "parent" array) and the float defines the cover value of this edge.

            [[int,float] [int,float] [int,float] [int,float]] [[int,float] [int,float] [int,float] [int,float]] [[int,float] [int,float] [int,float] [int,float]] [[int,float] [int,float] [int,float] [int,float]]

            It should be possible to re-run calculating cover for a smaller area. Just use the Get Indexes In Range function in the area where cover may have been destroyed and then run the same cover generation code for these tiles as was originally done for the entire map. I designed the cover system with this possibility in mind, and though I have not tested it out yet, I see no reason why it should not work.
            Advanced Turn Based Tile Toolkit (Marketplace - Support)

            Dungeon Crawler Toolkit (Marketplace - Support)

            Discord

            Comment


              I think I did actually misunderstand a little originally, thanks for this explanation. Yes the way you have it here running the cover trace in game in a given area should be reasonably efficient - I was anticipating that the whole level would have to have the traces re-run at once but that's not the case.

              One further question (if you have time) - how does this work with multi-level grids or altitude differences?
              On the forum, Kev will do.

              Comment


                Yes, I've designed the system with this in mind, though I still require more testing to get it working perfectly.
                Advanced Turn Based Tile Toolkit (Marketplace - Support)

                Dungeon Crawler Toolkit (Marketplace - Support)

                Discord

                Comment


                  Click image for larger version

Name:	71Gx05O.png
Views:	1
Size:	426.3 KB
ID:	1111622
                  I'm having an issue with the Hydra's Lair example. Sometimes, the game will freeze just after moving the camera to an enemy, as shown in the screenshot. This seems to only occur when there are 1-2 other enemies on tiles separating the enemy whose turn it just switched to and the player. Is this a known issue? Is there a fix?

                  Comment


                    Similar to the person before i'm looking to make a first person dungeon crawler style, how would you suggest editing this sytem to fit that?

                    I'll likely mess with it some but figure the creator may know a super easy way I won't see

                    Comment


                      @gooberCP: This issue was not known. Thank you for bringing it to my attention. I have a small delay at the end of each AI unit's turn just to make the game feel less rushed. Due to a mistake in how I have sequenced the event nodes in ATBTT_AI_Controller this delay is called twice for AI units that have friendly units between them and their target. The game doesn't really freeze (fps stays consistent), but the delay is doubled. To fix this, make this change in the event graph of ATBTT_AI_Controller (at the far right of the Choose Target comment box):

                      Old:
                      Click image for larger version

Name:	BhRhymT.png
Views:	1
Size:	201.2 KB
ID:	1111673
                      New:
                      Click image for larger version

Name:	a7wyCXb.png
Views:	1
Size:	209.7 KB
ID:	1111674

                      I will make sure to fix this in the next update.

                      @tamaster92: I have experimented with this before so I have a few ideas. First, of course, you will need to change the camera. The best way is to attach a camera to your player (pointing forward) unit and possess it. For movement (if you want something Grimrock-style) you would simply lerp the unit in the direction you are moving at a distance equal to the distance between tiles. Before moving you should check if the index of the tile you are moving into is in the edge array of the tile you are currently occupying (meaning it is allowed to move between these tiles). After moving you should remove the player unit from the Pawn Array at the index it previously occupied and insert it at the tile index it is now occupying.
                      Advanced Turn Based Tile Toolkit (Marketplace - Support)

                      Dungeon Crawler Toolkit (Marketplace - Support)

                      Discord

                      Comment


                        Thanks for the response!

                        After implementing that change though, I'm seeing the same behaviour (gameplay freezes - game itself stays running) at this point:
                        Click image for larger version

Name:	szo4C6T.png
Views:	1
Size:	366.8 KB
ID:	1111713

                        To give some context:
                        -Came through the door to the right, hugged the wall down to the bottom of that room, then went through the door at the bottom. The health bar just off the bottom of the image is my player.
                        -The gameplay froze after the wizard moved, when the turn switched to the goblin.

                        (The walls are grey because I was testing adding new tiles. Also ignore the small door to the right of the image, it's another test I'm doing.)

                        Thanks!
                        Chris

                        EDIT: Gameplay froze in this setup as well:
                        Click image for larger version

Name:	v2r6Bxi.png
Views:	1
Size:	503.8 KB
ID:	1111717
                        Last edited by gooberCP; 07-08-2016, 11:55 AM.

                        Comment


                          Ok, I have been able to replroduce your bug. I observed a similar bug a long time back, but thought I had been able to fix it. Maybe this is caused by changes in an Unreal update or unforseen consequences of my own updates. I will look into this and report back with a solution. I will probably first have the time tomorrow, but I promise I will find the cause and fix it as soon as I'm able.
                          Advanced Turn Based Tile Toolkit (Marketplace - Support)

                          Dungeon Crawler Toolkit (Marketplace - Support)

                          Discord

                          Comment


                            Thank you for the continued support!

                            I look forward to your fix. In the meantime, I can continue to work on other aspects of the project.

                            Thanks!

                            Comment


                              Ok, I've found a solution to the game freezing, though I'm not 100% certain on the cause yet. It seems like one of the later UE4 updates has caused an issue with using event dispatchers on child actors, which screws up using my Pathfinding per Tick macro in the grid manager child actor in the 2D game example. You can prevent the game from freezing by replacing the Pathfinding per Tick event call in the Search for targets behind friendly units of ATBTT_AI_Controller with a regular pathfinding function. This should probably still not cause a framerate drop when calculating pathfinding. Here is what to replace:

                              Old:
                              Click image for larger version

Name:	ASm7NKL.png
Views:	1
Size:	203.1 KB
ID:	1111754

                              New:
                              Click image for larger version

Name:	ANmdEsx.png
Views:	1
Size:	197.1 KB
ID:	1111757

                              I will look more into this to discover the true source of the issue. It does not occur with the regular toolkit, only the 2D example. As I mentioned it probably has to do with event dispatchers not working properly for child actors.
                              Advanced Turn Based Tile Toolkit (Marketplace - Support)

                              Dungeon Crawler Toolkit (Marketplace - Support)

                              Discord

                              Comment


                                Hi Monokkel,

                                This looks like a great toolkit. I am really excited to start working with this. I was wondering if there was a simple way to port this project into a C++ project so I could use the combination of blueprints and C++. I tried by creating an empty C++ project and then migrating the assets from this project into that C++ project. However, my first pass was unsuccessful because I could not get the mouse to recognize the input to the pawn (i.e select the grid to move to). I figure this has something to do with the player controller and perhaps re-parenting, however I am not exactly sure. Anyways, any help on this front would be appreciated.

                                Thanks,

                                Eric
                                ----
                                Eric Kruger, DPT, CSCS | @EKrugerDPT | Research Gate Profile
                                Doctor of Physical Therapy
                                Graduate Student Psychology
                                University of New Mexico
                                ----

                                Comment

                                Working...
                                X