- Joined
- May 10, 2024
- Messages
- 57
Hi,
I have multiple custom abilities based on Inner Fire and I have one function for that ability which holds the logic. In vanilla game, Priest can cast Inner Fire only after research. In my map some units can cast Inner Fire without research.
I'm looking for universal solution that will work the same way as it work for user in the interface. If ability is not researched, then it is greyed out and cannot be clicked. I need to detect that state.
I have multiple custom abilities based on Inner Fire and I have one function for that ability which holds the logic. In vanilla game, Priest can cast Inner Fire only after research. In my map some units can cast Inner Fire without research.
JASS:
// this function selects proper target and issue "innerfire" order on that target
function AbilityInnerFire takes unit whichUnit, integer abilityId returns nothing
local integer techLevel = GetPlayerTechCount(GetOwningPlayer(whichUnit), 'ResearchCode', true)
if (techLevel >= 2) then
// If ability requires technology then it works just fine but it is not working if technology is not needed
endif
// I can solve this problem comparing types of the unit or abilityId
// The problem is that I need to edit this code each time I add or change something for this ability.
if (GetUnitTypeId(whichUnit) == 'PriestId' or abilityId == "HealWithTechRequrement") then
endif
endfunction
I'm looking for universal solution that will work the same way as it work for user in the interface. If ability is not researched, then it is greyed out and cannot be clicked. I need to detect that state.
JASS:
function IsAbilityGrayedOutAndCannotBeClicked takes unit whichUnit, integer abilityId returns boolean
// Initially I thought ability level will be 0 if ability is not available (researched), but it is not 0.
endfunction