How would I implement this system?

Hello everyone,

I’m making an element system for my game and I wonder how could I implement it efficiently.

Pic to demonstrate:

element

I know I can use if-elseif but I’m looking for something better in case I expanded the amount of elements in there, any ideas?

if you want to change the selected element then use a module that containts all of the elements and call it to swap it depending on the variable.

a little off topic sorry but I feel nature and water should be swapped

1 Like

here you go

--We create an element rotation table where each key is stronger than the value
--Idk if i got this right but for example Fire is stronger than Water
local ElementRotation = {
["Fire"] = "Water",
["Water"] = "Nature",
["Nature"] = "Wind",
["Wind"] = "Fire"
}
local YourElement = --Your element here
local EnemyElement = --Enemy element
--now for damage checking whenever u try to deal damage you do :
if ElementRotation[YourElement] == EnemyElement then
--Deal increased damage (your element stronger than enemy's)
elseif ElementRotation[EnemyElement] == YourElement then
--Deal reduced damage (enemy's damage stronger than yours)
end
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.