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.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though

      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