When should a modifier be added to the player?

Hi,
I am making an auto-battler game and i have the following question.
I have a list for all modifiers (Stat Modifiers present at the player).
When an ability triggers the event of the addition a modifier to the player should I immidietly add this modifier to his list or should I temporarly add it to a waiting queue and then add it to the player at start of the Update (or any predetermined stage, e.g After AutoAttack method, or after damage calculation). Is there any concern doing it immedietly after the event was triggered? Maybe during the damage calculation if I am unlucky and the event happens while a stat is read, i dont know…

Nobody has any idea about the architecture of your game in particular except you. Is there some good reason in your code that it should need to wait until Update?

I guess no, I just asked if it was a standard practice

The thing is that systems like this are almost always bespoke to an individual game and every bespoke system is going to have its own quirks and such. Something applicable to someone else’s stat system is not likely to be applicable to your system.

2 Likes

Think of the architecture your game as like cooking. Some cooking you can kinda throw all the stuff in one pot and stir while you heat and it comes out pretty good (veggies and egg for example).

Other stuff needs to be done in stages, mixed specially, then set aside, more spices added, more cooking, then liquids stirred, mixed together, etc. Think curried meats for instance.

How your combat system works is as @PraetorBlue says totally dependent on your precise design. Keep it simple, keep it quick, get it working. Adding complexity now just because someone told you on the net to do it isn’t useful. Add complexity to solve actual NOW problems, not just as “standard practice.”

If you’re not coding to solve a specific problem, by definition you are simply coding yourself another future problem.

Keep it simple.

2 Likes

Nicely put! I can only add Musk’s quote “The best part is the one that doesn’t exist.” which he used to describe how much rocket design benefits not only from solving existing problems, but also by removing the parts altogether because their mere existence mandates future problems.

From this I can infer that you’re worried about the execution order. First of all, events are synchronous (and atomic), nothing can happen during an event, an event can’t “happen while a stat is read”. Second, Update is also synchronous, you can find the exact timing order in the docs. So, you as a designer of the system have absolute control over when exactly things will happen. And as others said, the way you make these things interact with one another are subject to custom specs, so there are no generic rules to follow.

1 Like