• 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.

[Solved] Why won't this Fade Filter for Specific Player in JASS work?

Status
Not open for further replies.
Level 8
Joined
Jul 17, 2004
Messages
283
I'm trying to run a Fade Filter for the owner of a unit who enters a specific region.

Events
Unit - A unit enters Region 000 <gen>
Conditions
Actions
Custom script: if ( GetLocalPlayer() == GetOwningPlayer(GetTriggerUnit()) ) then
Cinematic - Fade out and back in over 2.00 seconds using texture Black Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
Custom script: endif

I have 2 user players setup in game. (Player 1 Red, and Player 2 Blue).
If I walk to the region with a unit owned by me (Player 1 Red), the other player drops (Player 2 Blue), but I don't. How do I fix?
 
Level 8
Joined
Jul 17, 2004
Messages
283
Yeah, I've read that before, but I don't see any explanation for referencing a unit owned by a player.

??
 
Level 10
Joined
May 27, 2009
Messages
495
a unit owned by the player from that thread
  • Actions
    • -------- - --------
    • Set AlphaReal = 100.00
    • Custom script: if GetLocalPlayer() != Player(GetPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1) then
    • Set AlphaReal = 0.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
 
Level 8
Joined
Jul 17, 2004
Messages
283
DIDN'T WORK. here's my trigger:

  • Fade
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
    • Actions
      • Set AlphaReal = 100.00
      • Custom script: if GetLocalPlayer() != Player(GetPlayerId(GetOwningPlayer(GetTriggerUnit())) - 1) then
      • Set AlphaReal = 0.00
      • Custom script: endif
      • Cinematic - Fade out and back in over 2.00 seconds using texture Black Mask and color (0.00%, 0.00%, 0.00%) with AlphaReal% transparency
Caused fatal error for both players.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
-1 should be +1.If that doesn't work too, change time instead of alpha.

On a second think, there shouldn't even be -1 or +1.

  • Fade
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
    • Actions
      • Set AlphaReal = 100.00
      • Custom script: if GetLocalPlayer() != GetOwningPlayer(GetTriggerUnit()) then
      • Set AlphaReal = 0.00
      • Custom script: endif
      • Cinematic - Fade out and back in over 2.00 seconds using texture Black Mask and color (0.00%, 0.00%, 0.00%) with AlphaReal% transparency
 
Level 8
Joined
Jul 17, 2004
Messages
283
Okay, I'm making progress now...

  • Fade
    • Events
      • Unit - A unit enters Region 000 <gen>
    • Conditions
    • Actions
      • Set AlphaReal = 100.00
      • Custom script: if GetLocalPlayer() != Player(GetPlayerId(GetOwningPlayer(GetTriggerUnit())) + 1) then
      • Set AlphaReal = 0.00
      • Custom script: endif
      • Cinematic - Fade out and back in over 2.00 seconds using texture Black Mask and color (0.00%, 0.00%, 0.00%) with AlphaReal% transparency
IT WORKS, EXCEPT, when I step on the region, only I see it... but if Blue steps on it, we both see it... why would it do that?

I only want it to display to the player who steps on the region with their own unit.
 
Level 10
Joined
May 27, 2009
Messages
495
ohh sorry for the code earlier, i just copy pasted from the thread D:

anyways,

use this
  • Fade
  • Events
    • Unit - A unit enters Region 000 <gen>
  • Conditions
  • Actions
    • Set AlphaReal = 100.00
    • Custom script: if GetLocalPlayer() == GetOwningPlayer(GetTriggerUnit()) then
    • Set AlphaReal = 0.00
    • Custom script: endif
    • Cinematic - Fade out and back in over 2.00 seconds using texture Black Mask and color (0.00%, 0.00%, 0.00%) with AlphaReal% transparency
the one given by Ceday that might work, try that
since
  • Custom script: if GetLocalPlayer() != Player(GetPlayerId(GetOwningPlayer(GetTriggerUnit())) + 1) then
will get the next player slot after the owner of the triggering unit.
 
Level 16
Joined
Aug 7, 2009
Messages
1,406
There's no need to mess with Player Id:

if GetLocalPlayer()!= GetOwningPlayer(GetTriggerUnit()) then

But actually != means "Not Equal To". So if player 1 enters the region, it will run for player 2.

Equals To: ==

EDIT:
Also, the reason why the script in the main post doesn't work is this:

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

-->

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

-->

JASS:
    set bj_cineFadeFinishTimer = CreateTimer()

That bj creates a handle on ONLY ONE cumputer. The actual HandleId is different on the players' computer --> desync.
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
@X-Death

Look at my edited post again (I didn't think you will read that fast :vw_wtf:)
 
Level 8
Joined
Jul 17, 2004
Messages
283
@X-Death

Look at my edited post again (I didn't think you will read that fast :vw_wtf:)

Hey, that worked! after you switched from '!=' to '==', hehe...

BUT, now I have other problem... If we both step on the region at same or near same time, my instance of the fade cut out too early, as if the instance was disturbed when Blue stepped on it so quickly after I did... any way to fix that?

Also, what's the point of using these variables to set the transparency? any alternative to that?
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
Yeah, I've read that before, but I don't see any explanation for referencing a unit owned by a player.

??

You have written it yourself. Is it so hard to implement into the other code? Also it did not seem to be the relevant problem here.

JASS:
    set bj_cineFadeFinishTimer = CreateTimer()

That bj creates a handle on ONLY ONE cumputer. The actual HandleId is different on the players' computer --> desync.

No, only the transparency is locally set and it does not depend on that.

BUT, now I have other problem... If we both step on the region at same or near same time, my instance of the fade cut out too early, as if the instance was disturbed when Blue stepped on it so quickly after I did... any way to fix that?

Also, what's the point of using these variables to set the transparency? any alternative to that?

The filters actually run for all players, only that for one it is completely transparent. That is also the reason why player1's stops when another filter is iniated for anyone because the code wants to cancel the previous filter and there can only be one at a time anway.

You did not read the thread I linked you completely. Further down, I posted some functions that mirror the blizzard variants but are laid out for multiple players, so they do not affect each other.
 
Level 16
Joined
Aug 7, 2009
Messages
1,406
No, only the transparency is locally set and it does not depend on that.

I'm talking about this:

Events
Unit - A unit enters Region 000 <gen>
Conditions
Actions
Custom script: if ( GetLocalPlayer() == GetOwningPlayer(GetTriggerUnit()) ) then
Cinematic - Fade out and back in over 2.00 seconds using texture Black Mask and color (0.00%, 0.00%, 0.00%) with 0.00% transparency
Custom script: endif
 
Level 8
Joined
Jul 17, 2004
Messages
283
I went ahead with WaterKnight's advice, and I must say, the result is much more efficient and consistent than any other method I've tried. I can't thank you enough for your help, WaterKnight. +Mega Rep for you, and I'll let you know if I have any more questions.
 
Status
Not open for further replies.
Top