Warcraft III resources & community, 2003–2006 · archived

Fade in Credits

not rated
Submitted by UnMiText Parsing0 downloads
Fades in a cumstomable text (Like in a movie :O). Recommanded to be used for giving credits.
Note: Transparency effect only works on a black background.

Source

//****************************************************************************************
//                         KaTTaNa's Handle Var Functions                               **
//****************************************************************************************
globals
    gamecache udg_gamecache
endglobals

function H2I takes handle h returns integer
    return h
    return 0
endfunction
 
function game_cache takes nothing returns gamecache
    if (udg_gamecache==null) then
        call FlushGameCache(InitGameCache("hax.w3v"))
        set udg_gamecache=InitGameCache("hax.w3v")
    endif
    return udg_gamecache
endfunction
 
function SetHandleString takes handle subject, string name, string value returns nothing
    if value==null then
        call FlushStoredString(game_cache(), I2S(H2I(subject)), name)
    else
        call StoreString(game_cache(), I2S(H2I(subject)), name, value)
    endif
endfunction
 
function SetHandleReal takes handle subject, string name, real value returns nothing
    if value==0 then
        call FlushStoredReal(game_cache(), I2S(H2I(subject)), name)
    else
        call StoreReal(game_cache(), I2S(H2I(subject)), name, value)
    endif
endfunction
 
function GetHandleReal takes handle subject, string name returns real
    return GetStoredReal(game_cache(), I2S(H2I(subject)), name)
endfunction
 
function GetHandleString takes handle subject, string name returns string
    return GetStoredString(game_cache(), I2S(H2I(subject)), name)
endfunction
 
function FlushHandleLocals takes handle subject returns nothing
    call FlushStoredMission(game_cache(), I2S(H2I(subject)) )
endfunction
//----------------------------------------------------------------------------------------
//****************************************************************************************
//                                  Fade in Credits                                     **
//****************************************************************************************
function FiC_text_to_all takes string s, real r1, real r2, real r3 returns nothing
    if (IsPlayerInForce(GetLocalPlayer(), GetPlayersAll())) then
        call DisplayTimedTextFromPlayer(GetLocalPlayer(), r1, r2, r3, s)
    endif
endfunction
                              
function FiC_inc_main takes string s returns string
    if (s=="A") then
        return "B"
    elseif (s=="B") then
        return "C"
    elseif (s=="C") then
        return "D"
    elseif (s=="D") then
        return "E"
    elseif (s=="E") then
        return "F"
    elseif (s=="9") then
        return "A"
    else
        return I2S(S2I(s)+1)
    endif
    return s
endfunction
  
function FiC_inc_sub takes string s returns string
    local string main = SubString(s,0,1)
    local string sub = SubString(s,1,2)
    if (sub=="9") then
        set sub = "A"
    elseif (sub=="A") then
        set sub = "B"
    elseif (sub=="B") then
        set sub = "C"
    elseif (sub=="C") then
        set sub = "D"
    elseif (sub=="D") then
        set sub = "E"
    elseif (sub=="E") then
        set sub = "F"
    elseif (sub=="F") then
        set main = FiC_inc_main(main)
        set sub = "0"
    else
        set sub = I2S(S2I(sub)+1)
    endif
    return main+sub+main+sub+main+sub
endfunction
  
function FiC_print_fading_2 takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local string string_2 = GetHandleString(t,"String 2")
    local string fading_2 = GetHandleString(t,"Fading 2")
    local string string_1 = GetHandleString(t,"String 1")
    local string faded = "|c00FFFFFF"+string_1
    local real position = GetHandleReal(t,"Position")
    local real duration = GetHandleReal(t,"Duration")
    call ClearTextMessagesBJ(GetPlayersAll())
    set fading_2 = "|c00"+FiC_inc_sub(SubString(fading_2,4,6))+string_2
    call SetHandleString(t,"Fading 2",fading_2)
    call FiC_text_to_all(faded,position,0.00,duration)
    call FiC_text_to_all(fading_2,position,0.00,duration)
    if (SubString(fading_2,4,6) == "FF") then
        call FlushHandleLocals(t)
        call DestroyTimer(t)
    endif
    set t = null
endfunction
 
function FiC_print_fading_1 takes nothing returns nothing
    local timer t = GetExpiredTimer()
    local string string_1 = GetHandleString(t,"String 1")
    local string fading_1 = GetHandleString(t,"Fading 1")
    local string string_2 = GetHandleString(t,"String 2")
    local string fading_2 = "|c00000000"+string_2
    local real position = GetHandleReal(t,"Position")
    local real duration = GetHandleReal(t,"Duration")
    local timer t2
    call ClearTextMessagesBJ(GetPlayersAll())
    set fading_1 = "|c00"+FiC_inc_sub(SubString(fading_1,4,6))+string_1
    call SetHandleString(t,"Fading 1",fading_1)
    call FiC_text_to_all(fading_1,position,0.00,duration)
    call FiC_text_to_all(" ",position,0.00,duration)
    if (SubString(fading_1,4,6) == "FF") then
        set t2 = CreateTimer()
        call SetHandleString(t2,"String 1",string_1)
        call SetHandleString(t2,"String 2",string_2)
        call SetHandleString(t2,"Fading 2",fading_2)
        call SetHandleReal(t2,"Position",position)
        call SetHandleReal(t2,"Duration",duration)
        call TimerStart(t2,0.007,true,function FiC_print_fading_2)
        call FlushHandleLocals(t)
        call DestroyTimer(t)
    endif
    set t = null
    set t2 = null
endfunction
 
//########################################################################################
//                      This is the actual function to fade in a text                   ##
//########################################################################################
function FiC_fade_in_credits takes string category, string name, real position, real duration returns nothing
// Type a real of "0.00" for position to make the text display on the left corner, and "1.70" to make it appear on the right side
    local string fading_1 = "|c00000000"+category
    local timer t = CreateTimer()
    call SetHandleString(t,"Fading 1",fading_1)
    call SetHandleString(t,"String 1",category)
    call SetHandleString(t,"String 2",name)
    call SetHandleReal(t,"Position",position)
    call SetHandleReal(t,"Duration",duration)
    call TimerStart(t,0.007,true,function FiC_print_fading_1)
    set t = null
endfunction

Comments

4
How do you use these?
very nice job!
Oh...I see!!!
*Updated*
gj, but...

-down with those darn "|r" tags --- as long as you want the entire string to be colored, they are unneeded ( they just tell wc3 where to stop coloring the string if you wish for a partial coloring )

-just put the names of the required Handle Vars in the Comments, dont bother adding them to the code, as anyone using this has about a 99% chance of already having them lying around