Snippet TimedEffects

XeNiM666

I lurk for pizza
Reaction score
138
Timed Effects

What does this do?
- This does exactly what the names states. It creates a special effect with a duration. This also creates special effects with height and scale.

Pros:
- Its easy to use
- Its very useful
- Leakless
- Lagless
- GUI friendly

Cons:
- Requires Vexorian's dummy.mdx ( attached at the bottom of post )
- Requires very little knowledge of JASS

Functions:
JASS:
//      1. AddTimedSpecialEffect                                                       //
//         - takes string modelName, real duration, real x, real y, real z             //
//         - This function creates a timed effect for the duration of choice           //
//      1. AddTimedSpecialEffectLoc                                                    //
//         - takes string modelName, real duration, location whichLoc, real z          //
//         - This function creates a timed effect for the duration of choice           //
//         - This is used for GUI. Because GUI uses locations instead of reals         //
//      1. AddTimedSpecialEffectEx                                                     //
//         - takes string modelName, real duration, real scale, real x, real y, real z //
//         - This function creates a timed effect for the duration of choice           //
//         - This one creates a special effect with a desired size                     //


The Code:
JASS:
//****************************************************************************************//
//****************************************************************************************//
//                                                                                        //
//                        TIMED EFFECTS SYSTEM                                            //
//                            by XeNiM666                                                 //
//                                                                                        //
//****************************************************************************************//
//****************************************************************************************//
//                                                                                        //
//     REQUIRES:                                                                          //
//         1. A vJASS preprocessor ( Jass NewGen Pack )                                   //
//         2. Vexorian's dummy.mdx model                                                  //
//                                                                                        //
//****************************************************************************************//
//****************************************************************************************//
//                                                                                        //
//     THIS SYSTEM HAS 3 FUNCTIONS:                                                       //
//         1. AddTimedSpecialEffect                                                       //
//            - takes string modelName, real duration, real x, real y, real z             //
//            - This function creates a timed effect for the duration of choice           //
//         1. AddTimedSpecialEffectLoc                                                    //
//            - takes string modelName, real duration, location whichLoc, real z          //
//            - This function creates a timed effect for the duration of choice           //
//            - This is used for GUI. Because GUI uses locations instead of reals         //
//         1. AddTimedSpecialEffectEx                                                     //
//            - takes string modelName, real duration, real scale, real x, real y, real z //
//            - This function creates a timed effect for the duration of choice           //
//            - This one creates a special effect with a desired size                     //
//                                                                                        //
//****************************************************************************************//
//****************************************************************************************//
//                                                                                        //
//     HOW TO IMPLEMENT:                                                                  //
//         1. Create a trigger named TE                                                   //
//         2. Convert it to custom text                                                   //
//         3. Delete the text inside                                                      //
//         4. Copy all the text here and copy it to the trigger you created               //
//         5. Copy the dummy unit in this map                                             //
//                                                                                        //
//****************************************************************************************//
//****************************************************************************************//

