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
 
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.
 
I'll try it but the raising units don't die either. And were do I put the loop?
 
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
 
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.
 
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.
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    News portal has been retired. Main page of site goes to Headline News forum now
  • The Helper The Helper:
    I am working on getting access to the old news portal under a different URL for those that would rather use that for news before we get a different news view.
  • Ghan Ghan:
    Easily done
    +1
  • The Helper The Helper:
    https://www.thehelper.net/pages/news/ is a link to the old news portal - i will integrate it into the interface somewhere when i figure it out
  • Ghan Ghan:
    Need to try something
  • Ghan Ghan:
    Hopefully this won't cause problems.
  • Ghan Ghan:
    Hmm
  • Ghan Ghan:
    I have converted the Headline News forum to an Article type forum. It will now show the top 20 threads with more detail of each thread.
  • Ghan Ghan:
    See how we like that.
  • The Helper The Helper:
    I do not see a way to go past the 1st page of posts on the forum though
  • The Helper The Helper:
    It is OK though for the main page to open up on the forum in the view it was before. As long as the portal has its own URL so it can be viewed that way I do want to try it as a regular forum view for a while
  • Ghan Ghan:
    Yeah I'm not sure what the deal is with the pagination.
  • Ghan Ghan:
    It SHOULD be there so I think it might just be an artifact of having an older style.
  • Ghan Ghan:
    I switched it to a "Standard" article forum. This will show the thread list like normal, but the threads themselves will have the first post set up above the rest of the "comments"
  • The Helper The Helper:
    I don't really get that article forum but I think it is because I have never really seen it used on a multi post thread
  • Ghan Ghan:
    RpNation makes more use of it right now as an example: https://www.rpnation.com/news/
  • The Helper The Helper:
  • The Helper The Helper:
    What do you think Tom?
  • tom_mai78101 tom_mai78101:
    I will have to get used to this.
  • tom_mai78101 tom_mai78101:
    The latest news feed looks good

      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