diff --git a/CHANGELOG.md b/CHANGELOG.md index 54b2beae7..7123d52f2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,7 +10,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) - (DevTools) New block available for strategies. E.g `SetTierBlock(1, 0.75, 60, true)` that blocks tiering up from tier 1 unless more than 75% of higher priority units are built. Unlocks if over 60 food. Final argument prevents tier up while expanding if set to true. Tier block overrides previous tier level block if repeated in a strategy. ### Changed -- When we enhanced the build code to build other things if it can't build the current priorities it caused strategies to tier up much earlier than designed, so now tier ups can only happen once most higher priority unit production is done honoring the strategy and they are not currently expanding. +- When we enhanced the build code to build other things if it can't build the current priorities it caused strategies to tier up much earlier than designed. Now tier ups can only occur as follows: + - once most higher priority unit production is done honoring the strategy. + - No expansion occurring unless we already have multiple mines to support the cost. + - Or we have lots and lots of spare gold and wood so should just use it to tier up. - Building additional factory buildings should not be done while actively tiering up as the buildings needed for tier 2/3 may be different. - Harass will correctly keep harassing if no units can harm its air harass. - Harass attacks will return harassing units faster to the ai's control when complete. diff --git a/common.eai b/common.eai index c6685b86c..7e06e00ef 100644 --- a/common.eai +++ b/common.eai @@ -594,6 +594,7 @@ globals integer array bl_tier_foodlock real array bl_tier_unitlock boolean array bl_tier_expansionblock + boolean array bl_tier_lockactive //============================================================== // (AMAI) Standard Unit Variables @@ -11640,6 +11641,7 @@ function OneBuildLoopAM takes nothing returns nothing local integer tracedall = 0 local string logtype = "" local boolean blocktierup = false + local boolean expablocktier = false call InitLastUpkeep() @@ -11689,10 +11691,13 @@ function OneBuildLoopAM takes nothing returns nothing // call DumpInteger("Prio"+Int2Str(index),build_prio[index]) if qty > mo and qty > 0 then - if tp == BUILD_UNIT and IsRacialHallId(id, 2) and blocktierup then + if tp == BUILD_UNIT and IsRacialHallId(id, 2) and ((blocktierup and bl_tier_lockactive[tier - 1]) or expablocktier) and GetUnitGoldCost2(id) * 4 > total_gold and GetUnitWoodCost2(id) * 4 > total_wood then call Trace("TIER UP block " + logtype + unitNames[id] + " " + Int2Str(id)) set ret = CANNOT_BUILD // Not ready to tier up elseif tp == BUILD_UNIT then + if IsRacialHallId(id, 2) then + set bl_tier_lockactive[tier - 1] = false // lock only occurs once per tier, once lock is unlocked for that tier it stays unlocked e.g it doesn't have to start from scratch again if strategy changes or units die within tier 1 + endif set logtype = "unit " set ret = StartUnitAM(qty,id,build_town[index], build_loc[index], build_prio[index], mo) elseif tp == BUILD_UPGRADE then @@ -11701,8 +11706,8 @@ function OneBuildLoopAM takes nothing returns nothing elseif tp == BUILD_EXPAND then set logtype = "expand " set ret = StartExpansionAM(qty,id) - if ret == BUILT_SOME then // block tier up while actually expanding - set blocktierup = bl_tier_expansionblock[tier - 1] + if ret == BUILT_SOME and GetMinesHarvested() < 3 then // block tier up while actually expanding or enough mines to support this + set expablocktier = bl_tier_expansionblock[tier - 1] endif elseif tp == BUILD_ITEM then set logtype = "item " diff --git a/races.eai b/races.eai index 9e257d42e..3348464dc 100644 --- a/races.eai +++ b/races.eai @@ -772,6 +772,12 @@ function build_sequence_all takes nothing returns nothing local boolean reset_counter = false call Trace("Starting Build Sequence Loop") + loop + exitwhen new_tier >= tiernum + set bl_tier_lockactive[new_tier] = true + set new_tier = new_tier + 1 + endloop + set new_tier = 0 loop exitwhen player_defeated