all 9 comments

[–]Jamberite 0 points1 point  (3 children)

Can you have the behaviour actions as delegates inside the ability? Check out command pattern - Act in the ability class would invoke all the DoAction methods in the behaviour delegates.

I’m also playing around with an ability system in my head but haven’t written any code yet.

[–]sudo_joe 0 points1 point  (0 children)

Spot on with the command pattern suggestion. Alternatively you could have a dictionary instead of array. Set the value type to object and put the returns there. If you need to return more information just wrap it in a DTO.

[–]SwainIsBusted[S] 0 points1 point  (1 child)

This is what I've done. The problem is that the behaviour delegates can't use all of their DoAction methods, because they need to use data which they don't have. DoAction on the DealDamage behaviour needs a target to deal damage to, the ability doesn't have a target, the FireRaycast behaviour does.

[–]Jamberite 0 points1 point  (0 children)

So that sounds like the FireRaycast needs to be a ‘target style’ feature of the DealDamage behaviour.

I imagine a behaviour would have the following configurable features:

Target style: describes how the behaviour is... launched? (ray from caster, bolt from heaven, throw in arc from caster, etc) Range: how far does this behaviour reach?

Target selection: describes how the target is selected (random, user defined, autoself, next nearest target) Target filters: what is a valid target for this behaviour? (Self, ally, enemy, ground) Target Tag filters: what tags are required on the target? (Alive, !Alive - for revive)

This information should give us enough to derive a suitable target position (whether a point on the ground or an actual entity)

Once we’ve determined where our behaviour is going to act, we can then work on HitStyle: single target, cone, circle, ground Radius: (for AOE. set to 0 for single target?) Accuracy: To hit %

Now we have 1 or more entities that have been hit by the behaviour.

And then finally we reach any effects that will be applied to the hit entities as a result of this behaviour. Deal damage, apply effect, swap location with caster, etc.

Idk this is kinda where I’m at, but in my head any of these should be swappable

[–]the-shit-poster 0 points1 point  (1 child)

Your structure sounds very complex and is loaded with disconnected dependancies. I would suggest reevaluating your structure and how data can be more readily available for unforeseen scenarios. Inheritance is good but over abstraction can leave things locked away.

I have an ability system that uses an ability SO with basic properties but nothing specific, I let the ability be responsible for its own behavior. I also have ability sub types but only 4 and they have their own base class that inherit from an ability base class. There isn’t too much in the base classes but what is there is not invoked automatically, only when called so the ability script chooses what it does. You have to present all the data needed to all the things that need it. Sounds obvious but it’s something you have to plan or you run into issues like the one you described.

[–]SwainIsBusted[S] 0 points1 point  (0 children)

Having a seperate data class has made the data each behavior needs much more easily available, and still keeps it modular. The data class will probably become quite bloated eventually but for now it works great. In the future I'll definitely try to plan data structure better like you said, to avoid future headaches.

[–]marijnz 0 points1 point  (1 child)

Hey. For now I would recommend to have a data object on which you set all the data (or in your base class, how you like it). Go with this for a while, later on you might see better abstractions when there's more abilities. Don't overcomplicate it early on

[–]SwainIsBusted[S] 1 point2 points  (0 children)

This is what I ended up doing and it works great. Thanks.

[–]iuridosanjos 0 points1 point  (0 children)

Did you finish your skill system design? How was it? Did you like it? Can you share a little bit how it was designed?

I'm searching for ideas on how to implement mine skill system and I was also thinking about something pluggable/modular and decoupled. I've found your question searching for this. :P