• 0

    posted a message on Attaching custom tactical AI scripts to units

    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:

    void AIThinkHighTemplar (int player, unit aiUnit, unitgroup scanGroup) {
        marker mark;
        order ord;
        bool lowVitality;
        unitfilter f;
        region r;
        unitgroup enemyGroup;
    
        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.

    So... any takers? Any ideas?

    Posted in: Galaxy Scripting
  • 0

    posted a message on Attaching custom tactical AI scripts to units

    @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:

    void AIThinkHighTemplar (int player, unit aiUnit, unitgroup scanGroup) {
        marker mark;
        order ord;
        bool lowVitality;
        unitfilter f;
        region r;
        unitgroup enemyGroup;
    
        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.

    Posted in: Data
  • 0

    posted a message on Attaching custom tactical AI scripts to units

    @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.

    Posted in: Data
  • 0

    posted a message on Attaching custom tactical AI scripts to units

    @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.

    Posted in: Data
  • 0

    posted a message on Attaching custom tactical AI scripts to units

    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)

    Posted in: Data
  • 0

    posted a message on Attaching custom tactical AI scripts to units

    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

    Posted in: Galaxy Scripting
  • 0

    posted a message on Attaching custom tactical AI scripts to units

    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

    Posted in: Triggers
  • 0

    posted a message on AutoCast an ability (like psi storm) while moving?

    Just make a weapon with all the effects of PSI storm, allow the weapon to be fired while moving, and add that weapon to the unit. Make all the numerical adjustments you need (range, cooldown, etc), and you should be good to go.

    At least that's what first popped into my mind with this question. You can hide the weapon from showing up on the UI too, if you want.

    Posted in: Data
  • 0

    posted a message on TSMarker - target sort, your thoughts?

    Maybe, if you get time Kueken, you can do a short tutorial on markers and the TSMarker target sorts?

    I'd bet there are tons of people out there who could use such info :)

    Posted in: Data
  • 0

    posted a message on TSMarker - target sort, your thoughts?
    Quote from Kueken531: Go

    Are you familiar with markers in general? You can for exampe make a persistent effect or weapon put markers on all units affected by the sub-effects. Then, you can use a No Markers validator for the effects, to not affect the same unit twice within the same persistent/weapon.

    The TSMarker target sort can be used in a similar fashion; you can use it for a search effect with limited targets to prefer units with markers (or without). So you can make, for example, a spell, which periodically hits 1 random unit in an area, but prefers to hit the same target, as long as it is still in the area.

    Good stuff. This is kind of what I'm trying to figure out how to do.

    Basically what I am going for is similar to what you described.

    In the end, I want to create an autocast ability whose autocast target acquisition is driven by markers (kind of like some of the autocast abilities from Warcraft 3, like the Naga's frost arrows). Ideally, I would have the caster place a marker on a target when it attacks it (either through a dummy weapon or through the first cast of the ability), then the ability picks up on that marker and proceeds to autocast on the target that has the marker, and if no marker is present, the ability just targets a unit randomly (but have it so that the ability itself can place markers on units too).

    Any ideas on how to get something like that up and running?

    As more precise set of questions:

    What field on the weapon object would I use to have a weapon place a marker on a unit?

    How can I make an ability itself place markers on a target, so that it can use that same marker for its autocast?

    What field on an ability do I have to set up (and how do I set it up) to have the ability target the marker set by the previous question(s)?

    Any help, much appreciated.

    Posted in: Data
  • 0

    posted a message on TSMarker - target sort, your thoughts?

    What is "TSMarker"? What does it do? How does it work? Where is it used? What can we use it for?

    If you can answer any of these questions or can shed some light on this elusive thing, post your thoughts here.

    For some basic info, TSMarker is classified as a "Target Sort" (found under "Target Sorts" in the Data Editor), a type of entity that allows you to specify how a particular ability or spell targets enemies. There are many other types of target sorts, e.g. TSDistance, which tells the ability to target enemies closest to the caster. TSLife which tells the ability to target enemies with the lowest/highest health in range, etc.

    Now, TSMarker seems to have something to do with the Effect Marker fields found on most objects, but I don't know the details on how to make it work. I hypothesize that it has something to do with "target enemies with a marker on them", but then we have to ask, how can we set markers on enemies for TSMarker to use.

    N.B. I know there is a way to set markers using triggers, but I would prefer to figure out how to use the whole marker system using just the data editor. Figure out base functionality first, and then we can see if we can do more exotic things using triggers.

    All thoughts, ideas, explanations welcome.

    Go!

    Posted in: Data
  • 0

    posted a message on Auto-cast attack

    I have actually been working on this very thing. I have everything set up except for getting the unit with the autocast ability to target enemies like I command. I have discussed this issue in some detail in this thread:

    http://forums.sc2mapster.com/development/data/19905-ability-target-sorts-help/#p1

    Setting up the basic autocast is pretty straightforward. If you need help with that let me know.

    Posted in: Data
  • 0

    posted a message on Ability - Target Sorts+ help

    Bumping for the weekend crowd.

    It seems Ability Target Sorts needs a lot more investigation.

    Posted in: Data
  • 0

    posted a message on Ability - Target Sorts+ help
    Quote from RebeliousDragon: Go

    I just noticed you can create yoru own 'Target Sorts' and one of the types is control. If you go to the drop down menu in the data editor its at the bottom. Might be worth looking into.

    Yea, I've looked into the other types of Target Sorts, for the most part they do what we expect them to do.

    E.g.

    TSDistance will pick the closest target to the caster

    TSRandom will fire the ability at a random target in range every cast.

    The only one that isnt working as we need, is TSMarker, which unfortunately, is exactly the one I need for this to work. That being said, I might have an idea why it isnt working as expected.

    When I use TSMarker as my target sort type for autocast target aquisition, it only fires the ability at the right clicked target once, then proceeds to fire it at other targets. The reason this *could* be happening is that the right click puts a temporary marker on the unit which expires by the time the ability has finished casting (it has a cast time), Which means that by the time the next cast starts, the marker set from the previous cast doesn't exist, so the game starts casting at some other target.

    This means that we need a way to somehow extend the duration that a target marker stays on the target, so as to allow it to still exist on the target by the time the next cast of the ability starts.

    Which turns the question into, how do we manipulate how long a particular marker stays on a target?

    Posted in: Data
  • 0

    posted a message on Ability - Target Sorts+ help

    Lets get some ideas and discussion on this from the weekend crowd.

    Posted in: Data
  • To post a comment, please or register a new account.