All right.
Welcome back.
Now, we've gone through all this work to apply a gameplay effect to the target ability system component
here in apply effect to target.
And remember, we made this function blueprint callable apply effect to target.
And we did that with the intention of calling this from blueprint because we don't have our sphere component
here in C plus plus anymore.
We're no longer responding to callbacks to overlap events in C plus plus.
We're now handing that over to the design side, to the blueprint side, right?
So what we'd like to do is go into Blueprint and call this function after creating an actual gameplay
effect, and we're going to make one on our potion blueprint.
So I'm going to go ahead and run in debug mode.
That way we can catch if anything happens at runtime and get some information about it.
So I'm going to go ahead and open the blueprint editor that I had open, and that was BP Health Potion.
And in the event graph I have on component began overlap for the sphere and my blueprint callable function
is called apply effect to target.
So if I right click and type apply effect to target.
Then I get that and I can pass in the actor and the gameplay effect class.
Now we don't have a gameplay effect class, do we?
If I click on Health Potion Self and search for gameplay effect.
Here it is.
It's called Instant Gameplay effect class.
It's set to none.
The only option here is the base gameplay effect class.
So we need a gameplay effect.
And as we learned in the first lecture for this section, we simply subclass the gameplay effect class.
We're going to make a blueprint for that.
Now, the way we organize our folder, we have a couple of options.
We can have our gameplay effect for the potion just right here next to the potion.
But if we plan on using the health potion heal gameplay effect elsewhere in our code, we could put
it in say a ability system folder that has all gas related stuff in it.
But what I like to do is here in Blueprints actor I'd like to make a new folder called Potion and put
Health potion in there.
And I'll just make the effect right here so we can make a gameplay effect by right clicking and selecting
blueprint class.
And under all classes we can search for gameplay effect and there are several options, but we're going
to choose just gameplay effect.
Select that and we typically prefix these with g for gameplay effect.
Sometimes you'll hear them referred to as GS and we're going to call this potion heal.
And let's go ahead and open up this blueprint.
Now, sometimes you'll open it up in the data only view without the event graph, but other times you'll
have just the whole details panel showing across the whole screen.
It doesn't really matter.
The details panel is all that really matters here.
So we have a number of settings here and we're only going to go over a few of them.
We just want a simple instant gameplay effect, meaning we want it to be applied once immediately and
that's it and it's over.
So things like period have nothing to do with instant gameplay effects.
We see that period has to do with periodic things, things that happen every so often, right?
That has to do with gameplay effects that are not instant.
So we don't care about those.
Stacking type is also not really applicable to instant gameplay effects because they fire off once and
they're done.
Whereas gameplay effects that have a duration such as has duration or infinite gameplay effects, those
can be ongoing, they'll be applied to the character and continue to be applied until they're removed
or they remove themselves.
And at that point, when multiples of the same gameplay effect are applied at once, then you need to
start thinking about do they stack, how do they stack and so on.
Now we're going to skip over granted abilities.
We're not interested in those yet down here under gameplay effect, this is what we're interested in
and here we see duration policy.
The default setting is instant.
We could set it to infinite.
This effect lasts forever.
That's what it says anyway.
We can remove infinite effects.
Spoiler alert there and has duration.
The duration of this effect will be specified by a magnitude We want instant and we want this effect
to affect our health.
We want to increase the health right.
So we're going to take our modifiers.
This is how we change attributes and modifiers.
Is an array and effect can affect multiple attributes.
And we're going to click plus and we've added one element to this array.
We're going to expand this index zero element, and here we have some options.
Attribute is the attribute.
We want this effect to change.
So I'm going to open the dropdown and look at this.
We have some attributes to choose from.
Now these appear in the form of the attribute set class separated by a dot, followed by the attribute
name itself.
Now, yes, there are two here from the ability system component.
We're not going to mess with those for now.
We're just interested in our attributes and look at that aura.
Attribute set has four attributes and they're here so we can choose health.
And for modifier op, this is the operation.
For this modifier we can override, multiply, divide, add.
We're interested in adding a value.
And for the modifier magnitude, here is where we can specify what we want to add to the health.
Now, scalable float allows us to choose a magnitude.
For example, we can choose 25 or 10 or -1 or -100.
It doesn't matter.
And by default, that's all that will happen.
When we apply this effect, we'll take the health, we'll add a value of 25 to it and the effect will
be done.
Now use curve table has a dropdown with absolutely zero options here, so that's kind of funny, right?
Well, that's because if we wanted to use a table, we'd have to create our own.
Don't worry, we will.
This is just a way that we can scale that magnitude based on a table that takes this effects level into
account.
We're just using a level of one, and we're just hard coding a 25 here.
We're keeping it simple from the beginning.
And for the rest of this, we have executions.
That's some custom, more complicated calculations that'll be for more complicated types of effects
that we'll implement later in the course.
Conditional gameplay effects.
Same.
Thing and chance to apply to Target.
Well, you can use a curved table for this.
You can also put a value here.
I want 100% chance to apply this effect.
I don't want a chance that it'll do nothing.
So I'm going to leave it at one.
And for application requirement, I don't want any requirements.
I want this to just be applied.
So that's basically all we need for this simple instant effect.
We just want the duration policy instant.
We want a single modifier that adds to the health attribute, a constant value of 25.0.
So I'm going to compile and save.
And we have our G Potion Heal Effect.
Now back in Health potion.
I'm going to set that now.
We made it a variable.
I mean, yes, blueprint callable functions can allow us to sort of hardcode values in so I could set
it there, but I'm going to be a good blueprint programmer and find what I call this gameplay effect,
which was instant gameplay effect.
So I'm going to right click in the event graph search for instant gameplay effect.
And of course I don't get it because I didn't expose it to Blueprint.
So really quick.
We need to do that.
I'm going to save all close out of the editor and make this instant gameplay effect exposed to blueprint.
We need it to be at least blueprint read only.
So we'll go ahead and do that and run and debug again.
I almost always do that.
I rarely give variables blueprint read only by default.
I always get to the point where I need to access them in blueprint and then I go and add that specifier
and that way I'm taking the approach of underexposing rather than overexposing.
Right?
So now that I've exposed it, we can search for instant gameplay effect and get that and plug it in
to our blueprint callable function apply effect to target.
It just needs a target.
And when something overlaps, we're going to take the other actor and pass it in as the target and hook
that up.
And now we have a blueprint for an actor that will apply an effect.
Now let's just say we want to destroy the actor.
We'll just call destroy actor here.
Because why not?
But later we'll make that a parameter that we can set so that this can be a very versatile class that
doesn't have a self destruction, mandatory quality or anything like that.
Now, by default, blueprint callable functions get that target self.
So target here might not be the best choice of name since we have two targets that might be ambiguous
a little bit.
So what we'll do is we'll go ahead and close the editor and rename this.
So I'll go ahead and rename it to Target Actor.
That way we know the difference here.
And I'll go ahead and run in debug mode again and I'll go ahead and open these blueprint editors.
And now this is called Target Actor and not Target.
I can simply alt click that and get rid of it.
And now other actor can go into target actor we can compile and that works.
So now we need to make sure our instant gameplay effect class is set.
We'll go to that.
We have G potion heal looks good and we can test this out so we can drag in one of these healing potions
and press play and I can show debug ability system.
I see that I have 50 health and as soon as I pick it up.
There we go, up to 75.
The gameplay effect has worked successfully and we can go into net mode.
Let's play as a listen server and change the number of players to two and press play.
Now I have the client here in the small window and we see that it works there as well.
So our gameplay effect is working.
Excellent.
Okay, so now our effect actor is a little bit more versatile.
And this is really cool because if we wanted to, we could make a mana potion that will increase our
mana as well.
And we have this nice apply effect to target.
We can choose to destroy the actor if we want to and all we need to do is swap out that instant gameplay
effect class and things would be pretty easy now.
It would be a red potion bottle.
But if we browse to the asset here for potion bottle and open it, we see that it's using three materials,
one of which is my red liquid.
It's a material instance.
In fact, you didn't have to browse to the mesh to do that.
You can just see it here in the blueprint.
If you browse to my red liquid, we'll look at this.
We have my blue liquid.
And if you were to say swap them out by choosing blue liquid, you can change it.
And it looks suddenly like a mana potion.
I'm going to change that back.
But showing you that because your quest is to make a mana potion.
Good times.
All right, so you're going to make a mana potion starting with the gameplay effect.
Make the gameplay effect.
You can call it g potion mana or something similar and configure the gameplay effect.
You should know how to cause a change to the mana.
Now create the blueprint mana potion and play test O and make it blue.
No one ever picks up a red potion bottle and expects their mana to go up, so definitely make it blue.
Pause the video and conquer this quest now.
All right, let's make our mana potion.
Now I'm just going to keep these all in the potions folder.
I'm going to browse back to potion and we'll make our mana potion here.
But first I'm going to make that gameplay effect.
So I'm going to right click and go to Blueprint class, search for gameplay effect and choose that and
we'll call this G underscore potion mana and we'll open it up.
And just like with our health potion gameplay effect, we're going to go down to duration policy.
We want that to be instant and we want to add a modifier here.
We'll expand the index and the attribute that's going to be mana and the modifier op is Add.
I'd like to add two mana.
I don't want to subtract it.
We subtract it earlier for demonstration purposes.
We're going to add and for the modifier magnitude, we're going to add let's say 30 mana and that's
it.
That's all we need for our gameplay effect.
We're going to save that and we'll make our mana potion blueprint.
So let's go ahead and do that.
I'm going to search for aura effect actor.
Choose that.
Select it.
Call this BP mana potion.
And we'll open this up and select the root component.
We'll add a static mesh.
It's going to be the potion mesh.
I think I called it in health potion.
Yeah, potion mesh.
I like these to be consistent and I'll set the mesh to potion bottle.
And I'd like to first of all, before I change the material, I'm going to set that scale.
Whoever made this potion made it way too big.
And I'm going to go to browse to the red liquid, but I'm going to select my blue liquid and come back
and press that little left pointing arrow.
Whoops.
Not that one.
This one.
To make this look blue.
Excellent.
Now I have what looks like a blue mana potion.
Now mana potion self selecting that I see my instant gameplay effect class.
I can set that to potion mana and I want to apply that when something overlaps with this, which means
I need a sphere component.
So I'm going to click add.
I'm going to choose Sphere.
And just to show you, normally I'd do a sphere here, but just to show you how we've gained some versatility
by moving this step to the blueprint side.
Let's say I want to do a box collision instead, so why not?
I'll make it a box, right?
And go into event graph with box selected, I can choose to get that on component begin overlap.
And see now I don't have to go and create a new C plus plus class or add a box component to my C plus
plus class.
That step has been moved to blueprint, which makes it easier.
And then I can call my apply effect to target function that I created and plug in other actor to target
actor.
Hook this up and I can get my instant gameplay effect class and plug that in.
And of course, if I want to destroy the potion after I can call destroy actor.
Now, I think later on I'm going to move this destroy call into the apply effect to Target.
That way we'll only destroy if we're actually applying the effect to a target, because I don't want
something that doesn't have an ability system component to overlap with this and cause it to destroy
itself.
I only want to have this be consumed if something with an ability system component overlaps with it.
In fact, to be more specific, I only want the main character to be able to drink these.
But our AI isn't walking around yet, so we'll cross that bridge when we get there.
So why don't we test this out?
I'm going to save all.
As a general rule, I save all just in case I get a crash for some reason.
Then my saved progress will be there.
Oh, and I guess I need to drag a potion into the world.
So let's browse to the asset and we'll drag in a mana potion as well.
Now, I'm going to go ahead and set this back to one player we can use standalone or listen server doesn't
matter.
And because I start off at full mana, I'm not going to really see anything visually.
I suppose before I go and change that, I could show debug and see my mana at 50.
Now it's at 80, so we know it's working.
We're not really clamping it.
We'll learn how to do that soon enough.
But just to get that cool feeling that you get when you see that health globe or Mana Globe change,
I'm going to go into my attribute set and start my mana off at a lower value.
So closing private and public, I'm going to go into ability system attribute set and right here I'm
going to init my mana to ten.
We really need mana, so let's run a debug mode.
And let's go ahead and play test.
My man is nice and low.
I need a potion.
There it goes.
And it goes up.
Perfect.
Let's go ahead and just drink that potion while we're at it.
And we have working potions, and they're better now because they're using gameplay effects and gameplay
effects are awesome and we're going to see how awesome throughout this course.
And also these are both derived from the same C plus plus class.
Even though one uses a sphere, one uses a box because we've moved some things over to the blueprint
side.
And so we're starting to see that, you know, sometimes a lot of developers will say that they try
to air on C plus plus for everything or as much as they can, and in doing so, you can sort of lose
some versatility in exchange for little to no performance gain.
And so it's important to kind of reassess that line and where you draw it and decide where exactly you
think things should be done, whether it's in C plus plus or blueprints or some other scripting language
such as verse.
Mm So anyway, excellent job.
We have a working effect actor.
We'd like it to be even more versatile, even more flexible, and we'll work on those things as we go.
But great job so far and I'll see you in the next video.