• 🏆 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!

About hide unit and localplayer

Status
Not open for further replies.
Level 5
Joined
Jan 12, 2010
Messages
132
So I have some custom abilities that create some missile based on dummy units.
To reduce some lagg I want to hide missile for others player that are not owner of triggering unit inside localplayer block.
What I`m asking for is:
-Did a hide unit reducess lagg?
-Did created special effects inside localplayer block desync in so manner to drop players?
 
Level 12
Joined
Sep 11, 2011
Messages
1,176
So I have some custom abilities that create some missile based on dummy units.
To reduce some lagg I want to hide missile for others player that are not owner of triggering unit inside localplayer block.
What I`m asking for is:
-Did a hide unit reducess lagg?
-Did created special effects inside localplayer block desync in so manner to drop players?

- yes but not sure.
- GetLocalPlayer() faq

shadowvzs said:
3. Special effects, visibile for 1 player only?

Question - this cause desyncronization?
Answer - No - tested myself
 
Level 5
Joined
Jan 12, 2010
Messages
132
This is what I mean":
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • SFX_controller[(Player number of (Owner of Temp_unit[1]))] Equal to False
    • Then - Actions
      • Set Player = (Owner of Temp_unit[1])
      • Custom script: if ( udg_Player == GetLocalPlayer() ) then
      • Special Effect - Create a special effect attached to the origin of Hash_unit using war3mapImported\IceNova.mdx
      • Special Effect - Destroy (Last created special effect)
      • Custom script: endif
    • Else - Actions
 
Level 5
Joined
Jan 12, 2010
Messages
132
Thx a lot.
So for this trigger,for any unit created inside it,if I hide them for rest of players using "Unit - Hide (unit)" ,should reducess lagg for others players?
Can cause mallfunctions?
  • Gun event
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
      • (Number of units in Gun_group2) Greater than or equal to 1
    • Actions
      • Unit Group - Pick every unit in Gun_group2 and do (Actions)
        • Loop - Actions
          • Set Hash_unit = (Picked unit)
          • Custom script: set udg_Hash_key = GetHandleId(udg_Hash_unit)
          • Set Temp_unit[1] = (Load 3 of Hash_key in Table_gun)
          • Set Temp_unit[2] = (Load 4 of Hash_key in Table_gun)
          • Set Temp_point[1] = (Position of (Picked unit))
          • Set Temp_point[2] = (Position of Temp_unit[1])
          • Set Temp_real[1] = (Distance between Temp_point[1] and Temp_point[2])
          • Set Temp_real[2] = (Angle from Temp_point[1] to Temp_point[2])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Temp_real[1] Greater than or equal to 40.00
            • Then - Actions
              • Set Temp_point[3] = (Temp_point[1] offset by 40.00 towards Temp_real[2] degrees)
              • Unit - Move (Picked unit) instantly to Temp_point[3], facing Temp_real[2] degrees
              • Custom script: call RemoveLocation(udg_Temp_point[3])
            • Else - Actions
              • Set Temp_real[3] = (Load 1 of Hash_key from Table_gun)
              • Set Temp_real[4] = (Load 2 of Hash_key from Table_gun)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • SFX_controller[(Player number of (Owner of (Picked unit)))] Equal to False
                • Then - Actions
                  • Unit - Create 1 Flare fx for (Owner of (Picked unit)) at Temp_point[1] facing Default building facing degrees
                  • Animation - Change (Last created unit)'s size to ((50.00 + (Temp_real[4] / 10.00))%, (50.00 + (Temp_real[4] / 10.00))%, (50.00 + (Temp_real[4] / 10.00))%) of its original size
                  • Unit - Turn collision for (Last created unit) Off
                  • Unit - Move (Last created unit) instantly to Temp_point[1]
                  • Unit - Add a 1.00 second Generic expiration timer to (Last created unit)
                • Else - Actions
              • Set Temp_group = (Units within Temp_real[4] of Temp_point[1] matching ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) is an enemy of (Owner of (Picked unit))) Equal to True)))
              • Unit Group - Pick every unit in Temp_group and do (Actions)
                • Loop - Actions
                  • Set Temp_integer[2] = (Custom value of (Picked unit))
                  • If (Temp_integer[2] Equal to 2) then do (Set Temp_real[3] = (Temp_real[3] x 0.50)) else do (Do nothing)
                  • If (Temp_integer[2] Equal to 4) then do (Set Temp_real[3] = (Temp_real[3] x 2.00)) else do (Do nothing)
                  • Unit - Cause Temp_unit[2] to damage (Picked unit), dealing Temp_real[3] damage of attack type Spells and damage type Normal
              • Custom script: call DestroyGroup(udg_Temp_group)
              • Hashtable - Clear all child hashtables of child Hash_key in Table_gun
              • Unit - Remove (Picked unit) from the game
              • Unit Group - Remove (Picked unit) from Gun_group2
          • Custom script: call RemoveLocation(udg_Temp_point[1])
          • Custom script: call RemoveLocation(udg_Temp_point[2])
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
I'd like to emphasize on how to use GetLocalPlayer correctly, without desync.

