• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

GetLocalPlayer() faq

Status
Not open for further replies.
Level 28
Joined
Jan 26, 2007
Messages
4,789
The problem is that the trigger will fire locally, maybe it already desync by itself.
Yeah, that was what I was thinking too. I'm not really sure because nothing actually happens, aside from the event that fired.
If that in itself does cause a desync, then you must make absolutely sure they don't enter any region that fires either of those events.
Yep, but it must be mentionned in the FAQ.
I completely agree.
Wrong, i'm sure that GroupEnumUnitInRect enum locust units, but yes inRange don't enum them.
I just checked this (both InRect and InRectCounted), but the locusts didn't register for me.
Maybe I'm missing something here, could you double-check yourself?
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Hmm, maybe my memory is lying, or the behavior has changed since some patch.
I was pretty sure that there was somewhere some snippet which used GroupEnumInRect in order to enum every "units in range", locust unit included.

And no i can't test, i just don't have wc3 installed anymore since a while.
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Last edited:
Level 17
Joined
Nov 13, 2006
Messages
1,814
I just checked this (both InRect and InRectCounted), but the locusts didn't register for me.
Maybe I'm missing something here, could you double-check yourself?

i heard that too on another forum, i mean locust unit cant be picked unit

Yep, but it must be mentionned in the FAQ.
it was

do u know if getting the camera target and source locally desyncs? i think it does

what do u mean? if it is about store something to variable locally that doesnt desync until u dont refer to it (ok depend on action) but anyway have arrays for that and dont need local things, no?
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
do u know if getting the camera target and source locally desyncs? i think it does

A camera position is something already local by nature, even if you use the same camera for each player, each player can still have different values.
So no getting in a local block does not desync by itself, but you just don't need to use a local block.

Now, ofc you can't create an unit using these values for example, unless you sync the data.

About the GroupEnumInRect with locust unit, and enter/leave region event, someone should really share a test code, instead of just guessing.
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
About the GroupEnumInRect with locust unit, and enter/leave region event, someone should really share a test code, instead of just guessing.
  • Melee Initialization
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Unit - Create 1 Footman for Player 1 (Red) at (Random point in Region 000 <gen>) facing Default building facing degrees
      • Custom script: call UnitAddAbilityBJ( 'Aloc', GetLastCreatedUnit() )
this result: dont show the unit name with locust - so dont detect in unti group
  • group
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Unit Group - Pick every unit in (Units in Region 000 <gen>) and do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (Name of (Picked unit))

result: game detect if a locust unit leave the region
  • group2
    • Events
      • Unit - A unit leaves Region 000 <gen>
    • Conditions
    • Actions
      • Game - Display to (All players) the text: (Name of (Triggering unit))
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
Well i meant jass, because it's easy to copy/paste and test it, but ok i suppose that 2 testers is enough.
Now as said, since it trigger the region events, it could still be a problem.

I'm sorry troll-brain I didn't know this, you where right all along.
I can also confirm what shadowvzs tested is true.
 
Last edited:
Level 4
Joined
Jan 7, 2011
Messages
72
I know from reading this FAQ that it is possible to hide destrucibles from a specific player without causing desyncs. However, the example trigger of how to do this (at the start of this thread) is limited to just one player (Red) as well as just one destructible (Summer Tree Wall).

Is there a concise way of hiding multiple destructibles from ANY player whenever they execute the same triggering event? (e.g. one of their units enters a specific region)

I can already use the GUI to hide multiple destructibles of a specific type (e.g. all "tables") that are located in a specific region. Is it possible to integrate this with a GetLocalPlayer() trigger?
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
I know from reading this FAQ that it is possible to hide destrucibles from a specific player without causing desyncs. However, the example trigger of how to do this (at the start of this thread) is limited to just one player (Red) as well as just one destructible (Summer Tree Wall).

Is there a concise way of hiding multiple destructibles from ANY player whenever they execute the same triggering event? (e.g. one of their units enters a specific region)

I can already use the GUI to hide multiple destructibles of a specific type (e.g. all "tables") that are located in a specific region. Is it possible to integrate this with a GetLocalPlayer() trigger?

i dont understand your question. its not limited to one player or one destructable type or one destructable at all
 
