CORPG Prototype – #004 New skill system and character behaviour

Square

Time for a new post, now that there is enough new stuff in the project to post about. I will not even start rambling about personal life distractions and get straight the point!

State Of Development

  • First version of something like a game launcher. Not delta-based, but it reduces download times a lot.
  • New skill and effects system allows for faster creation and iteration of skills
    • using structs and tables; Blueprints are now used for specific custom behaviour
    • Event Dispatchers now used to keep track of any skill and effect in the world for statistics and more advanced effects
  • Behaviour of characters adjusted heavily
    • Characters move into range if they are too far away when casting a skill
    • A skill queue executes skills one after another
    • Movement will interrupt the caster, and there are mechanics that allow skills to interrupt players as well as root, stun or knock them down
    • On-Character widget shows health and active effects on a player, cooldowns are shown on the skillbar
  • First set of skills for Elementalist implemented, with visual placeholders from Infinity Blade, provided by Epic Games
  • Updated the project to 4.13 to fix very annoying bugs
    • Some bugs still there, not really fixable right now but only happening in-editor.  I.e. changing defaults of structs destroy scripts and have to be re-added in blueprint editor.
    • No gamebreaking bugs as of right now, though
  • Code/Blueprint refactor and cleanup for many systems

New Skills / Character Behaviour Showcase

The most important additions are the new skills.

This video shows the new Fireball skill as well as new character behaviour. Characters will move into range if they are too far away, not execute the skill if the player has not enough mana and so on. There is also a skill queue that executes a skill if you have pressed it during a cast. Other than the Fireball, there are a few new skills implemented with the new system.

Currently these are the skills for the Elementalist:

  • “Savannah Heat”: Creates a fire field at target’s location for 5 seconds. Every second, enemies get hit for 40 damage. Last hit inflicts Burning for 3 seconds.
  • “Fireball”: Fires a projectile at the enemy that hits for 60 damage upon impact.
  • “Ignite”: Hits target enemy and 2 surrounding enemies for 120 damage and inflicts Burning for 1 second.
  • “Replenish Mana”: For 45 seconds, everytime you cause Burning on a target, you gain 1 energy.
  • “Burn”: Inflicts Burning on target for 6 seconds
  • Of course, there are already other skills such as the Simple Heal. But they are mainly for testing purposes and not relevant to the actual game.

More skills will follow very soon. The main problem is finding proper visuals and animations.

Behind The Scenes

There have been many changes to both code and blueprints. As they are not really interesting, here is a quick summary:

  • Cleaned up event graphs for every gameplay-related class
    • Split graphs into multiple sub-graphs when necessary
  • Cleaned up C++ codebase, revealed most vital functions to blueprints to allow blueprints more control over player behaviour
  • In general, more systems have been moved over to blueprints in addition to C++ if not absolutely critical. So far I have no performance loss at all and Blueprints feel as natural as coding by now
    • These classes are not exclusively blueprints, but instead blueprints based off of a C++ class. This way I can work in both code and Blueprints when necessay
    • Only the new skills system is made almost exclusively with blueprints right now, with the exception of the abstract skill class and character components
  • There was a messy relationship between Characters, Controllers, GameState and GameMode. This was cleaned up to be more in line with Unreal’s standards
    • Also done to prepare for possible future features such as observer mode
Skill / Effect System
Skill table
Skill table

As the last post suggested, I wanted to have skills to be more data driven. I needed a quick and easy way to find and organize skills, so I looked at various solutions and finally thought that a structure-based approach with data tables would make the most sense. For this purpse, there is now a somewhat-simple skill structure that covers most necessary parameters for any given skill.

Together with the data table(left), skills can now be easily created by copying a desired base skill class (see this post), adding the proper name and then filling in the values in the data table. Based on that name, the skill looks for the appropriate data before moving itself to a global skill system that resolves effects and values.

Effects work exactly the same with the exception of having prepared logic such as regular ticks and listeners, but more on that later.

Currently, this is what happens when a player wants to cast a skill:

  • User presses skill button
  • Server checks whether the character can cast that skill, moves to range if too far away, adds to skill queue if the character is already casting, or simply does nothing if anything else is wrong, such as a stun effect or simply not having enough energy
  • If the check is succesful, the character starts the cast animation. Effects that speed up casting are applied here.
  • Upon a succesful cast, the skill object is created and gathers data from the data table. Interrupts will cause a fail animation
  • Skill is passed to the skill system which checks active effects on the caster, such as a damage boost
  • Skill’s mechanic is executed: projectile flies, ground effect is being placed and so on.
  • On each hit, depending on the mechanic, the resolved skill is being passed to the skill system again to account for any active effects on the target, such as a shield or armor boost
  • All adjusted values are applied to the target hit, and depending on the skill mechanic the skill is destroyed

Most effects can be covered by simply adjusting character or skill vaues.
Some effects require a bit more logic, though. An example is the current idea of “Replenish Mana” for the Elementalist:

For 45 seconds, everytime you cause Burning on a target, you gain 1 energy.

Simply having the skill do bookkeeping on the effects caused is a suboptimal solution. Skills should follow the “fire & forget” principle and not have any brain or memory. This would also be hard to implement: What if an effect is triggered after another effect has ended, long after the inflicting skill has been destroyed?

Using Event Dispatchers for more advanced logic

With the help of Event Dispatchers, aka Observer Pattern in Unreal Engine, this is solved pretty easily though. If unfamiliar with the pattern, I recommend to take a look over at gameprogrammingpatterns.com. Explains it much better than I ever could.

Here is the usage for the “Replenish Mana” effect:

  • The GameState creates an event called “GS_EP_CreatedEffect” to get notified about any effect that was created. It does nothing else than to take note of an effect and then broadcast this message to every object in the scene. Because the GameState is replicated to both server & clients, this is especially useful.
Event Dispatcher in GameState
Event Dispatcher in GameState
  • Whenever a skill now creates an effect, it calls this message and lets the GameState now about the effect.
Event call in Skill logic
Event call in skill logic (ugh, optimize that Blueprint!)

 

  • Now, any object can sign up to listen to the GameState’s broadcast and then do logic on the specific effect. For “Replenish Mana”, we check whether or not the effect’s name is “Burning”, and then give the original caster of the effect a point of energy. Note: DecreaseEnergy with negative values is just lazier than implementing IncreaseEnergy.
Event call in effect
Event call in effect

This system not only allows for more advanced effect and skill mechanics, but it is also useful to create statistics about a match. There simply needs to be a class that listens to every damage applied and create neat lists of that. Pretty neat.

What’s Next?

As usual, here is what I will be working on next. Quick and dirty:

  • Finalize all the skill sets for the classes
    • Currently three classes planned: Warrior, Monk and Elementalist
    • Fixed skill sets for easier use that allow for interesting team dynamics
  • Give each skill a proper audiovisual presentation
    • This will be done with both placeholders from the Marketplace as well as handmade animations
    • Theoretically, this is not necessary for the technical prototype. But the combat system simply requires this to be fun, which is also a goal
  • Adjust game mode to be more fun and allow for better team interactions
  • Design and blockout a proper level. The current one looks nice, but it is not suited for actual gameplay

A lot to do, but I am still very motivated. But since this is a project I do in my freetime, I can not really say how long it will take to complete all these.

Comment

One Reply to “CORPG Prototype – #004 New skill system and character behaviour”

Comments are closed.