WEBVTT

00:06.970 --> 00:07.390
Okay.

00:07.390 --> 00:14.080
So now that we have a listen for event gameplay ability and we know that it's being activated right

00:14.080 --> 00:16.900
away, we can start sending events.

00:16.900 --> 00:18.700
So how do we do that?

00:18.730 --> 00:22.180
Well, we've already seen that we can send gameplay events.

00:22.210 --> 00:28.700
We've done so in our custom anim, notify where we call send gameplay event to actor.

00:28.720 --> 00:34.630
Now this is the ability system blueprint library, static function, and notice that it takes in an

00:34.630 --> 00:36.570
event tag and a payload.

00:36.580 --> 00:44.340
So when we receive the events that payload is available, we can send data through it.

00:44.350 --> 00:51.330
We're planning on sending in the event tag that we set on that data, this struct here and a magnitude.

00:51.340 --> 00:59.590
So our job now is to send this as soon as we've caused fatal damage and we know when that happens from

00:59.590 --> 01:01.120
within our attributes set.

01:01.120 --> 01:05.410
So let's go ahead and open our attribute set.

01:05.620 --> 01:12.980
So in aura attribute set in post gameplay effect, execute, we're checking the evaluated data to see

01:12.980 --> 01:14.690
if it's incoming damage.

01:14.690 --> 01:19.620
And we know then if it's fatal, we've already made that determination.

01:19.640 --> 01:24.050
So here, if it's fatal, we're taking our combat interface.

01:24.080 --> 01:29.120
We're casting the target Avatar actor to it and calling die.

01:29.150 --> 01:33.620
So the target Avatar actor is the thing getting hit.

01:33.620 --> 01:36.020
And we need to do a couple things.

01:36.020 --> 01:44.060
We need to get that target Avatar Actors XP rewards, so that we can set that magnitude value in a gameplay

01:44.060 --> 01:45.920
event and send that off.

01:46.130 --> 01:52.040
We also need to know who to send this gameplay event to, so we need to know something about the target

01:52.040 --> 01:53.540
and the source.

01:53.540 --> 01:59.480
And those are all info that we've stored in the props effect properties struct.

01:59.480 --> 02:05.990
So we could just create a function here to send an event and we can pass props into it.

02:06.080 --> 02:08.180
And that's how I'd like to handle this.

02:08.180 --> 02:13.430
So I'm going to open the header file and way down at the bottom I'm going to make a void function in

02:13.430 --> 02:22.640
the private section called Send XP event and this will take a const f effect properties struct by const

02:22.640 --> 02:24.920
reference called props.

02:26.540 --> 02:29.690
And we'll go ahead and generate this function.

02:30.730 --> 02:36.570
And Ryder did that annoying thing where it gave me an inline function definition, not what I want.

02:36.580 --> 02:40.720
So I'm going to go into the CPP file and define it.

02:41.290 --> 02:44.340
And here is where we need to figure out a few things.

02:44.350 --> 02:49.530
For one, we need to know how much XP to reward the attacker.

02:49.540 --> 02:52.990
So that's a value we need to figure out.

02:52.990 --> 02:57.970
But we made a ability system library function that can do that.

02:57.970 --> 03:05.080
If we go to that CP file, we can find get XP reward for class and level.

03:05.080 --> 03:11.410
And as long as we know the character class and the character level, we can get an XP reward value.

03:11.740 --> 03:15.910
So we can call that as long as we have the character class and the character level.

03:15.910 --> 03:17.650
So we need to get that.

03:17.680 --> 03:25.240
So closing the Blueprint library there, let's figure out how we can get the level and the class.

03:25.780 --> 03:32.640
Well, we can get that combat interface because the combat interface here defined in interaction.

03:32.650 --> 03:37.720
I'm going to go to the public folder interaction and open combat interface.

03:37.720 --> 03:41.980
We have get player level and we have get character class.

03:41.980 --> 03:45.970
We can get those values from the combat interface.

