Welcome back.
So now that we have this concept of damage types, it logically makes sense that we should have a concept
of resistances to those damage types.
Now, here in exec calc damage, we're looping through this array that we've created in aura gameplay
tags called damage types.
And here we can get set by caller magnitudes if they exist in our gameplay effect.
Mapping a damage type tag to some damage value.
But now that we're going to take resistances into account, we're going to want resistance tags and
resistance attributes.
So while we're in this for loop, it'd be really handy if we knew which resistance gameplay tag was
associated with which damage type.
So for that reason it might be a little bit more handy if aura gameplay tags didn't have a damage types
array of gameplay tags, but rather a damage types.
Map of damage types to damage resistances.
Now, if we're going to have damage types and resistances, we're going to need gameplay tags for those.
So the first thing we should do is add our resistances.
Now we only have one damage type and that's fire.
But I'd like to decide all of the different damage types for my project at this stage, and that way
I don't have to keep going back and adding more damage types and more resistances.
Then we can add our resistances to our attribute set as attributes.
So the first step is to add gameplay tags for all the damage types and all the resistances, and then
we can create this team map instead of using a t array.
So let's go to Aura gameplay tags.
I'm going to go ahead and close all other tabs except for calc damage and open up aura gameplay tags.
Here it is and we have damage.
We're also going to want resistances and we'll have one for each damage type.
So we have damage fire.
I'm going to decide on having three other damage types in addition to fire.
I'd like to have damage lightning.
I'd also like damage.
Arcane.
We'll just call this one of those types.
And I'd also like damage physical and that will be for melee and such.
So we have four damage types fire, lightning, arcane and physical.
And these can be sort of the elements, if you will, in this game will have that as a theme, as one
of the character classes is Elementalist a master of the elements right now, since we know that we
need resistances for each of these, let's go ahead and add those gameplay tags here.
Now these are going to be attributes and really they're just secondary attributes, but in case we'd
like to categorize them a little bit differently so that we can sort things by tag preemptively, I'm
going to place them in a different sub category than secondary.
I'm just going to place them in resistances, so I'm going to make an gameplay tag.
Called attributes underscore resistances or just resistance, underscore fire.
And then we can have attributes, resistance, lightning and the others.
So we'll have attributes, resistance, lightning.
We'll have attributes, resistance arcane, and we'll have attributes, resistance, physical.
But again, these are just secondary attributes.
They'll be treated exactly like secondary attributes.
The difference is, well, they're resistances, but that doesn't really mean anything from a technical
standpoint.
It just means something to humans when we want to organize these, much like some of these secondary
attributes are related to combat and others are more related to the vital aspects such as Max Health
and Max Mana and so on.
Now we have damage types and we have resistances.
I really like a t map instead of a t array.
So we can associate all the resistances with the damage types.
So I'm going to change this from a t array to a t map and it's going to map from gameplay tag to gameplay
tag.
So gameplay tag there.
And we can call this damage types to resistances.
Now we need to define all of these new gameplay tags and then make sure our t map has all the tags to
resistances.
So let's go into the CPP file and let's flesh this out.
Now just to make things easier, I'm going to make a multi-line comment here that says damage types
and after damage types, we'll have the resistances.
So we'll say resistances and let's just make sure we have all of these here.
Now first of all, this gameplay tags.
Damage types no longer exists.
Now we have a map.
I'm just going to go ahead and remove that for now.
And in addition to fire, let's add the other three.
So we're going to have one, two, three more damage types starting with damage underscore lightning.
This is going to be for the name damage dot lightning and we'll just say lightning damage type.
Next we'll have damage.
Arcane the name is damage dot arcane comment says arcane damage type and finally damage underscore physical
the name is damage dot physical and the comment is physical damage type.
So now we have all of these damage types.
Now we need the resistances.
So let's go ahead and define those.
So first we have attributes, underscore resistance, underscore arcane, and our name is going to be
and this is very important not to typo here attributes dot resistance dot arcane.
And this will be resistance to arcane damage.
And we're going to want three others, right?
So let's go ahead and just paste it three times and the next one will be, I don't know why I did arcane
first, but the next one can be fire and it will be attributes dot resistance dot fire Comment says
Resistance to fire damage.
Next we'll do lightning.
The tag is attributes resistance, lightning resistance to lightning damage.
And finally we have physical.
Which will be attributes, resistance, physical and resistance to physical damage like so.
And just to separate these, I'm going to have another multi-line comment that says effects.
Now we need to set up this team map.
And I'm just going to set it up right here.
We'll have another multi-line comment that says map of damage types to resistances.
And we'll just go ahead and do all four damage types to resistances.
So we're going to say gameplay tags, dot damage types to resistances dot Add and we're going to add
damage underscore.
We'll just go in alphabetical order here.
Damage Arcane.
And we'll use attributes, resistances or resistance, rather arcane.
Now, we can't just pass these straight in.
We have to use gameplay tags, right?
Gameplay tags dot as this is a static function, so we need to use our actual gameplay tags.
Static variable here.
Now that's going to take care of arcane.
We need to take care of the other three.
So I'm going to paste three times.
One, two, three, and the next one will be damage underscore.
We'll go with lightning.
Mapping gameplay tags Resistance Lightning.
Next we'll do physical again.
Just going in alphabetical order here.
Physical.
And the last one is fire.
And having them all together here shows us that this map here contains the damage types, the resistances.
This is just for convenience so we don't have to go out of our way to figure out or hardcode these relationships.
This allows our algorithms to be more general in the future.
So now that we have gameplay tags for all the damage types and gameplay tags for all the resistances,
we can start implementing resistances.
Now something I have to go back and change is the exact calc because we were looping through that array.
Now we need to loop through the team map so gameplay tags get it now cannot be just damage types but
damage types to resistances.
And now this is no longer a gameplay tag, but a pair of gameplay tags.
So we're going to say auto reference pair and we can remove this damage type tag here.
This can be a const auto pair.
And really, if we want, we can just use its actual type A t tuple.
So for transparency we can do that.
Now we're getting the set by caller magnitude using the damage type.
That's going to be the pair dot key, right?
So we're going to use pair dot key here.
Okay.
So now we're set up.
We have gameplay tags for our resistances.
They're associated with damage types.
What's left is to make those resistances, these ones actual attributes in the attribute set and we'll
do that next.
So great job.
I'll see you soon.