• 🏆 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!

[JASS] Locally hiding units

Status
Not open for further replies.
Level 19
Joined
Oct 12, 2007
Messages
1,821
Hey there.
I had a small question about the GetLocalPlayer function.
I want to make a certain unit invisible for Player(X) and I want an other unit to be invisible for unit 1 withoud using permanent invisibility spell ofc.

How should I do this?

if Player(X) == GetLocalPlayer() then
hide unit1
endif
if the other player == GetLocalPlayer() then
hide unit2
endif

like that?.. I seriously dont know lol
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Well it should be possible.
At Oakwood we hide destructibles for everyone but one player. So this should work for units as well. Though I don't know enough about localplayer to try it out because I heard it's pretty risky if you have Multiplaye rmaps.
 
Level 19
Joined
Aug 16, 2007
Messages
881
I'm asking the same question as Teuncreemers, is this possible? I've got this trigger

  • Test123
  • Events
    • Time - Elapsed game time is 1.00 seconds
  • Conditions
  • Actions
    • For each (Integer i) from 1 to 12, do (Actions)
      • Loop - Actions
        • Set p = (Player(i))
        • Unit - Create 1 Footman for p at (Center of (Playable map area)) facing 90.00 degrees
        • Unit - Hide (Last created unit)
        • Custom script: if udg_p == GetLocalPlayer() then
        • Unit - Unhide (Last created unit)
        • Custom script: endif
but I don't really know if it would work.
 
Level 4
Joined
May 17, 2005
Messages
94
Playing with the boolean alone won't cause a desync, but unsynchronized effects due to actually using the boolean sure can.

Since the ShowUnit function can directly have enormous effects on gameplay, I would be VERY surprised if it were possible to do something like that and make it work without desync.


Any attempt at locally hiding a unit will have to do so without altering game function between the two computers. For example, if all you cared about was unit model visibility, you could change the unit's transparency between the two machines; this only alters the artistic output of how the unit looks on the screen, and so is OK.

Creation of handles in general is also bad even if it doesn't directly affect gameplay, since the handle stack gets toyed with.


But yeah, any time the two machines actually process a situation differently (ie if one thinks a unit is hidden and the other doesn't), the output of the two machines will differ and a desync will occur.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Hiding a unit causes significant changes to a unit's data; for example a hidden unit cannot be attacked. As soon as someone issues an order to attack your "unhidden" unit the game will desync. Other unit interactions would also cause a desync.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Exactly, the only way to "hide" the unit would be changing transparency to 100% (Unit - Set vertex coloring, tested and works) or using standard invisibility.

Too bad that will still reveal his health bar above his head and that's just the thing you dont want your unit to have when he's... well.. hiding:p
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
You could try to use wind-walk or some other type of ability that affects the shadow to eliminate it. I think I got it to work with wind-walk and a 0 fade-time, but I do not remember.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
The thing I needed this for is basically:
Unit talks with an other unit (order = attack).
Then the cinematic mode starts for that player and he is getting a conversation with the unit. While that cinematic mode is active the unit is still able to get attacked so I wanted to make him invisible but visible for the player viewing the cinematic.
Might be very risky but I don't think there will be any orders made by or against the unit while playing this cinematic. The unit will just stand there while being paused.

Something like windwalk or permanent invisibility won't work because some units have invisibility detection in the map.
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Well if you set the unit to invulnerable then you would probably be able to hide it locally.

JASS:
call SetUnitInvulnerable( <unit>, true )
call ShowUnit( <unit>, false )

I would test it right now but I do not have any friends online BNet right now :p
 
Level 8
Joined
Mar 3, 2009
Messages
327
Im just thinking... has anyone played the map phase killer?
There has to be massive usage of GetLocalPlayer() in that, because everything looks different when you go into the aetherworld or whatever, especially the phase killer... i wish i knew how they did that :p

anyway, im pretty sure when something warps to the aetherworld it can only be seen by other units in the aetherworld...

i might have the names mixed up, I havn't played for ages.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
And invulnerability and hiding propably won't work, for example it would desync if someone selects that unit (invulnerable can be selected, hidden can't)

But how can someone select a unit that is hidden? You can't do that by yourself. You can only try to do that with a trigger. I dont have triggers that manipulate selection so in that case it wouldnt be a problem would it?
Because well the unit is hidden (invisible) so no player will ever try to select him.
 
Level 12
Joined
Apr 15, 2008
Messages
1,063
I am not sure, but I think that hidden unit cannot be selected at all. That means when the computer, that has the unit hidden, receives information that someone has selected such unit (because for him it is not hidden -> it is selectable), it will cause a problem.

Additionally, invulnerable unit can be "followed", while hidden can't.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Yes I understand that it will desync if the player that is able to see the unit will try to select. The thing is: when I want to use this 'function', to make a unit invisible for all players except for the owner of the unit, the unit WONT be selectable because the only player able to see him is watching someting with the cinematic camera + transmissions. In that case the only thing, from what I think, that can desync is when I let the hidden unit to a transmission. Instead I could let the unit type of the hidden unit do a transmission to not let it get 'selected' by the camera. Because transmissions done by excisting units will cause a little circle to appear around the unit for 1sec when it starts it's speech.
So it's risky but I got the feeling it won't desync for the situation I need this in.

I think the only way to solve this is to just try it out^^
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
You could try to locally create a unit and give the unit the Locust ability so it is impervious to in-game control. This may prevent the game from desync but it would allow you to have a unit for only one player.

JASS:
local integer id=0
local unit u
if(GetLocalPlayer()==yourPlayer) then
    set id='h000'
endif
set u=CreateUnit(yourPlayer, id, x, y, facing)
call UnitRemoveAbility(u, 'Amov')
call UnitRemoveAbility(u, 'Aatk')
call UnitAddAbility(u, 'Aloc')

This may cause a desync immediately, but it may not if there is no user intervention. Try it out.
 
Status
Not open for further replies.
Top