jass 如何返回多个单位
魔兽地图编辑器吧
全部回复
仅看楼主
level 1
myjlwf 楼主
function gettav takes nothing returns unit
local group g = CreateGroup()
local unit u
call GroupEnumUnitsOfPlayer(g, Player(PLAYER_NEUTRAL_PASSIVE), null)
loop
set u = FirstOfGroup(g)
exitwhen u == null
if GetUnitTypeId(u) == 'nntt' then
call DestroyGroup(g)
return u
else
call GroupRemoveUnit(g, u)
endif
endloop
call DestroyGroup(g)
endfunction
这段函数返回的u是中立被动玩家的所有单位中第一个潮汐神庙
然后 set tav=gettav() 需要这个神庙时带入u即可
可如果有多个潮汐神庙,要如何按编号返回
同时按需要调用不同编号的单位??
我把循环改写成了数组 但完全不会返回,难道 returns unit要改? set tav又怎么改?
integer ix = 0
integer i = 0
unit array us
loop
set u = FirstOfGroup(g)
exitwhen u == null
if GetUnitTypeId(u) == 'nntt' then
return us[i]
set ix = i
set i = i + 1
call GroupRemoveUnit(g, u)
else
call GroupRemoveUnit(g, u)
endif
endloop
call DestroyGroup(g)
endfunction
2021年06月12日 15点06分 1
level 9
返回单位组
2021年06月13日 01点06分 2
level 9
unit array
2021年06月13日 01点06分 3
1