03:46.390 --> 03:52.960
So in send Exp event, let's just cast that target character to an eye combat interface.

03:52.960 --> 03:59.260
We'll say eye combat interface combat interface equals cast to eye combat interface.

03:59.500 --> 04:03.010
And we're going to cast props dot target character.

04:04.400 --> 04:10.340
Now we can wrap this in an if statement, and then feel free to access those values.

04:10.340 --> 04:17.360
We can get the player level as an int 32, we'll call it level, we'll call it target level because

04:17.360 --> 04:23.240
it's the target character and that will be combat interface get player level.

04:23.540 --> 04:30.980
We can also get the target class with a character class, target class, we'll call it.

04:32.190 --> 04:36.840
And we'll use combat interface get player class.

04:37.050 --> 04:39.690
No, it's actually get character class.

04:40.380 --> 04:47.520
Now that we have those two and those could be const, we can make them a const int 32 and a const character

04:47.520 --> 04:48.020
class.

04:48.030 --> 04:59.280
We can now get that exp reward from you or ability system library get exp reward for class and level.

04:59.280 --> 05:05.460
Now this does need a world context object so we could just pass in props dot target character.

05:05.850 --> 05:10.410
The next input is the character class so we can pass in target class.

05:10.410 --> 05:13.920
And finally we need the character level and that's target level.

05:15.180 --> 05:23.520
Now this returns us an int 32 so we can store it in a const int 32 called exp reward.

05:26.080 --> 05:28.450
Like that and I'll go ahead.

05:28.450 --> 05:34.150
And now that we know the XP reward, we can send a gameplay event.

05:34.270 --> 05:43.360
Now the gameplay event is on you Ability system Blueprint library and the function is called send gameplay

05:43.360 --> 05:46.780
event to actor, same as the one we used in Blueprint.

05:46.930 --> 05:53.470
Now it needs to know what actor to send this gameplay event to and we're going to send it to the source

05:53.470 --> 05:54.210
character.

05:54.220 --> 05:56.140
That's the character causing damage.

05:56.140 --> 05:59.080
That's the one that needs the XP reward.

05:59.200 --> 06:03.250
The XP reward itself came from the target that got slain.

06:03.280 --> 06:06.940
Now we're going to send the event to the attacker, the source character.

06:06.940 --> 06:09.640
So it's going to be props dot source character.

06:09.730 --> 06:11.230
That's the target.

06:11.770 --> 06:16.210
Now a gameplay tag will be used for this event.

06:16.240 --> 06:20.230
That's the tag that our ability will be listening for.

06:20.230 --> 06:24.780
And remember, we set this up to use that tag for the meta attribute.

06:24.790 --> 06:26.810
So we need to get that tag.

06:27.140 --> 06:30.770
So I'm going to make a const for a gameplay tags.

06:32.180 --> 06:38.720
So that can be const, it can even be a const reference and we can call this gameplay tags and I'm going

06:38.720 --> 06:42.410
to use F or a gameplay tags get.

06:44.160 --> 06:52.440
And then the tag will pass in will be gameplay tags dot attributes meta incoming exp.

06:53.100 --> 06:56.880
Now the last input is an gameplay event data.

06:57.210 --> 07:02.640
We need to make one of these because we have to send through the magnitude that our ability is going

07:02.640 --> 07:08.610
to use for a set by call or magnitude on our event based effect.

07:08.610 --> 07:12.450
So we need to make an gameplay event data called payload.

07:12.480 --> 07:13.650
Let's do it.

07:13.680 --> 07:22.440
So F gameplay event data, we'll call it payload, and we're going to set a couple things on it.

07:22.440 --> 07:27.900
For one, we're using that event tag on the struct in our ability.

07:27.990 --> 07:34.140
So even though we're sending that tag in send gameplay event to actor, the tag we're sending in the

07:34.140 --> 07:40.350
function call is what our wait gameplay event ability task is listening for.

07:40.350 --> 07:44.890
But then we're taking the payload data and getting the event tag from that.

