HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Get Local Player

07-03-2003, 11:25 PM#1
draconx
I'm just wondering: How can I do this in TFT's world editor? It's a JASS function I know, does anyone know what it is?
07-04-2003, 12:34 AM#2
Dead-Inside
getLocalplayer? maybe a big p
07-04-2003, 01:41 AM#3
dataangel
GetLocalPlayer()
07-04-2003, 04:47 AM#4
Weinbauer
yes it is implemented in custom text. But I recommend you not to use if your map is for more than 1 player. GetLocalPlayer returns the Player currently looking at the screen. So in multiplayer-map it returns ALL players.
I tried using this function in my map, but as soon as I noticed that you can't pick a specific player with it, I had to redo all the triggers:bgrun:
07-04-2003, 05:53 AM#5
ChrydGod
It return the local player (the one looking at the screen).

It works the same in multiplayer, it returns the local player. Not all players, but the local player, on each player's computer.

It is a very useful way of doings things for specific players when there is only a function for all players to do it.

It has to be used with caution, as if the things you are doing for the local player may affect game variables, it will cause a desync (server split)

This said, many things don't need to be synced to work properly for a local player only.

Regards
07-04-2003, 12:54 PM#6
draconx
I need it to select everyones "town halls" when the game starts.

Edited because: Wouldn't you know it! All that and TFT implelemted selection for single player themselves..
07-04-2003, 07:44 PM#7
Guest
You might want to know that "Get local player" causes desyncs in the game causing what warcrafters call "Server Split" Blizard explains this more in there Blizzard.j files under some of the triggers. Don't use it if you are making a multiplayer map. Email me the problem and a unprotected version of the map to this address [email protected]
07-05-2003, 01:42 AM#8
draconx
coolaboy: First off, Get Local Player does not cause server splits. Using Get Local Player CAN cause server splits, because it can potentially cause the different clients to have different game states

(For example: If you used this trigger: "If Get Local Player equal to Player 1 (red) then do Create 3 sheep for Neutral Passive at Center of playable map area else do Create 2 sheep for Neutral Passive at Center of playable map area", that most likely would drop Player 1 (red).)

As a Desync is caused by syncing errors, Get Local Player is safe to use with things that are not synced. Such as music playback or selections. Apparently if you use JASS though, you have to remember to call SyncSelections() after any selection event.

Secondly, if you read my last post, you would realize that I do not have any problems.
07-05-2003, 08:32 AM#9
Guest
Your not very smart are you. Blizzard states it themselves that it causes "Server Splits" and even if it may not cause it in your map rare problems could occur that would desync the game eventually. You are right though about the music that usually won't desync the game. Using Get Local PLayer in any massive way WILL cause server splits one way or another. Even using it in a small scale can cause them as i found out trying to make my Bomberman map. (Almost Done).
07-05-2003, 09:08 AM#10
AIAndy
Completely wrong, coolaboy. You implicitely use GetLocalPlayer all the time when you use some triggers in the GUI. Some functions cannot be realized without it. As long as you know what you are doing GetLocalPlayer can be used completely safe.

@draconx: SyncSelections needs to be called before you read a selection, not after you make one by trigger. In fact when you use it right after selecting it will not sync the selection you just did.
I did some tests with it when I wrote my SyncInteger function (syncs any integer by using selections). When I called SyncSelections right after doing a selection and then reading it out I read something completely wrong. So there seems to be a delay in multiplayer between when you do a selection and when it can be synced.
07-05-2003, 04:55 PM#11
Panto
AIAndy, would you be willing to post a little trigger which shows where you called it?
07-05-2003, 06:48 PM#12
RodOfNOD
Sometimes listening to you guys is SOOO entertaining....

To actually ANSWER the guys question try this....

Using the new what i call "DNA" insertion technique you are now able to freely mix JASS with GUI text, but only IF you know what you are doing....

I perosnally still needed GetLocalPlayer() for 2 reasons (I will address those below).... If people have work arounds for this then let me know....

1. Create a integer Variable called INTERFACEPlayer.
2. CREATE A NEW trigger.
3. Insert the following 3 lines of Custom Script (3rd choice on the Actions Popup screen) into their own action lines:

if ( GetLocalPlayer() != ConvertedPlayer( udg_INTERFACEPlayer ) ) then

return

endif

4. Place these 3 actions at the beginning of your trigger....

What will now happen is when this trigger is called ONLY the player you want (INTERFACEPlayer) will have the actions that follow those 3 lines actually executed... What that code actually does is says am i on the computer of the player i want to effect... if I am not then RETURN which means SKIP REMAINING ACTIONS.

FYI: ConvertedPlayer is there because while Player #1 = #1 in GUI, Player #0 = Player #1 in JASS.

Ok now what can you safely put under those 3 lines and NOT cause desyncs.....

Since we now have selections per player that is unnecessary now..

I have been told that I can place at least these 2 types of things....

#1: Enable/Disable Fog Of War

I do this because i want ONLY fog of war turned off for a particular player. The current visibility modifiers that use player#s DO NOT do this correctly as they also turn OFF black mask. As all I am doing is turning on/off vision parameters to a player this should NOT cause desyncs.

