找回密码
 点一下
查看: 2201|回复: 2

非缓存绑定 删除触发器 动作 条件 的方法

[复制链接]
发表于 2009-3-19 23:23:24 | 显示全部楼层 |阅读模式
晚上有人 问了我删除触发器动作条件等的方法 而且还抱怨说 缓存绑定太麻烦了

其时 我想起了以前测试过的触发器 动作 条件 等的handle值 都是处于同1区间


由此 我写了这个另类思路的删除法

[jass]function H2I takes handle h returns integer
return h
return 174
endfunction
//===========================================================================
function I2T takes integer i returns trigger
return i
return null
endfunction
function I2TA takes integer i returns triggeraction
return i
return null
endfunction
function I2TC takes integer i returns triggercondition
return i
return null
endfunction
function I2C takes integer i returns conditionfunc
return i
return null
endfunction
//===========================================================================
function a3c takes nothing returns nothing
local integer t=H2I(GetTriggeringTrigger())
call DestroyCondition(I2C(t+1))
call TriggerRemoveCondition(I2T(t),I2TC(t+2))
call DestroyTrigger(I2T(t))
call BJDebugMsg("3触发 t: "+I2S(t)+" c0: "+I2S(t+1)+" c: "+I2S(t+2)+" a: 0")
endfunction
//========
function a2c takes nothing returns nothing
local integer t=H2I(GetTriggeringTrigger())
call DestroyCondition(I2C(t+2))
call TriggerRemoveCondition(I2T(t),I2TC(t+3))
call DestroyTrigger(I2T(t))
call BJDebugMsg("2触发 t: "+I2S(t)+" c0: "+I2S(t+2)+" c: "+I2S(t+3)+" a: 0")
endfunction
//========
function a1 takes nothing returns nothing
local integer t=H2I(GetTriggeringTrigger())
call TriggerRemoveAction(I2T(t),I2TA(t+2))
call DestroyTrigger(I2T(t))
call BJDebugMsg("1触发 t: "+I2S(t)+" c0: 0 c: 0 a: "+I2S(t+2))
endfunction
//========
function a0 takes nothing returns nothing
local integer t=H2I(GetTriggeringTrigger())
call DestroyCondition(I2C(t+2))
call TriggerRemoveCondition(I2T(t),I2TC(t+3))
call TriggerRemoveAction(I2T(t),I2TA(t+4))
call DestroyTrigger(I2T(t))
call BJDebugMsg("0触发 t: "+I2S(t)+" c0: "+I2S(t+2)+" c: "+I2S(t+3)+" a: "+I2S(t+4))
endfunction
function a0c takes nothing returns boolean
return TRUE
endfunction
//===========================================================================
function InitTrig_shiyan2 takes nothing returns nothing
local integer t
local integer a
local integer c
local integer c0
//============================
set bj_lastCreatedUnit=CreateUnit(Player(0),'hpea',0,0,0)
set gg_trg_shiyan =CreateTrigger()
set t=H2I(gg_trg_shiyan)
call TriggerRegisterUnitEvent( gg_trg_shiyan,bj_lastCreatedUnit, EVENT_UNIT_DAMAGED )
set c0=H2I(Condition(function a0c))
set c=H2I(TriggerAddCondition(gg_trg_shiyan,I2C(c0)))
set a=H2I(TriggerAddAction(gg_trg_shiyan, function a0))
call BJDebugMsg("0 t: "+I2S(t)+" c0: "+I2S(c0)+" c: "+I2S(c)+" a: "+I2S(a))
//============================
set bj_lastCreatedUnit=CreateUnit(Player(0),'hpea',0,100,0)
set gg_trg_shiyan =CreateTrigger()
set t=H2I(gg_trg_shiyan)
call TriggerRegisterUnitEvent( gg_trg_shiyan,bj_lastCreatedUnit, EVENT_UNIT_DAMAGED )
set a=H2I(TriggerAddAction(gg_trg_shiyan, function a1))
call BJDebugMsg("1 t: "+I2S(t)+" c0: 0 c: 0 a: "+I2S(a))
//============================
set bj_lastCreatedUnit=CreateUnit(Player(0),'hpea',0,200,0)
set gg_trg_shiyan =CreateTrigger()
set t=H2I(gg_trg_shiyan)
call TriggerRegisterUnitEvent( gg_trg_shiyan,bj_lastCreatedUnit, EVENT_UNIT_DAMAGED )
set c0=H2I(Condition(function a2c))
set c=H2I(TriggerAddCondition(gg_trg_shiyan,I2C(c0)))
call BJDebugMsg("2 t: "+I2S(t)+" c0: "+I2S(c0)+" c: "+I2S(c)+" a: 0")
//============================
set bj_lastCreatedUnit=CreateUnit(Player(0),'hpea',0,300,0)
set gg_trg_shiyan =CreateTrigger()
set t=H2I(gg_trg_shiyan)
set c0=H2I(Condition(function a3c))
set c=H2I(TriggerAddCondition(gg_trg_shiyan,I2C(c0)))
call TriggerRegisterUnitEvent( gg_trg_shiyan,bj_lastCreatedUnit, EVENT_UNIT_DAMAGED )
call BJDebugMsg("3 t: "+I2S(t)+" c0: "+I2S(c0)+" c: "+I2S(c)+" a: 0")
endfunction
//===========================================================================
function InitTrig_shiyan takes nothing returns nothing
set gg_trg_shiyan =CreateTrigger()
call TriggerRegisterTimerEvent( gg_trg_shiyan, 0.00 ,FALSE)
call TriggerAddAction( gg_trg_shiyan, function InitTrig_shiyan2 )
endfunction
[/jass]

我感觉这样删除的话 不需要绑定,比绑定方便多了 `


```````````欢迎指正`~~

非绑定删除触发器动作条件.w3m

20 KB, 下载次数: 13

测试用地图

 楼主| 发表于 2009-3-20 00:07:57 | 显示全部楼层
宣告失败...

这个没考虑到 触发器等删除后 留下的handle空位 对新建触发器handle的影响````
(补进空位时 就错误了=_=)

如果考虑那个 因为替补的不确定性  会很窘``
回复

使用道具 举报

发表于 2009-3-22 13:27:23 | 显示全部楼层
果然很另类。
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-23 21:23 , Processed in 0.122802 second(s), 22 queries .

Powered by Discuz! X3.5

© 2001-2023 Discuz! Team.

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