Skip to content

Commit

Permalink
Fix #253
Browse files Browse the repository at this point in the history
  • Loading branch information
SMUnlimited committed Feb 24, 2024
1 parent c25bc61 commit cfec1bf
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fix water expansion distance not calculated correctly. (jzy-chitong56)
- In certain languages if translated chat messages with variable placeholders cannot be parsed at least still return the message rather than complete nonsense.
- Fixed an issue where only a specific creep needs to be killed for AMAI to think mines and neutral buildings were unguarded going forwards.
- Fixed an issue where town threat was always 0 or negative so AMAI couldn't tell it was in danger correctly.
- (Classic) Fixed game start crash with AMAI vs AI. (jzy-chitong56)
- (Classic) Fixed some TFT settings not in sync with REFORGED.
- (DevTools) Fixed the optimize all script and the makeAll and optimizeAll scripts will pause between versions.
Expand Down
11 changes: 6 additions & 5 deletions Jobs/ARMY_TRACK.eai
Original file line number Diff line number Diff line change
Expand Up @@ -187,14 +187,14 @@ function UpdateSpecificTownThreat takes integer num returns nothing
exitwhen i >= army_num
set dist = RMax(DistanceBetweenPoints(army_future[i], town_loc[num]), full_threat_distance)
if dist <= no_threat_distance then
set loc = GetSubtractionLoc(town_loc[num], army_loc[i])
set loc = GetSubtractionLoc(town_loc[num], army_loc[i])
if DistanceBetweenPoints(army_loc[i], town_loc[num]) < GetLengthOfLoc(army_dir[i]) and RAbs(GetAngleBetweenLocs(army_dir[i], loc)) <= 0.4 then
set dist = full_threat_distance
endif
call RemoveLocation(loc)
set loc = null
call RemoveLocation(loc)
set loc = null
set threat = distance_threat_mult * army_strength[i] / Pow(dist, distance_threat_exponent)
if IsPlayerAlly(Player(town_owner[num]), Player(army_owner[i])) or Player(town_owner[num]) == ai_player then
if IsPlayerAlly(Player(town_owner[num]), Player(army_owner[i])) or Player(army_owner[i]) == ai_player then
set town_threat[num] = town_threat[num] - threat
else
set town_threat[num] = town_threat[num] + threat
Expand Down Expand Up @@ -239,7 +239,8 @@ function UpdateTownThreat takes nothing returns nothing
if i >= town_num then
set mode = 3
set lastFreeNum = 0
if town_threat[most_threatened_town] > accepted_threat_level and town_threat[most_threatened_town] > (I2R(c_ally_total + 1) / c_enemy_total) * town_threat[most_threatened_enemy_town] then
call Trace ("ThreatenedTownThreat:" + Real2Str(town_threat[most_threatened_town]) + " AcceptedThreatLevel:" + Real2Str(accepted_threat_level))
if town_threat[most_threatened_town] > accepted_threat_level then //and town_threat[most_threatened_town] > (I2R(c_ally_total + 1) / c_enemy_total) * town_threat[most_threatened_enemy_town] then
set town_threatened = true
endif
if town_threatened then
Expand Down
8 changes: 5 additions & 3 deletions Jobs/TOWN_TRACK.eai
Original file line number Diff line number Diff line change
Expand Up @@ -128,9 +128,11 @@ endfunction

function TownTrackJob takes nothing returns nothing
call DisplayToAllJobDebug("TOWN_TRACK Job Start")
call GroupClear(in_town_group)
call TrackExistingTowns()
call SeedNewTowns()
if not town_threatened then
call GroupClear(in_town_group)
call TrackExistingTowns()
call SeedNewTowns()
endif
//call TQAddJob(15, TOWN_TRACK, 0)
call TQAddJob(1, ARMY_TRACK, 0) // Always runs army track after updating towns as otherwise most threatened town will not be correct
endfunction
Expand Down

0 comments on commit cfec1bf

Please sign in to comment.