07:44.890 --> 07:48.610
So we need to set that and that's going to be the same gameplay tag.

07:49.330 --> 07:54.280
So we're setting that and then we're going to take payload and set it to magnitude.

07:54.280 --> 07:56.140
It's called event magnitude.

07:56.140 --> 07:57.520
Now it's a float.

07:57.550 --> 08:00.250
We're going to set it equal to Exp reward.

08:00.370 --> 08:05.590
So we are getting an implicit conversion from INT to float, but no big deal.

08:05.590 --> 08:08.980
And now that we have our payload, we can pass it in.

08:10.970 --> 08:18.500
And with that we now have a function send exp event and we can call that up here in post gameplay effect

08:18.500 --> 08:21.250
execute if the damage is fatal.

08:21.260 --> 08:25.340
So we're going to call send exp event and pass in props.

08:25.970 --> 08:33.740
And as long as everything works, we should see an output log because our gameplay event will be received

08:33.740 --> 08:39.740
by our ability that's listening for it and then our ability will apply a gameplay effect spec to its

08:39.740 --> 08:44.300
owner and it's going to change the incoming XP meta attribute.

08:44.300 --> 08:48.590
And then we'll log that to the output log with our UI log.

08:48.590 --> 08:54.290
So with all that, we're now ready to launch this and try it out.

08:55.540 --> 08:58.150
Okay, so moment of truth here.

08:58.510 --> 09:00.820
We've got everything set up.

09:00.850 --> 09:03.670
I can close this and notify.

09:03.760 --> 09:04.780
We know that.

09:04.780 --> 09:08.680
Listen for event is activated when the event is received.

09:08.680 --> 09:13.900
Though I would also like to print a string to make sure that we're receiving it.

09:13.900 --> 09:19.180
So print string here and I'll just print the event tag from our payload.

09:19.450 --> 09:24.670
So I'm going to get a debug string from the gameplay tag and we'll print that too.

09:24.700 --> 09:31.750
And then if this effect is applied and our meta attribute is changed, we should also see something

09:31.750 --> 09:32.980
in the output log.

09:33.310 --> 09:41.770
So I'm going to press play and open and dock the output log here and then we can slay this enemy we

09:41.770 --> 09:43.390
got standing over here.

09:46.520 --> 09:48.350
And let's see what happens.

09:51.550 --> 09:53.510
Couple more shots should do it.

09:53.750 --> 09:55.880
One more will definitely do it.

09:56.680 --> 10:03.460
And we actually had an assertion it says we should call execute git character class instead of calling

10:03.460 --> 10:05.410
git character class directly.

10:05.410 --> 10:09.460
And that's right, because git character class is a blueprint native event.

10:09.460 --> 10:15.910
So what we should actually do here in send Exp event is call the execute version.

10:15.910 --> 10:17.400
Let's go ahead and do that.

10:17.410 --> 10:25.390
So right here where we're getting our character class, let's just get a combat interface and call execute

10:25.390 --> 10:30.400
git character class and pass in props dot target character.

10:32.150 --> 10:33.170
Like so.

10:33.200 --> 10:35.990
So if you forget, that's okay.

10:35.990 --> 10:39.830
If you try to call a function directly, that's a blueprint native event.

10:39.860 --> 10:46.910
You have to call the execute version here in C plus plus get player level was okay because it's not

10:46.910 --> 10:48.080
a blueprint native event.

10:48.080 --> 10:50.690
So let's go ahead and try this again.

10:51.500 --> 10:52.130
All right.

10:52.130 --> 10:53.450
We can press play.

10:53.480 --> 10:55.440
It says we're listening for events.

10:55.460 --> 10:57.140
Let's kill this enemy.

10:58.600 --> 11:02.080
We have a cooldown, so I can't do this fast.

11:02.320 --> 11:04.240
Okay, so we killed the enemy.

11:05.710 --> 11:08.500
It looks like we did not get an event.

11:08.500 --> 11:11.980
So I'm going to go into my listen for event.