This will desync;
  • Actions
    • Custom script: if GetLocalPlayer() == Player(0) then
    • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
    • Custom script: endif
This won't desync;
  • Actions
    • Set UnitType = No unit-type
    • Custom script: if GetLocalPlayer() == Player(0) then
    • Set UnitType = Footman
    • Custom script: endif
    • Unit - Create 1 UnitType for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
Do you see the difference ?

In trigger 1, the function is directly being called inside the GetLocalPlayer block, which it will perform exclusively for that Player only.

While on trigger 2, the only action inside the GetLocalPlayer block is the setting of variable which is equal to the unit-type that you want to spawn.
But first, we must make the Unit-type to become null outside the GetLocalPlayer block.

Why we did this ?
It is because once we set it to null for All Players and set it to certain unit-type for certain player, we just call the function outside the GetLocalPlayer block and everything will run fine.

What happens outside the block ?
Well, it basically will create a Footman (let's say you set it to Footman), for Player 1 (which is Player(0) in JASS) but it will create a null unit of the unit-type for all other players.

This still calls a global function instead of local ones, but the function applies follows to the variable sets in both outside and inside GetLocalPlayer block - which won't cause desync because you call the function outside the GetLocalPlayer block which makes the trigger to not localized to only 1 Player, but to All Players as well.
 
Level 5
Joined
Jan 12, 2010
Messages
132
You dont understood me.I dont want to create unit inside localplayer I just use this 2 exemples:
  • Set Local_player = (Owner of Temp_unit[1])
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • SFX_controller[(Player number of Local_player)] Equal to False
    • Then - Actions
      • Custom script: if GetLocalPlayer() == udg_Local_player then
      • Special Effect - Create a special effect attached to the over head of (Picked unit) using Abilities\Spells\Undead\CarrionSwarm\CarrionSwarmDamage.mdl
      • Special Effect - Destroy (Last created special effect)
      • Custom script: endif
    • Else - Actions
  • Set Temp_point[1] = (Position of (Triggering unit))
  • Unit - Create 1 Dummy (DF) for (Owner of (Triggering unit)) at Temp_point[1] facing Default building facing degrees
  • Set Local_player = (Owner of (Triggering unit))
  • Custom script: if ( not ( GetLocalPlayer () == udg_Local_player ) ) then
  • Unit - Hide (Last created unit)
  • Custom script: endif
  • Custom script: call RemoveLocation(udg_Temp_point[1])
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
I'd like to emphasize on how to use GetLocalPlayer correctly, without desync.

This will desync;
  • Actions
    • Custom script: if GetLocalPlayer() == Player(0) then
    • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
    • Custom script: endif
This won't desync;
  • Actions
    • Set UnitType = No unit-type
    • Custom script: if GetLocalPlayer() == Player(0) then
    • Set UnitType = Footman
    • Custom script: endif
    • Unit - Create 1 UnitType for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
Do you see the difference ?

In trigger 1, the function is directly being called inside the GetLocalPlayer block, which it will perform exclusively for that Player only.

While on trigger 2, the only action inside the GetLocalPlayer block is the setting of variable which is equal to the unit-type that you want to spawn.
But first, we must make the Unit-type to become null outside the GetLocalPlayer block.

Why we did this ?
It is because once we set it to null for All Players and set it to certain unit-type for certain player, we just call the function outside the GetLocalPlayer block and everything will run fine.

What happens outside the block ?
Well, it basically will create a Footman (let's say you set it to Footman), for Player 1 (which is Player(0) in JASS) but it will create a null unit of the unit-type for all other players.

This still calls a global function instead of local ones, but the function applies follows to the variable sets in both outside and inside GetLocalPlayer block - which won't cause desync because you call the function outside the GetLocalPlayer block which makes the trigger to not localized to only 1 Player, but to All Players as well.

That's likely to desync because with an invalid unit type, no unit will be created.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
Oh, the create unit was just an example, sorry didn't mention that.

It should be;
  • Actions
    • Set LocalPlayer = (Owner of (Triggering unit))
    • Set StringSFX = <Empty String>
    • Custom script: if GetLocalPlayer() == udg_LocalPlayer then
    • Set StringSFX = Abilities\Spells\Human\ThunderClap\ThunderClapCaster.mdl
    • Custom script: endif
    • Special Effect - Create a special effect attached to the head of (Picked unit) using StringSFX
    • Special Effect - Destroy (Last created special effect)
  • Actions
    • Set LocalPlayer = (Owner of Unit)
    • Unit - Create 1 Footman for Player 1 (Red) at (Center of (Playable map area)) facing Default building facing degrees
    • Set Unit = No unit
    • Custom script: if not (GetLocalPlayer() == udg_LocalPlayer) then
    • Set Unit = (Last created unit)
    • Custom script: endif
    • Unit - Hide Unit
That's likely to desync because with an invalid unit type, no unit will be created.
It's like you create a non-unit type to the map - which creates a blank unit that does not exist - yet the unit does exist in the game.
It doesn't cause desync because like I said, it creates a null unit - which is nothing, compared to function inside GetLocalPlayer block, it truly creates that unit for one player.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
No ...
The handle id stack will be different on each computer, there is an unit created or not. (i'm talking about your previous code)

EDIT : And i'm not sure that hide an unit locally is always safe, even if it's a locust unit.
And no need of this "no unit" thing, just hide it in a local code.
 
Level 33
Joined
Mar 27, 2008
Messages
8,035
As I have just tested it, lol...
I tried to create SFX at the position of the unit with null unit-type, but to no avail, it doesn't get created at all.

You're right, it will cause desync since unit stacks are different when handled on different computers caused by split server or desync.

Do you think instead of null unit, it should replace a dummy unit with no model ?
This way, it has the same stack of handle id per computer, 1 being dummy unit, 1 being true unit.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Do you think instead of null unit, it should replace a dummy unit with no model ?
This way, it has the same stack of handle id per computer, 1 being dummy unit, 1 being true unit.

It could work, but i don't know how wc3 handle that, maybe it still desync, and to be safer the only difference between the units should be the model.
 
Level 12
Joined
Jul 11, 2010
Messages
422
Locust units can be selected after you hide/show them.
I don't see why you all want to use GetLocalPlayer in such an hazardous way. It might be usefull to hide units locally but it's just better to use special effects in most situations.

Also, it is said here that offscreen units' models are hidden. If you care about fps, there are much better things to do than that (beginning with using jass).
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
Locust units can be selected after you hide/show them.
I don't see why you all want to use GetLocalPlayer in such an hazardous way. It might be usefull to hide units locally but it's just better to use special effects in most situations.

Also, it is said here that offscreen units' models are hidden. If you care about fps, there are much better things to do than that (beginning with using jass).

animations
attachments
moving them
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
I tested it in multiplayer and its drop all players.
This is verry sad :((.Localplayer seems to ruin all.

nope. it doesnt desync. your doing it wrong

  • Custom script: if GetLocalPlayer() == udg_Local_player then
  • Special Effect - Create a special effect attached to the over head of (Picked unit) using Abilities\Spells\Undead\CarrionSwarm\CarrionSwarmDamage.mdl
  • Special Effect - Destroy (Last created special effect)
  • Custom script: endif
desyncs

  • Custom script: if GetLocalPlayer() == udg_Local_player then
  • Set path = Abilities\Spells\Undead\CarrionSwarm\CarrionSwarmDamage.mdl
  • Custom script: endif
  • Special Effect - Create a special effect attached to the over head of (Picked unit) using path
  • Special Effect - Destroy (Last created special effect)
 
Level 12
Joined
Jul 11, 2010
Messages
422
Then use "SetUnitVertexColor"...

And about shadows, there is also a way to hide them :
JASS:
function CreateDummyForPlayer takes player p returns unit
    local image shadow = CreateImage("ReplaceableTextures\\Splats\\AuraRune9b.blp",0,0,0,0,0,0,0,0,0,1 )
    local integer alpha = 0
    call DestroyImage(shadow)
    set bj_lastCreatedUnit = CreateUnit(p,'dumy',0,0,0)
    if GetLocalPlayer()==p then
        set alpha = 255
    endif
    call SetUnitVertexColor(bj_lastCreatedUnit,255,255,255,alpha)
    call SetImageColor(shadow,255,255,255,alpha)
    return bj_lastCreatedUnit
endfunction

That's for animations and attachments... Because Vexorian's dummy gives a better api to control the movement.
 
Last edited:
Level 19
Joined
Aug 8, 2007
Messages
2,765
ok I saw that I was wrong with specialls effects.
But what to do with
  • Unit - Hide (last created unit)
Can I use it inside localplayer block or no?

yes but the unit must have the "Locust" ability and you cannot "show" it after hiding it
 
Status
Not open for further replies.
Top