|
发表于 2008-4-11 20:35:43
|
显示全部楼层
以下是选取单位组常使用的函数,参数中有一个boolexpr参数类型,用来过滤选取的单位。
[jass]native GroupEnumUnitsInRange takes group whichGroup,real x,real y,real radius,boolexpr filter returns nothing
native GroupEnumUnitsInRangeOfLoc takes group whichGroup,location whichLocation,real radius,boolexpr filter returns nothing
native GroupEnumUnitsInRect takes group whichGroup,rect r,boolexpr filter returns nothing
native GroupEnumUnitsOfPlayer takes group whichGroup,player whichPlayer,boolexpr filter returns nothing
native GroupEnumUnitsOfType takes group whichGroup,string unitname,boolexpr filter returns nothing
native GroupEnumUnitsSelected takes group whichGroup,player whichPlayer,boolexpr filter returns nothing
[/jass]
创建一个boolexpr:
[jass]
native Condition takes code func returns conditionfunc
[/jass]
在归类上,boolexpr属于conditionfunc类型,其使用方法如下:
[jass]
function IsFitlerUnitAlive takes nothing returns boolean
return GetUnitState( GetFitlerUnit(), UNIT_STATE_LIFE) >= 0.00
endfunction
function EnumAliveUnit takes nothing returns group
local group g = CreateGroup()
local boolexpr b = Condition( function IsFitlerUnitAlive )
call GroupEnumUnitsInRange( g, 0.00, 0.00, 9999999, b)
call DestroyBoolExpr(b)
set b = null
return g
endfunction
[/jass] |
|