Shameless bump for preview. Leaving town for a couple days; I will continue working on the AI and post update when I return.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu//Count players
i = 1;
j = 16; //this is the max. setting it to 17+ generates an error
TOTAL_PLAYERS = 0;
while(i < j)
{
if(PlayerRace(i) == "Prot" || PlayerRace(i) == "Terr" || PlayerRace(i) == "Zerg")
{
TOTAL_PLAYERS = TOTAL_PLAYERS + 1;
}
//TriggerDebugOutput(1, StringToText("Player " + IntToString(i) + " color index: "+IntToString(PlayerGetColorIndex(i, false))), true);
i = i + 1;
}
TriggerDebugOutput(1, StringToText("TOTAL_PLAYERS: "+IntToString(TOTAL_PLAYERS)), true);
Quote from: Aeg1s on March 05, 2010, 05:02:17 PMAlso, all variables have to be declared at the top of the function before anything else.QFE - you will forget this one so many times.
int a;
int b;
point p;
unitgroup g;
p = PlayerStartLocation(player);
int a;
int b;
point p = PlayerStartLocation(player);
unitgroup g;
// EPlayerType
const int c_playerTypeNone = 0;
const int c_playerTypeUser = 1;
const int c_playerTypeComputer = 2;
const int c_playerTypeNeutral = 3;
const int c_playerTypeHostile = 4;
const int c_playerTypeReferee = 5;
const int c_playerTypeSpectator = 6;
Quote from: asdf14 on March 07, 2010, 10:42:42 AM
Again, this is OOP model you are thinking about. Galaxy is not object-oriented and point is not a class, so it doesn't have methods (point.getX()) or properties (point.x).
Now, if you really wanted to, here's an example which may work and uses a struct to hold both the point and its coordinates:struct myPoint
{
int x;
int y;
point coordinates;
}
void createMyPoint (int x, int y)
{
myPoint.x = x;
myPoint.y = y;
myPoint.coordinates = (x, y);
}
void ChronoBoost(int player, bool beAggressive)
{
unitfilter uf1;
aifilter af1;
unitgroup g1;
unitgroup g2;
unit u1;
unit u2;
order o1;
string firstprio;
string secondprio;
string thirdprio;
int i;
int j;
fixed r = AIUnitFixed(player, c_PB_Nexus, c_fieldRadius) + AIAbilityFixed(player, "TimeWarp", c_fieldRange0);
//Setup target filters
uf1 = UnitFilterStr(AIAbilityStr(player, "TimeWarp", c_fieldTargetFiltersAB)); //only valid Time Warp targets
UnitFilterSetState(uf1, c_targetFilterUnderConstruction, c_unitFilterExcluded); //dont attempt to target buildings under construction
af1 = AIFilter(player);
AISetFilterBits(af1, uf1);
AISetFilterBehaviorCount(af1, c_noBehaviorMin, c_noBehaviorMax, "TimeWarpProduction"); //Filter out targets that are already buffed.
g1 = AIFindUnits(player, c_PB_Nexus, PlayerStartLocation(player), 9999, c_noMaxCount);
j = UnitGroupCount(g1,c_unitCountAlive);
i = 1;
while(i <= j)
{
u1 = UnitGroupUnit(g1,i);
if (u1)
{
if (UnitGetPropertyInt(u1, c_unitPropEnergy, c_unitPropCurrent) >= 25)
{
o1 = AICreateOrder(player, "TimeWarp", 0);
if(!weNeedProbes && beAggressive) //only prioritize gateways if we don't need probes
{
firstprio = c_PB_Gateway;
secondprio = c_PB_WarpGate;
thirdprio = c_PB_Nexus;
}
else //always prioritize nexi if on non-aggressive setting
{
firstprio = c_PB_Nexus;
secondprio = c_PB_Gateway;
thirdprio = c_PB_WarpGate;
}
//Find targets
g2 = AIFindUnits(player, firstprio, UnitGetPosition(u1), r, c_noMaxCount);
g2 = AIGetFilterGroup (af1, g2);
if(UnitGroupCount(g2,c_unitCountAlive) == 0)
{
g2 = AIFindUnits(player, secondprio, UnitGetPosition(u1), r, c_noMaxCount);
g2 = AIGetFilterGroup (af1, g2);
}
if(UnitGroupCount(g2,c_unitCountAlive) == 0)
{
g2 = AIFindUnits(player, thirdprio, UnitGetPosition(u1), r, c_noMaxCount);
g2 = AIGetFilterGroup (af1, g2);
}
if(UnitGroupCount(g2,c_unitCountAlive) != 0)
{
u2 = UnitGroupUnit(g2,1);
OrderSetTargetUnit(o1,u2);
AICast (u1, o1, c_noMarker, false);
}
}
}
i = i + 1;
}
}