• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Objects only a certain player can see

Status
Not open for further replies.
Level 8
Joined
Aug 2, 2006
Messages
346
Hi, is there any way to make a unit only visible to a certain player?

I figured one way would be to make the unit invisible, so only the player that owns it could see it, but that also makes it so the player can see through it. (I need it to be 100% opaque to a certain player, and 0% opaque to all others.)
 
Level 12
Joined
Mar 16, 2006
Messages
992
Hi, is there any way to make a unit only visible to a certain player?

I figured one way would be to make the unit invisible, so only the player that owns it could see it, but that also makes it so the player can see through it. (I need it to be 100% opaque to a certain player, and 0% opaque to all others.)

I'd like to know if this were possible. And then if this was crash free.
 
Level 4
Joined
Dec 16, 2007
Messages
134
Hi, is there any way to make a unit only visible to a certain player?

I figured one way would be to make the unit invisible, so only the player that owns it could see it, but that also makes it so the player can see through it. (I need it to be 100% opaque to a certain player, and 0% opaque to all others.)

Try making the unit invisible and then create a hidden tower or very very small tower that no one can see and then place Magic Sentry then set the range of Magic sentry into 9999999999999999999999...

[noinipOyMgniviGtsuJ]
 
Level 12
Joined
Mar 16, 2006
Messages
992
Try making the unit invisible and then create a hidden tower or very very small tower that no one can see and then place Magic Sentry then set the range of Magic sentry into 9999999999999999999999...

[noinipOyMgniviGtsuJ]

Depending on how many computers you're using, this is possible. But it would be limited by the amount of players using the invisible thing, and the truesight thing.

Basically, you'd temporarily share vision with neutral victim or extra, and have a truesight unit in the map for that neutral, with infinite sight range. Then remove shared vision when done.

The only downside of this would be that, if you have any other detection, or invisible things, it will not work as well.
 
Level 11
Joined
Aug 25, 2006
Messages
971
As far as I know this is easily possible.

JASS:
function HideUnitForPlayers takes force r, unit g returns nothing
local integer s = 0
    if IsPlayerInForce(GetLocalPlayer(),r) then
        set s = 0
    else
        set s = 255
    endif
    call SetUnitVertexColor(g,255,255,255,s)
endfunction

This uses the minimal (and shortest) local operations. I might have reversed the 255 and zero though. (Meaning unit will be visible when supposed to hidden and hidden when supposed to be visible.)

Try it out, it should work.
 
Last edited:
Level 12
Joined
Mar 16, 2006
Messages
992
As far as I know this is easily possible.

JASS:
function HideUnitForPlayers takes force r, unit g, returns nothing
local integer s = 0
    if IsPlayerInForce(GetLocalPlayer(),r) then
        set s = 0
    else
        set s = 255
    endif
    call SetUnitVertexColor(g,255,255,255,s)
endfunction

This uses the minimal (and shortest) local operations. I might have reversed the 255 and zero though. (Meaning unit will be visible when supposed to hidden and hidden when supposed to be visible.)

Try it out, it should work.

You did reverse the 255 and zero. 0 = no color. 255 = full color.

I'm 98% sure that this will desync the game, wd40bomber7.

And it will desync the game and ruin multiplay. =(
 
Level 8
Joined
Aug 2, 2006
Messages
346
When a unit is invisible, they are compeltely invisible to all other players, but visible to the owner, but it's transparent. Is there any way to change the semi transparency value?

I'm trying to make a side scroller map (kind of like that soldiers map) but I'm trying to get a sky background into the map, and I plan on having a plane with a sky texture on it, and I'll set the position to something to do with the player's camera, but it would look a bit odd to see another players sky floating around.
 
Level 12
Joined
Mar 16, 2006
Messages
992
When a unit is invisible, they are compeltely invisible to all other players, but visible to the owner, but it's transparent. Is there any way to change the semi transparency value?

I'm trying to make a side scroller map (kind of like that soldiers map) but I'm trying to get a sky background into the map, and I plan on having a plane with a sky texture on it, and I'll set the position to something to do with the player's camera, but it would look a bit odd to see another players sky floating around.

God. You just made me want to make a Metal Slug map. Hahaha
 
Level 11
Joined
Aug 25, 2006
Messages
971
This won't desynch. Why? Because it has no effect on game-play. Enemies can still see & shoot at the unit. It only effects alpha of a unit. (Meaning it still reacts the same both ways) Because I perform the same amount of operations for all players, theres no chance that will desychn either.

I'll test it within 2 hours.
 
Level 12
Joined
Mar 16, 2006
Messages
992
This won't desynch. Why? Because it has no effect on game-play. Enemies can still see & shoot at the unit. It only effects alpha of a unit. (Meaning it still reacts the same both ways) Because I perform the same amount of operations for all players, theres no chance that will desychn either.

I'll test it within 2 hours.

If it doesn't desync, the only thing I'd say is it's still selectable, has a HP bar, and can be attacked.

So how are you gonna test it with multiplay?
 
Level 11
Joined
Aug 25, 2006
Messages
971
Hehe, I have two computers in my house. I figure 50 units will be a good test case.

I was correct, it showed no ill effects gamewise. However I did find an extra comma which prevented compilation of the code. (Fixed it) Test map attached. vJass required.
 

Attachments

  • Air.w3x
    16.6 KB · Views: 58
Level 11
Joined
Aug 25, 2006
Messages
971
Don't make me laugh. vJASS compiles into normal jass for playing. The only reason you need a vJASS compiler is if you want to open/modify the map. And the function itself doesn't need vJass, just the test code.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,259
That snippet will not cause a desync unless you use an opperation to get unit alpha because it will only affect the appearence of the unit (the mechanics of the unit and targitability will still exist). Basically it works like displaying a local multiboard or other such opperations (texttags, special effects, lightning effects, ubersplats).
 
Level 11
Joined
Aug 25, 2006
Messages
971
vJass adds things to JASS that ordinarily would take many lines of code to do. Then when you click the save button it compiles what you did for you. It allows you to use structs and other things. (which are actually just a trick of arrays)

Like the reason the test requires vJass was because I used the globals/endglobals syntax. Normally you can only put that one place, the head of the war3map.j file. However vJass automatically moves your globals into that location when you press save. (Other-wise you wouldn't be able to modify that section of the .j file)
 
Status
Not open for further replies.
Top