#status effects

1 messages · Page 1 of 1 (latest)

rare night
#

I'm not sure SOs are the right choice for the actual status effects. They don't correspond to assets on disk, do they?

#

I guess you can just create them at runtime -- I almost exclusively use them for data that lives in an asset on disk

stable elk
#

when you say it lives in an asset on disk, do you mean that they are already like, being held by some game object when you run the game?

rare night
#

so, for example, I have a ScriptableObject type for consumable items

#

they store all of the data needed to describe the item

#

I used to also store the actual effects as SOs, but I realized that I was very rarely sharing these between two items

#

so I just made them plain old C# classes and stored them in a [SerializeReference] list

rare night
stable elk
#

yeah, the way I am theorising would be, an enemy would have an ability component, if it applies 'poison' it holds and passes the scriptable object for the debuff "PoisonDebuffSO" to the target, the target would then add that SO to it's status list, on add it applies any stat effecting values, and then if there is an OnTick function, (this would be the c# class I think) it runs the damage effect.

It would be the same for like a heal over time, like a RegenerateSO, or a RageSO would both have the onTick, to say Decrease Rage value, and the static buff would be applied like a +25 STR.

I just wasn't sure how to best approach the uhh, situation where these abilities may be able to stack on each other

#

I say theorising, most of that is done

rare night
#

yeah, and the exact implementation doesn't really matter when it comes to stacking

#

I last dealt with this on...uh, a game I helped briefly with like 5 years ago, and it was mega spaghetti

#

so whatever I did then would probably not work, lol

#

I'd definitely give each kind of status effect a "stackable" flag

stable elk
#

yeah I've been trying to avoid that, I moved recently to Unity from GameMaker, and my stat code there was functional but very very messy, so I've been reworking my approach this time

rare night
#

it should then have a Stack method that takes the new instance and updates itself

#

that way, each kind of effect can handle that in its own way

stable elk
#

yeah okay that sounds like what I was thinking

rare night
#

some effects might be complex

stable elk
#

so like a poison status, you'll only ever have one, but its data is adjustable for stacking

rare night
#

e.g. an effect that builds up, and if it hits a threshold, it deletes itself and adds a new status effect

stable elk
#

oh yeah

#

I think with the way I add/remove stats it should actually be pretty good to handle that

icy hare
#

stacking can get complex as it depends on how you want that type of effect to stack . . .

rare night
#

I think the most general idea here would be to ask every effect if it wants to stack a new effect

so, suppose you could build up a Curse effect, and when it got to 100 stacks, it became a Cursed effect: and the Cursed effect should silently eat any new Curse instances

#

but that might be going too far into the weeds

icy hare
#

what if you can stack 3 times but limit the max effectiveness, like 30% max?

stable elk
#

I think it would be yeah, when the status goes to apply, the IsStackable() in the SO would say, no don't stack me, and the status manager would just drop the process there

#

so it would silently drop it i suppose

stable elk
rare night
#

oh yeah, that's another dimension to consider

#

Oh right! I did something like this in another game once

icy hare
rare night
#

I never merged effects together. I just had a big list

#

Every effect has a big pile of methods to modify various things

#

e.g. an effect could be asked to modify incoming melee damage

#

most of the time, the effect just did nothing

#

but each effect would have its own special behavior in a few places

#

so the melee defense buff would override that one method and reduce the melee damage number

#

however, you probably don't want to display 300 copies of the same small buff in the status bar..

stable elk
#

HAHA, that is interesting though

rare night
#

that was a Typescript game, lol

#

I am about to go implement status effects in a new game, so I guess I'm about to figure this one out too, lol

stable elk
#

its rough, I just wanted to make a nice tower defense, but then cool towers means status system

#

BUT, this code will probably be used anywhere I use a status system once I get it all cleaned up

rare night
#

I guess that I would do a sort of two-pass system. Each entity has zero or more status effects, which each have their own rules for stacking

#

Then, once you have a list of active effects, you compute the actual consequences

#

so if you decide you should never be able to get more than 50% fire resistance, you clamp that at the second step

stable elk
#

Yeah, when it calls to see if it even stacks, you can say 'is the stackable flag on, and is the current value + new value greater than max value

#

If there is a max value

icy hare
# rare night they store all of the data needed to describe the item

@stable elk i believe this a good approach whether an ability, spell, or (item) effect system. you'd store a list of effects with the corresponding stat and its value. i did smth similar a long time ago that i'm in the process of creating a complete system for, except i use SOs instead of an enum for the stat and type . . .

stable elk
#

thanks y'all for the convo! It was really helpful best of luck to the both of you