GetLocalPlayer() - set variables

N-a-z-g-u-l

New Member
Reaction score
30
Code:
set Var1 = GetCameraTargetPositionLoc()

this way Var1 would have different values for all players, does this create desyncs? should i use an array instead?:
Code:
set Var1[GetPlayerId(GetLocalPlayer())] = GetCameraTargetPositionLoc()
 
M

Mythic Fr0st

Guest
hmm

As far as I know, I'd use [GetPlayerId], cus otherwise would "Var1" not be set to a players location? What if what triggers it sets it to players 2 location for example?, (However, I dont know what "Desync" is)
 

N-a-z-g-u-l

New Member
Reaction score
30
GetCameraTargetPositionLoc() returns the LocalPlayer's Camera Location, and if the var is set for the local player to that location, the var is on every PC different, the location for the camera each, but without an array... it would be a desync, but a wanted desync (desync means that the game is different on other computers, perhaps one has a unit, and on the other pc, the player does not see that unit, because it was only created for LocalPlayer)
 

Xorifelse

I'd love to elaborate about discussions...........
Reaction score
87
First of all... This is the forum forum, try the JASS zone.

Secondly

This would never work.

GetPlayerId(GetLocalPlayer()) Extra brace. No good.
 

SFilip

Gone but not forgotten
Reaction score
634
> Extra brace. No good.
:nuts:
GetPlayerId(GetLocalPlayer())

well anyway...what are you trying to do?
 

Xorifelse

I'd love to elaborate about discussions...........
Reaction score
87
SFilip said:
> Extra brace. No good.
:nuts:
GetPlayerId(GetLocalPlayer())

well anyway...what are you trying to do?

o_O, i knew i should have gone to bed early..
 

N-a-z-g-u-l

New Member
Reaction score
30
This should make the camera shake, but only if it is in the target area.... and i have to save the Noise for player to higher or lower it, otherwise, the script would not be multi-taskable... in this case i use udg_NoiseForPlayer[] for saving it, and i was thinking about replacing them with a non-array...

please no comments that this code would not work, it definetely works, and it works in a multiplayer game, too.... i dont know much about desyncs, but in that multiplayer game i tested it, there were none i could recognize...

btw, sorry for posting it in the wrong section, but i bookmarked this section, started to post, then recognized, that the forum has sections and read "world editor help zone", thought i were right...

Code:
function CameraAddEQNoiseForPlayerSave takes real magnitude returns nothing
	local real Noise = udg_NoiseForPlayer[GetPlayerId( GetLocalPlayer(  ) ) + 1] + magnitude
	local real richter
	set udg_NoiseForPlayer[GetPlayerId( GetLocalPlayer(  ) ) + 1] = Noise
	if Noise > 5.0 then
		set richter = 5.0
	else
		if Noise < 2.0 then
			set richter = 2.0
		else
			set richter = Noise
		endif
	endif
	call CameraSetSourceNoise( Noise * 2.0, Noise * Pow( 10, richter ) )
	call CameraSetTargetNoise( Noise * 2.0, Noise * Pow( 10, richter ) )
endfunction

function ShakeCamAtLoc_Child takes nothing returns nothing
	local real X = bj_meleeNearestMineDist
	local real Y = bj_cineFadeContinueRed
	local real fadeStart = bj_cineFadeContinueGreen * 0.85
	local real fadeEnd = bj_cineFadeContinueGreen * 1.20
	local real magnitude = bj_cineFadeContinueBlue
	local real duration = bj_cineFadeContinueDuration
	local real DistX
	local real DistY
	local real Dist
	local real LastShakingMagnitude = 0
	local real NewShakingMagnitude
	local timer durTimer = CreateTimer(  )
	local integer i = 0
	call TimerStart( durTimer, duration, false, null )
	loop
		exitwhen TimerGetRemaining( durTimer ) < 0.20
		set NewShakingMagnitude = -LastShakingMagnitude
		set DistX = GetCameraTargetPositionX(  ) - X
		set DistY = GetCameraTargetPositionY(  ) - Y
		set Dist = SquareRoot( DistX * DistX + DistY * DistY )
		if Dist < fadeStart then
			set NewShakingMagnitude = NewShakingMagnitude + magnitude
		else
			if Dist < fadeEnd then
				set NewShakingMagnitude = NewShakingMagnitude + magnitude * ( fadeEnd - Dist ) / 200
			endif
		endif
		set LastShakingMagnitude = LastShakingMagnitude + NewShakingMagnitude
		call CameraAddEQNoiseForPlayerSave( NewShakingMagnitude )
		call TriggerSleepAction( 0.20 )
	endloop
	call DestroyTimer( durTimer )
	call CameraAddEQNoiseForPlayerSave( -LastShakingMagnitude )
endfunction

function ShakeCamAtLoc takes location P, real range, real magnitude, real duration returns nothing
	local trigger t = CreateTrigger(  )
	set bj_meleeNearestMineDist = GetLocationX( P )
	set bj_cineFadeContinueRed = GetLocationY( P )
	set bj_cineFadeContinueGreen = range
	set bj_cineFadeContinueBlue = magnitude
	set bj_cineFadeContinueDuration = duration
	call TriggerAddAction( t, function ShakeCamAtLoc_Child )
	call TriggerExecute( t )
	call DestroyTrigger( t )
endfunction
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
As long as you doesn't use GetCameraTargetPositionLoc in a code block that isn't executed on all computers there shouldn't be a problem. Then, ofc, it depends on what you do with the returned location. Creating a unit at it will be a very bad idea while panning the camera to it probably works fine.
 

N-a-z-g-u-l

New Member
Reaction score
30
i want to set a global to a value, which is different on all computers, so the global will not be the same on all computers, is that possible or does it influence randomized values perhaps? etc? setting a local to different values for all players works fine
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Setting a variable to something will never desync, it is the action that returns the value wich the variable will be set to that may cause the desync or what you do with the variable afterwards.

Anyway there is a few stuff that will desync, just stay away from those and you will be fine:
1. Creating an object some player but not for others, this will mess the internal id system up. The same thing applies to destroy things.
2. Using a different value to a function for different players that affect something that isn't 'local'. IE a players camera is local but a units position or hp isn't.
3. Do a randomization of any kind or change the 'seed' for some players but not for others.

There may be some special cases somewhere that I've forgotten.
 

N-a-z-g-u-l

New Member
Reaction score
30
k so, if you read my code, that could be changed?

the variable is only used for the shaking magnitude, only in this part here, because there is no GetCameraNoise(), at least i think so

Code:
	local real Noise = udg_NoiseForPlayer[GetPlayerId( GetLocalPlayer(  ) ) + 1] + magnitude
	local real richter
	set udg_NoiseForPlayer[GetPlayerId( GetLocalPlayer(  ) ) + 1] = Noise

Code:
	local real Noise = udg_NoiseForPlayer + magnitude
	local real richter
	set udg_NoiseForPlayer = Noise
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top