• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Help with leaks clear and better solution for this skill

Status
Not open for further replies.
Level 3
Joined
Nov 26, 2009
Messages
35
This is my spell, every time knight suffers damage he gain armor based on stacks and strength.
I'm increasing it with a skill which have around 200 level(max str will be near at 1000 so it's enough)
But mby there a better way to do it than using a skill? It seems that there no way to increase armor directly or just i have lack of knowledge and can't find it.
Also i'm curious about leaks, did i cleared all of them?
Sorry for my bad english, not my native language and never learned it besides in WoW.
JASS:
function KnightT3Passive_Conditions takes nothing returns boolean
    return GetUnitAbilityLevelSwapped('A00J', udg_DamageEventTarget) >= 1 
endfunction

function KnightT3Stacks_Clear takes nothing returns nothing
    local timer knightT3ClearTimer = GetExpiredTimer()
    local unit target = LoadUnitHandle(udg_KnightT3HashTable, GetHandleId(knightT3ClearTimer), 2)
    local integer timerCount = LoadInteger(udg_KnightT3HashTable, GetHandleId(target), 51)
    local integer playerId = GetConvertedPlayerId(GetOwningPlayer(target))
    set timerCount = (timerCount - 1)
    call DisplayTextToForce( GetPlayersAll(), ( "timerCount - " + I2S(timerCount)) )
    if(timerCount <= 0) then
        call SaveInteger(udg_KnightT3HashTable, GetHandleId(target), 51, timerCount)
        call SetUnitAbilityLevelSwapped( 'A00R', target, 1)
        call FlushChildHashtableBJ(GetHandleIdBJ(knightT3ClearTimer), udg_KnightT3HashTable)   
        call FlushChildHashtableBJ(GetHandleIdBJ(target), udg_KnightT3HashTable)   
        call PauseTimer(knightT3ClearTimer)
        call DestroyTimer(knightT3ClearTimer)
    endif
    call SaveInteger(udg_KnightT3HashTable, GetHandleId(target), 51, timerCount)
    set target = null
endfunction

function KnightT3_Action takes nothing returns nothing 
    local timer knightT3Timer = GetExpiredTimer()
    local unit target = LoadUnitHandle(udg_KnightT3HashTable, GetHandleId(knightT3Timer), 1)
    local integer timerCount = LoadInteger(udg_KnightT3HashTable, GetHandleId(target), 51)
    local integer stacks = LoadInteger(udg_KnightT3HashTable, GetHandleId(target), 52)
    local integer armorPoints
    if(stacks >= 0  and stacks < 10) then 
        set stacks = (stacks + 1)
    endif
    call SaveInteger(udg_KnightT3HashTable, GetHandleId(target), 51, 10)  
    set armorPoints = (stacks + ( stacks * ( GetHeroStatBJ(bj_HEROSTAT_STR, target, true) / 100 ) ))
    call SetUnitAbilityLevelSwapped( 'A00R', target, (1 + armorPoints))
    call SaveInteger(udg_KnightT3HashTable, GetHandleId(target), 52, stacks)
    call FlushChildHashtableBJ(GetHandleIdBJ(knightT3Timer), udg_KnightT3HashTable)   
    call PauseTimer(knightT3Timer)
    call DestroyTimer(knightT3Timer)
    set target = null
endfunction

function KnightT3Passive_Actions takes nothing returns nothing
    local unit target = udg_DamageEventTarget
    local timer knightT3Timer = CreateTimer()
    local timer knightT3ClearTimer = CreateTimer()
    local integer check = LoadInteger(udg_KnightT3HashTable, GetHandleId(target), 51)
    if(check == 0) then
        call SaveInteger(udg_KnightT3HashTable, GetHandleId(target), 51, 10)
        call SaveUnitHandle(udg_KnightT3HashTable, GetHandleId(knightT3ClearTimer), 2, target)
        call TimerStart(knightT3ClearTimer, 1, true, function KnightT3Stacks_Clear)
    endif
    if(check > 0) then 
        call PauseTimer(knightT3ClearTimer)
        call DestroyTimer(knightT3ClearTimer)
    endif
    call SaveUnitHandle(udg_KnightT3HashTable, GetHandleId(knightT3Timer), 1, target)
    call TimerStart(knightT3Timer, 0.01, false, function KnightT3_Action)
    set target = null
endfunction

//===========================================================================
function InitTrig_KnightT3Passive takes nothing returns nothing
    set gg_trg_KnightT3Passive = CreateTrigger(  )
    call TriggerRegisterVariableEvent( gg_trg_KnightT3Passive, "udg_DamageEvent", EQUAL, 1.00 )
    call TriggerAddCondition( gg_trg_KnightT3Passive, Condition( function KnightT3Passive_Conditions ) )
    call TriggerAddAction( gg_trg_KnightT3Passive, function KnightT3Passive_Actions )
endfunction
 
Level 3
Joined
Nov 26, 2009
Messages
35
If your map uses functions that only exist in 1.31+ then it won't work on previous wc3 versions.
Those older versions don't have the new functions and you can't use what you don't have.
Then what better to use, ability or upgrade? What is "provides" less weight to the map? And what is faster?
 
Level 19
Joined
Oct 17, 2012
Messages
860
There is this custom stat system by Doomlord for older and newer patches.

Whether you want to use upgrades or abilities, it depends on whether you want the armor to show up as green bonuses or be added to base armor.
Use upgrades for base armor and abilities for green bonuses.

Is the armor bonus temporary? If it is, you will have to keep track of it. Keep in mind that in some older patches, you cannot remove upgrades. That means you will need upgrades that decrease armor. This opens up a huge can of worms. That is you will need a lot of upgrades or upgrades with a lot of levels. Depending on your circumstances, using upgrades may not be practical.
 
Last edited:
Level 3
Joined
Nov 26, 2009
Messages
35
Thanks!
I have another question, don't think that it's need a new thread.
Will this leak?
JASS:
 loop
        exitwhen looping == 0
        set looping = looping - 1
        call AddSpecialEffectTargetUnitBJ( "chest", target, "effect.mdx" )
        set infusionEffect2 = GetLastCreatedEffectBJ()
        call BlzSetSpecialEffectOrientation( infusionEffect2, GetRandomReal(15.00, 85.00), GetRandomReal(15.00, 85.00), GetRandomReal(15.00, 85.00) )
        call BlzSetSpecialEffectScale(infusionEffect2, 1.3)
        call DestroyEffect(infusionEffect2)
        set infusionEffect2 = null
    endloop
And it seems every next loop effect became bigger, so first was 1.3, next one will be 1.3*1.3 and etc.
How to do it properly?
And i have same effect on timer every 1 second for 2 seconds but 0.4 scale instead, so every time it gets a 0.4*0.4*0.4 and etc..
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,872
That won't leak. Also, setting infusionEffect2 to null is unnecessary but fine to do.

There's a bug on recent versions with Special Effect Scale and attached Special Effects in particular. It causes the scale change to be permanent and apply to future effects of the same kind. I think you have to reset it by setting the scale back to 1.0 or something along those lines.

Also, try not to use the BJ functions when possible:
vJASS:
call AddSpecialEffectTarget(modelName, targetWidget, attachPointName)
Sometimes a non-BJ version doesn't exist.
 
Last edited:
Level 3
Joined
Nov 26, 2009
Messages
35
Awesome, thanks.
Is there any way to always show maximum mana? For Example if my unit have a lot of mana then UI will show only his current mana, not something like 5232/39923.
 
Status
Not open for further replies.
Top