• 🏆 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] Invisibility Question

Status
Not open for further replies.
Level 19
Joined
Oct 12, 2007
Messages
1,821
Hey there,

I've got a question about invisible units.

What I actually want is a unit that's only visible for the owning player, but he shouldn't be transparant like he is when I give him Permanent Invisibility.

Is this possible?

The unit is supposed to also have Locust. Don't know if that matters, but is it possible to make him invisible for all players except for his owner withoud making him transparant?

Thanks for your time.

Teuncreemers
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
yes from what i know
make player 1 treat player 2 as an ally "without" shared vision

No that won't work.

I explain a bit better.

Player 1 and Player 2 are both watching (per example) the same rect. Player 1 has to see one unit and Player 2 shouldnt be able to see the unit. However the unit shouldnt be transparant for player 1 (so permanent invisibility shouldnt be added to the unit)
 
Level 12
Joined
Mar 23, 2008
Messages
942
No that won't work.

I explain a bit better.

Player 1 and Player 2 are both watching (per example) the same rect. Player 1 has to see one unit and Player 2 shouldnt be able to see the unit. However the unit shouldnt be transparant for player 1 (so permanent invisibility shouldnt be added to the unit)

Locust + Set unit transparency to 100% for the other players.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Locust + Set unit transparency to 100% for the other players.

How to set a unit's transparency for players?

JASS:
call SetUnitVertexColor(u, 255, 255, 255, 100)

This makes the unit invisible for all players right?
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
Use GetLocalPlayer()
Like this:
JASS:
if GetLocalPlayer() != owner then
    call SetUnitVertexColor(u, 255, 255, 255, 100)
    call UnitAddAbility(u, 'Aloc')
endif
owner is the owner of the unit and u is the unit. I think 'Aloc' is locust.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
Use GetLocalPlayer()
Like this:
JASS:
if GetLocalPlayer() != owner then
    call SetUnitVertexColor(u, 255, 255, 255, 100)
    call UnitAddAbility(u, 'Aloc')
endif
owner is the owner of the unit and u is the unit. I think 'Aloc' is locust.

Thanks alot.

So just to check. Every function that automatically applies things to All players (like per example creating quests or in this case making a unit invisible for all players) can be applied to only one player by using GetLocalPlayer()?

Do I need a special Event for using GetLocalPlayer() ?
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
1. Yes, by using GetLocalPlayer() you can do things to certain players, but be careful with it because it can cause desyncs if you create a handle within the if.
2. No, you don't need a special event for GetLocalPlayer(). You can use it wherever you want.
 
Level 7
Joined
Jul 20, 2008
Messages
377
Use GetLocalPlayer()
Like this:
JASS:
if GetLocalPlayer() != owner then
    call SetUnitVertexColor(u, 255, 255, 255, 100)
    call UnitAddAbility(u, 'Aloc')
endif
owner is the owner of the unit and u is the unit. I think 'Aloc' is locust.

I don't think you should add an ability locally, though. That probably would cause desync.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
I don't think you should add an ability locally, though. That probably would cause desync.

The unit that should be affected by this invisiblity trigger has Locust already.
So I don't have to add it to him in a trigger.


JASS:
if GetLocalPlayer() != owner then
    call SetUnitVertexColor(u, 255, 255, 255, 100)
endif
Is this tricky for desyncs? Just this, nothing more.
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
The unit that should be affected by this invisiblity trigger has Locust already.
So I don't have to add it to him in a trigger.


JASS:
if GetLocalPlayer() != owner then
    call SetUnitVertexColor(u, 255, 255, 255, 100)
endif
Is this tricky for desyncs? Just this, nothing more.

That shouldn't create desyncs. If you need to add an ability you could do it like this:
JASS:
local integer i = 'Aloc'
if GetLocalPlayer() == owner then
    set i = 0
endif
call UnitAddAbility(u, i)
if GetLocalPlayer() != owner then
    call SetUnitVertexColor(u, 255, 255, 255, 100)
endif
That one should work
 
Level 12
Joined
Mar 23, 2008
Messages
942
That shouldn't create desyncs. If you need to add an ability you could do it like this:
JASS:
local integer i = 'Aloc'
if GetLocalPlayer() == owner then
    set i = 0
endif
call UnitAddAbility(u, i)
if GetLocalPlayer() != owner then
    call SetUnitVertexColor(u, 255, 255, 255, 100)
endif
That one should work

Lol, and things like units attacking locust users? o.o
or if the unit uses the ability?
 
Level 6
Joined
Sep 5, 2007
Messages
264
And locust locally is a VERY bad idea...
All the other players wouldn't be able to see the unit, but they would auto attack it, which would desync the owner as soon as damage is deal to it (due to owner and everyone else having different health for the unit).
Add locust in the object editor.

Adding any abilities locally is probably bad... if it's an aura, then as soon as the aura effects anything (including the unit), desync... anything else, then when the unit uses it, desync...

The transparency will, however, not cause any issues when altered locally, as it is only how the unit is displayed... :thumbs_up:
 
Level 8
Joined
Aug 6, 2008
Messages
451
Adding an ability locally will deffinetly desync. Is somethign affects gameplay, you cant do it locally.

