• 🏆 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!
  • ✅ Time to vote for the top 3 models! The POLL for Hive's 6th HD Modeling Contest: Mechanical is now open! 📅 Poll close on July 16, 2024! 🔗 Cast your vote now!

[Trigger] Get Local Player and

Status
Not open for further replies.
Level 7
Joined
Jul 9, 2012
Messages
159
Hello everyone!
I'm struggling with a trigger:
A periodic loop checks if a player's in-game camera is within a region, and then runs the call SetDayNightModels("","") for the player by using GetLocalPlayer. It changes the DayNightModels back to normal if the camera is not within the region anymore.

I tested the map with a friend, and we disconnected every time the GetLocalPlayer runned. It desynced, but I don't know why. Hope you can help me find the problem :)

  • Spooky Passage DNC Loop
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set SpookyPassageDNC_player = (Picked player)
          • Set SpookyPassageDNC_p = (Target of current camera view)
          • Set SpookyPassageDNC_i = (Load 1 of (Key (Picked player)) from SpookyPassageDNC_hashtable)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Spooky Passage <gen> contains SpookyPassageDNC_p) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SpookyPassageDNC_i Equal to 0
                • Then - Actions
                  • Set SpookyPassageDNC_i = 1
                  • Custom script: if GetLocalPlayer() == udg_SpookyPassageDNC_player then
                  • Cinematic - Fade in over 0.50 seconds using texture Black Mask and color (0.00%, 0.00%, 0.00%) with 25.00% transparency
                  • Custom script: call SetDayNightModels("","")
                  • Custom script: endif
                  • Hashtable - Save SpookyPassageDNC_i as 1 of (Key (Picked player)) in SpookyPassageDNC_hashtable
                • Else - Actions
            • Else - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SpookyPassageDNC_i Equal to 1
                • Then - Actions
                  • Set SpookyPassageDNC_i = 0
                  • Custom script: if GetLocalPlayer() == udg_SpookyPassageDNC_player then
                  • Custom script: call SetDayNightModels("Environment\\DNC\\DNCAshenvale\\DNCAshenValeTerrain\\DNCAshenValeTerrain.mdx","Environment\\DNC\\DNCAshenvale\\DNCAshenValeUnit\\DNCAshenValeUnit.mdx")
                  • Custom script: endif
                  • Hashtable - Save SpookyPassageDNC_i as 1 of (Key (Picked player)) in SpookyPassageDNC_hashtable
                • Else - Actions
          • Custom script: call RemoveLocation(udg_SpookyPassageDNC_p)
 
Level 13
Joined
May 10, 2009
Messages
868
My bet is that "(Target of current camera view)" is causing the problem. It is an asynchronous function, which means that it returns a different value for each client. Then, the condition might return true for some players, and false for the rest. Resulting in an attempt of saving an integer value into the table for certain clients.
 

LeP

LeP

Level 13
Joined
Feb 13, 2008
Messages
540
For once you shouldnt declare the string in the "local" block, but rather set it "" like this:
JASS:
set whatever_string = "your\\path\\here"
if GetLocalPlayer() != wanted_player then
  set whatever_string = ""
endif

But that is not the problem here.
Let's look at the fade-filter function:
JASS:
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 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

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

I have hightlighted a few lines which should make it very clear why it is desyncing.
 
Level 7
Joined
Jul 9, 2012
Messages
159
Ah, I see! :) Thanks for the replies. My knowledge of scripting isn't good.
Read about the topic of desync on a few forums; people stated that the advanced fading filter won't desync. So I hope they're right, and the problem is fixed by making an advanced filter instead of the simple.
 
Last edited:
Level 13
Joined
May 10, 2009
Messages
868
Hm... I completely forgot about basic fade filter creating those handles. Well, the advanced one seems to be a little bit better, except that it calls for the AbortCinematicFadeBJ function. Though it doesn't create any handle.

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
 
Status
Not open for further replies.
Top