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: 186
  • dummy.mdx
    34.2 KB · Views: 191

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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      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