|
动态注册事件的一些疑问.
看了GA的动态注册事件....真是无语啊....不知道j还可以这样用...
RegisterUnitAmortEvent 想问问这个是不是为单位注册事件的意思? 不过 我在 TriggerEventStrings 没有找到...
想问问类似这样的函数是不是还有很多....去哪里找它们呢?
我自己试着写了3个....
一个失败,一个成功,一个成功一半...但是不明白为何.所以发上来问问.
我觉得我失败的原因,似乎是把声明变量和改变单位的
第一个.我已经删除了,不能发出来.我就说一下...我想做的是把两个触发合并到一起.一个触发是玩家选择单位后,给这个单位赋值.
另一个触发就是玩家按下Left键后.单位会满血...但是...合并出来没有效果..想问问.这动态注册事件是不是有哪些限制?
半成功的....之所以是半成功是因为.这个J中的等待单位组的冲突我暂时无法解决...关键是不想用全局变量...
另外想问.单位组 的排泄 是只 删除单位组就可以了? 还是先清空.然后再删除?
这个J中我没有删除...因为我发现删除后...会有更多的单位加不上技能,,如果我按Esc快的话...而且听人说全局变量是可以反复利用的.不用太担心占内存的问题...
[jass]
function Trig____________________005Actions takes nothing returns nothing
local location d = GetRectCenter(gg_rct______________000)
set udg_U2 = CreateNUnitsAtLoc( 100, 'hfoo', Player(0),d , bj_UNIT_FACING )
call sm(udg_U2)
call RemoveLocation(d)
call TriggerSleepAction(2)
call GroupClear( udg_U2 )
set d = null
endfunction
//===========================================================================
function InitTrig____________________005 takes nothing returns nothing
set gg_trg____________________005 = CreateTrigger()
call TriggerRegisterPlayerEventEndCinematic( gg_trg____________________005, Player(0) )
call TriggerAddAction(gg_trg____________________005, function Trig____________________005Actions)
endfunction
function s2 takes nothing returns nothing
call UnitAddAbility( GetEnumUnit(), 'A000' )
call DisplayTextToForce( GetPlayersAll(), "2" )
endfunction
function s1 takes nothing returns nothing
call DisplayTextToForce( GetPlayersAll(), "1" )
call ForGroupBJ( udg_U2, function s2 )
call DisplayTextToForce( GetPlayersAll(), "3" )
call DestroyTrigger(GetTriggeringTrigger())
endfunction
//===========================================================================
function sm takes group u returns nothing
local trigger trg
set trg = CreateTrigger()
call TriggerRegisterTimerEventSingle( trg, 0.00 )
call TriggerAddAction(trg, function s1)
set trg = null
endfunction
[/jass]
成功的....请问高手.这样写可以吗?有没有什么不妥...我最大的收获是原来事件里面也可以LOOP...呵呵.
[jass]
function Trig____________________001Actions takes nothing returns nothing
set udg_U = GetTriggerUnit()
endfunction
//===========================================================================
function InitTrig____________________001 takes nothing returns nothing
local integer i =0
set gg_trg____________________001 = CreateTrigger()
loop
exitwhen i > 10
call TriggerRegisterPlayerSelectionEventBJ( gg_trg____________________001, Player(i), true )
set i = i + 1
endloop
call TriggerAddAction(gg_trg____________________001, function Trig____________________001Actions)
endfunction
[/jass]
[jass]
function Trig____________________003Actions takes nothing returns nothing
call SetUnitLifePercentBJ( udg_U, 1.00 )
endfunction
function Trig____________________002Actions takes nothing returns nothing
call SetUnitLifePercentBJ( udg_U, 100 )
endfunction
//===========================================================================
function InitTrig____________________003 takes nothing returns nothing
local trigger you
local trigger zuo
local integer i
set you = CreateTrigger()
set i = 0
loop
exitwhen i > 10
call TriggerRegisterPlayerKeyEventBJ( you, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_RIGHT )
set i = i + 1
endloop
call TriggerAddAction(you, function Trig____________________003Actions)
set zuo = CreateTrigger()
set i = 0
loop
exitwhen i > 10
call TriggerRegisterPlayerKeyEventBJ( zuo, Player(i), bj_KEYEVENTTYPE_DEPRESS, bj_KEYEVENTKEY_LEFT )
set i = i + 1
endloop
call TriggerAddAction(zuo, function Trig____________________002Actions)
set you = null
set zuo =null
endfunction
[/jass] |
|