Turn Based Combat

Discussion pertaining to resources, stories/characters and gameplay ideas in this forum dedicated to games that are just a faint glow.
Forum rules
Do not create a topic offering to produce resources. Click here for the reason.

Please use above resources section of site so everyone can have access to the resources you create.
User avatar
Lucifiend
001 Subscriber
 
Joined: Wed Apr 22, 2009 7:37 am
Location: Layton, UT

Turn Based Combat

Postby Lucifiend » Tue May 31, 2016 12:19 am

So I wanted to try my hand at making a combat system similar to how X-COM works, and in my head I thought it would be similar to developing Combat AI like I had previously. The only problem was, I didn't really think through all the parts that I would need to have thought out to make it work. With combat AI, the state machine is just reacting to observations about the battlefield. I didn't need a whole lot of technical data to observe, listen and pursue. But once I sat down to begin piecing together a turn based combat system, I realized the entire combat system has to be fleshed out before I even made the first custom script. How do you determine how far a actor can move? Well you need movement points or action points or whatever. Where does this action point data come from? Well, it must come from a stat of some sort. How does the stat translate from a stat score into an action point? What modifies action points available? What about terrain modifiers, armor penalties, skill modifiers, spell effects, and on down the rabbit hole you go.

In the end, for my EASY turn based combat system, I had to develop the entire combat system on paper and map out all the interactions. I'm pretty confident I can get the turn based working, I just didn't realize how much pre-planning was going to be involved. I could have made some really basic combat rules and dove in, but I figured this would lead to a patch work system of tangled scripts as I wedged in new features. The reason I bring all this up is I was wondering if there is any interest for me to blog my development on the forums as I go. I did this with the AI and it seemed to get a lot of views. It would have the secondary function of documenting exactly how I performed this considering I seem to have a habit of losing my project files over the years. If there is interest then I will try to add updates on progress and how I achieved it to this thread.

User avatar
SBG
001 Subscriber
 
Joined: Thu Jun 17, 2010 8:37 pm
Location: merca

Re: Turn Based Combat

Postby SBG » Tue May 31, 2016 7:39 am

I just recently implemented a basic version of this exact battle system. You're right, I had to plan out EVERYTHING I did first, which I found out as soon as I started. It was a lot easier than I thought though. Only took a couple of hours to get working. I can go into more depth later, but I will say that I handled AI movement with a time limit rather than a distance limit. So basically action points determine the amount of time an AI moves, and speed determines how far they make it.

User avatar
Lucifiend
001 Subscriber
 
Joined: Wed Apr 22, 2009 7:37 am
Location: Layton, UT

Re: Turn Based Combat

Postby Lucifiend » Tue May 31, 2016 10:50 am

That's a simple solution I hadn't considered. In the past when I've fiddled with this idea, I used the Next Direction to Walk to Location value to step through the AI movement path. I'm sure the way I do it is a little more complicated to implement, but it allows me to do checks on each step of the way to see if they cross through opportunity attacks and such. Plus I can see if they are visible during each step to see if the player can see the enemy AI or not. This way I can make them invisible when the player's characters don't have a line of site on them.

User avatar
SBG
001 Subscriber
 
Joined: Thu Jun 17, 2010 8:37 pm
Location: merca

Re: Turn Based Combat

Postby SBG » Tue May 31, 2016 4:17 pm

Yeah my scripts don't take line of sight into account. Not really sure how to script AI line of sight to be honest. I could see that being a small problem depending on how levels are built. I figured I probably won't need it for how I'm designing my game, so I didn't bother trying. If you(or others) would like, I could upload my project so you could see how I made it work. It's fully functional at a very basic level, but it could definitely use some improvements and additions.

User avatar
Lucifiend
001 Subscriber
 
Joined: Wed Apr 22, 2009 7:37 am
Location: Layton, UT

Re: Turn Based Combat

Postby Lucifiend » Tue May 31, 2016 5:59 pm

I'm always down for seeing how someone else came up with a solution. It never fails that my first attempt to do something is the most convoluted route possible, so I might even find an easier method by seeing how you accomplished something.

I normally use the line collision branch to see if I can draw a direct line from one actor to another location without hitting obstacles.

User avatar
SBG
001 Subscriber
 
Joined: Thu Jun 17, 2010 8:37 pm
Location: merca

Re: Turn Based Combat

Postby SBG » Tue May 31, 2016 6:39 pm

I didn't even know about line collisions... sounds easy!

