Skip to content

Commit

Permalink
Slowed down tier ups #440
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
SMUnlimited committed Nov 23, 2024
1 parent 01d4433 commit 06c03c4
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
11 changes: 9 additions & 2 deletions common.eai
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down Expand Up @@ -11558,15 +11559,18 @@ 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
set logtype = "upgrade "
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)
Expand Down Expand Up @@ -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]
Expand Down

0 comments on commit 06c03c4

Please sign in to comment.