• 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.

[JASS] Effect doesnt get destroyed

Status
Not open for further replies.
Level 14
Joined
Jul 1, 2008
Messages
1,314
hey guys,

i made an ability, please dont mind the german comments, they are not important.

First of all here is the trigger:

JASS:
function Trig_Giesskanne_Conditions takes nothing returns boolean
    if GetSpellAbilityId() == 'A01S' or GetSpellAbilityId() == 'A01V' then
        return true
    endif
        return false
endfunction

function Giessen_Check takes nothing returns boolean
    return IsUnitType(GetFilterUnit(), UNIT_TYPE_MECHANICAL) == true
endfunction

function Trig_Giesskanne_Actions takes nothing returns nothing
    local unit UG = GetSpellAbilityUnit()
    local unit Targ = GetSpellTargetUnit()
    local group g
    local unit x
    local effect Water
    local integer Abil = GetSpellAbilityId()
    // Gießen
    if Abil == 'A01S' then
        set g = CreateGroup()
        call GroupEnumUnitsInRange(g, GetUnitX(UG),GetUnitY(UG),325.00,Condition(function Giessen_Check))
        loop
            set x = FirstOfGroup(g)
            exitwhen x == null
            call SetUnitState(x,UNIT_STATE_MANA, GetUnitState(x,UNIT_STATE_MAX_MANA)*RMaxBJ(0,100) * 0.01)
            set Water = AddSpecialEffect("Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveDamage.mdl",GetUnitX(x),GetUnitY(x))
            call DestroyEffect(Water)
            //------
            call GroupRemoveUnit(g,x)
        endloop
        call SetItemUserData( GetItemOfTypeFromUnitBJ(UG, 'I00I'), 1 )
    endif
    // Am Brunnen füllen
    if Abil == 'A01V' and GetUnitTypeId(Targ) == 'h014' then
        set Water = AddSpecialEffect("war3mapImported\\KnockbackWater.mdx", GetUnitX(Targ),GetUnitY(Targ))
        call SetItemUserData(GetItemOfTypeFromUnitBJ(UG,'I00I'), 2 )
    endif
    call TriggerSleepAction( 5.00 )
    // Kanne leer?
    if GetItemUserData(GetItemOfTypeFromUnitBJ(UG, 'I00I')) == 1 then
        call UnitAddAbility(UG, 'A01V')
        call UnitRemoveAbility(UG, 'A01S')
    else
        call UnitAddAbility(UG, 'A01S')
        call UnitRemoveAbility(UG, 'A01V')
    endif
    call DestroyGroup(g)
    set g = null
    set UG = null
    set x = null
    set Targ = null
    call DestroyEffect(Water)
    set Water = null
endfunction

//===========================================================================
function InitTrig_Giesskanne takes nothing returns nothing
    set gg_trg_Giesskanne = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Giesskanne, EVENT_PLAYER_UNIT_SPELL_CAST )
    call TriggerAddCondition( gg_trg_Giesskanne, Condition( function Trig_Giesskanne_Conditions ) )
    call TriggerAddAction( gg_trg_Giesskanne, function Trig_Giesskanne_Actions )
endfunction

The Problem is, that this Effect, i create here
JASS:
     // Am Brunnen füllen
    if Abil == 'A01V' and GetUnitTypeId(Targ) == 'h014' then
        set Water = AddSpecialEffect("war3mapImported\\KnockbackWater.mdx", GetUnitX(Targ),GetUnitY(Targ))
        call SetItemUserData(GetItemOfTypeFromUnitBJ(UG,'I00I'), 2 )
    endif
is NOT destroyed at the end of the trigger,
but i wrote this line
JASS:
    call DestroyEffect(Water)
at the end of the trigger.

So WHY does it not work?

Can you guys please help me?

Greets
 
Level 14
Joined
Jul 1, 2008
Messages
1,314
hm yes the modell is imported, but in GUI it worked fine to destroy it.

I had a global variable, and i destroyed it in another trigger...i will do it like this again, but i thought it would be more comfortable in jass...

Thanks for the answer :)

Any other ideas?
 
I think I got something

Think with me... You initialize the group g only if Abil = 'A01S', right?
Otherwise, g = null

And you create the effect only if Abil = 'A01V'. So, when you create the effect, g = null (because Abil is not 'A01S' xD)

So, when you use DestroyGroup(g) when you casted 'A01S', the trigger will halt, as g = null.
And the effect is never destroyed...
 
Status
Not open for further replies.
Top