Announcement

Collapse
No announcement yet.

[SUPPORT] Advanced Turn Based Tile Toolkit

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

    Originally posted by Monokkel View Post

    Are you sure it is not triggering the notify or just that it is not doing damage? In the included offensive ability blueprints I unbind the event dispatcher which listens for the attack hitting after the first hit, so this is what might be happening. If you are uncertain about what is being triggered, try using PrintString nodes to see how many times something is executed (like the notify events)
    Okay, you're right. The event is going off (twice per hit for some reason), but damage is only being done once. How should I fix this? I'm scared of messing with the ability blueprint and messing things up. Should I get rid of this Unbind event or something?
    Last edited by PrayWaits; 08-19-2019, 08:03 AM.

    Comment


      Hi, just want to say I'm really appreciating the toolkit, thanks for doing such a great job with it. Have some questions and doing my best to answer them with the resources available, but if not, I'll send you some questions soon.

      Comment


        So I've been using the toolkit for a few days and doing my best to keep up.

        There are a couple of tasks that I want to accomplish but have been struggling with.

        1) I'm hoping to add objects on certain corners of the square grid, i.e. at the point in between 4 square tiles. that are able to be attacked but don't have any movement or attacking of their own. I could do this by offsetting the locations of things like units by 100x100, but then they will still be occupying a square tile that another unit may need to occupy later. I need them to be recognized as being on the corners, so I can click on them as opposed to an object on a square adjacent to them. Some of them will also end up needing to have functionality such as increasing the damage or reducing the health of units in the 4 squares adjacent to them (depending on faction).

        2) Relatedly, I'm hoping to have a level system where a unit levels up (and stores its new level) after successfully killing something, be it enemy units or the above mentioned corner objects. I'm hoping to have this level up increase both its health and damage values by a fixed integer amount each time it gets a kill.

        Comment


          Originally posted by PrayWaits View Post

          Okay, you're right. The event is going off (twice per hit for some reason), but damage is only being done once. How should I fix this? I'm scared of messing with the ability blueprint and messing things up. Should I get rid of this Unbind event or something?
          Ok, so here is what I'm guessing is happening (without being able to check my code). When your attack animations are being called in my offensive abilities an immediate QueueAction macro is called, which culminates in an attack animation being played by the unit. Before the action is queued I bind an event to an event dispatcher which is responsible for showing damage dealt and ending the action. As part of this it also unbinds the event from the dispatcher.

          Since the event is unbound as soon as it is called only the first attack will call the dispatcher. However, if you do not unbind it, EndAction will be called twice (which would result in issues, since you have not queued two actions. This would then end whatever the next action in the queue is). You could fix this by splitting it up. Have one event that is bound to one dispatcher, which is responsible for displaying damage dealt and another responsible for ending the action. The first dispatcher should be called whenever an attack animation lands an attack (through notifies), while the other should be called first when all attack animations have ended. Only this second event should unbind events (both) and end the action.

          Originally posted by behappyandsm1le View Post
          So I've been using the toolkit for a few days and doing my best to keep up.

          There are a couple of tasks that I want to accomplish but have been struggling with.

          1) I'm hoping to add objects on certain corners of the square grid, i.e. at the point in between 4 square tiles. that are able to be attacked but don't have any movement or attacking of their own. I could do this by offsetting the locations of things like units by 100x100, but then they will still be occupying a square tile that another unit may need to occupy later. I need them to be recognized as being on the corners, so I can click on them as opposed to an object on a square adjacent to them. Some of them will also end up needing to have functionality such as increasing the damage or reducing the health of units in the 4 squares adjacent to them (depending on faction).
          This is the sort of question that I wished I was back home for, as it would help to do some testing, but I'll try my best.

          So, there are roughly as many corners on a square grid as there are tiles (since all tiles have four corners, but most corners are shared between four tiles). As you mention you can put an object at the corner of a tile by placing it on the center of a tile and then offsetting it by half the width of a tile on both the X and Y axes. This is in fact what I do with multi-tile ("big") units that occupy an even number of tiles along both axes. In the case of units sized 2*2 tiles, for instance, the unit "really" occupies only the top left of the tiles (as far as its GridIndex variable is concerned). You should be able to do something similar with your corner objects.

          But this leads to some complications, as you have noted. Your objects cannot be units, or units will not be able to stand on the tile which is occupies on the grid. You should thus not use units for this. Luckily I've included another TMap called GridObjects which was made with these sorts of things in mind. By using AddObjectToGrid you can add a reference to your objects to any tile without disrupting unit movement. Check out the items in the HydrasLair map for examples of how to add and interact with GridObjects.

          For the aura effects of your objects, that increase damage, reduce health etc. on adjacent units you can get all the appropriate tiles pretty easily. If the object really occupies the top left tile you can get the object's GridIndex as well as GridIndex + 1, +1000 and +1001.

          So to perhaps the trickiest part, which is targeting the objects with an attack. If you use a special type of attack for just targeting these objects but not units it is relatively straightforward. You would just offset the hover marker similarly to what I do for the move ability when you have a 2*2 unit as the active unit. Again you are really targeting the tile to the top left of whatever tile you are hovering over here, but for all gameplay purposes it works as if you are targeting the space between tiles.

          However, I am guessing you want your attack abilities to be able to attack both units and your objects depending on what the player is hovering over, which again leads to the problem of units and your objects occupying the same tile. It was for these sorts of corner cases (forgive the pun) I made it so that abilities store not just the index of the tile being hovered over (or clicked), but also the precise world location under the mouse. You likely want to make a child actor of BP_AbilityBase that you use for your abilities (at least the ones that can target the corner objects) where you override some of what is done for the hover and click events. Normally I here check if the mouse is hovering over something that blocks path trace, which is a valid tile etc. Before this you could do a line trace for your corner objects (using some trace channel your objects are set to block. Do not use PathTrace or RangeTrace for this, as this will affect visibility and pathfinding). If this channel is blocked by one of your corner objects, do not run the regular hover and click events, but instead make custom ones which target the custom corner objects.

          This is the general approach I would take for implementing something like this. It takes a bit of work, as you can see, since you're violating an assumption of the toolkit, which is that anything relevant to gameplay exists withing tiles. However I have kept these sorts of things in mind while designing the toolkit, which makes such modifications much simpler than they could have been. I hope this helps you. I can go into more detail once I'm back from my vacation early next month if you are still in need of help.

          Originally posted by behappyandsm1le View Post
          2) Relatedly, I'm hoping to have a level system where a unit levels up (and stores its new level) after successfully killing something, be it enemy units or the above mentioned corner objects. I'm hoping to have this level up increase both its health and damage values by a fixed integer amount each time it gets a kill.
          This is a lot simpler. Modifying health or damage is as simple as modifying any variable in UE4 (though for health you would also have to remember to update the health bar appropriately). The only bit of modification you would need to do here would be related to how you determine the killer whenever a unit is killed. There are several ways you could do this. You could do this by adding a reference to the source unit in the TakeDamage event in BP_Unit and run your LevelUp event for this unit if CurrentHealth of the target is 0 after taking damage. If units only ever take damage on other unit's turns you can simply check what is the current ActiveUnit in BP_TurnManager whenever a unit dies and level up this unit. You could even level up as part of your attack abilities. After dealing damage with the attack, check if the target unit still lives (several possibilities here. Is health 0? Can the unit still be found in the initiative array? Has a custom bDead boolean been set to true), and level up the OwningUnit if this is the case.
          The Advanced Turn Based Tile Toolkit (Marketplace page - Feedback thread)

          Comment


            Thanks for your detailed feedback Knut

            I'm going to give all of your suggestions my best shot and hopefully won't need too much guidance along the way.

            Comment


              Originally posted by Monokkel View Post

              You could fix this by splitting it up. Have one event that is bound to one dispatcher, which is responsible for displaying damage dealt and another responsible for ending the action. The first dispatcher should be called whenever an attack animation lands an attack (through notifies), while the other should be called first when all attack animations have ended. Only this second event should unbind events (both) and end the action.
              I can't figure out how to do this. :/ Is there any way to revert the toolkit back to the version before the action system? I've always been bad with figuring out where and when and how to use events.

              Comment


                Hi. I'm making a turn by turn game that is more in the line of a chess or checker type game. That is, the pieces move one or two squares at a time, capture a piece by either moving into the opponet's piece square or jumping it, depending on the situation. The pieces themselves are spaceships and bases.

                Any tips on using your product to build a game like this?

                Also, I've seen your tutorial vids, (great work on them and the product by the way), but since I can't always watch vids, I was hoping that there was some kind of pdf type of documentation. Something I can download and refer to without using a vid. (I know it's old fashioned :-) ).

                thank you for your product and your attention.

                Comment


                  Hi Knut,

                  Just finished up watching your Ability video and wanted to see if I'm understanding correctly that you intended to make a video of how to set up a new ability from scratch, but it hasn't come out yet (if it does exist, would love to see it). Thanks

                  Comment


                    With regards to the question I had about setting up pieces on the corners of squares, and your answer about how there are nearly as many corners as squares, I'm wondering what you think about the feasibility of building another 7x7 grid on top of my 8x8 grid (by setting the position correctly we can make the center of every tile on the 7x7 grid rest on top of the corners of all of the tiles on the 8x8 grid). I know the toolkit wasn't designed to be used with multiple grids, but if we built communication between them, would that be a potentially easier way to go about it?

                    Secondly, I have another piece of functionality that I am trying to build in to abilities. I'm trying to make it so that players have a number of Action Points (AP) for their whole faction, as opposed to for each owning unit. In other words, the owning units AP cost is being subtracted from a limited share of total AP that belongs to the whole faction (moving a unit costs 1 per square, attacking costs 2 per target, some other abilities may cost 3), and this number is determined at the beginning of each faction's turn by a random integer in range 1-6.

                    Within this functionality, I also need a way for units to attack single targets together. Something like select multiple units and doing a single attack with them on a target. For some context, my game is designed to incentivize players to have their units work together to attack single targets by having an attack on a single target always cost 2 AP, no matter how many units you're using, whereas if you're attacking separate targets it costs 2 AP per attack.

                    Thanks so much and looking forward to getting a sense of how difficult this might be and how you would go about it. All the best.

                    Comment


                      Sorry for the delay. Been out biking the last couple of days. Will get to your questions now.

                      Originally posted by PrayWaits View Post

                      I can't figure out how to do this. :/ Is there any way to revert the toolkit back to the version before the action system? I've always been bad with figuring out where and when and how to use events.
                      Sorry to hear you are struggling. As soon as I'm back home in a weeks time I'll be able to give you a more detailed explanation (with screenshots). It is possible to get a version without the action system, though I cannot really recommend it. It is so different from the current version and a couple of years old at this point, so it would be very difficult for me to provide support. To get it you have to select version 4.14 in the dropdown when creating a new project with the toolkit. If you choose to convert in place to use a newer version of UE4 with the older ATBTT you likely have to fix several issues to get things working properly.

                      I can give you a hacky solution for your problem for now, which is more in line with how I would have done things in older versions. Keep the event dispatcher for the events that show damage on the health bar, but disconnect it from the EndAction event. After binding the dispatcher create a delay node. Have the delay be long enough that all your attack animations are completed (you could get a custom float variable from the OwningUnit for this so you can vary it for units with different animations. Once the delay is over, unbind the dispatcher and call EndAction.

                      Originally posted by OwnerJFA View Post
                      Hi. I'm making a turn by turn game that is more in the line of a chess or checker type game. That is, the pieces move one or two squares at a time, capture a piece by either moving into the opponet's piece square or jumping it, depending on the situation. The pieces themselves are spaceships and bases.

                      Any tips on using your product to build a game like this?

                      Also, I've seen your tutorial vids, (great work on them and the product by the way), but since I can't always watch vids, I was hoping that there was some kind of pdf type of documentation. Something I can download and refer to without using a vid. (I know it's old fashioned :-) ).

                      thank you for your product and your attention.
                      Hey, I recently answered a similar question about chess movement in this thread. See if this answers your questions and let me know if you have any remaining questions: https://forums.unrealengine.com/unre...18#post1653018

                      As for the PDF question, yeah I can see how that would be useful to people. The main reason I have not done so is that it is quite time consuming, and my dev time is already quite limited. There are still a lot of tutorial videos I need to do, so it would be a long time until I feel I can afford the time. Sorry about that. I hope you can still make use of the video tutorials and let me know here if you need me to clear something up.

                      Originally posted by behappyandsm1le View Post
                      Hi Knut,

                      Just finished up watching your Ability video and wanted to see if I'm understanding correctly that you intended to make a video of how to set up a new ability from scratch, but it hasn't come out yet (if it does exist, would love to see it). Thanks
                      Yes, that is indeed high on my list. I am planning this as my next video after I've made a video on pathfinding.

                      Originally posted by behappyandsm1le View Post
                      With regards to the question I had about setting up pieces on the corners of squares, and your answer about how there are nearly as many corners as squares, I'm wondering what you think about the feasibility of building another 7x7 grid on top of my 8x8 grid (by setting the position correctly we can make the center of every tile on the 7x7 grid rest on top of the corners of all of the tiles on the 8x8 grid). I know the toolkit wasn't designed to be used with multiple grids, but if we built communication between them, would that be a potentially easier way to go about it?
                      Hmm, can be done, but you're breaking some built-in assumptions which means you'll need to do some extra work. As far as pathfinding is concerned, the toolkit does not really care about the layout of the grid. You can set GridLocations to be anything you want and connect tiles for pathfinding with GridEdges in an arbitrary fashion. However, the code for finding grid indexes based on a location and finding tiles in range both make assumptions about the grid structure. You would thus have to make custom methods for finding tiles in range, for instance. Selecting corner tiles would also need to be done in a different fashion to the regular conversion from location to grid index. All of this is doable, but tricky. I think my suggestion for using GridObjects and faking the offset would be a much simpler solution to your problem.

                      Originally posted by behappyandsm1le View Post
                      Secondly, I have another piece of functionality that I am trying to build in to abilities. I'm trying to make it so that players have a number of Action Points (AP) for their whole faction, as opposed to for each owning unit. In other words, the owning units AP cost is being subtracted from a limited share of total AP that belongs to the whole faction (moving a unit costs 1 per square, attacking costs 2 per target, some other abilities may cost 3), and this number is determined at the beginning of each faction's turn by a random integer in range 1-6.
                      This should be pretty straightforward to implement. In any code that gets or sets the AP of a single unit instead get or set the AP of your group AP. This value could perhaps be stored in the TurnManager or GameState. I assume you already know how to get a random integer, which is what you would do at the start of the turn.

                      Originally posted by behappyandsm1le View Post
                      Within this functionality, I also need a way for units to attack single targets together. Something like select multiple units and doing a single attack with them on a target. For some context, my game is designed to incentivize players to have their units work together to attack single targets by having an attack on a single target always cost 2 AP, no matter how many units you're using, whereas if you're attacking separate targets it costs 2 AP per attack.
                      This one is a bit more difficult, though also doable. I'd probably want to make a new custom ability for this (based on BP_AbilityBase, probably, as it is quite nonstandard) that handles selecting multiple units at once and getting them all to attack. This is another of those questions I wish I was home in order to answer better. Essentially you would keep an array in the ability of selected units, where you can add new units by clicking them. Then when clicking an enemy you would loop through all the units and have all of them attack the target unit (in the game logic). Then you would queue an action with this array of units and the target unit as inputs and in AnimateAction loop over these units to play their attack animations.

                      Originally posted by behappyandsm1le View Post
                      Thanks so much and looking forward to getting a sense of how difficult this might be and how you would go about it. All the best.
                      Happy to help, and hope my answers are useful. You're trying some stuff that requires somewhat large modifications to the toolkit. Nothing that is impossible by any means, but I hope you're prepared to spend a lot of time learning and experimenting. Best of luck, and let me know if you have any follow-up questions.
                      The Advanced Turn Based Tile Toolkit (Marketplace page - Feedback thread)

                      Comment


                        Hey Knut! I was wondering if there's an easy way to merge changes from your recent updates into my slightly older version? Would be a shame to have to go file by file and see what I have changed. I would love to get the updates! Also, is the animations while moving still in the Experimental folder? Or is it part of the standard stuff now? Thanks!

                        Comment


                          Hello Knut,

                          I ran into a problem with the Game Over message never showing up in a certain circumstance. After a week of debugging and listening to you videos over and over, I figured out how to solve it and will explain it now.

                          So I have a unit with 3 Action Points and 3 Abilities something like this:

                          Move
                          Staff Attack (melee)
                          Lightning Strike (ranged)

                          I always had everything in code working fine, except in one situation. That is when the AI used the Melee Staff Attack to kill the last enemy in game. That leaves 1 or maybe even 2 Action Points left with that unit, so the Turn never ends, the game freezes in the RunNextAction loop, and the game never displays Game Over Message never shows up even though the game is over and the unit just runs idle animation.
                          Last edited by Locoweed; 08-24-2019, 09:04 PM.

                          Comment


                            Anyhow, after a week of debugging, this is where I found to set the AI Unit's Action Points to zero when the game was over and the Unit still had Action Points left.

                            It's in BP_Unit - Select Actor

                            Add the code with yellow edges.
                            Last edited by Locoweed; 08-24-2019, 06:12 PM.

                            Comment


                              So basically, the code sets the current AI Unit's CurrentAP to Zero when game is over so next Turn starts and Game Over will be displayed even if AI Unit has Action Points left.

                              That code doesn't hurt anything Knut, I would add it next update.

                              Would have saved me a week of frustration.

                              It really took a week to figure out where to put that code. A very painful week.
                              Last edited by Locoweed; 08-24-2019, 07:56 PM.

                              Comment


                                Originally posted by Zennisin View Post
                                Hey Knut! I was wondering if there's an easy way to merge changes from your recent updates into my slightly older version? Would be a shame to have to go file by file and see what I have changed. I would love to get the updates! Also, is the animations while moving still in the Experimental folder? Or is it part of the standard stuff now? Thanks!
                                Unfortunately diffing and merging is limited with blueprints. I think Perforce has some functionality for this, but I have not tested it myself. I try to mark most changes in a new version with a comment named after the new version.

                                You can search for these comments in blueprints to find most of the changes. However, I do not mark every minor change I make in such a fashion, so it is not perfect. It is possible to make updating to a new version simpler by not touching any of the core blueprints of the toolkit, but adding your changes to child actors of these blueprints. However, this can sometimes limit you in the sort of changes you can make, so it is unfortunately not ideal either.

                                The safest approach, and the one I would generally recommend, is to merge and copy over your own custom changes manually. However, this is of course time consuming, so you'll have to consider whether the changes in the update are worth the hassle, or if it is better to keep working with the older version. I wish I had a better answer for this, but I'm afraid I'm not aware of any perfect solution for this.
                                Originally posted by Locoweed View Post
                                So basically, the code sets the current AI Unit's CurrentAP to Zero when game is over so next Turn starts and Game Over will be displayed even if AI Unit has Action Points left.

                                That code doesn't hurt anything Knut, I would add it next update.

                                Would have saved me a week of frustration.

                                It really took a week to figure out where to put that code. A very painful week.
                                I'm very sorry to hear that you had to bang your head against the wall for a week for this, Locoweed. This is something that I should clearly have discovered and fixed a long time ago, and I thank you for posting your solutions here. From your screenshots it seems like you are not using the latest version, though. My last update was a major overhaul of the turn system, which I had hoped would eliminate these sorts of issues (among other things). I am away now and cannot confirm for myself for another week, but I will certainly look into this when I'm back and see if this is still a problem. If so I will make sure to fix it.
                                The Advanced Turn Based Tile Toolkit (Marketplace page - Feedback thread)

                                Comment

                                Working...
                                X