• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[AI] Let Campaign AI build expansions

Status
Not open for further replies.
Level 27
Joined
Feb 2, 2006
Messages
1,577
Hi,
another question again. This time about AI scripts. I would love to improve the AI in my map. I have written multiple campaign AI scripts for the different races and a modified common.ai:

From the common.ai, for a Campaign AI StartBuildLoop is called which calls in a loop:

JASS:
exitwhen index == build_length

        set qty = build_qty [index]
        set id  = build_item[index]
        set tp  = build_type[index]

        //--------------------------------------------------------------------
        if tp == BUILD_UNIT then
            if not StartUnit(qty,id,build_town[index]) then
                return
            endif

        //--------------------------------------------------------------------
        elseif tp == BUILD_UPGRADE then
            call StartUpgrade(qty,id)

        //--------------------------------------------------------------------
        else // tp == BUILD_EXPAND
            if not StartExpansion(qty,id) then
                return
            endif
        endif

and then in StartExpansion:

JASS:
set count = TownCount(hall)
    if count >= qty then
        return true
    endif

so everything looks like I have to call:

JASS:
call SetBuildExpa(5, TOWN_HALL) // 5 is the number of expansions

Is this correct? How do I specify then which buildings will be build in the main base and which in the expansion?
Do I have to set the town parameter of:

JASS:
function SetBuildAll takes integer t, integer qty, integer unitid, integer town returns nothing
but is t set as BUILD_UNIT?

Basically the expansions should be used to get more gold and lumber and be guarded with some tower.s, maybe 1 shop. That's it. It should make the game more interesting since you find the main base but then there could be more.
Do campaign AIs try to rebuilt their base always at their starting location or at an expansion? For example, if you destroy all of there buildings in the main base but the expansion is left. What will happen next?

Currently I am using Campaign AIs. Would there be any benefit to switch to Melee AIs? Is it even possible with custom races? My custom races use lots of custom units and only have 1 hero.
 
Status
Not open for further replies.
Top