• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

cant destroy certain attached special effects

Status
Not open for further replies.
Level 7
Joined
Jan 30, 2011
Messages
267
this is the code:



  • test effect
    • Events
      • Event - A unit is being attacked
    • Actions
      • Specialeffect - Create a special effect attached to the hand, left of (Attacking unit) using Abilities\Spells\Human\FlameStrike\FlameStrikeTarget.mdl
      • Specialeffect - Destroy (Last created special effect)
      • Specialeffect - Create a special effect attached to the hand, left of (Attacking unit) using AssaultRifleEffektAttachmentLeft.MDX
      • Specialeffect - Destroy (Last created special effect)
the first special effect is being destroyed, the second one not (second one is imported (its supposed to be the fire at the front of a gun))
 
Level 7
Joined
Jan 30, 2011
Messages
267
thats what i actually did:


JASS:
function TimedEffectExpires takes nothing returns nothing
    local trigger trig = GetTriggeringTrigger()
    call DestroyEffectBJ(LoadEffectHandleBJ(30, GetHandleIdBJ(trig), udg_hash))
    call DisplayTextToForce( GetPlayersAll(), "BOOM" )
    call DestroyTimerBJ(GetExpiredTimer())
    call DestroyTrigger(trig)
endfunction


function TimedEffectOnUnit takes string attachPointName, widget targetWidget, string modelName, real time returns effect
    local effect eff = AddSpecialEffectTargetUnitBJ(attachPointName, targetWidget, modelName)
    local trigger trig = CreateTrigger()
    local timer t=CreateTimer()
    
    call StartTimerBJ( t, false, time)
    call SaveEffectHandleBJ(eff, 30, GetHandleIdBJ(trig), udg_hash)
    
    call TriggerRegisterTimerExpireEventBJ( trig, t )
    call TriggerAddAction( trig, function TimedEffectExpires )
    
    return eff
endfunction

EDIT:
  • Custom script: call TimedEffectOnUnit ( "hand, left", GetAttacker(), "AssaultRifleEffektAttachmentLeft.mdx", 1)
this call created the special effect, but it didnt get destroyed
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Why don't you save the Effect handle on the UNIT handle , instead of saving it on the TRIGGER handle? If the trigger runs twice, the first effect handle would be overwritten by the second one, therefore, leak.

Use one index for the first effect, another one for the second.

If you are inmediatly going to destroy an effect after creating it, it's better to use
call DestroyEffect(AddSpecialEffectTarget(...))
 
Level 7
Joined
Jan 30, 2011
Messages
267
how shall the trigger run twice?
it can only be executed by the timer that is created inside the function, and the timer and the trigger are destroyed at the same moment, so another timer cant get the same handle id like the first timer
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,217
The custom model might have poor death animation support. wait a few minutes and see if it disappears. If not tell the author to add a death animation.

When you create a special effect it plays the birth animation
If the birth animation complets, it then plays stand animations
When you destroy a special effect it plays the death animation

If no birth animation exists it goes onto the stand animation.
If no death animation exists it keeps playing the currently active animation until it finishes in which case the model is removed. This animation can often be minutes long in the case of some stand animations.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Try this

JASS:
function TimedEffectExpires takes nothing returns nothing
    local trigger trig = GetTriggeringTrigger()
    call DestroyEffect(LoadEffectHandle(udg_hash, GetHandleId(trig), 30))

    call DisplayTextToForce( bj_FORCE_ALL_PLAYERS, "BOOM" )
    call DestroyTimer(GetExpiredTimer())
    call DestroyTrigger(trig)
endfunction


function TimedEffectOnUnit takes string attachPointName, widget targetWidget, string modelName, real time returns nothing
    local effect eff = AddSpecialEffectTarget(modelName, targetWidget, attachPointName)
    local trigger trig = CreateTrigger()
    local timer t= CreateTimer()
    
    call TimerStart(t, time, false, null)
    call SaveEffectHandle(udg_hash, GetHandleId(trig), 30, eff)
    
    call TriggerRegisterTimerExpireEvent( trig, t )
    call TriggerAddAction( trig, function TimedEffectExpires )
endfunction
 
Level 7
Joined
Jan 30, 2011
Messages
267
@ dr super good:
just looked it up: the model doesnt have any death animation at all (only Stand)
might that be the problem?

@Spartipilo
you just replaced the dummy function DestroyEffectBJ by DestroyEffect
DestroyEffectBJ does nothing else than calling DestroyEffect with the provided parameters
and replacing StartTimerBJ by TimerStart isnt needed too, cause the timer works properly
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
never heared of speed?
Blizzard Jass is just as efficient as doing
JASS:
function CreateTheEffect takes string e, unit u, string att returns nothing
    call AddSpecialEffectTarget(e, u, att)
endfunction
The natives are better then sJass(shitty Jass - Jass2 - Blizzards Jass - red text) because it runs some C++ or what code which is like 15 times+ faster then calling function which calls another function
Example
If you are 2 meters off table with apple and next to you stands your friend which is also 2 meters off the table what is faster, going to the table taking the apple or ordering your friend to go to table to bring it back for you? hmm...think about it
Also sJass has some very not wanted effects, for instance CinematicModeBJ does a shit load of stuff which you can avoid(and sometimes want)
 
Level 7
Joined
Jan 30, 2011
Messages
267
allright, i played the stand animation with war3 model editor
normally, when u select "Default Loop" the animation is played once (normally means that how it is all the blizzard and many other models)
but this model loops when saying "default loop"
cant i edit the .mdl in normal text editor, so that it doesnt loop anymore?
 
Level 2
Joined
Aug 3, 2012
Messages
19
this is the code:



  • test effect
    • Events
      • Event - A unit is being attacked
    • Actions
      • Specialeffect - Create a special effect attached to the hand, left of (Attacking unit) using Abilities\Spells\Human\FlameStrike\FlameStrikeTarget.mdl
      • Specialeffect - Destroy (Last created special effect)
      • Specialeffect - Create a special effect attached to the hand, left of (Attacking unit) using AssaultRifleEffektAttachmentLeft.MDX
      • Specialeffect - Destroy (Last created special effect)
the first special effect is being destroyed, the second one not (second one is imported (its supposed to be the fire at the front of a gun))

try putting a delay between each create / destroy effect... i had the same problem and adding a delay fixed it...
 
Level 7
Joined
Jan 30, 2011
Messages
267
i guess i managed to fix it more or less, i went into the .mdl and messed around a bit, so that the animation goes from 0-20000 instead of 0-333 now, where it is invisible from 333-20000
enough time so that the animation can "decay"
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Actually, besides improving the code, I removed the "Return effect", since the effect is already being created and attached.

I wonder if you even tested...
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Btw... I heard before that directly destroying a timer would leak if not paused before. Does that applies for periodic timers or any timer?
 
Status
Not open for further replies.
Top