I'm looking for some insight into attaching custom the tactical AI scripts to units. Some units (e.g. High Templar) already have tactical AI scripts (ones that instruct the Templar on how and when to use some of his abilities). From what I can see, most of the units with tactical AI have the "Tactical AI" field of their unit object populated with the name of some tactical AI function.
However, I cannot find where these tactical AI scripts are housed, or, where I can create a new tactical AI script and add it to a custom unit.
If you have any experience in this, I would be very thankful for your thoughts/insights into this topic.
The parameters are all required, with the given type and in this order.
Owner is the owner (player) of the unit,
Caster is the unit itself,
and Targets is a unit-group with pretty much everything "nearby" the caster.
The names are up to you.
However, regardless of what filtering or other options you put in the AI data, this only ever includes enemy units!
No idea if that's a bug, a feature or if my testing didn't quite work...
Anyway, works well with the default settings, and really includes anything enemy nearby, including missiles.
And, well, what exactly you are doing inside the Actions part is completely up to you.
To get it to work:
- the player must be computer controlled
- you run the action "AI - Start the campaign AI" for that player.
If there are pre-placed units (includes those the computer gets through "Melee - Create starting units",
run "AI - Disable script control" on each one.
If you feel like it, you can also run "AI Advanced - Set the APM count for ... to ..." for that player.
Yes, they do play "better" (where better means faster that is) with higher numbers.
300 feels somewhat slow, whereas at 3000 things are really starting to roll.
Here's a complete, working example that's running in my map:
It's perhaps a bit unreadable from all the filtering, which makes for very long lines...
The short version is that it tries to target an enemy with a damage spell.
If that doesn't work, it tries a healing spell on a friend.
If neither works... well, we're just going to try it again next time.
Filtering is, of course, somewhat required.
You really want to make sure to get a working target, and, obviously, a target worthy of your attention.
The other important part is how to get and check for the validity of an order.
Of course, you also have to put it on the unit:
Open menu: Data / View script.
Scroll down a bit to a section called "Global Function Declarations".
You'll see something like:
void gf_AI_Infestor (int lp_Owner, unit lp_Caster, unitgroup lp_Targets);
You want the "gf_AI_Infestor" part.
Put that string in your unit's "AI - tactical AI function".
Good fun, have luck
Rollback Post to RevisionRollBack
To post a comment, please login or register a new account.
Does anyone have any experience in this?
I'm looking for some insight into attaching custom the tactical AI scripts to units. Some units (e.g. High Templar) already have tactical AI scripts (ones that instruct the Templar on how and when to use some of his abilities). From what I can see, most of the units with tactical AI have the "Tactical AI" field of their unit object populated with the name of some tactical AI function.
However, I cannot find where these tactical AI scripts are housed, or, where I can create a new tactical AI script and add it to a custom unit.
If you have any experience in this, I would be very thankful for your thoughts/insights into this topic.
Thanks
Basically, a custom tactical AI is a function of a predefined prototype, that suggests (or not) an order.
The general layout is this:
You create one through "New action definition".
The parameters are all required, with the given type and in this order.
Owner is the owner (player) of the unit,
Caster is the unit itself,
and Targets is a unit-group with pretty much everything "nearby" the caster.
The names are up to you.
However, regardless of what filtering or other options you put in the AI data, this only ever includes enemy units!
No idea if that's a bug, a feature or if my testing didn't quite work...
Anyway, works well with the default settings, and really includes anything enemy nearby, including missiles.
And, well, what exactly you are doing inside the Actions part is completely up to you.
To get it to work:
- the player must be computer controlled
- you run the action "AI - Start the campaign AI" for that player.
If there are pre-placed units (includes those the computer gets through "Melee - Create starting units",
run "AI - Disable script control" on each one.
If you feel like it, you can also run "AI Advanced - Set the APM count for ... to ..." for that player.
Yes, they do play "better" (where better means faster that is) with higher numbers.
300 feels somewhat slow, whereas at 3000 things are really starting to roll.
Here's a complete, working example that's running in my map:
It's perhaps a bit unreadable from all the filtering, which makes for very long lines...
The short version is that it tries to target an enemy with a damage spell.
If that doesn't work, it tries a healing spell on a friend.
If neither works... well, we're just going to try it again next time.
Filtering is, of course, somewhat required.
You really want to make sure to get a working target, and, obviously, a target worthy of your attention.
The other important part is how to get and check for the validity of an order.
Of course, you also have to put it on the unit:
Open menu: Data / View script.
Scroll down a bit to a section called "Global Function Declarations".
You'll see something like:
void gf_AI_Infestor (int lp_Owner, unit lp_Caster, unitgroup lp_Targets);
You want the "gf_AI_Infestor" part.
Put that string in your unit's "AI - tactical AI function".
Good fun, have luck