|
楼主 |
发表于 2012-7-30 11:55:07
|
显示全部楼层
我拿出实例好一点
function GetUnitById takes integer unitid returns unit //通过单位id获得单位
local unit ru=null
local unit u=null
local group g=CreateGroup()
call GroupEnumUnitsInRange(g,0,0,999999,null)
loop
set u=FirstOfGroup(g)
exitwhen u==null
if(GetUnitTypeId(u)==unitid) then
set ru=u
endif
call GroupRemoveUnit(g,u)
endloop
call DestroyGroup(g)
set g=null
return ru
endfunction
function others takes nothing returns nothing
local unit u=GetUnitById ('hfoo')
call DoSomething()
set u=null
endfunction
这个不知道有没有排泄的问题,在下面
function GetPlayersAllies takes player whichPlayer returns force
local force f = CreateForce()
call ForceEnumAllies(f, whichPlayer, null)
return f
endfunction
中local force f = CreateForce()创建了新势力,所以在调用后要清除
而GetUnitById()并没有创建单位,这样可以吗? |
|