|
发表于 2008-7-9 11:43:11
|
显示全部楼层
[codes=jass]function CreateNUnitsAtLoc takes integer count, integer unitId, player whichPlayer, location loc, real face returns group
call GroupClear(bj_lastCreatedGroup)
loop
set count = count - 1
exitwhen count < 0
call CreateUnitAtLocSaveLast(whichPlayer, unitId, loc, face)
call GroupAddUnit(bj_lastCreatedGroup, bj_lastCreatedUnit)
endloop
return bj_lastCreatedGroup
endfunction[/codes]
[codes=jass]function CreateUnitAtLocSaveLast takes player id, integer unitid, location loc, real face returns unit
if (unitid == 'ugol') then
set bj_lastCreatedUnit = CreateBlightedGoldmine(id, GetLocationX(loc), GetLocationY(loc), face)
else
set bj_lastCreatedUnit = CreateUnitAtLoc(id, unitid, loc, face)
endif
return bj_lastCreatedUnit
endfunction[/codes]
CreateNUnitsAtLoc就是循环调用CreateUnitAtLocSaveLast并用bj_lastCreatedGroup(最后创建的单位组)记录创建的这些单位,而CreateUnitAtLocSaveLast就是调用CreateUnitAtLoc并用bj_lastCreatedUnit(最后创建的单位)记录这个单位
其实最推荐使用的是CreateUnit,直接通过坐标创建单位
带bj的说明是blizzard.j中的全局变量或者函数,这些函数都是调用common.j里函数的 |
|