#2: Play a sound to a player. While there are better 3d sound triggers in TFT i was unable to play a sound for just ONE player.
Once again this is something the game does all the time and thus should NOT cause desyncs...

I have talked to many quality people. IF you have CREDIBLE evidence that either of these or just getlocalplayer in general will guaranteed cause desyncs then please provide not only a statement but evidence and explanation to that fact. If you have an easier way to insert the GUI version of GetLocalPlayer() please also provide this.

I hope this is clear and easy for most people that have experience in mapping/modding to take advantage of this function.

Best of luck.
07-05-2003, 08:45 PM#13
Guest
function CameraSetupApplyForPlayer takes boolean doPan, camerasetup whichSetup, player whichPlayer, real duration returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call CameraSetupApplyForceDuration(whichSetup, doPan, duration)
endif
endfunction.
07-05-2003, 08:51 PM#14
dataangel
Quote:
Originally posted by coolaboy
Your not very smart are you.


Seeing as you're wrong on this issue, you especially shouldn't be calling others stupid.
07-05-2003, 09:08 PM#15
Guest
These are from Blizzard.j


function SetCameraFieldForPlayer takes player whichPlayer, camerafield whichField, real value, real duration returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SetCameraField(whichField, value, duration)
endif
endfunction





function SetCameraTargetControllerNoZForPlayer takes player whichPlayer, unit whichUnit, real xoffset, real yoffset, boolean inheritOrientation returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SetCameraTargetController(whichUnit, xoffset, yoffset, inheritOrientation)
endif
endfunction



function SetCameraPositionForPlayer takes player whichPlayer, real x, real y returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SetCameraPosition(x, y)
endif
endfunction



function SetCameraPositionLocForPlayer takes player whichPlayer, location loc returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SetCameraPosition(GetLocationX(loc), GetLocationY(loc))
endif
endfunction



function PanCameraToForPlayer takes player whichPlayer, real x, real y returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call PanCameraTo(x, y)
endif
endfunction





function PanCameraToLocForPlayer takes player whichPlayer, location loc returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call PanCameraTo(GetLocationX(loc), GetLocationY(loc))
endif
endfunction





function PanCameraToTimedForPlayer takes player whichPlayer, real x, real y, real duration returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call PanCameraToTimed(x, y, duration)
endif
endfunction






function PanCameraToTimedLocForPlayer takes player whichPlayer, location loc, real duration returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), duration)
endif
endfunction






function PanCameraToTimedLocWithZForPlayer takes player whichPlayer, location loc, real zOffset, real duration returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call PanCameraToTimedWithZ(GetLocationX(loc), GetLocationY(loc), zOffset, duration)
endif
endfunction



function SmartCameraPanBJ takes player whichPlayer, location loc, real duration returns nothing
local real dist
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.

set dist = DistanceBetweenPoints(loc, GetCameraTargetPositionLoc())
if (dist >= bj_SMARTPAN_TRESHOLD_SNAP) then
// If the user is too far away, snap the camera.
call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), 0)
elseif (dist >= bj_SMARTPAN_TRESHOLD_PAN) then
// If the user is moderately close, pan the camera.
call PanCameraToTimed(GetLocationX(loc), GetLocationY(loc), duration)
else
// User is close enough, so don't touch the camera.
endif
endif
endfunction






function SetCinematicCameraForPlayer takes player whichPlayer, string cameraModelFile returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SetCinematicCamera(cameraModelFile)
endif
endfunction





function ResetToGameCameraForPlayer takes player whichPlayer, real duration returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call ResetToGameCamera(duration)
endif
endfunction






function CameraSetSourceNoiseForPlayer takes player whichPlayer, real magnitude, real velocity returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call CameraSetSourceNoise(magnitude, velocity)
endif
endfunction




function CameraSetTargetNoiseForPlayer takes player whichPlayer, real magnitude, real velocity returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call CameraSetTargetNoise(magnitude, velocity)
endif
endfunction



function CameraClearNoiseForPlayer takes player whichPlayer returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call CameraSetSourceNoise(0, 0)
call CameraSetTargetNoise(0, 0)
endif
endfunction




function SetCameraBoundsToRectForPlayerBJ takes player whichPlayer, rect r returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SetCameraBoundsToRect(r)
endif
endfunction





function AdjustCameraBoundsForPlayerBJ takes integer adjustMethod, player whichPlayer, real dxWest, real dxEast, real dyNorth, real dySouth returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call AdjustCameraBoundsBJ(adjustMethod, dxWest, dxEast, dyNorth, dySouth)
endif
endfunction






function SetCameraQuickPositionForPlayer takes player whichPlayer, real x, real y returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SetCameraQuickPosition(x, y)
endif
endfunction





function SetCameraQuickPositionLocForPlayer takes player whichPlayer, location loc returns nothing
if (GetLocalPlayer() == whichPlayer) then
// Use only local code (no net traffic) within this block to avoid desyncs.
call SetCameraQuickPosition(GetLocationX(loc), GetLocationY(loc))
endif
endfunction