作者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