1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Take part in a Futuristic musical experience with our very own Music Contest. The 5th edition has finally arrived after a long time.
    Dismiss Notice
  3. The 1st Galaxy Terraining Contest has reached an end. We've set up the poll for it. Who among these fine guys should take the cake?
    Dismiss Notice
  4. The results for Techtree Contest #11 are out!
    Dismiss Notice
  5. The long awaited results for the Mini-Texturing Contest have been released. Check it out and congratulate the winner!
    Dismiss Notice
  6. Dust off your mapping skills, a mini-mapping contest is coming up! Cast your vote on its theme now!
    Dismiss Notice

DelFX - Delayed Effects 1.4.2

Submitted by Deaod
This little library allows the user to schedule effects and destroy them after some time with only one line. There are some more things you can do to delayed effects and I suggest you look at the code to understand this library.

I developed this library for my Phoenix Form spell, which is why the testmap matches the Phoenix Form one. In particular I used DelFX to time the flamestrike effects and simulate the burning effect of immolation.

This library uses Vexorian's TimerUtils library and vJass syntax.

- "-reset": spawns some footmen
- "-level <level>": Set the heros level to the level you specified. Note that you cannot decrease it that way.
- "-handleid": creates a location, displays its handlid-0x100001, and then destroys it.
- "-credits": displays credits
- "-commands": displays this list
- "-clear": removes all messages ingame

01/08/2009 - Version 1.0.0
- initial release

01/21/2009 - Version 1.0.1
- shortened code

01/21/2009 - Version 1.1.0
- Now uses one timer per instance

02/11/2009 - Version 1.1.1
- fixing of a few really small glitches
- better error reporting (when in debug mode)

02/22/2009 - Version 1.2.0
- Added OnSpawn and OnDestroy callbacks, so you can run code when a DELFX struct spawns an effect or is destroyed
- Enabled attaching to DELFX structs

