Status effects

What would be a good way to implement a status effect system, things like decrease attack of increase defense any and all help would be much appreciated :slight_smile:

You can just do them as floats in the player.

On attack, you decrease the float, and increase it when they get a pickup etc…

in the blueprint of the player create boolean like: isWounded then use a conditional to check: IF isWounded is TRUE and when it’s true you will run the DecreaseAttack function, else do nothing. You will need to check the state of isWounded continually with a timer. The timer needs to be set to run when the actor spawns into the world. The timer is similar to the tick function found in the C++ code. you can display the status effect on a hud using UMG or just print it as text using blueprints.

Do not do it with vars if you’re planning on having more than 10 statuses.

Look into how actor components work.

  • create a base actor component
  • create a bunch of inherited components off that base (fire / poison / HP regen …)
  • each component encapsulated status effect logic (fire spreads, poison ticks, health replenishes …)
  • when a comp is created, give it to a world entity (player / mob / world prop)
  • the comp reaches out to its owner and modifies what’s needed there
  • the comps can destroy themselves or something else can remove them

It’s highly scalable and easy to maintain in the long run.

And nothing stops you from having multiple similar effects affecting the target simultaneously - stacking. You absolutely can have 3 different speed reductions active, each with different duration. That’s not something you can do with a bool / float.

4 Likes