Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

TurnBased-Toolkit (TBTK)

Discussion in 'Assets and Asset Store' started by songtan, Aug 11, 2013.

  1. DonJaket

    DonJaket

    Joined:
    Oct 14, 2013
    Posts:
    10
    Hey Songtan,

    I'm currently trying to create unit interaction with the scenario. More specifically, open and close doors.
    I know that I can easily change tiles from walkable to non-walkable, but the doors are not so large to fit inside a whole tile.

    What I'm trying to do is use walls (Obstacle_Wall_FullCover) as doors. I'm able to activate and deactivate them ingame, but the units still won't move through the now deactivated walls.

    Could you give me some pointers as how I could do this? Activate / deactivate a wall so the units can walk through?

    Thanks
     
  2. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    The thing is, the connected neighbor (not blocked by wall or obstacle) of each tile has been setup from when the game start. You can activate/deactivate the wall object but that that wont add the adjacent tile back to the neighbour list. I'm in a hurry so I cant tell you all the detail now. Please look into Tile.cs AddWall() and RemoveWall(). They will give you a clue to how to do it properly.
     
  3. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    Right, I've took another look at the code and add two function (to be placed in Tile.cs) to connect and disconnect the neighbour as you disable/enable the wall. I haven't try it out yet so please give it a go and let me know.
    Code (csharp):
    1.     public void DisableWall(Transform wallObjT){
    2.        for(int i=0; i<wallList.Count; i++){
    3.          if(wallList[i].wallObjT==wallObjT){
    4.            Tile neighbour=wallList[i].neighbour;
    5.            aStar.ConnectNeighbour(neighbour);
    6.        
    7.            for(int n=0; n<neighbour.wallList.Count; n++){
    8.              if(neighbour.wallList[n].wallObjT==wallObjT){
    9.                aStar.ConnectNeighbour(neighbour.wallList[n].neighbour);
    10.                break;
    11.              }
    12.            }
    13.        
    14.            break;
    15.          }
    16.        }
    17.      }
    18.  
    19.      public void EnableWall(Transform wallObjT){
    20.        for(int i=0; i<wallList.Count; i++){
    21.          if(wallList[i].wallObjT==wallObjT){
    22.            Tile neighbour=wallList[i].neighbour;
    23.            aStar.DisconnectNeighbour(neighbour);
    24.        
    25.            for(int n=0; n<neighbour.wallList.Count; n++){
    26.              if(neighbour.wallList[n].wallObjT==wallObjT){
    27.                aStar.DisconnectNeighbour(neighbour.wallList[n].neighbour);
    28.                break;
    29.              }
    30.            }
    31.        
    32.            break;
    33.          }
    34.        }
    35.      }
    I assume what you are doing right now is activate and deactivate the wall object. Since you have reference to the wall object, what you need to do is determine the two nearest tiles to the wall and call these two function on the tile component.
     
  4. DonJaket

    DonJaket

    Joined:
    Oct 14, 2013
    Posts:
    10
    Thanks for the "little" piece of code, it works perfectly :)
    Units can now enable or disable walls.

    There is just one thing, though: although the units are able to cross the tile, they are still considered in cover, as if the wall was still there (the cover shield icon still shows up where the wall was).

    I guess the obstacle is still there, although the wall is not visible and the tiles are now reconnected?
     
  5. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    So you have got cover system enabled. I haven't considered that. But obviously like the tile connection, the cover will need to be enabled/disabled as you activate/deactivate the wall. This involved a little bit more modification than changing the tile connection. Give me sometime, I'll work it out and email you the modification.
     
  6. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    Hi song, have you got news for the damage armor table?
     
  7. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    Sorry for the slow respond. I've just checked, everything seems to be in good order. Is it working the other way round for you consistently?
     
  8. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,074
    Hi Song,

    I'm just thinking ahead if Unity ever disables the legacy animation. Is it a lot of work to convert the old version of this kit to Mechanim? I know you updated it at some point. Do you recall if it was a lot of work? Was it just changing a few things in UnitTBAnimation or was it more involved?
     
  9. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    I don't think it's a lot of work. In term of the code, it's just one script file that is less than 100 lines. You can download the latest TBTK and see for yourself. It's all in UnitAnimation.cs. The thing is, scripting is only half of the work. The other half is actually setting up the AnimationController (The state machine, the control parameter, etc).
     
  10. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,074
    Cool ... I'll take a look at the newest version. I don't know anything about Mechanim so will have to learn it. Glad it won't be a massive effort to adjust animations from a scripting side. I have no qualms re-assigning animations to the units, obviously.
     
  11. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    A new update (v2.0.1) has just gone live on AssetStore!

    Stuff Added:
    • support for hybrid unit (range and melee attack)
    • support for hit/miss/damage-type for unit-abilities
     
  12. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,074
    What do you mean by hit / miss / damage type abilities?
     
  13. huxley

    huxley

    Joined:
    Apr 27, 2009
    Posts:
    329
    Thanks for this update on the set. Amazing that there are still improvements being made on a kit that was originally realeased over 2 years prior.

    I have downloaded the version update (v2.0.1) fresh install on Unity 5.1.3f1 and I no longer am getting the cover system icon display when units next to wall/obstacle. Has this been removed? Or is it just bug on my system?
     
  14. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    @Rajmahal, means unit abilities now have option to be subjected to hit chance. Also the damage inflicted can be given a type so that it multiplier damage table is considered.

    @huxley, you are right. I guess I might have break it when doing some internal restructuring. I'll find out what causes it and upload a fix soon. Thanks for letting me know.
     
  15. huxley

    huxley

    Joined:
    Apr 27, 2009
    Posts:
    329
    Sorry if this has been answered before. But when editing the grid assignment with the GridManager.cs component, is there a way to 'reset' a grid space back to it's default state (not complete reset)?

    As I lay out the map, I sometimes misplace obstacles, or need to change spawn points. Currently, assigning a Default tile after placing another tile does not reset to Default.
     
  16. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    Are you aware that you can right-click on the tile to remove corresponding item selected in the GridManager? For instance, when editing tiles' obstacle, you left-click to place an obstacle, right click to remove it.

    So I imagine it would be pretty easy to undo whatever mistake you have made there and then.
     
  17. DeeCeptor

    DeeCeptor

    Joined:
    Aug 4, 2013
    Posts:
    23
    Hi. I'm currently creating a 2D hex based turn-based strategy game in the styles of Fire Emblem or Final Fantasy Tactics.

    The AI in my game needs to be capable of deciding what move will inflict the most damage to enemies, while sticking closely to its other units so their forces don't get strung out and picked off one at a time. How does your AI evaluate priorities and threat levels of certain spaces?

    Could I customize it to use a custom graph structure that would encode the threat levels of being in certain tiles? Ex: Moving next to a swarm of enemies is bad, moving next to a single enemy when next to lots of allies is good.

    Thanks
     
  18. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    The AI in TBTK are pretty basic if I'm honest. The unit will just randomly select a target and attack, while giving stuff like fog-of-war and cover system some consideration. It doesn't do any advance tactical analysis.

    You can certainly modify the existing code to implement your own algorithm. The full source code is included in the package. The AI code itself is separated from the core framework so you can easily replace that.

    Hope this helps.
     
  19. huxley

    huxley

    Joined:
    Apr 27, 2009
    Posts:
    329
    Thanks Song, I can edit the grid manager fine when I use the right mouse button. Thanks for pointing me to that.

    I have found in my testing useing the TBTK_Campaign_CoverSystem scene, if I die in campaign and return to the scene from the TBTK_Menu_Campaign scene, the UnitDeployment UI never disappears. Even after I have placed all units in the scene and pressed the 'Done' button, the UnitDeployment UI remains.
     
  20. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    Thanks for letting me now, I'll check it out.
     
  21. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    @songtan thanx a lot! I'll check as soon as possible! :)
     
  22. Pedro-Oliveira

    Pedro-Oliveira

    Joined:
    Aug 1, 2013
    Posts:
    25
    @songtan I have downloaded the new version but I can't see new options(abilities hit chance for example) anywhere in the editor. This is an error or I am misunderstanding something?
     
  23. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    The setting for ability (hit-chance and damage type) can be found in UnitAbilityEditor.



    The setting for hybrid unit can be found in UnitEditor. However most of the option will only show up if the hybrid unit flag is set to true. The new option includes melee attack sound and animation.
     
  24. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,074
    Looks cool ... what is SilentChance, SilentAvoidance and SilentDuration?
     
  25. Pedro-Oliveira

    Pedro-Oliveira

    Joined:
    Aug 1, 2013
    Posts:
    25
    @songtan Well I guess is an error then, because I even imported it to a new project to avoid incompatibility with my script changes but those options simply won't appear. What do you think?
     
  26. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    @Rajmahal, it works like stun but with silence a unit cannot cast any ability. Got the term from DnD.

    @Pedro Oliveira, I'm not sure what went wrong for you. I tried it on my end as well, download the latest version from AssetStore and import it to a new project. Everything works fine.
     
  27. Nine_Tails

    Nine_Tails

    Joined:
    Sep 16, 2013
    Posts:
    31
    You've probably answered this like a billion times, and if you have, I'm really sorry I'm asking again (27 pages is a lot to go through) but does the version 2 support mechanim animations?

    You mentioned on your blog that V3 would support mechanim but I can't find any information about this on the current version up on the app store (V2.0.1). I'd like to make use of your kit to make an X-Com style clone, so this is kinda important to me that I can use animations with your kit.
     
  28. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    First allow me to clafity this. If I have mentioned anything about version3 for TBTK on my blog, then I might have mistype it somehow. Like you said, the framework is currently in v2.0.1 on AssetStore.

    Now to answer your question, yes support for mecanim has been added since the first release of v2.
     
  29. Nine_Tails

    Nine_Tails

    Joined:
    Sep 16, 2013
    Posts:
    31
    Thank you so much for the reply.

    Have you any plans to release any tutorial videos or things like that?
     
  30. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    Not in the near future I'm afraid. But there two old videos for older version that you can refer to.



    The current version is more or less working on a same principal like what it's shown in the video. But the workflow are generally better and easier.
     
  31. huxley

    huxley

    Joined:
    Apr 27, 2009
    Posts:
    329
    I have become quite familiar with the kit and the component functions, but in my testing I found some players were confused with the rules and action points utilization for turns. Maybe it is because of my lack of knowledge of turn-based games, but I also was not sure. I am using the cover system scene provided as an example and these are the questions I received.

    Why are units limited to two movement phases per turn, even if that unit has more action points available?

    Why sometimes are perk abilities disabled after an attack action, even if that unit has enough action points needed for ability?

    Why can't a unit move after it attacks, even if it has remaining action points?

    Is there a reason that the faction ability action points are separate from the unit action points?

    What do the numbers on the units next to the health bar indicate?

    What conditions result in the unit being 'greyed' out, effectively displaying that the unit has completed its turn?

    What conditions must be met to cause the automatic end turn without pressing the 'end turn' button, allowing the AI to make it's turn?

    I apologise if these questions are rudimentary due to my lack of understanding of basic turn-based rules. I'm trying to determine what additional info I can display on screen to give the player a complete understanding of the game mechanics.
     
  32. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    First of all, I should say that there's never a standard mechanic to turn-based game. Some use action point, some dont, some use action point as a currency for all action, some use it only as currency for abilities, etc. I try to accommodate all those possibilities in TBTK. That's why it ends up with lots of contrived stuff sometime contradict each other. However there are option to set it to fit some system or another.

    Since you are refering to the cover system scene. I should say that I was trying to create a system which replicate the mechanic in XCom:EnemyUnknown, to an extent. Keep in mind that this is a demo. I didn't set out to make a perfectly cohesive mechanic. The abilities for example, are not uniquely made to fit those mechanic.

    So to answer your question:

    You can have as many movement phase as you want by setting the unit MovePerTurn and AttackPerTurn value. In the cover system scene, The AP (action point) in this case are just uses as the currency to cast ability. You can set it to be used for movement and attack.

    Again this is up for customisation. You can check EnableActionAfterAttack on GameControl to allow unit to cast ability after attacking.

    Same as above.

    This is pretty much a design decision. It's either the unit have individual ap pool or they shared one. I think the former is better in allowing more tactical depth.

    It's just the faction of the unit.

    It depends on various game setting. like if EnableActionAfterAttack is checked. If yes, how many move/attack can the unit make. Is the move and attack using AP? If yes, how much is left. and so on. Basically, it's greyed out when the the unit can make any move anymore.

    When all unit is 'greyed out'.

    I hope this answer your question.
     
  33. huxley

    huxley

    Joined:
    Apr 27, 2009
    Posts:
    329
    Yes, I understand now. Thank you for pointing out all the methods in the various scripts, it really helped to find access to all the turn stats.

    How could I best access the unit.moveRemain variable of the currently selected unit during my turn?
     
  34. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    GameControl keeps a reference of the current selected unit (for player only). So if the any player has a unit selected, this will do: GameControl.selectedUnit.moveRemain
     
  35. Tom_Timothy

    Tom_Timothy

    Joined:
    Nov 21, 2013
    Posts:
    85
    Sorry 27 pages is a lot to read few questions.

    1.) How Large of grids can you do now in this kit?
    2.) Does your system support multi level grid?
    3.) Does your system have a built in system for changing equipment n units?
     
  36. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    No worries. :)

    1. Depends. There's no hard cap to the grid size. If you are not looking to do any elevation, 100x100 is the largest I've ever tried. But I'm sure with some optimization you can certainly go higher. If you are looking to do elevated terrain however, you are limited to somewhere around 40x40.

    2. No

    3. Unfortunately that's a no too.
     
  37. huxley

    huxley

    Joined:
    Apr 27, 2009
    Posts:
    329
    GameControl.selectedUnit is working great. Now I'd like to convert each units overlay to display in world space (like your old style in the TDTK) rather then to screen space in unitOverlayList. Can you think of an easier way to do this than creating a modification of UIOverlay.cs?

    Looks like I can just by calling unitOverlayList.Init(); then iterate through that array with unitOverlayList.unit?
     
  38. Tom_Timothy

    Tom_Timothy

    Joined:
    Nov 21, 2013
    Posts:
    85
    Confused whats the difference between elevated terrain and a multi level grid? for instance can I have a house with people going two the second story of it?
     
  39. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    I'm not sure if there's a relatively simple way to do this. No matter how you approach this, you will need an entirely different implementation than the existing one. Imo, it would be easier if you just ditch the current approach and add your own. You can refer to the current UIOverlay.cs script for things like how to get all unit in game and how to get the HP value of a specific unit. But that's the extent of the thing you can salvage from there.


    By elevated terrain I meant terrain that has got varying height, a hill or slope for instance. It certainly doesnt support a multi-level grid.
     
  40. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,074
    Hi Song Tan, what are your thoughts on implementing an in-game save feature? I'm not asking you do it but just wanted your thoughts on how I could implement it via playerprefs. I'm thinking I would load the level normally and then to through all tiles and add a unit or collectable to it as per the saved game data. Then add stuff like abilities in play to each unit, adjust the units stat points for damage and AP use and then set the turn to the appropriate round? Can you think of any other way to do this? I'm thinking of having it auto-save at the end of each turn.
     
  41. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    That's pretty much how I would approach it. The grid is static for the most part so you don't need to save that. But you will need to get all the units and collectibles in the scene and save them. First by what unit/collectible are they and then their corresponding stats/status. If you are using prefab for the units, and If the stats is not altered in runtime, then there's no need to save them (you will be instantiate from prefab anyway). So if this is the case you only need to save grid-position, HP, AP, abilities usage and cooldown as well as any buff/debuff they have on them.

    Depends on how your game works. I might go as far as just load the default scene and modify it from there based on the saved data. By removing the unit not in the saved data and modify the unit remain with their corresponding saved data. This way you dont need to fiddle with the initial logic setup like setting up the factions in FactionManager.

    Hope this help.
     
  42. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    @songtan Hi songtan! I
    I really appreciated you updating TBTK.
    I have another question for you.
    How do I increase the maximum number of skills that a unit can have?
    Because now I can not give more than 5.
    Thank you
     
  43. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    There's two things you need to modify as far as I remember.
    • First in UnitEditorWindow.cs, line433. Just change the limit of 5 to whatever you fancy.
    • Next is the interface, in UIAbilityButtonUnit.cs, line34, change the item limit to match the one in UnitEditorWindow.
    The reason to why it's limited in the first place is the UI looks optimum at 5 ability buttons. Maybe I'll just remove the limit in the next update.
     
  44. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    Thanks, it worked fine!
     
  45. Smazzolus

    Smazzolus

    Joined:
    Sep 21, 2014
    Posts:
    32
    Hi songtang! I have another question.
    I've noticed that in the unit ability editor fields "ap min" and "ap max" do not work well.
    It seems that the editor consider only the field "ap min".
     
  46. mahdijj

    mahdijj

    Joined:
    Sep 24, 2015
    Posts:
    31
    Hi
    I purchased tdtk
    It is hard for me to making a complete app for android or iOS with tdtk or tbtk kit
    I can hire you for creating an app with tdtk or tbtk kit,how much you get for making an complete app ,estimatly?i can provide graphic assets
     
    Last edited: Oct 5, 2015
  47. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    @Smazzolus, I checked the code. Seems to be in order. Can you elaborate about the problem?

    @mahdijj, It depends on the scale of the app. Mostly how much time it will take. If you are interest, email me about the detail. Then we will see where we can go from there.
     
  48. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,074
    Hi Song Tan,

    In my old version, the Tile.cs script has an Awake and Start functions as virtual. I'm running into some bugs and I'm trying to figure out why these methods are set as virtual. Do you recall why?

    Code (CSharp):
    1. public virtual void Awake(){
    2.         thisT=transform;
    3.  
    4. }
     
  49. mahdijj

    mahdijj

    Joined:
    Sep 24, 2015
    Posts:
    31
    i sent you email
     
  50. songtan

    songtan

    Joined:
    Apr 9, 2011
    Posts:
    2,624
    @Rajmahal, unfortunately I cant remember. Unless the tile class are derived from other class, it must have been a mistake on my part.

    @mahdijj, responded!
     
unityunity