Hello. I’m trying to create passives system for character and stuck with one thing. For example I have passive skill which grants me +3 to Strength and Dexterity parameters. So I created struct:
But how to store effects? Just to use array of strings? And how to implement it in game? I’m keeping all the parameters in GameInstance. So, if I have 100 passives, do I need to check for every passive if it’s acquired every time when I’m calling “begin play” event? I would like to just pre-construct all passives and get their effects automatically according to boolean variable. Is it possible?
If I’m understanding you correctly (apologies if I’m not), you’re just asking how to efficiently have your player access their buffs during runtime. You don’t want to cycle through all 100 at the start of each game, you want it to be initialized already. Based on that, here’s what I’d reccomend:
When the player starts a new game, they logically wouldn’t have any buffs. Therefore, there is nothing to predetermine.
When the player unlocks a buff, apply it directly to their stats. In other words, check the PassiveAcquired Boolean value, but also add +3 directly to their strength and Dexterity. You’ll need to add an int or float (whichever is appropriate) to the struct to represent the value.
If the player is able to lose the passive, make sure to also remove it from their stats when they do.
Track the player’s current stats and their current passives in a save file.
When they start the next game, grab that info from the save file. It is now predetermined.
If I completely misunderstood what you were asking, just let me know. I hope this helps.
Yes, you’re almost right, just one thing is incorrect - in my case player can not lose the passive. You have describe all other things correctly and I already did everything you mention. There is one problem: how to apply passive’s buff directly to character? Yes, I can add to character BP something like “if passive1 acquired then cast to GameInstance, get Dexterity, add +3 to that parameter, set new value to that parameter, done”. But for 100 passives I’ll need to do that 100 times and there can be passives with a few effects, so I’m looking for more effective way.
Are they getting 100 at a time? If they only get one passive at a time, then you just apply that passive to their stats when they get it. Instead of the playwr cycling through the list of passives, the passive should send information to the player
I would still say the same thing. When the player obtains it, it does all the logic. Thats the best I can do without a very detailed breakdown of how this is supposed to work