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
€93.84
List Price:  €131.38
You save:  €37.54
£80.95
List Price:  £113.34
You save:  £32.38
CA$137.04
List Price:  CA$191.86
You save:  CA$54.82
A$154.99
List Price:  A$216.99
You save:  A$62
S$136.27
List Price:  S$190.79
You save:  S$54.51
HK$783.50
List Price:  HK$1,096.94
You save:  HK$313.43
CHF 91.19
List Price:  CHF 127.67
You save:  CHF 36.48
NOK kr1,101.37
List Price:  NOK kr1,541.96
You save:  NOK kr440.59
DKK kr700.13
List Price:  DKK kr980.21
You save:  DKK kr280.08
NZ$169.21
List Price:  NZ$236.90
You save:  NZ$67.69
د.إ367.23
List Price:  د.إ514.14
You save:  د.إ146.90
৳10,965.37
List Price:  ৳15,351.96
You save:  ৳4,386.58
₹8,334.23
List Price:  ₹11,668.26
You save:  ₹3,334.02
RM477.95
List Price:  RM669.15
You save:  RM191.20
₦125,683.43
List Price:  ₦175,961.83
You save:  ₦50,278.40
₨27,806
List Price:  ₨38,929.52
You save:  ₨11,123.51
฿3,703.32
List Price:  ฿5,184.80
You save:  ฿1,481.48
₺3,259.92
List Price:  ₺4,564.01
You save:  ₺1,304.09
B$516.59
List Price:  B$723.25
You save:  B$206.66
R1,923.67
List Price:  R2,693.22
You save:  R769.54
Лв183.31
List Price:  Лв256.64
You save:  Лв73.33
₩137,775.97
List Price:  ₩192,891.88
You save:  ₩55,115.90
₪378.18
List Price:  ₪529.46
You save:  ₪151.28
₱5,754.62
List Price:  ₱8,056.70
You save:  ₱2,302.07
¥15,478.45
List Price:  ¥21,670.45
You save:  ¥6,192
MX$1,711.89
List Price:  MX$2,396.72
You save:  MX$684.82
QR364.36
List Price:  QR510.13
You save:  QR145.76
P1,383.88
List Price:  P1,937.49
You save:  P553.61
KSh13,448.65
List Price:  KSh18,828.65
You save:  KSh5,380
E£4,807.48
List Price:  E£6,730.67
You save:  E£1,923.18
ብር5,687.89
List Price:  ብር7,963.28
You save:  ብር2,275.38
Kz83,485.81
List Price:  Kz116,883.48
You save:  Kz33,397.66
CLP$95,253.47
List Price:  CLP$133,358.67
You save:  CLP$38,105.20
CN¥724.60
List Price:  CN¥1,014.47
You save:  CN¥289.87
RD$5,894.01
List Price:  RD$8,251.85
You save:  RD$2,357.84
DA13,445.45
List Price:  DA18,824.17
You save:  DA5,378.72
FJ$227.71
List Price:  FJ$318.80
You save:  FJ$91.09
Q777.29
List Price:  Q1,088.24
You save:  Q310.94
GY$20,903.54
List Price:  GY$29,265.80
You save:  GY$8,362.25
ISK kr14,104.58
List Price:  ISK kr19,746.98
You save:  ISK kr5,642.40
DH1,013.18
List Price:  DH1,418.50
You save:  DH405.31
L1,782.83
List Price:  L2,496.04
You save:  L713.20
ден5,776.11
List Price:  ден8,086.79
You save:  ден2,310.67
MOP$806.39
List Price:  MOP$1,128.98
You save:  MOP$322.58
N$1,907.39
List Price:  N$2,670.43
You save:  N$763.03
C$3,677.32
List Price:  C$5,148.40
You save:  C$1,471.07
रु13,326.11
List Price:  रु18,657.10
You save:  रु5,330.98
S/368.16
List Price:  S/515.44
You save:  S/147.28
K379.71
List Price:  K531.61
You save:  K151.90
SAR375.04
List Price:  SAR525.07
You save:  SAR150.03
ZK2,580.25
List Price:  ZK3,612.45
You save:  ZK1,032.20
L466.96
List Price:  L653.76
You save:  L186.80
Kč2,370.96
List Price:  Kč3,319.44
You save:  Kč948.48
Ft36,978.60
List Price:  Ft51,771.52
You save:  Ft14,792.91
SEK kr1,088.71
List Price:  SEK kr1,524.24
You save:  SEK kr435.53
ARS$87,217.91
List Price:  ARS$122,108.57
You save:  ARS$34,890.65
Bs692.87
List Price:  Bs970.05
You save:  Bs277.17
COP$390,680.46
List Price:  COP$546,968.27
You save:  COP$156,287.81
₡50,009.58
List Price:  ₡70,015.41
You save:  ₡20,005.83
L2,466.51
List Price:  L3,453.22
You save:  L986.70
₲740,348.57
List Price:  ₲1,036,517.61
You save:  ₲296,169.04
$U3,852.35
List Price:  $U5,393.45
You save:  $U1,541.09
zł405.43
List Price:  zł567.62
You save:  zł162.18
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.