Hime-Works / Requests

Bug reports and requests that may require longer discussions and is not suitable to leave on the blog
http://himeworks.com/
GNU General Public License v2.0
7 stars 9 forks source link

Building an Active-Time Battle System Part 1 #77

Open HimeWorks opened 10 years ago

HimeWorks commented 10 years ago

As far as battle systems go, they can be quite complex to implement, both in terms of the actual logic, as well as compatibility with other scripts.

At the end of this discussion, we will implement an active time battle (ATB) system (albeit one that may not look very fancy).

The system will be developed one step at a time, starting with some realistic assumptions to form a working prototype, and then relaxing those assumptions and seeing whether the the assumptions made before were ones that could be made.

Ideally, we will have a nice battle system in the end, but it's very possible that a few assumptions were in fact wrong and should have been tackled head-on from the very start. But well, that's how learning works.

At the end of each post, there will be an exercise, which is basically you going and building the system. I will put together a solution of my own as well and post it up for the purpose of comparing and contrasting. Naturally, there is nothing to gain from this if you don't actually attempt the exercise yourself.

Contents

Part 1 - this post

Part 1

The default battle system is a very simple turn based system. The entire flow of logic can be captured as follows

Battle Start
  Command Input
  Turn Start
     Action Start
     Action End
  Turn End
Battle End

The command input phase is where you enter the commands for all "movable" battlers for the current turn. The turn phase is where all battlers execute their actions based on the battler speed as well as the action speed.

Turn 0 is when the battle begins, and turn 1 begins at the start of the first turn phase.

In order to move to an ATB system, we need to change the logic slightly. For now, we will assume the following:

These assumptions lead to a couple nice facts. Let us suppose we have two battlers A and B, and we assume that the system has arbitrarily decided that A will be the first to choose an action.

The battle flow for such a simplified ATB system looks like this

Battle Start
   Turn Start
      Command Input
      Action Start
      Action End
   Turn End
Battle End

Note that it doesn't look that much different from the default battle system, and indeed, if we are under the assumption that all battlers have equal speeds and equal action speeds, then everyone will take their turn one at a time in some arbitrary order, and then when everyone takes their turn, the turn ends and a new turn begins.

Exercise

Following the assumptions above, modify the battle system so that whenever you enter a command, an action is performed, and once all battlers have performed an action, run any turn-end logic, and start a new turn.

Keep in mind compatibility. You should be able to plug your script under battle systems like yanfly's Ace Battle Engine or yami's Symphony engine and it should work. After all, you're just changing the battle flow.

To my knowledge, you will only need to make changes to Scene_Battle and BattleManager Unfortunately, you will likely have to overwrite some methods.

Reference

The battle systems mentioned above

Roguedeus commented 10 years ago

This is one heck of a complex part of the game to jump into tutorial/education. :)

Though I would normally be all for it, I just managed to complete the first 15 of a playable prototype, with 99% of all text externalized, and most enemy details externalized. Class, Actor, Item(s), etc... are a bit more complex, but Bubble's - Notes from .txt Files script is making it possible.

I have pulled out every ATB system I've tried to use so far, as they are all clunky or have serious compatibility issues. Which I understand is why you are stressing that aspect. :)

I was using Yanfly's alternative, but it was way to unbalanced. It put all the power into the players hands and made most battles, that where not heavily weighted boss battles, into either a waste of time or super hard, and rarely in between.

As of now I am using a vanilla battle system, with Yanfly's Combat Log, and his Battle Command, confirm window, to stop those annoying accidental turn passage inherent to his battle interface.

I have found that given the current limitations to the way that AGI and SPEED work, most ATB systems rarely function as expected... And the lack of screen space to factor in a timing bar for each battler, not to mention the headache it would be to make one, while keeping it compatible with Yanfly's party graphics changes and Enemy Health Bars, adds even more difficulty.

I don't mean to poop on the parade but we are in for some difficult times, with this particular mechanic. If the intent is to educate, I might suggest something a little less riddled with complexity.

Also, I am really trying to focus on content creation for my project right now, and anything not directly applicable to that is on the back burner for me, time wise. If you aren't interested in getting the Conditional States working, I am going to do what I can to implement it purely via script calls, and post what I manage to hack together. I might also see what I can do figuring out note parsing.

Of course, I am only speaking for myself. I know I'm not the only one, other than you, here. :)

Roguedeus commented 10 years ago

Don't misunderstand me. I am not refusing to take part. I will take part. I need to learn anything I can get a hold of right now. I just don't have any other reason too at the moment. I have a ton of busy work for this project I have to tackle every day, on top of the new creative work like the Blink script I made the other day... And at the end of the day, if feels like I have no time for anything. :p

HimeWorks commented 10 years ago

This is mostly to serve as a development log, as most scripts I write tend to be 15-minute kind of things. Since I've never written battle systems before this might be useful to keep around.

Roguedeus commented 10 years ago

I'll help as much as I can. :)