• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[AI] Let Campaign AI build expansions

Status
Not open for further replies.
Level 25
Joined
Feb 2, 2006
Messages
1,687
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