I have an ability type system that needs to apply effects based on events such as
OnDamaged, OnAttack, etc.
What is the best way to approach this?
I thought of using dispatchers and binding the effects to them (maybe multicast)
I also thought of adding an array of objects inheriting from a base class. During each event going through the array and calling a function like “ApplyEffect” on each object.
Is there an easier way to accomplish this? I would have to give EVERY event an array of potential effects to check.
You know GAS (correctly expanded is): Game Ability System.
It is a bit complicated, but if you stick to most basic features is not that hard to use.
Uh and do not use arrays for storing your data (static data). Blueprints happily like to revert to default state on occasion (it is rare but if it happens and your array gets empty you may spend weeks searching for errors or why some system you coded 3 months ago returns wrong stuff)
So use Data Assets ( they are doable in c++ +or blueprints), store default things in data assets, they do not get wiped out unless you change their definition. Well just like blueprints, but with BPs, some error and recompiling it sometimes is enough to wipe all.
This being said some of the cue’s sometimes not enough, it can get complicated. You can also make gameplay effect on target run another ability. If that would be the case, you can just add a tag with effect that runs another ability.
These suggestions are great! Im using my own system for now and not GAS (since its single player and fairly simple). I like the idea of setting up gameplay events with cues and just checking for them. Sounds like the gist of this is gameplay events need to be wrapped in a handler.
Thats correct I want to apply a gameplay effect like “take 15% more damage”, “spawn an enemy behind you” etc.
The idea is when a character selects an ability they must take a negative aspect that is something like…
Take extra damage, 15% chance when dodging to spawn an explosion, [some kind of negative gameplay effect].
I just need to apply an affliction with some kind of cue. As i see it the cue uses a callback to this affliction when triggered.
I know GAS is a great way to handle things but I want to try learning by creating a ground up type system without replication.
I understand. Well I think thats above my experience but what I do is managers if not using GAS. Please note that aside, I am pretty sure there would be better advices.
Like HealthManager, StaminaManager, DamageManager, ArmorManager, CastManager etc.
Ex: DamageManager manager attributes on character with the current effectors like, armor, temporary effects.
So when a damage is received -->Damage manager handles it and asks other dependent managers their status (if exists on character if not assumes no coefficient (1))
Asks armor about its coefficient and armor manager just calculates the output for DamageManager on that time of gameplay.
Damage manager doesn’t cares what buff is applied unless something applied directly on damage manager.
Armor manager knows what is applied or not so this way I don’t have to check arrays etc. Lets say there is a debuff applied as SunderArmor, that the armor value is decreased by 0.5 * whatever
I think i’ll do something similar but try an all encompassing Cue System. Keep a lookup table of gameplay event types which map to an array of Cues, using delegates to callback specific functions. Have Gameplay Events check the lookup table when they do something, and call the delegates.
Might be tricky having to modify damage values and such, but it’s a start.
Honestly the actual gameplay events shouldn’t be very complicated, its a singleplayer “souls-like” so most of the depth is in AI and Animations. I’m not looking for interaction at any complicated level, just basic RPG stuff (for now).
Appreciate the advice! I have some new ideas now thanks to that.
Would having a global manager that manages specific global events and a local manager specific to the actor work? The local manager handles OnDeath, which will call OnAnyDeath in the global manager? I’m using a map for now to hash gameplay events as string id’s (like “OnAttack”, “OnDeath”, etc). Would this be a bad way to organize it?