[Galaxy Files] Including Custom Function files and Overlords Example

Started by Kernel64, March 20, 2010, 10:51:40 PM

Previous topic - Next topic

Kernel64

Just add, say your custom library of functions are within ZergFuncs.galaxy:

include "TriggerLibs/ZergFuncs"

from where you would call the functions. Say if you're looking to call them from Zerg0.galaxy, just add the above at the top of Zerg0.galaxy.

having other extensions other than .galaxy is something to be tested yet.

This function below allows you to command overlords at will. The command given here is a move command, where the point is chosen by the function:

AIPlacementNearbyFindTest (...);

and is used by:
OrderSetTargetPoint(...);


This isn't perfect. But to use this, disabling the code at Zerg.galaxy in the function AINewUnitZerg (int player, unit u) where overlords are given to scout seems to be necessary.

The goal of this function is to make the overlords stay at creep spots and drop creep there whenever lair is up.

void CommandOvie(int player, int CTown){
order ord;
point OTarg;
unit Ovie;
       
        Ovie = AIGrabUnit(player, c_ZU_Overlord, c_prioScriptControlled, AIGetTownLocation (player, CTown));
        OTarg = AIPlacementNearbyFindTest (player, UnitGetPosition(Ovie), 20, c_ZB_CreepTumor);
        ord = AICreateOrder(player, c_AB_Move, 0);
        OrderSetTargetPoint(ord, OTarg);
        if (UnitOrderIsValid(Ovie, ord)) {
            AICast(Ovie, ord, c_noMarker, c_castHold);       
        }
        else {}
}

Astazha

I assume that yours looks something like this:


Include "TriggerLibs/Zerg0"
Include "TriggerLibs/ZergFuncs"




Or that you have your include at the bottom.




If so, try moving your Include above the one for Zerg0 so that your file has already been included when Zerg0 gets parsed, that way it has already read your function definitions before it sees Zerg0 using them.


Like this:


Include "TriggerLibs/ZergFuncs"

Include "TriggerLibs/Zerg0"


Alternately you could put your include at the top of Zerg0.galaxy

Kernel64

Ah, yes. Figured it out. Edited.

It was actually ordered like that.

Include "TriggerLibs/Zerg0"
Include "TriggerLibs/ZergFuncs"

Thanks man!

Astazha

Been messin' with Overlords myself.  I had the selection as scout disabled, but not the part in AINewUnitZerg() where it assigns them to the extra scout group.  I should try that.


Anyway, I could move them, but they'd just return after arriving at the destination.  I made sure they weren't in any waves.


What finally worked for me was creating a new wave just for the Overlord and setting it's gather point where I wanted him to go.  If I order him somewhere else he'll go there and then return to the gather point.


I haven't messed with it a lot.  The next piece I wanted was to send him to the enemy town, and then I realized that I didn't know how to do that without cheating.


One thing that will be easy to do will be send overlords to monitor expansion locations - especially the obstructed, out of the way, and island ones.

Kernel64

I'm having a hard time figuring out the necessary point values to set into the target. How did you do it? What function did you use to find the proper location?

Astazha

Well, I was just using Point(150,150) on a 4 player map, which was roughly the top right corner.


GetUnitPosition() returns a point, as does the townlocation function (I forget the exact name but you should be able to find it.)