Effects not being Destroyed from Array, what am I missing?

Sungazer

New Member
Reaction score
0
This is my 2nd attempt at a JASS spell and up to this point I've been doing ok, slowly plowing my way through it. However, I'm finally stumped and I'm not seeing it.

Explanation: This is a simple custom spell that creates a "castable" immolation that gives the hero a buff that lasts for 10 seconds that creates a special effect and deals damage once per second in a 200 area.

There is a little added complexity with a "chain-spell" system I'm implementing (inspired by my recent Aion Online beta experience), where this spell "unlocks" access to two other spells. If those spells are cast, the immolation effect is consumed and this spell is supposed to "shut off."

What's not working: As per the title, the immolation_target special effect is sticking around and stacking, instead of "flickering" for one second like it's supposed to. I had this working at one point and a few modifications later it's got me stumped.

JASS:
function Conditions takes nothing returns boolean
    if (GetSpellAbilityId() == 'A00D') then   //checking for the correct spell
        return true
    endif
endfunction

function EnemyCheck takes nothing returns boolean
    return ( IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit())))  //A simple Condition function that is used with GetEnumUnitsInRange() below
endfunction

function DamageEffect takes nothing returns nothing     //This function is the "What to do on the units picked with ForGroup()", hence the globals needed so I can use this as a "static" function
    call BJDebugMsg("immo_count: "+I2S(udg_immo_count))     //My debug attempts; as far as I can see the indexes are behaving as expected
    call AddSpecialEffectTarget( "Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage.mdl", GetEnumUnit(), "head" )
    set udg_immo_effect[udg_immo_count] = GetLastCreatedEffectBJ()
    call UnitDamageTarget(GetTriggerUnit(), GetEnumUnit(), 15.00, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
    set udg_immo_count = udg_immo_count + 1
endfunction

function Actions takes nothing returns nothing
  
    local unit caster
    local integer abil_level
    local integer i = 0   //index used for the outer loop which runs the bulk of the spell
    local integer j = 0   //index used for the inner loop which destroys effects from an array
    local integer k = 9   //max index used for outer loop
    local group immo_targets = CreateGroup()
   
    set udg_pyroclast_active = true  //A boolean flag that gets set to 'false' when this effect is consumed by its chain spell
    set caster = GetTriggerUnit()
    set abil_level = GetUnitAbilityLevel(caster, 'A00D')
    
    if (abil_level > 0) then                  //Checks the level of the ability being cast and adds a corresponding chain spell
        call UnitAddAbility(caster, 'A00P')
    elseif (abil_level > 2) then
        call UnitAddAbility(caster, 'A00R')
    else
        call DoNothing()
    endif
    
    
    loop
        exitwhen ((i > k) or (udg_pyroclast_active == false)) //k=9 here because I want this to loop for 10 seconds
         
        call GroupEnumUnitsInRange(immo_targets, GetUnitX(caster), GetUnitY(caster), 200.00,Condition(function EnemyCheck))
        call ForGroup ( immo_targets, function DamageEffect ) //These "work"; the units in range that I want are selected and damaged like they're supposed to be             
           
        call TriggerSleepAction(1.00)         //I know waits are looked down upon, but this makes this loop a 1-sec "periodic"; 
                                              //also, the immolation target effect is destroyed instantly without a wait
        loop                                 //If there's another way around this, I'm open to it
            call BJDebugMsg("j: "+I2S(j))
            exitwhen j > (udg_immo_count - 1)  //udg_immo_count = the # of effects in the array, subtracting 1 because it increments an extra time after the last effect is added
            call DestroyEffect(udg_immo_effect[j]) //The culprit line apparently not working
            set j = j + 1
        endloop 

        set udg_immo_count = 0 //Resetting indexes because the hero may move and get an entirely new set of units
        set j = 0              //I'm still looking at this, it may be what's causing an effect to linger
        set i = i + 1
         
    endloop
    
    set i = 0
    set j = 0
    set k = 9
    set udg_immo_count = 0
   
    call UnitRemoveAbility(caster, 'A00P')  //If the hero does not use the chain spell to consume the effect in 10 seconds
    call UnitRemoveAbility(caster, 'A00R')  //the chain spell is removed 
     
    call DestroyGroup(immo_targets)         //Leaks; did I miss any others?
    
endfunction

function InitTrig_Pyroclastic_Shards takes nothing returns nothing
    set gg_trg_Pyroclastic_Shards = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Pyroclastic_Shards, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Pyroclastic_Shards, Condition( function Conditions ) )
    call TriggerAddAction( gg_trg_Pyroclastic_Shards, function Actions )
endfunction


Oh, if you find ways to clean this up or have suggestions on functions that can simplify things I'm open to them. Still learning a lot.

Thanks in advace, +Rep around the room for any help!
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
Don't do bj_lastCreatedSpecialEffect, instead do this:

JASS:
set udg_immo_effect[udg_immo_count] = AddSpecialEffectTarget( "Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage.mdl", GetEnumUnit(), "head" )
 

Sungazer

New Member
Reaction score
0
lol, wow, that was it!

I don't understand though, what's wrong with that function?

