|
看到个很奇怪的东西...
WE里有个随机选取物品的函数..
[jass]
function RandomItemInRectBJ takes rect r, boolexpr filter returns item
set bj_itemRandomConsidered = 0
set bj_itemRandomCurrentPick = null
call EnumItemsInRect(r, filter, function RandomItemInRectBJEnum)
call DestroyBoolExpr(filter)
return bj_itemRandomCurrentPick
endfunction
function RandomItemInRectBJEnum takes nothing returns nothing
set bj_itemRandomConsidered = bj_itemRandomConsidered + 1
if (GetRandomInt(1, bj_itemRandomConsidered) == 1) then
set bj_itemRandomCurrentPick = GetEnumItem()
endif
[/jass]
这个
if (GetRandomInt(1, bj_itemRandomConsidered) == 1) then
用GetRandomInt感觉是不是多余了...直接if (bj_itemRandomConsidered == 1) then不就行了..不知里面有什么玄机....
还有,随机选取个物品要这么多代码吗?好浪费..-_-!! |
|