Main Menu
Menu

Show posts

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

Messages - Xest

#1
Can you add support for 16 player maps?
#2
I fixed up your code (removed some redundant stuffs and organized it) to be read/pushed into the GIT.

void AIWaveThinkDefault (int player, wave w, int type)
{
    point pHome = AIGetTownLocation(player, c_townMain);
    int pDist;
    int pDistMax;
    int i = 1;
    unit u;

    if (AIWaveUnitCount(w) < 1)
    {
        return;
    }
    while(i <= AIWaveUnitCount(w))
    {
      u = UnitGroupUnit(AIWaveGetUnits(w),i);
      pDist = FixedToInt(DistanceBetweenPoints(pHome, UnitGetPosition(u)));
      //retreat idle groups when far away from base
      if (AIWaveGetTimeInCombat(w) == 0)
      {
        pDistMax = 32;
      }
      else
      {
        pDistMax = 38;
      }
      if ((pDist >= pDistMax) && (type == c_waveMain))
      {
        if ( (AIWaveState(w) == c_waveStateIdle) || (AIWaveState(w) == c_waveStateDefend) )
        {
          AIWaveSetType(w, c_waveStateRetreat, AIWaveTargetGatherO(player, c_townMain));
          return;
        }
      }
      i = i + 1;
    }
   
    if (type == c_waveMain) {
        AIWaveMain(player, w);
    }
    else if (type == c_waveDefend) {
        AIWaveDefend(player, w);
    }
    else if (type == c_waveAttack) {
        AIWaveAttack(player, w);
    }
    else if (type == c_waveDivert1) {
        AIWaveDivert(player, w, e_divert1State);
    }
    else if (type == c_waveDivert2) {
        AIWaveDivert(player, w, e_divert2State);
    }
    else if (type == c_waveClearObs) {
        AIWaveClearObs(player, w);
    }
    else if (type == c_waveHome) {
        AIWaveHome(player, w);
    }
}

void AIManageSupply (int player)
{
    string supplyType;
    string p_race = PlayerRace(player);
   
    int supply_made = PlayerGetPropertyInt(player, c_playerPropSuppliesMade);
    int supply_gap = supply_made / 9;
    if (supply_gap < 5)
    {
      supply_gap = 5;
    }
   
    if(p_race == "Terr")
    {
        supplyType = c_TB_SupplyDepot_Alias;
    }
    else if(p_race == "Prot")
    {
        supplyType = c_PB_Pylon;
    }
    else if(p_race == "Zerg")
    {
        supplyType = c_ZU_Overlord_Alias;
    }
   
    if ( (PlayerGetPropertyInt( player, c_playerPropSuppliesUsed ) >= supply_made - supply_gap )
        && (AITechCount ( player, supplyType, c_techCountIncompleteOnly ) == 0 ))
    {
        AISetStockUnitNext( player, AITechCount( player, supplyType, c_techCountCompleteOnly ) + 1, supplyType, c_stockAlways);
    }
}

void AIBalancePeons(int player)
{
  int a = 0;
  int gas = PlayerGetPropertyInt(player, c_playerPropVespene);
  int minerals = PlayerGetPropertyInt(player, c_playerPropMinerals);
  int totalTowns = AIGetTotalTowns(player);
  int nRefinery = 0;
  int needPeons = 0;
  int gasPeons;
  string refine;
  string worker;
  string mbase;
  string p_race = PlayerRace(player);
  if(p_race == "Terr")
  {
    refine = "Refinery";
    worker = "SCV";
    mbase = c_TB_CommandCenter_Alias;
  }
  else if(p_race == "Prot")
  {
    refine = "Assimilator";
    worker = "Probe";
    mbase = c_PB_Nexus;
  }
  else if(p_race == "Zerg")
  {
    worker = "Drone";
    refine = "Extractor";
    mbase = c_ZB_Hatchery_Alias;
  }
  while(a != 8 )//Starcraft supports up to 16 players (0 to 15)
  {
    gasPeons = 0;
    if (AIGetTownState(player, a) == c_townStateEstablished)
    {
      nRefinery = AIGetBuildingCountInTown(player, a, refine, c_techCountCompleteOnly);
      if(AIGetCurPeonCount(player, a) > 12)
      {
        AISetStockEx (player, a, 2, refine, c_makeCollector, 0);
        if (gas > minerals + 1200)
        {
          gasPeons = 0;
        }
        else if (gas > minerals + 900)
        {
          gasPeons = 1;
        }
        else if (gas > minerals + 600)
        {
          gasPeons = 2;
        }
        else if (gas > minerals + 300)
        {
          gasPeons = 3;
        }
        else
        {
          gasPeons = 3 * nRefinery;
        }
      }
      else if(AIGetCurPeonCount(player, a) > 6)
      {
        AISetStockEx (player, a, 1, refine, c_makeCollector, 0);
        gasPeons = 3;
      }
      else
      {
        gasPeons = 0;
      }
    }
    AISetGasPeonCountOverride(player, a, gasPeons);
    a = a + 1;
  }

  //making zerg spam hatchs
  //AISetStockUnitNext(player, totalTowns, mbase ,c_stockIdle);
   
  // build peons
  if(p_race == "Zerg")
  {
    needPeons = totalTowns * 28;
  }
  else
  {
    needPeons = totalTowns * 33;
  }
  if (needPeons > 90)
  {
    needPeons = 90;
  }
  if (needPeons < totalPeons)
  {
    needPeons = AITechCount (player, worker, c_techCountCompleteOnly); //Should you just ignore AISetStockUnitNext() ?
  }
  AISetStockUnitNext(player, needPeons, worker, c_stockAlways);
}