- Joined
- Nov 5, 2008
- Messages
- 7
hey guys
well I have a simple problem here, which I can somehow not solve myself...
I wrote a basic function for a Motion Blur
but somehow, my created dummies don't share the same animation as the main unit does...
and also, the units seem not to have zero collision size Oo
here is the code:
So where is the reason for my dummy units not to share the animation?!
oh btw here is my call:
Furthermore, I don't think this is the most efficient way...
to learn more about vJASS, I would very much appreciate if someone could help me making this functions more efficient =)
thanks in advance!
greetz
Wishmaster
edit:
the #s were somehow created....dunno why ^^
they are gone now
well I have a simple problem here, which I can somehow not solve myself...
I wrote a basic function for a Motion Blur
but somehow, my created dummies don't share the same animation as the main unit does...
and also, the units seem not to have zero collision size Oo
here is the code:
JASS:
//******************************************//
//Blur Motion
//******************************************//
struct fadeAlpha
unit u
integer fadeSpeed
boolean fadeColor
integer R
integer G
integer B
integer A
static method create takes unit u, integer fadeSpeed, boolean fadeColor returns fadeAlpha
local fadeAlpha fA = fadeAlpha.allocate()
set fA.u = u
set fA.fadeSpeed = fadeSpeed
set fA.fadeColor = fadeColor
set fA.R = 255
set fA.G = 255
set fA.B = 255
set fA.A = 255
return fA
endmethod
method onDestroy takes nothing returns nothing
set .u = null
endmethod
endstruct
private function UnitBlurMotion_fadeAlpha_Child takes nothing returns nothing
local timer t = GetExpiredTimer()
local fadeAlpha fA = fadeAlpha(GetAttachedStruct1(t))
if fA.A <= 0 then
call RemoveUnit(fA.u)
call PauseTimer(t)
call DestroyTimer(t)
else
if fA.fadeColor then
set fA.R = fA.R - fA.fadeSpeed
set fA.G = fA.G - fA.fadeSpeed
set fA.B = fA.B - fA.fadeSpeed
endif
set fA.A = fA.A - fA.fadeSpeed
call SetUnitVertexColor(fA.u,fA.R,fA.G,fA.B,fA.A)
endif
set t = null
endfunction
private function UnitBlurMotion_fadeAlpha takes unit u, integer fadeSpeed, boolean fadeColor, real interval returns nothing
local timer t = CreateTimer()
local fadeAlpha fA = fadeAlpha.create(u,fadeSpeed,fadeColor)
call AttachStruct1(t,fA)
call TimerStart(t,interval,true,function UnitBlurMotion_fadeAlpha_Child)
set t = null
endfunction
private struct MotionBlur
unit hero
group imageGroup
integer images
integer fadeSpeed
boolean fadeColor
real interval
static method create takes unit hero, integer animId, real animSpeed, real animDuration, real interval, boolean fadeColor returns MotionBlur
local MotionBlur MB = MotionBlur.allocate()
local integer i = 0
local integer images = R2I(animDuration/interval + 0.5)
local player pl = GetOwningPlayer(hero)
local unit d
set MB.hero = hero
set MB.imageGroup = CreateGroup()
set MB.fadeSpeed = R2I(255/images + 0.5)
set MB.fadeColor = fadeColor
set MB.interval = interval
loop
exitwhen i > images
set d = CreateUnit(pl,GetUnitTypeId(hero),0,0,GetUnitFacing(hero))
call UnitAddAbility(d,'Amrf')
call UnitRemoveAbility(d,'Amrf')
call UnitAddAbility(d,'Aloc')
call SetUnitAnimationByIndex(d,animId)
call SetUnitTimeScale(d,animSpeed)
call ShowUnit(d,false)
call SetUnitPathing(d,false)
call SetUnitXYZ(d,GetUnitX(hero),GetUnitY(hero),GetUnitZ(hero))
call PauseUnit(d,true)
call GroupAddUnit(MB.imageGroup,d)
set d = null
set i = i+1
endloop
set pl = null
return MB
endmethod
method onDestroy takes nothing returns nothing
local unit u
set .hero = null
call GroupClear(.imageGroup)
call DestroyGroup(.imageGroup)
set .imageGroup = null
endmethod
endstruct
private function UnitBlurMotion_Child takes nothing returns nothing
local timer t = GetExpiredTimer()
local MotionBlur MB = MotionBlur(GetAttachedStruct1(t))
local integer i = 0
local unit imageUnit
set imageUnit = FirstOfGroup(MB.imageGroup)
if imageUnit == null then
call MB.destroy()
call PauseTimer(t)
call DestroyTimer(t)
else
call SetUnitXYZ(imageUnit,GetUnitX(MB.hero),GetUnitY(MB.hero),GetUnitZ(MB.hero))
call SetUnitTimeScale(imageUnit,0)
call GroupRemoveUnit(MB.imageGroup,imageUnit)
call ShowUnit(imageUnit,true)
call UnitBlurMotion_fadeAlpha(imageUnit,MB.fadeSpeed,MB.fadeColor,MB.interval)
endif
set t = null
endfunction
public function UnitBlurMotion takes unit hero, integer animId, real animSpeed, real animDuration, real interval, boolean fadeColor returns nothing
local timer t = CreateTimer()
local MotionBlur MB = MotionBlur.create(hero,animId,animSpeed,animDuration,interval,fadeColor)
call AttachStruct1(t,MB)
call TimerStart(t,interval,true,function UnitBlurMotion_Child)
set t = null
endfunction
//******************************************//
//Blur Motion END
//******************************************//
So where is the reason for my dummy units not to share the animation?!
oh btw here is my call:
JASS:
call WishFunctions_UnitBlurMotion(udg_Wish_XL,4,1,1.,0.1,false)
Furthermore, I don't think this is the most efficient way...
to learn more about vJASS, I would very much appreciate if someone could help me making this functions more efficient =)
thanks in advance!
greetz
Wishmaster
edit:
the #s were somehow created....dunno why ^^
they are gone now