Combo-Ergänzt
This commit is contained in:
227
MoanS.lua
227
MoanS.lua
@@ -1,22 +1,19 @@
|
||||
local addonName = "MoanS"
|
||||
local MOAN_NAME = "|cFFFF69B4MoanS|r"
|
||||
local MOAN_TEXT = "|cFFFF69B4Moan!|r"
|
||||
local COMBO_COLOR = "|cFF00FF00"
|
||||
|
||||
local defaults = {
|
||||
active = true,
|
||||
chat = true,
|
||||
petEnabled = true,
|
||||
healEnabled = true,
|
||||
totalMoans = 0,
|
||||
showCounter = true,
|
||||
framePos = nil,
|
||||
soundBaseName = "moan",
|
||||
comboTimeout = 4.0,
|
||||
locked = false,
|
||||
active = true, chat = true, petEnabled = true, healEnabled = true,
|
||||
totalMoans = 0, showCounter = true,
|
||||
framePos = nil, soundBaseName = "moan", comboTimeout = 4.0, locked = false,
|
||||
}
|
||||
|
||||
local frame = CreateFrame("Frame")
|
||||
frame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
|
||||
frame:RegisterEvent("ADDON_LOADED")
|
||||
|
||||
local lastSoundTime, comboCount, MAX_SOUNDS = 0, 0, 9
|
||||
local lastSoundTime, comboCount = 0, 0
|
||||
|
||||
local function FormatNumber(amount)
|
||||
if not amount or type(amount) ~= "number" then return amount or "0" end
|
||||
@@ -35,100 +32,144 @@ if not amount or type(amount) ~= "number" then return amount or "0" end
|
||||
CounterFrame.text = CounterFrame:CreateFontString(nil, "OVERLAY", "GameFontNormalLarge")
|
||||
CounterFrame.text:SetPoint("CENTER")
|
||||
|
||||
local function ShowCritText(amount)
|
||||
local function ShowCritText(amount, isHighCombo)
|
||||
local f = CreateFrame("Frame", nil, CounterFrame); f:SetSize(200, 30)
|
||||
f:SetPoint("CENTER", CounterFrame, "CENTER", 0, 0)
|
||||
local text = f:CreateFontString(nil, "OVERLAY", "NumberFont_Outline_Huge")
|
||||
text:SetPoint("CENTER"); text:SetText(FormatNumber(amount)); text:SetTextColor(1, 0.41, 0.7)
|
||||
local ag = f:CreateAnimationGroup()
|
||||
local targetX, targetY = math.random(-120, 120), math.random(80, 150)
|
||||
local scale = ag:CreateAnimation("Scale"); scale:SetScale(1.5, 1.5); scale:SetDuration(0.15); scale:SetOrder(1)
|
||||
local translation = ag:CreateAnimation("Translation"); translation:SetOffset(targetX, targetY); translation:SetDuration(1.4); translation:SetSmoothing("OUT"); translation:SetOrder(2)
|
||||
local alpha = ag:CreateAnimation("Alpha"); alpha:SetFromAlpha(1); alpha:SetToAlpha(0); alpha:SetStartDelay(0.7); alpha:SetDuration(0.7); alpha:SetOrder(2)
|
||||
ag:SetScript("OnFinished", function() f:Hide() end); ag:Play()
|
||||
end
|
||||
text:SetPoint("CENTER"); text:SetText(FormatNumber(amount))
|
||||
|
||||
local function UpdateCounterDisplay()
|
||||
if not MoanSDB then return end
|
||||
CounterFrame.text:SetText("Moans: " .. (MoanSDB.totalMoans or 0))
|
||||
CounterFrame:SetShown(MoanSDB.showCounter and MoanSDB.active)
|
||||
CounterFrame:EnableMouse(not MoanSDB.locked)
|
||||
end
|
||||
|
||||
CounterFrame:SetScript("OnDragStart", CounterFrame.StartMoving)
|
||||
CounterFrame:SetScript("OnDragStop", function(self)
|
||||
self:StopMovingOrSizing()
|
||||
local point, _, rel, x, y = self:GetPoint()
|
||||
if MoanSDB then MoanSDB.framePos = { point, rel, x, y } end
|
||||
end)
|
||||
|
||||
local function TriggerCombo()
|
||||
local currentTime = GetTime()
|
||||
local timeout = MoanSDB and MoanSDB.comboTimeout or 4.0
|
||||
if (currentTime - lastSoundTime) > timeout or comboCount >= MAX_SOUNDS then comboCount = 1 else comboCount = comboCount + 1 end
|
||||
lastSoundTime = currentTime
|
||||
CounterFrame.Cooldown:SetCooldown(currentTime, timeout)
|
||||
return "Interface\\AddOns\\MoanS\\media\\" .. (comboCount == MAX_SOUNDS and "moan10" or (MoanSDB.soundBaseName or "moan") .. comboCount) .. ".ogg"
|
||||
if isHighCombo then
|
||||
text:SetTextColor(0, 1, 0)
|
||||
else
|
||||
text:SetTextColor(1, 0.41, 0.7)
|
||||
end
|
||||
|
||||
local MoanSPanel = CreateFrame("Frame", "MoanSConfigPanel", UIParent); MoanSPanel.name = addonName
|
||||
local category
|
||||
|
||||
local function CreateCB(parent, label, x, y, dbKey)
|
||||
local cb = CreateFrame("CheckButton", nil, parent, "InterfaceOptionsCheckButtonTemplate")
|
||||
cb:SetPoint("TOPLEFT", x, y); cb.Text:SetText(label)
|
||||
cb:SetScript("OnShow", function(self) if MoanSDB then self:SetChecked(MoanSDB[dbKey]) end end)
|
||||
cb:SetScript("OnClick", function(self) MoanSDB[dbKey] = self:GetChecked(); UpdateCounterDisplay() end)
|
||||
return cb
|
||||
local ag = f:CreateAnimationGroup()
|
||||
local targetX, targetY = math.random(-120, 120), math.random(80, 150)
|
||||
local scale = ag:CreateAnimation("Scale"); scale:SetScale(1.5, 1.5); scale:SetDuration(0.15); scale:SetOrder(1)
|
||||
local translation = ag:CreateAnimation("Translation"); translation:SetOffset(targetX, targetY); translation:SetDuration(1.4); translation:SetSmoothing("OUT"); translation:SetOrder(2)
|
||||
local alpha = ag:CreateAnimation("Alpha"); alpha:SetFromAlpha(1); alpha:SetToAlpha(0); alpha:SetStartDelay(0.7); alpha:SetDuration(0.7); alpha:SetOrder(2)
|
||||
ag:SetScript("OnFinished", function() f:Hide() end); ag:Play()
|
||||
end
|
||||
|
||||
frame:SetScript("OnEvent", function(self, event, arg1)
|
||||
if event == "ADDON_LOADED" and arg1 == addonName then
|
||||
if not MoanSDB then MoanSDB = CopyTable(defaults) end
|
||||
for k, v in pairs(defaults) do if MoanSDB[k] == nil then MoanSDB[k] = v end end
|
||||
category = Settings.RegisterCanvasLayoutCategory(MoanSPanel, addonName)
|
||||
Settings.RegisterAddOnCategory(category)
|
||||
local function UpdateCounterDisplay()
|
||||
if not MoanSDB then return end
|
||||
CounterFrame.text:SetText("Moans: " .. (MoanSDB.totalMoans or 0))
|
||||
CounterFrame:SetShown(MoanSDB.showCounter and MoanSDB.active)
|
||||
CounterFrame:EnableMouse(not MoanSDB.locked)
|
||||
end
|
||||
|
||||
local title = MoanSPanel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
|
||||
title:SetPoint("TOPLEFT", 16, -16); title:SetText("|cffFF69B4MoanS|r - Retail")
|
||||
CounterFrame:SetScript("OnDragStart", CounterFrame.StartMoving)
|
||||
CounterFrame:SetScript("OnDragStop", function(self)
|
||||
self:StopMovingOrSizing()
|
||||
local point, _, rel, x, y = self:GetPoint()
|
||||
if MoanSDB then MoanSDB.framePos = { point, rel, x, y } end
|
||||
end)
|
||||
|
||||
CreateCB(MoanSPanel, "Addon Aktiviert", 16, -50, "active")
|
||||
CreateCB(MoanSPanel, "Fenster anzeigen", 16, -80, "showCounter")
|
||||
CreateCB(MoanSPanel, "Fenster fixieren (Lock)", 16, -110, "locked")
|
||||
local function GetNextSound()
|
||||
local currentTime = GetTime()
|
||||
local timeout = MoanSDB and MoanSDB.comboTimeout or 4.0
|
||||
|
||||
local slider = CreateFrame("Slider", "MoanSTimeoutSlider", MoanSPanel, "OptionsSliderTemplate")
|
||||
slider:SetPoint("TOPLEFT", 20, -160); slider:SetMinMaxValues(0.5, 10.0); slider:SetValueStep(0.5); slider:SetWidth(180)
|
||||
_G[slider:GetName().."Low"]:SetText("0.5s"); _G[slider:GetName().."High"]:SetText("10s")
|
||||
local sliderVal = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
|
||||
sliderVal:SetPoint("BOTTOM", slider, "TOP", 0, 5)
|
||||
slider:SetScript("OnValueChanged", function(s, val)
|
||||
val = math.floor(val * 2 + 0.5) / 2
|
||||
MoanSDB.comboTimeout = val
|
||||
sliderVal:SetText("Combo-Zeit: "..val.."s")
|
||||
end)
|
||||
slider:SetValue(MoanSDB.comboTimeout)
|
||||
if (currentTime - lastSoundTime) > timeout then
|
||||
comboCount = 1
|
||||
else
|
||||
comboCount = comboCount + 1
|
||||
end
|
||||
|
||||
local btnTest = CreateFrame("Button", nil, MoanSPanel, "UIPanelButtonTemplate")
|
||||
btnTest:SetPoint("TOPLEFT", 16, -210); btnTest:SetSize(160, 25); btnTest:SetText("Feuerwerk Testen")
|
||||
btnTest:SetScript("OnClick", function() PlaySoundFile(TriggerCombo(), "Master"); ShowCritText(math.random(100, 5000)) end)
|
||||
lastSoundTime = currentTime
|
||||
CounterFrame.Cooldown:SetCooldown(currentTime, timeout)
|
||||
|
||||
if MoanSDB.framePos then
|
||||
CounterFrame:ClearAllPoints()
|
||||
CounterFrame:SetPoint(MoanSDB.framePos[1], UIParent, MoanSDB.framePos[2], MoanSDB.framePos[3], MoanSDB.framePos[4])
|
||||
local soundIndex = comboCount % 10
|
||||
if soundIndex == 0 then soundIndex = 10 end
|
||||
|
||||
local sFile = (MoanSDB.soundBaseName or "moan") .. soundIndex .. ".ogg"
|
||||
local isHigh = comboCount >= 10
|
||||
|
||||
return "Interface\\AddOns\\MoanS\\media\\" .. sFile, comboCount, isHigh
|
||||
end
|
||||
UpdateCounterDisplay()
|
||||
elseif event == "COMBAT_LOG_EVENT_UNFILTERED" then
|
||||
if not MoanSDB or not MoanSDB.active then return end
|
||||
local _, sub, _, sGUID, _, _, _, _, _, _, _, arg12, _, _, _, arg15, _, arg17, arg18, _, arg21 = CombatLogGetCurrentEventInfo()
|
||||
if sGUID == UnitGUID("player") or sGUID == UnitGUID("pet") then
|
||||
local isCrit, amount = false, 0
|
||||
if sub == "SWING_DAMAGE" then amount, isCrit = arg12, arg17
|
||||
elseif sub:find("_DAMAGE") then amount, isCrit = arg15, arg21
|
||||
elseif sub == "SPELL_HEAL" then amount, isCrit = arg15, arg18 end
|
||||
if isCrit then PlaySoundFile(TriggerCombo(), "Master"); ShowCritText(amount); MoanSDB.totalMoans = MoanSDB.totalMoans + 1; UpdateCounterDisplay() end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
SLASH_MOANS1 = "/moans"
|
||||
SlashCmdList["MOANS"] = function() if category and category.GetID then Settings.OpenToCategory(category:GetID()) end end
|
||||
local MoanSPanel = CreateFrame("Frame", "MoanSConfigPanel", UIParent)
|
||||
local category
|
||||
|
||||
local function CreateCB(parent, label, x, y, dbKey)
|
||||
local cb = CreateFrame("CheckButton", nil, parent, "InterfaceOptionsCheckButtonTemplate")
|
||||
cb:SetPoint("TOPLEFT", x, y); cb.Text:SetText(label)
|
||||
cb:SetScript("OnShow", function(self) if MoanSDB then self:SetChecked(MoanSDB[dbKey]) end end)
|
||||
cb:SetScript("OnClick", function(self) MoanSDB[dbKey] = self:GetChecked(); UpdateCounterDisplay() end)
|
||||
return cb
|
||||
end
|
||||
|
||||
frame:SetScript("OnEvent", function(self, event, arg1)
|
||||
if event == "ADDON_LOADED" and arg1 == addonName then
|
||||
if not MoanSDB then MoanSDB = CopyTable(defaults) end
|
||||
for k, v in pairs(defaults) do if MoanSDB[k] == nil then MoanSDB[k] = v end end
|
||||
|
||||
category = Settings.RegisterCanvasLayoutCategory(MoanSPanel, MOAN_NAME)
|
||||
Settings.RegisterAddOnCategory(category)
|
||||
|
||||
local title = MoanSPanel:CreateFontString(nil, "ARTWORK", "GameFontNormalLarge")
|
||||
title:SetPoint("TOPLEFT", 16, -16); title:SetText(MOAN_NAME .. " - Retail")
|
||||
|
||||
CreateCB(MoanSPanel, "Addon Aktiviert", 16, -50, "active")
|
||||
CreateCB(MoanSPanel, "Chat Nachrichten", 16, -80, "chat")
|
||||
CreateCB(MoanSPanel, "Fenster anzeigen", 16, -110, "showCounter")
|
||||
CreateCB(MoanSPanel, "Fenster fixieren (Lock)", 16, -140, "locked")
|
||||
CreateCB(MoanSPanel, "Pet Crits zählen", 16, -170, "petEnabled")
|
||||
CreateCB(MoanSPanel, "Heil-Crits zählen", 16, -200, "healEnabled")
|
||||
|
||||
local slider = CreateFrame("Slider", "MoanSTimeoutSlider", MoanSPanel, "OptionsSliderTemplate")
|
||||
slider:SetPoint("TOPLEFT", 20, -250); slider:SetMinMaxValues(0.5, 10.0); slider:SetValueStep(0.5); slider:SetWidth(180)
|
||||
_G[slider:GetName().."Low"]:SetText("0.5s"); _G[slider:GetName().."High"]:SetText("10s")
|
||||
local sliderVal = slider:CreateFontString(nil, "ARTWORK", "GameFontHighlight")
|
||||
sliderVal:SetPoint("BOTTOM", slider, "TOP", 0, 5)
|
||||
slider:SetScript("OnValueChanged", function(s, val)
|
||||
val = math.floor(val * 2 + 0.5) / 2
|
||||
MoanSDB.comboTimeout = val
|
||||
sliderVal:SetText("Combo-Zeit: "..val.."s")
|
||||
end)
|
||||
slider:SetValue(MoanSDB.comboTimeout)
|
||||
|
||||
local btnTest = CreateFrame("Button", nil, MoanSPanel, "UIPanelButtonTemplate")
|
||||
btnTest:SetPoint("TOPLEFT", 16, -300); btnTest:SetSize(160, 25); btnTest:SetText("Combo Testen")
|
||||
btnTest:SetScript("OnClick", function()
|
||||
local sPath, cIdx, isHigh = GetNextSound()
|
||||
local amount = math.random(100, 5000)
|
||||
PlaySoundFile(sPath, "Master")
|
||||
ShowCritText(amount, isHigh)
|
||||
if MoanSDB.chat then
|
||||
local prefix = isHigh and (COMBO_COLOR .. "[ULTRA COMBO x" .. cIdx .. "]|r") or ("[Combo " .. cIdx .. "/9]")
|
||||
print(MOAN_TEXT .. " " .. prefix .. " Crit: " .. FormatNumber(amount))
|
||||
end
|
||||
end)
|
||||
|
||||
if MoanSDB.framePos then
|
||||
CounterFrame:ClearAllPoints(); CounterFrame:SetPoint(MoanSDB.framePos[1], UIParent, MoanSDB.framePos[2], MoanSDB.framePos[3], MoanSDB.framePos[4])
|
||||
end
|
||||
UpdateCounterDisplay()
|
||||
elseif event == "COMBAT_LOG_EVENT_UNFILTERED" then
|
||||
if not MoanSDB or not MoanSDB.active then return end
|
||||
local _, sub, _, sGUID, _, _, _, _, _, _, _, a12, _, _, _, a15, _, a17, a18, _, a21 = CombatLogGetCurrentEventInfo()
|
||||
if sGUID == UnitGUID("player") or (MoanSDB.petEnabled and sGUID == UnitGUID("pet")) then
|
||||
local isCrit, amount = false, 0
|
||||
if sub == "SWING_DAMAGE" then amount, isCrit = a12, a17
|
||||
elseif sub:find("_DAMAGE") then amount, isCrit = a15, a21
|
||||
elseif sub == "SPELL_HEAL" and MoanSDB.healEnabled then amount, isCrit = a15, a18 end
|
||||
if isCrit then
|
||||
local sPath, cIdx, isHigh = GetNextSound()
|
||||
PlaySoundFile(sPath, "Master")
|
||||
ShowCritText(amount, isHigh)
|
||||
MoanSDB.totalMoans = MoanSDB.totalMoans + 1
|
||||
UpdateCounterDisplay()
|
||||
if MoanSDB.chat then
|
||||
local prefix = isHigh and (COMBO_COLOR .. "[ULTRA COMBO x" .. cIdx .. "]|r") or ("[Combo " .. cIdx .. "/9]")
|
||||
print(MOAN_TEXT .. " " .. prefix .. " Crit: " .. FormatNumber(amount) .. " (Total: " .. MoanSDB.totalMoans .. ")")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
SLASH_MOANS1 = "/moans"
|
||||
SlashCmdList["MOANS"] = function()
|
||||
if category and category.GetID then Settings.OpenToCategory(category:GetID()) end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
## Interface: 110007
|
||||
## Title: |cffFF69B4MoanS|r (Retail)
|
||||
## Notes: Spielt Combo-Sounds bei kritischen Treffern.
|
||||
## Author: DeinName
|
||||
## Version: 1.5
|
||||
## Title: |cffFF69B4MoanS|r
|
||||
## Notes: Krit-Sound Addon
|
||||
## Author: Quasimoder
|
||||
## Version: 3.1
|
||||
## SavedVariables: MoanSDB
|
||||
|
||||
MoanS.lua
|
||||
|
||||
Reference in New Issue
Block a user