Welcome back.
Now in the last video, we just did a whole bunch of work for our electrocutes stun ability.
And we noticed at the very end that if we right click and hold and release, things look fine on the
client.
But if we right click and release right away, there's an issue.
We see that we don't actually stop.
Shocking.
Now nothing else is happening.
Our mana isn't draining, we just never actually remove that gameplay.
Cue is what it appears.
So if we go into electrocute into the event graph, let's see what happens if we release.
And it's only when we're releasing right away.
So it's when our time held is less than minimum spell time.
And we have this delay.
Now the delay happens before clear timer and end ability happens.
And we're ending the ability.
It appears a little too early, and we can easily fix this by making sure that we end the ability only
on the server in this case.
So in the true case we can check for authority.
We can say has authority, and only if we have authority we'll do a delay and clear timer and end ability.
And this will fix the issue in a sense that we can right click and release fast.
So that works.
But now we can't see our mouse cursor.
So there are a few things we have to handle and those things are in prepare to end ability.
These are those superficial things where we're showing the mouse cursor no longer setting our shock
loop variable, setting our in shock loop to false, setting the movement mode back, removing gameplay
cues, things like that, those we're doing here.
So we're going to do that in the false case.
And I don't really like the crisscrossing wires, so we can just really quickly fix that.
And that way it's clear what's going on.
And with that.
We can test things out.
We'll test a short press.
And things appear to work.
And we're still able to shock the enemy with a short press.
Okay, so that's looking good.
And while we're at it.
While we're checking authority.
There's another thing we shouldn't do unless we have authority and that's apply damage.
And we're doing that in a couple places.
One is in clear time or an end ability where we're adding damage, and it looks like if we check in,
prepare to end ability, we're doing that here.
And we should only do that if we're on the server, so we can have an authority check before we apply
the damage effect.
So we'll check has authority.
And if we do have authority, we'll apply the damage effect.
If we don't, we'll bypass the damage effect.
So we'll take the false and we'll reroute it around and we'll continue and we'll do the same thing before
applying damage here.
We'll check has authority first, and only if we have authority should we apply the damage effect.
And we should still cause damage because damage is done on the server.
It's a predictive action.
And it appears to work.
Excellent.
Okay, so that polishes electrocute a little bit, but when stunned, I'd like to have a Stun Niagara
system, just like we have the Fire Niagara system when burned.
If we burn an enemy.
And it appears that we got a exception here.
And on sphere overlap for the projectile.
Where the source ability system component here is null, and it looks like that's going to be the case
on clients, isn't it?
So let's do a null check here.
We'll say if and we're going to check if that source ability system component is null.
And we'll just return if that's the case.
So if equals null pointer return.
Now this brings up an important point though.
This projectile should be replicated.
Its movement should also be replicated.
So we should go up to where we're setting be replicates to true.
And we should also set replicate movement.
Now, if we try to set it here, we see that it's inaccessible.
And if we try to call, set, replicate movement and set that to true.
Well, we'll also see that this is not something that's resolved at compile time.
And this is a virtual function.
So we can set that and begin play.
But we could also just check it in the blueprint because it is exposed to the details panel.
So with that.
We can go ahead and just open up Firebolt and check for replicate.
And we can check replicate movement.
Now if we do that.
Then on the client, we should be able to launch Firebolts.
We should still get.
Then replicate it.
As far as their movement goes, we're still causing damage.
We're still burning.
Everything's looking good.
Okay, so now the thing we want to add is particle system effects for whenever.
Stunned.
So we can do this just like we did our burn component.
In fact, this is going to be quite easy.
I'm going to close all tabs except for aura character base.
And here in or a character base, I'm going to take a look at where we added a component.
For burn, we have a burn debuff component.
It's a you debuff Niagara component.
I'm going to add one for stun now and call this Stun Debuff component.
And if I go into the constructor I can construct one of these.
I'm just going to copy the three lines for Burn Debuff component and paste them and change this to Stun
Debuff Component and change its name.
Change that.
We're setting attachment for it to the root component, and we're going to change its debuff tag as
well to debuff underscore stun.
And with that everything should work because in the debuff component, if we go to Debuff Debuff Niagara
component, we see that we're registering a gameplay tag event for its debuff tag that we have set for
it.
Now, we notice earlier that we weren't actually removing this at the appropriate time and or a character
base.
If we search for multicast handle death down here at the bottom, we're taking a burn debuff component
and calling deactivate on it.
And that was because our debuff Niagara component did not seem to be able to deactivate itself.
Now, part of that is because of one important detail when it comes to.
Get on a registered delegate.
This is on the combat interface.
If we go to the combat interface and Interaction combat interface, the age file, then we'll see that
we have two delegates on ASC registered and on death signature.
And we have getters for those.
And on death signature returns a reference to the actual delegate.
But on ASC registered the getter for that down here does not return a reference to it.
So we can change that to return a reference.
And if we change it here, we must change it in or a character base.
So we can change it here.
And we also need to change it in the cpp file right here.
And that way it will be sure to get that actual delegate.
Now in addition, we can go to multicast Handle death, and still deactivate the stun debuff component
just to be sure.
And with that, we now have a stun debuff component and we can set the Niagara system for it in the
editor.
So back here in the editor, I'm going to go into my character folder into enemy base.
And here I can select my stun debuff component and set its Niagara system.
Now if I search for stun I have NS stars.
And if I go to that it's in the effects stun folder.
And here's what it looks like.
We're going to put these above our characters heads, and I think that's going to look pretty good for
stun.
And I'll stick it right about this high by default.
And for the stun debuff component, we can check auto activate if we want to see it and uncheck it.
If we don't.
And we can just make sure that all of our enemies have it at the correct height.
So I'm going to go to character and I'll start with the demon.
We'll go to BP Demon Ranger.
And take my stun debuff component and check auto activate.
It's a little low, and what I'd like to do is go to the enemy base and move it up a little.
Hit compile.
And check it out here.
It's a little low still, so I'm going to move it up a little more.
And that's going to work.
And since I moved it on enemy base, then it works on the other demon as well.
Looks like this one has auto activate for burn.
So I'm going to uncheck that and take my stun and check auto Activate and see what it looks like there.
Now.
We need to keep in mind, too, that this isn't what the enemies look like when they're in the stunned
pose.
In fact, for demons, we're going to want it a little lower.
So I'm going to uncheck auto activate for both of them and close those.
We'll go back and tweak them more if we need to.
But let's go to the Google.
And for the ghoul, I'm going to take the stun debuff check auto activate.
And for this I'm going to need to move it forward a bit.
And we'll put it up about there.
Next we can go to the goblins.
Go to Goblin slingshot.
By the way, I'm going to uncheck auto activate on the Google.
And for Goblin Slingshot I'll take the stun check auto activate, and I think the goblins have it at
a good height.
So I'm going to uncheck that.
And I think we're fine on the goblins, even the shaman.
But we'll check the shaman as well.
Take that stun debuff component.
Check.
Auto activate.
Yeah, I think that's fine.
So.
Now we have those set.
We can also set it for.
Aura.
So we can go to blueprints.
Character.
Aura.
Open or a character.
Select stun debuff component.
And for aura, we'll need to move it up a bit.
And we'll check auto activate to see.
Looks like we also need to set it to stars.
And we see the particles.
Perfect.
Now that those are set, we can save all.
And we can stun some things.
So we'll try getting stunned on the client.
Now we are stunned, but we're not seeing those particles.
And on the server, if we get stunned.
We do see the particles, and we'll see if aura loses them when no longer stunned.
And we do.
So we just need the client to show those particles.
And that makes sense, right?
Because we're not getting that debuff tag on the client.
So because we have on rep stunned in aura character, we can handle the debuff component for aura separately.
So we're going to go into aura character.
In on rep, stunned.
And we know whether or not we're stunned.
So what we can do is we can activate or deactivate based on is stunned.
So if is stunned, we're going to take our stun debuff component and call activate.
And if we're not stunned we're going to take stun debuff component and call deactivate.
And with that.
We should get those particles on aura as well on the client.
So one last little check.
We'll test this out.
So on the client, we're going to get stunned.
There's our particles.
And they go away.
Perfect.
Now, this raises an important point.
If we have this problem with the stun tag only being applied on the server and only getting those particles
on the server for stun, the same goes for burn.
So we are going to want to know if we're burned as well.
So even though we don't need to know if we're burned in the animation blueprint, we could use a replicated
B is burned just to activate and deactivate the burn debuff component for our client.
So the last thing I'd like to do is just add a replicated B is burned just like B is stunned.
We can add it to or a character base.
We could just add it to or a character as we only have a need for it in or a character right now, but
I'm just going to add it to or a character base anyway.
So we'll have a B is burned and an on rep burned.
So in addition to on rep stunned, we'll have on rep burned.
It'll be virtual.
We'll make it empty in over a character base, and we'll override it in or a character.
So just like on rep.
Stunned.
We have virtual void on rep burned.
Generate the definition and we'll just check if burned.
So if be burned or is burned.
Then we'll take the burn debuff component and activate.
And we'll have an else.
We'll take the burn debuff component and deactivate, and we'll test this when aura gets burned in the
future.
But for now, we know this will work, and we do need to add this to Aura Character Base and get lifetime
replicated props.
So we'll add do rep lifetime here for B is burned.
So that'll take care of that issue.
And with that that's going to wrap up this video.
So now we have the stun mechanic.
And it looks pretty good.
So now that we're able to stun enemies and enemies are able to stun aura, this is pretty cool.
We now have a new type of debuff and we're now ready to move on, making more abilities for our spell
tree.
Excellent job and I'll see you soon.