• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] SetEffectVertexColor???

Status
Not open for further replies.
Level 11
Joined
Dec 19, 2012
Messages
411
no, there aren't. you have to re-model it or use dummies
I hope you did test it before answering the question...


Just adding an effect to a dummy unit and resizing/recoloring the unit won't do ...
Try this trigger and you will know changing unit scale and vertex color did actually affect the special effect attached to the unit.
JASS:
	local unit u = CreateUnit(Player(0), 'hfoo', 0, 0, 0)
	call AddSpecialEffectTarget("Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl", u, "overhead")
	
	call TriggerSleepAction(2.)
	
	call SetUnitScale(u, 4, 4, 4)
	
	call TriggerSleepAction(2.)
	
	call SetUnitVertexColor(u, 0, 255, 0, 255)
 
Level 8
Joined
Jan 28, 2016
Messages
486
I hope you did test it before answering the question...



Try this trigger and you will know changing unit scale and vertex color did actually affect the special effect attached to the unit.
JASS:
	local unit u = CreateUnit(Player(0), 'hfoo', 0, 0, 0)
	call AddSpecialEffectTarget("Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl", u, "overhead")
	
	call TriggerSleepAction(2.)
	
	call SetUnitScale(u, 4, 4, 4)
	
	call TriggerSleepAction(2.)
	
	call SetUnitVertexColor(u, 0, 255, 0, 255)
Correct me if I am wrong but aren't you rescaling and recolouring the unit, not the effect? In which case you've proved DracoLich right, as that would be the only way to edit the special effect without remodeling it.

Edit: DracoLich himself beat me to it... awks. :|
 
Level 11
Joined
Dec 19, 2012
Messages
411
I said "dummies", do you know what it stands for? and author said "won't do" about dummies as well
Sorry for the misunderstand, I should only quote "no, there aren't" instead of whole statement. Setting the dummy model to effect path is only needed only if you want to modify the animation speed of the effect.

Correct me if I am wrong but aren't you rescaling and recolouring the unit, not the effect? In which case you've proved DracoLich right, as that would be the only way to edit the special effect without remodeling it.
I wouldn't post a false information, so it must works. As a prove, here's a link : link
The gif picture should shows clearly.

And in the code I did this :
JASS:
                //Setting the sphere to initial scale value
                call SetUnitScale(this.sphereDummy, SPHERE_INITIAL_SCALE, SPHERE_INITIAL_SCALE, SPHERE_INITIAL_SCALE)
                
                //Setting the sphere color
                call SetUnitVertexColor(this.sphereDummy, SPHERE_COLOR_RED, SPHERE_COLOR_GREEN, SPHERE_COLOR_BLUE, SPHERE_TRANSPARENCY)
                
                //Add the sphere effect to the unit
                set this.sphereEffect = AddSpecialEffectTarget(SPHERE_EFFECT_PATH, this.sphereDummy, SPHERE_EFFECT_ATTACHMENT_PATH)
 
Level 17
Joined
Sep 8, 2007
Messages
994
Well then it apparently isn't working for ALL models then, because I've tried it as well. Resizing worked, recoloring didn't. I actually don't need the color to change but only the transparency.

JASS:
globals
        // ========= GENERAL ========= 
        private constant integer DUMMYID = 'n000'
        private constant string MODELPATH = "war3mapImported\\VoidWalker.mdx" //"Abilities\\Spells\\Human\\Banish\\BanishTarget.mdl"
        private constant real GROWTH_DURATION = 1.
        private constant real MAX_SIZE = 2.
        private constant real TICK = 1./32.
    endglobals
    
    private struct UnitImage
        unit u
        unit dummy
        integer fade
        real size
        timer t
        effect spx
        static integer fadeStep
        static real sizeStep
        private static method onTick takes nothing returns nothing
            local thistype data = thistype(GetTimerData(GetExpiredTimer()))
            local real x
            local real y
            if not (data.fade <= 0) then
                set data.fade = data.fade - fadeStep
                set data.size = data.size + sizeStep
                set x = GetUnitX(data.u)
                set y = GetUnitY(data.u)
                call SetUnitPosition(data.dummy, x, y)
                call SetUnitFacing(data.dummy, GetUnitFacing(data.dummy))
                call SetUnitVertexColor(data.dummy, 255,255,255,data.fade)
                call SetUnitScale(data.dummy, data.size, data.size,data.size)
            
            else
                call data.destroy()
            endif
        endmethod
        
        public static method create takes unit caster, unit target returns thistype
            local thistype data = thistype.allocate()
            local real x = GetUnitX(target)
            local real y = GetUnitY(target)
            set data.u = target
            set data.dummy = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), DUMMYID, GetUnitX(data.u), GetUnitY(data.u), GetUnitFacing(data.u))
            set data.spx = AddSpecialEffectTarget(MODELPATH, data.u,"origin")
            call SetUnitPosition(data.dummy, x, y)
            set data.fade = 255
            set data.size = 1.
            
            set data.t = NewTimer()
            call SetTimerData(data.t, integer(data))
            call TimerStart(data.t, TICK, true, function thistype.onTick)
            
            return data
        endmethod
        
        private method onDestroy takes nothing returns nothing
            set this.u = null
            call RemoveUnit(this.dummy)
            call DestroyEffect(this.spx)
            call ReleaseTimer(this.t)
            set this.spx = null
            set this.dummy = null
        endmethod
        
        private static method onInit takes nothing returns nothing
            set fadeStep = R2I((255. * TICK) / GROWTH_DURATION)
            set sizeStep = (MAX_SIZE * TICK) / GROWTH_DURATION
        endmethod
    endstruct

