Enemy - Script #2

17 minutes
Share the link to this page
Copied
  Completed
You need to have access to the item to view this lesson.
One-time Fee
$99.99
List Price:  $139.99
You save:  $40
€95.85
List Price:  €134.19
You save:  €38.34
£79.54
List Price:  £111.35
You save:  £31.81
CA$143.73
List Price:  CA$201.23
You save:  CA$57.50
A$159.93
List Price:  A$223.91
You save:  A$63.97
S$135.54
List Price:  S$189.77
You save:  S$54.22
HK$777.83
List Price:  HK$1,089
You save:  HK$311.16
CHF 89.34
List Price:  CHF 125.09
You save:  CHF 35.74
NOK kr1,131.88
List Price:  NOK kr1,584.68
You save:  NOK kr452.80
DKK kr715.08
List Price:  DKK kr1,001.15
You save:  DKK kr286.06
NZ$176.75
List Price:  NZ$247.46
You save:  NZ$70.70
د.إ367.26
List Price:  د.إ514.18
You save:  د.إ146.92
৳11,945.33
List Price:  ৳16,723.94
You save:  ৳4,778.61
₹8,493.77
List Price:  ₹11,891.62
You save:  ₹3,397.85
RM450.75
List Price:  RM631.07
You save:  RM180.32
₦154,938.50
List Price:  ₦216,920.10
You save:  ₦61,981.60
₨27,824.38
List Price:  ₨38,955.25
You save:  ₨11,130.86
฿3,419.79
List Price:  ฿4,787.84
You save:  ฿1,368.05
₺3,519.01
List Price:  ₺4,926.76
You save:  ₺1,407.74
B$608.53
List Price:  B$851.97
You save:  B$243.44
R1,830.80
List Price:  R2,563.19
You save:  R732.39
Лв187.32
List Price:  Лв262.25
You save:  Лв74.93
₩144,627.53
List Price:  ₩202,484.33
You save:  ₩57,856.80
₪365.39
List Price:  ₪511.57
You save:  ₪146.17
₱5,882.91
List Price:  ₱8,236.31
You save:  ₱2,353.40
¥15,643.93
List Price:  ¥21,902.13
You save:  ¥6,258.20
MX$2,007.58
List Price:  MX$2,810.70
You save:  MX$803.11
QR364.41
List Price:  QR510.19
You save:  QR145.78
P1,381.63
List Price:  P1,934.33
You save:  P552.70
KSh12,923.70
List Price:  KSh18,093.70
You save:  KSh5,170
E£5,087.81
List Price:  E£7,123.14
You save:  E£2,035.32
ብር12,764.56
List Price:  ብር17,870.89
You save:  ብር5,106.33
Kz91,790.82
List Price:  Kz128,510.82
You save:  Kz36,720
CLP$98,905.10
List Price:  CLP$138,471.10
You save:  CLP$39,566
CN¥729.56
List Price:  CN¥1,021.42
You save:  CN¥291.85
RD$6,087.13
List Price:  RD$8,522.23
You save:  RD$2,435.09
DA13,485.25
List Price:  DA18,879.89
You save:  DA5,394.64
FJ$231.62
List Price:  FJ$324.28
You save:  FJ$92.66
Q770.23
List Price:  Q1,078.35
You save:  Q308.12
GY$20,913.67
List Price:  GY$29,279.97
You save:  GY$8,366.30
ISK kr13,911.60
List Price:  ISK kr19,476.80
You save:  ISK kr5,565.20
DH1,006.07
List Price:  DH1,408.53
You save:  DH402.46
L1,836.70
List Price:  L2,571.46
You save:  L734.75
ден5,900.06
List Price:  ден8,260.33
You save:  ден2,360.26
MOP$800.26
List Price:  MOP$1,120.39
You save:  MOP$320.13
N$1,840.36
List Price:  N$2,576.58
You save:  N$736.22
C$3,678.42
List Price:  C$5,149.94
You save:  C$1,471.51
रु13,597.49
List Price:  रु19,037.04
You save:  रु5,439.54
S/372.23
List Price:  S/521.13
You save:  S/148.90
K405.36
List Price:  K567.52
You save:  K162.16
SAR375.62
List Price:  SAR525.88
You save:  SAR150.26
ZK2,766.46
List Price:  ZK3,873.15
You save:  ZK1,106.69
L477.10
List Price:  L667.96
You save:  L190.86
Kč2,408.98
List Price:  Kč3,372.68
You save:  Kč963.69
Ft39,689.03
List Price:  Ft55,566.23
You save:  Ft15,877.20
SEK kr1,103.13
List Price:  SEK kr1,544.43
You save:  SEK kr441.30
ARS$102,160.40
List Price:  ARS$143,028.65
You save:  ARS$40,868.24
Bs690.76
List Price:  Bs967.10
You save:  Bs276.33
COP$435,928.80
List Price:  COP$610,317.76
You save:  COP$174,388.96
₡50,434.81
List Price:  ₡70,610.75
You save:  ₡20,175.94
L2,537.51
List Price:  L3,552.62
You save:  L1,015.10
₲779,455.88
List Price:  ₲1,091,269.42
You save:  ₲311,813.53
$U4,474.38
List Price:  $U6,264.31
You save:  $U1,789.93
zł408.66
List Price:  zł572.14
You save:  zł163.48
Already have an account? Log In

