Custom Object, Behavior, Functions (for Unit AI)

My question (TLDR):
How to make modular logic for AI-Behavior/AI State Machine that requires multiple objects in CustomObject logic, ObjectBehavior logic and CustomFunction logic? Split the logic parts in modular pieces (StateHandling, MovementHandling, ObjectPicking)? Make it modular at all, or all in one place?

Appreciate :pray:


Hey there,

I want to learn and use the extension architecture more often, and I have done so before. In many cases it was delightful to use. It is said to be particular essential, when the project gets more complicated, and that is often true. I just hit a wall, as soon, as I am creating systems, that require multiple objects in almost any situation.

My example ist Unit AI Behavior (I will stick to the basics):

Objects: Unit, ResourceNode, Building
Variables/Properties: IDs, TargetIDs, States, Stats/Attributes
Major picking actions: Variables/Properties, Nearest, Linking(TargetID)

Now, using an Custom Extension for the Unit AI Behavior is giving me an headache. It is not too hard, to manage the whole StateMachine/UnitAI in the classic Events Sheet, but I want to learn how to do it in a Custum Extension. I can’t get my head around, how to approach it… If it is useful at all, to ecapsulate it in a modular system… If and how to split it in CustomObject logic, ObjectBehavior logic and CustomFunction logic…

EDIT:
I quickly created a simplyfied version of an Unit AI, to demonstrate the concept (please don’t mind not having variables declared, its just to demonstrate)

Custom extensions can definitely make a huge range of tasks much easier. I have never done exactly what you describe, but I can recommend using object parameters more. They make it much easier and more convenient to configure objects and work with them in general:

For example, for creating NPCs and configuring them, switching modes, setting everything up, making variations using the same setup. Checkboxes, default values, separate fields with parameters and strings, the ability to select strings or numbers from lists, load external resources, set colors, and so on:

This helps to keep the project more organized and allows you to check/change their values more conveniently than with regular variables.


For example It would be very convenient to use such actions/conditions in conjunction with an item_list structure variable containing damage stats, names, price etc, and you could still refer to all of it simply by a drop-down list:

You can use them both in scene and in custom extension events.

I’m not sure if this will be useful to you, but in my opinion, using custom extensions and behaviors without this doesn’t offer much advantage over regular scene events or external events with variables.

1 Like

Thank you for your reply, @7ToGo. I do agree, that Parameters can be a nice way to structure (and organize) your CustomObject-Data.

I tried to figure out the system, and this is what I ended up with:

EventSheet:

Actions&Conditions:

The work action: (the other actions are basicaly the same as in my initial post,just seperated in different functions)

It does not feel more scaleable at all. Every State of my objects needs their own function and it feels like I am doing things multiple times. I need to pass the required objects via normal events anyways. Then I need to keep in check, which functions fit into the CustumObject, and which in the Behavior. Then I need to make my parameters available for the different behaviors (this will add up, when other CustomObjects are added, like e.g. Wildlife (Animals, different from Unit-category). On top the debugging feels harder, because I can’t just check my Parameters in the Debugger, as I can do with Variables. So there I need an extra step as well, to make this visible.

…don’t get me wrong, I want to use the system. But it feels like I don’t get it right.

I mean I could probably just create a single function, which passes all needed Objects to my Unit, and let it handle everything with one single Action in my event sheet. But even then, it seems like I am not getting any value from doing this(?)

Anyone experienced with this and also getting my issue?

I changed it to one line:
grafik
which does everything now:

which is basically what I had before, just embedded in a behavior…

This template has 3 dedicated extensions: Player, Bomb and Bonus

1 Like