Alan Aragon
Alan Aragon

Reputation: 1

How to implement a scalable PlayerStats-PassiveSkills-ActiveSkills system

I'm making a game that has a Player with some stats, but I'm adding a system of "Passive Items" that, when obtained, give a boost to the player's stats or even modify their skills to apply extra effects. I came up with several ways to implement it, but I'm a bit undecided regarding scalability, since initially I was thinking of including about 20 items, but it's extremely likely that it will be closer to 100-200 items. I'm also a bit worried about the impact on performance. Currently I have something like this:

PlayerStats.cs: Only has properties that define some relevant values such as health, maximum health, speed, damage, cooldown reduction, armor, etc.

PassiveSkillsController.cs: Has several methods that change the values of some PlayerStats properties, these receive the upgrade level of that stat as a parameter.

SkillHolderController.cs: This script has the logic to take different skills defined in ScriptableObjects and execute them according to the assigned keybinding, but I'm not clear how to implement extra effects to those skills, for example:

SkillHolderController activates EnergyBlast, this skill only fires an energy ball in a straight line that pierces through everything, but if PassiveSkillsController activates the ElectricDischarge skill, EnergyBlast should instantiate a lightning zone upon impact against each target it touches, or if I activate the MultiShot passive, EnergyBlast should fire 2 or more energy balls depending on the level of the upgrade.

This last system is difficult for me to implement it in an efficient way and without repeating so much code, since the easy option I think would be that each skill has its own method defined that reacts according to some PlayerStats values and according to that change the prefab or something like that, but when adding each item it would be necessary to almost completely redesign or change a lot of logic in each of the skills, making it not very scalable.

My goal would be that initially the effects of passive items apply to all skills by default and that I manually decide to do at most an override or something like that if I want some skill to have the passive work differently or not apply the effect.

Upvotes: -1

Views: 30

Answers (0)

Related Questions