作者readper (佑子)
看板WarCraft
标题[WE] [范例] 用UnitPool 做随机单位
时间Fri Apr 18 01:34:57 2008
因为全域变数没有UnitPool可以选
所以有使用Return Bug将UnitPool转成Integer存在全域变数
其实还有ItemPool 用法也都差不多
用UnitPool的好处:
随机选单位的触发变的很精简
坏处:
最核心的部份只有jass
Return Bug部分的jass如下---------
function H2I takes handle pTarg returns integer
return pTarg
return 0
endfunction
function I2UnitPool takes integer i returns unitpool
return i
return null
endfunction
---------------------------------
建立清单的部份
Custom script: local unitpool up=CreateUnitPool() 这是建立UnitPool
Custom script: set udg_UnitPool = H2I(up) 这是利用return bug存进变数
然後就是一堆的
Set SystemIndex = (SystemIndex + 1)
Set Units[SystemIndex] = XXXX单位
然後最後跑个loop
For each (Integer A) from 1 to SystemIndex, do (Actions)
Loop - Actions
Custom script:
call UnitPoolAddUnitType(up,udg_Units[bj_forLoopAIndex],1)
而最後建立单位的时候非常简单的
Custom script: call PlaceRandomUnit(I2UnitPool(udg_UnitPool),玩家,X,Y,面向)
我做好的范例图在流连上
连结:
http://forums.wasabistudio.ca/viewtopic.php?f=5&t=18330
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 210.192.224.249
1F:推 gonzdevour:看不懂就推。 04/18 14:10
2F:→ gonzdevour:不太了解这跟UnitType阵列的差别说....... 04/18 14:10
3F:→ readper:其实差不多 主要是多一个他能设定机率 04/18 14:40
4F:→ readper:范例图里面我是都设定机率一样 04/18 14:47
5F:推 gonzdevour:喔,了解,谢谢。 04/18 21:53
6F:推 chungsen: 偶喔喔喔喔~~~~~~~ 04/21 21:11
7F:推 chungsen: /▏ |\ 04/21 21:11
8F:推 chungsen: ▏\__ __/ ▏ 该推爆了 04/21 21:11
9F:推 chungsen: \__◢███◣__/ 兄弟们出动啦!!! 04/21 21:11
10F:推 chungsen: █████▏ 04/21 21:11
11F:推 chungsen: ▏ ● ●▏ ╴╴╴╴╴╴ 04/21 21:11
12F:推 chungsen: ▏ > ▏ ◣ ﹨ 04/21 21:11
13F:推 chungsen: ▏ △皿△▏ █◣ ﹨ ██ /▏ 04/21 21:11
14F:推 chungsen:┌─ ﹨ ╱┐ ██◣ ﹨ ██/ ▏ 04/21 21:11
15F:推 chungsen:│ ╱  ̄ ̄ ﹨│ ███████▋ █ ( / 04/21 21:11
16F:推 chungsen:│ ∕ ╲ 蛮∕ ╲ ███████▊ ◢██^^ 04/21 21:11
17F:推 chungsen:│∕ ╲ ╴╴╲╴ ███████▊◢█◤█ 04/21 21:11
18F:推 chungsen:│︳ ╲ ╱\\\\ \\\\ ◢████▌ 04/21 21:11
19F:推 chungsen:│︳ ▄▅▇███▆███████◣ 04/21 21:11