• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Ubersplat System v1.0

This bundle is marked as useful / simple. Simplicity is bliss, low effort and/or may contain minor bugs.
Ubersplat System v1.0
by hell gate and Deoad

about the system:
this system allows you to create timed ubersplats on specific location.

how to use:
call NewUbersplat(ImageFile,Size,X,Y,Duration,FadeDuration)

JASS:
//=====================================================================================
//                      |        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

Keywords:
Ubersplat, Image, Splat, System, fade, timed
Contents

Noch eine WARCRAFT-III-Karte (Map)

Reviews
19:21, 17th Jun 2010 The_Reborn_Devil: This is pretty small and should be placed in the JASS section instead. Rejected.

Moderator

M

Moderator

19:21, 17th Jun 2010
The_Reborn_Devil:

This is pretty small and should be placed in the JASS section instead.

Rejected.
 
Well old friend... :D

A good idea cause its completly new...

BUT there is a lot to improve:
1. Add a new parameter for giving a alpha value on creation
2. If it should be something like UberSplatUtils there is no need to make the struct private cause it is supposed to be reacheable everywhere
3. in case you do 2., create operators for changing the attributes after creation
4. add a instant destruction method

then it will be fine ;D
 
Well old friend... :D

A good idea cause its completly new...

BUT there is a lot to improve:
1. Add a new parameter for giving a alpha value on creation
2. If it should be something like UberSplatUtils there is no need to make the struct private cause it is supposed to be reacheable everywhere
3. in case you do 2., create operators for changing the attributes after creation
4. add a instant destruction method

then it will be fine ;D

1) will added in next update (as color)
2) i said it's something like this but i'll do this too :p
3) hmm.... yes may i'll ad this
4) just set FadeDuration to 0. o_O
 
Top