• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Fade Filter for Triggering Player

Status
Not open for further replies.
Level 7
Joined
Dec 8, 2008
Messages
243
Following the pinned "Tips and Tricks for the cinema" thread, I've gotten this.

I'm trying to make the trigger work for only the triggering player.

  • Actions
    • -------- - --------
    • Set AlphaReal = 0.00
    • Custom script: if GetLocalPlayer() != Player(GetPlayerId(GetTriggerPlayer()) - 1) then
    • Set AlphaReal = 100.00
    • Custom script: endif
    • Cinematic - Fade in over 2.00 seconds using texture White Mask and color (0.00%, 0.00%, 0.00%) with AlphaReal% transparency
    • -------- - --------
 
I believe that, whenever you call certain triggers with GUI, the custom script won't have to embrace Jass's features. I am speaking of the player's Id. I don't think it has to be GetPlayerId() - 1. It should only be GetPlayerId(), since the event that fired this trigger is called from GUI, where Player 1 (Red) is PlayerId == 1. I might be wrong, but I also support this.

Anyway, the values must be set in the other way around: First set the 100, and then the 0, so that the transparent filter will be applied for the rest players, while the visible one will only be applied for the Triggering player.
 
Level 7
Joined
Dec 8, 2008
Messages
243
  • Actions
    • -------- - --------
    • Set AlphaReal = 100.00
    • Custom script: if GetLocalPlayer() != Player(GetPlayerId()) then
    • Set AlphaReal = 0.00
    • Custom script: endif
    • Cinematic - Fade in over 4.00 seconds using texture White Mask and color (0.00%, 0.00%, 0.00%) with AlphaReal% transparency
    • -------- - --------
Naw, got an error trying that. :<

  • Actions
    • -------- - --------
    • Set AlphaReal = 100.00
    • Custom script: if GetLocalPlayer() != Player(GetConvertedPlayerId(GetTriggerPlayer())) then
    • Set AlphaReal = 0.00
    • Custom script: endif
    • Cinematic - Fade in over 4.00 seconds using texture White Mask and color (0.00%, 0.00%, 0.00%) with AlphaReal% transparency
    • -------- - --------
Just tried the above piece and it worked, but thats testing single player. Not sure whether it'l work multiplayer. I'll be able to test it later.
 
Level 7
Joined
Dec 8, 2008
Messages
243
Seems to work for single player. I'll give it alil' test later, thanks a million. Been trying to get this to work for months. :X
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
The following script should allow you to properly have different filters simultaneously running (doing their transitions) for the different players.

I have written this some years ago because you are not really the first one that wants local fade filters.

Variables:
cineFadeFinishTimer --> timer array with size 11, preset value new timer
cineFadeContinueTimer --> timer array with size 11, preset value new timer
cineFadeContinueRed --> real array
cineFadeContinueGreen --> real array
cineFadeContinueBlue --> real array
cineFadeContinueTrans --> real array
cineFadeContinueDuration --> real array
cineFadeContinueTex --> string array

JASS:
function CinematicFadeCommonForPlayer takes player p, real red, real green, real blue, real duration, string tex, real startTrans, real endTrans returns nothing
    if (duration == 0) then
        set startTrans = endTrans
    endif
    if (GetLocalPlayer() == p) then
        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)
    endif
endfunction

function FinishCinematicFadeForPlayer takes nothing returns nothing
    local integer playerid
    local integer index = 0
    loop
        exitwhen index > 11
        if (GetExpiredTimer() == udg_cineFadeFinishTimer[index]) then
            set playerid = index
        endif
        set index = index + 1
    endloop
    call DestroyTimer(udg_cineFadeFinishTimer[playerid])
    set udg_cineFadeFinishTimer[playerid] = null
    if (GetPlayerId(GetLocalPlayer()) == playerid) then
        call DisplayCineFilter(false)
        call EnableUserUI(true)
    endif
endfunction

function FinishCinematicFadeAfterForPlayer takes integer playerid, real duration returns nothing
    set udg_cineFadeFinishTimer[playerid] = CreateTimer()
    call TimerStart(udg_cineFadeFinishTimer[playerid], duration, false, function FinishCinematicFadeForPlayer)
endfunction

function ContinueCinematicFadeForPlayer takes nothing returns nothing
    local integer playerid
    local integer index = 0
    loop
        exitwhen index > 11
        if (GetExpiredTimer() == udg_cineFadeContinueTimer[index]) then
            set playerid = index
        endif
        set index = index + 1
    endloop
    call DestroyTimer(udg_cineFadeContinueTimer[playerid])
    set udg_cineFadeContinueTimer[playerid] = null
    call CinematicFadeCommonForPlayer(Player(playerid), udg_cineFadeContinueRed[playerid], udg_cineFadeContinueGreen[playerid], udg_cineFadeContinueBlue[playerid], udg_cineFadeContinueDuration[playerid], udg_cineFadeContinueTex[playerid], udg_cineFadeContinueTrans[playerid], 100)