Changing vertex color locally is perfectly safe.

JASS:
if GetLocalPlayer()!=p then    
    call SetUnitVertexColor(u,255,255,255,100)
endif
 
Level 22
Joined
Dec 31, 2006
Messages
2,216
Viikuna said:
Adding an ability locally will deffinetly desync. Is somethign affects gameplay, you cant do it locally.

Changing vertex color locally is perfectly safe.

JASS:
if GetLocalPlayer()!=p then    
    call SetUnitVertexColor(u,255,255,255,100)
endif

I didn't add the ability locally in the new script. I added it for all players, but the owner didn't get the right ability (the same method is used when creating special effects for specific players).
Saishy said:
Lol, and things like units attacking locust users? o.o
How can they attack units with locust? If you use call IssueTargetOrder(SOME_UNIT, "attack", LOCUST_UNIT) it will return false because it cannot be done.
EDIT: It will return false for everyone except the owner. Maybe that can cause desync...
EDIT2: You could use a trigger to detect when the invisible unit is being targeted and immediately cause the targeting unit to stop which will prevent a desync.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
I didn't add the ability locally in the new script. I added it for all players, but the owner didn't get the right ability (the same method is used when creating special effects for specific players).
How can they attack units with locust? If you use call IssueTargetOrder(SOME_UNIT, "attack", LOCUST_UNIT) it will return false because it cannot be done.
EDIT: It will return false for everyone except the owner. Maybe that can cause desync...
EDIT2: You could use a trigger to detect when the invisible unit is being targeted and immediately cause the targeting unit to stop which will prevent a desync.

Well the unit that should be invisible can't be attacked anyway. It's a model that's used for a hero selection system as a preview of the hero he's gonna get. So the player only see's the model doing certain animations, but the model will never get in real combat or even move.

However I got the info I wanted now:D thanks alot,
+repped.
 
Level 8
Joined
Aug 6, 2008
Messages
451
I didn't add the ability locally in the new script. I added it for all players, but the owner didn't get the right ability (the same method is used when creating special effects for specific players).

You are missing my point. Having a different abilities for different players affects the gameplay so it will desync. It wont work.

For special effects you need to create them for all players, because all players need to have same handles etc. Special effects model path can be different for different players, because what model file special effect uses, doesnt affect gameplay in any way. That is why you can have "local" special effects.

edit. Then again you can actually create texttags locally because their handle id is less than 0x100000
With special effects that is, however, not the case.
 
Level 11
Joined
Apr 6, 2008
Messages
760
what about GetLocalPlayer() in loops

like

JASS:
local integer i = 0

loop
    exitwhen i >= 9
    if GetLocalPlayer() == Player(i) and Player(i) != OwnerOfUnit then
        call SetUnitVertexColor(u,255,255,255,255)
    endif
    set i = i + 1
endloop

will this work?
 
Last edited:
Level 22
Joined
Dec 31, 2006
Messages
2,216
what about GetLocalPlayer() in loops

like

JASS:
local integer i = 0

loop
    exitwhen i >= 9
    if GetLocalPlayer() == Player(i) and Player(i) != OwnerOfUnit then
        call SetUnitVertexColor(u,255,255,255,255)
    endif
    set i = i + 1
endloop

will this work?
It should work, but I don't understand why you would do it that way though.
 
Level 6
Joined
Sep 5, 2007
Messages
264
JASS:
local integer index = 0
local player player_local = GetLocalPlayer()
local player player_check

loop
    exitwhen (index > 11)
    set player_check = Player(index)

    if (player_check == player_local) then
        if (IsUnitAlly(unit, player_check)) then
            call SetUnitVertexColor(u,255,255,255,255)
        else
            call SetUnitVertexColor(u,255,255,255,0)
        endif
    endif

    set player_check = null
    set index = index + 1
endloop

set player_local = null

How's this? The only problem I can see is that enemy units will "walk around" this unit, even though they can't see it... Also, do health bars show up for units that are completely transparent, if so, then the enemy just has to hold ALT to know where this guy is.
 
Level 19
Joined
Oct 12, 2007
Messages
1,821
JASS:
local integer index = 0
local player player_local = GetLocalPlayer()
local player player_check

loop
    exitwhen (index > 11)
    set player_check = Player(index)

    if (player_check == player_local) then
        if (IsUnitAlly(unit, player_check)) then
            call SetUnitVertexColor(u,255,255,255,255)
        else
            call SetUnitVertexColor(u,255,255,255,0)
        endif
    endif

    set player_check = null
    set index = index + 1
endloop

set player_local = null

How's this? The only problem I can see is that enemy units will "walk around" this unit, even though they can't see it... Also, do health bars show up for units that are completely transparent, if so, then the enemy just has to hold ALT to know where this guy is.

Thanks for the work but I already got what I wanted hehe.
You see this was needed for a selection system where you see a little preview version of your hero. So nobody will ever walk near the hero.

Ciebron made the selection system and he told me it worked, so I think it's done:D

No need for more work, thank you all.
 
Status
Not open for further replies.
Top