|
以下代码是我在everguo教程里看到的,用的是condition,但是使用的时候却发生错误
[codes=jass]function DestroyTriggerAll takes trigger trg returns nothing
call TriggerRemoveCondition(trg,I2TC(GetStoredInteger(udg_GC,I2S(H2I(trg)),"TriggerCondition")))
call DestroyTrigger(trg)
call FlushStoredMission(udg_GC,I2S(H2I(trg)))
endfunction
//========================================================
function RegisterUnitAmortCond takes nothing returns nothing
call SetUnitInvulnerable(GetTriggerUnit(), true)
call DestroyTriggerAll(GetTriggeringTrigger())
endfunction
function RegisterUnitAmortEvent takes unit witchUnit returns nothing
local trigger trg = CreateTrigger()
call TriggerRegisterUnitStateEvent(trg, witchUnit, UNIT_STATE_LIFE, LESS_THAN_OR_EQUAL, 50)
call StoreInteger(udg_GC,I2S(H2I(trg)),"TriggerCondition",H2I (TriggerAddCondition(trg,Condition(function RegisterUnitAmortCond))))
set trg = null
endfunction[/codes]
这是在教程中看到的另一段代码,是用action做的...但却可以运行
[codes=jass]function RegisterUnitAmortAction takes nothing returns nothing
local trigger trg = GetTriggeringTrigger()
local triggeraction Act=I2TA(GetStoredInteger(udg_GC,I2S(H2I(trg)),"Triggeraction"))
call SetUnitInvulnerable(GetTriggerUnit(), true)
call TriggerRemoveAction(trg,Act)
call DestroyTrigger(trg)
call FlushStoredMission(udg_GC,I2S(H2I(trg)))
set trg = null
set Act=null
endfunction
function RegisterUnitAmortEvent takes unit witchUnit returns nothing
local trigger trg = CreateTrigger()
local triggeraction Act
call TriggerRegisterUnitStateEvent(trg, witchUnit, UNIT_STATE_LIFE, LESS_THAN_OR_EQUAL, 50)
set Act=TriggerAddAction(trg,function RegisterUnitAmortAction)
call StoreInteger(udg_GC,I2S(H2I(trg)),"Triggeraction ",H2I(Act))
set trg = null
set Act=null
endfunction[/codes]
经过测试,把第一段代码中的call TriggerRemoveCondition(trg,I2TC(GetStoredInteger(udg_GC,I2S(H2I(trg)),"TriggerCondition"))) 去掉就不会出错...
不知道是我使用有问题,还是代码的问题....想请教下各位大大 |
|