Stuck on a logic about afflictions..

Hello! I’m a little stuck on a logic I’m trying to create. I have an actor component that has all the vital stats of a character like health, hunger, thirst and now afflictions. I have an array of afflictions that the character carries. If I get a new one I just go there and add a new affliction structure to this array (Which is great because in the future I’ll need to save this information and it’ll be much simpler this way). I need to save the information of what will happen to my character if he has that affliction. For example: My character has a headache. I’d like to make his vision blurry from time to time. Where would I save the scenario that this affliction creates for my character? Inside the actor component? A class of the “headache affliction” type (that is, each one separate and with its specific scenarios)? What would be the best practice for this situation? What would be the best object orientation? Ideas? :thinking:

Hey again @Vinicius_Pires!

I would say you’re on the right track, having it be on the actor component. You can do a check to make sure it’s a player vs an AI as well, so you can have different reactions. For instance, the player gets blurry screen but enemies stagger.

I’d say have a function for each that does something unique per affliction.

Hope that helps!

1 Like

Look into Gameplay Tags. You can think about them as advanced enumerators. They have functiuons to compare, partially match, containers (like arrays of them) that you can check if matching tag is there etc.

That with your component idea should be right what you need.

You can component that translates gameplay tag for affliction, into tag for visual effect. Then there is switch on gameplay tag that you can use to apply effect.

2 Likes

Hello! @Nawrot Thanks for the answer! :slight_smile: :pray: :v:

Yes, it’s a great idea. In fact, the tags allow booleans to be displayed in the .ini. However, the big problem I wanted to avoid is having several functions for each affliction (Lets say about 20 afflictions.) in the same place, making an switch on. If there was a way to separate them into classes, actors with only code without transforms, you know? That would be really nice. Remember that I’m using structures and some variables within these structures will change, so I couldn’t use data assets… I’m still thinking of a way but gameplay tags are a good start. Any ideas? :thinking:

Hello again! :rofl: Thanks for the reply. Now the problem is different! :rofl: :v:

As @Nawrot mentioned, gameplay tags seem great but I would still have the big problem that I wanted to avoid, which is having several functions for each affliction in the same place. If there was a way to separate them into classes, actors with only code without transforms, you know? Everything would be nice and organized. Remember that I am using structures and some variables within these structures will change so I could not use data assets. I wanted to have the afflictions separated with each one having its function without leaving a switch (at least as much as possible) to avoid spaghetti nodes if i have more then 20 diferent afflictions. :thinking:

Because of your post here, i started watching tutorials about Gameplay Ability System.
And that is best solution to all that stuff.

Ps.
For organizing code you can split it all into two classes: parent character class and its inherited child class. For eg. i create parent class that has all animations, movement code etc. Then i create multiple child classes for different skeletons (realtime retargetting), and for swapping clothing heads hair etc (great for that is mutable plugin).

So you could do base class with most code, then child class with ability system.

As Nawrot mentioned, the GAS is meant for this- but you don’t HAVE to learn it.
Keep in mind you can nest functions

timer event

Event_CheckAfflictions

f_CheckAfflictions

check Afflictions does:

f_headacheCheck
f_poisonCheck
f_burnCheck

Then each affliction could use some simple code they share:
Is (array member for this affliction) true?
if true: do unique action.