Welcome back.
Now that we have rich text blocks and we have the capability of setting their styles by formatting the
text used by the rich text block, we can now implement spell descriptions, and I'd like this to be
a quality of the spell class itself.
So what I'm going to do is close out of the editor and I'm going to close all my tabs and go into my
aura gameplay ability.
So in abilities.
We have ora gameplay ability and for each of our ora gameplay abilities I'd like to have a virtual function
that child abilities can override and these are going to return the spell description so they'll be
public, they're going to be virtual.
We plan on overriding them and they'll return an F string.
F strings are just easy to manipulate and we'll call this one get description.
And description will depend on the level, so we'll pass that in as an int 32.
So our description will change based on that level.
Now we also need a string returning function for the next level, so we're going to make a virtual F
string returning function called Get Next Level description.
And this will also take in an int 32 called level.
So we can generate definitions.
And the aura gameplay ability implementation of this is just going to return some default text.
So we'll just say return F string print f.
Text and we'll go ahead and format it with one of our rich text styles.
So I'm going to use default here and what I can do inside of this.
As I can say, percent s with a comma there and a space.
And then after using the default style, I can use the level style.
And percent here.
So this is a print F So what I can do is use string literals here.
If I use an uppercase L with quotes, that's going to make a wide character for me and I can just say
default ability name and just put a whole bunch of text when we want a whole bunch of text and it doesn't
matter what it says, we say Lorem ipsum.
Many times over, so I'm just going to go ahead and paste Lorem ipsum a bunch of times.
And after that, since we also have a percent de I can also put my level in there.
Why not?
So we're just giving some default text here.
Doesn't matter what it says.
And for the next level description, we'll say return F string print f.
Text and we'll just put we'll use the default.
Format here and just say next level.
Just kind of getting practice using these formatting syntax, we'll say level opening the level percent
D closing the level.
We can even have slash N to get a new line here and I can copy the opening and closing for the default
again.
And say causes much more damage.
And then after the text, I just need to replace the percent de with an integer that can be level.
So we can see, you know, what it looks like by using the default format for next level, using the
level format for this percent de, which will be replaced by level.
We can do a new line character inside of our string and then we have the default style here again.
So really just, you know, showing how this stuff works and making sure that it's going to work now
or a gameplay ability can also return a locked description.
So I'm going to have a virtual F string returning function called Get Locked description.
This will also take in an INT 32 called level.
And it's just going to say, you know, ability locked until level, right?
So we'll say return f string, we'll print f.
With text and the text will just be using the default style for now.
And it's going to say ability or we'll say spell locked until level and we'll use percent D And so this
function will take in the level requirement.
So we'll use that to replace percent D here.
So the locked description will just be for a locked spell.
Okay, so we have these functions.
We're going to override them in child ability classes, but for now we just have something to call on
the ability in order to get a description.
But our ability system component is going to need a function that can return a description based on
an ability tag.
So I'm going to open the ability system component class.
Or a ability system component.
So I'd like a function that can get the description and the next level description based on an abilities
ability tag.
So the function can be public.
And I'd like it to return a bool.
That way, if we fail to get a proper description, we'll just return false and this will be get descriptions.
By ability tag and notice I said descriptions plural.
Because we have a description and we have a description for the next level.
So this will take a const gameplay tag by reference called ability tag and it'll also take in an F string
by non-const reference that it can fill in.
And this will be description, we'll call it out description.
And we'll also have another one for the next level.
Description passed in by reference.
We'll call it out Next level Description.
So this function is going to fill in out description and out.
Next level Description.
So how are we going to do that?
Well, let's create the function definition.
And what we need to do is, first of all, check to see if our ability tag is valid, if it has a valid
ability spec, if it's in our activatable abilities, and we'll do that with an If check, we'll say
if we'll make a const f gameplay ability spec that's a pointer, we'll call it spec, I'll call it ability
spec.
I won't be that lazy.
And we're going to call get spec from ability tag passing an ability tag.
So we won't get into the if statement if this is not even a valid ability tag.
Now, if that's the case, I would like to just use a string that says that the ability is locked,
but we do know the ability tag.
So we could get ability info our data asset and take a look at its ability level requirement so we could
get our ability info with you ability info.
We'll call this ability info.
And we can use you or ability system library get ability info passing in a world context object.
I always like to use get avatar actor and with our ability info we can get the level requirement and
that way we can get the locked ability description from our gameplay ability and then we can set our
f string to a locked description.
And I suppose we could just make that locked description here and it doesn't really matter that we have
a get locked description on the ability class because we can set that string to a locked description,
which means if we're going to want to call that get locked description function on or a gameplay ability,
we should just make it static and don't plan on overwriting it.
So I'm going to take virtual off, but I'm going to make it a static function and the static function
will say spell locked until this level, right?
So it's going to be a static function, which means we can call it straight on the Or gameplay ability
class.
So that's what I'm going to do is I'm going to set the description out.
Description.
Equal to you or a gameplay ability.
Double colon get locked Description because it's a static function and we'll pass in the level requirement
from ability info.
So we'll say ability info.
Find ability info for tag passing an ability tag and from that ability info we'll get the level requirement
and pass that in.
And now our out description will just have the locked description and next level description can be
empty.
So we'll say out next level description equals the empty string F string.
That's what we'll do.
And we'll say that in this case we'll return false.
Meaning that we did not find an ability in our activatable abilities and get spec from ability tag.
We'll just say that we have a locked ability.
We'll consider this to be locked and I'll make ability info const and in the case that we do find a
valid ability spec, then we know that it's not a locked ability and we can set the description by getting
our gameplay ability from the ability spec.
So we'll do this.
We'll say you are a gameplay ability or ability, we'll call it that.
Equals a cast to you or a gameplay ability.
And we're going to take our ability spec and get the ability from this ability spec.
So we're going to get the actual ability, the Ue or a gameplay ability.
If we successfully cast to it, then we're going to call those non-static functions on our ability.
We're going to take out description and set it equal to or ability get description and we're going to
pass in the level.
We can get that from the ability spec, so ability, spec level and for our next level description,
we'll set it equal to aura ability, get next level description passing in ability spec level.
Plus, you guessed it, plus one.
All right.
And then we can return.
True.
So this way we'll know the difference between these two outcomes.
But the important thing is that we have a git descriptions by ability tag function that we can use to
get the descriptions.
Whenever a ability changes, either changes its status, changes its level and what have you.
So because we have this function, we can call this function from our spell menu widget controller.
So I'm just going to quickly go to my private folder to UI widget controller, spell menu, widget controller,
and I'm going to look at wherever we're broadcasting spell globe selected delegate.
Why?
Because we're broadcasting these two booleans whenever we've selected a spell globe.
But now when we select a spell globe, we should also get those descriptions and push those up to our
widgets as well so we can set those rich text blocks.
That would be ideal.
So we're going to get the spell menu.
Widget controllers delegate that broadcast to Booleans.
We're also going to broadcast two F strings as well.
So I'm going to add an F string comma.
We'll call this description string and we'll add another F string comma, and we'll call this next level
description string.
And now that spell globe selected signature requires two F strings in addition to two booleans.
We need to pass in strings, so we'll go back to spell menu widget controller Everywhere we're broadcasting
spell globe selected delegate and make sure we pass two strings in.
I'm going to go up to the top and search for it.
So I find the first instance of it, and that's going to be when ability status change has been broadcast.
Now we have the ability tag and our ability system component.
It has the function get descriptions by ability tag that takes a tag and two out parameters for descriptions.
So what we can do is just like we made two booleans and set them with this function, we can make two
F strings and set them with that ability system component function.
So we're going to make an F string called description.
And F string called Next Level Description.
We're going to get RISC.
And we're going to call get descriptions by ability tag and pass in the ability tag and pass in description
and pass in next level description.
And then when we broadcast the delegate, we can pass in description and we can pass in next level description.
And of course we get the red squiggles because you guessed it, this can now be changed to four params
instead of two.
And that's going to fix that.
So now we need to call.
This with two strings every time we broadcast this delegate.
So we're going to find it down here.
When spell points change, we're going to replace this line with these.
For now, we're going to get a string called description and F string.
Next level description.
We're going to call get descriptions by ability tag.
This has to be our selected ability.
So we're going to pass in selected ability, dot ability, and then we'll broadcast.
And I believe that's the only Nope.
There's another place where we're broadcasting that's in Spell Globe selected.
So we also need to do this here to description next level description passing in ability tag.
And then we broadcast those strings up with those booleans.
Now that we've done this, we can handle those two strings in our spell menu.
So let's go back into the editor.
We'll compile and launch.
And we'll get our spell menu open and in the spell menu.
Right here on Spell Globe selected.
We now have two strings that we're receiving.
I'm going to make some room.
And move this out.
And I'm going to take these two strings and set the values for my rich text blocks, which I have here
called Rich Text description and Rich Text.
Next level Description.
So I'm going to get those out here.
Rich Text Description.
And where's the other one?
I might not have made it a variable.
I did not.
So now it's a variable and there it is.
Now for rich text description and next level description.
We just need to call, set, text on them.
So for rich text description, we're going to call, set, text.
The function and we're going to get our description string and hook it straight in.
It's going to be converted from a string to a text, and we're going to do the same thing for next level
Description.
We'll get our next level description string right there.
So now we're setting our descriptions.
So we can compile and save that.
And we should just see some default messages from the aura gameplay ability.
And we do we see default ability name and then Lorem ipsum now it goes off the screen it doesn't wrap
around.
So that's something we can set on our text block.
So I'm going to take this text block and search for wrap.
And auto wrap text.
I'm going to do the same thing for the other one, auto wrap text.
So now.
Saving all.
I can select.
And now we see that it wraps.
And because I typed Lorem ipsum so much, we have our scroll bar because it's got enough text to scroll
and at the very end I said the level, which is one really, really cool.
And then here next level to causes much more damage.
Cool.
And if we level up and upgrade that other ability to eligible.
Like so.
Well, we still see the same thing, so it's not going to do much.
But if we click on all these other ones, they're going to say spell locked until level one because
they don't actually have ability tags set for them.
But what we can do is we can test out that second ability before we upgrade it to eligible.
If I click on it, it says spell locked until level two.
So we know that part works so we can actually see the level requirement when we click on it.
As long as it has a valid ability tag corresponding to an ability in our ability info data asset that
has a level requirement because that's where we're getting our level requirement from.
All right.
So we now have spell descriptions, but we just have a default description on our ability class.
We need to fill this in for our firebolt ability.
So it actually shows some really cool info for the Firebolt and we can also do it for our electrocute
ability as well.
And we'll do that next.
So great job and I'll see you soon.