HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

AI Script: Ordering AI to create an expansion

03-25-2007, 12:31 AM#1
The__Prophet
How do I order an AI to create an expansion. After looking through other AI files, I found the way the AI Editor creates expansions, is using the following function:
Collapse JASS:
function BuildExpansion takes integer hallID, integer mineID returns nothing
    if (HallsCompleted(hallID)) then
        call SetBuildExpa( TownCount(hallID) + 1, mineID )
    endif
endfunction

However, I can't get this to work. When I see others call this function, like for instance, orc.ai, they put the hallID for both the hallID and the mineID.

Collapse JASS:
    call BuildExpansion( 'ogre', 'ogre' )

Why?
03-25-2007, 12:43 AM#2
moyack
WEll, I've checked orc.ai and this AI uses this function: call BasicExpansion( c_mines < 2, GREAT_HALL )
which takes a boolean comparison to activate the expansion building.
03-25-2007, 01:06 AM#3
The__Prophet
So I tried running the function:
Collapse JASS:
    call BasicExpansion(true, Expansion)

And... the game crashed. What gives?
03-25-2007, 01:39 AM#4
Av3n
Firstly try doing all the bulding stra in the AI editor then convert it to JASS (.ai file)

-Av3n
03-25-2007, 03:29 AM#5
The__Prophet
Quote:
Originally Posted by Av3n
Firstly try doing all the bulding stra in the AI editor then convert it to JASS (.ai file)

-Av3n

I already did what you told me to do. Read my first post again.
03-27-2007, 05:15 AM#6
The__Prophet
Heres my build Priority script if this helps: Note everytihng works fine up until the ai tries to build an expansion. The game crashes at that point.
Collapse JASS:
function BuildPriorities takes nothing returns nothing
    local integer c_mines = GetMinesOwned()
    call MeleeTownHall(0, Main )
    call MeleeTownHall(1, Main )
    call SetBuildUnit(3, Peasant)  
    call SetBuildUnit(3, Marine_Barracks)
    call SetBuildUnit(4, Supply_Depot)
    call SetBuildUnit(12, Combat_Marine)
    call SetBuildUnit(10, Marine_Rifleman)
    call SetBuildUnit(10, Defense_Turret)
    call SetBuildUnit(8, Supply_Depot)
    call SetBuildUnit(1, Special_Forces_Center)
    
    call BasicExpansion( c_mines < 3, Main ) //Crashes Here   
    
    call SetBuildUnit(1, Radar_Center)
    call SetBuildUnit(1, Factory)
    call SetBuildUnit(2, Plasma_Tower)
    call SetBuildUnit(1, Mortar_Team)  
    call SetBuildUnit(1, Mech)
    call SetBuildUnit(1, Radar_Center)
    call SetBuildUnit(2, Factory)
    call SetBuildUnit(1, Tech_Facility)
    call SetBuildUnit(1, AirPort)    
    call SetBuildUnit(2, Radar_Center)
    call SetBuildUnit(12, Defense_Turret)    
    call SetBuildUnit(5, Marine_Barracks)
    call SetBuildUnit(15, Supply_Depot)
    call SetBuildUnit(25, Combat_Marine)
    call SetBuildUnit(25, Marine_Rifleman)    
    call SetBuildUnit(4, Mortar_Team)  
    call SetBuildUnit(3, Mech)
    call SetBuildUnit(4, Radar_Center)
    call SetBuildUnit(3, Factory)              
        
endfunction
03-27-2007, 11:28 PM#7
Zycat
All BasicExpansion and SetBuildExpa (and actually, all SetBuildUnit and Upgrades) do is adding into an "array" list of build orders, which then get executed by OneBuildLoop function.

OneBuildLoop is executed each second normally and will call StartExpansion when it encounters an expo job.

There are three important functions that the script will execute, that is GetNextExpansion(), GetExpansionPeon(), and SetExpansion(peon,hall).

I'm thinking you screwed up one of those functions with unconventional units, try checking/changing your peasant/gold mines/hall
03-27-2007, 11:54 PM#8
The__Prophet
Yea that would make sense, since the ai is for a custum race, with custum peons, expansions, and gold mines.