• 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.

[JASS] GetLocalPlayer + native Unit API

Status
Not open for further replies.
Level 24
Joined
Aug 1, 2013
Messages
4,658
I don't really understand the "(native Unit API)" part of the question but this might help:

GetLocalPlayer() can be used for effects that do not change behavior.
Behavior is like, setting a unit's location, damage, avaiable abilities, etc.

Visual effects will only be applied for local players.
Visual effects are like, setting a unit's size, color, show/hide objects, etc.

Some functions may not be called outside GetLocalPlayer() because they will desync other players.
Most (maybe all) BJ functions will handle stuff like that.
These things could be, showing text to a player, changing the camera, unit selection functions, etc.
 
Basically, you just need to use your reasoning. First, you need to understand how multiplayer works in strategy games. It is too intensive for the server to keep track of every units position and health at all times, so instead, it just sends the orders issued by the different players (and other kinds of player input) and trusts that the simulation is deterministic, giving the same results for all players. If, however, you move a unit for a local player, this unit might end up killing some other unit, or take damage and trigger some event, or just generally screw things up causing the games synchronization to deteriorate. Think of it kinda like going back in time to kill your grandfather.

Actions which are purely aesthetic do not affect synchronization. For instance, creating or destroying text tags, sounds, effects or lightings will not cause any problems since it does not affect gameplay. Same goes for displaying texts or multiboards. It is not okay to locally remove abilities, hide units, register events, etc.
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
You are correct, ShowUnit is volatile

Use something like this

JASS:
local real alpha = 1
if GetLocalPlayer() != p the
set alpha = 0
endif
call SetUnitScale(u, alpha)
 
Thanks for replies ^^

The origin of my question is because using GetLocalPlayer + ShowUnit in a multiplayer game, the NOT host player is removed from the game with no reason.

The reason for this is that the unit is not just graphically hidden, but hidden from unit targeting aswell. This means that units which are hidden for one player will essentially be invulnerable in his version of the game, while they act normally in the other players game. When you have a server split, it's not about any player getting removed from the game, each player will continue to run his own instance, but from your perspective it will appear as if the other player dropped.
 
Status
Not open for further replies.
Top