Okay, so we've got some really nice fireballs, and they're causing damage on the way out.
Didn't mean to cast that spell.
I keep hitting the one key instead of the two key, but let's hit the two key.
And of course, our fireballs are a little op, but we can take our ghoul and set its character class
level to something higher, like seven.
And then we shouldn't be causing fatal damage anymore.
But the point here is that we need some explosive damage.
We're going to want these fireballs to blow up and actually blast our enemies away.
And for that reason, I'd like some damage effect parameters specifically on our fireball for radial
damage.
Right.
For explosive damage.
So we're going to close the editor and open up Aura Fireball.
And we're going to add another variable to this.
I'd like this to be specifically for radial damage.
So this could be in the protected section.
It can be an f damage effect params called explosion damage params.
Now explosion damage per rams is going to need to be set.
Of course I'm going to expose it to blueprint.
I'm going to make it blueprint red right.
So we'll have write access to it in blueprint.
And I'd like to be able to apply damage using this from blueprint.
So now we just need to set these explosion damage params.
Now we need to set some things on this.
As soon as we've spawned our fireball in our fire blast.
So what I'm going to do is I'm going to call make damage effect params from class defaults, but I'm
going to make a local f damage effect params called explosion damage effect params and call make damage
effect params from class defaults.
So most of the parameters will be filled in.
But we're going to want to set more of these later, right?
I'd like to be able to set some of those damage params a little bit more easily.
Now it'd be nice if we could just go into aura ability types into our struct f damage effect params
and put some blueprint callable functions like set is radial damage and so on.
But unfortunately we can't put blueprint callable functions into a struct.
What we have to do instead is use other means.
One thing we could do is we could use an aura ability system library function to set some parameters
on our damage effect params.
Let's do that.
I'm going to go to Aura Ability System library and we'll make a couple of static functions.
And this is going to be under the comment damage effect params.
So I'm going to make a static void function called set is radial damage.
Now we already have a set is radial damage I believe, which takes in an effect context handle.
So I'm going to call this set is radial damage effect param.
And this is just going to take in a f damage effect params struct called damage effect params.
And a bool called b is radial.
And this is going to be a blueprint callable function.
And I do need to use my upper ram ref right here.
That way this can be an input parameter even though it's a reference.
Now I'm going to go ahead and generate a definition.
And all I'm going to do is take damage effect params dot is radial damage and set it to be is radial.
Now I'm just going to debug real quick.
And we'll go ahead and get that fireball back and here in the fireball before destroying the actor after
on hit, I'd like to go ahead and get my explosion.
Damage per amps.
And I'm going to call set is radial damage.
Effect Param passing this in.
Checking is radial.
Dragging off and breaking the damage effect params getting that is radial damage.
Using a branch.
And checking is radial damage.
It should be true now.
So I'm going to print.
Is radial.
So saving all.
Pressing two.
And look at all that is radial lots of times.
So we see that that's working.
So rather than creating a whole bunch of functions I'd like to make one called set is radial damage
effect params and pass in a whole bunch of parameters here.
And then we'll have one for knockback force as well, and death impulse as well, because now that we
have this additional explosion damage params, we can cause radial explosive damage with it.
We just have to be able to set some of its params here.
So I'm going to close the editor.
And let's change this function to take in a few more inputs.
We have bool b as radial.
Now we have to remember that our damage effect params are partially being set already, because in aura
fireblast we're calling make damage effect params from class defaults.
Now if we peek that if we go to its definition.
We'll see that we're all ready, setting a lot of things.
But we're not setting these radial damage parameters because is radial damage for our ability is false.
So we need to set the origin inner and outer radius.
So this function can take a float called inner radius, a float called outer radius.
And an F vector called origin.
So we'll add these inputs to our function.
And we'll just set our damage effect parameters.
So we're going to set radial damage inner radius to inner radius.
We'll take the damage effect params dot radial damage outer radius.
Set that to outer radius and take our damage effect params dot origin, radial damage origin that is
and set it to origin.
And so we can set those properties from within blueprint now.
And we can do the same thing for knockback.
So I'm going to go ahead and make a new static void function called set knockback.
And we'll just use set knockback direction because in aura damage gameplay ability.
We are setting the knockback force magnitude already.
As well as death impulse magnitude.
So we just need to set those directions.
So set knockback direction can take an f vector called knockback direction, but it also is going to
need the damage effect params as a u param ref.
So we'll put that in first and we'll give it blueprint callable with a category.
Now in addition to this I'm going to have a set death impulse as well.
So set death impulse and it'll actually be set impulse direction and its input is going to be impulse
direction.
So I'm going to create function definitions for these two.
And they'll be super simple.
This one is going to take damage effect params, and there's really not any point in setting the knockback
force direction.
We just need to take the knockback force and set it equal to knockback force direction times damage
effect params dot, knockback, force magnitude.
It doesn't really matter what we set that direction to, it's the knockback force that's actually used.
But what we can do is take knockback direction and call normalize on it first, just in case we don't
pass in a normal vector.
And we'll do the same thing for impulse direction.
So we'll say impulse direction dot normalize.
And then we'll take damage effect params dot def impulse and set it equal to impulse direction times
death impulse magnitude.
And that's going to be on damage effect params.
So death impulse magnitude.
So now we have two functions to set those parameters as well.
Okay, now we do need one more thing and that's that.
Our knockback force magnitude is zero for this particular fireblast ability.
So if we're going to set the knockback direction, I'd like to have an optional override of the magnitude
itself.
So I'm going to have an additional float parameter called magnitude and set it equal to zero.
And I'll do this for both death impulse and knockback.
So we'll have a float magnitude input parameter that's optional.
And then in these setters we'll only override the magnitudes if this magnitude is not zero.
So what we can do here is we'll check if magnitude is zero.
Then we'll do what we were doing here.
We'll just use the knockback force magnitude that was already there.
Otherwise, we'll override the knockback force magnitude.
We'll multiply knockback direction by the magnitude passed in.
And we'll do this same thing for the death impulse.
We'll say if magnitude is zero, then we'll do what we were doing.
Else?
Will do the same thing, except we're going to use magnitude instead of the damage effect per Ram's
magnitude.
So we can just pass in a zero if we're confident that that magnitude is set in the damage effect params.
Otherwise we can pass in an override for that magnitude.
Okay, let's compile and launch.
Okay, so we're back now.
Here in the fireball on hit, we're going to take our explosion damage params.
Now we're going to set some things.
I want it to be radial, and we'll set an inner and an outer radius.
For this I'll just use 50 and 200 for now, maybe even 300.
And the origin is going to be this fireballs location.
Get actor location.
Now we can also set some additional parameters.
Such as knockback.
So I'm going to say set knockback direction.
And we're also going to set the death impulse direction.
And how are we going to calculate these?
Well, if this is going to be radial damage, then I'd like to get all actors that are alive within
radius.
In other words, get live players within radius.
Well, I have a nice function for that.
Get live players within radius will return an array of actors, and I can even pass in actors to ignore,
such as the owner of this fireball.
Now we are going to want to avoid overlapping aura.
So we could call get owner.
But are we setting the owner?
Well, let's make sure we are.
We'll just close real quick and we'll go back into aura Fireblast when we're spawning the fireball and
we can set the fireballs.
Owner.
We can take fireball and we can call set owner.
Setting it to get avatar actor from actor info.
Now we can be confident that the fireball is going to have its owner set.
So with that, let's go back into the editor.
We'll get our fireball back open.
We'll get our owner and we can plug that in and use make array.
Now we could also take this array and we can add the self to it.
So we can use AD.
Hook that in and we can get a reference to self.
And we can make sure this projectile doesn't overlap with itself either.
So we're getting live players within radius world context object can also be self.
So I'm going to pass that in.
And the radius is going to be the same as our outer radius.
We can make these variables as well.
And the sphere origin is going to be the same as our projectiles location.
So now we have an array to loop over.
So we're going to loop over this.
With for each.
And in our loop body we're going to take our damage effect params.
And for each iteration of the loop we're going to overwrite some properties in our explosion damage
params, namely our knockback direction and our magnitude.
We don't have to set the radial params.
We can do that before the loop.
We can even do it after the loop.
But in the loop body we need to set our knockback directions.
So we need to get our array element and get actor location.
And we need to calculate the direction for the knockback.
So I'm going to get the vector from my projectiles location.
To the victim's location.
The thing we're hitting.
Or almost hitting or getting close to hitting.
So if I want the vector from the fireball to the victim, then I'm going to subtract the destination
from the start point of the vector destination being the actor we're hitting.
So we're going to subtract.
We'll get that direction.
And.
So we can pass this in as the knockback direction and we can give a knockback magnitude.
I'm just going to give it 800 for now.
And I'm going to use the same vector for the death impulse and give it 600.
So for each loop body here, we're setting those parameters.
And if we're going to apply damage to each one we actually need to set the radial damage params as well.
Before we do that so we can set them first.
Like that.
And I'm going to actually promote this array to a variable.
And we'll call this overlapping players.
That way.
We don't need this reroute node.
And we'll hook up overlapping players to the for loop.
So now we have our explosion damaged params.
We're calculating knockback and death impulse.
So for each of these actors I'm going to call apply damage effect.
And hook in my explosion damage params.
And then at the end of this loop.
I'm finally going to destroy the actor.
And we could do on hit there, but it's fine that we're doing it before, so let's test this out.
Okay, so I got a exception.
And apply damage effect.
And my source ability system component is not valid.
Looks like it's a null pointer and I have some empty damage effect params.
Actually, I've just set the death impulse, but nothing else is being set here, just the things we
set in blueprint, right?
So it's not being filled in.
And we need to see why in aura Fireblast.
And sure enough, here's why I never actually set it on my fireball.
I just made a local variable, which makes sense.
So I'm going to go ahead and hit stop and make sure that I'm setting this.
I'm going to go to my fireball.
I'm going to take my fireball and set its explosion damage effect params.
I don't see it here.
So let's go to Aura Fireball and it's protected.
I need to make it public.
And here in aura Fireblast.
I can set it here with that.
Now it should be set.
Let's try this again.
Okay, so I need to go back into my.
Fire, fire!
Blast and open up BP.
Fireball.
And it looks like I have lost some of my progress here because of that exception.
No worries.
After on hit.
I'm going to go ahead and set my radial damage effect params.
And then we'll get live players within radius.
I'm going to take the owner and make an array, passing it in.
Hook that up.
But I'm also going to add the self to this array.
So I'm going to call AD.
Get a reference to self.
Hook that in.
And that's going to go in here.
Right here.
And self is also going to be the world context object.
Now, if I can't help but cross wires, I make sure that the wires are as short as possible so you can
see where they go.
Okay, so I have live players within radius.
I need the sphere origin that's going to be get actor location.
I need my radius.
I'm just going to promote that to a variable and call this radial damage radius.
I'll make it.
Radial damage.
Outer radius.
And I'll compile and set this to a default value of 300.
And I'll use it here when setting my radial damage effect params.
And I'll promote the inner radius to a variable to.
Radial damage.
Inner radius.
That way we have parameters.
This is why I save before play testing.
Usually looks like I forgot this time, but this is why I do it.
Because.
When you crash in debug mode and you haven't saved, you lose progress.
Okay, so we're getting live players within radius.
We're going to do a loop.
For each.
And we need to calculate knockback direction and impulse direction.
So I'm going to use Get actor location.
And I'm also going to get actor location of the array element.
And I want the vector from the fireball to the array element.
In other words, from the fireball to the hit actor.
We always subtract the destination from the starting point of a vector.
And that's going to be our knockback direction.
And we'll just have a knockback magnitude here.
We'll promote this to a variable.
Call it knockback magnitude.
I'll make it 800.
And for the loop body, we'll set this.
And we'll use the same vector for knockback direction as death impulse direction.
So I'm going to promote it.
To a variable and we'll just overwrite it every time.
We'll call this knockback direction.
And I'm going to use it instead of having more than one wire here.
So I'm going to use knockback direction here.
And I'm going to use the same vector for the death impulse.
Knocked back.
Direction.
And I'll just have a knockback magnitude.
So promote to variable.
I said knock back, but I mean death impulse magnitude and death impulse magnitude.
Can be 600.
Okay, now with that.
We have these parameters.
Again, we're going to call apply damage effect and pass in these parameters which should no longer
be empty.
As we're actually setting them.
In our game play ability now.
And with that, when this loop is done, we'll destroy the actor.
Okay, this time I'm going to save all.
And press play and try it out.
Okay, so the target ability system component is null.
So.
Yet one more thing that I haven't set that I need to set in that for loop.
Getting the ability system component from the other actor.
It's okay.
This is sometimes an iterative process.
Sometimes we have to try things and find where they break and fix the issue at hand.
Try them again, see where they break again, and fix the issue again.
Sometimes this is the development process.
But we're getting closer now.
We know that we're getting to just about the end of that function.
Let's go to fireball.
And here in this iteration of the loop, we need to be setting the target ability system component pointer
on our damage effect params.
And we can get our array element and we can call get ability system component.
On the ability system blueprint library and we can take those explosion damage params.
And we can set and we don't have a setter.
So let's just really quickly make one in our ability system library.
So static void set effect params AC.
It's going to take in.
A upper arm ref damage effect params and a new ability system component pointer in ASC.
It's going to be blueprint callable.
We can generate a definition.
We can take the damage effect params dot target ability.
System component.
And set it equal to nasc.
And we should probably specify that this is for the target.
So we're going to say set target effect params asc.
And with that we should be able to set it.
Okay, back into the fireball.
And this should be our last step.
We're going to take the damage params.
We're going to call set target effect params as passing in that ASC.
Looking this up.
Like so.
And with a little slight cleanup.
We can try this out.
All right.
Now they're dying because they can't take that much damage.
So to really test this, we can take our damage.
For Fireblast and we can just scale it by zero.
That way we'll only see the effects of.
Our knockback.
And I'm going to set my knockback magnitude to 2000.
There's no way we can miss that.
All right.
I'm going to have to override that pitch, I think, because it is knocking them back.
But it's not knocking them upward.
So I'm just going to alter my knockback direction.
So I'm going to take knockback direction.
I'm going to make a rotator I can use make wrote from X.
I can break it.
Or split the struct pin.
I can take this and make a new rotator from it.
And I can hook in yaw and roll and override pitch to 45.
And I can make a vector.
So we'll call get forward vector from this rotator and pass this in for the knockback direction.
There we go.
That's what I wanted to see.
Okay.
Kind of a lot of steps to this.
I'm going to collapse this to a function.
I'm going to call it override knockback pitch and I'm going to make it pure.
And hook that in.
And knockback magnitude doesn't have to be 2000.
I'll set it back to 800.
And it's working.
Excellent.
All right.
And I'm going to go ahead and take my fire blast and set its damage scale back to one.
And with that we now have our fire blast ability.
Beautiful.
Excellent job.
I'll see you in the next video.