Originally posted by HaxorViper
View Post
Announcement
Collapse
No announcement yet.
[SUPPORT] Advanced Turn Based Tile Toolkit
Collapse
X
-
Advanced Turn Based Tile Toolkit (Marketplace - Support)
Dungeon Crawler Toolkit (Marketplace - Support)
Discord
-
I am a bit puzzled as to how to add a multiple weapon functionality. What I did was make the weapon stats as a separate component and then made a bunch of actors for each weapon with the separate component as their stats. But when I tried to get the extra component information in the moveattack ability I wasn't able to do it. I referred back to previous explanations on how to add weapons to this, but they are old and I don't know if there is a better way in the new update using abilities. Even with tutorials, I don't really understand the specifics of casting to other objects, getting child components, referencing, and all that stuff. I reverted to source control to get a fresh slate and I forgot to screenshot, so I am sorry if I am not clear. What is the best way to implement a weapon system in this current version: as different skills, as different actors, as different components, or something different?
Comment
-
Originally posted by HaxorViper View PostI am a bit puzzled as to how to add a multiple weapon functionality. What I did was make the weapon stats as a separate component and then made a bunch of actors for each weapon with the separate component as their stats. But when I tried to get the extra component information in the moveattack ability I wasn't able to do it. I referred back to previous explanations on how to add weapons to this, but they are old and I don't know if there is a better way in the new update using abilities. Even with tutorials, I don't really understand the specifics of casting to other objects, getting child components, referencing, and all that stuff. I reverted to source control to get a fresh slate and I forgot to screenshot, so I am sorry if I am not clear. What is the best way to implement a weapon system in this current version: as different skills, as different actors, as different components, or something different?
Create a new blueprint class for your weapons. This class should have designating all the important stuff that differentiate weapons, like damage, range, damage type (if this is in your game) etc. It would probably also contain the mesh of the weapon.
If the weapon in your games differ significantly in how they work mechanically it would probably also be good to have an ability class reference for what ability this weapon should use (you would probably not need an entire different ability for each weapon, but something like a rocket launcher and a sword would be different enough that creating two abilities would be simpler than making a shared ability general enough to work for both. Also you would probably want a tag or enum for the weapon class that the unit animation blueprint can look at when attacking to know how to animate the attack.
While answering your question I've thought of another possibility that could also work. Have the weapons use the ability class and themselves be abilities. You would likely want to create a weapon master class that inherits from BP_Ability which contains functionality used by all or most weapons and then have weapons be child blueprints of this master class. Weapons could play an equip animation when activated and would otherwise function just like abilities. The more I think about it the more I like this solution. I don't think I'd do something like this in a game with very simple weapon rules, such as for example Fire Emblem, but for something like Fallout or XCOM I think it would work great.
I'll try to give you quick explanations for the UE4 features you are uncertain about:
Casting is something you do when you have a reference to an object, but the reference variable is of a more basic class than the one you want, so you cast to get access to properties that are unique to the child object. For instance, the GridUnits map in BP_GridManager contains references to all the units placed on the grid. Say that you get one of these references and want to deal damage to it. However you have a child blueprint of BP_Unit that has an armor variable which you want to subtract from the damage dealt. UnrealEngine does not know what type of unit it references when you get a reference from the GridUnits map, only that it is a unit, so you do not have access to the armor variable. To get access you need to cast, which is essentially asking Unreal Engine "is this unit a unit_armor type unit?". If this is true you can use the access pin to get access to the armor variable. A pretty bad example, since using interfaces or simply handling the damage reduction within the unit itself would get the job done here, but I hope it helps you understand. Know that casting is a costly operation, so try to avoid using it whenever possible. Interfaces can generally do the same thing and better.Advanced Turn Based Tile Toolkit (Marketplace - Support)
Dungeon Crawler Toolkit (Marketplace - Support)
Discord
Comment
-
Im sure i remember seeing an example map with the multi-tile units, was that removed in the 1.8.1 update?
Anyway, just about to start a big project using the toolkit as a base. How far off is the 1.8.2 update? Only thing that is worrying me about starting now is the nativization bug you reported.
Comment
-
Originally posted by Monokkel View Post
It depends somewhat on the game and what the weapons do, I would say, but I'll give you one pretty general and powerful solution.
Create a new blueprint class for your weapons. This class should have designating all the important stuff that differentiate weapons, like damage, range, damage type (if this is in your game) etc. It would probably also contain the mesh of the weapon.
If the weapon in your games differ significantly in how they work mechanically it would probably also be good to have an ability class reference for what ability this weapon should use (you would probably not need an entire different ability for each weapon, but something like a rocket launcher and a sword would be different enough that creating two abilities would be simpler than making a shared ability general enough to work for both. Also you would probably want a tag or enum for the weapon class that the unit animation blueprint can look at when attacking to know how to animate the attack.
While answering your question I've thought of another possibility that could also work. Have the weapons use the ability class and themselves be abilities. You would likely want to create a weapon master class that inherits from BP_Ability which contains functionality used by all or most weapons and then have weapons be child blueprints of this master class. Weapons could play an equip animation when activated and would otherwise function just like abilities. The more I think about it the more I like this solution. I don't think I'd do something like this in a game with very simple weapon rules, such as for example Fire Emblem, but for something like Fallout or XCOM I think it would work great.
I'll try to give you quick explanations for the UE4 features you are uncertain about:
Casting is something you do when you have a reference to an object, but the reference variable is of a more basic class than the one you want, so you cast to get access to properties that are unique to the child object. For instance, the GridUnits map in BP_GridManager contains references to all the units placed on the grid. Say that you get one of these references and want to deal damage to it. However you have a child blueprint of BP_Unit that has an armor variable which you want to subtract from the damage dealt. UnrealEngine does not know what type of unit it references when you get a reference from the GridUnits map, only that it is a unit, so you do not have access to the armor variable. To get access you need to cast, which is essentially asking Unreal Engine "is this unit a unit_armor type unit?". If this is true you can use the access pin to get access to the armor variable. A pretty bad example, since using interfaces or simply handling the damage reduction within the unit itself would get the job done here, but I hope it helps you understand. Know that casting is a costly operation, so try to avoid using it whenever possible. Interfaces can generally do the same thing and better.
1. I made a component class that contains the weapon stats called BP_WeaponFEAttributes, I thought it'd be best to separate it in case I make different games with the same engine, and because that's the format that was being used for the extra components and the stealth component.
2. I made a weapon class containing the Weapon Attributes component and an empty skelletal mesh (Set as skelletal mesh because that was how the infinity blade weapons for testing it were setup)
3. I made child actors of that class that defined the inherited components, such as an iron sword. This picture isn't different in attributes as that's the default but I made the skelletal mesh a sword.
3.I then followed previous advice to add this weapon class to the unit blueprint. Here is where I have no idea what to do. Was I supposed to just make everything a component? They end up all as child actors when I directly dragged it into it. Well anyways, I didn't know how to get it to work out so I provisionally added the weapon attribute component to the unit itself to test the combat data function.
4. I attempted referencing these in the ability blueprint, since move_attack inherits from it. So I changed the FindHitChance function for the advanced example to FindCombatData, this would take the unit's attributes and combine them with the weapon's attributes to get the total combat data.
5. Since I didn't know how to reference the weapon child actors, I just copied the function you used for the extra components. Even when I didn't attempt to reference them as child actors, I didn't know how to cast to them and get their data, and I don't understand how interfaces work either. I have the feeling that I wasn't supposed to add the weapons directly onto the unit like I did as child actors.
6. Once done, I attempted to call this function somewhere in the moveattack, specifically after the "attack" action in the "Click" section. But it didn't seem to work well, the execution flow only goes to the attack action when it kills the other unit, which I feel is kind of misleading or perhaps my thing was bugged out. So I assumed the later and reverted the moveattack back to when I had no changes. My question now is, where in this large graph would I put the function to get the combat data and check if random floats are lower than the hit chance and the critical chance? I know you explained it before in this support thread, but that was before you made this queue action system.
Comment
-
Originally posted by elec2ron View PostIm sure i remember seeing an example map with the multi-tile units, was that removed in the 1.8.1 update?
Anyway, just about to start a big project using the toolkit as a base. How far off is the 1.8.2 update? Only thing that is worrying me about starting now is the nativization bug you reported.
Edit: Whoops, forgot to answer your first question. Big units are a work-in-progress and won't be fully implemented until 1.9, However there is experimental support already in the version currently on the marketplace. Only recommended for people with a very good understanding of the toolkit at this point, since you will probably need to modify it quite a bit to fit your game. To make a unit multi-tile increase its size variable under grid options. Then in the grid manager set max unit size. Max unit size currently supported is 5 and only for square, single-level grids.
Originally posted by HaxorViper View Post
Thanks, I am doing it for a Fire Emblem system so I only need a basic system of getting their weapon stats, their weapon triangle position, and their effectiveness. I managed to recreate the situation I was in, and knowing that I did most things wrong, I want to know what I should do instead. This is the way I did it (It didn't work):
1. I made a component class that contains the weapon stats called BP_WeaponFEAttributes, I thought it'd be best to separate it in case I make different games with the same engine, and because that's the format that was being used for the extra components and the stealth component.
2. I made a weapon class containing the Weapon Attributes component and an empty skelletal mesh (Set as skelletal mesh because that was how the infinity blade weapons for testing it were setup)
[ATTACH=CONFIG]n1471327[/ATTACH]
Originally posted by HaxorViper View Post4. I attempted referencing these in the ability blueprint, since move_attack inherits from it. So I changed the FindHitChance function for the advanced example to FindCombatData, this would take the unit's attributes and combine them with the weapon's attributes to get the total combat data.
[ATTACH=CONFIG]n1471330[/ATTACH]
5. Since I didn't know how to reference the weapon child actors, I just copied the function you used for the extra components. Even when I didn't attempt to reference them as child actors, I didn't know how to cast to them and get their data, and I don't understand how interfaces work either. I have the feeling that I wasn't supposed to add the weapons directly onto the unit like I did as child actors.
[ATTACH=CONFIG]n1471331[/ATTACH]
Originally posted by HaxorViper View Post6. Once done, I attempted to call this function somewhere in the moveattack, specifically after the "attack" action in the "Click" section. But it didn't seem to work well, the execution flow only goes to the attack action when it kills the other unit, which I feel is kind of misleading or perhaps my thing was bugged out. So I assumed the later and reverted the moveattack back to when I had no changes. My question now is, where in this large graph would I put the function to get the combat data and check if random floats are lower than the hit chance and the critical chance? I know you explained it before in this support thread, but that was before you made this queue action system.
[ATTACH=CONFIG]n1471332[/ATTACH]
Originally posted by HaxorViper View PostThe problem is, I couldn't reference the weapon attributes, I don't know how to communicate between blueprints correctly. And when I attempted to reference the combat data for the attack ability, I didn't know where to put it. Since I am new to UE4 I have comprehension issues, I sometimes misinterpret directions as the wrong things, which is what I think happened with the weapons. I'd appreciate if you could check it out and see what I did wrong and where I could put the find data function. Thank you for your time.Last edited by Monokkel; 05-04-2018, 11:38 PM.Advanced Turn Based Tile Toolkit (Marketplace - Support)
Dungeon Crawler Toolkit (Marketplace - Support)
Discord
Comment
-
Originally posted by Monokkel View Post
I don't believe you can add meshes to blueprint components, as I think you've also discovered. So if you want your weapon components to be associated with a mesh you would either make them actors or have a static mesh variable as one of the variables contained in the component and spawn an instance of this mesh when the weapon is equipped. If you go by it this second way you can keep using components which are simpler to access than child actors.
Originally posted by Monokkel View PostYou're going to need to do some reading up on Unreal Engine features. Read the UE4 documentation and do some tutorials. I googled "unreal engine get child actor reference" and this was the result, so the information is there if you search for it. I know that these things are frustrating when you are learning the engine and that it is tempting to jump ahead to add the specific features you want, you need to build up the fundamentals first. If you use the component method I suggested above, though, you can just use the get component nodes, which are simple and efficient.
Originally posted by Monokkel View PostThe attack action is called whenever an attack is performed, not just when a unit is killed, so you must have changed something on your end. What exactly is your function supposed to do? The resolution of the screenshot you included is too low for me to read it. In most cases I think it would be best to call it somewhere after ExecuteAbility. If it modifies any of the information that is passed to the attack action or deal damage you would want to call it before any of these.
And on move_attack's behavior, I just debugged it and it seems like the execution is actually passing through it when frame skipped, but when I checked it in real time it doesn't flow through it. It seems more like an unreal engine 4 bug, the flow only appeared when the game ended by killing the last unit. I was thinking that I broke it so I deleted what I've done and got a fresh slate of move_attack, but it was just the execution flow being glitched. :/
Originally posted by Monokkel View PostAs mentioned, the documentation and various tutorials on referencing and casting will do a better job of describing all of this than I can. So to sum up, right after ExecuteAbility is probably a good place for your FindData function. For accessing components use the GetComponent functions. For accessing other variables contained in the blueprint itself get a reference to the blueprint and use a cast if you want to access variables contained in a child blueprint where you only have a reference to the parent. To access variables in child actor components first get a reference to the component and then use GetChildActor. Cast if needed. Also, check out some tutorials on interfaces, as they are very useful for these sorts of things; especially in cases where you have multiple different objects with shared functionality.
Comment
-
Hey man!
I will get to your ideas on how to make a deployment phase and I'm sure they will work great but I realized before I get to that I would like to use some placeholder Characters instead of the default mannekins to be able to differentiate between the different players aswell as having the option from the selected character from the lobby carry over into the game.
My first issue I've run into is that the character, even though rigged and retargeted, only takes the idle state in the game and never animates hits och animates taken hits. I know previously you've talked about this issue, just wondered if you have the time to go over it again in some more detail? I could not really understand the previous answer (to another forum user, not me).
Thanks man and hope all is well!
Cheers,
Mivke
Comment
-
Originally posted by HaxorViper View PostI have actually been watching tutorials and documentation for months, but everything blends together because there are so many different ways to do the same thing. And due to my inexperience my comprehension is pretty bad when reading these things. I feel like I don't understand things unless I try them, so I wanted to build my fundamentals with experience. It is pretty rough, and I understand when to use them, I just need to learn how. Thanks for the links, I feel a bit stupid not googling it :P
Originally posted by HaxorViper View PostMy function is the one pictured in 4, it's basically just a bunch of float additions and substractions taken from the unit stats and weapon stats to get the combat data of an encounter (Chance to hit, critical hit chance, and damage). What I screenshot in 6 is the move_attack function that came with the package, I just wanted to know the general location of where I'd put the combat data function so that I can roll numbers against the hit chance and critical chance and get an updated damage value.
Originally posted by HaxorViper View PostAnd on move_attack's behavior, I just debugged it and it seems like the execution is actually passing through it when frame skipped, but when I checked it in real time it doesn't flow through it. It seems more like an unreal engine 4 bug, the flow only appeared when the game ended by killing the last unit. I was thinking that I broke it so I deleted what I've done and got a fresh slate of move_attack, but it was just the execution flow being glitched. :/
Originally posted by HaxorViper View PostThanks man. I hope I am not frustrating you or anything, I know I shouldn't tackle something like this when just starting out. While I watched a bunch of documentation and tutorials, what I read isn't retained in my head because by just reading I didn't have anything to apply it to and remember. I want to learn the engine by using your package because of my love for tactical role playing games, and I feel that whatever I learn here I am going to remember more easily.
Like I said, don't worry about it, we've all been there. Sorry if my tone came across as annoyed; that was not my intent. I agree that it is often easier to learn stuff while you're working towards a goal.
Originally posted by Stirling93 View PostCould the GridActors be used to snap onto each other / other grid actors? Example: Stacking a BP_GA_Tile_Wall on top of itself to make a modular wall.
Originally posted by Nobleactual View PostHi Monokell and felow toolkit users, I want to create a trap tile were if a unit moves over it, it will stop on the trap tile and take damage. I know the damage part but the unit keeps on moving and then take the damage but i want it to stop. Is this possible?
Thanks in advance
So for a trap you would want to add a check to each step of the movement simulation that sees if anything happens on that specific tile before proceding to the next. If a trap is found and that trap is supposed to stop the unit you need to make sure only the grid indexes up to the index of the trap are converted to locations.
There is an event dispatcher in the toolkit created for just this sort of thing. If you look in the SimulateMove function of BP_Unit you can see that the "OnEnterTileSimulate" event dispatcher is called whenever a unit enters a new tile (during simulation).
You can bind an event in your trap actors to this event dispatcher. When the dispatcher is called, compare the grid index to the trap to the grid index output from the OnEnterTileSimulate dispatcher. If they are the same that means that the unit has entered the tile of the trap.
At this point you deal damage to the unit. Then, if you want movement to stop you first want to stop the simulated movement. In the SimulateMove function add a branch that exits the loop if true, similar to the "contains" node for the GridUnits map that is currently in the SimulateMove function. Set whatever variable is input to this branch to true when the trap is entered to stop the simulated movement.
Now you need to make sure to only pass the locations up to the tile index of the trap into the QueueAction macro, instead of the entire path. You can do this by storing the index of the trap when it is triggered, using Find on the PathIndex array to find the array index of this grid index and use this to create a new array of locations from the PathLocations array stopping at the index found in the last step and feeding this into the move action. You would then want to queue an animation for displaying the unit being hurt by the trap right after the move action has been queued (as it happens right after movement stops).
Those are the steps I would go through to create something like this. It is a bit complex, I know, so let me know if you have any questions.
Originally posted by Mivke1 View PostHey man!
I will get to your ideas on how to make a deployment phase and I'm sure they will work great but I realized before I get to that I would like to use some placeholder Characters instead of the default mannekins to be able to differentiate between the different players aswell as having the option from the selected character from the lobby carry over into the game.
My first issue I've run into is that the character, even though rigged and retargeted, only takes the idle state in the game and never animates hits och animates taken hits. I know previously you've talked about this issue, just wondered if you have the time to go over it again in some more detail? I could not really understand the previous answer (to another forum user, not me).
Thanks man and hope all is well!
Cheers,
MivkeAdvanced Turn Based Tile Toolkit (Marketplace - Support)
Dungeon Crawler Toolkit (Marketplace - Support)
Discord
Comment
-
Originally posted by Monokkel View PostThere might be several reasons for this depending on what you have done. Check the event graph of BP_Unit_Anim and compare it to the event graph of your new units. Are there any differences? What about ABP_Unit compared to your new animation blueprint? Maybe you have forgotten to add notify events to the new animations? Let me know what differences you find and I'll try to figure out what has gone wrong.
Cheers man and as always thanks for the quick replies!
P.S I'm looking through your most recent tutorials again to try to understand. I think the problem is that I'm not animating my unit, but since I didn't change anything I'm wondering why it does not "inherit" this automatically? (I am at work atm so can't look at the BP for it right now, maybe it's obvious
Comment
-
Hey man,
I solved this issue. Not 100% sure what was wrong since I still don't understand all the basics but when I redid the overides you do in BP_Unit_Anim with regards to the ABP_Refs it started working. I guess since I'm using another mesh the cast to BP_Unit became null or something to that effect.
IF you have the time and will you are more than free to let me know by text what I did, otherwise simply ignore this last strand of issue
Back to work on the deplyment phase :P
Speaking of which, do you have some kind of round counter or round start or something to that effect? Basically something that does what Start Match does but get's called after every unit has had one turn.
Cheers man!
Comment
-
Hey man, sorry for the spam but just had a very good day of working on the project and wanted to get this question out before having to go pick up my kid :P
I've started implementing the DeploymentPhase and it's going really good. I have run into a problem though that I think is due to some behaviour of the Grid Manager "under the hood". I will try to explain with text and some screenshots.
So basically, I've made a custom event i BP_ATBTT called DeployCharacter (this gets called from BP_PlayerController_ATBTT) that loads my settings from the Lobby and then spawns a character on a tile (like you said earlier). This worked wonderfully. I then added a boolean called bDeployable to the BP_GA_Tile_Hex, set to false by default, and changed it to true on the tiles I wanted to be deployable. However, none of the tiles with bDeployable set to true can be deployed and neither can the default tiles with ONE exception with allows the spawning of the character. I get an error on the Branch where I'm checking if bDeployable is true or not in the DeployCharacter event, the error says
"Blueprint Runtime Error: Accessed None trying to read property CallFunc_Array_Get_Item3 from function: 'ExecuteUbergraph_BP_ATBTT' from node: Branch in graph: EventGraph in object: BP_ATBTT with description: Accessed None trying to read property CallFunc_Array_Get_Item3"
Below are screenshots of all of the things I can think of that I've modified. If you have the time and will to help I will as always be super grateful, let me know if you need any more clarification.
Hope all is well!
(there is one more picture that is too large to be uploaded, let me know if you need it and I can try to make it smaller or mail it).Last edited by Mivke1; 05-08-2018, 09:48 AM.
Comment
-
Originally posted by Mivke1 View PostHey man,
I solved this issue. Not 100% sure what was wrong since I still don't understand all the basics but when I redid the overides you do in BP_Unit_Anim with regards to the ABP_Refs it started working. I guess since I'm using another mesh the cast to BP_Unit became null or something to that effect.
IF you have the time and will you are more than free to let me know by text what I did, otherwise simply ignore this last strand of issue
Back to work on the deplyment phase :P
Speaking of which, do you have some kind of round counter or round start or something to that effect? Basically something that does what Start Match does but get's called after every unit has had one turn.
Cheers man!
Originally posted by Mivke1 View PostHey man, sorry for the spam but just had a very good day of working on the project and wanted to get this question out before having to go pick up my kid :P
I've started implementing the DeploymentPhase and it's going really good. I have run into a problem though that I think is due to some behaviour of the Grid Manager "under the hood". I will try to explain with text and some screenshots.
So basically, I've made a custom event i BP_ATBTT called DeployCharacter (this gets called from BP_PlayerController_ATBTT) that loads my settings from the Lobby and then spawns a character on a tile (like you said earlier). This worked wonderfully. I then added a boolean called bDeployable to the BP_GA_Tile_Hex, set to false by default, and changed it to true on the tiles I wanted to be deployable. However, none of the tiles with bDeployable set to true can be deployed and neither can the default tiles with ONE exception with allows the spawning of the character. I get an error on the Branch where I'm checking if bDeployable is true or not in the DeployCharacter event, the error says
"Blueprint Runtime Error: Accessed None trying to read property CallFunc_Array_Get_Item3 from function: 'ExecuteUbergraph_BP_ATBTT' from node: Branch in graph: EventGraph in object: BP_ATBTT with description: Accessed None trying to read property CallFunc_Array_Get_Item3"
Below are screenshots of all of the things I can think of that I've modified. If you have the time and will to help I will as always be super grateful, let me know if you need any more clarification.
Hope all is well!
(there is one more picture that is too large to be uploaded, let me know if you need it and I can try to make it smaller or mail it).
Say you have 6 actors of type BP_GA_Tile_Hex placed in your game. If you used GetAllActors of type BP_GA_Tile_Hex this will return an array of length 6, with the array indexes 0-5. Now when you use the GetHitLocationAndIndex function you get the grid index of the tile under the mouse and try to use this to get a tile from this other, small array. To get the grid index of a tile using a similar method to what you are using you would need to loop over all of the actors in the array and check their GridIndex variable agains the grid index output from GetHitLocationAndIndex.
This would work, but it would not be very performant. Not a big issue here, as you are just looping over a few actors and not very often. I would instead suggest to create a new set of integers in BP_GridManager holding the grid indexes of all deployable tiles. If you want to define which tiles are deployable by manually placing these in the viewport like you are doing now you could fill this set by looping over all these spawning platforms during the setup of BP_GridManager, getting the GridIndex of each and adding these to the set. That way you only need to loop over all the actors once, and not while the game is running. You could also fill this set by any other way you wanted and would not be dependent on manually placing spawning points if you do not want to.
You are really close to have a working setup, and I hope my explanation will allow you to get it working how you want it to.Advanced Turn Based Tile Toolkit (Marketplace - Support)
Dungeon Crawler Toolkit (Marketplace - Support)
Discord
Comment
Comment