|
附件里面的 map.j 就是我的struct 的使用办法 在ui阶段都是正常的 struct IDS 的取值都是正常的
但是在做技能的时候 发生了异步
function mushi3A takes nothing returns nothing
local integer jn
local timer tm
local unit u
local unit ud
local real r
local IDS id
local player p
local string s_ef
local string s_art
local effect ef
local integer i
local integer jndj
set jn = GetSpellAbilityId()
set tm = CreateTimer()
set u = GetSpellAbilityUnit()
set ud = GetSpellTargetUnit()
set p = GetOwningPlayer(u)
set id = WJload(GetPlayerId(p))
set i = GetHandleId(tm)
if jn == 'A00A' and id.UID == u then
set s_ef = "Abilities\\Weapons\\FaerieDragonMissile\\FaerieDragonMissile.mdl"
set s_art = "overhead"
set ef = AddSpecialEffectTargetUnitBJ( s_art, ud, s_ef )
call SaveUnitHandle(mushi,i,1,u)
call SaveUnitHandle(mushi,i,2,ud)
call SaveEffectHandle(mushi,i,3,ef)
set jndj = id.WJJNDJ[3] ////////这个地方发生了异步
if jndj == 1 then
set r = 1
elseif jndj ==2 then
set r = 2
elseif jndj ==3 then
set r = 3
elseif jndj == 0 then
set r = 4
endif
call BJDebugMsg(R2S(r))
call TimerStart(tm,r,false , function mushi3Timer)
call DisplayTextToPlayer( p, 0, 0, "321" )
endif
set tm = null
set u = null
set ud = null
set ef = null
set i = 'null'
endfunction
但是奇怪的点在于,如果我没有用ui学习技能,那么这个技能r取值就是4
如果不使用 ui 来学习技能 在外界直接学习,那么就不会掉线
也就是说 id.WJJNDJ[3] 的取值是正常的
之后一直测了很多遍
发现是技能同步问题
function XXJNTB takes nothing returns nothing //技能同步事件
local player p
local string s
local integer s_frame //截取frame
local integer s_jn //截取技能id
local integer s_i //截取长度
local IDS id
local IDS idjn
local integer WJID
local integer JNID
local unit u
local integer jndj
local integer frame_lp
local integer jn
set p = DzGetTriggerSyncPlayer()
set s = DzGetTriggerSyncData()
set s_i = StringLength(s)
set s_frame = S2I(SubString(s,0,9))
set s_jn = S2I(SubString(s,9,s_i))
//call BJDebugMsg(s)
//call BJDebugMsg(I2S(s_frame))
//call BJDebugMsg(I2S(s_jn))
set WJID = GetPlayerId(p)
set id = WJload(WJID)
set u = id.UID
set JNID = s_jn
set idjn = JNload(JNID)
set frame_lp = ClickXXButtonUItxet(s_frame)
set jndj = id.WJJNDJ[frame_lp]
set jndj = jndj + 1
//set id.WJJNDJ[frame_lp] = jndj //问题就出在这里,学习技能是没有问题的,但是在同步事件下,我更改了单个玩家注册的id.值, 在技能那块取值的r就掉线了 但是不在同步事件下,更改单个玩家id.值 又不会掉线
set id.JND = id.JND - 1
set jn = idjn.JNXXID[jndj]
call UnitAddAbility(u,jn)
if StartHeroIf(p) == true then
call JNXXGS(id)
endif
endfunction
function JNXXButton takes nothing returns nothing //技能学习按钮点击事件
local integer frame
local player p
local integer frame_lp
local integer WJID
local IDS id
local IDS idu
local IDS idjn
local string s
set frame = DzGetMouseFocus()
set p = DzGetTriggerUIEventPlayer()
set frame_lp = ClickXXButtonUItxet(frame)
set WJID = GetPlayerId(p )
set id = WJload(WJID )
set idu = RWload(id.RWID)
set idjn = JNFramelp(frame_lp,idu)
if XXJNGYIF(id,idjn,frame_lp) == true then //加这一个判断无非是想节省使用同步的次数 不要点一下同步一下
set s = I2S(frame)+I2S(idjn.JNID)
call DzSyncData("XXJN",s)
endif
endfunction
可能我说的有点乱 , 希望大佬能帮我看看 这个同步事件里面 为什么更改id.WJJNDJ[]的值 会造成技能事件里面r的取值异步
|
|