Welcome back.
Now here's my gameplay effect G damage.
It's set to modify incoming damage.
That's our meta attribute.
We're adding to it and the magnitude calculation type is set by caller.
So we've seen that we can set a set by caller magnitude from game logic either in C plus plus or it
can be done in blueprint and that's the magnitude calculation type.
But we can also set this to a custom calculation class if we like.
And execution calculations are another choice for our custom calculation class.
In addition to MKs, we're going to make one for damage because our damage calculation is going to be
quite a bit more complex than simply setting a value directly.
So let's make that class.
We're going to go into C plus plus classes, Aura, public ability system.
And here's a mod mag calc folder where we could have called this custom calculations and just keep all
our custom calcs in there, but we're going to make a new C plus plus class in a new folder.
So for this it's going to be a gameplay effect execution calculation.
So we'll choose that type and we'll place it in ability system slash exec calc.
So that's a shorthand way of referring to an execution calculation.
We often call them exec Calcs.
Now I'm going to prefix this with exec calc underscore, and I'm going to call this damage.
So we'll have a exec calc damage.
Let's go ahead and create the class.
And I'm going to close the editor down.
And this should show up right in my ability system and exec calc folder so I can go ahead and close
all the tabs and open the exec calc and CPP files.
So here's our custom calculation class based on you gameplay effect execution calculation.
It's called you exec calc damage.
And we've seen in the last slide just what this type of class is capable of.
We just don't know yet how to implement that.
So here are the things we have to do just by default.
The first things to do are, first, we need a constructor, so we're going to add a public section.
And we'll add a constructor and we'll define the constructor.
So that's step one.
And then we need to decide what happens when this custom calculation class is executed, what type of
calculations are going to occur, And for that we override a virtual function.
It's a virtual void function and it's called execute underscore implementation.
Now, if I let writer complete this, for me it's a function with a couple of input parameters.
First is an input called execution params, it's an gameplay effect custom execution parameters.
So it's a little struct that contains some information.
We also have an gameplay effect custom execution output.
It's called out execution output and that's not const, that's just by reference indicating that perhaps
we can change this struct in some way and it will be used somewhere later after this function has been
executed.
So we have this function, we can generate a definition for it.
So here we have it.
And we don't have to call super.
We can just decide exactly what happens here.
And what we're deciding is how this execution calculation is going to affect any other attributes by
setting their values.
So remember, this belongs in a gameplay effect.
So if we add a modifier to the gameplay effect, then by setting a custom calculation class, it's really
this custom calculation class that determines what's going to happen when we apply that gameplay effect.
So here we can decide how to change various attributes and we can capture attributes and we can also
get information about the gameplay effect concerning who caused the effect and who the effect is targeting
at the time of application.
So we're just going to start off by retrieving some data that's available to us thanks to these input
parameters that we have at our disposal.
We're going to take a look at the execution params, so let's type execution params.
And have a dot here.
And notice that as soon as we hit dot, we have lots and lots of cool functions.
Some of the most notable are look at this git owning spec, the gameplay effect spec that owns this
calculation.
There's the prediction key.
We have some functions that sound like they're related to capturing attributes and their magnitudes.
And we also have things like get source ability system component.
And get target ability system component.
These are really nice and convenient functions for us.
Let's say we'd like the source ability system component.
Well here it is.
We can call that function and we can even store it in a const you ability system component pointer called
source ASC for example.
We can also do that with the target.
So we can say const you ability system component target ASC equals execution params dot get target ability
system component.
So right there we've already got the ability system components of the source and the target.
Now because we have these, we can also get the Avatar actors.
If we need those, for example, we can make an A actor pointer called Source Avatar for example, and
we can get that from the source ability system component.
Now in the case that the source ability system component is null, then we'll just set this source actor
to null.
How about that?
So we can use the ternary operator and say source ASC question mark.
And if that is not null, then we'll take source ASC and call get Avatar actor and if it is null, we'll
set this source avatar to a null pointer and we can do that for the source and the target for now we
can make them const.
So const a actor.
And we'll make a target avatar and we'll check Target ask question mark.
If it's valid, we'll take target.
Ask and call get Avatar actor.
Otherwise we'll set it to null pointer.
So right there we have the ability system components and the avatar actors for the source and the target
of the gameplay effect using this custom calculation.
We can also get the effect spec as we've seen, so we can make a const gameplay effect spec.
I'm going to make it a const reference called spec and we can get that from the execution params with
get owning spec.
So that right there has tons of information inside of it.
All right.
So now that we know that we can access source and target ability system component and avatar actors
as well as lots of other information in the effects spec, we need to know how we can capture attributes
and use them and set them and really make this execution calculation do its thing.
Now, at some point it looks like writer Auto included something up there that's not used for me.
I'm going to go ahead and remove it.
There we go.
So next, we need to actually capture some attributes and then decide how we're going to use those to
change other attributes.
Ultimately, this damage exec calc is going to want to set the damage meta attribute on the target.
So that's one of the next things we need to do.
So in the next video, we're going to learn how we can start capturing attributes in our execution calculation.
I'll see you soon.