Galaxy Editor - Code Samples

Ice Bane

Member
Reaction score
5
Code:
unit AIEarlyDefScoutZerg (int player, unit prev) {
    unit obs;
    
    if (!AIGetFlag(player, e_flagsEarlyDefScout)) {
        return c_nullUnit;
    }
    if (UnitGetType(prev) == c_ZU_Overseer) {
        return prev;
    }
    obs = AIGrabUnit(player, c_ZU_Overseer, c_prioScout, null);
    if (obs) {
        return obs;
    }
    if (UnitGetType(prev) == c_ZU_Zergling) {
        return prev;
    }
    obs = AIGrabUnit(player, c_ZU_Zergling, c_prioScout, null);
    if (obs) {
        return obs;
    }
    if (prev) {
        return prev;
    }
    return AIGrabUnit(player, c_ZU_Drone, c_prioScout, null);
}


bool AIWaveNeedClearObsUnits (int player) {
    unit obstruction = null;
    wave waveClob = null;
    wave waveAtck = null;
    int countClob = 0;
    int countAtck = 0;
    int evalAtck = 0;

    // Check global option
    if (AIGetFlag(player, e_flagsClearObs) == false) {
        return false;
    }

    // Don't clear obstructions in the first 10 minutes (leaves the AI too open to being rushed)
    if (AIGetTime() < 600) {
        return false;
    }

    // See if there is any obstruction
    obstruction = AIGetObstruction(player);
    if (obstruction == null) {
        return false;
    }

    // See if the clear obstruction wave is already full
    waveClob = AIWaveGet(player, c_waveClearObs);
    countClob = AIWaveUnitCount(waveClob);
    if (countClob >= 4) {
        return false;
    }

    // If the attack wave is getting weak, keep units available for it instead
    waveAtck = AIWaveGet(player, c_waveAttack);
    countAtck = AIWaveUnitCount(waveAtck);
    evalAtck = AIWaveEvalRatio(waveAtck, c_evalRange);
    if (countAtck > 0 && evalAtck < 80) {
        return false;
    }

    // Yes, units are needed for clear obstruction duty
    return true;
}


void ProtossOpenGnd0 (int player) {
    AIClearStock(player);

    AISetStock( player, 1, c_PB_Nexus );
    AISetStock( player, 8, c_PU_Probe );
    AISetStock( player, 1, c_PB_Pylon );
    
    // around 100 resources in about 2 units
    AISetStock( player, 1, c_PU_Zealot );
    ProtossTechUp(player, 1);
    
	if (AIEnableVeryEasyStockOpen(player, c_PU_Probe)) {
		return;
	}

    // around 300 resources in about 3 unit
	AIAddStringInt(player, c_PU_Stalker, 1);
	AIAddStringInt(player, AIPickFrom2(c_PU_Zealot, c_PU_Disruptor), 1);
}




From what I can tell, its syntax is very similar to C/Java/PHP. Furthermore, it looks to be a procedural language instead of object oriented (oh well!). I know this will excite some of you modders out there :]

Source: http://www.sc2armory.com/


Found this, thought you'd like it.

Best regards, your friendly neibourhood Ice_bane
 

Ice Bane

Member
Reaction score
5
You're a few weeks late.

I thought that maybe someone would appreciate seeing it in a programme like above, I'm not saying this is news.

Furthermore I didn't see any actual thread with code samples only.

I've seen code before, I just wanted to share.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top