//=====================================================================================
// | Ubersplat System |
// | by hell gate and Deaod |
//=====================================================================================
// how to use:
// CnP this system in your map
// to create an ubersplat use:
// call NewUbersplat(ImageFile,Size,X,Y,Duration,FadeDuration)
//=====================================================================================
library UbersplatSystem
globals
private constant integer UbersplatNr = 4 //Ubersplat number. Don't change this!
private constant real RefreshTime = 1./40 //The refresh intervall
endglobals
private struct Ubersplat
image Splat //the ubersplat
real Alpha = 0. //the Alpha of the ubersplat
real Duration //time left befor fade
real FadeSpeed //how much alpha will added/RefreshTime
private integer i
private static timer Tim = CreateTimer()
private static integer Total = 0
private static thistype array Images
private method onDestroy takes nothing returns nothing
call DestroyImage(Splat)
set Total = Total - 1
set Images[i] = Images[Total]
set Images[i].i=i
if Total==0 then
call PauseTimer(Tim)
endif
endmethod
private static method UbersplatUpdate takes nothing returns nothing
local thistype dat
local integer i = Total-1
loop
exitwhen i < 0
set dat = Images[i]
if dat.Duration <= 0. then
if dat.Alpha >= 100. then
call dat.destroy()
else
set dat.Alpha = dat.Alpha + dat.FadeSpeed
call SetImageColor(dat.Splat,255,255,255,PercentToInt(100.0-dat.Alpha,255))
endif
else
set dat.Duration = dat.Duration-RefreshTime
endif
set i = i-1
endloop
endmethod
static method create takes string File, real Size, real X, real Y, real Duration, real FadeDuration returns thistype
local thistype dat = allocate()
set Images[Total] = dat
if Total==0 then
call TimerStart(Tim,RefreshTime,true,function thistype.UbersplatUpdate)
endif
set dat.i=Total
set Total = Total+1
set dat.Splat = CreateImage(File,Size,Size,Size,X-Size*.5,Y-Size*.5,0.,0.,0.,0.,UbersplatNr)
set dat.Duration = Duration
set dat.FadeSpeed = RefreshTime*100/FadeDuration
call ShowImage(dat.Splat,true)
call SetImageRenderAlways(dat.Splat,true)
call SetImageColor(dat.Splat,255,255,255,255)
return dat
endmethod
endstruct
function NewUbersplat takes string File, real Size, real X, real Y, real Duration, real FadeDuration returns nothing
call Ubersplat.create(File, Size, X, Y, Duration, FadeDuration)
endfunction
endlibrary