So I had the idea of creating functions for the different affixes that can be found on my in-game items. The reason I was thinking of doing it that way is I would run the functions when an item is equipped or un-equipped. Some of the affixes will give general buffs to the player and therefore I need to make sure they’re taken away when the player swaps gear. I figured I would give items a number/type of slots depending on its rarity, and then assign affix functions to those slots at random. It doesn’t look like there’s a way to directly create an array of functions, so does anyone have any suggestions on how this can be accomplished? Thanks a lot.
Consider the following setup:
- Create an enumerator for the buff types:
(for a more advanced setup)
Create lists of:
- Create a struct that will hold the details of the buffs:
Create a DataTable and populate it with your buffs. More than one DT if needed.
Basic item setup:
- a struct holding innate item stats (so you can always refer to them)
- another struct that holds the modified values (after the item got buffed)
- an empty array of enums (more than one if needed) that will tell your item which buff(s) it currently holds
When the item is spawned, its base struct is modified by the buff(s) pulled from a DT and saved in the modified struct.
Have a separate blueprint (referenced by the player) that applies the desired condition on the player (player_buffs) when the item is equipped. This blueprint can hold all the actual functions and monitor whether the ability granted by the item can be used.
Other things to consider before you start coding it:
- the order in which the buffs are applied
- ability exclusivity and duplication system
- start thinking about how to save it all
On top of that, you’d need to make the setup inheritance heavy.
Interesting approach. I was doing some digging and talking to someone on a Facebook group and came up with the following solution. Opinions are welcome.
*Create classes for the affixes, with a boolean for the class being “active” or not.
*Create variables for gear that essentially act as slots. 2 Slots for uncommon, 3 for rare, etc.
*When an item rolls it’s rarity, it fills the appropriate number of slots with the classes.
*When the player equips said item, it sets the classes to “active,” applying the bonuses.
I may give that method a try. My only question is, how can I make sure that multiple items can reference the same affix classes simultaneously? I’m quite sure two pieces of armor will drop some day, both with +5 to defense (or whatever), and I want to make sure the bonuses are applied appropriately to both items.