System Effect

Executor

I see you
Reaction score
57
Effect


Effect allows the creation of unit-independent effects with z-parameter and the possibilty to change their color, scaling and position.
  • Coding Style: vJass
  • Interface: vJass + 'normal' Jass

JASS:
library Effect requires optional AutoFly

    // ========== Effect ==========
        
    // Better control over unit-independent effects
    
    // Author: Executor alias Lord_Executor
    
    // ====== Implementation ======
    
    // Make a new trigger called "Effect"
    // Convert it to custom text
    // Paste the whole code in the empty page
    
    // IMPORTANT: 
    // Import Vexorian's dummy.mdx
    
    // finally save the map once and AFTER that remove the '!' of the '//!' beneath this line
    
    //! external ObjectMerger w3u ushd vdum unam "Visible Dummy" uabi "Aeth,Avul,Aloc" umvs "520" umvr 1 umvt foot umvh -500 uhpm 99999 uhom 1 ucol -10 umdl "war3mapImported\dummy.mdl" ucbs 0 ucpt 0 ushu "" umvh 0 ufoo 0

    // ========== Credits =========
    
    // Vexorian: vJass & Dummy.mdx
    // Azlier: Autofly
    
    struct Effect
        private static integer  DUMMY_ID            = 'vdum'
        private static real     DEFAULT_SCALING     = 1.
        private static real     RECYCLE_WAIT        = 2.
        private static player   DUMMY_OWNER         = Player(14) // neutral
    
        private unit carrier
        private effect sfx
        
        method scale takes real size returns nothing
            call SetUnitScale(.carrier,size,size,size)
        endmethod
        
        method scalePercent takes real size returns nothing
            set size = size * 0.01
            call SetUnitScale(.carrier,size,size,size)
        endmethod
        
        method color takes integer r, integer g, integer b, integer alpha returns nothing
            call SetUnitVertexColor(.carrier,r,g,b,alpha)
        endmethod
        
        method move takes real x, real y , real z returns nothing
            call SetUnitX(.carrier,x)
            call SetUnitY(.carrier,y)
            call SetUnitFlyHeight(.carrier,z,0.)
        endmethod
        
        method onDestroy takes nothing returns nothing
            call SetUnitScale(.carrier,.DEFAULT_SCALING,.DEFAULT_SCALING,.DEFAULT_SCALING)
            call SetUnitVertexColor(.carrier,255,255,255,255)
        endmethod
        
        method remove takes nothing returns nothing
            call DestroyEffect(.sfx)
            call TriggerSleepAction(.RECYCLE_WAIT) // transitional
            call .destroy()        
        endmethod
            
        static method new takes string modelName, real x, real y, real z returns thistype
            // z depends on floor height!
            local thistype this = thistype.allocate()
            if .carrier == null then 
                set .carrier = CreateUnit(.DUMMY_OWNER,.DUMMY_ID,x,y,0.)
                call SetUnitPathing(.carrier,false)
                static if not AutoFly then
                call UnitAddAbility(.carrier,'Amrf')
                call UnitRemoveAbility(.carrier,'Amrf')
                endif
            endif
            call SetUnitX(.carrier,x)
            call SetUnitY(.carrier,y)
            call SetUnitFlyHeight(.carrier, z, 0.)
            set .sfx = AddSpecialEffectTarget(modelName, .carrier, "origin")
            return this
        endmethod        
    endstruct
    
    function AddEffect takes string modelName, real x, real y, real z returns Effect
        return Effect.new(modelName,x,y,z)
    endfunction
    
    function ScaleEffect takes Effect e, real scale returns nothing
        call e.scale(scale)
    endfunction       
    
    function ScaleEffectByPercent takes Effect e, real scale returns nothing
        call e.scalePercent(scale)
    endfunction
    
    function ReColorEffect takes Effect e, integer r, integer g, integer b, integer alpha returns nothing
        call e.color(r,g,b,alpha)
    endfunction
    
    function MoveEffect takes Effect e, real x, real y, real z returns nothing
        call e.move(x,y,z)
    endfunction
    
    function RemoveEffect takes Effect e returns nothing
        call e.remove()
    endfunction
