From 06c03c491fe90d8da1ce49b3e003691f28df6557 Mon Sep 17 00:00:00 2001 From: SMUnlimited Date: Sat, 23 Nov 2024 14:31:58 +0000 Subject: [PATCH] Slowed down tier ups #440 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 and they are not currently expanding. --- CHANGELOG.md | 1 + common.eai | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ca1e91468..4c7b06f66 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) ### Changed - Further improvements for team attacks where AI should ignore its teammates attacks e.g for the ancient barracks rush above. +- 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 and they are not currently expanding. ### Fixed diff --git a/common.eai b/common.eai index 26a412b9a..acdafa8cf 100644 --- a/common.eai +++ b/common.eai @@ -11509,6 +11509,7 @@ function OneBuildLoopAM takes nothing returns nothing local integer tracednoresources = 0 local integer tracedall = 0 local string logtype = "" + local boolean blocktierup = false call InitLastUpkeep() @@ -11558,7 +11559,9 @@ 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 then + if tp == BUILD_UNIT and IsRacialHallId(id, 1) and blocktierup then + set ret = CANNOT_BUILD // Not ready to tier up + elseif tp == BUILD_UNIT then set logtype = "unit " set ret = StartUnitAM(qty,id,build_town[index], build_loc[index], build_prio[index], mo) elseif tp == BUILD_UPGRADE then @@ -11566,7 +11569,8 @@ function OneBuildLoopAM takes nothing returns nothing set ret = StartUpgradeAM(qty,id) elseif tp == BUILD_EXPAND then set logtype = "expand " - set ret = StartExpansionAM(qty,id) + set ret = StartExpansionAM(qty,id) // Don't tier up while doing a higher priority expansion + set blocktierup = true elseif tp == BUILD_ITEM then set logtype = "item " set ret = StartItem(qty,id) @@ -11594,6 +11598,9 @@ function OneBuildLoopAM takes nothing returns nothing call Trace("NO RESOURCES " + logtype + unitNames[id] + " " + Int2Str(id)) set tracednoresources = id endif + if tp == BUILD_UNIT and (ret == CANNOT_BUILD or ret == BUILT_SOME) and qty < build_qty[index] *0.75 then + set blocktierup = true // Block tier up if a large proportion of requested units of strategy not built + endif exitwhen ret == NOT_ENOUGH_RES and tp != BUILD_ITEM and tp != BUILD_UPGRADE // Don't try and build anything else as thing we trying to buy is too expensive if ret == CANNOT_BUILD or ret == BUILT_SOME or ret == NOT_ENOUGH_RES or (ret == BUILT_ALL and qty < build_qty[index]) then set build_qty[index_free] = build_qty[index]