endfunction

function ContinueCinematicFadeAfterForPlayer takes integer playerid, real duration, real red, real green, real blue, real trans, string tex returns nothing
    set udg_cineFadeContinueRed[playerid] = red
    set udg_cineFadeContinueGreen[playerid] = green
    set udg_cineFadeContinueBlue[playerid] = blue
    set udg_cineFadeContinueTrans[playerid] = trans
    set udg_cineFadeContinueDuration[playerid] = duration
    set udg_cineFadeContinueTex[playerid] = tex
    set udg_cineFadeContinueTimer[playerid] = CreateTimer()
    call TimerStart(udg_cineFadeContinueTimer[playerid], duration, false, function ContinueCinematicFadeForPlayer)
endfunction

function AbortCinematicFadeForPlayer takes integer playerid returns nothing
    if (udg_cineFadeContinueTimer[playerid] != null) then
        call DestroyTimer(udg_cineFadeContinueTimer[playerid])
    endif
    if (udg_cineFadeFinishTimer[playerid] != null) then
        call DestroyTimer(udg_cineFadeFinishTimer[playerid])
    endif
endfunction

function CinematicFadeForPlayer takes player p, integer fadetype, real duration, string tex, real red, real green, real blue, real trans returns nothing
    local integer playerid = GetPlayerId(p)
    if (fadetype == bj_CINEFADETYPE_FADEOUT) then
        call AbortCinematicFadeForPlayer(playerid)
        call CinematicFadeCommonForPlayer(p, red, green, blue, duration, tex, 100, trans)
    elseif (fadetype == bj_CINEFADETYPE_FADEIN) then
        call AbortCinematicFadeForPlayer(playerid)
        call CinematicFadeCommonForPlayer(p, red, green, blue, duration, tex, trans, 100)
        call FinishCinematicFadeAfterForPlayer(playerid, duration)
    elseif (fadetype == bj_CINEFADETYPE_FADEOUTIN) then
        if (duration > 0) then
            call AbortCinematicFadeForPlayer(playerid)
            call CinematicFadeCommonForPlayer(p, red, green, blue, duration * 0.5, tex, 100, trans)
            call ContinueCinematicFadeAfterForPlayer(playerid, duration * 0.5, red, green, blue, trans, tex)
            call FinishCinematicFadeAfterForPlayer(playerid, duration)
        endif
    endif
endfunction

Call the lowest function if you want to use this.
 
Level 2
Joined
Jul 7, 2010
Messages
16
The following script should allow you to properly have different filters simultaneously running (doing their transitions) for the different players.

"blablalbalbalblabla...."

Call the lowest function if you want to use this.

I know that it was a long time since you wrote this reply in this thread but...
..I'm in need of your expertise!!! O:) :thumbs_up:

I'd like to know how I could use this (if okay with you) to create a trigger that when a player :eekani:... wait I'll try to break it down easier...

Event, Condition- Unit casts spell X
Action-
fade out screen to image "war3mapImported\MangekyouUSharinganU(3)_ad.blp" for only the targeted unit . 4 seconds later fade in screen back to normal.

The thing is that I can't understand how to edit your script the way I want it!
So please, would you help me out?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
You display the filter for a player, not a unit.

  • Actions
    • Custom script: local player targetOwner = GetOwningPlayer(GetSpellTargetUnit())
    • Custom script: call CinematicFadeForPlayer(targetOwner, bj_CINEFADETYPE_FADEOUT, 2., "war3mapImported\\MangekyouUSharinganU(3)_ad.blp", 100., 100., 100., 0.)
    • Wait 4.00 game-time seconds
    • Custom script: call CinematicFadeForPlayer(targetOwner, bj_CINEFADETYPE_FADEIN, 2., "war3mapImported\\MangekyouUSharinganU(3)_ad.blp", 100., 100., 100., 0.)
    • Custom script: set targetOwner = null
The 2.s arguments in the CinematicFadeForPlayer calls are the transition times, you can replace them with your desired length.
 
Level 2
Joined
Jul 7, 2010
Messages
16
Thank you so much!! I love you! <3 :)
I have used quite some hours to try to understand your script and also trying to create a trigger that'd work. I failed with both of those.

Thanks a bunch again!
+rep
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
The script is that of blizzard how the GUI actions work, only that I have modified it to support it indepently for different players. Of course, if you do not want to make it GUI-style, you can break it down to only use the native functions that are shown in function CinematicFadeCommonForPlayer.
 
Status
Not open for further replies.
Top