Roach Burrow Assistance Required

Started by Reelix, March 16, 2010, 01:49:55 AM

Previous topic - Next topic

Reelix

Hi All!

After spending about 6 hours last night coverting my AI from version 0.1 to 0.2, I have come across a slight problem.

What I'm trying to do is select every roach a player has, iterate through them all, and, if their health is below 40%, burrow, and stay burrowed, while health < 90%

Now, it works rather well, up to a point.

When the roaches health is below 40% it burrows like it's meant to, and just pops straight back up - It subsequently "leapfrogs" up and down while it's health is below 90%, causing it to be obliterated in the heat of battle.

Does anyone know how to make a burrowed unit, stay burrowed?

a simple (Pseudocode)

while (healthPercect < 90)
{
     AICast(burrow, roach);
}


causes problems.

I think sending the burrow "spell" unburrows the burrowed unit...

Does anyone have a solution to this?

Nova

Perhaps "burrow" and "unburrow" are two different spells?

Makes sense. When you tell it to burrow, it thinks you are telling it to 'go under'. So it pops up, just so it can go down again to fulfill that command.

Reelix

Hmmm - I never thought of that...

I DO know that "RoachBurrow" and "RoachUnburrow" are two separate abilities...

Don't suppose you know a

static bool IsBurrowed(unit u);

command? :)

Nova

Wouldn't have a clue. I'm good with logic, terrible with syntax.

Reelix

#4
# AIControlWantsToUnburrow(unit u)
# AIControlWantsToBurrow(unit u)
# AIControlForceUnburrow(unit u)

Those 3 exist.

Curse the lack of AIControlForceBurrow(unit u)

:(

I've tried something along the lines of

if (AIControlWantsToUnburrow(theUnit))
{
    // doBurrow(theUnit);
}

But that just bunny-hops the roach as well


-- Edit ---


Possible Helpful Functions:

UnitTestState(unit u, int state) - Test state of the unit
UnitGetPropertyInt(unit u, int property, bool current) - Property of the unit
UnitOrder(unit, int)
UnitOrderIsValid(unit, order)
UnitTypeTestFlag(string, int)
UnitTypeTestAttribute(string, int)
AICast(unit u, order, marker, bool)
AICastFlee(unit, unit, int, marker)

AIControlWantsToMove(unit u)  / AIControlWantsToUnburrow(unit u)  / AIControlWantsToBurrow(unit u)
-- Maybe a StopAction(unit u) somewhere?

ShadowTiger

Im not really familiar with sc2 ai programming, but i looked at galaxy wiki for you and i found a potential way to do this if you cannot use the aicontrolwantstoburrow functions.

1) use the unitfilter to pick out units which are "buried". Use this to issue separate orders to units that are burrowed and not burrowed.

anwyays hope that helps

kazibi

I dont have a 100% understanding of galaxy, but from what I can see I will say that:

while (heal <90)
    burrow ();
);

Will use burrow the ability lots of times, and if we assume that burrow () == unburrow  (), then we have the effect you describe: roaches being burrowed/  unburrowed multiple times.

Maybe something like this works:

if (heal <90) (
   burrow ();
   while (heal <90) (
      wait (1);
   )
   burrow ();
)

Of course in pseudocode ...  ::)