• 🏆 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!

How to create a screen "Flash"

Status
Not open for further replies.
Level 26
Joined
Aug 18, 2009
Messages
4,097
@DivineLight: Where do your plain pronouncements originate from?

If you use a local block as Xonok shows, do not take the Video - Fade Filter but rather the Video - Advanced Filter action. The first one contains the handling of timers, thus should not be desynced. The latter one at least tries to reset those timers, so avoid Video - Fade Filter altogether to not have them.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
I'm not sure, but I think you have to apply the Fade Filter to everyone, but base the transparency on each player with an array. If you want just player 1 to have the flash, set transparency to 100% for everyone except player 1.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
@DivineLight: Where do your plain pronouncements originate from?

If you use a local block as Xonok shows, do not take the Video - Fade Filter but rather the Video - Advanced Filter action. The first one contains the handling of timers, thus should not be desynced. The latter one at least tries to reset those timers, so avoid Video - Fade Filter altogether to not have them.
I'm not sure, but I think you have to apply the Fade Filter to everyone, but base the transparency on each player with an array. If you want just player 1 to have the flash, set transparency to 100% for everyone except player 1.
Good point, the cinematic actions in GUI are very expansive and thus have a high chance of containing stuff that should be synced.

EDIT: I've looked over what the GUI fadefilters translate into and the way they suggested is actually the best way for now, cos the transitions are done with timers(must be synced).
 
IDK which one of these is the Video Fade Filter
JASS:
//===========================================================================

function CinematicFadeCommonBJ takes real red, real green, real blue, real duration, string tex, real startTrans, real endTrans returns nothing

    if (duration == 0) then

        // If the fade is instant, use the same starting and ending values,

        // so that we effectively do a set rather than a fade.

        set startTrans = endTrans

    endif

    call EnableUserUI(false)

    call SetCineFilterTexture(tex)

    call SetCineFilterBlendMode(BLEND_MODE_BLEND)

    call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)

    call SetCineFilterStartUV(0, 0, 1, 1)

    call SetCineFilterEndUV(0, 0, 1, 1)

    call SetCineFilterStartColor(PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100-startTrans))

    call SetCineFilterEndColor(PercentTo255(red), PercentTo255(green), PercentTo255(blue), PercentTo255(100-endTrans))

    call SetCineFilterDuration(duration)

    call DisplayCineFilter(true)

endfunction



//===========================================================================

function FinishCinematicFadeBJ takes nothing returns nothing

    call DestroyTimer(bj_cineFadeFinishTimer)

    set bj_cineFadeFinishTimer = null

    call DisplayCineFilter(false)

    call EnableUserUI(true)

endfunction



//===========================================================================

function FinishCinematicFadeAfterBJ takes real duration returns nothing

    // Create a timer to end the cinematic fade.

    set bj_cineFadeFinishTimer = CreateTimer()

    call TimerStart(bj_cineFadeFinishTimer, duration, false, function FinishCinematicFadeBJ)

endfunction



//===========================================================================

function ContinueCinematicFadeBJ takes nothing returns nothing

    call DestroyTimer(bj_cineFadeContinueTimer)

    set bj_cineFadeContinueTimer = null

    call CinematicFadeCommonBJ(bj_cineFadeContinueRed, bj_cineFadeContinueGreen, bj_cineFadeContinueBlue, bj_cineFadeContinueDuration, bj_cineFadeContinueTex, bj_cineFadeContinueTrans, 100)

endfunction



//===========================================================================

function ContinueCinematicFadeAfterBJ takes real duration, real red, real green, real blue, real trans, string tex returns nothing

    set bj_cineFadeContinueRed = red

    set bj_cineFadeContinueGreen = green

    set bj_cineFadeContinueBlue = blue

    set bj_cineFadeContinueTrans = trans

    set bj_cineFadeContinueDuration = duration

    set bj_cineFadeContinueTex = tex



    // Create a timer to continue the cinematic fade.

    set bj_cineFadeContinueTimer = CreateTimer()

    call TimerStart(bj_cineFadeContinueTimer, duration, false, function ContinueCinematicFadeBJ)

endfunction



//===========================================================================

function AbortCinematicFadeBJ takes nothing returns nothing

    if (bj_cineFadeContinueTimer != null) then

        call DestroyTimer(bj_cineFadeContinueTimer)

    endif



    if (bj_cineFadeFinishTimer != null) then

        call DestroyTimer(bj_cineFadeFinishTimer)

    endif

endfunction



//===========================================================================

function CinematicFadeBJ takes integer fadetype, real duration, string tex, real red, real green, real blue, real trans returns nothing

    if (fadetype == bj_CINEFADETYPE_FADEOUT) then

        // Fade out to the requested color.

        call AbortCinematicFadeBJ()

        call CinematicFadeCommonBJ(red, green, blue, duration, tex, 100, trans)

    elseif (fadetype == bj_CINEFADETYPE_FADEIN) then

        // Fade in from the requested color.

        call AbortCinematicFadeBJ()

        call CinematicFadeCommonBJ(red, green, blue, duration, tex, trans, 100)

        call FinishCinematicFadeAfterBJ(duration)

    elseif (fadetype == bj_CINEFADETYPE_FADEOUTIN) then

        // Fade out to the requested color, and then fade back in from it.

        if (duration > 0) then

            call AbortCinematicFadeBJ()

            call CinematicFadeCommonBJ(red, green, blue, duration * 0.5, tex, 100, trans)

            call ContinueCinematicFadeAfterBJ(duration * 0.5, red, green, blue, trans, tex)

            call FinishCinematicFadeAfterBJ(duration)

        endif

    else

        // Unrecognized fadetype - ignore the request.

    endif

