HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Non-transparency invisibility

03-04-2009, 08:10 PM#1
Weyrling
I need a way to make a unit invisible without the automatic transparency tinting, as it needs to have a different transparency value.

Alternatively, I need a way to make a unit's tinting transparency different when viewed by different players.

This is for a graphical effect for individual players I'm trying to create, and if other players can see the effect then it messes up gameplay.
I cannot seem to figure this out, I would really appreciate some help.
03-04-2009, 09:15 PM#2
xombie
Collapse JASS:
if GetLocalPlayer() == somePlayer then
    call SetUnitVertexColor(someHero[GetPlayerId(somePlayer)], 255, 255, 255, customAlphaForPlayer)
endif

This will set the someHero (in this case it would be an array for every player) vertex coloring (the last one is alpha) to something different for somePlayer as all the others. Play with it a little bit to see if you can achieve your effect.
03-05-2009, 12:58 AM#3
Weyrling
Code:
function Test takes unit u, player p returns nothing
    local integer i = 0
    loop
        exitwhen i > 12
        if GetLocalPlayer() == p then
            call SetUnitVertexColor(u,0,0,255,100)
        else
            call SetUnitVertexColor(u,0,0,0,50)
        endif
        set i = i+1
    endloop
endfunction
This does not seem to work at all, tint does not change in any way regardless of which player I send to this function.
03-05-2009, 01:06 AM#4
Blackroot
Quote:
Originally Posted by Weyrling
Code:
function Test takes unit u, player p returns nothing
    local integer i = 0
    loop
        exitwhen i > 12
        if GetLocalPlayer() == p then
            call SetUnitVertexColor(u,0,0,255,100)
        else
            call SetUnitVertexColor(u,0,0,0,50)
        endif
        set i = i+1
    endloop
endfunction
This does not seem to work at all, tint does not change in any way regardless of which player I send to this function.

This should work; what parameters are you passing to test?
03-05-2009, 01:24 AM#5
Weyrling
Event: Cast a spell
Code:
call Test(GetTriggerUnit(),GetOwningPlayer(GetTriggerUnit())
Edits: Restart WE ftw.
03-05-2009, 02:04 AM#6
Fledermaus
Why are you using a loop btw?
03-05-2009, 02:25 AM#7
xombie
Collapse JASS:
function Test takes unit u, player p returns nothing
    local integer i = 0
    loop
        exitwhen i > 12
        if GetLocalPlayer() == p then
            call SetUnitVertexColor(u,0,0,255,100)
        else
            call SetUnitVertexColor(u,0,0,0,50)
        endif
        set i = i+1
    endloop
endfunction

You're looping through players 1 (red) to 13 (neutral), first of all. Second of all, I don't think you quite understand how GetLocalPlayer( ) works. It might be easier to help you out if you tell me what the context is in which you would like to lower the unit's alpha.
03-05-2009, 02:36 AM#8
Weyrling
Quote:
Originally Posted by xombie
Collapse JASS:
function Test takes unit u, player p returns nothing
    local integer i = 0
    loop
        exitwhen i > 12
        if GetLocalPlayer() == p then
            call SetUnitVertexColor(u,0,0,255,100)
        else
            call SetUnitVertexColor(u,0,0,0,50)
        endif
        set i = i+1
    endloop
endfunction

You're looping through players 1 (red) to 13 (neutral), first of all. Second of all, I don't think you quite understand how GetLocalPlayer( ) works. It might be easier to help you out if you tell me what the context is in which you would like to lower the unit's alpha.
I forgot about indexes starting at 0, fixed that.

I have no idea how GetLocalPlayer() works, so I basically copied what looked supposedly correct.

Context:
I'm creating various UI indicators using dummy units to each player, but I don't want any of the other players to see them.
The dummy units are necessary, as I can't move images around with great accuracy and variable size.
Edit: I realize that the function works as 0=invisible, no need to point that particular point out anymore.
03-05-2009, 02:55 AM#9
Fledermaus
Collapse JASS:
function Test takes unit u, player p returns nothing
    if GetLocalPlayer() == p then
        call SetUnitVertexColor(u,0,0,255,100)
    else
        call SetUnitVertexColor(u,0,0,0,50)
    endif
endfunction

That will make unit u visible to player p (full colour and slightly-transparent (~40%)) but "invisible" to all other players (no colour and more transparent (~20%)).

Edit: You know that 100 for the alpha value != 100% non-transparent right?
03-05-2009, 02:57 AM#10
Weyrling
Final code, not tested online.
Will this desync or not?
Collapse JASS:
function PersonalTint takes unit u, integer r, integer g, integer b, integer a, player p returns nothing
    local integer i = 0
    loop
        exitwhen i > 11
        if GetLocalPlayer() == p then
            call SetUnitVertexColor(u,r,g,b,a)
        else
            call SetUnitVertexColor(u,0,0,0,0)
        endif
        set i = i+1
    endloop
endfunction
Edit: To elaborate, this is the coloring you want your UI indicators to be.
03-05-2009, 03:25 AM#11
Fledermaus
You don't need the loop at all..
03-05-2009, 03:32 AM#12
xombie
Collapse JASS:
function SetUnitAlphaLocal takes unit u, player localPlayer, integer alpha returns nothing
    if GetLocalPlayer() == localPlayer then
        call SetUnitVertexColor(u, 255, 255, 255, alpha)
    endif
endfunction

This is more or less the function you would need. It will only change the unit's alpha for a certain player, so if you wanted to set it to 255 for everybody except for, say, player 0, then...

Collapse JASS:
call SetUnitVertexColor(someUnit, 255, 255, 255, 255) //this is 255 alpha
call SetUnitAlphaLocal(someUnit, Player(0), 50)

Understand?
03-05-2009, 04:57 AM#13
Weyrling
I understand how it works now, thanks a lot Xombie.
03-05-2009, 05:15 AM#14
xombie
Not a problem.