Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

TurnBased-Toolkit (TBTK)

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

  1. insertcoins2

    insertcoins2

    Joined:
    Jan 24, 2015
    Posts:
    4
    Thank you, I appreciate it.
     
  2. Frogames

    Frogames

    Joined:
    Jun 10, 2005
    Posts:
    199
    Finally, after many prototypes and a lot of design, we started to work on a turn based fantasy strategy game using the TBTK2.

    We hope to release it at the end of the year. I'll post info and screenshots here as often as I can.

     
  3. insertcoins2

    insertcoins2

    Joined:
    Jan 24, 2015
    Posts:
    4
    I'm not sure if this is the best place to report bugs, but here goes. I'm working on creating summoners for my upcoming fantasy TRPG, and found a bug in FactionManager.cs _InsertUnit.

    This line does the opposite of what is intended:

    Code (CSharp):
    1. unit.isAIUnit=factionList[i].isPlayerFaction;
    This will create the unit as an AI unit if the faction is the player faction. The fix is simple:

    Code (CSharp):
    1. unit.isAIUnit=!factionList[i].isPlayerFaction;
    Hopefully this helps others too :)
     
    Last edited: Feb 11, 2015
  4. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    @ChristFrogames, interesting. Is it for mobile or pc?

    @insertcoins2, thanks for pointing that out. :)
     
  5. insertcoins2

    insertcoins2

    Joined:
    Jan 24, 2015
    Posts:
    4
    I'm glad to help. There's another small bug in this part of the code. When you use a SpawnNew ability, the prefab is instantiated and this code is called.
    Code (CSharp):
    1.      
    2. public void SetNewTile(Tile targetTile){
    3. tile.unit=null;
    4. tile=targetTile;
    5.  
    This leads to an error, since tile for the newly instantiated prefab is null. Adding a check to see if tile was null worked for me, and now both SpawnNew and Teleport work.
     
    Last edited: Feb 12, 2015
  6. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    Thanks again for point that out. Very careless of me.
     
  7. Crival

    Crival

    Joined:
    Sep 3, 2014
    Posts:
    21
    Hi!

    Is it easy to place an indicator on a unit that hasn't made a move? It is somewhat hard recalling all the units that hasn't made a move in the game...
     
  8. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    It shouldn't be too hard. I'll try and see if I can do that.
     
  9. Crival

    Crival

    Joined:
    Sep 3, 2014
    Posts:
    21
    Thanks! Much appreciated!
     
  10. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    Hi all, I've just uploaded another update to AssetStore. The new update should fix all the bug reported so far as well as some small tweak/addition requested by user. They included separate unique AI-mode for the ai different AI faction and moved unit indicators. You are welcome. :)

    On another notes, I'll be away starting on monday for 2 weeks. I apologize in advance for being slow in responding to your post or email. Thanks for understanding!
     
  11. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    What exactly is the Ai change?
     
  12. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    Each AI faction can have different AI-mode (passive, trigger, aggressive), instead of sharing one. Also there's now option to have untriggered unit to move around a bit when using trigger AI-mode, otherwise they wont move until they spotted any target.
     
  13. Frogames

    Frogames

    Joined:
    Jun 10, 2005
    Posts:
    199
    @songtan for Mac/PC/Linux. We'll consider a iOS version later.

    @Crival Yes, you can customize unit overlays. I made different looking overlays and I added a move tag and an attack tag to my player units overlays, as well as active effects icons. I even added the effect duration and if your mouse is over an effect icon, a tooltip displays the effect name and description.

     
  14. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    hi Songtan,

    Quick question ... hope it gets to you before you leave. Do you know how I can disable touch / mouse input during an action cam sequence? I'm finding some bugs that occur on iPhone (crashes) when the screen is touched during an action camera zoom in.
     
  15. Crival

    Crival

    Joined:
    Sep 3, 2014
    Posts:
    21
    @songtan : thanks! Imma update the asset and check it out!

    @Frogames : Im aware of that but I'm kinda new to programming and learning programming isn't easy for someone like me who isn't a native speaker of the English language...
     
  16. Crival

    Crival

    Joined:
    Sep 3, 2014
    Posts:
    21
    Just checked the latest update... It seems that the MovedUnitIndicator only works on units that attacked...
     
  17. Crival

    Crival

    Joined:
    Sep 3, 2014
    Posts:
    21
    @songtan : thanks for the awesome work songtan! I manage to pull it of how to allow the MovedUnitIndicator to work on units who only made a move and didn't attack... I appreciated your work very much!
     
  18. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    Sorry for the slow respond. Glad you figure it out.

    Guess you have learnt by now but It's by default intended to show for unit which has depleted all available movement only (all move, attack and ability).
     
  19. Crival

    Crival

    Joined:
    Sep 3, 2014
    Posts:
    21
    @songtan: Yep! I wanted to display the movedunitindicator when the unit doesn't have any options left to do instead of depleting all the available movement... Sadly with the edited code I made it seems that it doesn't allow me to move then make an attack it's either move only or attack only... I'm still trying to figure it out how to fix this problem... XD

    I appreciate your time and effort for being active in your forum despite your busy schedule...
     
  20. Crival

    Crival

    Joined:
    Sep 3, 2014
    Posts:
    21
    Does anyone know how to enable select hostile tile during player's turn? THANKS!
     
  21. Pedro-Oliveira

    Pedro-Oliveira

    Joined:
    Aug 1, 2013
    Posts:
    25
    Songtan, this toolkit seems nice. I'm very interested in it, but i want to take a look in the documentation before buying could you please send it to my e-mail ?
    The address is : pedro_henrique_chaves@hotmail.com
     
  22. Malastal

    Malastal

    Joined:
    Feb 28, 2015
    Posts:
    4
    Hi Songtan,
    Could you please send me the documentation of TBTK? I would like to read it before making the purchase. My email is
    mail@markoalastalo.com
     
  23. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    @Crival, by default the MoveUnitIndicator script calls IsAllActionCompleted() on Unit.cs to check if a unit has complete all move. The function checks the unit all available action including moves, attack. If you just want to restrict it to movement, you may want to create a new function called exclusively by MoveUnitIndicator script. The function could be like this (a simplified version of the default IsAllActionCompleted())
    Code (csharp):
    1.  
    2.     public bool IsAllActionCompleted(){
    3.        if(stunned>0) return true;
    4.        if(moveRemain>0 && AP>=GetMoveAPCost()) return false;
    5.        return true;
    6.      }
    7.  
    Btw, I'm not sure what do you mean by "enable select hostile tile".

    @Pedro and @Malastal, I've send the download link to your email.
     
  24. Crival

    Crival

    Joined:
    Sep 3, 2014
    Posts:
    21
    @songtan : Thanks for the reply but I already figured that out... ATM I'm trying to figure it out on how to stop from proceeding to the next unit after he finished moving because I won't be able to proceed to attack after moving unless I select the unit again that just finished moving but it also prevent the last unit from attacking since it will end the player turn immediately... Removing the TurnControl.NextUnit doesnt help since when its the AI turn it seems after the first unit moves it can no longer proceed to the next unit thus making the game in a stand still...

    I wanted to be able to click on the hostile unit during my turn in order for me to check the stats of the hostile unit with the unit info button I added...
     
  25. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    You can comment out TurnControl.NextUnit(); in FinishAction() in Unit.cs. That should stop the code from selecting the next unit or skip to next faction when a unit's action is completed.

    Well you can click on any tile or any unit anytime you want as it's. The question is what happen when you click on them. The problem now is not that you cant click on them, it's that when you do, there's no code to handle the situation. This is something you will have to code from scratch, starting from _OnTileCursorDown() in GridManager.cs, which is called when a tile has been clicked on.
     
  26. W1ntermute

    W1ntermute

    Joined:
    Aug 24, 2014
    Posts:
    9
    Hi, I have a strange problem: every time when I'm launching scene in Unity "Enable Cover system" flag is setting to "false", and it disables. There is no such problem in TBTK_StandAlone_CoverSystem scene. I have the latest version of TBTK. DId anybody have such problem?
    Also, in UnitEditor, whan I'm changing unit's HP or AP, it returns to default as soon as I leave input field unfocused.
     
  27. Crival

    Crival

    Joined:
    Sep 3, 2014
    Posts:
    21
    @songtan : commenting out TurnControl.NextUnit(); in FinishAction() in Unit.cs doenst help because when it is the AI turn it... The AI wont be able to proceed to the next AI unit thus making the game on a standstill...
     
  28. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    @W1ntermute, Do you have "UseGlobalSetting" enabled? I found that having that enabled reset the setting in GameControl after play. I'm trying to get it fixed. As for the UnitEditor, there's a bug concerning HP and AP field. Please ignore it for now. I'll include the fix in the next update.

    @Crival, are you using the latest version? In the latest version, AI unit doesnt use that line.
     
  29. Pedro-Oliveira

    Pedro-Oliveira

    Joined:
    Aug 1, 2013
    Posts:
    25
    @songtan : You think that would be hard to create in game events? Like calling some sort of external event, for example: a cutscene, when a specific unit dies or when an unit stop in an specific tile etc.
    There is something in the toolkit that help me in those things?
     
  30. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    The toolkit doesnt support anything like that I'm afraid. However if you are comfortable with coding, it shouldnt be too difficult to add something. I can show you how the code logic runs and where to start and it's up to you to do the rest.
     
  31. Crival

    Crival

    Joined:
    Sep 3, 2014
    Posts:
    21
    @songtan : Yes Im using the latest version of TBTK and that's exactly why I can't figure it out since I can't find the connection between the AI and TurnControl.NextUnit(); in FinishAction() in Unit.cs...
     
  32. ConfirmCrit

    ConfirmCrit

    Joined:
    Nov 26, 2013
    Posts:
    7
    Is it possible to use an external grid system like Grids into your tool kit? Main goal is to make strange maps that aren't hex/square based.
     
  33. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    @Crival, well the first line in FinishAction() is if(isAIUnit) return;. So if the unit is an AI unit, the rest of the function wont get executed at all. Hence I dont see why edit anything in the function will affect AI unit at all. As a matter of fact, I've just disable the line TurnControl.NextUnit myself without any problem.

    @ConfirmCrit, it's going to be very tricky to integrate any 3rd party grid if I'm honest. Many of the TBTK feature and mechanic is very much built into the grid (path-finding, faction/unit position and what not). By using a 3rd party grid you will very likely need to rewrite most of the stuff. It's not impossible, but it's going to be a lot of work. Almost as much as rebuilding half of the toolkit from scratch.
     
  34. Pedro-Oliveira

    Pedro-Oliveira

    Joined:
    Aug 1, 2013
    Posts:
    25
    @songtan : Hmm... ok, i think i can do it. I bought the kit today so expect me to bother you a little more in a near future :D
     
  35. ConfirmCrit

    ConfirmCrit

    Joined:
    Nov 26, 2013
    Posts:
    7
    If you don't mind sending the documentation when you can, Confirm4Crit@gmail.com. or PM it, either way is fine, thanks.
     
  36. W1ntermute

    W1ntermute

    Joined:
    Aug 24, 2014
    Posts:
    9
    @songtan : Yes, the reason was in "UseGlobalSettings". Thank you for help!
     
  37. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    @Pedro Oliveira, Thanks! Do bother me. :)

    @ConfirmCrit, sent!

    @W1ntermute, the bug has been fixed.

    I've just uploaded an update to AssetStore. The update fixed all the bug reported to me thus far. Please update your copy!
     
  38. Crival

    Crival

    Joined:
    Sep 3, 2014
    Posts:
    21
    @songtan : thanks! I appreciate your help! It seems that I must have messed up some codes thats why I can't get the move indicator to the way I want it to be...
     
  39. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    Woot, just added support to Unity5!

    If you want a version that works right out of the box for Unity5, there's one now.
     
  40. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Do you recall what changes you had to make for compatibility?
     
  41. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    Basically I just tweak the shader for a bunch of objects so that they look right. In term of code, I've done pretty much nothing. The auto-updater should do the trick.
     
  42. Pinsukka

    Pinsukka

    Joined:
    Feb 17, 2014
    Posts:
    15
    Hey Song, bought the TBTK yesterday and loving it so far, it's fantastic. This is going to save me so much time, thanks!

    I have couple of questions though. I am not very good at programming, been practicing for half year or so, now I would like to create something similar to the Advance Wars series. I don't know if you have ever played that series, but it is a turn-based strategy game that lets you capture cities and factories, earn money every turn and use that money to build more units.

    So what I'm looking for is the script that handles spawning. Is there perhaps a line of code I can use myself to spawn units? There are just so many scripts and so many lines that are just mysteries to me, I would really appreciate it if you pointed me to the right direction.

    Also not quite sure how to make the AI work well with the capture system. Maybe I can just make the nodes that player/AI can capture a target to the AI, similar to how they target player units? Have to look into that in more detail I guess, always difficult to use code others have made when you don't fully understand how everything works.

    Anyways, thanks again, was totally worth the money! I'll leave a review on the asset store at some point.
     
  43. Pinsukka

    Pinsukka

    Joined:
    Feb 17, 2014
    Posts:
    15
    Sorry to bother you so much with my problems, but it seems I'm getting some errors with the toolkit. I wanted to clean everything so I started off by removing perks in the perk editor, but unity started giving me this error, preventing me from even closing the perk window:

    ArgumentOutOfRangeException: Argument is out of range.
    Parameter name: index
    System.Collections.Generic.List`1[TBTK.Perk].get_Item (Int32 index) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/List.cs:633)
    TBTK.PerkEditorWindow.OnGUI () (at Assets/TBTK/Scripts/Editor/PerkEditorWindow.cs:130)
    System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Reflection/MonoMethod.cs:222)

    The same seems to happen with the unity ability editor too, every time I remove something I cannot click inside the window anymore. Why is this happening? By the way, this is completely clean project, haven't touched the scripts or anything at all yet.
     
  44. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    Thanks for your purchase!

    Right, let me start by saying brace yourself, what you are looking to do is not going to be very easy if you are like you said yourself, not very good at programming. The AI with the capture system is going to be particularly challenging I imagine. I hope this doesnt put you off.

    There's a function in FactionManager.cs, InsertUnit() that allow you to add unit to the game in runtime. However that just added the unit to a particular faction, you will still have to create the unit and place it on a tile. You can refer to AbilityManagerUnit.cs. There's an example of how to create a unit instance and add it into the game. Look for function ApplyAbilityEffect(), with the condition SpawnNew.

    You can find all things related to AI in AIManager.cs, particularly in the function Analyse(). The is pretty much the code determine what a particular AI unit would do. It's adequately commented for you to understand what the code is generally doing. You can build from there. But you have need to have the nodes defined on the grid and a capture system to start with. What constitude a node and what defines its capture state and so on. For that I think you will need to look into Tile.cs, see how various state of a certain tile of the grid is defined.

    Regarding the editor error, I'm sorry about that. It only happen when you delete the first item in the list. I'll get it fixed. For the time being, I would suggest try not to do that. If you must, shift the item down to be the second item before you remove them.
     
  45. ZeroPAiN

    ZeroPAiN

    Joined:
    Mar 5, 2015
    Posts:
    2
    From what I can see so far, your script looks impressive. My main goal is to do multiplayer, however your toolkit provides the main framework for me that would take ages to think up, so I'm probably going to buy it anyhoo shortly.

    I'm guessing implementing multiplayer would just have to do something with replacing the AI's turn with prompts for another player.

    Gonna be tough, but you've already fought half of the battle for me!

    *edit* I also totally dig how active you are here! That's a major selling point for me.
     
  46. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
    Thanks for your kind compliment. And Thanks in advance for your purchase!

    I wish I could comment on implementing multi-player component but frankly I'm quite clueless when it comes to that. I can only say good luck. But if you need any help on the existing code, ask away. :)
     
  47. Frogames

    Frogames

    Joined:
    Jun 10, 2005
    Posts:
    199
    Finally found some time to post a screenshot of our upcoming strategy game Farabel.
    We hope to enter the beta phase by next summer. More news to come.

     
  48. josker

    josker

    Joined:
    May 10, 2014
    Posts:
    45
    I have seen you send the documentation out, Could you send me the docs please. john@wargamesemporium.co.uk

    I have been looking at both TBTK and TDTK and not sure which one to go for first.

    Both kits look great.
     
  49. Song_Tan

    Song_Tan

    Joined:
    Apr 9, 2011
    Posts:
    2,960
  50. Pedro-Oliveira

    Pedro-Oliveira

    Joined:
    Aug 1, 2013
    Posts:
    25
    @songtan : I am with a little problem. I want to have some units that need 0 ap to attack but i also want to have others that require more. The thing is, when an unit has 0 ap it can't attack, even when ap attack cost is set to 0.
    There is a way to solve this problem?