- Joined
- Nov 25, 2021
- Messages
- 507
So basically, I've been making a few custom abilities and stuffs, and I realized that some of them won't work properly for one reasons or another. Details below:
, and it will search the map for those with that ability, remove it, then re-add at the same level. However, I'm at a stump, because I ran out of brain juice to figure out a way to remove the global variable udg_TempAbilCode and replace it with 'myabilcode'.
tl;dr: I want to remove the use of Global Variables in my ReAdd functions.
-
Frostbite Aura
-
Events
-
Unit - A unit Learns a skill
-
-
Conditions
-
Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Learned Hero Skill) Equal to Frostbite Aura
-
-
Then - Actions
-
Unit - Remove Frostbite Damage Aura (Frostbite 1) from (Triggering unit)
-
Unit - Remove Frostbite Damage Aura (Frostbite 2) from (Triggering unit)
-
Unit - Remove Frostbite Damage Aura (Frostbite 3) from (Triggering unit)
-
Unit - Remove Frostbite Damage Aura (Frostbite 4) from (Triggering unit)
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Level of Frostbite Aura for (Triggering unit)) Equal to 1
-
-
Then - Actions
-
Unit - Add Frostbite Damage Aura (Frostbite 1) to (Triggering unit)
-
Custom script: call UnitMakeAbilityPermanent(GetLearningUnit(),true,'A69Q')
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Level of Frostbite Aura for (Triggering unit)) Equal to 2
-
-
Then - Actions
-
Unit - Add Frostbite Damage Aura (Frostbite 2) to (Triggering unit)
-
Custom script: call UnitMakeAbilityPermanent(GetLearningUnit(),true,'A69S')
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Level of Frostbite Aura for (Triggering unit)) Equal to 3
-
-
Then - Actions
-
Unit - Add Frostbite Damage Aura (Frostbite 3) to (Triggering unit)
-
Custom script: call UnitMakeAbilityPermanent(GetLearningUnit(),true,'A69T')
-
-
Else - Actions
-
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
-
If - Conditions
-
(Level of Frostbite Aura for (Triggering unit)) Equal to 4
-
-
Then - Actions
-
Unit - Add Frostbite Damage Aura (Frostbite 4) to (Triggering unit)
-
Custom script: call UnitMakeAbilityPermanent(GetLearningUnit(),true,'A69U')
-
-
Else - Actions
-
-
-
-
-
-
-
-
-
Else - Actions
-
-
-
- This is for an ability called Frostbite Aura. When learned, the Hero will gain another Aura on top of that (Frostbite Damage Aura) based on Building Damage Aura (Tornado).
- In my tests, levelling up the Damage Aura didn't work, and disabled->re-enabled also did not, so the solution is to remove the old and re-add the new when the Hero learns Frostbite Aura. This unfortunately doesn't work if the Hero is preplaced, and learned the ability beforehand.
- Since I remember that there are other abilities also working that way, I want to make a script that's like this for future-proofing:
JASS:
call ReAdd('myabilcode')
JASS:
//Still incomplete.
function ReAdd1 takes nothing returns boolean
return (GetUnitAbilityLevelSwapped(udg_TempAbilCode, GetFilterUnit()) > 0)
endfunction
function ReAdd2 takes nothing returns nothing
local integer int = GetUnitAbilityLevelSwapped(udg_TempAbilCode, GetEnumUnit())
call UnitRemoveAbilityBJ( udg_TempAbilCode, GetEnumUnit() )
set bj_forLoopAIndex = 1
set bj_forLoopAIndexEnd = int
loop
exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
call ModifyHeroSkillPoints( GetEnumUnit(), bj_MODIFYMETHOD_ADD, 1 )
call SelectHeroSkill( GetEnumUnit(), udg_TempAbilCode )
set bj_forLoopAIndex = bj_forLoopAIndex + 1
endloop
endfunction
function ReAdd3 takes nothing returns nothing
local group Group = GetUnitsInRectMatching(GetPlayableMapRect(),Condition(function ReAdd1))
call ForGroupBJ( Group, function ReAdd2 )
call DestroyGroup (Group)
endfunction
function ReAdd takes integer ID returns nothing
local integer AbilId = ID
call ReAdd3()
endfunction
, and it will search the map for those with that ability, remove it, then re-add at the same level. However, I'm at a stump, because I ran out of brain juice to figure out a way to remove the global variable udg_TempAbilCode and replace it with 'myabilcode'.
tl;dr: I want to remove the use of Global Variables in my ReAdd functions.