library TE initializer onInit

    globals
        // THE RAW CODE OF THE DUMMY UNIT USED AS EFFECTS
        // THE DUMMY MUST HAVE THE MODEL "dummy.mdx" BY "Vexorian"
        private constant integer DUMMY_EFFECT = 'u001'
    endglobals
    
     //**************************************************************************************//
    //**************************************************************************************//
   //                DO NOT TOUCH UNLESS YOU KNOW WHAT YOU'RE DOING                        //
  //**************************************************************************************//
 //**************************************************************************************//
    
    private function Destroy takes effect e, real dur returns nothing
        call TriggerSleepAction( dur )
        call DestroyEffect( e )
        set e = null
    endfunction
    
    function AddTimedSpecialEffectEx takes string modelName, real duration, real scale, real x, real y, real z returns nothing
        local unit model = CreateUnit( Player( 15 ), DUMMY_EFFECT, x, y, 270.00 )        
        local effect e = AddSpecialEffectTarget( modelName, model, "origin" )
        call SetUnitScale( model, scale * 0.01, scale * 0.01, scale * 0.01 )
        call UnitApplyTimedLife( model, 'BTLF', duration )
            
        if z != 0.00 then
            call UnitAddAbility( model, 'Amrf' )
            call SetUnitFlyHeight( model, z, 0.00 )
            call UnitRemoveAbility( model, 'Amrf' )
        endif
            
        set model = null
        call Destroy( e, duration )
    endfunction

    function AddTimedSpecialEffect takes string modelName, real duration, real x, real y, real z returns nothing
        local unit model = CreateUnit( Player( 15 ), DUMMY_EFFECT, x, y, 270.00 )        
        local effect e = AddSpecialEffectTarget( modelName, model, "origin" )
        call UnitApplyTimedLife( model, 'BTLF', duration )
            
        if z != 0.00 then
            call UnitAddAbility( model, 'Amrf' )
            call SetUnitFlyHeight( model, z, 0.00 )
            call UnitRemoveAbility( model, 'Amrf' )
        endif
            
        set model = null
        call Destroy( e, duration )
    endfunction
    
    // FOR THOSE WHO LIKE USING LOCATIONS...
    
    function AddTimedSpecialEffectLoc takes string modelName, real duration, location whichLoc, real z returns nothing
        local unit model = CreateUnit( Player( 15 ), DUMMY_EFFECT, GetLocationX( whichLoc ), GetLocationY( whichLoc ), 270.00 )        
        local effect e = AddSpecialEffectTarget( modelName, model, "origin" )
        call UnitApplyTimedLife( model, 'BTLF', duration )
            
        if z != 0.00 then
            call UnitAddAbility( model, 'Amrf' )
            call SetUnitFlyHeight( model, z, 0.00 )
            call UnitRemoveAbility( model, 'Amrf' )
        endif
            
        set model = null
        call Destroy( e, duration )
    endfunction
    
    private function onInit takes nothing returns nothing
        call RemoveUnit( CreateUnit( Player( 15 ), DUMMY_EFFECT, 0.00, 0.00, 0.00 ) )
    endfunction
    
endlibrary


There is a sample spell inside the map. Also please note that THE SPELL DOES NOTHING. Just shows a sample of the snippet.

Special Thanks:
- Vexorian for his dummy.mdx model
- Tinki3 for his Spell Map Template

Map:
 

Attachments

  • TimedEffects Sample.w3x
    61.2 KB · Views: 187
  • dummy.mdx
    34.2 KB · Views: 192

XeNiM666

I lurk for pizza
Reaction score
138
Well this has an advantage in GUI-ers. Since they try hard to make spells MUI and this avoid using waits. Also an advantage is using only 1 unit instead of making other dummy units with effects for models.

I hear you say effects with Z.
:D Just thought it would be a great feature. :D
Also, fast reply :p

EDIT:
What advantages does this have over something like this:
What if that is used for callbacks in timers? :p
 

Romek

Super Moderator
Reaction score
964
> Also an advantage is using only 1 unit instead of making other dummy units with effects for models.
They can do that without this system.

> Just thought it would be a great feature.
It is. But this by no means needs any units whatsoever.

> What if that is used for callbacks in timers?
JASS:
function BlahdyBlah takes... .. ... 
  call MakeSomeTimedEffect.execute(...)
endfunction
 

Azlier

Old World Ghost
Reaction score
461
>- Leakless
Lies. You never null 'e'.
 

Azlier

Old World Ghost
Reaction score
461
Nulling it in the destroy function does nothing.

Why even have the destroy function, in fact :confused:
 
Reaction score
341
He was probably under the impression that nulling locals passed through functions counted.

Anyways, I doubt anyone would use this over an accurate timer removal.

I mean, TSA's are off by what .30 seconds?
 

Jesus4Lyf

Good Idea™
Reaction score
397
No, this is much worse than that. TSA's do horrible things.

Replace the line in the sample spell with this:
JASS:
call BJDebugMsg("Before")
call AddTimedSpecialEffect( "Abilities\\Weapons\\FireBallMissile\\FireBallMissile.mdl", 0.50, x, y, 0.00 )
call BJDebugMsg("After")

"After" never displays. If you put a call AddTimedSpecialEffect( "Abilities\\Weapons\\FireBallMissile\\FireBallMissile.mdl", 0.50, 0, 0, 0.00 ) before the return true, you'll find the spell never ends. (Remember, TT internally uses conditions.)

101 reasons I ban TSA (Trigger Sleep Action).

As for the pro's:
Its easy to use - It doesn't document the situations in which it fails.
Its very useful - It can terminate threads.
Leakless - Wrong.
Lagless - This statement is no doubt relative considering how many times this has been written, so supply benchmarks or this is unfounded.
GUI friendly - This system probably causes a delay in GUI threads (a wait until the effect is removed).

My personal vote: Graveyard. <_< Sorry. :)
 

Romek

Super Moderator
Reaction score
964
I'm shocked I didn't notice all these problems. :p
GY'ed.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top