[WE] [範例] 用UnitPool 做隨機單位

看板WarCraft (魔獸爭霸 - 魔獸爭霸3)作者 (祐子)時間17年前 (2008/04/18 01:34), 編輯推噓16(1603)
留言19則, 3人參與, 最新討論串1/1
因為全域變數沒有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

04/18 14:10, , 1F
看不懂就推。
04/18 14:10, 1F

04/18 14:10, , 2F
不太瞭解這跟UnitType陣列的差別說.......
04/18 14:10, 2F

04/18 14:40, , 3F
其實差不多 主要是多一個他能設定機率
04/18 14:40, 3F

04/18 14:47, , 4F
範例圖裡面我是都設定機率一樣
04/18 14:47, 4F

04/18 21:53, , 5F
喔,瞭解,謝謝。
04/18 21:53, 5F

04/21 21:11, , 6F
偶喔喔喔喔~~~~~~~
04/21 21:11, 6F

04/21 21:11, , 7F
/▏      |\
04/21 21:11, 7F

04/21 21:11, , 8F
▏\__ __/ ▏ 該推爆了
04/21 21:11, 8F

04/21 21:11, , 9F
\__◢███◣__/ 兄弟們出動啦!!!
04/21 21:11, 9F

04/21 21:11, , 10F
█████▏
04/21 21:11, 10F

04/21 21:11, , 11F
▏ ● ●▏ ╴╴╴╴╴╴
04/21 21:11, 11F

04/21 21:11, , 12F
▏ > ▏ ◣ ﹨    
04/21 21:11, 12F

04/21 21:11, , 13F
▏ △皿△▏ █◣ ﹨ ██ /▏
04/21 21:11, 13F

04/21 21:11, , 14F
┌─ ﹨    ╱┐ ██◣ ﹨ ██/ ▏
04/21 21:11, 14F

04/21 21:11, , 15F
│ ╱  ̄ ̄ ﹨│ ███████▋ █ ( /
04/21 21:11, 15F

04/21 21:11, , 16F
│ ∕ ╲ 蠻∕ ╲ ███████▊ ◢██^^
04/21 21:11, 16F

04/21 21:11, , 17F
│∕ ╲ ╴╴╲╴ ███████▊◢█◤█
04/21 21:11, 17F

04/21 21:11, , 18F
│︳ ╲ ╱\\\\ \\\\ ◢████▌
04/21 21:11, 18F

04/21 21:11, , 19F
│︳ ▄▅▇███▆███████◣
04/21 21:11, 19F
文章代碼(AID): #181uf2PZ (WarCraft)
文章代碼(AID): #181uf2PZ (WarCraft)