Level 17
Joined
Nov 13, 2006
Messages
1,814
I know from reading this FAQ that it is possible to hide destrucibles from a specific player without causing desyncs. However, the example trigger of how to do this (at the start of this thread) is limited to just one player (Red) as well as just one destructible (Summer Tree Wall).

Is there a concise way of hiding multiple destructibles from ANY player whenever they execute the same triggering event? (e.g. one of their units enters a specific region)

I can already use the GUI to hide multiple destructibles of a specific type (e.g. all "tables") that are located in a specific region. Is it possible to integrate this with a GetLocalPlayer() trigger?

if u checked my full screen inventory in signature then u can see u can hide/show a whole fullscreen inventory interface easily also not limited to 1 player, u can use player is in playergroup or just boolean array where is the index the player number (like if boolean_var[Player number of GetLocalPlayer()] == true then , ofc dont need that == true but i guess this way u can understand this work for every player where the variable is true)

so dont really have limitation how much desctructable want hide or show or to what /how many player
 
Level 4
Joined
Jan 7, 2011
Messages
72
i dont understand your question. its not limited to one player or one destructable type or one destructable at all

I know that, in theory, GetLocalPlayer() triggers aren't limited to one player or one destructible. But the example trigger that Shadowvzs included in his original post has some limitations in practice. For example, it only triggers when Player 1 types a specific message and it only hides Summer Tree Wall destructibles.

So my question is this: how can I use GetLocalPlayer() in a trigger to hide all destructibles of a certain type (e.g. "walls") in a certain region (e.g. "region 1") whenever a unit controlled by any player enters that region.
 
Level 4
Joined
Jan 7, 2011
Messages
72
if u checked my full screen inventory in signature then u can see u can hide/show a whole fullscreen inventory interface easily also not limited to 1 player, u can use player is in playergroup or just boolean array where is the index the player number (like if boolean_var[Player number of GetLocalPlayer()] == true then , ofc dont need that == true but i guess this way u can understand this work for every player where the variable is true)

I've downloaded your advanced inventory system, but it is very high level stuff that goes straight over my noob head!
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
[...] the example trigger that Shadowvzs included in his original post has some limitations in practice. For example, it only triggers when Player 1 types a specific message and it only hides Summer Tree Wall destructibles.
You're wrong: the trigger Shadow gave us can be used for any player, for any destructible type, even in its current state.
The only thing you need to do is change the variable "Player" (the player for whom the destructible is visible) and the variable "Tree" (the destructible that gets (in)visible).
I must add that "Tree" is a bad variable name, because it also works on walls and gates and rocks and so on.
 
Level 4
Joined
Jan 7, 2011
Messages
72
You're wrong: the trigger Shadow gave us can be used for any player, for any destructible type, even in its current state.
The only thing you need to do is change the variable "Player" (the player for whom the destructible is visible) and the variable "Tree" (the destructible that gets (in)visible).
I must add that "Tree" is a bad variable name, because it also works on walls and gates and rocks and so on.

OK, so if I want that trigger to do what I explained in my earlier post, then I would:

1. Add additional events (one for each player whose units are capable of triggering the hidden destructables when they enter a specific region); and

2. Change the "tree" variable to the specific destructible type (e.g. "brick wall") that I want to hide.

Will that hide all of the specified destructables from the triggering player whenever any of the units that they control enter the specified region?

Also, Shadowvzs specifies "Summer Tree Wall 0000" in his trigger. Does that hide ALL summer tree walls? Or just number 0000?

Is there any way of limiting the destructables that are hidden to a specific region?

Finally, Shadowvzs' trigger includes the ShowDestructable function. If I want to hide destructables, do I use HideDestructable? Or do I use the ShowDestructable function and change the Boolean variable to false for the player who I want to hide the destructables from?

Sorry for all the questions - I really do appreciate the help!
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
OK, so if I want that trigger to do what I explained in my earlier post, then I would:

1. Add additional events (one for each player whose units are capable of triggering the hidden destructables when they enter a specific region); and

2. Change the "tree" variable to the specific destructible type (e.g. "brick wall") that I want to hide.

Will that hide all of the specified destructables from the triggering player whenever any of the units that they control enter the specified region?

