Welcome back.
Now, as soon as we've spawned an electric beam, it's time to start thinking about doing damage and
committing our ability cost so we can see that a globe start going down.
We're going to handle that in this video.
And the way that I'd like it to happen is as I'm holding this input down and we see those electric beams,
I want to see the man globe going down steadily, say ten times a second or so.
Now that ten times a second, that could be a parameter.
We can make a float and that float I'm going to add right now it's going to be a variable.
And that variable is going to be called I'm going to call it damage delta time.
And change its type to a float.
And it doesn't need to be a map.
So we have to come over here and change it to a single and damage delta time.
If we compile, I'm going to give it a 0.1.
So every 0.1 seconds will not only apply damage but also commit our ability cost.
So what I'm going to do is drag off of spawn electric beam and use set timer by event.
And we can make a custom event.
And this will be called damage and cost.
And we'll hook it in.
And the time.
Can be damaged.
Delta time.
And it's going to be looping, and we're going to store the return value as a timer handle for damaging
costs.
So we'll call it damage and cost timer.
And that's our timer handle.
When we clear and invalidate it, we'll stop the timer.
So here's the thing.
Each time this event occurs we are going to commit the ability cost, which we can do separately.
We can use commit ability cost.
And as soon as we've committed that we can check.
We can use a boolean and see if we have successfully applied that ability cost.
And if we fail, then we can't meet that ability cost.
We're out of mana and we can use.
Prepare to end ability and end ability.
Now each time, if we're not ending the ability, we're going to apply damage and we'll get to that.
For now, let's see if we can commit this ability.
Cost.
So I'm going to cast.
And look at my mana.
See it going down?
That is looking great.
Now we can also just clear and invalidate that timer as well.
We can take our damage and cost timer and use clear and invalidate timer by handle here.
Just before.
We end the ability.
We could even do that inside prepare to end ability.
But anyway, now that we're committing the cost, what we can also do is we can.
As long as we can pay the cost, we can do damage.
Now, applying damage is going to involve a couple things, right?
We need to apply damage to the mouse hit actor, but also to the additional targets.
So I'm going to add a new function here.
And this will be Apply damage.
And apply damage will first apply damage to the mouse hit actor and then apply damage to the additional
targets.
So how are we going to apply damage to the mouse hit actor?
Well, first we need our ability system component so we can get that from actor info.
So we can use get ability system component from actor info.
And we can make an effect context with it.
So we'll use make effect context and and we can also make an outgoing spec.
So make outgoing spec all of this stuff we've done already.
We can hook up that context and we can get our ability level.
So get ability level.
We can hook up our ability level.
That's going to be converted into a float for the outgoing spec, and we can set our damage gameplay
effect class to damage gameplay effect.
It's actually called damage effect class.
We can hook that in.
Now all we're doing is applying the damage gameplay effect.
We haven't actually set any set by color magnitudes or anything, and I don't want to use our ability
system blueprint library function because it's going to require damage effect params.
And if we use make damage effect params from class defaults, then we would end up setting our debuff
chance.
And for each of these little damages, I'll call them.
As we're casting this spell.
I don't want each of these times we're applying damage little by little to have a debuff chance.
I don't want any debuff chance for this only when I apply damage for the very last time when I release.
When I stop casting this spell, do I want to actually apply damage that has those set by color magnitudes
in them?
For debuff chance and all the debuff parameters?
So all I'm going to do with this spec is assign a damage set by color magnitude.
So I'm going to use assign tag set by color magnitude.
And I'm going to choose the damage type.
So it's going to be damage dot lightning right.
So that's the damage type.
And the magnitude is going to be gotten from our damage.
And of course that is right here.
And our damage isn't actually exposed to blueprint.
So I'd like it to be exposed.
Even more useful would be just a function that performs the lookup and returns the float damage at current
level.
So I'd like to do that.
So I'm going to close the editor and go back to Aura Beam spell.
Actually, it would be nice if this were in Aura Damage gameplay ability.
So we can make a blueprint pure function, and this will be a float returning function.
Get damage at level.
So make it a new function blueprint pure.
And we'll go ahead and define this.
And what's it going to be?
Well, we're doing something like this already in Aura Firebolt.
If we go to the cpp file for that.
We'll see that we're already calculating damage and get description.
We have scaled damage.
Its damage get value at level.
I'm going to copy that and we're going to go back.
Two or a damaged gameplay ability, and we're going to return damaged value at level passing in get
ability level.
Now this could be a const function.
Of course it's going to be.
And with that, now we can get that damage.
So let's go ahead and launch again.
All right back into our ability.
I'm going to call get damage at level.
And that is going to be plugged in to magnitude.
So we're assigning a tag set by color magnitude.
And I'm going to apply this to the ability system component of our mouse hit actor.
So I'm going to right click get our mouse hit actor and get the ability system component from it.
So get ability system component.
And from that ability system component I'm going to.
Call apply.
Gameplay effect.
Spec two.
Self.
And we'll hook this up to apply damage here.
And in fact, we need to assign the tag set by color magnitude first and foremost.
And then we can call this.
And let's get our nodes under control.
Okay.
I think it's best if you can minimize the number of crossing wires so that it's really easy to see exactly
where each wire goes.
That is good blueprint organization in my opinion.
Now this function is applying damage to mouse hit actor, but we need to do the same exact thing to
all of the additional targets.
So what I'd like to do is I'm going to take this mouse hit actor, this one here, and drag it way over
here.
Like this, and then I can highlight all of this and collapse it to a function.
I'm just going to collapse it and call the function apply damage single target.
And this function can be used with mouse hit actor.
And it can also be used with all of the additional targets.
If we get those additional targets and we use a for each loop.
Then we can call apply damage single target on all of them in the loop body with the array elements
as the actor.
So now we have apply damage which we can apply.
So we can go back out to the event graph and each time damage and cost is executed.
If we can afford the ability cost, we can call our new function apply damage.
Which will apply damage to all of our enemies.
Now, when the mouse hit actor dies, I would like to end the ability.
So I'm going to make a boolean called target dead.
And I'm going to check it here even before applying the damage effect.
So I'm going to have another branch and we're going to check if target dead.
Now we're not setting it yet, but once we do, we'll know when the target is dead.
And if it's not dead, we'll apply the damage effect.
If it is dead, then we can go ahead and prepare to end ability.
We can do all of this stuff clear and invalidate the timer.
We'll just have it all right here.
And of course, we're repeating ourselves here and here.
We could just collapse these to a function clear timer and end ability.
Let's do that.
Collapse the function.
Clear timer and end ability.
And we'll just use that here.
And we'll use that here.
Now, how do we know when the target has died?
Well, we'll get to that.
Let's just see.
Now, if we're handling damage correctly and it looks like I have an error here, I'm applying the gameplay
effect spec without passing in a spec handle.
I need to pass that spec handle in, and it's actually returned from sign tag set by color magnitude,
so I can plug that in there.
And looking at the inside of this function, I see that it's a little bit.
ifI.
So I'm going to promote this input parameter to a local variable.
We'll call this damaged target.
Like so.
And that can be what we put right here.
Damaged target.
And I'm going to reroute this around these.
Okay, now we're looking a little bit better.
Compiling that.
Let's just see if we are causing damage.
Oh, yes we are.
Look at that.
Pretty crazy.
Okay.
Well.
That's working.
Crazy.
Okay, so that's working.
Now this seems to look pretty good, but there are a few details we still have to take care of.
It's kind of hard to see some of them, but for one, when all of them die, we still see electricity.
Right.
So that's something we have to fix.
In addition to that, we also need to decide when we should end the ability and decide when we should
commit the ability cost.
So there are still a few things left to do and we'll handle those next.
I'll see you soon.