From 1ac8383e7f3844e195a60bb253c67dca19a1e3bb Mon Sep 17 00:00:00 2001 From: SMUnlimited Date: Fri, 7 Jun 2024 17:29:08 +0100 Subject: [PATCH] Expansion fixes and prep 3.3.5 --- CHANGELOG.md | 7 ++++- REFORGED/Elf/Settings.txt | 2 +- TFT/Elf/Settings.txt | 2 +- common.eai | 58 +++++++++++++++++++++++++++++---------- 4 files changed, 51 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 331463cb0..a28cbebb2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,10 +3,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) -## Unreleased +## [3.3.5a] - 2024-06-07 + +### Changed +- If AI is not strong enough to creep an expansion it won't save resources and instead use them to buy more units. ### Fixed - Fixed an issue where the undead meat fiend strategy hero wasn't built first which blocked anything from building for the first minute. +- Fixed an issue where AI would expand less consistently because it decided it wanted to expand to an existing expansion. +- Disabled elf building farms on the front line as it too often causes blockages until we can work out a solution. ## [3.3.5] - 2024-06-05 diff --git a/REFORGED/Elf/Settings.txt b/REFORGED/Elf/Settings.txt index c0a422cdd..6999a0d96 100644 --- a/REFORGED/Elf/Settings.txt +++ b/REFORGED/Elf/Settings.txt @@ -66,7 +66,7 @@ race_item_sale_level 0 buy expand item need hall level ? race_item_expansion_item_id 0 what is expand item name(from StandardUnits.txt) ? race_sell_ziggurats false does the race sell ziggurats that are at no more needed expansions ? race_ziggurat_keep_distance 1500 keep ziggurat if this near another building except a ziggurat is -race_build_farms_front true should the race build farms towards the front (as soon as the front is computed) ? +race_build_farms_front false should the race build farms towards the front (as soon as the front is computed) ? race_farms_front_limit 4 limit the number of farms at the front to this number race_farms_at_mine 0 the first that many farms will be built at the mine race_max_expa_mine_distance 850 the maximum distance between the mine and the expansion building diff --git a/TFT/Elf/Settings.txt b/TFT/Elf/Settings.txt index c0a422cdd..6999a0d96 100644 --- a/TFT/Elf/Settings.txt +++ b/TFT/Elf/Settings.txt @@ -66,7 +66,7 @@ race_item_sale_level 0 buy expand item need hall level ? race_item_expansion_item_id 0 what is expand item name(from StandardUnits.txt) ? race_sell_ziggurats false does the race sell ziggurats that are at no more needed expansions ? race_ziggurat_keep_distance 1500 keep ziggurat if this near another building except a ziggurat is -race_build_farms_front true should the race build farms towards the front (as soon as the front is computed) ? +race_build_farms_front false should the race build farms towards the front (as soon as the front is computed) ? race_farms_front_limit 4 limit the number of farms at the front to this number race_farms_at_mine 0 the first that many farms will be built at the mine race_max_expa_mine_distance 850 the maximum distance between the mine and the expansion building diff --git a/common.eai b/common.eai index cb0a13cd9..774ca464b 100644 --- a/common.eai +++ b/common.eai @@ -5992,6 +5992,8 @@ function CheckExpansionTaken takes unit expa returns boolean local unit u = null local integer claimedMines = 0 local integer minecount = 0 + local integer ownedmines = 0 + local boolean mineclaimed = true if expa == null then return false elseif expa == not_taken_expansion then // Used in the ancient expansion and item expansion system @@ -6002,7 +6004,6 @@ function CheckExpansionTaken takes unit expa returns boolean endif set g = CreateGroup() call GroupEnumUnitsInRange(g, GetUnitX(expa), GetUnitY(expa), expansion_taken_radius, null) - call GroupRemoveUnit(g, expa) set g = SelectByPlayer(g, Player(PLAYER_NEUTRAL_AGGRESSIVE), false) set g = SelectUnittype(g, UNIT_TYPE_STRUCTURE, true) //set g = SelectByAlive(g, true) @@ -6010,25 +6011,34 @@ function CheckExpansionTaken takes unit expa returns boolean loop set u = FirstOfGroup(g) exitwhen u == null + // Enemy holds the area if IsPlayerEnemy(GetOwningPlayer(u), ai_player) then call DestroyGroup(g) set g = null set u = null return true endif - if IsUnitGoldMine(u) or IsUnitType(u,UNIT_TYPE_TOWNHALL) then - if IsValidMineClaimed(u) and DistanceBetweenUnits(u, expa) < race_max_expa_mine_distance then + if u == expa then + set mineclaimed = false // Mine not been captured by elf or undead + endif + if IsUnitGoldMine(u) then // This is just informative doesnt affect check + if GetOwningPlayer(u) == Player(PLAYER_NEUTRAL_PASSIVE) then + set minecount = minecount + 1 + else + set ownedmines = ownedmines + 1 + endif + endif + // A single town hall of humans and orcs can capture close enough mines + // For now elf will also claim the mines, due to elf mine has to wait for tree of ages to be built so don't want allies to grab mine before its complete. + if IsUnitType(u,UNIT_TYPE_TOWNHALL) and GetUnitTypeId(u) != old_id[NECROPOLIS_1] and GetUnitTypeId(u) != old_id[NECROPOLIS_2] and GetUnitTypeId(u) != old_id[NECROPOLIS_3] and DistanceBetweenUnits(u, expa) < race_max_expa_mine_distance then set claimedMines = claimedMines + 1 - endif - if not IsUnitType(u, UNIT_TYPE_TOWNHALL) then - set minecount = minecount + 1 // Informative but not used - endif endif call GroupRemoveUnit(g, u) endloop call DestroyGroup(g) set g = null - return claimedMines >= 1 // While there may be extra mines, we focusing on is this mine taken + call CreateDebugTagLoc("Mines:" + Int2Str(minecount) +" Taken:" + Int2Str(claimedMines) + " Own:" + Int2Str(ownedmines), 10, GetUnitX(expa), GetUnitY(expa), 10.00, 1.80) + return claimedMines >= 1 or mineclaimed// While there may be extra mines, we focusing on is this mine taken endfunction // Prevent some map creeps too far away @@ -10476,20 +10486,28 @@ function StartExpansionAM takes integer qty, integer hall returns integer local boolean f = false local boolean w = false if countdone >= qty then + call Trace("AMAIStartexpa: Built All Expansions") return BUILT_ALL endif - if (count > countdone) or town_threatened then + if (count > countdone) then + call Trace("AMAIStartexpa: All Expansions being built") + return BUILT_SOME + endif + + if town_threatened then + call Trace("AMAIStartexpa: Town threatened") return BUILT_SOME endif if first_town_mine > 1 and MultipleMinefix() then + call Trace("AMAIStartexpa: Built All MultiMineFix") return BUILT_ALL endif if current_expansion == null or CheckExpansionTaken(current_expansion) then call ChooseExpansion() if current_expansion == null then - call Trace("AMAIStartexpa: Expansion Not Found") + call Trace("AMAIStartexpa: Expansion Not Found") return BUILT_ALL endif endif @@ -10523,6 +10541,12 @@ function StartExpansionAM takes integer qty, integer hall returns integer set take_exp = (GetExpFoe(u) != null) set u = null if take_exp then + if GetOwnStrength() <= GetExpansionStrength() then + // Not strong enough to take mine so don't save gold and wood for expansion, use to build more troops instead + set total_gold = total_gold + gold_cost + set total_wood = total_wood + wood_cost + endif + call Trace("AMAIStartexpa: Need to remove creeps from expansion") return BUILT_SOME // If creeps need clearing save the gold but don't block building at the moment as may need troops endif @@ -10876,6 +10900,7 @@ local unit u = null local boolean upkeepboost = false if not first_expansion_chosen then + call Trace("ExpansionBuilder: First expansion not chosen") return endif if current_expansion == null or CheckExpansionTaken(current_expansion) then @@ -10949,6 +10974,7 @@ endloop if mines < 1 or gold_left < 2500 or exp_prepared then call Trace("ExpansionBuilder: Putting mine on build list") + call CreateDebugTagLoc("Current Expansion", 10, GetUnitX(current_expansion), GetUnitY(current_expansion), 1.00, 0.80) if mines < 1 or gold_left < 2500 then call BuildExpa(TownCount(racial_expansion) + 1, racial_expansion, expa_emergency_prio) elseif rebuild or upkeepboost then @@ -10956,6 +10982,8 @@ if mines < 1 or gold_left < 2500 or exp_prepared then else call BuildExpa(TownCount(racial_expansion) + 1, racial_expansion, expa_prio) endif +else + call Trace("ExpansionBuilder: Not ready to build mine") endif endfunction @@ -12806,11 +12834,9 @@ function SingleMeleeAttackAM takes boolean needs_exp, boolean has_siege, boolean set hall = ChooseAttackTarget(hall) if hall != null and UnitAlive(hall) then - call SetAllianceTargetIfLeadAndChat(alli_target, C_Attack) // This technically won't work as the new attack move in the sleep loop will redirect this player as well to this target - //set alli_target = null + call SetAllianceTargetIfLeadAndChat(alli_target, C_Attack) call FormGroupAM(3) call AttackMoveKillAAM(hall) - call ClearAllianceTarget(hall) set hall = null return endif @@ -13294,7 +13320,9 @@ function universal_peon_assignment takes nothing returns nothing if (desperation_assault) then return endif - + + call Trace("Harvest Gold at Town:" + Int2Str(T) ) + call CreateDebugTagLoc("MINES:" + Int2Str(GetMinesOwned()) + ":" + Int2Str(T), 10, GetLocationX(home_location), GetLocationY(home_location), 1.00, 0.80) call HarvestGold(T,ver_optimal_gold - 1) call HarvestWood(0,1) call HarvestGold(T,1) @@ -13302,7 +13330,7 @@ function universal_peon_assignment takes nothing returns nothing call HarvestWood(0,swh) set T = Max(T + 3,TownCountDone(racial_expansion)) - call CreateDebugTagLoc("MINES:" + Int2Str(GetMinesOwned()), 10, GetLocationX(home_location), GetLocationY(home_location), 1.00, 0.80) + //call CreateDebugTagLoc("MINES:" + Int2Str(GetMinesOwned()), 10, GetLocationX(home_location), GetLocationY(home_location), 1.00, 0.80) loop exitwhen i > T if T != i and TownHasMine(i) and TownCountEx(racial_expansion,true,i) > 0 then