11:12.010 --> 11:13.330
My print string is gone.

11:13.330 --> 11:14.310
That's okay.

11:14.320 --> 11:16.810
Let's see though, if we receive anything.

11:16.810 --> 11:21.610
So I'm going to print a string and say event received.

11:26.250 --> 11:27.870
We'll go ahead and kill this thing.

11:33.270 --> 11:33.630
Okay.

11:33.630 --> 11:35.640
So we did receive an event.

11:35.670 --> 11:38.520
Let's see what that event tag was.

11:39.720 --> 11:43.050
So we'll get a debug string from that event tag.

11:43.970 --> 11:46.280
We'll see if it was the correct tag.

11:51.540 --> 11:52.650
One more should do it.

11:53.990 --> 11:54.350
Okay.

11:54.380 --> 11:56.690
Attributes dot meta dot incoming exp.

11:56.720 --> 12:01.060
So we did get the correct tag and we created an effect spec.

12:01.070 --> 12:08.720
We set a set by caller magnitude and we called apply gameplay effect spec to self getting the ability

12:08.720 --> 12:11.420
system component from the actor info.

12:11.600 --> 12:14.600
So we are applying the gameplay effect.

12:14.630 --> 12:16.850
Let's double check with that gameplay effect.

12:16.850 --> 12:24.590
Looks like it's called event based effect where setting incoming exp we're adding to it using a set

12:24.590 --> 12:25.970
by caller with attributes.

12:25.970 --> 12:27.740
Dot meta dot incoming exp.

12:28.100 --> 12:29.840
So that looks good.

12:29.870 --> 12:36.350
Next, we can make sure that we're actually getting to this point in our attributes set.

12:36.650 --> 12:40.850
So if evaluated data dot attribute is incoming exp.

12:41.270 --> 12:45.950
We can see right here if we reach that so we can press play.

12:47.240 --> 12:49.250
And we can try once again.

12:54.910 --> 12:56.140
One more should do it.

12:57.270 --> 12:57.750
Okay.

12:57.750 --> 13:00.000
And we are reaching this far.

13:00.120 --> 13:06.900
So we know that incoming XP is being set and we should see that UI log.

13:06.900 --> 13:13.230
So I'm going to remove that breakpoint and resume and take a look at the output log.

13:14.360 --> 13:16.610
And I'm going to search for log ora.

13:17.220 --> 13:22.770
And there it is, incoming XP 2020, 2020 and in GA.

13:22.800 --> 13:23.790
Listen for event.

13:23.820 --> 13:25.950
We could even see that magnitude.

13:26.190 --> 13:30.660
If we print that as a string, let's give that one a try.

13:35.340 --> 13:37.380
One more, maybe two.

13:38.350 --> 13:39.790
Okay, one last one.

13:39.940 --> 13:40.870
There we go.

13:40.870 --> 13:46.660
And 20 So we are receiving that event that's working.

13:46.660 --> 13:49.300
So I don't need that print string anymore.

13:50.180 --> 13:51.410
We can remove that.

13:51.410 --> 13:53.540
I don't need this print string anymore.

13:53.960 --> 13:59.150
Make sure it's event received hooked up to a sign tag set by color magnitude.

13:59.150 --> 14:00.380
That looks good.

14:00.380 --> 14:04.670
And I don't need my UI log right here.

14:05.810 --> 14:06.320
Excellent.

14:06.320 --> 14:10.160
So things are all tied together almost.

14:10.190 --> 14:16.670
We know that in the case of causing fatal damage, we're getting this incoming exp.

14:16.700 --> 14:18.410
Meta attribute set.

14:18.440 --> 14:25.190
The last piece of the puzzle is to actually set the exp on the player state and then we should be able

14:25.190 --> 14:29.220
to set up listening for that change updating in the HUD.

14:29.240 --> 14:35.930
So a couple things left and we'll have exp working and then we'll start working on leveling up.

14:36.660 --> 14:39.360
Excellent job and I'll see you in the next video.
