Do all bonuses get recalculated on each hit?


I am watching this lecture here:

if I understand it correctly, all damage modifiers are being recalculated on each hit. is that correct?
I would like to have an entity which has all damage modifiers always available without them needing to be recalculated. Of course, all systems that have to do with equipment and bonuses need to communicate changes when they happen, but I think they’ll happen less often than hits in a hack and slay game :smiley:
which entity would be the best choice to save this data?

I could use the BaseStats module, a scriptable object or…?
I heard scriptable objects are not supposed to be modified during runtime, so I guess BaseStats would be suited best as it is already there for every character?

Thanks for any input :slight_smile:

Yes, all bonuses are currently recalculated on each hit.

There is no question that the logical place to cache these values would be in BaseStats… as it’s already the place responsible for gathering the stats in the first place.

One potential issue is dependency inversion… right now, Fighter relies on BaseStats to get it’s stats. We don’t want BaseStats calling Fighter to subscribe to an event (this creates cross dependency). There are two solutions…
One is to create a UnityEvent on each of the elements that could have stat changes and hook the OnModifiersChanged event hooked up in the inspector. The other is to make a public function in BaseStats OnModifierChanged() that anything that has modifiers can call directly. For now, our source of modifiers is Fighter… so when equipping a weapon, call GetComponent().OnModifierChanged(), and let that method re-poll the modifiers.

This topic was automatically closed after 22 hours. New replies are no longer allowed.