April 10, 2021, 05:35:28 PM

Author Topic: [Progress] How to make One Queen spawn larva at Main and Expo  (Read 1011 times)

Kernel64

  • Sr. Member
  • ****
  • Posts: 207
    • View Profile
The idea is utilizing how the AI engine loops within a state like OpenGnd0, for example.

By making a variable loop from 20 to 0, and resetting at will, the Queen can be ordered to move between the two bases.

Having a third base may not work with this code. But as a prototype, this is somewhat a good start.

Here's the code used to order the Queen around:

Quote
void CommandQueen(int player, int CTown, string StructHatch){
order ord;
point OTarg;
unit Queen;
unit nearbyHatch;
region r;   
       
        nearbyHatch = AIGrabUnit(player, StructHatch, c_prioScriptControlled, AIGetTownLocation (player, CTown));
        Queen = AIGrabUnit(player, c_ZU_Queen, c_prioScriptControlled, AIGetTownLocation (player, CTown));
        r = RegionCircle(UnitGetPosition(nearbyHatch), 4);
        //OTarg = UnitGetPosition(nearbyHatch);
        OTarg = AIRandomSpawnPoint (player, r, 50, 100, 3);
       
            ord = AICreateOrder(player, c_AB_Move, 0);
            OrderSetTargetPoint(ord, OTarg);
       
        if (UnitOrderIsValid(Queen, ord)) {
            AICast(Queen, ord, c_noMarker, c_castHold);       
        }
        else {}
}

Here's how it is used within OpenGnd0:

Quote
        if (loopTimer < 20 && loopTimer > 10 ) {  //queen management prototype
            CommandOvie(player, c_townOne);
            CommandQueen(player, c_townOne, c_ZB_Lair);
            CommandQueen(player, c_townOne, c_ZB_Hatchery);
        }

        if (loopTimer < 10) {                    //queen management
            CommandOvie(player, c_townTwo);
            CommandQueen(player, c_townOne,c_ZB_Lair);
        }
        if (loopTimer < 1) {
            loopTimer = 20;
        }

Obviously, this can be developed further. And as you can see, even if c_townOne is used at both cases, the queen will still be ordered to move to c_townTwo.

I have no idea what's going on with that.
« Last Edit: March 21, 2010, 07:20:01 PM by Kernel64 »

hd

  • Member
  • ***
  • Posts: 56
    • View Profile
Re: [Progress] How to make One Queen spawn larva at Main and Expo
« Reply #1 on: March 22, 2010, 02:09:24 AM »
Why wouldn't you just spawn 1 queen per hatchery / lair / hive and place one queen at each hatchery / lair / hive and then have it check on the unit's think if it can cast spawn larva and then have it target the closest hatchery / liar / hive?

Astazha

  • Member
  • ***
  • Posts: 78
    • View Profile
Re: [Progress] How to make One Queen spawn larva at Main and Expo
« Reply #2 on: March 22, 2010, 09:31:40 AM »
Obviously, this can be developed further. And as you can see, even if c_townOne is used at both cases, the queen will still be ordered to move to c_townTwo.

I have no idea what's going on with that.


I think this might be the culprit:


Quote
OTarg = AIRandomSpawnPoint (player, r, 50, 100, 3);
Those 50 & 100 values set a min/max distance from the enemy.  What happens if the minimum distance from the enemy can't be reached within the region you specified?  Will she move outside of it (and towards your natural expansion by default)?

I'm interested in this because I want to learn about what kinds of unit management functions we have, but I don't actually think that shuffling a Queen back and forth from Main to Expansion is very useful.  She can barely keep up with spawning larva at one Hatch, and when you add travel time and the possibility of losing her in transit it doesn't seem worthwhile.

I could see performing one time reassignments - you might start a Queen for an expansion before it's Hatch is built and then just send her over, for example.  Or she might flee a dying expansion and be used for healbot duty until a free Hatch was available that needed larva.

I'm also interested in trying her out as a battle healer.  She could be a key part of a Nydus drop, coming out 1st and keeping the canal exit healed until the army can get out.  She would also be devastating as part of an Ultralisk raid - her healing combined with their damage mitigation would make for a very long lived assault.  Her speed would be an issue though - you'd probably want Overlords and/or a Nydus canal to facilitate her transport and to serve as a shelter if she gets targetted.  I think healing duty queens might be valuable in other circumstances too - anywhere that you have expensive units really - Guardians, Infestors, Mutalisks.  Particularly in a heavy air battle scenario where minerals are plentiful and gas is scarce.

We would need to make significant alterations to her Tactical AI to assess whether she was part of a Hatch/Queen pair or assigned to a wave as healer.  I'm still learning about waves etc. but I think it will be possible to code.

Kernel64

  • Sr. Member
  • ****
  • Posts: 207
    • View Profile
Re: [Progress] How to make One Queen spawn larva at Main and Expo
« Reply #3 on: March 27, 2010, 09:17:08 PM »
I've got this already. IntToFixed on those numbers.

A value of 40 (fixed) is about the radius of LostTemple's high ground starting locations. It can be controlled now, and here's what I'm using atm:

Quote
void CommandQueen(int player, int CTown, string StructHatch){
order ord;
point OTarg;
unit Queen;
unit nearbyHatch;
region r;   
       
        nearbyHatch = AIGrabUnit(player, StructHatch, c_prioScriptControlled, AIGetTownLocation (player, CTown));
        Queen = AIGrabUnit(player, c_ZU_Queen, c_prioScriptControlled, AIGetTownLocation (player, CTown));
        r = RegionCircle(UnitGetPosition(nearbyHatch), IntToFixed(20));
        //OTarg = UnitGetPosition(nearbyHatch);
        OTarg = AIGetTownLocation (player, CTown); //AIRandomSpawnPoint (player, r, 500, 1000, 3);
       
            ord = AICreateOrder(player, c_AB_Move, 0);
            OrderSetTargetPoint(ord, OTarg);
       
        if (UnitOrderIsValid(Queen, ord)) {
            AICast(Queen, ord, c_noMarker, c_castHold);       
        }
        else {}
}

Maybe if I get more time, I'll give hatcheries/lairs/hives an AIThink so they will grab queens closer to them.

This is important since anyone can kite queens to their deaths atm.  :)