DBM修改教學 - WOW

By Audriana
at 2017-03-18T19:41
at 2017-03-18T19:41
Table of Contents
身為手殘玩家&略懂程式工程師,可以交給電腦的事情當然要交給電腦處理;
以下分享一下最近修改DBM提高自己/團隊容錯率順便貢獻回 upstream 的過程
# 增加特定法術冷卻計時, 倒數音效以及特別警告 #
大約一個月前團內在拓荒提克的時候,腿短DK如我在 P2 的射線死亡率有點高,
而當時的DBM對於射線(腐肉夢魘)是沒有任何提示的
隔天分析了一下打那幾場的 wcl, 發現他的頻率很固定, 模式如下:
[wcl截圖](http://i.imgur.com/L034htH.png)
P2 進場後第4秒開始唱第一條射線, 施法2秒, 施法後過2秒會唱下一道,
直到唱完6次為止
所以這邊想到要做的事情如下
(1) 增加腐肉夢魘的冷卻計時以及倒數語音
(2) 施法開始時增加特別語音警告(快跑啊小女孩快跑兮兮兮)
## 我們先找到提克 DBM 的檔案 ##
打開 Interface/Addons/DBM-Nighthold/Tichondrius.lua
觀察了一下裡面完全沒有提到腐肉夢魘,所以第一要務是找出腐肉夢魘的 spell id
可以從腐肉夢魘=>Carrion Nightmare=>在 wowhead 找到 spell id: 215988
## 增加計時條/倒數語音/特殊警告 ##
(a) 為了讓 DBM 可以辨認並產生選項, 我們需要宣告兩個變數
```lua
local timerCarrionNightmare = mod:NewNextCountTimer(4, 215988, nil, nil,
nil, 2)
local countdownCarrionNightmare = mod:NewCountdown("Alt4", 215988, false, 2,
3)
```
主要是參考其他 timer 跟 countdown 去更改 spellid 就好, 其他參數可以先雷同
(b) 然後我們必要讓 DBM 知道我們想知道腐肉夢魘開始施法了 在事件註冊的地方
```lua
-- add spell event for carrion nightmare
mod:RegisterEventsInCombat(
"SPELL_CAST_START 212997 213238 212794 213531 206365 216034 216723 215988",
```
(c) 接著在施法事件處理加入計時條跟倒數啟動
```lua
function mod:SPELL_CAST_START(args)
local spellId = args.spellId
if spellId == 215988 then
self.vb.carrionNightmare = self.vb.carrionNightmare + 1
specWarnCarrionNightmare:Show()
voiceCarrionNightmare:Play("watchstep")
if self.vb.carrionNightmare < 6 then
timerCarrionNightmare:Start()
countdownCarrionNightmare:Start()
end
```
(d) 別忘了宣告施法次數跟歸零, 不過這段沒有很重要, 單純是告訴你這是第幾次
```lua
mod.vb.addsCount = 0
mod.vb.carrionNightmare = 0
mod.vb.batsKilled = 0
```
以上修改在 2/14 當天晚上 Raid 測試完畢正常運作後,
[當天寫的](https://gist.github.com/alivedise/add3dc7b8740d3756480178f0fe8b59a)
我就去 DBM forum 請作者考慮是否加入並給他我的參考程式
[論壇文章 - Feature request for Tich's Carrion Nightmare Warning]
(https://www.deadlybossmods.com/forum/viewtopic.php?f=5&t=188)
2/22後的 DBM 開始就有腐肉夢魘的警告了
(不過他 API 有點更動, 所以現在 DBM 的程式碼跟我當天寫得不盡相同)
# 增加資訊框架 #
最近古爾單拓荒到 P3, 一樣發現了靈魂之井相關的提示太少,
WeakAura 那邊有個靈魂之井的提示 (https://wago.io/V1agWHR8M) 實測後發現不合用,
而且對其他人來說要額外裝 WA 有點煩
所以我又把念頭動到比較熟悉的 DBM 身上
要顯示這類的資訊只能使用 DBM 的 InfoFrame 功能了
就是打眾星的時候會自動顯示找惡魔提示出來的小框框
參考了幾個有使用這個功能的副本 boss 後整理出一個流程如下
## 一樣先找到古爾丹檔案 ##
打開 Interface/Addons/DBM-Nighthold/Guldan.lua
這時候會發現裡面已經有一個 InfoFrame 的提示叫 TimeStop
不過基於這不是主要困擾我的事
而 DBM 又似乎不支援多重 InfoFrame, 我們就先把這段複寫成靈魂之井
## 找到關鍵法術 ID ##
參考上面的 WeakAura 字串 跟 Guldan.lua 後
很快地抓出相關的 ID 如下
(1) 靈魂之井 Well of Soul: 206939
(2) 靈魂虹吸 Soul Siphon: 221891
(3) 靈魂腐敗: 208802
它們之間的關係如下
(a) 當古爾單施放 221891 時, 井內多一個靈魂
(b) 當任何玩家獲得 208802 時, 井內少一個靈魂
(c) 當黑暗收穫施放時, 井內靈魂數量影響黑暗收穫傷害
所以我們藉此去維護一個 soulCount 然後用 update/sort InfoFrame 來顯示
a. 目前井內靈魂數量
b. 目前有腐敗 debuff 的人的列表, 從小到大
## 實作流程 ##
1. 宣告 InfoFrame 使用
```lua
mod:AddInfoFrameOption(206939)
```
2. 戰鬥開始或進入p3後顯示 InfoFrame
```lua
if self.Options.InfoFrame then
DBM.InfoFrame:SetHeader(GetSpellInfo(208536))
DBM.InfoFrame:Show(31, "function", updateInfoFrame, sortInfoFrame)
end
```
3. 實作 update & sort
```lua
local updateInfoFrame, sortInfoFrame
do
local playerName = UnitName("player")
local lines = {}
local soaking = GetSpellInfo(221891)
local spellid = "<|cff00ffff"..soak..">|r"
sortInfoFrame = function(a, b)
if a == spellid then return true end
if b == spellid then return false end
local a = lines[a]
local b = lines[b]
if not tonumber(a) then a = -1 end
if not tonumber(b) then b = -1 end
if a < b then return true else return false end
end
updateInfoFrame = function()
table.wipe(lines)
lines[spellid] = mod.vb.soulCount
for uId in DBM:GetGroupMembers() do
local _, _, _, count, _, _, _ = UnitDebuff(uId, soaking)
lines[UnitName(uId)] = count
end
return lines
end
end
```
update 是告訴 DBM 如何更新內容
sort 是告訴 DBM 內容要怎麼排序
[Screenshot](http://i.imgur.com/PMWL7Ov.png)
4. 維護靈魂數量
```lua
elseif spellId == 221891 then
local now = GetTime()
if (now - self.vb.lastSiphonTime) >= 2 then
self.vb.soulCount = self.vb.soulCount + 1
self.vb.lastSiphonTime = now
end
warnSoulSiphon:CombinedShow(0.3, args.destName)
elseif spellId == 208802 then
local now = GetTime()
if (now - self.vb.lastSoakingTime) >= 2 then
self.vb.soulCount = self.vb.soulCount - 1
self.vb.lastSoakingTime = now
end
local amount = args.amount or 1
if args:IsPlayer() and amount >= 3 then
specWarnSoulCorrosion:Show(amount)
end
```
P.S. 此功能還在測試中, 所以暫不提供完整檔案,
等完成後會向 DBM 作者提案
以上
by 聖光之願聯盟/人類死亡騎士/伊芙蕾娜
--
Tags:
WOW
All Comments

By Suhail Hany
at 2017-03-22T12:59
at 2017-03-22T12:59

By Isla
at 2017-03-23T16:14
at 2017-03-23T16:14

By Yedda
at 2017-03-28T14:50
at 2017-03-28T14:50

By Lily
at 2017-04-01T16:08
at 2017-04-01T16:08

By Lydia
at 2017-04-01T23:07
at 2017-04-01T23:07

By Eden
at 2017-04-03T01:59
at 2017-04-03T01:59

By Frederica
at 2017-04-06T20:11
at 2017-04-06T20:11

By Necoo
at 2017-04-09T07:15
at 2017-04-09T07:15

By Olivia
at 2017-04-14T00:27
at 2017-04-14T00:27

By Joe
at 2017-04-15T08:30
at 2017-04-15T08:30

By Victoria
at 2017-04-16T05:57
at 2017-04-16T05:57

By Selena
at 2017-04-20T14:02
at 2017-04-20T14:02

By Hedwig
at 2017-04-25T13:03
at 2017-04-25T13:03

By Annie
at 2017-04-30T11:31
at 2017-04-30T11:31

By Kumar
at 2017-05-01T22:20
at 2017-05-01T22:20

By Edwina
at 2017-05-04T10:53
at 2017-05-04T10:53

By Selena
at 2017-05-06T06:55
at 2017-05-06T06:55

By Daph Bay
at 2017-05-09T06:11
at 2017-05-09T06:11

By Noah
at 2017-05-13T14:54
at 2017-05-13T14:54

By Lucy
at 2017-05-18T14:49
at 2017-05-18T14:49

By Delia
at 2017-05-19T13:16
at 2017-05-19T13:16

By Hazel
at 2017-05-23T07:22
at 2017-05-23T07:22

By Ethan
at 2017-05-26T03:58
at 2017-05-26T03:58

By Puput
at 2017-05-30T17:25
at 2017-05-30T17:25

By Andy
at 2017-06-02T22:32
at 2017-06-02T22:32

By Suhail Hany
at 2017-06-04T10:16
at 2017-06-04T10:16

By Hamiltion
at 2017-06-06T02:48
at 2017-06-06T02:48

By Jack
at 2017-06-10T01:34
at 2017-06-10T01:34

By Dora
at 2017-06-14T05:38
at 2017-06-14T05:38

By Quintina
at 2017-06-16T16:06
at 2017-06-16T16:06

By Carol
at 2017-06-20T21:23
at 2017-06-20T21:23

By Kumar
at 2017-06-24T10:10
at 2017-06-24T10:10

By Oscar
at 2017-06-27T12:47
at 2017-06-27T12:47

By Kama
at 2017-06-27T16:01
at 2017-06-27T16:01

By Frederica
at 2017-07-01T10:24
at 2017-07-01T10:24

By Suhail Hany
at 2017-07-02T04:43
at 2017-07-02T04:43

By Michael
at 2017-07-03T19:54
at 2017-07-03T19:54

By Ursula
at 2017-07-03T22:01
at 2017-07-03T22:01

By Lily
at 2017-07-06T00:18
at 2017-07-06T00:18

By Faithe
at 2017-07-10T20:55
at 2017-07-10T20:55

By Kristin
at 2017-07-13T19:20
at 2017-07-13T19:20

By Yedda
at 2017-07-17T14:24
at 2017-07-17T14:24

By Sarah
at 2017-07-18T02:05
at 2017-07-18T02:05

By Irma
at 2017-07-18T16:47
at 2017-07-18T16:47

By Lily
at 2017-07-22T20:40
at 2017-07-22T20:40

By Andy
at 2017-07-23T12:20
at 2017-07-23T12:20
Related Posts
日屠部落的艾斯然是不是很難排

By Tracy
at 2017-03-18T13:22
at 2017-03-18T13:22
關於增強薩的裂地浩劫天賦

By Brianna
at 2017-03-18T12:51
at 2017-03-18T12:51
伊利達瑞的靈魂稜石 任務串

By Hedy
at 2017-03-18T12:38
at 2017-03-18T12:38
冰DK手法問題請益

By Bethany
at 2017-03-18T10:52
at 2017-03-18T10:52
日屠聯盟公會傳奇團招生7/10M

By William
at 2017-03-18T10:51
at 2017-03-18T10:51