Skip to content

Commit

Permalink
Fix unavailable hero units #333
Browse files Browse the repository at this point in the history
  • Loading branch information
SMUnlimited committed Nov 18, 2024
1 parent cc03337 commit 92db457
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Fix an issue where ranged micro could sometimes move ally computer and player units.
- Logic to build multiple unit buildings takes better account of cost to construct these to avoid building multiple when there is no resources available to do so.
- Fix critical issue where retreating forces never fully retreated home, they could just immediately go back into battle.
- Fix an issue where healer units are not available until next attack iteration.
- Fix PERIAPT_OF_VITALITY gold cost to correct reforged value. (Slayer95)
- Fix ally attack target not being reset, particularly expansion seemed to be slower without fix. (jzy-chitong56)
- Fix Goblin Tinker Skill not upgrading past rockets on one of the trees. (jzy-chitong56)
Expand Down
1 change: 1 addition & 0 deletions Jobs/MICRO_HERO.eai
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,7 @@ function ExecuteSaveHero takes integer hn, integer a, unit healer returns nothin
endif
if a == ACTION_HEALER and healer != null and GetUnitState(hero_unit[hn], UNIT_STATE_LIFE) >= 0.40 * GetUnitState(hero_unit[hn], UNIT_STATE_MAX_LIFE) then
call GroupAddUnit(unit_healing, hero_unit[hn])
call GroupAddUnit(unit_healing, healer)
call CreateDebugTag("HERO: Going to Healer", 10, hero_unit[hn], 4.00, 2.00)
set unitloc = GetUnitLoc(healer)
if GetLocationX(last_enemy_loc) != 0 and GetLocationY(last_enemy_loc) != 0 then
Expand Down
1 change: 1 addition & 0 deletions Jobs/MICRO_UNITS.eai
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ function SaveUnit takes unit u , integer id returns nothing
call IssuePointOrderLoc(u, "move", unitloc)
endif
call GroupAddUnit(unit_healing, u)
call GroupAddUnit(unit_healing, healer)
call RemoveLocation(unitloc)
set unitloc = null
call HealUnit(healer, u, false)
Expand Down
12 changes: 9 additions & 3 deletions common.eai
Original file line number Diff line number Diff line change
Expand Up @@ -7240,21 +7240,27 @@ function HealUnit takes unit healer, unit to_heal, boolean hero_heal returns not
call IssueTargetOrderById(healer, healer_spell[id], to_heal)
endif
endif
call GroupRemoveUnit(unit_healing, healer)
endif
endfunction

//============================================================================
function GetHealer takes unit u returns unit
local integer id = 0
local group rg = CopyGroup(healer_group)
loop
set u = FirstOfGroup(healer_group)
set u = FirstOfGroup(rg)
exitwhen u == null
set id = GetHealerId(GetUnitTypeId(u))
if id != -1 and not IsUnitLoaded(u) and UnitAlive(u) and GetUnitState(u, UNIT_STATE_MANA) >= healer_mana_cost[id] and ((healer_upg_id[id] == 0) or (GetUpgradeLevel(healer_upg_id[id]) >= healer_upg_level[id])) then
if id != -1 and not IsUnitLoaded(u) and UnitAlive(u) and GetUnitState(u, UNIT_STATE_MANA) >= healer_mana_cost[id] and ((healer_upg_id[id] == 0) or (GetUpgradeLevel(healer_upg_id[id]) >= healer_upg_level[id])) and not IsUnitInGroup(u, unit_healing) then
call DestroyGroup(rg)
set rg = null
return u
endif
call GroupRemoveUnit(healer_group, u)
call GroupRemoveUnit(rg, u)
endloop
call DestroyGroup(rg)
set rg = null
return u
endfunction

Expand Down

0 comments on commit 92db457

Please sign in to comment.