kingkingyyk3
Visitor (Welcome to the Jungle, Baby!)
- Reaction score
- 216
You can include the Zinc as long as vJass still there.
library SmoothUnitMod requires T32, UnitAppearance
//===========================================================================
private function interface ModificationFunction takes unit whichUnit, real increment returns nothing
private function SetScale takes unit whichUnit, real increment returns nothing
call ModifyUnitScale(whichUnit, increment)
endfunction
private function SetA takes unit whichUnit, real increment returns nothing
call ModifyUnitVertexColor(whichUnit, increment, 0.00, 0.00, 0.00)
endfunction
private function SetR takes unit whichUnit, real increment returns nothing
call ModifyUnitVertexColor(whichUnit, 0.00, increment, 0.00, 0.00)
endfunction
private function SetG takes unit whichUnit, real increment returns nothing
call ModifyUnitVertexColor(whichUnit, 0.00, 0.00, increment, 0.00)
endfunction
private function SetB takes unit whichUnit, real increment returns nothing
call ModifyUnitVertexColor(whichUnit, 0.00, 0.00, 0.00, increment)
endfunction
//===========================================================================
struct SmoothMod
private unit whichUnit
private real increment
private ModificationFunction modFunc
//===========================================================================
static method scale takes unit whichUnit, real duration, real value returns nothing
local SmoothMod sm = SmoothMod.allocate()
set sm.whichUnit = whichUnit
set sm.increment = value / duration * T32_PERIOD
set sm.modFunc = SetScale
set sm.ticks = R2I(duration / T32_PERIOD)
call sm.startPeriodic()
endmethod
static method alpha takes unit whichUnit, real duration, real value returns nothing
local SmoothMod sm = SmoothMod.allocate()
set sm.whichUnit = whichUnit
set sm.increment = value / duration * T32_PERIOD
set sm.modFunc = SetA
set sm.ticks = R2I(duration / T32_PERIOD)
call sm.startPeriodic()
endmethod
static method red takes unit whichUnit, real duration, real value returns nothing
local SmoothMod sm = SmoothMod.allocate()
set sm.whichUnit = whichUnit
set sm.increment = value / duration * T32_PERIOD
set sm.modFunc = SetR
set sm.ticks = R2I(duration / T32_PERIOD)
call sm.startPeriodic()
endmethod
static method green takes unit whichUnit, real duration, real value returns nothing
local SmoothMod sm = SmoothMod.allocate()
set sm.whichUnit = whichUnit
set sm.increment = value / duration * T32_PERIOD
set sm.modFunc = SetG
set sm.ticks = R2I(duration / T32_PERIOD)
call sm.startPeriodic()
endmethod
static method blue takes unit whichUnit, real duration, real value returns nothing
local SmoothMod sm = SmoothMod.allocate()
set sm.whichUnit = whichUnit
set sm.increment = value / duration * T32_PERIOD
set sm.modFunc = SetB
set sm.ticks = R2I(duration / T32_PERIOD)
call sm.startPeriodic()
endmethod
//===========================================================================
implement T32
private integer ticks
private method periodic takes nothing returns boolean
set this.ticks = this.ticks - 1
if this.ticks <= 0 then
call this.destroy()
return true
else
call this.modFunc.execute(this.whichUnit, this.increment)
return false
endif
endmethod
endstruct
endlibrary
set this.alpha = 255
set this.red = 255
set this.green = 255
set this.blue = 255
When?Ok, will change that then !
It's broken, trying to return integers from reals without R2I. The members of Appearance are reals, yet GetUnitAlpha, etc. return integer.
[edit] Also, calling FadeUnitRGB twice in a row seems to crash the thread?