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

[Desync] Show Special Effect for 1 Player only

Status
Not open for further replies.
Level 10
Joined
Apr 27, 2012
Messages
241
Hello folks,

I made a squad system. All units in a squads share the same custom value.

When the squad is selected, all except for the designated 'leader' unit are deselcted via trigger. To keep the illusion, a selection circle graphic is created on the deselected squad memebers. These circles shall not be visible to other players, naturally. So I used ''Get Local Player.'' But it causes desyncs then (meaning it disconnects a player)

This is what it looks like (more or less):
  • Set PlayerVariable = Triggering Player
  • Custom Script: if GetLocalPlayer() == udg_PlayerVariable then
  • Special Effect - Create Special Effect XY on unit
  • Custom Script: endif
--> result: causes players to disconnect (=desync)

I also tried using an ability that does nothing but adds a special effect to the unit:
  • Set PlayerVariable = Triggering Player
  • Custom Script: if GetLocalPlayer() == udg_PlayerVariable then
  • Unit - Add AbilityXY to UnitXY
  • Custom Script: endif
--> result: causes players to disconnect (=desync)



Help please. Those damn desyncs, why ain't there an action to simply disable them. I mean, it limits the game. I don't use the 'Get Local Player'-Function in a way that actually would influence the Synchronisation of the game. I just want graphics to be shown to one player only. Damn you Blizzard!! :p


+rep for helpers :)
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
Try to abuse a trick with initialisizing a string locally:

  • Custom script: local string s
  • Custom script: if GetLocalPlayer() == GetTriggerPlayer then
  • Custom script: set s = "YourEffectPath"
  • Custom script: endif
  • Custom script: AddSpecialEffectTarget(s, GetTriggerUnit(), "chest")

That is not desync-proof.

This is

  • Custom script: local string s = "YourEffectPath"
  • Custom script: if GetLocalPlayer() != GetTriggerPlayer then
  • Custom script: set s = ""
  • Custom script: endif
  • Custom script: AddSpecialEffectTarget(s, GetTriggerUnit(), "chest")
The reason is that creating new strings locally desyncs too.
 
Level 10
Joined
Apr 27, 2012
Messages
241
the trick works, I can create selection circles (as special effect) on units with the circles only being visible to one player and no desync occurs! thanks and +rep! :)


yet, how do I properly remove the effects again? When the 'leader' unit is deselected, the selection circle should be removed from all 'squad members' that share the same custom value. How can this be done?


I'd like to assign the custom value of a unit to the Special Effects when the effect is generated, so I can later refer to it when it is to be removed. Problem is, Custom Values are already in use, and several units that belong to the same 'squad' share the same Value as their 'CustomValue'.
 
Level 21
Joined
Mar 27, 2012
Messages
3,232
You should not change custom values of anything yourself. Use a unit indexer for this and then use the custom value of unit as array index for data.
That way you can have any amount of arrays for units without any risk of overlap.
 
Level 10
Joined
Apr 27, 2012
Messages
241
Hmm, when a squad is created, add them to a group. SquadGroup[]
[0], [1], and so on. Increase each time squad is added.

Upon deselecting a leader, loop from 1 to <max squad number> and check if the leader is in such SquadGroup[]. If so, deselect all members of the squad.

yes, but I'd have to keep unit groups then without clearing them immediately. Doesn't that cause memory leaks? I'd like to avoid that.


Try to abuse a trick with initialisizing a string locally:

  • Custom script: local string s
  • Custom script: if GetLocalPlayer() == GetTriggerPlayer then
  • Custom script: set s = "YourEffectPath"
  • Custom script: endif
  • Custom script: AddSpecialEffectTarget(s, GetTriggerUnit(), "chest")


Can you also use that trick with an ability? I mean, adding an ability instead of a special effect.
That would require a line of Custom Script that adds an ability and gets the ability name from the Variable s.

Someone help me out here. Is that possible?
 
I'd have to keep unit groups then without clearing them immediately
If you ensure you remove them, before you give variable a new valoe you don't have a leak.

Can you also use that trick with an ability?
You locally want to add an ability to an unit? What for exactly?

The reason is that creating new strings locally desyncs too.
I'm not sure really it would desync. Should be tested maybe. But in my case, I just forgot first to initialisize it globaly.:)
 
Level 26
Joined
Aug 18, 2009
Messages
4,097
It would still have desynced before Xonok's fix because the local variable was not initialized without the local branch -> thread would have halted for other players, they would not have received the effect handle. And the parantheses are missing behind GetTriggerPlayer -> GetTriggerPlayer()
 
Status
Not open for further replies.
Top