HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Quick look.. Will this spell desync?

06-28-2007, 12:10 PM#1
Oki
Will this desync? I´m just asking because I have bad experiences in using getlocalplayer after last time I used it in a flashbang spell.

Collapse JASS:
function Trig_Telescope_Conditions takes nothing returns boolean
   
    return GetSpellAbilityId() == 'A000'
endfunction

function Trig_Telescope_Actions takes nothing returns nothing
    
    local unit u = GetTriggerUnit()
    local unit dummy
    local player p = GetOwningPlayer(u)
    local location l = GetUnitLoc(u)
    local location l2 = GetSpellTargetLoc()
    local real x = GetLocationX(l)
    local real y = GetLocationY(l)
    local real z = GetLocationZ(l)
    local real x2 = GetLocationX(l2)
    local real y2 = GetLocationY(l2)
    local real z2 = GetLocationZ(l2)
    local real dist = DistanceBetweenPoints( l2,l )
    local real fielddist = 2000
    local real noise = 0.007 * dist
    local real angle = Atan2(y - y2, x - x2) * bj_RADTODEG + 180
    local real angle2 = Atan2( z2 - z , dist) * bj_RADTODEG
    local real cameyeX = 0
    local real cameyeX2 = 0
    local real cameyeY = 0
    local real cameyeY2 = 0
    
    if dist > 5000 then
       set fielddist = dist - 3000
    elseif dist < 2000 then
       set fielddist = dist 
    endif
    
    //call BJDebugMsg(R2S(dist))
    
    call  CreateNUnitsAtLoc( 1, 'e001', p, l2, bj_UNIT_FACING )
    set dummy = GetLastCreatedUnit()
 
    if p == GetLocalPlayer() then
        
         call CinematicFadeBJ( bj_CINEFADETYPE_FADEOUT, 0.00, "ReplaceableTextures\\CameraMasks\\Scope_Mask.blp", 1.00, 1.00, 1.00, 0.00 )
         call PanCameraTo( x2, y2)
         call SetCameraField( CAMERA_FIELD_TARGET_DISTANCE, fielddist, 0.00 )
         call SetCameraField( CAMERA_FIELD_ROTATION, angle , 0.00 )
         call SetCameraField( CAMERA_FIELD_ANGLE_OF_ATTACK, angle2, 0.00 ) 
         call SetCameraField( CAMERA_FIELD_ZOFFSET, 25.00 + z2 * 0.40 , 0.00 )
         call CameraSetTargetNoise( noise, noise*0.01 )
         
    endif
    
    call TriggerSleepAction( 1. )
    
    loop
        
    
                                   
        exitwhen  x-50 > GetUnitX(u) or x+50 < GetUnitX(u) or y-50 > GetUnitY(u) or y+50 < GetUnitY(u) or cameyeX-50 > cameyeX2 or cameyeX+50 < cameyeX2 or cameyeY-50 > cameyeY2 or cameyeY+50 < cameyeY2 
      
        call TriggerSleepAction(0.5)
        
        if cameyeX == 0 then
        set cameyeX = GetCameraEyePositionX()
        set cameyeY = GetCameraEyePositionY()
        
        endif
        
        if p == GetLocalPlayer() then
        set cameyeX2 = GetCameraEyePositionX()
        set cameyeY2 = GetCameraEyePositionY()
        endif

    endloop
    
    call KillUnit(dummy)
    
    if GetUnitCurrentOrder(u) != String2OrderIdBJ("acolyteharvest") then
     
    if p == GetLocalPlayer() then
        
         call CinematicFadeBJ( bj_CINEFADETYPE_FADEIN, 0.00, "ReplaceableTextures\\CameraMasks\\Scope_Mask.blp", 1.00, 1.00, 1.00, 0.00 )
         call ResetToGameCamera( 0.1 )
         call PanCameraTo( x, y)
    endif
    
    endif
    
    call RemoveLocation(l)            
    call RemoveLocation(l2) 
    
  
    set u = null 
    set dummy = null
    set p = null 
    set l = null 
    set l2 = null 
    
endfunction