Transcript

All right Welcome back everyone in the last video we created some variables inside of our BP enemy character here located in this directory and we also expose them to our level editor by placing our character into the level and with our player character placed into level we had set all of these variables inside of our BP enemy character base to have these particular variables be instance editable, meaning we can get to them from the main level editor now we are going to create a macro inside of our BP enemy character base to utilize a bunch of these variables we just created. So with your BP enemy character base open, come along the My Blueprint panel and we've got a section here for macros. What is a macro Willie macro is a lot Like a function in many ways in which you can have a node one single node do a lot of stuff.

But it's different from a function in that a function can only have one input execution pin and one output execution pin. macros can have multiples also inside of a macro, you can put in things like delay nodes, which you cannot put into a function node. Now I want to create a macro here because the series of scripts that I'm going to be writing is going to result in having a multiple output execution pins. So let's come under macro, click this plus button to create a macro. And I'm going to call this one calculate. damage that is what is going to happen between our input node here in our output node.

Notice that once we created this, we added a new tab across the top. create some space between your input and your output node because We're gonna need it and we're gonna start off by creating some inputs. So select this input node right here and over in your Details panel, click this plus button three times to create three new inputs. The first input we are going to create here is just going to be called exec in. And this is simply going to be an executive pin. You've seen that and execution pin right there.

The next one we're going to create is going to be called incoming base damage. This will be a float variable. And the next one we're going to create here is going to be called incoming damage type. And this is going to be of the damage type. And if you do a search for it in the variable type damage Damage type, we're looking for an object reference here. And so now you see these pins populated here in our calculate damage macro.

Now we will be making use of this macro in our Event Graph eventually. And let me just jump over to my Event Graph really quickly. And if I drag in my calculate damage macro, and I'm zoomed way out, you can see what it's currently going to look like when I begin to utilize this in the Event Graph. We've got some input pins here for exact in incoming base damage and incoming damage type. So we're going to be plugging some stuff into it on this side of the node. So now let's jump back to our calculate damage macro.

Let's work on adding some outputs here. So we're going to be doing some math in between all of these and determining if our character or enemy character is resistant or vulnerable. To the given incoming damage type, and then we're going to be determining how much damage should be applied. And based on all of that we're going to have different potential outcomes. So under outputs, click the new parameter 12345 and six times and we will name these accordingly vulnerable death and this is going to be an exact pin. In fact, all of these are going to be exact pins, then I'm going to set another one too vulnerable, damaged.

This is gonna be an exact pin, and I'll explain why we're creating all these in just a little bit resistant. Death and I got to spell this right that's not intelligent, otherwise resistant damage. Let me just set these all to exact right away. And then down below in slot number five, here we got normal death and normal damaged. So we're going to be receiving some damage given float value is as well as a damage type. And based upon all that math and the damage type, we're going to fire out of one of these output pins.

And if I jump back to my Event Graph, depending on how much damage we received, and if we were vulnerable to it or resistant to it, we can spawn in different particle effects and either destroy the actor or not. So that is going to be pretty handy. Let's jump back into our calculate damage macro here. And what are we going to do first out of our inputs, so let's drag out Out of are actually let's not drag out of our exec in. The first thing I'm going to do is I am going to drag our incoming a base damage variable here, drag it in, we're going to set it and by default This is zero and the reason this is zero is because we're going to set it to be whatever our incoming base damage is like so. Okay, and our incoming damage type, we're gonna drag out of this, and we're gonna type in get class.

Okay, and we're going to find out the incoming damage type. We're going to drag in a damaged, vulnerable class, we're going to get the vulnerable class. And I'm going to drag out of here and type in the equal symbol and I want to see equal to class I want to find out if the damaged vulnerable class is equal to that is the same as the incoming damage type. If it is, we're going to bring in a branch. If it is, we're going to calculate damage in a certain way. And if it's not, we're going to calculate damage in a certain way.

Okay, let's just stay right here for a moment. Because I'm also going to bring in my damage resistance class right here, drag and drop that in, we're going to get that. And I'm going to drag off of my get class pane here, and bring in a nother equal class node equal class. And we're going to find out if our class is equal to the damage resistance class. And if that is the case, we're going to bring in a nother branch node like so. And our false branch from this top one is going to plug into the input input of this branch note right here.

So at this point, this is the script you should have Might want to pause the video here if you need to. Okay, and at this point, we can say like, Hey, where are we going to be getting this base damage from and this incoming damage type? Well, while we're here and we've got our BP, electric, spark and BP fireball open, let's jump into each of those. I'm gonna jump into BP electro spark first in our BP electro spark script, we're gonna find out if this particular collision component, f right there that that wireframe right there we're going to be checking to see if that's overlapping something. In this case, we're going to see if it's overlapping, our enemy character. If the enemy character the other actor is overlapped, we're going to apply some damage.

