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
edit: for some reason it is not letting me post this in the scripting forums.. ehh
Just wanted to clarify that I am talking about the "AI - Tactical AI Function" field in the unit object.
For example, for High Templars, that field is set with "AIThinkHighTemplar" which is a function in the "TactProtAI.galaxy" internal script.
The function itself is:
voidAIThinkHighTemplar(intplayer,unitaiUnit,unitgroupscanGroup){markermark;orderord;boollowVitality;unitfilterf;regionr;unitgroupenemyGroup;if(AIEvalTacticalData(aiUnit,null)){return;}// If we already have a psi storm order, ignore any new orders since psi storm is more important.// If we already have an PhaseShift order, ignore any new PhaseShift orders.if(UnitOrderHasAbil(aiUnit,c_AB_PhaseShift)||UnitOrderHasAbil(aiUnit,c_AB_PsiStorm)){return;}// Low Vitality = less than 50%, then use this to escape.lowVitality=(UnitGetPropertyInt(aiUnit,c_unitPropVitalityPercent,c_unitPropCurrent)<c_HighTemplarLowVitPerc);if(!lowVitality){// Don't cast if the enemy only has 1 unit when we are at full health.// If we have less than 1.25 * the enemies forces.f=UnitFilterStr("-;Missile,Dead,Stasis,Worker");r=RegionCircle(UnitGetPosition(aiUnit),AIRangeHighTemplar(player,aiUnit));if((UnitGroupCount(UnitGroupAlliance(player,c_unitAllianceEnemy,r,null,c_noMaxCount),c_unitCountAll)<2)||AIAllyEnemyRatio(player,UnitGetPosition(aiUnit),f,AIRangeHighTemplar(player,aiUnit),c_MinThreshold)>c_EnemyMultiplierHighTemplar){return;}}mark=AIMarker(aiUnit,c_MK_PhaseShift);ord=PhaseShift(player,aiUnit,scanGroup,mark,lowVitality);if(ord!=null){AICast(aiUnit,ord,mark,c_castRetreat);return;}}
If we look closely, we see that this function seems to be manipulating the order stack of a unit, and has access to quite a few helper functions.
What I'm looking for, is a way to make this work but with a custom function. This would pertain to finding not only how to do the hook up itself, but what kind of helper functions are available within the scope of the custom tactical AI function.
There are also "Tactical AI" objects in the data editor (but the guys in the Data Editor forums don't seem to have a clue about those). From what I can tell, these Tactical AI objects also deal with some aspect of a units tactical play, but seem to do it through validators (and I'm not even sure they can handle multiple abilities). These Tactical AI objects plug into the "Tactical AI" field in the unit object.
The thread is a little old but I'll reply anyway, given this is an important topic with very few answers in the forums.
Tactical AI data works fine, but it's strictly a set of conditions (validators) to use just one specific ability. AI Tactical Functions are much more flexible in that regard, especially if you need to manage more than one ability.
The function prototype must always be :
void MyAIThinkFunction(int player, unit aiUnit, unitgroup scanGroup)
Where "MyAIThinkFunction" is the string that must be entered in the data unit's field "AI - Tactical AI Function" ( or TacticalAIThink in raw data ) in order for the function to be called.
It works quite well, it's certainly worth playing with!
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
edit: for some reason it is not letting me post this in the scripting forums.. ehh
Just wanted to clarify that I am talking about the "AI - Tactical AI Function" field in the unit object.
For example, for High Templars, that field is set with "AIThinkHighTemplar" which is a function in the "TactProtAI.galaxy" internal script.
The function itself is:
If we look closely, we see that this function seems to be manipulating the order stack of a unit, and has access to quite a few helper functions.
What I'm looking for, is a way to make this work but with a custom function. This would pertain to finding not only how to do the hook up itself, but what kind of helper functions are available within the scope of the custom tactical AI function.
There are also "Tactical AI" objects in the data editor (but the guys in the Data Editor forums don't seem to have a clue about those). From what I can tell, these Tactical AI objects also deal with some aspect of a units tactical play, but seem to do it through validators (and I'm not even sure they can handle multiple abilities). These Tactical AI objects plug into the "Tactical AI" field in the unit object.
So... any takers? Any ideas?
The thread is a little old but I'll reply anyway, given this is an important topic with very few answers in the forums.
Tactical AI data works fine, but it's strictly a set of conditions (validators) to use just one specific ability. AI Tactical Functions are much more flexible in that regard, especially if you need to manage more than one ability.
The function prototype must always be : void MyAIThinkFunction(int player, unit aiUnit, unitgroup scanGroup)
Where "MyAIThinkFunction" is the string that must be entered in the data unit's field "AI - Tactical AI Function" ( or TacticalAIThink in raw data ) in order for the function to be called.
It works quite well, it's certainly worth playing with!