• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Hiding unit and local players

Status
Not open for further replies.
Level 24
Joined
Aug 1, 2013
Messages
4,657
ShowUnit does work, except when your unit (that is shown for some players) interacts with anything. Then it desyncs.

What you could do is:
JASS:
    function SetUnitVisibility takes unit whichUnit, boolean show returns nothing
        if show then
            call SetUnitVertexColor(whichUnit, 255, 255, 255, 255)
        else
            call SetUnitVertexColor(whichUnit, 255, 255, 255, 0)
        endif
    endfunction
    
    function foo takes nothing returns nothing
        call SetUnitVisibility(u, false)
        
        if GetLocalPlayer() == Player(0) then
            call SetUnitVisibility(u, true)
        endif
        
        //  or rather:
        
        call SetUnitVisibility(u, GetLocalPlayer() == Player(0))
        
    endfunction
Which properly hides the unit.
 
Level 12
Joined
May 22, 2015
Messages
1,051
ShowUnit does work, except when your unit (that is shown for some players) interacts with anything. Then it desyncs.

What you could do is:
JASS:
    function SetUnitVisibility takes unit whichUnit, boolean show returns nothing
        if show then
            call SetUnitVertexColor(whichUnit, 255, 255, 255, 255)
        else
            call SetUnitVertexColor(whichUnit, 255, 255, 255, 0)
        endif
    endfunction
    
    function foo takes nothing returns nothing
        call SetUnitVisibility(u, false)
        
        if GetLocalPlayer() == Player(0) then
            call SetUnitVisibility(u, true)
        endif
        
        //  or rather:
        
        call SetUnitVisibility(u, GetLocalPlayer() == Player(0))
        
    endfunction
Which properly hides the unit.

Wouldn't this still allow you to select the unit and stuff? I don't know the applications of using ShowUnit() since I haven't touched it. Does it desync if you give the unit orders as well? I think I am just maybe missing some details about this.
 
Level 12
Joined
May 22, 2015
Messages
1,051
Vertex color will never be able to desync.
You can still select the unit... except with 0 alpha iirc.

So this is helpful if you don't want everyone to be able to see a specific unit, right? Like you could use dummy units as animations and then hide them from certain players? Maybe like a confusion ability that adds a bunch of fake units to only one player's screen and they just run around to make it hard to see what's happening?
 
ShowUnit does work, except when your unit (that is shown for some players) interacts with anything. Then it desyncs.

What you could do is:
JASS:
    function SetUnitVisibility takes unit whichUnit, boolean show returns nothing
        if show then
            call SetUnitVertexColor(whichUnit, 255, 255, 255, 255)
        else
            call SetUnitVertexColor(whichUnit, 255, 255, 255, 0)
        endif
    endfunction
    
    function foo takes nothing returns nothing
        call SetUnitVisibility(u, false)
        
        if GetLocalPlayer() == Player(0) then
            call SetUnitVisibility(u, true)
        endif
        
        //  or rather:
        
        call SetUnitVisibility(u, GetLocalPlayer() == Player(0))
        
    endfunction
Which properly hides the unit.

Your solution isn't really any better than mine.
The only difference is that the model can still be selected while you have to drag select with setting the unit scale to 0%.

Also changing the colour can mess up the original colour of he unit.
Messes up the original scaling with my method, but whatev'.

Silly how blizzard didn't implement getting the default values for scale and colour.
Or even a function to make a particular unit unselectable.
Or that arrow keys aren't instant.
Or how the Unit Select event isn't instant.
Or how there is a lot of potential natives missing.


Edit:
But yeah if you don't care about any units colour potentially messing up without indexing the units colour or if the unit has a custom colour at all, then just go with colour vexing.

But you'll still have issues with the unit being selectable.
 
Level 24
Joined
Aug 1, 2013
Messages
4,657
Silly how blizzard didn't implement getting the default values for scale and colour.
I have 'em.

Or even a function to make a particular unit unselectable.
Yea, that is kind of stupid.

Or that arrow keys aren't instant.
They need to be synchronized.

Or how the Unit Select event isn't instant.
These as well.

Or how there is a lot of potential natives missing.
Like what?

Edit:
But yeah if you don't care about any units colour potentially messing up without indexing the units colour or if the unit has a custom colour at all, then just go with colour vexing.
Then you want some higher quality coding anyway.

But you'll still have issues with the unit being selectable.
I only need it on dummy units.



There is also another way to make local units.
Units can be made with different model files, so if you have a copy of your unit type and have the second one be with a dummy model, then you can make units locally for certain players with the normal model and for the others with the dummy model, then you have a proper local unit.
(You cannot make them global or make them local with an existing unit though.)
 
Status
Not open for further replies.
Top