Over the last week, I worked on adding in the different stats that I would be using for both the player and the enemies when in combat. I also worked on adding in damage types that would allow the player to deal more or less damage depending on the element of the attack.
Firstly, I worked on the players stats. I decided to go with 5 other stats to be added along with the stats already in the player (Speed, Mana and health). These stats are Defence, which determines how much physical damage is reduced by, Strength, which determines how much damage a physical attack causes, Intelligence, which determines how powerful magic attacks and healing are, Wisdom, which determines how much magic damage is reduced by, and Luck, which determines the chance of getting item drops and critical hits.
To start, I went about adding these stats into the save data, the overworld character and the combat character. This way, I will be able to save and transfer the stats over to other characters, along with setting any changes made either by stat boosters or from levelling up.
From there, I started to add the stats into some of the action events, along with the player damaged event. The first of these events I worked on was the AnyDamage event, where I added the defence stat and used it to subtract the damage taken before dealing damage to the players health. I also added in a check to see if the enemies damage was less than 0 as I didn't want any errors occurring if that happened. For now, It just prints a print string indicating the damage taken was 0.
Afterwards, I went through all of the attacking and healing actions the player could make, and added in the respective player stat to them, with attacking actions having the stats added to the damage value, and healing actions having the stats added to the add health calculation. I also add space in between the stats and the end node for these calculations to add in more variables and values from buffs and de-buffs when I blueprint them in.
From there, I was planning on adding a second calculation to the player takes damage event where it would determine which type of attack it was. However, I didn't know how I should go about it, so I decided to look up a video on determining damage types and found a pair of videos from Ryan Laley that goes over an entire damage type matchup system, as well as how to cast to that system to determine how much damage a target takes. Using this, I made an initial damage type table and have plans to rework it later.
Links: Unreal
Engine 5 Tutorial - Elemental Damage Table Part 1: The Damage Table (youtube.com)
Unreal
Engine 5 Tutorial - Elemental Damage Table Part 2: Applying Damage - YouTube
To start, I created an enumerator and added in three damage types to it, these being the initial types that I will be using to test the blueprint out.
I then made a new structure and added the enumerator as a variable inside and made it into a mapping variable for later use.
Afterwards, I created a data table using the new structure so that I could determine how each of the damage types would react with one another.
Going back into the new structure, I then went into default values section so that I could add in a base value to each of the damage types, in this case, all of them being 1. This way, the values recorded would be added to the data table without me having to constantly copy the elements from one data set to the other.
From there, I went back into the data table and added some data sets to act as the damage reactions to an element being hit with a different damage type. For this, I would first add in the damage type that is being targeted, then adjusting the values below to determine the multiplier a damage type would deal when hitting a enemy of that element, for example, my current blunt types have a multiplier of 1 when taking damage from any damage types whilst my fire type takes 2 time damage from slashing attacks and half from fire type attacks.
After sorting out the data table, I then went and made some new damage types, one being the base damage type which I would use as the parent for other damage types, and the others being the respective damage types. I then added a variable of the enumerator in for a calculation in a function, with each damage type having the variable match the damage type.
Continuing on, I then created a function library and made a function to calculate the overall damage multiplier based on the element types of the enemy and the damage type of the attack.
To start, I added two pins, one being an enumerator for the incoming damage type and another being a enumerator array for the element types of the enemy, with it being an array for if they have multiple types. I then turned the incoming damage into a string and then a name so that I had an accurate name to be used in a Get Data Table Row node.
This node would allow me to get the data table I made for the damage types and I could insert the converted name into the row pin of the node, allowing it to check if it matches a row in the data table too which I break the structure of the row and get the mapped response of the damage type. If the row is not found then it will simply return as a multiplier of 1.
However, if the row is found, then it will get the enemies elemental types and use the mapped damage response to find the damage multiplier value for each element, this value being based on the data tables response and not the default. I then made a local variable array to store these multipliers and had the values checked before to be true or not. Once all of the values are added, I then used a for each loop of the values and multiplied them with a new local variable, which I set the value to 1, before setting them as the new value of the variable. Finally for the function, I used the results of the variable as the damage multiplier and plugged it into a return node.
After creating the function, I went into my test enemy and made a variable for the element types to be used with the newly created function. I then went to the AnyDamage event I had setup already and casted to the base damage type, that I setup earlier, from the damage type node of the event. Once casted, I then got the damage type of the attack and connected it to the newly created function. I also added a Boolean variable to the base damage type, though this is for a later blueprint.
Once I added the function in, I then went an made the function a Pure function by ticking the Pure box when selecting the function in the library. This allows the function to take up less space and not need as much processing power dedicated to it.
Finally, I connected the damage value into the sequence, with it being multiplied by the damage multiplier to determine the final damage value before dealing the damage.
Over the next week, I will be working on adding the stats the enemies, incorporating more of the stats into different actions/blueprints, and adjusting the damage type table to have more damage types, along with it potentially using monster types, rather than damage types to determine weaknesses.