Edit: Correction - Resizing doesn't work. I got confused with the birth animation.
 
Level 17
Joined
Sep 8, 2007
Messages
994
Sorry for the misunderstand, I should only quote "no, there aren't" instead of whole statement. Setting the dummy model to effect path is only needed only if you want to modify the animation speed of the effect.


I wouldn't post a false information, so it must works. As a prove, here's a link : link
The gif picture should shows clearly.

And in the code I did this :
JASS:
                //Setting the sphere to initial scale value
                call SetUnitScale(this.sphereDummy, SPHERE_INITIAL_SCALE, SPHERE_INITIAL_SCALE, SPHERE_INITIAL_SCALE)
                
                //Setting the sphere color
                call SetUnitVertexColor(this.sphereDummy, SPHERE_COLOR_RED, SPHERE_COLOR_GREEN, SPHERE_COLOR_BLUE, SPHERE_TRANSPARENCY)
                
                //Add the sphere effect to the unit
                set this.sphereEffect = AddSpecialEffectTarget(SPHERE_EFFECT_PATH, this.sphereDummy, SPHERE_EFFECT_ATTACHMENT_PATH)

What does your dummy unit look like? Maybe there's the flaw.
 
Level 17
Joined
Sep 8, 2007
Messages
994
Just an ordinary dummy unit using vexorian's dummy model.

So what are you trying to achieve now? Probably also a model link could help for checking.

I'm using the ordinary dummy unit with the dummy model as well.

I'm trying to build a library that makes any effect spawn on a unit, that effect should grow and fade over time.
So in the end, it should look somewhat like the effect spawned when casting the Avatar ability. Just with any model I want.
Here's the piece of code that I made for this (I skipped the trigger part):
JASS:
scope UnitImage
     globals
        private constant integer DUMMYID = 'n000'
        private constant string MODELPATH = "Abilities\\Weapons\\FarseerMissile\\FarseerMissile.mdl"
        private constant real GROWTH_DURATION = 1.
        private constant real MAX_SIZE = 3.
        private constant real TICK = 1./32.
    endglobals
    
    private struct UnitImage
        unit u
        unit dummy
        integer fade
        real size
        timer t
        effect spx
        static integer fadeStep
        static real sizeStep
        private static method onTick takes nothing returns nothing
            local thistype data = thistype(GetTimerData(GetExpiredTimer()))
            local real x
            local real y
            if not (data.fade <= 0) then
                set data.fade = data.fade - fadeStep
                set data.size = data.size + sizeStep
                set x = GetUnitX(data.u)
                set y = GetUnitY(data.u)
                call SetUnitPosition(data.dummy, x, y)
                call SetUnitFacing(data.dummy, GetUnitFacing(data.dummy))
                call SetUnitVertexColor(data.dummy, 255,255,255,data.fade)
                call SetUnitScale(data.dummy, data.size, data.size,data.size)
            
            else
                call data.destroy()
            endif
        endmethod
        
        public static method create takes unit caster, unit target returns thistype
            local thistype data = thistype.allocate()
            local real x = GetUnitX(target)
            local real y = GetUnitY(target)
            set data.u = target
            set data.dummy = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE), DUMMYID, GetUnitX(data.u), GetUnitY(data.u), GetUnitFacing(data.u))
            set data.spx = AddSpecialEffectTarget(MODELPATH, data.u,"origin")
            call SetUnitPosition(data.dummy, x, y)
            set data.fade = 255
            set data.size = 1.
            
            set data.t = NewTimer()
            call SetTimerData(data.t, integer(data))
            call TimerStart(data.t, TICK, true, function thistype.onTick)
            
            return data
        endmethod
        
        private method onDestroy takes nothing returns nothing
            set this.u = null
            call RemoveUnit(this.dummy)
            call DestroyEffect(this.spx)
            call ReleaseTimer(this.t)
            set this.spx = null
            set this.dummy = null
        endmethod
        
        private static method onInit takes nothing returns nothing
            set fadeStep = R2I((255. * TICK) / GROWTH_DURATION)
            set sizeStep = (MAX_SIZE * TICK) / GROWTH_DURATION
        endmethod
    endstruct
endscope

EDIT:
found the mistake. I had data.u instead of data.dummy. Everything works fine now.
Some (custom) models don't include transparency though.
 
Level 17
Joined
Sep 8, 2007
Messages
994
Glad you solved it :)


I don't think so since i never met this situation. Unless it works for other models expect the specific model, then you could conclude that.

I'll retest later. Maybe I just had the same mistake here.

Darn, if there was a function like GetUnitModelPath, that would make a perfectly customizable avatarish effect possible. Just what I need actually...
 
Status
Not open for further replies.
Top