• 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 when a building is created

Status
Not open for further replies.
Level 2
Joined
Mar 27, 2020
Messages
16
Hey, I finally got my new hero for my map to work, but now, every time I play it online, there is a desync happening when this unit creates a scout tower. He has an ability that he throws something and I triggered that a scout tower is created at the position the spell is aimed at. When I test my map solo, its not a problem,though there is a spike happening shortly before the tower is created.

Anyone an idea? Im desperate after all this work..

The trigger is:

  • Throws a Tower
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Triggering towerthrow
    • Actions
      • Wait 0.30 seconds
      • Unit - Create 1 Scout Tower for (Owner of (Triggering unit)) at ((Target point of ability being cast) offset by (0.00, 0.00)) facing Default building facing degrees
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
I can't explain why it's desyncing but I can point out some issues I see.

1) In most cases you want to use: A unit starts the effect of an ability as the Event for your abilities. Begins casting an ability will run the trigger even if you cancel the ability before it goes off, allowing the player to abuse this and create multiple scout towers without spending mana/putting the ability on cooldown.

Note that Begins casting can still be useful. For example, abilities used by structures, since in most cases a structure can't cancel an ability since it can't be stunned/silenced/or issued a "Stop" order.

2) Target point of ability being cast is treated like a global variable. What this means is that whenever a unit casts a spell that targets a point, Target point of ability being cast is set to that point. This is a problem when using Waits because if another unit uses a targeted ability before the Wait (0.30 seconds in this case) has passed, Target point of ability being cast will be changed and result in the Scout Tower being created at the wrong point.

3) You don't need to use Point with offset. You can simply reference Target point of ability being cast as the place to create the Scout Tower. Although, in this case I'd advise against using Target point of ability being cast entirely since you reference it after a Wait.

4) You're leaking a point. Now if you're new to the editor then I wouldn't worry too much about this type of thing, but it's something to be aware of: Things That Leak

Here's an example of a properly setup version of your spell:
  • Cast Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Your Spell
    • Actions
      • Custom script: local location udg_TempPoint = GetSpellTargetLoc()
      • Wait 0.30 seconds
      • Unit - Create 1 Scout Tower for (Owner of (Triggering unit)) at TempPoint facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_TempPoint)
      • Custom script: set udg_TempPoint = null
It requires a Point variable called TempPoint. I'm using a technique called Shadowing that allows us to turn a global variable (TempPoint) into a local variable. Local variables are great because their value can't be changed outside of the trigger, so you don't have to worry about TempPoint changing to something else during the Wait.

The Custom Script stuff is Jass, which is the programming language used by the Wc3 engine. All of your triggers use Jass, but it's hidden behind the GUI. And GUI is the interface that the Trigger Editor uses, which basically transforms the code into easily understandable Events/Conditions/Actions that you can select and fill out.

Here's an example of an Action converted into it's code form. Here's the Action:
  • Unit - Create 1 Footman for (Owner of (Triggering unit)) at TempPoint facing Default building facing degrees
And here's the actual code that is hidden behind that Action.
vJASS:
call CreateNUnitsAtLoc( 1, 'hfoo', GetOwningPlayer(GetTriggerUnit()), udg_TempPoint, bj_UNIT_FACING )
I don't expect you to understand all of this right away, and nor should you, but I figured I'd let you know just so you have some idea as to why i'm using Custom Script and other things.
 

Attachments

  • Spell Example.w3m
    16.8 KB · Views: 23
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
That's pretty interesting, perhaps there's divergence in the "target point of ability being cast" global that causes the desync. Would be interesting to know if Uncle's fix works.
I can't say for certain but I have a hunch that his issue is Reforged related. I'd have to see the rest of his triggers to know for certain, but I've been seeing a lot of posts about desyncs lately and with Reforged having such a rough launch it wouldn't surprise me if it's just Blizzard screwing things up.
 
Level 2
Joined
Mar 27, 2020
Messages
16
I can't say for certain but I have a hunch that his issue is Reforged related. I'd have to see the rest of his triggers to know for certain, but I've been seeing a lot of posts about desyncs lately and with Reforged having such a rough launch it wouldn't surprise me if it's just Blizzard screwing things up.


First of all, thank you a lot Uncle, for the well written and for me as beginner very understandable explanations!! However, I was aware of the "A Unit starts the effect of an ability" is in most cases not abusable, but I chose "Begins the effect.." on purpse (in this case, with my ability itsnot abusable and has some benefits).

I tried your trigger, with shockwave, and like with mine, there is no problem with creating units. I now figured out I think where the problem lies. As soon as a building, not a unit, is created I get a massive fps spike, which I think is the reason for the desync (because it always so far happened online in this moment). But weirdly just at the first building created. Using the ability a second time, third time etc, it runs smooth. I have no idea why.. Maybe the Building angle is important? Maybe the game is confused with other than standard angles in regards of buildings? Do you maybe know what is the standard angle? Or do you have the same problem at all, if you switch your footman in your map with a scout tower?

Thanks again, you improved the trigger a lot in terms of efficiency and leaks i think, but the problem lies somewhere else :(

Maybe its reforged, but I don't want to give up because I put so muchwork in this hero, and this is one of the basic abilities that is the foundation of all the other stuff :D
 

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
That spike is normal, the game is loading the art file for the first time. However, you may have other triggers that run when the Scout Tower is created that cause additional performance issues.

Do you use the "A unit enters the map" Event in any of your triggers? And if you want I can take a look at your map if you're comfortable with that
 
Level 2
Joined
Mar 27, 2020
Messages
16
That spike is normal, the game is loading the art file for the first time. However, you may have other triggers that run when the Scout Tower is created that cause additional performance issues.

Do you use the "A unit enters the map" Event in any of your triggers? And if you want I can take a look at your map if you're comfortable with that

I don't use this "a unit enters the map" trigger. Also no other triggers are involved in this "create a scout tower."

I could send you my map via pm if you wand to take a look, but its just this trigger causing problems. Maybe its really reforged related, so if I put somewhere randomly a scout tower on the map, the game doesnt have to load the art file for the first time when the ability is being used, and it won't cause a desync? ^^ I will give it a try
 
It's possible the game is out of sync before but when the unit is created it triggers the desync.

I would say try using default gameplay constants and replacing all timer events with countdown timers. Last I heard there was an issue with timer events in that they would run at different intervals depending on FPS.

You can also try using Desync checker for JASS snippets which will essentially look for improper use of any async natives such as these:

JASS:
GetDestructableName
GetSoundDuration
GetSoundFileDuration
GetCameraBoundMinX
GetCameraBoundMinY
GetCameraBoundMaxX
GetCameraBoundMaxY
GetCameraField
GetCameraTargetPositionX
GetCameraTargetPositionY
GetCameraTargetPositionZ
GetCameraTargetPositionLoc
GetCameraEyePositionX
GetCameraEyePositionY
GetCameraEyePositionZ
GetCameraEyePositionLoc
GetObjectName
IsMultiboardMinimized
GetLocalPlayer
GetLocationZ
GetLocalizedString
GetLocalizedHotkey
GetUnitName
BlzGetLocalUnitZ
BlzGetUnitZ
GetItemName
BlzGetItemDescription
BlzGetItemTooltip
BlzGetItemExtendedTooltip
BlzGetLocalSpecialEffectX
BlzGetLocalSpecialEffectY
BlzGetLocalSpecialEffectZ
GetPlayerSlotState
 
Status
Not open for further replies.
Top