Here's my project: https://drive.google.com/open?id=0B8XZbffXE3QTRVIwa3dUbWNFY1U

Some things to know going into this project. The TBB system operates through a few different components. Make a good note of the global variables and switches, also the actor variables in the Character template. Inside the Enemy template has the triggers that activate combat mode(Saw Enemy and Mouse Down). Turns are controlled with a series of custom scripts, and a timer on the interface Combat Control(the timer could have well been a custom script itself but I kept it as timer after I got it working). Obviously the LMB Down input trigger has some scripting that controls the system as well, so take a look at that in the Cursor input set.

Other important things to note: there is only enough scripting done to handle 3 AI enemies, and 1 playable character. More enemies can be made available by copying and pasting + value editing the custom AI scripts, and adding info to the interface timer. Unfortunately, the player side needs a lot more work since I mainly concentrated on AI. It's functional though. You can test the game and battle all 3 enemies on the starting map, and they have different fighting attributes. The players battle functionality as it is only allows you to attack, move, or end turn, though more options are there.

Also there is an obsolete bit in the player attack script. Although it still works, it checks for specific weapons instead of the actor variable I created to make it more ambiguous(weapon type) that narrows your weapon down to melee or ranged instead of specific weapons. Just thought I'd let anyone know before they try using a weapon other than a crowbar or pistol. This is also a variable that must be set to either Ranged or Melee for every actor, and if it's Ranged then there is a corresponding actor variable for weapon range, which should be set to Short, Medium or Long.

User avatar
Scaveleon
001 Translator
 
Joined: Thu Aug 09, 2007 4:15 pm
Location: Scandinavia

Re: Turn Based Combat

Postby Scaveleon » Tue May 31, 2016 7:30 pm

Lucifiend wrote:The reason I bring all this up is I was wondering if there is any interest for me to blog my development on the forums as I go. I did this with the AI and it seemed to get a lot of views. It would have the secondary function of documenting exactly how I performed this considering I seem to have a habit of losing my project files over the years. If there is interest then I will try to add updates on progress and how I achieved it to this thread.


I've personally found it rewarding to write about my projects, assuming that I'm still interested in it by the time I go back and read about it. I think you should write for your own sake. If you can imagine your future self still being on this project, then writing about it now can make a difference later.

Also, you cannot trust developers with keeping their games safe (warning, there is a NSFW moment just before this point in the video).

SBG wrote:I just recently implemented a basic version of this exact battle system. You're right, I had to plan out EVERYTHING I did first, which I found out as soon as I started. It was a lot easier than I thought though. Only took a couple of hours to get working. I can go into more depth later, but I will say that I handled AI movement with a time limit rather than a distance limit. So basically action points determine the amount of time an AI moves, and speed determines how far they make it.


This reminds me of how the first Diablo game was made. For many months it was a turn-based game, but a developer managed to change it into real-time within an hour, simply by linking the usage of turns with the passing of time.
MIV wrote:It's definitely not The Epic Game of Loladin as the screenshot said.
Nor is it The Epic Game of Loladin Happy Face.

SoundCloud
Project blog

User avatar
SBG
001 Subscriber
 
Joined: Thu Jun 17, 2010 8:37 pm
Location: merca

Re: Turn Based Combat

Postby SBG » Tue May 31, 2016 8:12 pm

Interesting! I kind of did the opposite. I retrofit this new system into my main project that was already real-time, identical to Avernum, and it has a nice time cycle that I'm currently trying to figure out how I should make it work with the battle system.

User avatar
evs
001 Admirer
 
Joined: Tue May 08, 2012 5:27 pm
Location: Perth, Australia

Re: Turn Based Combat

Postby evs » Wed Jun 01, 2016 11:27 am

i'd probably read it

User avatar
Lucifiend
001 Subscriber
 
Joined: Wed Apr 22, 2009 7:37 am
Location: Layton, UT

Re: Turn Based Combat

Postby Lucifiend » Wed Jun 01, 2016 12:33 pm

Also, you cannot trust developers with keeping their games safe (warning, there is a NSFW moment just before this point in the video).

I'm obviously proof of that, considering I can't find my AI work anywhere. I'm normally pretty reliable about keeping everything, I still have a copy of the Smugglers' Blues game and all the associated graphic files from 2009 on my computer, but after so many computer changes over the years some things fall through the cracks. I've actually used the thread I wrote on AI to remind myself how I had originally accomplished some of the trickier bits.

Next

Return to Resource, Story and Level Design

Who is online

Users browsing this forum: No registered users