Skip to content

Commit

Permalink
Expansion fixes and prep 3.3.5
Browse files Browse the repository at this point in the history
  • Loading branch information
SMUnlimited committed Jun 7, 2024
1 parent 4deb872 commit 1ac8383
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 18 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion REFORGED/Elf/Settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion TFT/Elf/Settings.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
58 changes: 43 additions & 15 deletions common.eai
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -6002,33 +6004,41 @@ 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)
set g = SelectByAlive2(g, true)
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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -10949,13 +10974,16 @@ 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
call BuildExpa(TownCount(racial_expansion) + 1, racial_expansion, expa_rebuild_prio)
else
call BuildExpa(TownCount(racial_expansion) + 1, racial_expansion, expa_prio)
endif
else
call Trace("ExpansionBuilder: Not ready to build mine")
endif

endfunction
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -13294,15 +13320,17 @@ 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)
call HarvestWood(0,pwh)
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
Expand Down

1 comment on commit 1ac8383

@jzy-chitong56
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try #309

Please sign in to comment.