And how would I have found this out? I've been pouring over pages of documentation and never saw this mentioned.

Thanks a ton for the extremely quick and correct reply!
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
The bj_lastCreatedSpecialEffect variable is only set if you use the BJ, hence GUI.
 

Sungazer

New Member
Reaction score
0
Ahh... I see it now. I used a native function to add the special effect and was using a BJ to access it. I'll have to be careful not to mix up my natives and BJs. *runs away giggling at the imagery*

Thanks again! :thup:
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
It's not much, but here's a vanity touch up:

JASS:
scope YourSpell initializer Init

private function EnemyCheck takes nothing returns boolean
    return IsUnitEnemy(GetFilterUnit(),GetOwningPlayer(GetTriggerUnit())) //A simple Condition function that is used with GetEnumUnitsInRange() below
endfunction

private function DamageEffect takes nothing returns nothing     //This function is the "What to do on the units picked with ForGroup()", hence the globals needed so I can use this as a "static" function
    call BJDebugMsg("immo_count: "+I2S(udg_immo_count))     //My debug attempts; as far as I can see the indexes are behaving as expected
    call AddSpecialEffectTarget( "Abilities\\Spells\\Other\\ImmolationRed\\ImmolationRedDamage.mdl", GetEnumUnit(), "head" )
    set udg_immo_effect[udg_immo_count] = GetLastCreatedEffectBJ()
    call UnitDamageTarget(GetTriggerUnit(), GetEnumUnit(), 15.00, true, false, ATTACK_TYPE_NORMAL, DAMAGE_TYPE_NORMAL, null)
    set udg_immo_count = udg_immo_count + 1
endfunction

private function Actions takes nothing returns nothing
    local unit caster = GetTriggerUnit()
    local integer abil_level = GetUnitAbilityLevel(caster, 'A00D')
    local integer i = 0   //index used for the outer loop which runs the bulk of the spell
    local integer j = 0   //index used for the inner loop which destroys effects from an array
    local integer k = 9   //max index used for outer loop
    local real x = GetUnitX(caster)
    local real y = GetUnitY(caster)
    local group immo_targets = CreateGroup()
    set udg_pyroclast_active = true  //A boolean flag that gets set to 'false' when this effect is consumed by its chain spell 
    if (abil_level > 0) then                  //Checks the level of the ability being cast and adds a corresponding chain spell
        call UnitAddAbility(caster, 'A00P')
    elseif (abil_level > 2) then
        call UnitAddAbility(caster, 'A00R')
    else
    endif        
    loop
        exitwhen i > k or udg_pyroclast_active == false//k=9 here because I want this to loop for 10 seconds         
        call GroupEnumUnitsInRange(immo_targets, x, y, 200.00, Filter(function EnemyCheck))
        call ForGroup ( immo_targets, function DamageEffect ) //These "work"; the units in range that I want are selected and damaged like they're supposed to be                        
        call TriggerSleepAction(1.00)         //I know waits are looked down upon, but this makes this loop a 1-sec "periodic"; 
                                            //also, the immolation target effect is destroyed instantly without a wait
        loop                                 //If there's another way around this, I'm open to it
            call BJDebugMsg("j: "+I2S(j))
            exitwhen j > (udg_immo_count - 1)  //udg_immo_count = the # of effects in the array, subtracting 1 because it increments an extra time after the last effect is added
            call DestroyEffect(udg_immo_effect[j]) //The culprit line apparently not working
            set j = j + 1
        endloop 
        set udg_immo_count = 0 //Resetting indexes because the hero may move and get an entirely new set of units
        set j = 0              //I'm still looking at this, it may be what's causing an effect to linger
        set i = i + 1
    endloop    
    set i = 0
    set j = 0
    set k = 9
    set udg_immo_count = 0
    call UnitRemoveAbility(caster, 'A00P')  //If the hero does not use the chain spell to consume the effect in 10 seconds
    call UnitRemoveAbility(caster, 'A00R')  //the chain spell is removed     
    call DestroyGroup(immo_targets)         //Leaks; did I miss any others?   
    set caster = null
endfunction

private function Conditions takes nothing returns boolean
    return GetSpellAbilityId() == 'A00D'
endfunction

private function Init takes nothing returns nothing
    local trigger t = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( t, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( t, Condition( function Conditions ) )
    call TriggerAddAction( t, function Actions )
endfunction
endscope
 

Sungazer

New Member
Reaction score
0
That clean-up looks like vJass. Don't get me wrong, I appreciate it, but I haven't had success using the utilities required for compiling vJass. In the past I often got errors when saving due to new WC3 versions and incompatibility. Now 1.24 is out and with my meager experience, I didn't want to touch it.

I did like Vex's tutorial on it and I see the advantages, just couldn't find updated working utilities.
 

Renendaru

(Evol)ution is nothing without love.
Reaction score
309
There's no problem to it, just download NewGen, put the code in, and save. If you have problems with vJass, just ask anyone here.
 

Sungazer

New Member
Reaction score
0
I have, that happens to be what I tried. Whenever I try to save it crashes with a windows error, so rather than risk losing work I'll just deal with primitive JASS for now ;P
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top