endlibrary



Interface:
JASS:
// Effect Interface:

// new type "Effect"


// vJass:

// local Effect sfx = Effect.new(string model, real x, real y, real z)

// call .scale( real value )

// call .scalePercent( real value )

// call .color( integer red, integer green, integer blue, integer alpha )

// call .move( real x, real y, real z )

// call .remove()


// non-vJass:

// local Effect sfx = AddEffect(string model, real x, real y, real z)

// call ScaleEffect( sfx, real value )

// call ScaleEffectByPercent( sfx, real value )

// call ReColorEffect( sfx, integer red, integer green, integer blue, integer alpha )

// call MoveEffect( sfx, real x, real y, real z )

// call RemoveEffect( sfx )

Example:
JASS:
call RemoveEffect(AddEffect("Abilities\\Weapons\\VengeanceMissile\\VengeanceMissile.mdl",80.,30.,100.))

Note: If you use my sys, keep in mind that you're still able to use 'normal' effects for 'normal' purposes as they should be more efficient in that case.

Didn't find a sys like this via search, so I hope it's useful :p
 

Attachments

  • dummy.mdx
    34.2 KB · Views: 234

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
.sfx

leak.

Anyway, I do prefer original one. This does much work compared with original natives.

JASS:
        private static integer  dummy           = 'vdum'
        private static real     default_scale   = 1.
        private static real     wait            = 2.
        private static player   neutral         = Player(14)

->
Constant globals + CAPTICAL LETTERS

JASS:
        call e.remove

->
JASS:
        call e.remove()


JASS:
            call TriggerSleepAction(.wait) // Failed.


sfx stands for sound effect.

JASS:
            call SetFlyHeight(.carrier,z)// What?


Too many dummies will cause performance issue.
 

Executor

I see you
Reaction score
57
Why does ".sfx" leak?

call e.remove
call SetFlyHeight(.carrier,z)// What?
saw it and corrected it before I read your post :p

The triggersleepaction is transitional, I recognized after posting, that the unit could be reused, while the effect shows his destroy-effect.

Constant globals + CAPTICAL LETTERS
Hm that's a question of standard, but yea, I'll change it.

This does much work compared with original natives
And? For example the AddEffectZ library also uses only natives.


SFX may refer to:

* Special effect(s), illusions used in film, television and entertainment
* Sound effect, artificially created or enhanced sounds

from Wikipedia
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
SFX may refer to:

* Special effect(s), illusions used in film, television and entertainment
* Sound effect, artificially created or enhanced sounds
Okay, my bad.

Too many dummies will cause performance issue.
You should think about it.
 

Executor

I see you
Reaction score
57
Well, I recycle them so the dummy-count will equal the max effect usage at one time. I could also include a cap, to remove to much dummies (if there are only a few moments with very high effect usage).

Atm I'm thinking about the best method to wait a short amount of time before the reusage of the dummies, someone an idea?
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Why does ".sfx" leak?
It is introduced since 1.24b.... just set it to null to prevent leak.
 

Deaod

Member
Reaction score
6
Great, you replicated xefx.

Does this improve on xefx in any way?

If not, then you should think about tossing this aside.
 

Executor

I see you
Reaction score
57
Well I do not use xe and didn't read the xe code, so if that's exactly what xefx does this can be GY'd.
 

Azlier

Old World Ghost
Reaction score
461
This leaks if you try to use it where TriggerSleepAction fails.

You should probably hide dummies somewhere when not in use. Helps performance somewhat.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
Does this improve on xefx in any way?

If not, then you should think about improve on xefx in any way.



[LJASS]DUMMY_ID[/LJASS]
Isn't it a convention that only constants are capitalised?
 

quraji

zap
Reaction score
144
Effect allows the creation of unit-independent effects with z-parameter and the possibilty to change their color, scaling and position.

Just wondering how the effects are unit-independent if they depend on units. It was kind of confusing for me, who thought you found some magic way to do it without attaching the effects to units :p
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • 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
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top