找回密码
 点一下
楼主: mnbvcxzqwe

又来发问了,这J有错误吗?

[复制链接]
发表于 2008-8-14 16:21:38 | 显示全部楼层
额,不知道自己写了些什么,那这个是怎么写出来的?

[codes=jass]function tiaojian takes nothing returns boolean
    if (not(IsUnitType(GetTriggerUnit(),UNIT_TYPE_HERO) == true)) then
        return false
    endif
    return true
endfunction

function jishiqi takes nothing returns nothing
    local unit u =I2U(GetStoredInteger(GameCache(),I2S(H2I(GetExpiredTimer())),"TriggerUnit"))
    if (not(IsUnitAlly(u,Player(11)) == true)) then
        call ReviveHeroLoc(u,GetRectCenter(udg_a),false)
    else
        call ReviveHeroLoc(u,GetRectCenter(udg_b),false)
    endif
    call SetUnitManaPercentBJ(u,100)
    set u = null
endfunction

function fh takes nothing returns nothing
    local unit u = GetTriggerUnit()
    local timer t = CreateTimer()
    local timerdialog td = CreateTimerDialog(t)
    call TimerDialogSetTitle(td, GetPlayerName(GetOwningPlayer(GetTriggerUnit())) + "复活时间:" )
    call StoreInteger(GameCache(),I2S(H2I(t)),"TriggerUnit",H2I(u))  
    call StoreInteger(GameCache(),I2S(H2I(u)),"Timer",H2I(t))
    call StoreInteger(GameCache(),I2S(H2I(u)),"TimerDialog",H2I(td))
    call TimerStart(t,180,false,function jishiqi)
    call TimerDialogDisplay(td,true)
    set u = null
    set t = null
    set td = null
endfunction

function Revive takes nothing returns nothing
    local timer t = I2T(GetStoredInteger(GameCache(),I2S(H2I(GetTriggerUnit())),"Timer"))
    local timerdialog td = I2TD(GetStoredInteger(GameCache(),I2S(H2I(GetTriggerUnit())),"TimerDialog"))
    call DestroyTimerDialog(td)
    call PauseTimer(t)
    call DestroyTimer(t)
    call FlushStoredMission(GameCache(), I2S(H2I(GetTriggerUnit())))
    call FlushStoredMission(GameCache(), I2S(H2I(t)))
    set t = null
    set td = null
endfunction

function InitTrig_rh takes nothing returns nothing
    local trigger tri0 = CreateTrigger()
    local trigger tri1 = CreateTrigger()
    call TriggerRegisterAnyUnitEventBJ(tri0,EVENT_PLAYER_UNIT_DEATH)
    call TriggerAddCondition(tri0,Condition(function tiaojian))
    call TriggerAddAction(tri0,function fh)
    call TriggerRegisterAnyUnitEventBJ(tri1,EVENT_PLAYER_HERO_REVIVE_FINISH)
    call TriggerAddCondition(tri1,Condition(function tiaojian))
    call TriggerAddAction(tri1,function Revive)
    set tri0 = null
    set tri1 = null
endfunction[/codes]
回复

使用道具 举报

 楼主| 发表于 2008-8-14 17:43:11 | 显示全部楼层
我是看J的电子书造出来的,造到缓存那里就开始乱了.不了解.
call StoreInteger(GameCache(),I2S(H2I(t)),"TriggerUnit",H2I(u))   
call StoreInteger(GameCache(),I2S(H2I(t)),"TimerDialog",H2I(td))
call StoreInteger(GameCache(),I2S(H2I(u)),"Timer",H2I(t))
call StoreInteger(GameCache(),I2S(H2I(u)),"TimerDialog",H2I(td))

为什么有2个的"TimerDialog"?I2S(H2I(u))和I2S(H2I(t))又是为什么啊.
回复

使用道具 举报

发表于 2008-8-14 17:49:13 | 显示全部楼层
一个是与计时器挂钩,一个是与单位挂钩,其实可以去掉一个

又编辑了下
回复

使用道具 举报

 楼主| 发表于 2008-8-14 18:02:51 | 显示全部楼层
开始明白,call StoreInteger(GameCache(),I2S(H2I(u)),"TimerDialog",H2I(td))
                    call StoreInteger(缓存名 类别名 缓存项目 数据类型)
                    local timerdialog td =I2TD(缓存名 I2S(H2I(*****)),"Timer"))
                    (*****)这部分应该写什么是按什么定的?
回复

使用道具 举报

发表于 2008-8-14 18:04:01 | 显示全部楼层
你要绑定到什么就写什么
回复

使用道具 举报

 楼主| 发表于 2008-8-14 18:09:14 | 显示全部楼层
哦..call StoreInteger(GameCache(),I2S(H2I(u)),"TimerDialog",H2I(td))
U就是单位,T就是计时期.I2S(H2I(u))原来是改这里绑的.
回复

使用道具 举报

发表于 2008-8-14 18:54:58 | 显示全部楼层
用TimerStart需要双向绑定,可以用TriggerRegisterTimerEvent,这样就可以把两个动作合在一起,在动作里检查触发事件就可以了
回复

使用道具 举报

发表于 2008-8-14 18:59:22 | 显示全部楼层
ls的意思是一个触发,两个事件,动作可重复部分较多,并在一起写,不同部分用GetTriggerEventId函数判断事件区分?
回复

使用道具 举报

 楼主| 发表于 2008-8-14 20:06:59 | 显示全部楼层
26楼兄的意思是什么?在动作里检查?
回复

使用道具 举报

发表于 2008-8-14 20:54:27 | 显示全部楼层
就是省掉一个触发,用同一个触发,注册多个事件,用我上面提到的那个函数可以的到触发的到底是哪一个事件
回复

使用道具 举报

 楼主| 发表于 2008-8-15 00:53:58 | 显示全部楼层
那么这样写好不好喽?
回复

使用道具 举报

发表于 2008-8-15 00:57:19 | 显示全部楼层
我觉得你这样写就可以了,那样写可能会乱
回复

使用道具 举报

发表于 2008-8-15 03:58:44 | 显示全部楼层
call FlushStoredMission(GameCache(), I2S(H2I(GetTriggerUnit())))

这个可能会出错,其他绑定在单位身上的数据也会被清理掉了,还有给单位绑定数据一不小心就会出现数据重复覆盖的错误,所以我觉得尽量不要给单位绑定临时数据,这也是用TriggerRegisterTimerEvent的好处之一
回复

使用道具 举报

发表于 2008-8-15 12:06:40 | 显示全部楼层
用这个事件也要双向绑定的,也会出现同样的问题的

对于这个问题,稍微作些修改,把MissionKey改一下,比如改成"Revive" + I2S(H2I(GetTriggerUnit()))就可以避免了
回复

使用道具 举报

发表于 2008-8-15 13:05:27 | 显示全部楼层
用trigger不需要双向绑定
回复

使用道具 举报

发表于 2008-8-15 13:08:12 | 显示全部楼层
我觉得还是需要的额,销毁计时器、销毁触发,反而更加麻烦………………
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 点一下

本版积分规则

Archiver|移动端|小黑屋|地精研究院

GMT+8, 2024-7-21 04:26 , Processed in 0.051175 second(s), 17 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表