Sign in to follow this  

Over-Engineered Battle System?

This topic is 824 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello everyone, I've been looking for some feedback to determine whether or not I'm over-engineering my battle system that deals with a lot of timing.

 

To preface, the combat system is combo-based with "characters" of the "fighter" class being locked into whatever action they have selected for x seconds, depending on the action. E.g., Player Character 1 is told to use a basic attack, locking him into that attack state for 0.5 seconds.

 

Combos are registered when player characters attack successively, giving them points towards using a longer duration, higher damage attacks. The timing for "hits" registering, however, are different between the two play characters e.g. while basic attacks for both characters lock them in for 0.5 seconds, PC1 may have his "hit" registered at 0.3 seconds while PC2 registers it at 0.4. Therefore, higher level attacks must be channeled fully for players to obtain the full damage.

 

The one exception to this is the "guard" function, which can interrupt any other action except itself and locks the player into a guard state for 0.25 or so seconds.

 

TL;DR: Here's a general list of basic functions that I want to accomplish. Functions that I have questions on whether they are necessary to implement will have a (?) at the end:

  • System can recognize when two "hits" occur consecutively vs simultaneously
  • Characters are locked into state for specified amount of time except under unique circumstances
  • System appropriately reduces damage output based on how long player allowed the attack to channel.

Here's the current class architecture:

 

Administrator: Creates synchronized timeline and serves as central hub of battle system. Registers if combos are created and returns values to both target and attacker.

 

Fighter: Sends queries to administrator who places a timestamp on their actions. Waits on returned values from administrator.

 

To illustrate: Player Character 1(Fighter) receives input to perform a basic attack action. PC1 then sends a query to the Administrator, who puts a timestamp on the action and continues searching for other queries. When 0.4 seconds passes, Administrator checks if Enemy1(Fighter) is in a block state, followed by a check to see if the attack followed a previous attack within a certain timeframe. After performing these checks, it returns the appropriate value to both Fighter objects so they can adjust their values (such as health, combo gauge, etc) accordingly. After an additional 0.1 seconds passes (0.5 total, the amount of time a character is locked into a basic attack), it then lets PC1 know that is unlocked and can receive more input.

 

My question is whether or not the administrator class is necessary or am I over-engineering it by creating an intermediary body between the two fighter classes? Could the same results be created by simply having the Fighter classes check each other or am I right in thinking it's important to have something that creates a synchronized timeline to check if combos hit?

 

Thank you very much for you help and feedback. Still very to programming things outside of simple classroom projects.

Edited by DoctorDouche

Share this post


Link to post
Share on other sites

in Caveman 3.0, i just use a counter for each combatant.  Attacks take 20 updates (1.333 seconds), and are resolved at update 5 (0.333 seconds).   this is similar to your attacks which take 0.5 seconds, and are resolved at 0.4 seconds.   

 

sounds like you'd need a "previous attack type" variable, and possibly a "time since last attack" variable as well, for each combatant.

Share this post


Link to post
Share on other sites


My question is whether or not the administrator class is necessary or am I over-engineering it by creating an intermediary body between the two fighter classes? Could the same results be created by simply having the Fighter classes check each other or am I right in thinking it's important to have something that creates a synchronized timeline to check if combos hit?

 

I think it's fine having an external system handling the updates, in fact, it's probably the right way to do it.  Your character classes would put their actions into the admin's queue, and each update the admin would check the actions and do whatever.  Then, when the time comes for the admin to "resolve", it would resolve everything in the right order according to when it received the action, not according to whichever character's Update() function is called 1st.  The Admin class would just query the character classes (punch damage value) and set values after (health, etc.)

 

Another possible issue, imagine PC1 and PC2 both press the punch button in the same update frame.  You'd want both punches occurring at the same time, in fact, possibly even killing each other.  But, if you tried it via character updates, you may update PC1, see he has health >0, and then apply his punch damage on PC2.  Now, PC2 will update, but his health <= 0, so he dies instead of executing his punch at the same itme.

Share this post


Link to post
Share on other sites


Another possible issue, imagine PC1 and PC2 both press the punch button in the same update frame.  You'd want both punches occurring at the same time, in fact, possibly even killing each other.  But, if you tried it via character updates, you may update PC1, see he has health >0, and then apply his punch damage on PC2.  Now, PC2 will update, but his health <= 0, so he dies instead of executing his punch at the same itme.

 

a good point, if you want simultaneous resolution of combat, simply running through the entities list won't cut it. unless perhaps you time stamp input as LSpiro often recommends.  but  even with time stamps, with simultaneous resolution, your taking all input occurring during some brief period of time and processing it all as though it all occurred exactly simultaneously - even if it didn't actually.

Share this post


Link to post
Share on other sites

I've been thinking of doing something similar to this for sword and shield combat in my rpg. It has similar ideas such as blocking and attacks which can be done while moving forwards, retreating or standing still.

 

I am considering using a simple state machine without a manager class but I don't think your idea is really over engineered. 

 

I assume your system is for PvP combat, like in a traditional beat em up game? If it isn't make sure to add sensible delays between AI attacks to allow the player some time to get an attack in. In my game at present the AI attacks aggressively and without mercy so you can't stop blocking to attack or it kills you too quickly. I need to fix that...

Edited by braindigitalis

Share this post


Link to post
Share on other sites

Thank you for the feedback everyone! I truly appreciate it :D

 

I had forgotten to think about edge-cases like if an enemy and ally both have their attacks inputted simultaneously/are reduced to zero. I'd probably have this lean towards the player's favor to reduce frustration.

 

Also, it's actually not really a beat-em up since characters don't really move. I'd like to think of it more as a more rhythm-based approach to the ATB system where you have to juggle the timings of the two player character's attacks to keep the combos going. I mostly came up with it as a means to create a RPG-like battle system without having to make 10,000 different sprites and animations for different spells, items, etc. Just no items, only four different attacks, and three hits per fight.

 

I'll definitely have to tinker with the AI a bit, although I'm not too scared of making them more aggressive since a large portion of the challenge in the game will be finding a way to juggle your attack timings while an enemy constantly threatens to interrupt them. It's going to be a fine line to tread though.

 

Again, thank you all for your feedback! I was really concerned about the over-engineering because I didn't want to realize I created a bad infrastructure after putting a lot of hours into it and then having to recreate it from the ground up.

 

 

Share this post


Link to post
Share on other sites

This topic is 824 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this