How much damage well we're going to apply the amount of damage that are electro spark attributes specifies also in I missed this in this video, when we put it together, we should plug in this damage type from here to this apply damage node. Now eventually not quite yet, we're going to be using a damaged event inside of our enemy character to receive and pass on all this information. Okay? So make sure here in your BP electoral spark that you've hooked up your damaged site right here to the apply damage node down here I missed that in the previous one I bet I did that in the fireball as well. So jumping over to my BP fireball, how much damage is our firewall going to do? We're gonna pass that to this apply damage function and our damage type here too.

I forgot that we got to plug this into our damage type class. You should Compile and Save that both in the BP fireball and your electrical Spark. Okay, and with that, let's jump back to our BP enemy character base. Now what kind of math are we going to do if the incoming damage type is equal to our damage vulnerable class if this evaluates to true, what we're going to be bringing in this series of nodes, we're going to be bringing in our incoming base damage, we're going to get that then we are going to be bringing in our vulnerable multiplier, I'm going to hold down Ctrl, left click and drag in to automatically bring in a getter for that. And I'm going to multiply these two together. So dragging off of one, this is going to be a float multiplied by float.

Gonna kind of make these all snuggy Okay, and then I'm gonna bring in my health variable going to control hold down Control, left click and drag so we can get that and I'm going to drag off of health and bring in a subtract, float minus float node. So we're going to take our health which is 100, and we're going to subtracted by whatever our incoming base damages, which gets set here and multiplying that by our vulnerable multiplier. So if our incoming base damage starts off at 50, which our fireball normally does, we're going to take our vulnerable multiplier times two, which equals 100. And we're going to subtract that from our health. And then we are going to set our health. So I'm just going to drag and drop our health on top of this output right here and that's going to bring in a center, square away, okay, and I want to bring in this wire now this execution wire from our true branch all the way up to this center.

And let's double click to bring in a little reroute node to make things look a little nicer. Okay, so, so far, so good. Something else I want to do is I'm going to drag off this center and bring in a print string node because I want to see some of this Some of these health values output to the screen so I can be sure that the math is behaving like I expected to dragging out of my health into my in string, that'll bring in a little conversion node. And then lastly, I want to do a little evaluation on the health I'm going to drag off of this health and safety if it is less than or equal to float less than or equal to float. If it's less than or equal to zero. I'm gonna bring in a branch node.

Like so. And I'm gonna say if it is less than or equal to zero, that means we have killed the player, right? So I'm going to say out of this true branch, if this evaluates to true, we're going to fire out of the vulnerable death output. If that is false, we're going to say, yeah, the enemy was vulnerable to this. But they were just damaged they did not die. Okay.

So if you need to pause the video here to get the This little bit of script now would be a good time to do so. Okay, now the good news is we can copy and paste this section of nodes right here for the next evaluation we're going to do so I'm just left clicking and dragging, I'm gonna hit Ctrl C right here. And then I'm going to come down here and do Ctrl V, to kind of move these into position. And out of this branch right here, if our incoming damage type is equal to our damage resist class, if this evaluates to true, I'm going to plug this true into this health sector. Then we're going to do some more math. The only thing I need to change here is we're getting our incoming base damage, but instead of the vulnerable multiplier, I'm going to delete that out and bring in our resist multiplier.

Okay, so that's the math we're going to do if Our incoming damage type is equal to our damage resistance class. If that is true, we're going to do all the same math. And here we're going to take the true branch that if that kills the player, we're going to say we should fire out of the resistant death output. But if it has not killed the player, we're going to fire out of the resistance damage output. Okay, then I'm going to make sure I've got all these nodes highlighted like I did before, which I already actually have them highlighted, but you can left click, drag Ctrl C again, we're going to come down here a little bit lower, I'm going to Ctrl V. And we are going to bring in off of this false branch right here. If our incoming damage type is not equal to our damage resist class, I'm going to take our false out of this branch, type it into plug it into our health now type it in, bring it a little reroute note here, but I do need to make a little modification down here as well.

Specifically, right here we got this incoming base damage and the resist multiplier. I can delete out this multiplier and this resistant multiplier and I simply want to take our health in subtract the incoming base damage, so no resistance multiplier, no vulnerable multiplier and then our branch here if the incoming base damage does result in our health dropping below zero we're going to say they received a normal death and if it did not, then we're going to say they were damaged they did not die. Okay, let me just kind of frame this all up so you can see this Mundo macro that we have just put together maximizing our screen space here. Okay, so take special notes as to where every note is double check all those wires make sure everything is hooked up as it is here. Let me just kind of go through it slowly from up to the top this is for if they're vulnerable.

Okay, this is if they are resistant, that is true. And lastly, if they are not resistant or vulnerable for that case, we're going to go on to this bottom false branch. Take our health simply subtract the incoming base damage And go out of that output as well. Okay with that guys, let's Compile and Save. We are not done yet with this macro in the next video we're going to put it to good use. So that'll do it all for this one.

See you in the next one

Sign Up

Share

Share with friends, get 20% off
Invite your friends to LearnDesk learning marketplace. For each purchase they make, you get 20% off (upto $10) on your next purchase.