So my idea for a game is to have 3 slots for elements (fire, water, earth, etc) that the player chooses before entering a dungeon. you can combine these elements to cast a spell for example (fire, fire, fire) would cast a giant fireball, (water, water, earth) will cast a wall of water, and (fire, empty, empty) will make a small fireball. If you played Dota 2 with invoker you will know what I mean (but it’s not always 3 elements, it could be just 1 element or 2 for casting a spell).
What I made it was making a Enum of the elements and the Player has an array with 3 slots. When the player tries to cast a spell (say fire, fire, water) I order the array by positions as the Enum. Then compare with a data list with all the possible spells. The data list of spells has to be in order to create a new spell in the future. So I think I’m doing everything a mess. Any suggestions on what could I improve? I feel like there’s already a blueprint that does this (compare my 3 slots of elements with a list of all spells) but I can’t find it.
Thank you for reading it
Where element = a number. (ex. Earth=0, Air=1, Fire=2, Water=3)
If you have 3 characters such as 012.
There are 6 possible combinations? 012 102 120 021 201 210
You can use Get Character Array From String
then use Get to make all 6 combinations, and put them in an array.
Now you have an array like: 012,102,120,021,201,210
.
For each in array, see if there is a matching recipe in your table.
Now 330 will match a recipe of 303.
Creating array…
I’d make a function with a string input, then the output is an array with all combinations.
I have made a similar system before,my solution is not that clean but is fast, i only had 2 slots but it can easily be adapted to 3 slots, i numbered the elements 0, 1, 3 so that if you add up the elements in the slots every combination will have a unique id,
0+0 = 0
0+1 = 1
1+1 = 2
0+3 = 3
1+3 = 4
3+3 = 6
For you with 3 slots it would have to be 0, 1, 4, 13
I used the sum as key for a map with all the spells