GetLocalPlayer - By ChaosyIntroductionThis is my first tutorial on blizzardmodding, but I have been around the editor messing around for GUI for one year now (@hiveworkshop) and I thought I might share this tutorial with you guys.
I made this tutorial since I think way to few people know that this exist in GUI, so I want to show you how to use "GetLocalPlayer" in GUI.
What is needed?Decent knowage of GUI triggering.
Very basic jass knowage.
A few moments of your time.
What is GetLocalPlayer?GetLocalPlayer is a method to create certain things/stuff in JASS, but I will show you how to use this method in the GUI.
This method will allow you to create this thing/stuff [
special effects, multiboards, floating text, etc] for the player of your choise only.
For example, you can show a multiboard to player 1 only, while the other player wont see any multiboard at all!
That sounds awesome how do I use this?As one example I will create a multiboard for player 1 only, you can use any event you want.
NOTICE! We use a player variable named "GetLocalPlayer" or "Player" based on wich way you want to use. but you can name it whatever you want.
This is the way I recomend for GUI users, you only set only single line JASS in the init trigger and then you can use that variable the whole game!
init
Events
Map initialization
Conditions
Actions
Custom script: set udg_GetLocalPlayer = GetLocalPlayer()
Multiboard for one player
Events
Player - Player 1 (Red) skips a cinematic sequence
Conditions
Actions
Multiboard - Create a multiboard with 1 columns and 1 rows, titled hellu
Multiboard - Hide (Last created multiboard)
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GetLocalPlayer Equal to Player 1 (Red)
Then - Actions
Multiboard - Show (Last created multiboard)
Else - Actions
Here is the version that you should use if you actually like jass (Wich I really dont do).
Multiboard for one player jass
Events
Player - Player 1 (Red) skips a cinematic sequence
Conditions
Actions
Multiboard - Create a multiboard with 1 columns and 1 rows, titled hellu
Multiboard - Hide (Last created multiboard)
Custom script: if GetLocalPlayer() == Player(0) then
Multiboard - Show (Last created multiboard)
Custom script: endif
Here is the trigger wich you can use if you want to but as said the first trigger is better. But this is pretty much the standrad
Multiboard for one player
Events
Player - Player 1 (Red) skips a cinematic sequence
Conditions
Actions
Multiboard - Create a multiboard with 1 columns and 1 rows, titled hellu
Multiboard - Hide (Last created multiboard)
Custom script: set udg_Player = GetLocalPlayer()
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Player Equal to Player 1 (Red)
Then - Actions
Multiboard - Show (Last created multiboard)
Else - Actions
Now I will go through the trigger.
First we create a multiboard just edit it as you want.
Multiboard - Create a multiboard with 1 columns and 1 rows, titled hellu
After that we instantly hide it so no player never saw that multiboard.
Multiboard - Hide (Last created multiboard)
Now the the hard part, now we use a custom script since the action does not exist within the GUI. It stores the player returned from the GetLocalPlayer() function inside your player variable.
Custom script: set udg_Player = GetLocalPlayer()
And lastly we just select wich players we want it to be showed to, in this case it will ONLY be showed to player red (1) aint that awesome?
NOTICE! The jass and the GUI version is just the same you can use any of them!
NOTICE! In jass the player index is between in 0-11 insted of 1-12 in GUI!
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Player Equal to Player 1 (Red)
Then - Actions
Multiboard - Show (Last created multiboard)
Else - Actions
Custom script: if GetLocalPlayer() == Player(0) then
Multiboard - Show (Last created multiboard)
Custom script: endif
Great, but can I do the same to other things?Yes you really can, lets take special effects.
Again I show you the same three ways nothing new with the method.
init
Events
Map initialization
Conditions
Actions
Custom script: set udg_GetLocalPlayer = GetLocalPlayer()
special effect trollbrain way
Events
Player - Player 1 (Red) skips a cinematic sequence
Conditions
Actions
Set Effect = <Empty String>
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
GetLocalPlayer Equal to Player 1 (Red)
Then - Actions
Set Effect = Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
Else - Actions
Special Effect - Create a special effect attached to the overhead of Peasant 0001 <gen> using Effect
Special effect for one player jass
Events
Player - Player 1 (Red) Presses the Right Arrow key
Player - Player 2 (Blue) Presses the Right Arrow key
Conditions
Actions
Set Effect = <Empty String>
Custom script: set udg_Player = GetLocalPlayer()
Custom script: if GetLocalPlayer() == Player(0) then
Set Effect = Abilities\Spells\Human\DispelMagic\DispelMagicTarget.mdl
Custom script: endif
Special Effect - Create a special effect attached to the overhead of Peasant 0001 <gen> using Effect
Special effect for one player
Events
Player - Player 1 (Red) skips a cinematic sequence
Conditions
Actions
Set Effect = <Empty String>
Custom script: set udg_Player = GetLocalPlayer()
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Player Equal to Player 1 (Red)
Then - Actions
Set Effect = Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
Else - Actions
Special Effect - Create a special effect attached to the overhead of Peasant 0001 <gen> using Effect
As you see I use the same system, but I will explain the new actions for you anyway.
Here I simply store a string variable into nothing, this means if the player aint the player I want it to be there wont be any effect. (you will see later).
Set Effect = <Empty String>
Here We check if the player is player red (1) and then we set the string variable to the question mark effect path.
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
Player Equal to Player 1 (Red)
Then - Actions
Set Effect = Abilities\Spells\Other\TalkToMe\TalkToMe.mdl
Else - Actions
And after that we create the effect simple as that.
Special Effect - Create a special effect attached to the overhead of Peasant 0001 <gen> using Effect
DesyncronizationDesyncronization only exist in multiplayer due you need both a host and a client to make this happen, it causes clients playing the map do disconnect from the game.
Thats why you must keep this in mind, ifpossible do only use the GetLocalPlayer in conditions.
So if it does desync don't use it, if it does not desync you can just enjoy the game.
NOTICE! Handles that have their own stack will never desync!
1. Fade filters for 1 player only
Question - this cause desyncronization?
Answer - No
2. Quest for 1 player only?
Question - this cause desyncronization?
Answer - Yes but if u use Enable/Disable quest then No
3. Special effects, visibile for 1 player only?
Question - this cause desyncronization?
Answer - No
4. Special effects attachment to unit, visibile for 1 player only?
Question - this cause desyncronization?
Answer - No
6. Unit visibility, color, visibile for 1 player only?
Question - this cause desyncronization?
Answer - Yes but Vertex color dont desync
7. Fog of war and black mask, color, visibile for 1 player only?
Question - this cause desyncronization?
Answer - Yes
8. Images, visibile for 1 player only?
Question - this cause desyncronization?
Answer - No
9. Sound & music, for 1 player only?
Question - this cause desyncronization?
Answer - Mostly No
10. Show Multiboard, for 1 player only?
Question - this cause desyncronization?
Answer - No
11. Trackables, for 1-2 player only?
Question - this cause desyncronization?
Answer - No
12. Pause the game, for 1 player only?
Question - this cause desyncronization?
Answer - Yes
13. Create different unit for player?
Question - this cause desyncronization?
Answer - Yes
Note - It might not desync if (1) it is a non hero unit and (2) the two units have only differences in art fields/physical display (such as model or icon) - by PurgeandFire111
14. Weather effect off for 1 player?
Question - this cause desyncronization?
Answer - No?
15. Desctructible visibility, for 1 player only?
Question - this cause desyncronization?
Answer - ?
Creditsshadowvzs - The list of what does desync and not
Hashjie - Telling me info about GetLocalPlayer and the idea to this tutorial
Troll-Brain - awesome tip to improve the tutorial