//===========================================================================
function InitTrig_Telescope takes nothing returns nothing
    set gg_trg_Telescope = CreateTrigger(  )
    call TriggerRegisterAnyUnitEventBJ( gg_trg_Telescope, EVENT_PLAYER_UNIT_SPELL_EFFECT )
    call TriggerAddCondition( gg_trg_Telescope, Condition( function Trig_Telescope_Conditions ) )
    call TriggerAddAction( gg_trg_Telescope, function Trig_Telescope_Actions )
endfunction
06-28-2007, 03:04 PM#2
Ammorth
I don't believe it should. All the local calls are to do with Cameras and fade filters (which is how Blizzard does it).
06-28-2007, 03:07 PM#3
Rising_Dusk
You have one part that maybe you forgot to put in a GetLocalPlayer() conditional that will cause issues in the way it works.
Collapse JASS:
        if cameyeX == 0 then
        set cameyeX = GetCameraEyePositionX()
        set cameyeY = GetCameraEyePositionY()
        
        endif
That will get the camera eye position for EVERY player and put the last player it cycles through into the final value for the variables.
I somehow don't think that was your goal.
06-28-2007, 03:34 PM#4
Oki
Okay I guess its pretty desync free then, and thanks for noticing the unintentional part.
06-28-2007, 03:49 PM#5
Vexorian
calling functions (not natives) inside GetLocalPlayer causes desync (else pan camera as necessary wouldn't desync..) You most likely have to replace CinematicFadeBJ with a native version

Quote:
Collapse JASS:
    loop
        
    
                                   
        exitwhen  x-50 > GetUnitX(u) or x+50 < GetUnitX(u) or y-50 > GetUnitY(u) or y+50 < GetUnitY(u) or cameyeX-50 > cameyeX2 or cameyeX+50 < cameyeX2 or cameyeY-50 > cameyeY2 or cameyeY+50 < cameyeY2 
      
        call TriggerSleepAction(0.5)
        
        if cameyeX == 0 then
        set cameyeX = GetCameraEyePositionX()
        set cameyeY = GetCameraEyePositionY()
        
        endif
        
        if p == GetLocalPlayer() then
        set cameyeX2 = GetCameraEyePositionX()
        set cameyeY2 = GetCameraEyePositionY()
        endif

    endloop
    
    call KillUnit(dummy)

This is set to totally desync. I think you are gonna have to sync those camera values, it is pretty hard to get this process without desync, the idea also seems totally lame imho... I don't think you HAVE to do this...
06-28-2007, 03:59 PM#6
Rising_Dusk
Quote:
calling functions (not natives) inside GetLocalPlayer causes desync
Really now?
That's interesting, I did not know that.
06-28-2007, 04:12 PM#7
Vexorian
I think it is something related to how locals work.

Well when we were wondering about what causes "pan camera as necessary" desync someone mentioned a blizzard employee saying that "functions cause net traffic" When I made it stop calling a function inside a GetLocalPlayer() block that function stopped desyncing.
06-28-2007, 04:34 PM#8
Oki
Have anybody created a native CinematicFadeBJ version then?^^
Quote:
Collapse JASS:
    loop
        
    
                                   
        exitwhen  x-50 > GetUnitX(u) or x+50 < GetUnitX(u) or y-50 > GetUnitY(u) or y+50 < GetUnitY(u) or cameyeX-50 > cameyeX2 or cameyeX+50 < cameyeX2 or cameyeY-50 > cameyeY2 or cameyeY+50 < cameyeY2 
      
        call TriggerSleepAction(0.5)
        
        if cameyeX == 0 then
        set cameyeX = GetCameraEyePositionX()
        set cameyeY = GetCameraEyePositionY()
        
        endif
        
        if p == GetLocalPlayer() then
        set cameyeX2 = GetCameraEyePositionX()
        set cameyeY2 = GetCameraEyePositionY()
        endif

    endloop
...just used this to avoid people from mouse scrolling and getting an odd telescope, but why would it desync the camera functions are natives...?
06-28-2007, 07:16 PM#9
Toadcop
Quote:
calling functions (not natives) inside GetLocalPlayer causes desync
really ? (yes i know everybody trust him ^^ ) but the answer is false ! you can call a custom function with out a problem ! (you simple must have direct hands X10 xD)
here a example

http://wc3campaigns.net/showthread.php?t=94870
// bottom post

Oki i will try a new Sync method today maybe it will work well ^^ so you can use it.