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 this is not letting me post this in the data forums, even though most existing tactical AI scripts *might* be a data related thing (the functions are on the units data field after all)
Well if you check Tactical AI data there something. By looking at "Create New" there's "Generic" "Order" and "Set". They appear to be working with validators and "Target Find" data. I could only assume it works something like AI-> Validate->Find targets (more like "is it worth to cast") but its unexplored area for now until someone make use of it and create some tutorial maybe. Personally i dont even bother to test it because i prefer triggers which can be set in 10 seconds.
I've definitely taken a look at the 'tactical AI' objects in the data editor, but they seem to be doing something else. I found that the "Tactical AI" field on the unit object actually links to a function written in script, which, for most units that have them (e.g. HTs, ghosts, science vessels) are stored in the core AI files.
What I was wanting to look into is how to write a whole new function in script, then somehow link that script function to the tactical AI field of the unit object.
Triggers are fine, and I know that triggers are definitely one way to set up tactical AI, but I think there is value in figuring out the existing tactical AI system.
I guess if this area is still unexplored like you say Nerfpl, then I guess I'm going to have to dive into it.
If anyone has any idea of importing custom scripts, that would be a good place to start.
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.
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 this is not letting me post this in the data forums, even though most existing tactical AI scripts *might* be a data related thing (the functions are on the units data field after all)
@zzPop: Go
No please, slow down. Don't all be going and replying all at once.
But seriously, no one has ever tried this before? I find that hard to believe.
Well if you check Tactical AI data there something. By looking at "Create New" there's "Generic" "Order" and "Set". They appear to be working with validators and "Target Find" data. I could only assume it works something like AI-> Validate->Find targets (more like "is it worth to cast") but its unexplored area for now until someone make use of it and create some tutorial maybe.
Personally i dont even bother to test it because i prefer triggers which can be set in 10 seconds.
@Nerfpl: Go
I've definitely taken a look at the 'tactical AI' objects in the data editor, but they seem to be doing something else. I found that the "Tactical AI" field on the unit object actually links to a function written in script, which, for most units that have them (e.g. HTs, ghosts, science vessels) are stored in the core AI files.
What I was wanting to look into is how to write a whole new function in script, then somehow link that script function to the tactical AI field of the unit object.
Triggers are fine, and I know that triggers are definitely one way to set up tactical AI, but I think there is value in figuring out the existing tactical AI system.
I guess if this area is still unexplored like you say Nerfpl, then I guess I'm going to have to dive into it. If anyone has any idea of importing custom scripts, that would be a good place to start.
@zzPop: Go
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.