• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Why does it leak ?

Status
Not open for further replies.
Level 17
Joined
Jul 1, 2010
Messages
721
JASS:
local unit u = GetSpellTargetUnit()
    local unit a
    local location tl = GetUnitLoc(u)
    local unit t = GetSpellAbilityUnit()
    call CreateNUnitsAtLoc( 1, 'e000', GetOwningPlayer(t), tl, bj_UNIT_FACING )
    set a = GetLastCreatedUnit()
    call UnitApplyTimedLifeBJ( 2.00, 'BTLF', a )
    call UnitAddAbility( a, 'A007')
    call IssueTargetOrderBJ( a, "soulburn", u )
    set a = null
    call RemoveLocation( tl )
    set t = null
    call UnitAddAbility( u, 'Abun')
    call UnitAddAbility( u, 'Awan')
    call TriggerSleepAction( 45 )
    call UnitRemoveAbility( u, 'Abun' )
    call UnitRemoveAbility( u, 'Awan' )

    set u = null


This happens when a unit casts a spell. The spell is MUI but when I cast it multiple times or other units cast it my computer starts lagging badly...
 
Level 6
Joined
Jun 20, 2011
Messages
249
What mag meant is that this forum should be impossible to post to people and only mods can move things here lol.

QUICK UPLOAD YOUR RESOURCES TO GET THEM INSTA-APPROVED

local unit a = CreateNUnitsAtLoc( 1, 'e000', GetOwningPlayer(t), tl, bj_UNIT_FACING )

Avoid the use of locations at all times.

local unit a = CreateUnit(player,unit,x,y,facing)
 
Level 17
Joined
Jul 1, 2010
Messages
721
Ok here's the whole trigger, I replaced everything like you guys told me and I think I know where the problem is. It's because the local unit u is kept in memory for 45 seconds as I need it and afterwards it's cleaned. Isn't there another way to do this ?
JASS:
function Trig_Blind_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'A008' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Blind_Actions takes nothing returns nothing
    local unit u = GetSpellTargetUnit()
    local real x = GetUnitX(u)
    local real y = GetUnitY(u)
    local unit a = null
    local unit t = GetSpellAbilityUnit()
    set a = CreateUnit(GetOwningPlayer(t), 'e000', x, y, 0.0 )
    call UnitApplyTimedLife( a, 'BTLF', 2.00 )
    call UnitAddAbility( a, 'A007')
    call IssueTargetOrder( a, "soulburn", u )
    set a = null
    set t = null
    set x = 0
    set y = 0
    call UnitAddAbility( u, 'Abun')
    call UnitAddAbility( u, 'Awan')
    call TriggerSleepAction( 45 )
    call UnitRemoveAbility( u, 'Abun' )
    call UnitRemoveAbility( u, 'Awan' )

    set u = null
endfunction

//===========================================================================
function InitTrig_Blind takes nothing returns nothing
    set gg_trg_Blind = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Blind, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Blind, Condition( function Trig_Blind_Conditions ) )
    call TriggerAddAction( gg_trg_Blind, function Trig_Blind_Actions )
endfunction
 
It possibly could.
Timer expirations happening at the same time could cause lag, but trust me. Even if 2 units cast the spell with a time difference of a hundredth of a second, it shouldn't matter at all.

Timers are the best way to go. TriggerSleepAction causes a lot of problems when used outside of single-player mode.
TriggerSleepAction doesn't work unless a function needs to return something.
Plus, since most of us use conditions for anything instead of actions, we can't use TriggerSleepAction anyway.

Trust me bro, timers win hands down.
 
Status
Not open for further replies.
Top