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

Getting desynced due to overload of use GetLocalPlayer()

Level 10
Joined
May 24, 2016
Messages
339
Hello, I have encountered a moment I got desynced suddenly from the rest 9 players.

From what I have seen in replay, I got desynced when I casted a spell and killed 10 mobs at time.

It's not an unusual thing in my map to happen: killing a few dozens of mobs in a moment.

But at that game I have given me a special "perk": creating a floating text and giving money for killing mobs.
Here's the fragment of UNIT_DIES even where's my perk takes its turn.
JASS:
set S = ""
set Ss = ""


if timeperm > 665. then // timeperm is global variable that stores game time, nothing tricky here 
set golddigger = golddigger * 2 // a local integer golddigger, it was predeclared ago so it's atleast set to 0
endif


if GetLocalPlayer() == Player(clot) // clot is local integer // set clot = GetPlayerId(GetOwningPlayer(k))
set S = "Item_GoldCoins.mdx" // global variable string S, I like global variables that way so i dont declare it every time in every trigger
set Ss = "+ "+I2S(golddigger) // global variable string Ss, I like global variables that way so i dont declare it every time in every trigger
endif

call SetPlayerState(Player(clot),PLAYER_STATE_RESOURCE_GOLD,GetPlayerState(Player(clot),PLAYER_STATE_RESOURCE_GOLD) + golddigger)


call AddEffectTimeToPoint(S,GetUnitX(d),GetUnitY(d),1.5) //2.5
            set TX = CreateTextTag() //TX is global variable texttag, I like global variables that way so I dont declare it every time in every trigger
            call SetTextTagColor(TX, 255, 255, 0, 250) //250
            call SetTextTagTextBJ(TX, Ss, 10 ) //13
            call SetTextTagPos(TX, GetUnitX(d), GetUnitY(d), 20) //25
            call SetTextTagVelocity(TX, 0.00, 0.02) //0.06 0.04
            call SetTextTagPermanent(TX, FALSE)
            call SetTextTagLifespan(TX, 2.3)
            //call SetTextTagAge(TX,0.8)
            call SetTextTagFadepoint(TX, 1.2)


When I tested it out it's still fine, so I dunno maybe Im wrong.


And yeahm you could see AddEffectTimeToPoint here. Here's how it looks like

JASS:
function DestroyEffectTimeToPoint takes nothing returns nothing
    call DestroyEffect(LoadEffectHandle(Hash,GetHandleId(GetExpiredTimer()),1))
    call DestroyTimer(GetExpiredTimer())
    call FlushChildHashtable(Hash,GetHandleId(GetExpiredTimer()))
endfunction

function AddEffectTimeToPoint takes string eff, real x, real y,real time returns nothing
local timer t = CreateTimer()
    call SaveEffectHandle(Hash,GetHandleId(t),1,AddSpecialEffect(eff,x,y))
    call TimerStart(t,time,false, function DestroyEffectTimeToPoint)
set t = null
endfunction
 
Last edited:

Uncle

Warcraft Moderator
Level 73
Joined
Aug 10, 2018
Messages
7,866
Some things to think about:

Anything using the Event "A unit dies" should be taken into consideration. This Event breaks the standard trigger queue rules and injects it's logic directly at the exact moment the unit dies.

You should look into and post the logic surrounding the spell you cast, assuming it has it's own custom logic. Also, think about systems that could be running in response to the spell being cast.

I've heard about strings causing a desync if you don't initialize them first..? Something like that, there's an old thread on Hive that mentions it you could probably dig up. Memory is foggy on the matter.
 
Top