- Joined
- Sep 14, 2009
- Messages
- 284
Hi. So last night I tested my map with a friend, who was disconnected during gameplay, and I learned of the GetLocalPlayer() desync problem.
So I rewrote the scripts that uses GetLocalPlayer() and now my script looks like below.
My question is will this cuase desyncs? And how do I learn to identify what causes desyncs so I can solve this by myself?
So I rewrote the scripts that uses GetLocalPlayer() and now my script looks like below.
My question is will this cuase desyncs? And how do I learn to identify what causes desyncs so I can solve this by myself?
JASS:
function DamageBasicAttack_Conditions takes nothing returns boolean
return udg_DamageEventSource != udg_DamageEventTarget and udg_AbilityMagical == false and udg_AbilityPhysical == false and GetUnitState(udg_DamageEventTarget, UNIT_STATE_LIFE) > 0.405 and GetUnitAbilityLevel(udg_DamageEventTarget, 'A001') < 1
endfunction
function DamageBasicAttack_Actions takes nothing returns nothing
local real dAmount = udg_DamageEventAmount
local unit dSource = udg_DamageEventSource
local unit dTarget = udg_DamageEventTarget
local real angle = GetRandomReal(70, 110)
local texttag t = null
local string s = I2S(R2I(dAmount))
if GetLocalPlayer() != GetOwningPlayer(dSource) then
set s = ""
endif
if s != "" then
set t = CreateTextTag()
call SetTextTagText(t, "|cffDC4522"+s+"|r", 0.022 + ((dAmount / 500) * (0.023 / 10)))
call SetTextTagPos(t, GetUnitX(dTarget), GetUnitY(dTarget), 0)
call SetTextTagVelocity(t, 0.11*Cos(angle*bj_DEGTORAD), 0.11*Sin(angle*bj_DEGTORAD))
call SetTextTagVisibility(t, true)
call SetTextTagFadepoint(t, 1.25)
call SetTextTagLifespan(t, 2)
call SetTextTagPermanent(t, false)
set t = null
endif
set dSource = null
set dTarget = null
endfunction
//===========================================================================
function InitTrig_DamageBasicAttack takes nothing returns nothing
set gg_trg_DamageBasicAttack = CreateTrigger()
call TriggerRegisterVariableEvent(gg_trg_DamageBasicAttack, "udg_DamageEvent", EQUAL, 1.0)
call TriggerAddCondition(gg_trg_DamageBasicAttack, Condition(function DamageBasicAttack_Conditions))
call TriggerAddAction(gg_trg_DamageBasicAttack, function DamageBasicAttack_Actions)
endfunction