DevLog 55: Adding new skills to our MMO game in UE

DevLog 55: Adding new skills to our MMO game in UE

In the previous two posts, I created the action bar and enabled drag and drop on it:

Now I will start to actually create a skill implementation for the game, I will begin with two basic skills for:

  • fireball: after channeling, hurl a travelling fireball at a target
  • basic heal: after channeling, instantly heal a target for a certain amount

There were multiple things for me to consider and this only caters for partial implementation:

  • request to begin casting skill
  • initiate channeling
  • receive response to stop channeling skill
  • begin skill animation and effects

As usual, the backend server that’s used can be found in GitHub here.

Integrating skills – YT overview

Creating a new Skill Base object

I will create skills as objects in the game, such that they contain all the information you need to start activating the skill.

Skill Base object definition

Other skill objects will have this Base Skill as the parent class, so it should contain all the foundation requirements for a skill.

All or most of the skills will require the following variables:

  • Skill definition, including name, description etc
  • Activating Actor: the actor which is activating the skill, whether its a player or mob.
  • Target Actor: Skills will not always require a target actor, however most will.
  • Icon: Icon is used to represent the skill in the action bar

This list may grow with time, but its a starting point for now. Also the Skill structure encapsulates most core information I need.

For now, its definition is:

Skill structure definition

Skill Activate function

This function is actually mainly working as an Interface. Also, not all skills will require me to Start Attack Cast Animations.

I will likely create several additional base classes for skills, which will define their own cast animation definitions. For now however, as I only introduced 2 basic skills, this is sufficient.

For reference, this StartAttackCastAnims function simply switches a Boolean in the player blueprint which will be watched in the animation blueprint.

Start attack cast animations

Fireball definition

The fireball definition is relatively simple, it’s catered for processing on the client side.

Fireball skill definition

For reference, the art and animations are used from this asset pack: Fantasy RPG VFX Pack in Visual Effects – UE Marketplace (unrealengine.com)

Asset pack used for fireball

You should be able to use other packs as you like.

You can see from the blueprint above, I spawn a particle actor relative to my casting actor with a transform offset. In future, I would make it relative to specific bones (from the hand).

Here the particle actor is essentially a mesh with a particle system and projectile movement.

Particle class

The look and feel you can customize as per your requirements.

I disabled the collisions on this actor because I will want this fireball to just go directly through to the main actor – even past trees etc. This will be by design.

Check target reached part1
Check target reached part2

The Fireball will have homing projectile movement. I will want to check whether I’ve reached the target and I will just do that by checking whether the distance between this projectile and target is within a certain threshold.

When it is, I will destroy the fireball actor and spawn the expected explosion.

I also have the function to ‘Lock on to’ target:

Projectile movement: lock on to target

Heal skill

The heal skill follows similar convention to the Fireball, however its a little different.

Heal skill activate BP

The heal skill will not create a projectile which will travel towards a target. It’s going to appear relative to the target actor, specifically from the bottom.

I created a new custom event on my actor base class:

Spawn child actor from base actor class
How I got the transform relative to the bottom of the character.

To be honest, I’d like to add fade effect to these skills, rather than completely disappear – but there’d be a bit extra steps to do that so will cover it later.

Finding Skill object by skill ID/Name

Previously, I did lookup of skill icon based on skill ID/name. I’ve refactored to simply get the skill object through this means. This means we’d create a simple structure to represent the skill and create the Data Table to find the skill.

SkillMap structure:

Skill Map structure

Skill Table:

Skill data table

This means that I can use the generic ‘Skill’ to reference my core objects and use the ‘Activate’ function similar to a template while pointing to the correct instances of the skills.

Activating the skill

We covered these steps from the creation of the action bar.

Action bar that we currently have

Each action bar is associated to an input action

Sending Skill request to server
Send skill request continued

So as we can see, we request the server to activate the skill based on the skill name. The castor ID is implicit (through self), though later we can add that explicitly, which will help when we have support for friendly units. We provide the target which is the selected target from the Actions Component.

The Java backend server then does the following:

  • Sends push to start actor channeling
  • Creates async workers to wait channel cast time
  • When cast time completed, send request to stop channeling and sends another request to initiate skill
  • part of initiate skill, it will process to activate effects, such as damage and heal

So our Unreal Engine client needs to process these responses

Processing server responses

From our server we can receive a few new commands:

Receiving new commands from server

Here’s how I currently process them.

Processing initiate and stop channeling and starting skill

In each case, I want to first find the relevant actor based on actor ID. This returns me the object representing that actor, in my current case its always the player but it can be proxies or mobs in future.

For starting / stopping channeling, I’ve simply introduced a new Boolean in my character blueprint, ‘isChanneling’. This will be used in animation blueprint and I will show how that’s used soon.

To initiate skill, we already saw the ‘Activate’ functionality from the Fireball and Heal and this is how we can map it.

Handle initiate skill

For reference, this is how I populate the Skill Map using the Data Table.

Populating skill map from data table

Animation BP for channeling

I wasn’t sure where I wanted to put the animations for channeling and activating the skill. I may still potentially put it into the skill Object to give more control over the options and variety.

This means there isn’t 1 best way for all projects and it will likely depend on your requirements.

So for now, I specify the channeling and cast animations in my animation blueprint.

Find your animation BP

First, find your animation BP, you can do this from your character BP by locating the anim class. You can also just confirm that you’re using an animation blueprint in the first place.

In the animation blueprint, I will add two new states for:

  • Channeling
  • Start Cast Attack Animations
New states in our animation blueprint

To enter the channeling state, simply need ‘is Channeling’ to be true. And to exit, it has to go to false.

Enter the channeling state

To start the cast attack animations, similarly, ‘start cast attack’ needs to be true.

enter cast attack animation

The state will exit when the animation is basically complete.

Exiting cast attack animation

Inside the channeling state, simply play the animation sequence for channeling.

Play animation sequence for channeling

And likewise for cast attack animation, we play the animation:

Play combat cast animation

Animation notify

For the cast attack animation, I added a notify to reset the animation sequence.

Add new animation notify event

You can open up your animation sequence, right click and click ‘add notify’ and select ‘new notify’.

I called it ‘CastAttackStarted’.

Now if you go back to your Animation Blueprint, you will be able to handle these custom events.

Handle Cast Attack Started custom event

As you can see, I create a new graph where I will handle my custom animation notify events. Here I searched for ‘CastAttackStarted’ animation notify and I will simply reset the ‘Start Cast Attack’ when its called.

Conclusion

I am now able to start displaying the activated skills in my UE client, using the generic skill model.

When I start a fireball, I will create new projectile class and set the homing target for it to chase.

The damage and channeling is processed by server which periodically sends updates to the client.