• 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.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[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?
 
Yeah, I've read that before, but I don't see any explanation for referencing a unit owned by a player.

??
 
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
 
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.
 
-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
 
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.
 
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.
 
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.
 
@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?
 
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.
 
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
 
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.
Back
Top