03/14/2009 - Version 1.3.0
- added support for destroying effects (
- added support for spawning Delayed Effects with a Z coordinate (
- added support for changing the spawning location of a Delayed Effect (

04/13/2009 - Version 1.4.0
- removed access to the DELFX struct; the struct is now private to the DelFX library (this breaks backwards compatibility)
- removed unnecessary code, now that the DELFX struct is private.

04/13/2009 - Version 1.4.1
- further reduced code amount, removing features not in the scope of this system
- small optimization behind the scenes

08/07/2009 - Version 1.4.2
- Compatibility with 1.24

Library-Code + Credits
Code (vJASS):
//  API:
//    >>CreateDelayedEffect(whichEffect, X, Y, Delay, Timeout)
//          - whichEffect is of type string and contains the path of the
//            effect-to-be-spawned
//          - X and Y indicate where the effect should be spawned
//          - Delay is of type real and indicates how long to wait before spawning the
//            effect
//          - Timeout is of type real and indicates how long to wait before destroying
//            the effect after it has been created
//    >>CreateDelayedEffectZ(whichEffect, X, Y, Z, Delay, Timeout)
//          - whichEffect: see above
//          - X, Y and Z indicate where to spawn the effect
//          - Delay: see above
//          - Timeout: see above
//    >>CreateDelayedEffectTarget(whichEffect, Target, AttachmentPoint, Delay, Timeout)
//          - whichEffect: see above
//          - Target is of type widget and indicates on which widget the effect should
//            be spawned
//          - AttachmentPoint is of type string and holds the attachment point where
//            the effect should be spawned on target widget
//          - Delay: see above
//          - Timeout: see above
//      - Vexorian (JassHelper; TimerUtils)
//      - Anitarf (Suggestions)
//      - KaTTaNa (AddSpecialEffectZ function @ wc3jass.com)
//      - PitzerMike (JassNewGenPack)
//      - Pipedream (Grimoire)
//      - SFilip (TESH)

library DelFX uses TimerUtils
    private struct DELFX
        private effect fx
        private string path
        private boolean target
        private widget tar
        private string attpt
        private real x
        private real y
        private real z
        private timer t
        private real timeout
        private method onDestroy takes nothing returns nothing
            if .fx!=null then
                call DestroyEffect(.fx)
                set .fx=null
            set .tar=null
            call ReleaseTimer(.t)
        private static method Release takes nothing returns nothing
            call DELFX.destroy(GetTimerData(GetExpiredTimer()))
        private static method Callback takes nothing returns nothing
        local DELFX s=GetTimerData(GetExpiredTimer())
        local destructable d
            debug if s.fx==null then
                if s.target then
                    set s.fx=AddSpecialEffectTarget(s.path, s.tar, s.attpt)
                elseif s.z==0 then
                    set s.fx=AddSpecialEffect(s.path, s.x, s.y)
                    set d=CreateDestructableZ('OTip', s.x, s.y, s.z, 0,1.,0)
                    set s.fx=AddSpecialEffect(s.path, s.x, s.y)
                    call RemoveDestructable(d)
                    set d=null
                call TimerStart(s.t, s.timeout, false, function DELFX.Release)
            debug else
            debug     call BJDebugMsg("DELFX["+I2S(s)+"].Callback: Effect already spawned!")
            debug endif
        static method Create takes string path, boolean target, widget tar, string attpt, real x, real y, real z, real delay, real timeout returns DELFX
        local DELFX s=DELFX.allocate()
            set s.t=NewTimer()
            call SetTimerData(s.t, s)
            set s.path=path
            set s.target=target
            set s.tar=tar
            set s.attpt=attpt
            set s.x=x
            set s.y=y
            set s.z=z
            set s.timeout=timeout
            call TimerStart(s.t, delay, false, function DELFX.Callback)
            return s
    // The functions below have been explained above.
    function CreateDelayedEffect takes string path, real x, real y, real delay, real timeout returns nothing
        call DELFX.Create(path, false, null, "", x, y, 0, delay, timeout)
    function CreateDelayedEffectZ takes string path, real x, real y, real z, real delay, real timeout returns nothing
        call DELFX.Create(path, false, null, "", x, y, z, delay, timeout)
    function CreateDelayedEffectTarget takes string path, widget target, string attachmentpoint, real delay, real timeout returns nothing
        call DELFX.Create(path, true, target, attachmentpoint, 0, 0, 0, delay, timeout)

Delayed, Timed, Effects, Effect, AddSpecialEffectZ

DelFX 1.4.2 (Map)

  1. 20:10, 25th Feb 2009

    Rating Points
    Advice: 5 points are the highest rating and 1 point is the lowest rating.

    Documentation: 2
    Visual Effects: -
    Triggering: 5
    Idea: -


    Rating Comment

    The code seems to be fine but you could maybe improve abit the documentation. Also I don't know how the performance differences are between your system and the normal way to destroy special effects delayed. Maybe you could make some performance test's and post them. But well the system work and the code is ok so I see no reason why I shouldn't approve it. The system could be maybe useful for some guys and I just can recommend to use it.

    - add a better manuel
    - clear up the code

    Advice: If you didn't understood my rating or if you maybe have questions because you don't know how to fix bugs or leaks etc. You can always send a private message to me. I will answer as soon I got time.
  2. nerovesper

    Sep 29, 2008
    Jass? I can't relate. xD
  3. Kingz

    Jun 5, 2008
    Isn't there already this kind of thing?
    I think i saw 2 simmilar(maybe exactly the same) resources on the hive...
  4. Deaod

    Nov 18, 2007
    this offers delayed spawning, which all other systems known to me dont.
    Last edited: Feb 23, 2009
  5. Dynasti

    Oct 18, 2007
    You're right :D

    I could only wish for this system to get a good manual, because the code looks a bit messy to me :X
  6. Kingz

    Jun 5, 2008
    Yeah, i looked and it offers spec eff spawning while others destroy it timed...
  7. aaron

    Oct 18, 2008
    already done.... plz come up with something original people.
  8. Deaod

    Nov 18, 2007
    to all who think this is too similar to already existing systems:

    This allows you to delay the creation of effects, which is a unique feature. However, if you can find a resource on THW, doing the same thing (in a better way) that has been approved before this, i'd like to have a link.
  9. Deaod

    Nov 18, 2007
    Version 1.4.1
  10. Deaod

    Nov 18, 2007
    Version 1.4.2