Won't kill effects

D.V.D

Make a wish
Reaction score
73
Ok, I made another spell called Dragon's Souls that I wanted to post on The helper but it's got some glitches. There are no Jass errors but the effects won't die. The spell makes fire appear around a circle and red balls fly up after a unit with a effect dies but the effects just stay there.Here's the code:
JASS:

function Trig_Dragon_Souls_Conditions takes nothing returns boolean
    if ( not ( GetSpellAbilityId() == 'AHtb' ) ) then
        return false
    endif
    return true
endfunction

function Trig_Dragon_Souls_Actions takes nothing returns nothing
    call UnitAddAbilityBJ( 'ANpi', GetSpellTargetUnit() )
endfunction

//===========================================================================
function InitTrig_Dragon_Souls takes nothing returns nothing
    set gg_trg_Dragon_Souls = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Dragon_Souls, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Dragon_Souls, Condition( function Trig_Dragon_Souls_Conditions ) )
    call TriggerAddAction( gg_trg_Dragon_Souls, function Trig_Dragon_Souls_Actions )
endfunction


JASS:

function Trig_Dragon_Souls_Death_Func001C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('ANpi', GetDyingUnit()) == 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Dragon_Souls_Death_Actions takes nothing returns nothing
    local unit Target = GetDyingUnit()
    local unit array Effect
    local effect array Fire 
    local integer ArrayNumber = 0 
    local integer UnitArray = 0 
    local real Angle = 0.00  
    if ( Trig_Dragon_Souls_Death_Func001C() ) then
        call CreateNUnitsAtLocFacingLocBJ( 1, 'h001', GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetDyingUnit()), GetUnitLoc(GetTriggerUnit()) )
        set Effect[0] = GetLastCreatedUnit()
        call UnitApplyTimedLifeBJ( 5, 'BTLK', Effect[0] )
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = 10
        loop
            exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
            call AddSpecialEffectLocBJ( PolarProjectionBJ(GetUnitLoc(GetDyingUnit()), 400.00, Angle), "Doodads\\Cinematic\\TownBurningFireEmitter\\TownBurningFireEmitter.mdl" )
            set Fire[ArrayNumber] = GetLastCreatedEffectBJ()
            set Angle = Angle + 36
            set ArrayNumber = ArrayNumber + 1
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = 40
        loop
            exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
            call CreateNUnitsAtLocFacingLocBJ( 1, 'h000', GetOwningPlayer(GetTriggerUnit()), PolarProjectionBJ(GetRandomLocInRect(RectFromCenterSizeBJ(GetUnitLoc(GetDyingUnit()), 500.00, 500.00)), GetRandomReal(0.00, 500.00), GetRandomDirectionDeg()), GetUnitLoc(GetTriggerUnit()) )
            set Effect[UnitArray] = GetLastCreatedUnit()
            call PauseUnitBJ( true, Effect[UnitArray] )
            call UnitAddAbilityBJ( 'Amrf', Effect[UnitArray] )
            call UnitApplyTimedLifeBJ( 2.00, 'BTLF', Effect[UnitArray] )
            call SetUnitFlyHeightBJ( Effect[UnitArray], 1000.00, 1000.00 )
            call TriggerSleepAction( 0.10 )
            set UnitArray = UnitArray + 1
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
    call DestroyEffectBJ( Fire[ArrayNumber] )
    else
    endif
endfunction

//===========================================================================
function InitTrig_Dragon_Souls_Death takes nothing returns nothing
    set gg_trg_Dragon_Souls_Death = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Dragon_Souls_Death, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Dragon_Souls_Death, function Trig_Dragon_Souls_Death_Actions )
endfunction
 

the Immortal

I know, I know...
Reaction score
51
I won't talk about leaks, optimizations and so on .. much work to be done on this part.

Mainly after your first loop the 'ArrayNumber' variable is set to 10 (you increase it by 1 every time) .. so in the end when you destroy "Fire[ArrayNumber]" you actually destroy "Fire[10]".

In short you only need 1 loop that destroys Fire[0-9]:

JASS:
set ArrayNumber = 0
loop
    call DestroyEffect( Fire[ArrayNumber] )
    exitwhen ArrayNumber == 9
    set ArrayNumber = ArrayNumber + 1
