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.

      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