endfunction
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Video - Fade Filter equals to CinematicFadeBJ as shown on the previous page.

Video - Advanced Filter equals to

JASS:
function CinematicFilterGenericBJ takes real duration, blendmode bmode, string tex, real red0, real green0, real blue0, real trans0, real red1, real green1, real blue1, real trans1 returns nothing
    call AbortCinematicFadeBJ()
    call SetCineFilterTexture(tex)
    call SetCineFilterBlendMode(bmode)
    call SetCineFilterTexMapFlags(TEXMAP_FLAG_NONE)
    call SetCineFilterStartUV(0, 0, 1, 1)
    call SetCineFilterEndUV(0, 0, 1, 1)
    call SetCineFilterStartColor(PercentTo255(red0), PercentTo255(green0), PercentTo255(blue0), PercentTo255(100-trans0))
    call SetCineFilterEndColor(PercentTo255(red1), PercentTo255(green1), PercentTo255(blue1), PercentTo255(100-trans1))
    call SetCineFilterDuration(duration)
    call DisplayCineFilter(true)
endfunction

Blizzard wanted to prevent overlapping filters, so the first line kills previous timers that could only have potentially been created by Video - Fade Filter. It means you will be fine if you do not use any Video - Fade Filter action.

Ofc you can also apply CinematicFadeCommonBJ or call the native functions directly if you do not mind some more jass.

@DivineLight: Read about local blocks. They allow you to execute parts of the code only for specific players, thereby crushing that "globality". Also, not knowing jass does not really help you in evaluating the possibilities of the engine.
 
Level 7
Joined
Jul 1, 2008
Messages
1,025
Oh right so this trigger will actually cause a desync?

  • The Risen
    • Events
    • Conditions
    • Actions
      • Custom script: if GetLocalPlayer() == Player(9) then
      • Cinematic - Fade out and back in over 2.00 seconds using texture White Mask and color (100.00%, 0.00%, 0.00%) with 0.00% transparency
      • Custom script: endif
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Maybe not. But if some other Fade filter is applied during these 2 seconds, it will probably desync, since there's only one global fade timer.

Have you tried to do this with images instead?
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
One way to prevent the desync is to just make it so that you flash the screen for everyone, but all players except one have 100% transparency.
So basically you set a variable to 100%
Then locally change it to 0
Then globally do the flash
Then set variable to 0(To make sure it won't cause a desync later in case the variable is shared)
 
Level 7
Joined
Jul 1, 2008
Messages
1,025
One way to prevent the desync is to just make it so that you flash the screen for everyone, but all players except one have 100% transparency.
So basically you set a variable to 100%
Then locally change it to 0
Then globally do the flash
Then set variable to 0(To make sure it won't cause a desync later in case the variable is shared)

Ok so is the bellow trigger what you mean? Have I done it right?

  • The Risen
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to (==) The "Risen"
    • Actions
      • Set Filter = 100.00
      • Custom script: if GetLocalPlayer() == Player(9) then
      • Set Filter = 0.00
      • Custom script: endif
      • Cinematic - Fade out and back in over 2.00 seconds using texture White Mask and color (100.00%, 0.00%, 0.00%) with Filter% transparency
      • Set Filter = 0.00
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Ok so is the bellow trigger what you mean? Have I done it right?

  • The Risen
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to (==) The "Risen"
    • Actions
      • Set Filter = 100.00
      • Custom script: if GetLocalPlayer() == Player(9) then
      • Set Filter = 0.00
      • Custom script: endif
      • Cinematic - Fade out and back in over 2.00 seconds using texture White Mask and color (100.00%, 0.00%, 0.00%) with Filter% transparency
      • Set Filter = 0.00

Yep, this is it.
 
Just note that if this is for a spell, you may want to add this line after the filter:
  • Custom script: call EnableUserUI(true)
So that certain things, like tooltips, won't be disabled for the duration of the filter. (or just use "Cinematic - Advanced fade filter" instead)

You can look at this for more info (which Spartipilo already linked):
http://www.hiveworkshop.com/forums/cinematics-268/tips-tricks-cinema-39854/#F
 
Level 7
Joined
Jul 1, 2008
Messages
1,025
Yep, this is it.

yay thanks! you've been really helpful!

Just note that if this is for a spell, you may want to add this line after the filter:
  • Custom script: call EnableUserUI(true)
So that certain things, like tooltips, won't be disabled for the duration of the filter. (or just use "Cinematic - Advanced fade filter" instead)

You can look at this for more info (which Spartipilo already linked):
http://www.hiveworkshop.com/forums/cinematics-268/tips-tricks-cinema-39854/#F

Ok thanks, this isnt for a spell but it's good to bear that in mind for future ref.
 
Status
Not open for further replies.
Top