1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Are you planning to upload your awesome spell or system to Hive? Please review the rules here.
    Dismiss Notice
  3. Participate in Blizzard's Public Test Realm to give them feedback on the upcoming patches. Info is here.
    Dismiss Notice
  4. Take part in forum poll and decide the winner of Icon Contest #16!
    Dismiss Notice
  5. Congratulate the winners of the first ATC contest!
    Dismiss Notice
  6. Zwiebelchen is hosting a special UI texturing contest. Whomever wins will get a $150 reward through paypal! Come along and draw your texturing tools for the Fantastic Adventurer UI contest.
    Dismiss Notice
  7. Sneak, pickpocket and assassinate! Create a stealth map in Mini-Mapping Contest #14!
    Dismiss Notice
  8. Music Contest #8 - Hive Soundtrack is up! Create the soundtrack for the upcoming videos of Hive Workshop's YouTube Channel.
    Dismiss Notice

DelFX - Delayed Effects 1.4.2

Submitted by Deaod
This bundle is marked as approved. It works and satisfies the submission rules.
Description:
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.

In-Game-Commands:
- "-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


Changelog:
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 (
DestroyEffectTimed
)
- added support for spawning Delayed Effects with a Z coordinate (
CreateDelayedEffectZ
)
- added support for changing the spawning location of a Delayed Effect (
DELFX.SetSpawnPosition
)

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
//
//  CREDITS:
//      - 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
            endif
            set .tar=null
            call ReleaseTimer(.t)
        endmethod
       
        private static method Release takes nothing returns nothing
            call DELFX.destroy(GetTimerData(GetExpiredTimer()))
        endmethod
       
        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)
                else
                    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
                endif
                call TimerStart(s.t, s.timeout, false, function DELFX.Release)
            debug else
            debug     call BJDebugMsg("DELFX["+I2S(s)+"].Callback: Effect already spawned!")
            debug endif
        endmethod
       
        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
        endmethod
    endstruct
   
    // 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)
    endfunction
   
    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)
    endfunction
   
    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)
    endfunction
   
endlibrary


Keywords:
Delayed, Timed, Effects, Effect, AddSpecialEffectZ
Contents

DelFX 1.4.2 (Map)

Reviews
Moderator
20:10, 25th Feb 2009 Hanky: Advice: 5 points are the highest rating and 1 point is the lowest rating. Documentation: 2 Visual Effects: - Triggering: 5 Idea: - Total: [img][img][img][img][img] The code seems to be fine but you...
  1. Moderator

    Moderator

    Resources:
    0
    Resources:
    0
    20:10, 25th Feb 2009
    Hanky:
    Evaluation

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

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

    Total:
    [​IMG][​IMG][​IMG][​IMG][​IMG]


    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.

    Suggestion:
    - 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

    nerovesper

    Joined:
    Sep 29, 2008
    Messages:
    615
    Resources:
    2
    Maps:
    1
    Spells:
    1
    Resources:
    2
    Jass? I can't relate. xD
     
  3. Kingz

    Kingz

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

    Deaod

    Joined:
    Nov 18, 2007
    Messages:
    807
    Resources:
    12
    Maps:
    1
    Spells:
    11
    Resources:
    12
    this offers delayed spawning, which all other systems known to me dont.
     
    Last edited: Feb 23, 2009
  5. Dynasti

    Dynasti

    Joined:
    Oct 18, 2007
    Messages:
    877
    Resources:
    3
    Maps:
    2
    Spells:
    1
    Resources:
    3
    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

    Kingz

    Joined:
    Jun 5, 2008
    Messages:
    2,471
    Resources:
    5
    Spells:
    5
    Resources:
    5
    Yeah, i looked and it offers spec eff spawning while others destroy it timed...
     
  7. aaron

    aaron

    Joined:
    Oct 18, 2008
    Messages:
    513
    Resources:
    6
    Maps:
    2
    Spells:
    4
    Resources:
    6
    already done.... plz come up with something original people.
     
  8. Deaod

    Deaod

    Joined:
    Nov 18, 2007
    Messages:
    807
    Resources:
    12
    Maps:
    1
    Spells:
    11
    Resources:
    12
    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

    Deaod

    Joined:
    Nov 18, 2007
    Messages:
    807
    Resources:
    12
    Maps:
    1
    Spells:
    11
    Resources:
    12
    Version 1.4.1
     
  10. Deaod

    Deaod

    Joined:
    Nov 18, 2007
    Messages:
    807
    Resources:
    12
    Maps:
    1
    Spells:
    11
    Resources:
    12
    Version 1.4.2