Galaxy Editor - Code Samples

Ice Bane

Member
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
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.
  • tom_mai78101 tom_mai78101:
    My Genetic Algorithm Bot is now v1.0.0
  • tom_mai78101 tom_mai78101:
    I dunno if I ever mentioned it here, but my bot actually helped someone discover a new way to clip through walls.
  • tom_mai78101 tom_mai78101:
    However, not many folks heard about it, because it's currently only compatible with the latest dev builds of multi-system emulator, BizHawk.
  • jonas jonas:
    cool! do you have a video?
  • tom_mai78101 tom_mai78101:
    I have a GIF though
  • tom_mai78101 tom_mai78101:
    In the GIF, I've configured it so the lower the "Main Value" is, the better. I had to compress it pretty far down though.
  • tom_mai78101 tom_mai78101:
    And this is the thread with the video that shows the wall clip. https://tasvideos.org/Forum/Topics/23453
    +2
  • tom_mai78101 tom_mai78101:
    Hmm, about the Headline News, I noticed threads are being moved into the subforum (Health News, Environmental News, etc.). When that happens, the TH Forum Home page loses the articles, and instead would show old articles posted 1 or 2 weeks ago.
  • tom_mai78101 tom_mai78101:
    What do we do with the Home page?
  • Ghan Ghan:
    I added those forums to the filter for that widget.
  • tom_mai78101 tom_mai78101:
    Oh nice. They're back. Thanks.
  • tom_mai78101 tom_mai78101:
    Now I think it makes more sense for me to put news in their own subforums, without worry.
  • The Helper The Helper:
    Awesome Ghan thanks! I was purposely not moving the first 15 news articles in Headline news to the different subforums but I guess I don't have to do that now?
  • tom_mai78101 tom_mai78101:
    Question: Is there a way to remove thread redirects? It creates a copy of the moved thread and takes up space, and I am leaning towards wanting to remove them in the Headline News. But if they have an expiration date, I guess I'm fine with it.
  • The Helper The Helper:
    If you move a thread please leave a permanent redirect. You can delete any redirects after 6 months. The redirects are left to help Search Engines find the moved content.
  • tom_mai78101 tom_mai78101:
    What if you move the permanent redirect, not the thread?
  • The Helper The Helper:
    I think that works but I have not messed with it. You can delete redirects though if you have to that will not delete the original thread
  • The Helper The Helper:
    if a redirect ends up in the same forum as the post it goes to though I think the redirect drops or fails or something but they are not bugged out and when you are working on an indirect the original post is safe.
  • The Helper The Helper:
    Happy Early Friday :)
    +1
  • V-SNES V-SNES:
    Happy Friday :)
  • tom_mai78101 tom_mai78101:
    Fun Friday for me
  • tom_mai78101 tom_mai78101:
    Happy Fun Friday to all.
    +2
  • The Helper The Helper:
    Happy Sunday everyone!!!
  • V-SNES V-SNES:
    Happy Sunday!!!
    +1

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top