1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
  2. Welcome to the new Hive! Be advised that we're still working on the site. There are still many rough edges, so please bear with us.
    Dismiss Notice
  3. The member Kam is making HIVE coasters. Take a look. For every coaster you buy, Hive gets $1.
    Dismiss Notice
  4. The poll for Icon Contest #14 - Seven Deadly Sins is out!
    Dismiss Notice
  5. The 25th Texturing Contest has started! Contestants are to create a skin representing a dark elf person/being or any construct related to it using the vanilla models or the custom ones found on the site.
    Dismiss Notice
  6. Buy it, use it, break it, fix it, trash it, change it, mail - upgrade it. Join (Optionally) Paired Techtree Contest #11 - Techno Magic now!
    Dismiss Notice
  7. Voting squad, line up! Cast your vote on the poll for Modeling Contest #29 - Squads!
    Dismiss Notice
  8. Hero Contest #8 is up and running! This time it's a joint contest between artists and coders. Go here for team matchmaking.
    Dismiss Notice
  9. The poll for the theme of our StarCraft II Terraining Contest is up. Cast your note now!
    Dismiss Notice
  10. The ninth Concept Art Contest has launched. Enter now!
    Dismiss Notice

DelFX - Delayed Effects 1.4.2

Submitted by Deaod
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)

  1. 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:
    614
    Jass? I can't relate. xD
     
  3. Kingz

    Kingz
    Joined:
    Jun 5, 2008
    Messages:
    2,475
    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
    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:
    878
    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,475
    Yeah, i looked and it offers spec eff spawning while others destroy it timed...
     
  7. aaron

    aaron
    Joined:
    Oct 18, 2008
    Messages:
    515
    already done.... plz come up with something original people.
     
  8. Deaod

    Deaod
    Joined:
    Nov 18, 2007
    Messages:
    807
    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
    Version 1.4.1
     
  10. Deaod

    Deaod
    Joined:
    Nov 18, 2007
    Messages:
    807
    Version 1.4.2