Also, Shadowvzs specifies "Summer Tree Wall 0000" in his trigger. Does that hide ALL summer tree walls? Or just number 0000?

Is there any way of limiting the destructables that are hidden to a specific region?

Finally, Shadowvzs' trigger includes the ShowDestructable function. If I want to hide destructables, do I use HideDestructable? Or do I use the ShowDestructable function and change the Boolean variable to false for the player who I want to hide the destructables from?

Sorry for all the questions - I really do appreciate the help!
Indeed: add events and change the "Tree"-variable.
The only destructible that gets hidden is the one you specify, not all destructibles of that type (in the shown trigger: only Tree 0000, not all trees).

There's no such thing as "HideDestructable": it would be a useless function because it already exists (ShowDestructable( d, false ) ).

You can hide all destructibles in a region by doing this:
  • Hide Destructables
    • Events
      • Player - Player 1 (Red) types a chat message containing -hide as An exact match
      • Player - Player 2 (Blue) types a chat message containing -hide as An exact match
    • Conditions
    • Actions
      • Set TempBool = False
      • Custom script: if GetLocalPlayer() == GetTriggerPlayer() then
      • Set TempBool = True
      • Custom script: endif
      • Destructible - Pick every destructible in Hide Region <gen> and do (Actions)
        • Loop - Actions
          • Custom script: call ShowDestructable( GetEnumDestructable(), udg_TempBool )
Only the triggering player will be able to see the destructibles in region "Hide Region" after typing "-hide".
You can filter destructible-types by using an If-Then-Else (ITE).
 
Last edited:
Level 4
Joined
Jan 7, 2011
Messages
72
Thank you so much ap0calypse! I am pretty sure I can figure out the ITE bit myself, but I'll shout if I get stuck.
 
Level 4
Joined
Jan 7, 2011
Messages
72
One more question (hopefully!): is there a JASS function for getting the owner of a triggering unit?

I want my trigger actions to be when a unit enters a region, not when a player types something in chat. Then I want to hide destructables in a region from the player who owns that unit.
 
Level 4
Joined
Jan 7, 2011
Messages
72
Thank you so much, edo! That works perfectly!

To everyone who has helped me in this thread: THANK YOU for helping me create a fully working multi-storey building system!
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
I know it is a pretty old thread, but I have to make a point here.
7. Fog of war and black mask, color, visibile for 1 player only?
It does desync.
JASS:
    public method setVision takes rect r returns nothing
        // old version (desync):
        if GetLocalPlayer() == .ref then
            call FogEnable(true)
        endif
      
        // new version:
        call FogModifierStop(.globalFog)
      
        // both versions:
        set .fog = CreateFogModifierRect(.ref, FOG_OF_WAR_VISIBLE, r, false, false)
        call FogModifierStart(.fog)
    endmethod
I used this script with the FogEnable() and it caused desyncs between the players that had it enabled and the players that had it disabled.
After changing it to a global fogmodifier, it didnt desync any more.
 

Dr Super Good

Spell Reviewer
Level 63
Joined
Jan 18, 2005
Messages
27,188
There is an option to hide the destructible, but not the item. So disappointing.
Even hiding destructables can cause the game to go out of sync. The reason it does not for most RPGs is that the destructables are not interacted with.

I used this script with the FogEnable() and it caused desyncs between the players that had it enabled and the players that had it disabled.
After changing it to a global fogmodifier, it didnt desync any more.
That is because fog of war has major mechanical implications. If you disable it for all players only on 1 client then combat and interactions may occur on that client that do not on the other clients with it is still enabled. The result is that client goes out of sync from the rest of the clients.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
uh yeah its certainly possible, I did it in FoE RPG, but I'm not digging up the code for that.
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
How to make item visible for only player? I have tried at least 2 ways, but it steel causes desync.

You could create 2 item types that only differ in model (one being invalid/invisible). The player should not be able to make an effective input without the bounding box. Of course you have to pay attention that the item type id does not cause diversity.
 
Level 19
Joined
Dec 12, 2010
Messages
2,069
you can fake or change any local data, whatever you want, just make sure it won't affect game flow for players.
like you can replace a unit with hero for a single player, but you have to make sure there's no hardcoded exp rewards, hero won't gain any kind of stat bonuses and so on.
 
Status
Not open for further replies.
Top