endloop
(it's free-written but should work)

Oh, and once again, work about optimization .. MUCH work to be done.
 

D.V.D

Make a wish
Reaction score
73
I'll try it but the raising units don't die either. And were do I put the loop?
 

Dryvnt

New Member
Reaction score
10
JASS:

function Trig_Dragon_Souls_Death_Func001C takes nothing returns boolean
    if ( not ( GetUnitAbilityLevelSwapped('ANpi', GetDyingUnit()) == 1 ) ) then
        return false
    endif
    return true
endfunction

function Trig_Dragon_Souls_Death_Actions takes nothing returns nothing
    local unit Target = GetDyingUnit()
    local unit array Effect
    local effect array Fire 
    local integer ArrayNumber = 0 
    local integer UnitArray = 0 
    local real Angle = 0.00  
    if ( Trig_Dragon_Souls_Death_Func001C() ) then
        call CreateNUnitsAtLocFacingLocBJ( 1, 'h001', GetOwningPlayer(GetTriggerUnit()), GetUnitLoc(GetDyingUnit()), GetUnitLoc(GetTriggerUnit()) )
        set Effect[0] = GetLastCreatedUnit()
        call UnitApplyTimedLifeBJ( 5, 'BTLK', Effect[0] )
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = 10
        loop
            exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
            call AddSpecialEffectLocBJ( PolarProjectionBJ(GetUnitLoc(GetDyingUnit()), 400.00, Angle), "Doodads\\Cinematic\\TownBurningFireEmitter\\TownBurningFireEmitter.mdl" )
            set Fire[ArrayNumber] = GetLastCreatedEffectBJ()
            set Angle = Angle + 36
            set ArrayNumber = ArrayNumber + 1
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
        set bj_forLoopAIndex = 1
        set bj_forLoopAIndexEnd = 40
        loop
            exitwhen bj_forLoopAIndex > bj_forLoopAIndexEnd
            call CreateNUnitsAtLocFacingLocBJ( 1, 'h000', GetOwningPlayer(GetTriggerUnit()), PolarProjectionBJ(GetRandomLocInRect(RectFromCenterSizeBJ(GetUnitLoc(GetDyingUnit()), 500.00, 500.00)), GetRandomReal(0.00, 500.00), GetRandomDirectionDeg()), GetUnitLoc(GetTriggerUnit()) )
            set Effect[UnitArray] = GetLastCreatedUnit()
            call PauseUnitBJ( true, Effect[UnitArray] )
            call UnitAddAbilityBJ( 'Amrf', Effect[UnitArray] )
            call UnitApplyTimedLifeBJ( 2.00, 'BTLF', Effect[UnitArray] )
            call SetUnitFlyHeightBJ( Effect[UnitArray], 1000.00, 1000.00 )
            call TriggerSleepAction( 0.10 )
            set UnitArray = UnitArray + 1
            set bj_forLoopAIndex = bj_forLoopAIndex + 1
        endloop
        set ArrayNumber = 0
        loop
            call DestroyEffect( Fire[ArrayNumber] )
            exitwhen ArrayNumber == 9
            set ArrayNumber = ArrayNumber + 1
        endloop
    else
    endif
endfunction

//===========================================================================
function InitTrig_Dragon_Souls_Death takes nothing returns nothing
    set gg_trg_Dragon_Souls_Death = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Dragon_Souls_Death, EVENT_PLAYER_UNIT_DEATH )
    call TriggerAddAction( gg_trg_Dragon_Souls_Death, function Trig_Dragon_Souls_Death_Actions )
endfunction


Like this? :D
 

the Immortal

I know, I know...
Reaction score
51
You never kill them .. there's no logic for them to die :p

Add something like:
JASS:
set ArrayNumber = 0
loop
    call DestroyUnit( Effect[ArrayNumber] )
    exitwhen ArrayNumber == 39
    set ArrayNumber = ArrayNumber + 1
endloop
And optimize this code.
 

D.V.D

Make a wish
Reaction score
73
I'm talking about units. The effects die but the units don't. I just go a theory how to fix it and I'll reply when I do.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top