Help for a conditional set of behaviour ?

Hello guys,
Would you have some guidance about the system I’m trying to build ?

I’m building an auto adventurer where the play only sets parameters, the combat are turn based.

The character will decide on his own wether he should attack, heal, use a bomb or whatever.
For this, I want my player to only be able to set (pre-fight) “how much of a big spender” he is (in terms of item usage), and wether he is more offense oriented or defensive.

How would you approach this, design-wise ?

Note 1 : I’d like to avoid visual fsm
Note 2 : I’m a scriptable object fan :smile:

Thank you for your inputs !

I just wrote about my Datasacks package here:

https://forum.unity.com/threads/can-you-add-conditions-via-the-inspector.1378791/#post-8687259

8687265--1171653--20180724_datasacks_overview.png
Datasacks is presently hosted at these locations:

https://bitbucket.org/kurtdekker/datasacks

Hey @Kurt-Dekker !
As always, your input is greatly appreciated :slight_smile:

This is a lot to take in ! From what I can see in the githbub explanation, I’m not sure I can process it xD I might need to import it and test it out :wink:

I’ve been able to think a bit further though and the “algorithmic” design I have in mind looks like this :

What do you think ? =)

(By the way, happy holidays !)

You could build it out of a base Condition class, which you extend for conditions such as “HP below / above X” and “just a random chance”, and then a base Operation class, which you would extend for operations such as “use potion” or “attack” or whatever.

These systems can be tricky to stand up “all at once,” even if you diagram them all at once. You sort of have to design, create, test, then iterate back on the original design to see if it works. Fortunately Unity makes it so easy to define a bunch of chunks like this, slot them into a test “runner” script and see how it goes.

Back at you! Nothing like a bit of gamedev over the holidays!

1 Like

Yep, this is what I meant with my “base class” comment on the image ^^

Would you recommend trying to have those classes as separate components and plug them into a prefab, the prefab being a “profile” ?

Or would you use Scriptable Objects ?

I started with an SO oriented design, maybe I should keep it consistent…

I say it is SOs all the way until it is something that lives in the scene.

And even then a generic MonoBehaviour that can be configured via SO is often the best solution, rather than injecting all the various bits of the SO’s interior “guts” into the MB.

For injecting bits of useful data into MonoBehaviours that you create in code, I like this pattern to keep me honest:

Factory Pattern in lieu of AddComponent (for timing and dependency correctness):

1 Like

Sounds good Kurt,
I’m gonna give it a try :wink: