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
€94.79
List Price:  €132.71
You save:  €37.92
£78.97
List Price:  £110.56
You save:  £31.59
CA$139.89
List Price:  CA$195.85
You save:  CA$55.96
A$153.73
List Price:  A$215.23
You save:  A$61.50
S$134.32
List Price:  S$188.05
You save:  S$53.73
HK$778.26
List Price:  HK$1,089.59
You save:  HK$311.33
CHF 88.57
List Price:  CHF 124
You save:  CHF 35.43
NOK kr1,105.08
List Price:  NOK kr1,547.16
You save:  NOK kr442.07
DKK kr706.99
List Price:  DKK kr989.82
You save:  DKK kr282.82
NZ$170.06
List Price:  NZ$238.10
You save:  NZ$68.03
د.إ367.26
List Price:  د.إ514.17
You save:  د.إ146.91
৳11,906.24
List Price:  ৳16,669.22
You save:  ৳4,762.97
₹8,436.24
List Price:  ₹11,811.08
You save:  ₹3,374.83
RM447.10
List Price:  RM625.96
You save:  RM178.86
₦167,464.25
List Price:  ₦234,456.65
You save:  ₦66,992.40
₨27,687.73
List Price:  ₨38,763.93
You save:  ₨11,076.20
฿3,470.35
List Price:  ฿4,858.63
You save:  ฿1,388.28
₺3,445.98
List Price:  ₺4,824.51
You save:  ₺1,378.53
B$578.68
List Price:  B$810.17
You save:  B$231.49
R1,810.53
List Price:  R2,534.81
You save:  R724.28
Лв185.34
List Price:  Лв259.49
You save:  Лв74.14
₩139,691.42
List Price:  ₩195,573.58
You save:  ₩55,882.15
₪373.67
List Price:  ₪523.15
You save:  ₪149.48
₱5,901.36
List Price:  ₱8,262.14
You save:  ₱2,360.78
¥15,574.86
List Price:  ¥21,805.43
You save:  ¥6,230.57
MX$2,020.46
List Price:  MX$2,828.72
You save:  MX$808.26
QR363.35
List Price:  QR508.71
You save:  QR145.35
P1,355.53
List Price:  P1,897.79
You save:  P542.26
KSh12,948.70
List Price:  KSh18,128.70
You save:  KSh5,180
E£4,969.50
List Price:  E£6,957.50
You save:  E£1,988
ብር12,262.61
List Price:  ብር17,168.15
You save:  ብር4,905.53
Kz91,256.94
List Price:  Kz127,763.36
You save:  Kz36,506.42
CLP$97,119.28
List Price:  CLP$135,970.88
You save:  CLP$38,851.60
CN¥724.58
List Price:  CN¥1,014.45
You save:  CN¥289.86
RD$6,000.34
List Price:  RD$8,400.72
You save:  RD$2,400.37
DA13,341.73
List Price:  DA18,678.95
You save:  DA5,337.22
FJ$227.04
List Price:  FJ$317.87
You save:  FJ$90.82
Q769.16
List Price:  Q1,076.85
You save:  Q307.69
GY$20,834.51
List Price:  GY$29,169.15
You save:  GY$8,334.63
ISK kr13,772.62
List Price:  ISK kr19,282.22
You save:  ISK kr5,509.60
DH995.44
List Price:  DH1,393.66
You save:  DH398.21
L1,819.82
List Price:  L2,547.83
You save:  L728
ден5,825.40
List Price:  ден8,155.79
You save:  ден2,330.39
MOP$798.74
List Price:  MOP$1,118.27
You save:  MOP$319.52
N$1,801.35
List Price:  N$2,521.97
You save:  N$720.61
C$3,666.61
List Price:  C$5,133.40
You save:  C$1,466.79
रु13,462.23
List Price:  रु18,847.67
You save:  रु5,385.43
S/378.10
List Price:  S/529.35
You save:  S/151.25
K400.90
List Price:  K561.28
You save:  K160.37
SAR375.38
List Price:  SAR525.55
You save:  SAR150.16
ZK2,752.36
List Price:  ZK3,853.42
You save:  ZK1,101.05
L471.69
List Price:  L660.38
You save:  L188.69
Kč2,395.79
List Price:  Kč3,354.20
You save:  Kč958.41
Ft38,840.72
List Price:  Ft54,378.57
You save:  Ft15,537.84
SEK kr1,099.74
List Price:  SEK kr1,539.68
You save:  SEK kr439.94
ARS$100,165.56
List Price:  ARS$140,235.79
You save:  ARS$40,070.23
Bs690.96
List Price:  Bs967.37
You save:  Bs276.41
COP$440,690.82
List Price:  COP$616,984.78
You save:  COP$176,293.95
₡50,645.88
List Price:  ₡70,906.26
You save:  ₡20,260.37
L2,517.41
List Price:  L3,524.47
You save:  L1,007.06
₲775,966.15
List Price:  ₲1,086,383.66
You save:  ₲310,417.50
$U4,274.58
List Price:  $U5,984.58
You save:  $U1,710
zł411.21
List Price:  zł575.71
You save:  zł164.50
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.