2 Commits

Author SHA1 Message Date
Git Admin
b3fe60a657 Release 3.10.1 2025-01-29 20:27:52 +00:00
ed5c5089b3 Automagically tag shit
All checks were successful
Release Workflow / release (push) Successful in 6s
2025-01-29 21:27:44 +01:00
40 changed files with 7598 additions and 8503 deletions

87
.github/workflows/release.yml vendored Normal file
View File

@@ -0,0 +1,87 @@
name: Release Workflow
on: [push]
jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Install zip
run: sudo apt-get install zip
- name: Configure Git
run: |
git config --global user.name "Git Admin"
git config --global user.email "gitadmin@quack-lab.dev"
- name: Run deploy script
run: bash deploy.sh
- name: Check for Existing Release Commit
id: check_release_commit
run: |
# Check if the latest commit is a release commit
if git log -1 --pretty=%B | grep -q "Release"; then
echo "Release commit found. Skipping version bump."
echo "::set-output name=release_commit::true"
else
echo "No release commit found. Proceeding with version bump."
echo "::set-output name=release_commit::false"
fi
- name: Run Release Script
if: steps.check_release_commit.outputs.release_commit == 'false'
run: bash release.sh
- name: Push Changes
if: steps.check_release_commit.outputs.release_commit == 'false'
run: |
git push origin HEAD:refs/heads/master --tags
- name: Determine Tag
id: determine_tag
run: |
# Check if the last commit has a tag
TAG=$(git describe --tags --exact-match 2>/dev/null || echo "")
if [ -z "$TAG" ]; then
# Get the latest tag
LATEST_TAG=$(git describe --tags `git rev-list --tags --max-count=1`)
# Increment the minor version
IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_TAG"
VERSION_PARTS[2]=$((VERSION_PARTS[2]+1))
TAG="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}"
# Create a new tag
git tag $TAG
git push origin $TAG
fi
echo "::set-output name=tag::$TAG"
- name: Create Release
id: create_release
run: |
curl -X POST \
-H "Authorization: token ${{ secrets.JEBENI_TOKEN }}" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"tag_name": "${{ steps.determine_tag.outputs.tag }}",
"name": "${{ steps.determine_tag.outputs.tag }}",
"draft": false,
"prerelease": false
}' \
http://srv-captain--git:3000/api/v1/repos/dave/wow-Heimdall/releases
- name: Upload Release Asset
run: |
RELEASE_ID=$(curl -s \
-H "Authorization: token ${{ secrets.JEBENI_TOKEN }}" \
http://srv-captain--git:3000/api/v1/repos/dave/wow-Heimdall/releases/tags/${{ steps.determine_tag.outputs.tag }} | jq -r '.id')
curl -X POST \
-H "Authorization: token ${{ secrets.JEBENI_TOKEN }}" \
-H "Content-Type: application/zip" \
--data-binary @Heimdall.zip \
http://srv-captain--git:3000/api/v1/repos/dave/wow-Heimdall/releases/${RELEASE_ID}/assets

1
.gitignore vendored
View File

@@ -1 +0,0 @@
scratch.lua

View File

@@ -1,5 +0,0 @@
globals = { "CykaPersistentData", "CreateFrame", "GetItemInfo", "aura_env" }
unused_args = false
max_line_length = 500
exclude_files = { "Meta/" }
global = false

View File

@@ -1,14 +0,0 @@
{
"workspace": {
"library": [
"./Meta"
]
},
"diagnostics.disable": [
"unused-local",
"unused-vararg"
],
"diagnostics.globals": [
"aura_env"
]
}

6
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,6 @@
{
"Lua.diagnostics.globals": [
"UIParent",
"BattlefieldMinimap"
]
}

View File

@@ -2,7 +2,7 @@ local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string ---@cast addonname string
local VERSION = "3.12.0" local VERSION = "3.10.1"
shared.VERSION = VERSION shared.VERSION = VERSION
local function init() local function init()
@@ -18,8 +18,7 @@ local function init()
---@field classColors table<string, string> ---@field classColors table<string, string>
---@field messenger HeimdallMessengerData ---@field messenger HeimdallMessengerData
---@field who HeimdallWhoData ---@field who HeimdallWhoData
---@field stinkyTracker StinkyTrackerData ---@field stinkyTracker HeimdallStinkyTrackerData
---@field agentTracker AgentTrackerData
---@field networkNodes string[] ---@field networkNodes string[]
---@field network HeimdallNetworkData ---@field network HeimdallNetworkData
---@field networkMessenger HeimdallNetworkMessengerData ---@field networkMessenger HeimdallNetworkMessengerData
@@ -27,7 +26,7 @@ local function init()
---@field _L fun(key: string, locale: string): string ---@field _L fun(key: string, locale: string): string
---@field _Locale Localization ---@field _Locale Localization
---@field VERSION string ---@field VERSION string
---@field dump fun(table: any, msg?: string, depth?: number): nil ---@field dumpTable fun(table: any, depth?: number): nil
---@field utf8len fun(input: string): number ---@field utf8len fun(input: string): number
---@field padString fun(input: string, targetLength: number, left?: boolean): string ---@field padString fun(input: string, targetLength: number, left?: boolean): string
---@field GetOrDefault fun(table: table<any, any>, keys: string[], default: any): any ---@field GetOrDefault fun(table: table<any, any>, keys: string[], default: any): any
@@ -36,31 +35,30 @@ local function init()
---@field Memoize fun(f: function): function ---@field Memoize fun(f: function): function
---@field GetLocaleForChannel fun(channel: string): string ---@field GetLocaleForChannel fun(channel: string): string
---@field WhoQueryService WhoQueryService ---@field WhoQueryService WhoQueryService
---@field AchievementSniffer AchievementSniffer ---@field Whoer InitTable|{ShouldNotifyForZone: fun(zone: string): boolean}
---@field AgentTracker AgentTracker ---@field Messenger InitTable
---@field BonkDetector BonkDetector ---@field Spotter InitTable
---@field Bully Bully ---@field DeathReporter InitTable
---@field CombatAlerter CombatAlerter ---@field Inviter InitTable
---@field Commander Commander ---@field Dueler InitTable
---@field Config Config ---@field Bully InitTable
---@field Configurator Configurator ---@field AgentTracker InitTable
---@field DeathReporter DeathReporter ---@field Emoter InitTable
---@field Dueler Dueler ---@field Echoer InitTable
---@field Echoer Echoer ---@field Macroer InitTable
---@field Emoter Emoter ---@field Commander InitTable
---@field Inviter Inviter ---@field StinkyTracker InitTable
---@field Macroer Macroer ---@field CombatAlerter InitTable
---@field Messenger Messenger ---@field Config InitTable
---@field MinimapTagger MinimapTagger ---@field Sniffer InitTable
---@field Network Network ---@field MinimapTagger InitTable
---@field NetworkMessenger NetworkMessenger ---@field BonkDetector InitTable
---@field Noter Noter ---@field Noter InitTable
---@field Sniffer Sniffer ---@field Network InitTable
---@field Spotter Spotter ---@field NetworkMessenger InitTable
---@field StinkyCache StinkyCache ---@field StinkyCache InitTable
---@field StinkyTracker StinkyTracker ---@field Configurator InitTable
---@field Whoer Whoer ---@field AchievementSniffer InitTable
---@field ChatSniffer ChatSniffer
--- Config --- --- Config ---
---@class HeimdallConfig ---@class HeimdallConfig
@@ -70,6 +68,7 @@ local function init()
---@field deathReporter HeimdallDeathReporterConfig ---@field deathReporter HeimdallDeathReporterConfig
---@field inviter HeimdallInviterConfig ---@field inviter HeimdallInviterConfig
---@field dueler HeimdallDuelerConfig ---@field dueler HeimdallDuelerConfig
---@field bully HeimdallBullyConfig
---@field agentTracker HeimdallAgentTrackerConfig ---@field agentTracker HeimdallAgentTrackerConfig
---@field emoter HeimdallEmoterConfig ---@field emoter HeimdallEmoterConfig
---@field echoer HeimdallEchoerConfig ---@field echoer HeimdallEchoerConfig
@@ -78,13 +77,13 @@ local function init()
---@field stinkyTracker HeimdallStinkyTrackerConfig ---@field stinkyTracker HeimdallStinkyTrackerConfig
---@field combatAlerter HeimdallCombatAlerterConfig ---@field combatAlerter HeimdallCombatAlerterConfig
---@field sniffer HeimdallSnifferConfig ---@field sniffer HeimdallSnifferConfig
---@field bonkDetector HeimdallBonkDetectorConfig
---@field noter HeimdallNoterConfig ---@field noter HeimdallNoterConfig
---@field network HeimdallNetworkConfig ---@field network HeimdallNetworkConfig
---@field networkMessenger HeimdallNetworkMessengerConfig ---@field networkMessenger HeimdallNetworkMessengerConfig
---@field configurator HeimdallConfiguratorConfig ---@field configurator HeimdallConfiguratorConfig
---@field stinkyCache HeimdallStinkyCacheConfig ---@field stinkyCache HeimdallStinkyCacheConfig
---@field achievementSniffer HeimdallAchievementSnifferConfig ---@field achievementSniffer HeimdallAchievementSnifferConfig
---@field chatSniffer HeimdallChatSnifferConfig
---@field whisperNotify table<string, string> ---@field whisperNotify table<string, string>
---@field addonPrefix string ---@field addonPrefix string
---@field stinkies table<string, boolean> ---@field stinkies table<string, boolean>
@@ -95,6 +94,201 @@ local function init()
---@field locale string ---@field locale string
---@field debug boolean ---@field debug boolean
---@class HeimdallSpotterConfig
---@field enabled boolean
---@field debug boolean
---@field everyone boolean
---@field hostile boolean
---@field alliance boolean
---@field stinky boolean
---@field channels string[]
---@field zoneOverride string?
---@field throttleTime number
---@class HeimdallWhoConfig
---@field enabled boolean
---@field debug boolean
---@field ignored table<string, boolean>
---@field channels string[]
---@field ttl number
---@field doWhisper boolean
---@field zoneNotifyFor table<string, boolean>
---@field queries string
---@class HeimdallMessengerConfig
---@field enabled boolean
---@field debug boolean
---@field interval number
---@class HeimdallDeathReporterConfig
---@field enabled boolean
---@field debug boolean
---@field throttle number
---@field doWhisper boolean
---@field channels string[]
---@field zoneOverride string?
---@field duelThrottle number
---@class HeimdallInviterConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field keyword string
---@field allAssist boolean
---@field agentsAssist boolean
---@field throttle number
---@field kickOffline boolean
---@field cleanupInterval number
---@field afkThreshold number
---@class HeimdallDuelerConfig
---@field enabled boolean
---@field debug boolean
---@field declineOther boolean
---@class HeimdallBullyConfig
---@field enabled boolean
---@field debug boolean
---@class HeimdallAgentTrackerConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@class HeimdallEmoterConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field prefix string
---@class HeimdallEchoerConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field prefix string
---@class HeimdallMacroerConfig
---@field enabled boolean
---@field debug boolean
---@field priority string[]
---@class HeimdallCommanderConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field commander string
---@field commands table<string, boolean>
---@class HeimdallStinkyTrackerConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@class HeimdallCombatAlerterConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@class HeimdallSnifferConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field throttle number
---@field zoneOverride string?
---@field stinky boolean
---@class HeimdallMinimapTaggerConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field throttle number
---@field scale number
---@field tagTTL number
---@field tagSound boolean
---@field tagSoundFile string
---@field tagSoundThrottle number
---@field tagTextureFile string
---@field alertTTL number
---@field alertSound boolean
---@field alertSoundFile string
---@field alertSoundThrottle number
---@field alertTextureFile string
---@field combatTTL number
---@field combatSound boolean
---@field combatSoundFile string
---@field combatSoundThrottle number
---@field combatTextureFile string
---@field helpTTL number
---@field helpSound boolean
---@field helpSoundFile string
---@field helpSoundThrottle number
---@field helpTextureFile string
---@class HeimdallBonkDetectorConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field throttle number
---@class HeimdallNoterConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@class HeimdallNetworkConfig
---@field enabled boolean
---@field debug boolean
---@field members string[]
---@field updateInterval number
---@class HeimdallNetworkMessengerConfig
---@field enabled boolean
---@field debug boolean
---@field interval number
---@class HeimdallConfiguratorConfig
---@field enabled boolean
---@field debug boolean
---@class HeimdallStinkyCacheConfig
---@field enabled boolean
---@field debug boolean
---@field commander string
---@field ttl number
---@class HeimdallAchievementSnifferConfig
---@field enabled boolean
---@field debug boolean
-----@field texture string
-----@field offsetX number
-----@field offsetY number
---@field rescan boolean
---@field scanInterval number
-----@field iconScale number
--- Data ---
---@class HeimdallMessengerData
---@field queue table<string, Message>
---@field ticker number?
---@class HeimdallNetworkMessengerData
---@field queue table<string, Message>
---@field ticker number?
---@class HeimdallWhoData
---@field updateTicker number?
---@field whoTicker number?
---@field ignored table<string, boolean>
---@class HeimdallStinkyTrackerData
---@field stinkies ReactiveValue
---@class HeimdallNetworkData
---@field ticker number?
---@class HeimdallStinkyCacheData
---@field stinkies table<string, {value: number, timestamp: number}>
shared.GetOrDefault = function(table, keys, default) shared.GetOrDefault = function(table, keys, default)
local value = default local value = default
if not table then return value end if not table then return value end
@@ -109,18 +303,23 @@ local function init()
break break
end end
if i == #keys then value = traverse end if i == #keys then
value = traverse
end
end end
return value return value
end end
shared.messenger = {
queue = {}
}
shared.who = {
ignored = {},
}
--/run Heimdall_Data.config.who.queries="g-\"БеспредеЛ\"|ally" --/run Heimdall_Data.config.who.queries="g-\"БеспредеЛ\"|ally"
Heimdall_Data.config = { Heimdall_Data.config = {
debug = shared.GetOrDefault(Heimdall_Data, { "config", "debug" }, false), debug = shared.GetOrDefault(Heimdall_Data, { "config", "debug" }, false),
chatSniffer = {
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "chatSniffer", "enabled" }, false),
debug = shared.GetOrDefault(Heimdall_Data, { "config", "chatSniffer", "debug" }, false),
},
spotter = { spotter = {
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "enabled" }, true), enabled = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "enabled" }, true),
debug = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "debug" }, false), debug = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "debug" }, false),
@@ -130,7 +329,7 @@ local function init()
stinky = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "stinky" }, true), stinky = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "stinky" }, true),
channels = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "channels" }, { "Agent" }), channels = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "channels" }, { "Agent" }),
zoneOverride = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "zoneOverride" }, nil), zoneOverride = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "zoneOverride" }, nil),
throttleTime = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "throttleTime" }, 10), throttleTime = shared.GetOrDefault(Heimdall_Data, { "config", "spotter", "throttleTime" }, 10)
}, },
who = { who = {
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "who", "enabled" }, false), enabled = shared.GetOrDefault(Heimdall_Data, { "config", "who", "enabled" }, false),
@@ -174,7 +373,6 @@ local function init()
kickOffline = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "kickOffline" }, false), kickOffline = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "kickOffline" }, false),
cleanupInterval = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "cleanupInterval" }, 10), cleanupInterval = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "cleanupInterval" }, 10),
afkThreshold = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "afkThreshold" }, 300), afkThreshold = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "afkThreshold" }, 300),
listeningChannel = shared.GetOrDefault(Heimdall_Data, { "config", "inviter", "listeningChannel" }, {}),
}, },
dueler = { dueler = {
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "dueler", "enabled" }, false), enabled = shared.GetOrDefault(Heimdall_Data, { "config", "dueler", "enabled" }, false),
@@ -219,7 +417,6 @@ local function init()
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "enabled" }, false), enabled = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "enabled" }, false),
debug = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "debug" }, false), debug = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "debug" }, false),
channels = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "channels" }, { "Agent" }), channels = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "channels" }, { "Agent" }),
ignoredTimeout = shared.GetOrDefault(Heimdall_Data, { "config", "stinkyTracker", "ignoredTimeout" }, 600),
}, },
combatAlerter = { combatAlerter = {
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "combatAlerter", "enabled" }, false), enabled = shared.GetOrDefault(Heimdall_Data, { "config", "combatAlerter", "enabled" }, false),
@@ -230,11 +427,7 @@ local function init()
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "enabled" }, false), enabled = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "enabled" }, false),
debug = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "debug" }, false), debug = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "debug" }, false),
delegates = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "delegates" }, {}), delegates = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "delegates" }, {}),
masterChannel = shared.GetOrDefault( masterChannel = shared.GetOrDefault(Heimdall_Data, { "config", "messageDelegator", "masterChannel" }, "Agent"),
Heimdall_Data,
{ "config", "messageDelegator", "masterChannel" },
"Agent"
),
}, },
sniffer = { sniffer = {
enabled = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "enabled" }, false), enabled = shared.GetOrDefault(Heimdall_Data, { "config", "sniffer", "enabled" }, false),
@@ -252,71 +445,37 @@ local function init()
scale = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "scale" }, 3), scale = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "scale" }, 3),
tagTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagTTL" }, 1), tagTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagTTL" }, 1),
tagSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagSound" }, false), tagSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagSound" }, false),
tagSoundFile = shared.GetOrDefault( tagSoundFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagSoundFile" },
Heimdall_Data, "MGSSpot.ogg"),
{ "config", "minimapTagger", "tagSoundFile" },
"MGSSpot.ogg"
),
tagSoundThrottle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagSoundThrottle" }, 0), tagSoundThrottle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagSoundThrottle" }, 0),
tagTextureFile = shared.GetOrDefault( tagTextureFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "tagTextureFile" },
Heimdall_Data, "Aura4.tga"),
{ "config", "minimapTagger", "tagTextureFile" },
"Aura4.tga"
),
--- ---
alertTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertTTL" }, 1), alertTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertTTL" }, 1),
alertSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertSound" }, false), alertSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertSound" }, false),
alertSoundFile = shared.GetOrDefault( alertSoundFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertSoundFile" },
Heimdall_Data, "OOF.ogg"),
{ "config", "minimapTagger", "alertSoundFile" }, alertSoundThrottle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertSoundThrottle" },
"OOF.ogg" 0),
), alertTextureFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "alertTextureFile" },
alertSoundThrottle = shared.GetOrDefault( "Aura27.tga"),
Heimdall_Data,
{ "config", "minimapTagger", "alertSoundThrottle" },
0
),
alertTextureFile = shared.GetOrDefault(
Heimdall_Data,
{ "config", "minimapTagger", "alertTextureFile" },
"Aura27.tga"
),
--- ---
combatTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatTTL" }, 1), combatTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatTTL" }, 1),
combatSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatSound" }, false), combatSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatSound" }, false),
combatSoundFile = shared.GetOrDefault( combatSoundFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatSoundFile" },
Heimdall_Data, "StarScream.ogg"),
{ "config", "minimapTagger", "combatSoundFile" }, combatSoundThrottle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatSoundThrottle" },
"StarScream.ogg" 2),
), combatTextureFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "combatTextureFile" },
combatSoundThrottle = shared.GetOrDefault( "Aura58.tga"),
Heimdall_Data,
{ "config", "minimapTagger", "combatSoundThrottle" },
2
),
combatTextureFile = shared.GetOrDefault(
Heimdall_Data,
{ "config", "minimapTagger", "combatTextureFile" },
"Aura58.tga"
),
--- ---
helpTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpTTL" }, 1), helpTTL = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpTTL" }, 1),
helpSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpSound" }, false), helpSound = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpSound" }, false),
helpSoundFile = shared.GetOrDefault( helpSoundFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpSoundFile" },
Heimdall_Data, "MedicGangsterParadise.ogg"),
{ "config", "minimapTagger", "helpSoundFile" }, helpSoundThrottle = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpSoundThrottle" }, 2),
"MedicGangsterParadise.ogg" helpTextureFile = shared.GetOrDefault(Heimdall_Data, { "config", "minimapTagger", "helpTextureFile" },
), "Aura68.tga"),
helpSoundThrottle = shared.GetOrDefault(
Heimdall_Data,
{ "config", "minimapTagger", "helpSoundThrottle" },
2
),
helpTextureFile = shared.GetOrDefault(
Heimdall_Data,
{ "config", "minimapTagger", "helpTextureFile" },
"Aura68.tga"
),
}, },
whisperNotify = shared.GetOrDefault(Heimdall_Data, { "config", "whisperNotify" }, {}), whisperNotify = shared.GetOrDefault(Heimdall_Data, { "config", "whisperNotify" }, {}),
stinkies = shared.GetOrDefault(Heimdall_Data, { "config", "stinkies" }, {}), stinkies = shared.GetOrDefault(Heimdall_Data, { "config", "stinkies" }, {}),
@@ -391,7 +550,7 @@ local function init()
["Void Elf"] = "Alliance", ["Void Elf"] = "Alliance",
["Lightforged Draenei"] = "Alliance", ["Lightforged Draenei"] = "Alliance",
["Mechagnome"] = "Alliance", ["Mechagnome"] = "Alliance",
["Mag'har Orc"] = "Horde", ["Mag'har Orc"] = "Horde"
} }
shared.classColors = { shared.classColors = {
@@ -406,13 +565,15 @@ local function init()
["Warlock"] = "8788EE", ["Warlock"] = "8788EE",
["Monk"] = "00FF98", ["Monk"] = "00FF98",
["Druid"] = "FF7C0A", ["Druid"] = "FF7C0A",
["Demon Hunter"] = "A330C9", ["Demon Hunter"] = "A330C9"
} }
---@param input string ---@param input string
---@return number ---@return number
shared.utf8len = function(input) shared.utf8len = function(input)
if not input then return 0 end if not input then
return 0
end
local len = 0 local len = 0
local i = 1 local i = 1
local n = #input local n = #input
@@ -454,7 +615,9 @@ local function init()
---@param deliminer string ---@param deliminer string
---@return table<number, string> ---@return table<number, string>
shared.Split = function(input, deliminer) shared.Split = function(input, deliminer)
if deliminer == nil then deliminer = "%s" end if deliminer == nil then
deliminer = "%s"
end
local t = {} local t = {}
for str in string.gmatch(input, "([^" .. deliminer .. "]+)") do for str in string.gmatch(input, "([^" .. deliminer .. "]+)") do
table.insert(t, str) table.insert(t, str)
@@ -472,8 +635,10 @@ local function init()
shared.Memoize = function(f) shared.Memoize = function(f)
local mem = {} -- memoizing table local mem = {} -- memoizing table
setmetatable(mem, { __mode = "kv" }) -- make it weak setmetatable(mem, { __mode = "kv" }) -- make it weak
return function(x) -- new version of 'f', with memoizing return function(x) -- new version of f, with memoizing
if Heimdall_Data.config.debug then print(string.format("[Heimdall] Memoize %s", tostring(x))) end if Heimdall_Data.config.debug then
print(string.format("[Heimdall] Memoize %s", tostring(x)))
end
local r = mem[x] local r = mem[x]
if r == nil then -- no previous result? if r == nil then -- no previous result?
if Heimdall_Data.config.debug then if Heimdall_Data.config.debug then
@@ -494,20 +659,22 @@ local function init()
---@param channel string ---@param channel string
---@return string ---@return string
shared.GetLocaleForChannel = function(channel) return Heimdall_Data.config.channelLocale[channel] or "en" end shared.GetLocaleForChannel = function(channel)
return Heimdall_Data.config.channelLocale[channel] or "en"
end
---@param key string ---@param key string
---@param locale string ---@param locale string
---@return string ---@return string
shared._L = function(key, locale) shared._L = function(key, locale)
local localeTable = shared._Locale[locale] local locale = shared._Locale[locale]
if not localeTable then if not locale then
if Heimdall_Data.config.debug then if Heimdall_Data.config.debug then
print(string.format("[Heimdall] Locale %s not found", tostring(locale))) print(string.format("[Heimdall] Locale %s not found", tostring(locale)))
end end
return key return key
end end
local value = localeTable[key] local value = locale[key]
if not value then if not value then
if Heimdall_Data.config.debug then if Heimdall_Data.config.debug then
print(string.format("[Heimdall] Key %s not found in locale %s", tostring(key), tostring(locale))) print(string.format("[Heimdall] Key %s not found in locale %s", tostring(key), tostring(locale)))
@@ -539,78 +706,13 @@ local function init()
shared.Configurator.Init() shared.Configurator.Init()
shared.StinkyCache.Init() shared.StinkyCache.Init()
shared.AchievementSniffer.Init() shared.AchievementSniffer.Init()
shared.ChatSniffer.Init()
print("Heimdall loaded!") print("Heimdall loaded!")
end end
local loadedFrame = CreateFrame("Frame") local loadedFrame = CreateFrame("Frame")
loadedFrame:RegisterEvent("ADDON_LOADED") loadedFrame:RegisterEvent("ADDON_LOADED")
loadedFrame:SetScript("OnEvent", function(self, event, addonName) loadedFrame:SetScript("OnEvent", function(self, event, addonName)
if addonName == addonname then init() end if addonName == addonname then
end) init()
-- Create the import/export frame
local ccpFrame = CreateFrame("Frame", "CCPFrame", UIParent)
ccpFrame:SetSize(512 * 1.5, 512 * 1.5)
ccpFrame:SetPoint("CENTER")
ccpFrame:SetFrameStrata("HIGH")
ccpFrame:EnableMouse(true)
ccpFrame:SetMovable(true)
ccpFrame:SetResizable(false)
ccpFrame:SetBackdrop({
bgFile = "Interface/Tooltips/UI-Tooltip-Background",
edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
tile = true,
tileSize = 4,
edgeSize = 4,
insets = {
left = 4,
right = 4,
top = 4,
bottom = 4,
},
})
ccpFrame:SetBackdropColor(0, 0, 0, 0.8)
ccpFrame:SetBackdropBorderColor(0.5, 0.5, 0.5, 1)
ccpFrame:SetMovable(true)
ccpFrame:EnableMouse(true)
ccpFrame:RegisterForDrag("LeftButton")
ccpFrame:SetScript("OnDragStart", function(self) self:StartMoving() end)
ccpFrame:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
ccpFrame:SetScript("OnShow", function(self) self:SetScale(1) end)
ccpFrame:Hide()
-- Create scroll frame
local scrollFrame = CreateFrame("ScrollFrame", "CCPFrameScrollFrame", ccpFrame, "UIPanelScrollFrameTemplate")
scrollFrame:SetPoint("TOPLEFT", ccpFrame, "TOPLEFT", 10, -10)
scrollFrame:SetPoint("BOTTOMRIGHT", ccpFrame, "BOTTOMRIGHT", -30, 10)
-- Create the text box
local ccpFrameTextBox = CreateFrame("EditBox", "CCPFrameTextBox", scrollFrame)
ccpFrameTextBox:SetSize(512 * 1.5 - 40, 512 * 1.5 - 20)
ccpFrameTextBox:SetPoint("TOPLEFT", scrollFrame, "TOPLEFT", 0, 0)
ccpFrameTextBox:SetFont("Fonts\\FRIZQT__.ttf", 12)
ccpFrameTextBox:SetTextColor(1, 1, 1, 1)
ccpFrameTextBox:SetTextInsets(10, 10, 10, 10)
ccpFrameTextBox:SetMultiLine(true)
ccpFrameTextBox:SetAutoFocus(true)
ccpFrameTextBox:SetMaxLetters(1000000)
ccpFrameTextBox:SetScript("OnEscapePressed", function(self) ccpFrame:Hide() end)
-- Set the scroll frame's scroll child
scrollFrame:SetScrollChild(ccpFrameTextBox)
CCP = function(window)
window = window or 1
local charFrame = _G["ChatFrame" .. window]
local maxLines = charFrame:GetNumMessages() or 0
local chat = {}
for i = 1, maxLines do
local currentMsg = charFrame:GetMessageInfo(i)
chat[#chat + 1] = currentMsg
end end
ccpFrameTextBox:SetText(table.concat(chat, "\n")) end)
ccpFrame:Show()
ccpFrameTextBox:SetFocus()
end

View File

@@ -1,9 +1,9 @@
## Interface: 70300 ## Interface: 70300
## Title: Heimdall ## Title: Heimdall
## Version: 3.12.0 ## Version: 3.10.1
## Notes: Watches over areas and alerts when hostiles spotted ## Notes: Watches over areas and alerts when hostiles spotted
## Author: Cyka ## Author: Cyka
## SavedVariables: Heimdall_Data, Heimdall_Achievements, Heimdall_Chat ## SavedVariables: Heimdall_Data, Heimdall_Achievements
_L.lua _L.lua
Modules/CLEUParser.lua Modules/CLEUParser.lua
@@ -33,5 +33,4 @@ Modules/NetworkMessenger.lua
Modules/StinkyCache.lua Modules/StinkyCache.lua
Modules/Configurator.lua Modules/Configurator.lua
Modules/AchievementSniffer.lua Modules/AchievementSniffer.lua
Modules/ChatSniffer.lua
Heimdall.lua Heimdall.lua

2
Meta

Submodule Meta updated: eee043a846...c0337ef97f

View File

@@ -1,19 +1,10 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "AchievementSniffer" local ModuleName = "AchievementSniffer"
---@class HeimdallAchievementSnifferConfig local HeimdallRoot = "Interface\\AddOns\\Heimdall\\"
---@field enabled boolean local TextureRoot = HeimdallRoot .. "Texture\\"
---@field debug boolean
-----@field texture string
-----@field offsetX number
-----@field offsetY number
---@field rescan boolean
---@field scanInterval number
-----@field iconScale number
-- local HeimdallRoot = "Interface\\AddOns\\Heimdall\\"
-- local TextureRoot = HeimdallRoot .. "Texture\\"
local Achievements = { local Achievements = {
15, 15,
@@ -84,9 +75,9 @@ local Achievements = {
12448, 12448,
} }
---@class AchievementSniffer ---@diagnostic disable-next-line: missing-fields
shared.AchievementSniffer = { shared.AchievementSniffer = {}
Init = function() function shared.AchievementSniffer.Init()
if Heimdall_Data.config.achievementSniffer.debug then if Heimdall_Data.config.achievementSniffer.debug then
print(string.format("[%s] Module initialized", ModuleName)) print(string.format("[%s] Module initialized", ModuleName))
end end
@@ -257,7 +248,9 @@ shared.AchievementSniffer = {
if Heimdall_Data.config.achievementSniffer.debug then if Heimdall_Data.config.achievementSniffer.debug then
print(string.format("[%s] Event triggered: %s for unit: %s", ModuleName, event, unit)) print(string.format("[%s] Event triggered: %s for unit: %s", ModuleName, event, unit))
end end
if event == "NAME_PLATE_UNIT_ADDED" then TryInspect(unit) end if event == "NAME_PLATE_UNIT_ADDED" then
TryInspect(unit)
end
--UpdateFrames() --UpdateFrames()
end) end)
@@ -278,6 +271,7 @@ shared.AchievementSniffer = {
Scan(name) Scan(name)
end) end)
local function Tick() local function Tick()
C_Timer.NewTimer(Heimdall_Data.config.achievementSniffer.scanInterval, Tick) C_Timer.NewTimer(Heimdall_Data.config.achievementSniffer.scanInterval, Tick)
if not Heimdall_Data.config.achievementSniffer.enabled then return end if not Heimdall_Data.config.achievementSniffer.enabled then return end
@@ -299,6 +293,5 @@ shared.AchievementSniffer = {
end end
Tick() Tick()
print(string.format("[%s] Module initialized", ModuleName)) print("[Heimdall] AchievementSniffer loaded")
end, end
}

View File

@@ -1,53 +1,11 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "AgentTracker" local ModuleName = "AgentTracker"
---@class AgentTrackerData ---@diagnostic disable-next-line: missing-fields
---@field agents ReactiveValue<table<string, string>> shared.AgentTracker = {}
function shared.AgentTracker.Init()
---@class HeimdallAgentTrackerConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@class AgentTracker
shared.AgentTracker = {
---@param name string
---@return boolean
Track = function(name)
if not name then return false end
local exists = shared.AgentTracker.IsAgent(name)
if exists then return false end
shared.agentTracker.agents[name] = date("%Y-%m-%dT%H:%M:%S")
-- Heimdall_Data.config.agents[name] = date("%Y-%m-%dT%H:%M:%S")
if Heimdall_Data.config.agentTracker.debug then
print(string.format("[%s] Tracking new agent: %s", ModuleName, name))
shared.dump(shared.agentTracker.agents)
end
return true
end,
---@param name string
---@return boolean
IsAgent = function(name)
if not name then return false end
return shared.agentTracker.agents[name] ~= nil
end,
---@param callback fun(agent: string)
OnChange = function(callback) shared.agentTracker.agents:onChange(callback) end,
---@param callback fun(agent: string)
ForEach = function(callback)
---@type table<string, string>
local agents = shared.agentTracker.agents:get()
for name, _ in pairs(agents) do
callback(name)
end
end,
---@return nil
Init = function()
shared.agentTracker = {
agents = ReactiveValue.new(Heimdall_Data.config.agents),
}
--/run Heimdall_Data.config.agents["Cyheuraeth"]=date("%Y-%m-%dT%H:%M:%S") --/run Heimdall_Data.config.agents["Cyheuraeth"]=date("%Y-%m-%dT%H:%M:%S")
---@type table<string, boolean> ---@type table<string, boolean>
local channelRosterFrame = CreateFrame("Frame") local channelRosterFrame = CreateFrame("Frame")
@@ -79,8 +37,18 @@ shared.AgentTracker = {
local newAgents = 0 local newAgents = 0
for i = 1, count do for i = 1, count do
name = GetChannelRosterInfo(index, i) local name = GetChannelRosterInfo(index, i)
shared.AgentTracker.Track(name) if name then
local isNewAgent = not Heimdall_Data.config.agents[name]
Heimdall_Data.config.agents[name] = date("%Y-%m-%dT%H:%M:%S")
if isNewAgent then
newAgents = newAgents + 1
end
if Heimdall_Data.config.agentTracker.debug then
print(string.format("[%s] %s agent: %s", ModuleName, isNewAgent and "Added new" or "Updated existing",
name))
end
end
end end
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
@@ -118,27 +86,24 @@ shared.AgentTracker = {
end end
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
shared.dumpTable(Heimdall_Data.config.agentTracker)
end end
sender = string.match(sender, "^[^-]+") sender = string.match(sender, "^[^-]+")
local new = shared.AgentTracker.Track(sender) local isNewAgent = not Heimdall_Data.config.agents[sender]
Heimdall_Data.config.agents[sender] = date("%Y-%m-%dT%H:%M:%S")
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
print( print(string.format("[%s] %s agent from message: %s", ModuleName,
string.format( isNewAgent and "Added new" or "Updated existing", sender))
"[%s] %s agent from message: %s",
ModuleName,
new and "Added new" or "Updated existing",
sender
)
)
end end
end) end)
if Heimdall_Data.config.agentTracker.debug then if Heimdall_Data.config.agentTracker.debug then
print(string.format("[%s] Module initialized", ModuleName)) local count = 0
shared.dump(shared.agentTracker.agents:get(), "Agents") for _ in pairs(Heimdall_Data.config.agents) do count = count + 1 end
print(string.format("[%s] Module initialized - Tracking %d agents", ModuleName, count))
end end
print(string.format("[%s] Module initialized", ModuleName)) print("[Heimdall] AgentTracker loaded")
end, end
}

View File

@@ -1,17 +1,11 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "BonkDetector" local ModuleName = "BonkDetector"
---@class HeimdallBonkDetectorConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.BonkDetector = {}
---@field debug boolean function shared.BonkDetector.Init()
---@field channels string[]
---@field throttle number
---@class BonkDetector
shared.BonkDetector = {
---@return nil
Init = function()
---@type table<string, number> ---@type table<string, number>
local lastReportTime = {} local lastReportTime = {}
@@ -36,23 +30,14 @@ shared.BonkDetector = {
return return
end end
---@type string|nil, string, string, string, string local source, err = CLEUParser.GetSourceName(...)
local err, source, sourceGUID, destination, destinationGUID
source, err = CLEUParser.GetSourceName(...)
if err then if err then
if Heimdall_Data.config.bonkDetector.debug then if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Error getting source name: %s", ModuleName, err)) print(string.format("[%s] Error getting source name: %s", ModuleName, err))
end end
return return
end end
sourceGUID, err = CLEUParser.GetSourceGUID(...) local sourceGUID = CLEUParser.GetSourceGUID(...)
if err then
if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Error getting source GUID: %s", ModuleName, err))
end
return
end
if not string.find(sourceGUID, "Player") then if not string.find(sourceGUID, "Player") then
if Heimdall_Data.config.bonkDetector.debug then if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Source %s is not a player, nothing to do", ModuleName, source)) print(string.format("[%s] Source %s is not a player, nothing to do", ModuleName, source))
@@ -60,20 +45,14 @@ shared.BonkDetector = {
return return
end end
destination, err = CLEUParser.GetDestName(...) local destination, err = CLEUParser.GetDestName(...)
if err then if err then
if Heimdall_Data.config.bonkDetector.debug then if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Error getting destination name: %s", ModuleName, err)) print(string.format("[%s] Error getting destination name: %s", ModuleName, err))
end end
return return
end end
destinationGUID, err = CLEUParser.GetDestGUID(...) local destinationGUID = CLEUParser.GetDestGUID(...)
if err then
if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Error getting destination GUID: %s", ModuleName, err))
end
return
end
if not string.find(destinationGUID, "Player") then if not string.find(destinationGUID, "Player") then
if Heimdall_Data.config.bonkDetector.debug then if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Destination %s is not a player, nothing to do", ModuleName, destination)) print(string.format("[%s] Destination %s is not a player, nothing to do", ModuleName, destination))
@@ -94,14 +73,8 @@ shared.BonkDetector = {
if lastReportTime[source] and (currentTime - lastReportTime[source]) < throttle then if lastReportTime[source] and (currentTime - lastReportTime[source]) < throttle then
if Heimdall_Data.config.bonkDetector.debug then if Heimdall_Data.config.bonkDetector.debug then
local timeLeft = throttle - (currentTime - lastReportTime[source]) local timeLeft = throttle - (currentTime - lastReportTime[source])
print( print(string.format("[%s] Damage report throttled for %s (%.1f seconds remaining)",
string.format( ModuleName, source, timeLeft))
"[%s] Damage report throttled for %s (%.1f seconds remaining)",
ModuleName,
source,
timeLeft
)
)
end end
return return
end end
@@ -109,15 +82,8 @@ shared.BonkDetector = {
lastReportTime[source] = currentTime lastReportTime[source] = currentTime
if Heimdall_Data.config.bonkDetector.debug then if Heimdall_Data.config.bonkDetector.debug then
print( print(string.format("[%s] Processing damage event - Source: %s, Target: %s, Type: %s",
string.format( ModuleName, source, destination, subevent))
"[%s] Processing damage event - Source: %s, Target: %s, Type: %s",
ModuleName,
source,
destination,
subevent
)
)
end end
for _, channel in pairs(Heimdall_Data.config.bonkDetector.channels) do for _, channel in pairs(Heimdall_Data.config.bonkDetector.channels) do
@@ -131,12 +97,11 @@ shared.BonkDetector = {
} }
if Heimdall_Data.config.bonkDetector.debug then if Heimdall_Data.config.bonkDetector.debug then
print(string.format("[%s] Queuing bonk detector message", ModuleName)) print(string.format("[%s] Queuing bonk detector message", ModuleName))
shared.dump(message) shared.dumpTable(message)
end end
table.insert(shared.messenger.queue, message) table.insert(shared.messenger.queue, message)
end end
end) end)
print(string.format("[%s] Module initialized", ModuleName)) print("[Heimdall] BonkDetector loaded")
end, end
}

View File

@@ -1,16 +1,13 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Bully" local ModuleName = "Bully"
---@class HeimdallBullyConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.Bully = {}
---@field debug boolean function shared.Bully.Init()
if Heimdall_Data.config.bully.debug then
---@class Bully
shared.Bully = {
---@return nil
Init = function()
if Heimdall_Data.config.bully.debug then print(string.format("[%s] Module initialized", ModuleName)) end
print(string.format("[%s] Module initialized", ModuleName)) print(string.format("[%s] Module initialized", ModuleName))
end, end
} print("[Heimdall] Bully loaded")
end

View File

@@ -12,12 +12,12 @@ local function Init()
["destGUID"] = 8, ["destGUID"] = 8,
["destName"] = 9, ["destName"] = 9,
["destFlags"] = 10, ["destFlags"] = 10,
["destRaidFlags"] = 11, ["destRaidFlags"] = 11
}, },
["GENERIC_SPELL"] = { ["GENERIC_SPELL"] = {
["spellId"] = 12, ["spellId"] = 12,
["spellName"] = 13, ["spellName"] = 13,
["spellSchool"] = 14, ["spellSchool"] = 14
}, },
["GENERIC_DAMAGE"] = { ["GENERIC_DAMAGE"] = {
["amount"] = 15, ["amount"] = 15,
@@ -29,19 +29,19 @@ local function Init()
["critical"] = 21, ["critical"] = 21,
["glancing"] = 22, ["glancing"] = 22,
["crushing"] = 23, ["crushing"] = 23,
["isOffHand"] = 24, ["isOffHand"] = 24
}, },
["GENERIC_MISSED"] = { ["GENERIC_MISSED"] = {
["missType"] = 15, ["missType"] = 15,
["isOffHand"] = 16, ["isOffHand"] = 16,
["amountMissed"] = 17, ["amountMissed"] = 17,
["critical"] = 18, ["critical"] = 18
}, },
["GENERIC_HEAL"] = { ["GENERIC_HEAL"] = {
["amount"] = 15, ["amount"] = 15,
["overhealing"] = 16, ["overhealing"] = 16,
["absorbed"] = 17, ["absorbed"] = 17,
["critical"] = 18, ["critical"] = 18
}, },
["GENERIC_HEAL_ABSORBED"] = { ["GENERIC_HEAL_ABSORBED"] = {
["extraGUID"] = 15, ["extraGUID"] = 15,
@@ -52,44 +52,44 @@ local function Init()
["extraSpellName"] = 20, ["extraSpellName"] = 20,
["extraSchool"] = 21, ["extraSchool"] = 21,
["absorbedAmount"] = 22, ["absorbedAmount"] = 22,
["totalAmount"] = 23, ["totalAmount"] = 23
}, },
["GENERIC_ENERGIZE"] = { ["GENERIC_ENERGIZE"] = {
["amount"] = 15, ["amount"] = 15,
["overEnergize"] = 16, ["overEnergize"] = 16,
["powerType"] = 17, ["powerType"] = 17
}, },
["GENERIC_DRAIN"] = { ["GENERIC_DRAIN"] = {
["amount"] = 15, ["amount"] = 15,
["powerType"] = 16, ["powerType"] = 16,
["extraAmount"] = 17, ["extraAmount"] = 17
}, },
["GENERIC_LEECH"] = { ["GENERIC_LEECH"] = {
["amount"] = 15, ["amount"] = 15,
["powerType"] = 16, ["powerType"] = 16,
["extraAmount"] = 17, ["extraAmount"] = 17
}, },
["GENERIC_INTERRUPT"] = { ["GENERIC_INTERRUPT"] = {
["extraSpellId"] = 15, ["extraSpellId"] = 15,
["extraSpellName"] = 16, ["extraSpellName"] = 16,
["extraSchool"] = 17, ["extraSchool"] = 17
}, },
["GENERIC_DISPEL"] = { ["GENERIC_DISPEL"] = {
["extraSpellId"] = 15, ["extraSpellId"] = 15,
["extraSpellName"] = 16, ["extraSpellName"] = 16,
["extraSchool"] = 17, ["extraSchool"] = 17,
["auraType"] = 18, ["auraType"] = 18
}, },
["GENERIC_DISPEL_FAILED"] = { ["GENERIC_DISPEL_FAILED"] = {
["extraSpellId"] = 15, ["extraSpellId"] = 15,
["extraSpellName"] = 16, ["extraSpellName"] = 16,
["extraSchool"] = 17, ["extraSchool"] = 17
}, },
["GENERIC_STOLEN"] = { ["GENERIC_STOLEN"] = {
["extraSpellId"] = 15, ["extraSpellId"] = 15,
["extraSpellName"] = 16, ["extraSpellName"] = 16,
["extraSchool"] = 17, ["extraSchool"] = 17,
["auraType"] = 18, ["auraType"] = 18
}, },
["GENERIC_EXTRA_ATTACKS"] = { ["amount"] = 15 }, ["GENERIC_EXTRA_ATTACKS"] = { ["amount"] = 15 },
["GENERIC_AURA_APPLIED"] = { ["auraType"] = 15, ["amount"] = 16 }, ["GENERIC_AURA_APPLIED"] = { ["auraType"] = 15, ["amount"] = 16 },
@@ -102,32 +102,38 @@ local function Init()
["extraSpellId"] = 15, ["extraSpellId"] = 15,
["extraSpellName"] = 16, ["extraSpellName"] = 16,
["extraSchool"] = 17, ["extraSchool"] = 17,
["auraType"] = 18, ["auraType"] = 18
}, },
["GENERIC_CAST_START"] = {}, ["GENERIC_CAST_START"] = {},
["GENERIC_CAST_SUCCESS"] = {}, ["GENERIC_CAST_SUCCESS"] = {},
["GENERIC_CAST_FAILED"] = {}, ["GENERIC_CAST_FAILED"] = {}
} }
CLEUEventInfo["SWING_DAMAGE"] = CLEUEventInfo["GENERIC_DAMAGE"] CLEUEventInfo["SWING_DAMAGE"] = CLEUEventInfo["GENERIC_DAMAGE"]
CLEUEventInfo["SWING_MISSED"] = CLEUEventInfo["GENERIC_MISSED"] CLEUEventInfo["SWING_MISSED"] = CLEUEventInfo["GENERIC_MISSED"]
CLEUEventInfo["SWING_HEAL"] = CLEUEventInfo["GENERIC_HEAL"] CLEUEventInfo["SWING_HEAL"] = CLEUEventInfo["GENERIC_HEAL"]
CLEUEventInfo["SWING_HEAL_ABSORBED"] = CLEUEventInfo["GENERIC_HEAL_ABSORBED"] CLEUEventInfo["SWING_HEAL_ABSORBED"] =
CLEUEventInfo["GENERIC_HEAL_ABSORBED"]
CLEUEventInfo["SWING_ENERGIZE"] = CLEUEventInfo["GENERIC_ENERGIZE"] CLEUEventInfo["SWING_ENERGIZE"] = CLEUEventInfo["GENERIC_ENERGIZE"]
CLEUEventInfo["SWING_DRAIN"] = CLEUEventInfo["GENERIC_DRAIN"] CLEUEventInfo["SWING_DRAIN"] = CLEUEventInfo["GENERIC_DRAIN"]
CLEUEventInfo["SWING_LEECH"] = CLEUEventInfo["GENERIC_LEECH"] CLEUEventInfo["SWING_LEECH"] = CLEUEventInfo["GENERIC_LEECH"]
CLEUEventInfo["SWING_INTERRUPT"] = CLEUEventInfo["GENERIC_INTERRUPT"] CLEUEventInfo["SWING_INTERRUPT"] = CLEUEventInfo["GENERIC_INTERRUPT"]
CLEUEventInfo["SWING_DISPEL"] = CLEUEventInfo["GENERIC_DISPEL"] CLEUEventInfo["SWING_DISPEL"] = CLEUEventInfo["GENERIC_DISPEL"]
CLEUEventInfo["SWING_DISPEL_FAILED"] = CLEUEventInfo["GENERIC_DISPEL_FAILED"] CLEUEventInfo["SWING_DISPEL_FAILED"] =
CLEUEventInfo["GENERIC_DISPEL_FAILED"]
CLEUEventInfo["SWING_STOLEN"] = CLEUEventInfo["GENERIC_STOLEN"] CLEUEventInfo["SWING_STOLEN"] = CLEUEventInfo["GENERIC_STOLEN"]
CLEUEventInfo["SWING_EXTRA_ATTACKS"] = CLEUEventInfo["GENERIC_EXTRA_ATTACKS"] CLEUEventInfo["SWING_EXTRA_ATTACKS"] =
CLEUEventInfo["GENERIC_EXTRA_ATTACKS"]
CLEUEventInfo["SWING_AURA_APPLIED"] = CLEUEventInfo["GENERIC_AURA_APPLIED"] CLEUEventInfo["SWING_AURA_APPLIED"] = CLEUEventInfo["GENERIC_AURA_APPLIED"]
CLEUEventInfo["SWING_AURA_REMOVED"] = CLEUEventInfo["GENERIC_AURA_REMOVED"] CLEUEventInfo["SWING_AURA_REMOVED"] = CLEUEventInfo["GENERIC_AURA_REMOVED"]
CLEUEventInfo["SWING_AURA_APPLIED_DOSE"] = CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"] CLEUEventInfo["SWING_AURA_APPLIED_DOSE"] =
CLEUEventInfo["SWING_AURA_REMOVED_DOSE"] = CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"] CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"]
CLEUEventInfo["SWING_AURA_REMOVED_DOSE"] =
CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"]
CLEUEventInfo["SWING_AURA_REFRESH"] = CLEUEventInfo["GENERIC_AURA_REFRESH"] CLEUEventInfo["SWING_AURA_REFRESH"] = CLEUEventInfo["GENERIC_AURA_REFRESH"]
CLEUEventInfo["SWING_AURA_BROKEN"] = CLEUEventInfo["GENERIC_AURA_BROKEN"] CLEUEventInfo["SWING_AURA_BROKEN"] = CLEUEventInfo["GENERIC_AURA_BROKEN"]
CLEUEventInfo["SWING_AURA_BROKEN_SPELL"] = CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"] CLEUEventInfo["SWING_AURA_BROKEN_SPELL"] =
CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"]
CLEUEventInfo["SWING_CAST_START"] = CLEUEventInfo["GENERIC_CAST_START"] CLEUEventInfo["SWING_CAST_START"] = CLEUEventInfo["GENERIC_CAST_START"]
CLEUEventInfo["SWING_CAST_SUCCESS"] = CLEUEventInfo["GENERIC_CAST_SUCCESS"] CLEUEventInfo["SWING_CAST_SUCCESS"] = CLEUEventInfo["GENERIC_CAST_SUCCESS"]
CLEUEventInfo["SWING_CAST_FAILED"] = CLEUEventInfo["GENERIC_CAST_FAILED"] CLEUEventInfo["SWING_CAST_FAILED"] = CLEUEventInfo["GENERIC_CAST_FAILED"]
@@ -135,22 +141,28 @@ local function Init()
CLEUEventInfo["RANGE_DAMAGE"] = CLEUEventInfo["GENERIC_DAMAGE"] CLEUEventInfo["RANGE_DAMAGE"] = CLEUEventInfo["GENERIC_DAMAGE"]
CLEUEventInfo["RANGE_MISSED"] = CLEUEventInfo["GENERIC_MISSED"] CLEUEventInfo["RANGE_MISSED"] = CLEUEventInfo["GENERIC_MISSED"]
CLEUEventInfo["RANGE_HEAL"] = CLEUEventInfo["GENERIC_HEAL"] CLEUEventInfo["RANGE_HEAL"] = CLEUEventInfo["GENERIC_HEAL"]
CLEUEventInfo["RANGE_HEAL_ABSORBED"] = CLEUEventInfo["GENERIC_HEAL_ABSORBED"] CLEUEventInfo["RANGE_HEAL_ABSORBED"] =
CLEUEventInfo["GENERIC_HEAL_ABSORBED"]
CLEUEventInfo["RANGE_ENERGIZE"] = CLEUEventInfo["GENERIC_ENERGIZE"] CLEUEventInfo["RANGE_ENERGIZE"] = CLEUEventInfo["GENERIC_ENERGIZE"]
CLEUEventInfo["RANGE_DRAIN"] = CLEUEventInfo["GENERIC_DRAIN"] CLEUEventInfo["RANGE_DRAIN"] = CLEUEventInfo["GENERIC_DRAIN"]
CLEUEventInfo["RANGE_LEECH"] = CLEUEventInfo["GENERIC_LEECH"] CLEUEventInfo["RANGE_LEECH"] = CLEUEventInfo["GENERIC_LEECH"]
CLEUEventInfo["RANGE_INTERRUPT"] = CLEUEventInfo["GENERIC_INTERRUPT"] CLEUEventInfo["RANGE_INTERRUPT"] = CLEUEventInfo["GENERIC_INTERRUPT"]
CLEUEventInfo["RANGE_DISPEL"] = CLEUEventInfo["GENERIC_DISPEL"] CLEUEventInfo["RANGE_DISPEL"] = CLEUEventInfo["GENERIC_DISPEL"]
CLEUEventInfo["RANGE_DISPEL_FAILED"] = CLEUEventInfo["GENERIC_DISPEL_FAILED"] CLEUEventInfo["RANGE_DISPEL_FAILED"] =
CLEUEventInfo["GENERIC_DISPEL_FAILED"]
CLEUEventInfo["RANGE_STOLEN"] = CLEUEventInfo["GENERIC_STOLEN"] CLEUEventInfo["RANGE_STOLEN"] = CLEUEventInfo["GENERIC_STOLEN"]
CLEUEventInfo["RANGE_EXTRA_ATTACKS"] = CLEUEventInfo["GENERIC_EXTRA_ATTACKS"] CLEUEventInfo["RANGE_EXTRA_ATTACKS"] =
CLEUEventInfo["GENERIC_EXTRA_ATTACKS"]
CLEUEventInfo["RANGE_AURA_APPLIED"] = CLEUEventInfo["GENERIC_AURA_APPLIED"] CLEUEventInfo["RANGE_AURA_APPLIED"] = CLEUEventInfo["GENERIC_AURA_APPLIED"]
CLEUEventInfo["RANGE_AURA_REMOVED"] = CLEUEventInfo["GENERIC_AURA_REMOVED"] CLEUEventInfo["RANGE_AURA_REMOVED"] = CLEUEventInfo["GENERIC_AURA_REMOVED"]
CLEUEventInfo["RANGE_AURA_APPLIED_DOSE"] = CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"] CLEUEventInfo["RANGE_AURA_APPLIED_DOSE"] =
CLEUEventInfo["RANGE_AURA_REMOVED_DOSE"] = CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"] CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"]
CLEUEventInfo["RANGE_AURA_REMOVED_DOSE"] =
CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"]
CLEUEventInfo["RANGE_AURA_REFRESH"] = CLEUEventInfo["GENERIC_AURA_REFRESH"] CLEUEventInfo["RANGE_AURA_REFRESH"] = CLEUEventInfo["GENERIC_AURA_REFRESH"]
CLEUEventInfo["RANGE_AURA_BROKEN"] = CLEUEventInfo["GENERIC_AURA_BROKEN"] CLEUEventInfo["RANGE_AURA_BROKEN"] = CLEUEventInfo["GENERIC_AURA_BROKEN"]
CLEUEventInfo["RANGE_AURA_BROKEN_SPELL"] = CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"] CLEUEventInfo["RANGE_AURA_BROKEN_SPELL"] =
CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"]
CLEUEventInfo["RANGE_CAST_START"] = CLEUEventInfo["GENERIC_CAST_START"] CLEUEventInfo["RANGE_CAST_START"] = CLEUEventInfo["GENERIC_CAST_START"]
CLEUEventInfo["RANGE_CAST_SUCCESS"] = CLEUEventInfo["GENERIC_CAST_SUCCESS"] CLEUEventInfo["RANGE_CAST_SUCCESS"] = CLEUEventInfo["GENERIC_CAST_SUCCESS"]
CLEUEventInfo["RANGE_CAST_FAILED"] = CLEUEventInfo["GENERIC_CAST_FAILED"] CLEUEventInfo["RANGE_CAST_FAILED"] = CLEUEventInfo["GENERIC_CAST_FAILED"]
@@ -158,22 +170,28 @@ local function Init()
CLEUEventInfo["SPELL_DAMAGE"] = CLEUEventInfo["GENERIC_DAMAGE"] CLEUEventInfo["SPELL_DAMAGE"] = CLEUEventInfo["GENERIC_DAMAGE"]
CLEUEventInfo["SPELL_MISSED"] = CLEUEventInfo["GENERIC_MISSED"] CLEUEventInfo["SPELL_MISSED"] = CLEUEventInfo["GENERIC_MISSED"]
CLEUEventInfo["SPELL_HEAL"] = CLEUEventInfo["GENERIC_HEAL"] CLEUEventInfo["SPELL_HEAL"] = CLEUEventInfo["GENERIC_HEAL"]
CLEUEventInfo["SPELL_HEAL_ABSORBED"] = CLEUEventInfo["GENERIC_HEAL_ABSORBED"] CLEUEventInfo["SPELL_HEAL_ABSORBED"] =
CLEUEventInfo["GENERIC_HEAL_ABSORBED"]
CLEUEventInfo["SPELL_ENERGIZE"] = CLEUEventInfo["GENERIC_ENERGIZE"] CLEUEventInfo["SPELL_ENERGIZE"] = CLEUEventInfo["GENERIC_ENERGIZE"]
CLEUEventInfo["SPELL_DRAIN"] = CLEUEventInfo["GENERIC_DRAIN"] CLEUEventInfo["SPELL_DRAIN"] = CLEUEventInfo["GENERIC_DRAIN"]
CLEUEventInfo["SPELL_LEECH"] = CLEUEventInfo["GENERIC_LEECH"] CLEUEventInfo["SPELL_LEECH"] = CLEUEventInfo["GENERIC_LEECH"]
CLEUEventInfo["SPELL_INTERRUPT"] = CLEUEventInfo["GENERIC_INTERRUPT"] CLEUEventInfo["SPELL_INTERRUPT"] = CLEUEventInfo["GENERIC_INTERRUPT"]
CLEUEventInfo["SPELL_DISPEL"] = CLEUEventInfo["GENERIC_DISPEL"] CLEUEventInfo["SPELL_DISPEL"] = CLEUEventInfo["GENERIC_DISPEL"]
CLEUEventInfo["SPELL_DISPEL_FAILED"] = CLEUEventInfo["GENERIC_DISPEL_FAILED"] CLEUEventInfo["SPELL_DISPEL_FAILED"] =
CLEUEventInfo["GENERIC_DISPEL_FAILED"]
CLEUEventInfo["SPELL_STOLEN"] = CLEUEventInfo["GENERIC_STOLEN"] CLEUEventInfo["SPELL_STOLEN"] = CLEUEventInfo["GENERIC_STOLEN"]
CLEUEventInfo["SPELL_EXTRA_ATTACKS"] = CLEUEventInfo["GENERIC_EXTRA_ATTACKS"] CLEUEventInfo["SPELL_EXTRA_ATTACKS"] =
CLEUEventInfo["GENERIC_EXTRA_ATTACKS"]
CLEUEventInfo["SPELL_AURA_APPLIED"] = CLEUEventInfo["GENERIC_AURA_APPLIED"] CLEUEventInfo["SPELL_AURA_APPLIED"] = CLEUEventInfo["GENERIC_AURA_APPLIED"]
CLEUEventInfo["SPELL_AURA_REMOVED"] = CLEUEventInfo["GENERIC_AURA_REMOVED"] CLEUEventInfo["SPELL_AURA_REMOVED"] = CLEUEventInfo["GENERIC_AURA_REMOVED"]
CLEUEventInfo["SPELL_AURA_APPLIED_DOSE"] = CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"] CLEUEventInfo["SPELL_AURA_APPLIED_DOSE"] =
CLEUEventInfo["SPELL_AURA_REMOVED_DOSE"] = CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"] CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"]
CLEUEventInfo["SPELL_AURA_REMOVED_DOSE"] =
CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"]
CLEUEventInfo["SPELL_AURA_REFRESH"] = CLEUEventInfo["GENERIC_AURA_REFRESH"] CLEUEventInfo["SPELL_AURA_REFRESH"] = CLEUEventInfo["GENERIC_AURA_REFRESH"]
CLEUEventInfo["SPELL_AURA_BROKEN"] = CLEUEventInfo["GENERIC_AURA_BROKEN"] CLEUEventInfo["SPELL_AURA_BROKEN"] = CLEUEventInfo["GENERIC_AURA_BROKEN"]
CLEUEventInfo["SPELL_AURA_BROKEN_SPELL"] = CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"] CLEUEventInfo["SPELL_AURA_BROKEN_SPELL"] =
CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"]
CLEUEventInfo["SPELL_CAST_START"] = CLEUEventInfo["GENERIC_CAST_START"] CLEUEventInfo["SPELL_CAST_START"] = CLEUEventInfo["GENERIC_CAST_START"]
CLEUEventInfo["SPELL_CAST_SUCCESS"] = CLEUEventInfo["GENERIC_CAST_SUCCESS"] CLEUEventInfo["SPELL_CAST_SUCCESS"] = CLEUEventInfo["GENERIC_CAST_SUCCESS"]
CLEUEventInfo["SPELL_CAST_FAILED"] = CLEUEventInfo["GENERIC_CAST_FAILED"] CLEUEventInfo["SPELL_CAST_FAILED"] = CLEUEventInfo["GENERIC_CAST_FAILED"]
@@ -181,25 +199,39 @@ local function Init()
CLEUEventInfo["SPELL_PERIODIC_DAMAGE"] = CLEUEventInfo["GENERIC_DAMAGE"] CLEUEventInfo["SPELL_PERIODIC_DAMAGE"] = CLEUEventInfo["GENERIC_DAMAGE"]
CLEUEventInfo["SPELL_PERIODIC_MISSED"] = CLEUEventInfo["GENERIC_MISSED"] CLEUEventInfo["SPELL_PERIODIC_MISSED"] = CLEUEventInfo["GENERIC_MISSED"]
CLEUEventInfo["SPELL_PERIODIC_HEAL"] = CLEUEventInfo["GENERIC_HEAL"] CLEUEventInfo["SPELL_PERIODIC_HEAL"] = CLEUEventInfo["GENERIC_HEAL"]
CLEUEventInfo["SPELL_PERIODIC_HEAL_ABSORBED"] = CLEUEventInfo["GENERIC_HEAL_ABSORBED"] CLEUEventInfo["SPELL_PERIODIC_HEAL_ABSORBED"] =
CLEUEventInfo["GENERIC_HEAL_ABSORBED"]
CLEUEventInfo["SPELL_PERIODIC_ENERGIZE"] = CLEUEventInfo["GENERIC_ENERGIZE"] CLEUEventInfo["SPELL_PERIODIC_ENERGIZE"] = CLEUEventInfo["GENERIC_ENERGIZE"]
CLEUEventInfo["SPELL_PERIODIC_DRAIN"] = CLEUEventInfo["GENERIC_DRAIN"] CLEUEventInfo["SPELL_PERIODIC_DRAIN"] = CLEUEventInfo["GENERIC_DRAIN"]
CLEUEventInfo["SPELL_PERIODIC_LEECH"] = CLEUEventInfo["GENERIC_LEECH"] CLEUEventInfo["SPELL_PERIODIC_LEECH"] = CLEUEventInfo["GENERIC_LEECH"]
CLEUEventInfo["SPELL_PERIODIC_INTERRUPT"] = CLEUEventInfo["GENERIC_INTERRUPT"] CLEUEventInfo["SPELL_PERIODIC_INTERRUPT"] =
CLEUEventInfo["GENERIC_INTERRUPT"]
CLEUEventInfo["SPELL_PERIODIC_DISPEL"] = CLEUEventInfo["GENERIC_DISPEL"] CLEUEventInfo["SPELL_PERIODIC_DISPEL"] = CLEUEventInfo["GENERIC_DISPEL"]
CLEUEventInfo["SPELL_PERIODIC_DISPEL_FAILED"] = CLEUEventInfo["GENERIC_DISPEL_FAILED"] CLEUEventInfo["SPELL_PERIODIC_DISPEL_FAILED"] =
CLEUEventInfo["GENERIC_DISPEL_FAILED"]
CLEUEventInfo["SPELL_PERIODIC_STOLEN"] = CLEUEventInfo["GENERIC_STOLEN"] CLEUEventInfo["SPELL_PERIODIC_STOLEN"] = CLEUEventInfo["GENERIC_STOLEN"]
CLEUEventInfo["SPELL_PERIODIC_EXTRA_ATTACKS"] = CLEUEventInfo["GENERIC_EXTRA_ATTACKS"] CLEUEventInfo["SPELL_PERIODIC_EXTRA_ATTACKS"] =
CLEUEventInfo["SPELL_PERIODIC_AURA_APPLIED"] = CLEUEventInfo["GENERIC_AURA_APPLIED"] CLEUEventInfo["GENERIC_EXTRA_ATTACKS"]
CLEUEventInfo["SPELL_PERIODIC_AURA_REMOVED"] = CLEUEventInfo["GENERIC_AURA_REMOVED"] CLEUEventInfo["SPELL_PERIODIC_AURA_APPLIED"] =
CLEUEventInfo["SPELL_PERIODIC_AURA_APPLIED_DOSE"] = CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"] CLEUEventInfo["GENERIC_AURA_APPLIED"]
CLEUEventInfo["SPELL_PERIODIC_AURA_REMOVED_DOSE"] = CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"] CLEUEventInfo["SPELL_PERIODIC_AURA_REMOVED"] =
CLEUEventInfo["SPELL_PERIODIC_AURA_REFRESH"] = CLEUEventInfo["GENERIC_AURA_REFRESH"] CLEUEventInfo["GENERIC_AURA_REMOVED"]
CLEUEventInfo["SPELL_PERIODIC_AURA_BROKEN"] = CLEUEventInfo["GENERIC_AURA_BROKEN"] CLEUEventInfo["SPELL_PERIODIC_AURA_APPLIED_DOSE"] =
CLEUEventInfo["SPELL_PERIODIC_AURA_BROKEN_SPELL"] = CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"] CLEUEventInfo["GENERIC_AURA_APPLIED_DOSE"]
CLEUEventInfo["SPELL_PERIODIC_CAST_START"] = CLEUEventInfo["GENERIC_CAST_START"] CLEUEventInfo["SPELL_PERIODIC_AURA_REMOVED_DOSE"] =
CLEUEventInfo["SPELL_PERIODIC_CAST_SUCCESS"] = CLEUEventInfo["GENERIC_CAST_SUCCESS"] CLEUEventInfo["GENERIC_AURA_REMOVED_DOSE"]
CLEUEventInfo["SPELL_PERIODIC_CAST_FAILED"] = CLEUEventInfo["GENERIC_CAST_FAILED"] CLEUEventInfo["SPELL_PERIODIC_AURA_REFRESH"] =
CLEUEventInfo["GENERIC_AURA_REFRESH"]
CLEUEventInfo["SPELL_PERIODIC_AURA_BROKEN"] =
CLEUEventInfo["GENERIC_AURA_BROKEN"]
CLEUEventInfo["SPELL_PERIODIC_AURA_BROKEN_SPELL"] =
CLEUEventInfo["GENERIC_AURA_BROKEN_SPELL"]
CLEUEventInfo["SPELL_PERIODIC_CAST_START"] =
CLEUEventInfo["GENERIC_CAST_START"]
CLEUEventInfo["SPELL_PERIODIC_CAST_SUCCESS"] =
CLEUEventInfo["GENERIC_CAST_SUCCESS"]
CLEUEventInfo["SPELL_PERIODIC_CAST_FAILED"] =
CLEUEventInfo["GENERIC_CAST_FAILED"]
---@class CLEUParser ---@class CLEUParser
CLEUParser = { CLEUParser = {
@@ -207,88 +239,132 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetTimestamp = function(...) GetTimestamp = function(...)
local val = select(CLEUEventInfo["GENERIC"]["timestamp"], ...) local val = select(CLEUEventInfo["GENERIC"]["timestamp"], ...)
if val == nil then return 0, "Timestamp is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "Timestamp is not a number" end return 0, "Timestamp is nil or missing"
end
if type(val) ~= "number" then
return 0, "Timestamp is not a number"
end
return val, nil return val, nil
end, end,
---@param ... any ---@param ... any
---@return string, nil|string ---@return string, nil|string
GetSubevent = function(...) GetSubevent = function(...)
local val = select(CLEUEventInfo["GENERIC"]["subevent"], ...) local val = select(CLEUEventInfo["GENERIC"]["subevent"], ...)
if val == nil then return "", "Subevent is nil or missing" end if val == nil then
if type(val) ~= "string" then return "", "Subevent is not a string" end return "", "Subevent is nil or missing"
end
if type(val) ~= "string" then
return "", "Subevent is not a string"
end
return val, nil return val, nil
end, end,
---@param ... any ---@param ... any
---@return boolean, nil|string ---@return boolean, nil|string
GetHideCaster = function(...) GetHideCaster = function(...)
local val = select(CLEUEventInfo["GENERIC"]["hideCaster"], ...) local val = select(CLEUEventInfo["GENERIC"]["hideCaster"], ...)
if val == nil then return false, "HideCaster is nil or missing" end if val == nil then
if type(val) ~= "boolean" then return false, "HideCaster is not a boolean" end return false, "HideCaster is nil or missing"
end
if type(val) ~= "boolean" then
return false, "HideCaster is not a boolean"
end
return val, nil return val, nil
end, end,
---@param ... any ---@param ... any
---@return string, nil|string ---@return string, nil|string
GetSourceGUID = function(...) GetSourceGUID = function(...)
local val = select(CLEUEventInfo["GENERIC"]["sourceGUID"], ...) local val = select(CLEUEventInfo["GENERIC"]["sourceGUID"], ...)
if val == nil then return "", "SourceGUID is nil or missing" end if val == nil then
if type(val) ~= "string" then return "", "SourceGUID is not a string" end return "", "SourceGUID is nil or missing"
end
if type(val) ~= "string" then
return "", "SourceGUID is not a string"
end
return val, nil return val, nil
end, end,
---@param ... any ---@param ... any
---@return string, nil|string ---@return string, nil|string
GetSourceName = function(...) GetSourceName = function(...)
local val = select(CLEUEventInfo["GENERIC"]["sourceName"], ...) local val = select(CLEUEventInfo["GENERIC"]["sourceName"], ...)
if val == nil then return "", "SourceName is nil or missing" end if val == nil then
if type(val) ~= "string" then return "", "SourceName is not a string" end return "", "SourceName is nil or missing"
end
if type(val) ~= "string" then
return "", "SourceName is not a string"
end
return val, nil return val, nil
end, end,
---@param ... any ---@param ... any
---@return number, nil|string ---@return number, nil|string
GetSourceFlags = function(...) GetSourceFlags = function(...)
local val = select(CLEUEventInfo["GENERIC"]["sourceFlags"], ...) local val = select(CLEUEventInfo["GENERIC"]["sourceFlags"], ...)
if val == nil then return 0, "SourceFlags is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "SourceFlags is not a number" end return 0, "SourceFlags is nil or missing"
end
if type(val) ~= "number" then
return 0, "SourceFlags is not a number"
end
return val, nil return val, nil
end, end,
---@param ... any ---@param ... any
---@return number, nil|string ---@return number, nil|string
GetSourceRaidFlags = function(...) GetSourceRaidFlags = function(...)
local val = select(CLEUEventInfo["GENERIC"]["sourceRaidFlags"], ...) local val = select(CLEUEventInfo["GENERIC"]["sourceRaidFlags"], ...)
if val == nil then return 0, "SourceRaidFlags is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "SourceRaidFlags is not a number" end return 0, "SourceRaidFlags is nil or missing"
end
if type(val) ~= "number" then
return 0, "SourceRaidFlags is not a number"
end
return val, nil return val, nil
end, end,
---@param ... any ---@param ... any
---@return string, nil|string ---@return string, nil|string
GetDestGUID = function(...) GetDestGUID = function(...)
local val = select(CLEUEventInfo["GENERIC"]["destGUID"], ...) local val = select(CLEUEventInfo["GENERIC"]["destGUID"], ...)
if val == nil then return "", "DestGUID is nil or missing" end if val == nil then
if type(val) ~= "string" then return "", "DestGUID is not a string" end return "", "DestGUID is nil or missing"
end
if type(val) ~= "string" then
return "", "DestGUID is not a string"
end
return val, nil return val, nil
end, end,
---@param ... any ---@param ... any
---@return string, nil|string ---@return string, nil|string
GetDestName = function(...) GetDestName = function(...)
local val = select(CLEUEventInfo["GENERIC"]["destName"], ...) local val = select(CLEUEventInfo["GENERIC"]["destName"], ...)
if val == nil then return "", "DestName is nil or missing" end if val == nil then
if type(val) ~= "string" then return "", "DestName is not a string" end return "", "DestName is nil or missing"
end
if type(val) ~= "string" then
return "", "DestName is not a string"
end
return val, nil return val, nil
end, end,
---@param ... any ---@param ... any
---@return number, nil|string ---@return number, nil|string
GetDestFlags = function(...) GetDestFlags = function(...)
local val = select(CLEUEventInfo["GENERIC"]["destFlags"], ...) local val = select(CLEUEventInfo["GENERIC"]["destFlags"], ...)
if val == nil then return 0, "DestFlags is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "DestFlags is not a number" end return 0, "DestFlags is nil or missing"
end
if type(val) ~= "number" then
return 0, "DestFlags is not a number"
end
return val, nil return val, nil
end, end,
---@param ... any ---@param ... any
---@return number, nil|string ---@return number, nil|string
GetDestRaidFlags = function(...) GetDestRaidFlags = function(...)
local val = select(CLEUEventInfo["GENERIC"]["destRaidFlags"], ...) local val = select(CLEUEventInfo["GENERIC"]["destRaidFlags"], ...)
if val == nil then return 0, "DestRaidFlags is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "DestRaidFlags is not a number" end return 0, "DestRaidFlags is nil or missing"
end
if type(val) ~= "number" then
return 0, "DestRaidFlags is not a number"
end
return val, nil return val, nil
end, end,
@@ -304,7 +380,9 @@ local function Init()
GetSpellId = function(...) GetSpellId = function(...)
local val = select(CLEUEventInfo["GENERIC_SPELL"]["spellId"], ...) local val = select(CLEUEventInfo["GENERIC_SPELL"]["spellId"], ...)
if val == nil then return 0, "SpellId is nil or missing" end if val == nil then return 0, "SpellId is nil or missing" end
if type(val) ~= "number" then return 0, "SpellId is not a number" end if type(val) ~= "number" then
return 0, "SpellId is not a number"
end
return val, nil return val, nil
end, end,
--- Specific to subevents prefixed by: --- Specific to subevents prefixed by:
@@ -318,8 +396,12 @@ local function Init()
---@return string, nil|string ---@return string, nil|string
GetSpellName = function(...) GetSpellName = function(...)
local val = select(CLEUEventInfo["GENERIC_SPELL"]["spellName"], ...) local val = select(CLEUEventInfo["GENERIC_SPELL"]["spellName"], ...)
if val == nil then return "", "SpellName is nil or missing" end if val == nil then
if type(val) ~= "string" then return "", "SpellName is not a string" end return "", "SpellName is nil or missing"
end
if type(val) ~= "string" then
return "", "SpellName is not a string"
end
return val, nil return val, nil
end, end,
--- Specific to subevents prefixed by: --- Specific to subevents prefixed by:
@@ -332,9 +414,14 @@ local function Init()
---@param ... any ---@param ... any
---@return number, nil|string ---@return number, nil|string
GetSpellSchool = function(...) GetSpellSchool = function(...)
local val = select(CLEUEventInfo["GENERIC_SPELL"]["spellSchool"], ...) local val = select(CLEUEventInfo["GENERIC_SPELL"]["spellSchool"],
if val == nil then return 0, "SpellSchool is nil or missing" end ...)
if type(val) ~= "number" then return 0, "SpellSchool is not a number" end if val == nil then
return 0, "SpellSchool is nil or missing"
end
if type(val) ~= "number" then
return 0, "SpellSchool is not a number"
end
return val, nil return val, nil
end, end,
@@ -364,10 +451,15 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetAmount = function(...) GetAmount = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
return 0,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["amount"], ...) local val = select(CLEUEventInfo[subevent]["amount"], ...)
if val == nil then return 0, "Amount is nil or missing" end if val == nil then return 0, "Amount is nil or missing" end
if type(val) ~= "number" then return 0, "Amount is not a number" end if type(val) ~= "number" then
return 0, "Amount is not a number"
end
return val, nil return val, nil
end, end,
--- Specific to subevents prefixed by: --- Specific to subevents prefixed by:
@@ -387,12 +479,21 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetOverkill = function(...) GetOverkill = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
if not CLEUEventInfo[subevent] then return 0, "Subevent is not a valid event" end return 0,
if not CLEUEventInfo[subevent]["overkill"] then return 0, "Overkill is nil or missing" end string.format("Failed getting subevent due to: %s", err)
end
if not CLEUEventInfo[subevent] then
return 0, "Subevent is not a valid event"
end
if not CLEUEventInfo[subevent]["overkill"] then
return 0, "Overkill is nil or missing"
end
local val = select(CLEUEventInfo[subevent]["overkill"], ...) local val = select(CLEUEventInfo[subevent]["overkill"], ...)
if val == nil then return 0, "Overkill is nil or missing" end if val == nil then return 0, "Overkill is nil or missing" end
if type(val) ~= "number" then return 0, "Overkill is not a number" end if type(val) ~= "number" then
return 0, "Overkill is not a number"
end
return val, nil return val, nil
end, end,
--- Specific to subevents prefixed by: --- Specific to subevents prefixed by:
@@ -412,10 +513,15 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetSchool = function(...) GetSchool = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
return 0,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["school"], ...) local val = select(CLEUEventInfo[subevent]["school"], ...)
if val == nil then return 0, "School is nil or missing" end if val == nil then return 0, "School is nil or missing" end
if type(val) ~= "number" then return 0, "School is not a number" end if type(val) ~= "number" then
return 0, "School is not a number"
end
return val, nil return val, nil
end, end,
--- Specific to subevents prefixed by: --- Specific to subevents prefixed by:
@@ -437,10 +543,17 @@ local function Init()
---@return boolean, nil|string ---@return boolean, nil|string
GetResisted = function(...) GetResisted = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return false, string.format("Failed getting subevent due to: %s", err) end if err then
return false,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["resisted"], ...) local val = select(CLEUEventInfo[subevent]["resisted"], ...)
if val == nil then return false, "Resisted is nil or missing" end if val == nil then
if type(val) ~= "boolean" then return false, "Resisted is not a boolean" end return false, "Resisted is nil or missing"
end
if type(val) ~= "boolean" then
return false, "Resisted is not a boolean"
end
return val, nil return val, nil
end, end,
--- Specific to subevents prefixed by: --- Specific to subevents prefixed by:
@@ -462,10 +575,17 @@ local function Init()
---@return boolean, nil|string ---@return boolean, nil|string
GetBlocked = function(...) GetBlocked = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return false, string.format("Failed getting subevent due to: %s", err) end if err then
return false,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["blocked"], ...) local val = select(CLEUEventInfo[subevent]["blocked"], ...)
if val == nil then return false, "Blocked is nil or missing" end if val == nil then
if type(val) ~= "boolean" then return false, "Blocked is not a boolean" end return false, "Blocked is nil or missing"
end
if type(val) ~= "boolean" then
return false, "Blocked is not a boolean"
end
return val, nil return val, nil
end, end,
--- Specific to subevents prefixed by: --- Specific to subevents prefixed by:
@@ -488,10 +608,17 @@ local function Init()
---@return boolean, nil|string ---@return boolean, nil|string
GetAbsorbed = function(...) GetAbsorbed = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return false, string.format("Failed getting subevent due to: %s", err) end if err then
return false,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["absorbed"], ...) local val = select(CLEUEventInfo[subevent]["absorbed"], ...)
if val == nil then return false, "Absorbed is nil or missing" end if val == nil then
if type(val) ~= "boolean" then return false, "Absorbed is not a boolean" end return false, "Absorbed is nil or missing"
end
if type(val) ~= "boolean" then
return false, "Absorbed is not a boolean"
end
return val, nil return val, nil
end, end,
--- Specific to subevents prefixed by: --- Specific to subevents prefixed by:
@@ -513,10 +640,17 @@ local function Init()
---@return boolean, nil|string ---@return boolean, nil|string
GetCritical = function(...) GetCritical = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return false, string.format("Failed getting subevent due to: %s", err) end if err then
return false,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["critical"], ...) local val = select(CLEUEventInfo[subevent]["critical"], ...)
if val == nil then return false, "Critical is nil or missing" end if val == nil then
if type(val) ~= "boolean" then return false, "Critical is not a boolean" end return false, "Critical is nil or missing"
end
if type(val) ~= "boolean" then
return false, "Critical is not a boolean"
end
return val, nil return val, nil
end, end,
--- Specific to subevents prefixed by: --- Specific to subevents prefixed by:
@@ -536,10 +670,17 @@ local function Init()
---@return boolean, nil|string ---@return boolean, nil|string
GetGlancing = function(...) GetGlancing = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return false, string.format("Failed getting subevent due to: %s", err) end if err then
return false,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["glancing"], ...) local val = select(CLEUEventInfo[subevent]["glancing"], ...)
if val == nil then return false, "Glancing is nil or missing" end if val == nil then
if type(val) ~= "boolean" then return false, "Glancing is not a boolean" end return false, "Glancing is nil or missing"
end
if type(val) ~= "boolean" then
return false, "Glancing is not a boolean"
end
return val, nil return val, nil
end, end,
--- Specific to subevents prefixed by: --- Specific to subevents prefixed by:
@@ -559,10 +700,17 @@ local function Init()
---@return boolean, nil|string ---@return boolean, nil|string
GetCrushing = function(...) GetCrushing = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return false, string.format("Failed getting subevent due to: %s", err) end if err then
return false,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["crushing"], ...) local val = select(CLEUEventInfo[subevent]["crushing"], ...)
if val == nil then return false, "Crushing is nil or missing" end if val == nil then
if type(val) ~= "boolean" then return false, "Crushing is not a boolean" end return false, "Crushing is nil or missing"
end
if type(val) ~= "boolean" then
return false, "Crushing is not a boolean"
end
return val, nil return val, nil
end, end,
--- Specific to subevents prefixed by: --- Specific to subevents prefixed by:
@@ -583,10 +731,17 @@ local function Init()
---@return boolean, nil|string ---@return boolean, nil|string
GetIsOffHand = function(...) GetIsOffHand = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return false, string.format("Failed getting subevent due to: %s", err) end if err then
return false,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["isOffHand"], ...) local val = select(CLEUEventInfo[subevent]["isOffHand"], ...)
if val == nil then return false, "IsOffHand is nil or missing" end if val == nil then
if type(val) ~= "boolean" then return false, "IsOffHand is not a boolean" end return false, "IsOffHand is nil or missing"
end
if type(val) ~= "boolean" then
return false, "IsOffHand is not a boolean"
end
return val, nil return val, nil
end, end,
@@ -609,10 +764,17 @@ local function Init()
---@return string, nil|string ---@return string, nil|string
GetMissType = function(...) GetMissType = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return "", string.format("Failed getting subevent due to: %s", err) end if err then
return "",
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["missType"], ...) local val = select(CLEUEventInfo[subevent]["missType"], ...)
if val == nil then return "", "MissType is nil or missing" end if val == nil then
if type(val) ~= "string" then return "", "MissType is not a string" end return "", "MissType is nil or missing"
end
if type(val) ~= "string" then
return "", "MissType is not a string"
end
return val, nil return val, nil
end, end,
@@ -635,10 +797,17 @@ local function Init()
--- return type is unconfirmed! --- return type is unconfirmed!
GetAmountMissed = function(...) GetAmountMissed = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
return 0,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["amountMissed"], ...) local val = select(CLEUEventInfo[subevent]["amountMissed"], ...)
if val == nil then return 0, "AmountMissed is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "AmountMissed is not a number" end return 0, "AmountMissed is nil or missing"
end
if type(val) ~= "number" then
return 0, "AmountMissed is not a number"
end
return val, nil return val, nil
end, end,
@@ -661,10 +830,17 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetOverhealing = function(...) GetOverhealing = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
return 0,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["overhealing"], ...) local val = select(CLEUEventInfo[subevent]["overhealing"], ...)
if val == nil then return 0, "Overhealing is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "Overhealing is not a number" end return 0, "Overhealing is nil or missing"
end
if type(val) ~= "number" then
return 0, "Overhealing is not a number"
end
return val, nil return val, nil
end, end,
@@ -685,10 +861,17 @@ local function Init()
---@return string, nil|string ---@return string, nil|string
GetExtraGUID = function(...) GetExtraGUID = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return "", string.format("Failed getting subevent due to: %s", err) end if err then
return "",
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["extraGUID"], ...) local val = select(CLEUEventInfo[subevent]["extraGUID"], ...)
if val == nil then return "", "ExtraGUID is nil or missing" end if val == nil then
if type(val) ~= "string" then return "", "ExtraGUID is not a string" end return "", "ExtraGUID is nil or missing"
end
if type(val) ~= "string" then
return "", "ExtraGUID is not a string"
end
return val, nil return val, nil
end, end,
@@ -709,10 +892,17 @@ local function Init()
---@return string, nil|string ---@return string, nil|string
GetExtraName = function(...) GetExtraName = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return "", string.format("Failed getting subevent due to: %s", err) end if err then
return "",
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["extraName"], ...) local val = select(CLEUEventInfo[subevent]["extraName"], ...)
if val == nil then return "", "ExtraName is nil or missing" end if val == nil then
if type(val) ~= "string" then return "", "ExtraName is not a string" end return "", "ExtraName is nil or missing"
end
if type(val) ~= "string" then
return "", "ExtraName is not a string"
end
return val, nil return val, nil
end, end,
@@ -733,10 +923,17 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetExtraFlags = function(...) GetExtraFlags = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
return 0,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["extraFlags"], ...) local val = select(CLEUEventInfo[subevent]["extraFlags"], ...)
if val == nil then return 0, "ExtraFlags is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "ExtraFlags is not a number" end return 0, "ExtraFlags is nil or missing"
end
if type(val) ~= "number" then
return 0, "ExtraFlags is not a number"
end
return val, nil return val, nil
end, end,
@@ -757,10 +954,17 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetExtraRaidFlags = function(...) GetExtraRaidFlags = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
return 0,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["extraRaidFlags"], ...) local val = select(CLEUEventInfo[subevent]["extraRaidFlags"], ...)
if val == nil then return 0, "ExtraRaidFlags is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "ExtraRaidFlags is not a number" end return 0, "ExtraRaidFlags is nil or missing"
end
if type(val) ~= "number" then
return 0, "ExtraRaidFlags is not a number"
end
return val, nil return val, nil
end, end,
@@ -785,10 +989,17 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetExtraSpellID = function(...) GetExtraSpellID = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
return 0,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["extraSpellID"], ...) local val = select(CLEUEventInfo[subevent]["extraSpellID"], ...)
if val == nil then return 0, "ExtraSpellID is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "ExtraSpellID is not a number" end return 0, "ExtraSpellID is nil or missing"
end
if type(val) ~= "number" then
return 0, "ExtraSpellID is not a number"
end
return val, nil return val, nil
end, end,
@@ -814,10 +1025,17 @@ local function Init()
---@return string, nil|string ---@return string, nil|string
GetExtraSpellName = function(...) GetExtraSpellName = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return "", string.format("Failed getting subevent due to: %s", err) end if err then
return "",
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["extraSpellName"], ...) local val = select(CLEUEventInfo[subevent]["extraSpellName"], ...)
if val == nil then return "", "extraSpellName is nil or missing" end if val == nil then
if type(val) ~= "string" then return "", "extraSpellName is not a string" end return "", "extraSpellName is nil or missing"
end
if type(val) ~= "string" then
return "", "extraSpellName is not a string"
end
return val, nil return val, nil
end, end,
@@ -843,10 +1061,17 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetExtraSchool = function(...) GetExtraSchool = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
return 0,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["extraSchool"], ...) local val = select(CLEUEventInfo[subevent]["extraSchool"], ...)
if val == nil then return 0, "ExtraSchool is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "ExtraSchool is not a number" end return 0, "ExtraSchool is nil or missing"
end
if type(val) ~= "number" then
return 0, "ExtraSchool is not a number"
end
return val, nil return val, nil
end, end,
@@ -867,10 +1092,17 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetAbsorbedAmount = function(...) GetAbsorbedAmount = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
return 0,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["absorbedAmount"], ...) local val = select(CLEUEventInfo[subevent]["absorbedAmount"], ...)
if val == nil then return 0, "AbsorbedAmount is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "AbsorbedAmount is not a number" end return 0, "AbsorbedAmount is nil or missing"
end
if type(val) ~= "number" then
return 0, "AbsorbedAmount is not a number"
end
return val, nil return val, nil
end, end,
@@ -891,10 +1123,17 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetOverEnergize = function(...) GetOverEnergize = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
return 0,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["overEnergize"], ...) local val = select(CLEUEventInfo[subevent]["overEnergize"], ...)
if val == nil then return 0, "OverEnergize is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "OverEnergize is not a number" end return 0, "OverEnergize is nil or missing"
end
if type(val) ~= "number" then
return 0, "OverEnergize is not a number"
end
return val, nil return val, nil
end, end,
@@ -919,10 +1158,17 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetPowerType = function(...) GetPowerType = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
return 0,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["powerType"], ...) local val = select(CLEUEventInfo[subevent]["powerType"], ...)
if val == nil then return 0, "PowerType is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "PowerType is not a number" end return 0, "PowerType is nil or missing"
end
if type(val) ~= "number" then
return 0, "PowerType is not a number"
end
return val, nil return val, nil
end, end,
@@ -944,10 +1190,17 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetExtraAmount = function(...) GetExtraAmount = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
return 0,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["extraAmount"], ...) local val = select(CLEUEventInfo[subevent]["extraAmount"], ...)
if val == nil then return 0, "ExtraAmount is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "ExtraAmount is not a number" end return 0, "ExtraAmount is nil or missing"
end
if type(val) ~= "number" then
return 0, "ExtraAmount is not a number"
end
return val, nil return val, nil
end, end,
@@ -976,10 +1229,17 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetExtraSpellId = function(...) GetExtraSpellId = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
return 0,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["extraSpellId"], ...) local val = select(CLEUEventInfo[subevent]["extraSpellId"], ...)
if val == nil then return 0, "ExtraSpellId is nil or missing" end if val == nil then
if type(val) ~= "number" then return 0, "ExtraSpellId is not a number" end return 0, "ExtraSpellId is nil or missing"
end
if type(val) ~= "number" then
return 0, "ExtraSpellId is not a number"
end
return val, nil return val, nil
end, end,
@@ -1008,12 +1268,17 @@ local function Init()
---@return number, nil|string ---@return number, nil|string
GetExtraAuraType = function(...) GetExtraAuraType = function(...)
local subevent, err = CLEUParser.GetSubevent(...) local subevent, err = CLEUParser.GetSubevent(...)
if err then return 0, string.format("Failed getting subevent due to: %s", err) end if err then
return 0,
string.format("Failed getting subevent due to: %s", err)
end
local val = select(CLEUEventInfo[subevent]["auraType"], ...) local val = select(CLEUEventInfo[subevent]["auraType"], ...)
if val == nil then return 0, "AuraType is nil or missing" end if val == nil then return 0, "AuraType is nil or missing" end
if type(val) ~= "number" then return 0, "AuraType is not a number" end if type(val) ~= "number" then
return 0, "AuraType is not a number"
end
return val, nil return val, nil
end, end
} }
end end
@@ -1021,5 +1286,7 @@ local frame = CreateFrame("Frame")
frame:RegisterEvent("PLAYER_LOGIN") frame:RegisterEvent("PLAYER_LOGIN")
frame:RegisterEvent("PLAYER_ENTERING_WORLD") frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:RegisterEvent("GUILD_ROSTER_UPDATE") frame:RegisterEvent("GUILD_ROSTER_UPDATE")
frame:SetScript("OnEvent", function(self, event, ...) Init() end) frame:SetScript("OnEvent", function(self, event, ...)
Init()
end)
Init() Init()

View File

@@ -1,49 +0,0 @@
local _, shared = ...
---@cast shared HeimdallShared
local ModuleName = "ChatSniffer"
---@class HeimdallChatSnifferConfig
---@field enabled boolean
---@field debug boolean
---@class ChatSniffer
shared.ChatSniffer = {
Init = function()
Heimdall_Chat = Heimdall_Chat or {}
local frame = CreateFrame("Frame")
frame:RegisterEvent("CHAT_MSG_SAY")
frame:RegisterEvent("CHAT_MSG_YELL")
frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:RegisterEvent("CHAT_MSG_WHISPER")
frame:RegisterEvent("CHAT_MSG_CHANNEL_JOIN")
frame:RegisterEvent("CHAT_MSG_CHANNEL_LEAVE")
frame:RegisterEvent("CHAT_MSG_EMOTE")
frame:RegisterEvent("CHAT_MSG_PARTY")
frame:RegisterEvent("CHAT_MSG_PARTY_LEADER")
frame:RegisterEvent("CHAT_MSG_RAID")
frame:RegisterEvent("CHAT_MSG_RAID_LEADER")
frame:RegisterEvent("CHAT_MSG_RAID_WARNING")
frame:RegisterEvent("CHAT_MSG_SYSTEM")
frame:RegisterEvent("CHAT_MSG_TEXT_EMOTE")
frame:RegisterEvent("CHAT_MSG_YELL")
frame:SetScript("OnEvent", function(self, event, msg, sender, language, channel)
if not Heimdall_Data.config.chatSniffer.enabled then return end
if not Heimdall_Data.config.chatSniffer.debug then
shared.dump(string.format("[%s] got message", { event, msg, sender, language, channel }))
end
local timestamp = date("%Y-%m-%d %H:%M:%S")
local log = string.format(
"%s|%s|%s|%s|%s|%s",
tostring(timestamp),
tostring(event),
tostring(sender),
tostring(msg),
tostring(language),
tostring(channel)
)
Heimdall_Chat[#Heimdall_Chat + 1] = log
end)
print(string.format("[%s] Module initialized", ModuleName))
end,
}

View File

@@ -1,15 +1,11 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "CombatAlerter" local ModuleName = "CombatAlerter"
---@class HeimdallCombatAlerterConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.CombatAlerter = {}
---@field debug boolean function shared.CombatAlerter.Init()
---@field channels string[]
---@class CombatAlerter
shared.CombatAlerter = {
Init = function()
local alerted = {} local alerted = {}
local combatAlerterFrame = CreateFrame("Frame") local combatAlerterFrame = CreateFrame("Frame")
combatAlerterFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED") combatAlerterFrame:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
@@ -24,10 +20,7 @@ shared.CombatAlerter = {
return return
end end
---@type string|nil, string, string local destination, err = CLEUParser.GetDestName(...)
local err, source, destination
destination, err = CLEUParser.GetDestName(...)
if err then if err then
if Heimdall_Data.config.combatAlerter.debug then if Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Error getting destination: %s", ModuleName, err)) print(string.format("[%s] Error getting destination: %s", ModuleName, err))
@@ -46,7 +39,7 @@ shared.CombatAlerter = {
return return
end end
source, err = CLEUParser.GetSourceName(...) local source, err = CLEUParser.GetSourceName(...)
if err then if err then
if Heimdall_Data.config.combatAlerter.debug then if Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Error getting source, using 'unknown': %s", ModuleName, err)) print(string.format("[%s] Error getting source, using 'unknown': %s", ModuleName, err))
@@ -58,16 +51,10 @@ shared.CombatAlerter = {
print(string.format("[%s] Combat event source: %s", ModuleName, source)) print(string.format("[%s] Combat event source: %s", ModuleName, source))
end end
if shared.StinkyTracker.IsStinky(source) then if shared.stinkyTracker.stinkies and shared.stinkyTracker.stinkies[source] then
if Heimdall_Data.config.combatAlerter.debug then if Heimdall_Data.config.combatAlerter.debug then
print( print(string.format("[%s] Source is tracked stinky: %s (Already alerted: %s)", ModuleName, source,
string.format( tostring(alerted[source] or false)))
"[%s] Source is tracked stinky: %s (Already alerted: %s)",
ModuleName,
source,
tostring(alerted[source] or false)
)
)
end end
if alerted[source] then return end if alerted[source] then return end
@@ -76,16 +63,8 @@ shared.CombatAlerter = {
local zone, subZone = GetZoneText(), GetSubZoneText() local zone, subZone = GetZoneText(), GetSubZoneText()
if Heimdall_Data.config.combatAlerter.debug then if Heimdall_Data.config.combatAlerter.debug then
print( print(string.format("[%s] Player location: %s/%s at %.2f,%.2f", ModuleName, zone, subZone, x * 100,
string.format( y * 100))
"[%s] Player location: %s/%s at %.2f,%.2f",
ModuleName,
zone,
subZone,
x * 100,
y * 100
)
)
end end
SetMapToCurrentZone() SetMapToCurrentZone()
@@ -94,14 +73,11 @@ shared.CombatAlerter = {
for _, channel in pairs(Heimdall_Data.config.combatAlerter.channels) do for _, channel in pairs(Heimdall_Data.config.combatAlerter.channels) do
local locale = shared.GetLocaleForChannel(channel) local locale = shared.GetLocaleForChannel(channel)
local text = string.format( local text = string.format(shared._L("combatAlerterInCombat", locale),
shared._L("combatAlerterInCombat", locale),
source, source,
shared._L("zone", locale), shared._L("zone", locale), shared._L("subZone", locale),
shared._L("subZone", locale),
tostring(areaId), tostring(areaId),
x * 100, x * 100, y * 100
y * 100
) )
---@type Message ---@type Message
local msg = { local msg = {
@@ -111,7 +87,7 @@ shared.CombatAlerter = {
} }
if Heimdall_Data.config.combatAlerter.debug then if Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Queuing alert message", ModuleName)) print(string.format("[%s] Queuing alert message", ModuleName))
shared.dump(msg) shared.dumpTable(msg)
end end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
end end
@@ -135,7 +111,8 @@ shared.CombatAlerter = {
alerted = {} alerted = {}
end) end)
if Heimdall_Data.config.combatAlerter.debug then print(string.format("[%s] Module initialized", ModuleName)) end if Heimdall_Data.config.combatAlerter.debug then
print(string.format("[%s] Module initialized", ModuleName)) print(string.format("[%s] Module initialized", ModuleName))
end, end
} print("[Heimdall] CombatAlerter loaded")
end

View File

@@ -1,14 +1,8 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Commander" local ModuleName = "Commander"
---@class HeimdallCommanderConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field commander string
---@field commands table<string, boolean>
local helpMessages = { local helpMessages = {
ru = { ru = {
"1) who - пишет вам никнеймы текущих врагов и локу.", "1) who - пишет вам никнеймы текущих врагов и локу.",
@@ -35,12 +29,12 @@ local helpMessages = {
"9) note <name> i..j - lists notes from i to j for the character.", "9) note <name> i..j - lists notes from i to j for the character.",
"10) note <name> delete i - deletes the i-th note for the character.", "10) note <name> delete i - deletes the i-th note for the character.",
"11) note <name> delete i..j - deletes notes from i to j for the character.", "11) note <name> delete i..j - deletes notes from i to j for the character.",
}, }
} }
---@class Commander ---@diagnostic disable-next-line: missing-fields
shared.Commander = { shared.Commander = {}
Init = function() function shared.Commander.Init()
---@param text string ---@param text string
---@param size number ---@param size number
---@return string[] ---@return string[]
@@ -57,12 +51,16 @@ shared.Commander = {
if #currentChunk + #word + 1 <= size then if #currentChunk + #word + 1 <= size then
currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word) currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word)
else else
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end if #currentChunk > 0 then
ret[#ret + 1] = currentChunk
end
currentChunk = word currentChunk = word
end end
end end
if #currentChunk > 0 then ret[#ret + 1] = currentChunk end if #currentChunk > 0 then
ret[#ret + 1] = currentChunk
end
return ret return ret
end end
@@ -71,7 +69,9 @@ shared.Commander = {
local function Count(arr) local function Count(arr)
local ret = {} local ret = {}
for _, player in pairs(arr) do for _, player in pairs(arr) do
if shared.Whoer.ShouldNotifyForZone(player.zone) then ret[player.zone] = (ret[player.zone] or 0) + 1 end if shared.Whoer.ShouldNotifyForZone(player.zone) then
ret[player.zone] = (ret[player.zone] or 0) + 1
end
end end
local text = {} local text = {}
for zone, count in pairs(ret) do for zone, count in pairs(ret) do
@@ -84,7 +84,6 @@ shared.Commander = {
local function CountPartitioned(arr) local function CountPartitioned(arr)
local count = Count(arr) local count = Count(arr)
local text = {} local text = {}
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
for _, line in pairs(Partition(strjoin(", ", unpack(count)), 200)) do for _, line in pairs(Partition(strjoin(", ", unpack(count)), 200)) do
text[#text + 1] = line text[#text + 1] = line
end end
@@ -96,39 +95,8 @@ shared.Commander = {
local ret = {} local ret = {}
for _, player in pairs(arr) do for _, player in pairs(arr) do
if shared.Whoer.ShouldNotifyForZone(player.zone) then if shared.Whoer.ShouldNotifyForZone(player.zone) then
ret[#ret + 1] = string.format( ret[#ret + 1] = string.format("%s/%s (%s) %s", player.name, player.class, player.zone,
"%s/%s (%s) %s", player.stinky and "(!!!!)" or "")
player.name,
player.class,
player.zone,
player.stinky and "(!!!!)" or ""
)
end
end
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Command result: %s", ModuleName, strjoin(", ", unpack(ret))))
end
return ret
end
-- This is really ugly, duplicating methods like this
-- But I have no better idea
-- We would have to drag reference channel all the way here
-- And then in here do some kind of deciding based on the fucking channel locale
-- That's also a nasty solution... I guess adding "kto" is better
---@param arr table<string, Player>
---@return string[]
local function WhoRu(arr)
local ret = {}
for _, player in pairs(arr) do
if shared.Whoer.ShouldNotifyForZone(player.zone) then
shared.dump(player)
ret[#ret + 1] = string.format(
"%s/%s (%s) %s",
player.name,
shared._L(player.class, "ru"),
shared._L(player.zone, "ru"),
player.stinky and "(!!!!)" or ""
)
end end
end end
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
@@ -141,7 +109,6 @@ shared.Commander = {
local function WhoPartitioned(arr) local function WhoPartitioned(arr)
local who = Who(arr) local who = Who(arr)
local text = {} local text = {}
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
for _, line in pairs(Partition(strjoin(", ", unpack(who)), 200)) do for _, line in pairs(Partition(strjoin(", ", unpack(who)), 200)) do
text[#text + 1] = "who: " .. line text[#text + 1] = "who: " .. line
end end
@@ -149,17 +116,6 @@ shared.Commander = {
end end
---@param arr table<string, Player> ---@param arr table<string, Player>
---@return string[] ---@return string[]
local function WhoPartitionedRu(arr)
local who = WhoRu(arr)
local text = {}
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
for _, line in pairs(Partition(strjoin(", ", unpack(who)), 200)) do
text[#text + 1] = "кто: " .. line
end
return text
end
---@param arr table<string, Player>
---@return string[]
local function CountClass(arr) local function CountClass(arr)
local ret = {} local ret = {}
for _, player in pairs(arr) do for _, player in pairs(arr) do
@@ -181,7 +137,6 @@ shared.Commander = {
local function CountClassPartitioned(arr) local function CountClassPartitioned(arr)
local countClass = CountClass(arr) local countClass = CountClass(arr)
local text = {} local text = {}
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
for _, line in pairs(Partition(strjoin(", ", unpack(countClass)), 200)) do for _, line in pairs(Partition(strjoin(", ", unpack(countClass)), 200)) do
text[#text + 1] = line text[#text + 1] = line
end end
@@ -189,36 +144,36 @@ shared.Commander = {
end end
local function CountClassPartitionedStinkies() local function CountClassPartitionedStinkies()
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: CountClassPartitionedStinkies", ModuleName)) print(string.format("[%s] Executing: CountClassPartitionedStinkies",
ModuleName))
end end
local res = CountClassPartitioned(HeimdallStinkies) local res = CountClassPartitioned(HeimdallStinkies)
if #res == 0 then return { "No stinkies found" } end if #res == 0 then
return { "No stinkies found" }
end
return res return res
end end
local function WhoPartitionedStinkies() local function WhoPartitionedStinkies()
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName)) print(string.format("[%s] Executing: WhoPartitionedStinkies",
shared.dump(HeimdallStinkies) ModuleName))
shared.dumpTable(HeimdallStinkies)
end end
local res = WhoPartitioned(HeimdallStinkies) local res = WhoPartitioned(HeimdallStinkies)
if #res == 0 then return { "No stinkies found" } end if #res == 0 then
return res return { "No stinkies found" }
end end
local function WhoPartitionedStinkiesRu()
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: WhoPartitionedStinkies", ModuleName))
shared.dump(HeimdallStinkies)
end
local res = WhoPartitionedRu(HeimdallStinkies)
if #res == 0 then return { "No stinkies found" } end
return res return res
end end
local function CountPartitionedStinkies() local function CountPartitionedStinkies()
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Executing: CountPartitionedStinkies", ModuleName)) print(string.format("[%s] Executing: CountPartitionedStinkies",
ModuleName))
end end
local res = CountPartitioned(HeimdallStinkies) local res = CountPartitioned(HeimdallStinkies)
if #res == 0 then return { "No stinkies found" } end if #res == 0 then
return { "No stinkies found" }
end
return res return res
end end
local function HelpRu() local function HelpRu()
@@ -235,32 +190,26 @@ shared.Commander = {
AcceptGroup() AcceptGroup()
groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST")
C_Timer.NewTimer(0.1, function() C_Timer.NewTimer(0.1, function()
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then print(string.format("[%s] Click event triggered", ModuleName)) end
print(string.format("[%s] Click event triggered", ModuleName))
end
_G["StaticPopup1Button1"]:Click() _G["StaticPopup1Button1"]:Click()
end, 1) end, 1)
end) end)
local function JoinGroup() local function JoinGroup()
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then print(string.format("[%s] JoinGroup command received", ModuleName)) end
print(string.format("[%s] JoinGroup command received", ModuleName))
end
groupInviteFrame:RegisterEvent("PARTY_INVITE_REQUEST") groupInviteFrame:RegisterEvent("PARTY_INVITE_REQUEST")
C_Timer.NewTimer(10, function() groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST") end, 1) C_Timer.NewTimer(10, function()
groupInviteFrame:UnregisterEvent("PARTY_INVITE_REQUEST")
end, 1)
return { "+" } return { "+" }
end end
local function LeaveGroup() local function LeaveGroup()
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then print(string.format("[%s] LeaveGroup command received", ModuleName)) end
print(string.format("[%s] LeaveGroup command received", ModuleName))
end
LeaveParty() LeaveParty()
return {} return {}
end end
---@param target string ---@param target string
local function FollowTarget(target) local function FollowTarget(target)
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then print(string.format("[%s] Following target: %s", ModuleName, target)) end
print(string.format("[%s] Following target: %s", ModuleName, target))
end
if not target then return end if not target then return end
FollowUnit(target) FollowUnit(target)
return {} return {}
@@ -269,13 +218,14 @@ shared.Commander = {
---@param args string[] ---@param args string[]
local function MacroTarget(args) local function MacroTarget(args)
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack print(string.format("[%s] Macroing: %s", ModuleName,
print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args)))) strjoin(" ", unpack(args))))
end end
if #args < 2 or #args % 2 ~= 0 then if #args < 2 or #args % 2 ~= 0 then
if #args < 2 or #args % 2 ~= 0 then if #args < 2 or #args % 2 ~= 0 then
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Invalid number of arguments for MacroTarget", ModuleName)) print(string.format(
"[%s] Invalid number of arguments for MacroTarget", ModuleName))
end end
return {} return {}
end end
@@ -289,40 +239,12 @@ shared.Commander = {
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Adding stinky: %s/%s", ModuleName, name, tostring(class))) print(string.format("[%s] Adding stinky: %s/%s", ModuleName, name, tostring(class)))
end end
shared.StinkyTracker.Track({ shared.stinkyTracker.stinkies[name] = {
name = name, name = name,
class = class or "unknown", class = class or "unknown",
seenAt = GetTime(), seenAt = GetTime(),
hostile = true, hostile = true
}) }
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Added stinky: %s/%s", ModuleName, name, tostring(class)))
end
end
return {}
end
---@param args string[]
local function IgnoreMacroTarget(args)
if Heimdall_Data.config.commander.debug then
---@diagnostic disable-next-line: param-type-mismatch something wrong with luals, it's picking up the "wrong" unpack
print(string.format("[%s] Macroing: %s", ModuleName, strjoin(" ", unpack(args))))
end
if #args < 1 then
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Invalid number of arguments for IgnoreMacroTarget", ModuleName))
end
return {}
end
table.remove(args, 1)
for i = 1, #args do
local stinky = strtrim(args[i])
local name = stinky:match("([^/]+)")
if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Ignoring stinky: %s", ModuleName, name))
end
shared.StinkyTracker.Ignore(name)
end end
return {} return {}
end end
@@ -334,7 +256,6 @@ shared.Commander = {
local commands = { local commands = {
{ keywordRe = "^who$", commanderOnly = false, callback = WhoPartitionedStinkies }, { keywordRe = "^who$", commanderOnly = false, callback = WhoPartitionedStinkies },
{ keywordRe = "^кто$", commanderOnly = false, callback = WhoPartitionedStinkiesRu },
{ keywordRe = "^howmany$", commanderOnly = false, callback = CountPartitionedStinkies }, { keywordRe = "^howmany$", commanderOnly = false, callback = CountPartitionedStinkies },
{ keywordRe = "^classes$", commanderOnly = false, callback = CountClassPartitionedStinkies }, { keywordRe = "^classes$", commanderOnly = false, callback = CountClassPartitionedStinkies },
{ keywordRe = "^help$", commanderOnly = false, callback = HelpRu }, { keywordRe = "^help$", commanderOnly = false, callback = HelpRu },
@@ -343,7 +264,6 @@ shared.Commander = {
{ keywordRe = "^leavegroup$", commanderOnly = false, callback = LeaveGroup }, { keywordRe = "^leavegroup$", commanderOnly = false, callback = LeaveGroup },
{ keywordRe = "^follow$", commanderOnly = false, callback = FollowTarget }, { keywordRe = "^follow$", commanderOnly = false, callback = FollowTarget },
{ keywordRe = "^macro", commanderOnly = false, callback = MacroTarget }, { keywordRe = "^macro", commanderOnly = false, callback = MacroTarget },
{ keywordRe = "^ignore", commanderOnly = false, callback = IgnoreMacroTarget },
} }
local commanderChannelFrame = CreateFrame("Frame") local commanderChannelFrame = CreateFrame("Frame")
@@ -351,7 +271,7 @@ shared.Commander = {
commanderChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...) commanderChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
--if Heimdall_Data.config.commander.debug then --if Heimdall_Data.config.commander.debug then
-- print(string.format("[%s] Event received", ModuleName)) -- print(string.format("[%s] Event received", ModuleName))
-- shared.dump(Heimdall_Data.config.commander) -- shared.dumpTable(Heimdall_Data.config.commander)
--end --end
if not Heimdall_Data.config.commander.enabled then if not Heimdall_Data.config.commander.enabled then
--if Heimdall_Data.config.commander.debug then --if Heimdall_Data.config.commander.debug then
@@ -370,14 +290,8 @@ shared.Commander = {
end end
if not ok then if not ok then
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print( print(string.format("[%s] Channel name '%s' does not match any of the channels '%s'", ModuleName,
string.format( channelname, table.concat(Heimdall_Data.config.commander.channels, ", ")))
"[%s] Channel name '%s' does not match any of the channels '%s'",
ModuleName,
channelname,
table.concat(Heimdall_Data.config.commander.channels, ", ")
)
)
end end
return return
end end
@@ -385,54 +299,41 @@ shared.Commander = {
sender = string.match(sender, "^[^-]+") sender = string.match(sender, "^[^-]+")
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Message from: %s", ModuleName, sender)) print(string.format("[%s] Message from: %s", ModuleName, sender))
shared.dump(Heimdall_Data.config.commander) shared.dumpTable(Heimdall_Data.config.commander)
end end
for _, command in ipairs(commands) do for _, command in ipairs(commands) do
local enabled = Heimdall_Data.config.commander.commands[command.keywordRe] == true or false local enabled = Heimdall_Data.config.commander.commands[command.keywordRe] == true or false
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print( print(string.format("[%s] Command match: %s = %s", ModuleName, command.keywordRe, tostring(enabled)))
string.format("[%s] Command match: %s = %s", ModuleName, command.keywordRe, tostring(enabled))
)
end end
if if enabled and
enabled (not command.commanderOnly
and ( or (command.commanderOnly
not command.commanderOnly and sender == Heimdall_Data.config.commander.commander)) then
-- if Heimdall_Data.config.commander.debug then print(string.format("[%s] Ignoring command, sender %s not commander %s", ModuleName, sender, Heimdall_Data.config.commander.commander)) end
or (command.commanderOnly and sender == Heimdall_Data.config.commander.commander)
)
then
if msg:match(command.keywordRe) then if msg:match(command.keywordRe) then
---@diagnostic disable-next-line: redundant-parameter Currently luals does not support variadic functions as a @field
local messages = command.callback({ strsplit(",", msg) }) local messages = command.callback({ strsplit(",", msg) })
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Messages to send: %s", ModuleName, #messages)) print(string.format("[%s] Messages to send: %s", ModuleName, strjoin(", ", unpack(messages))))
shared.dump(messages)
end end
for _, message in ipairs(messages) do for _, message in ipairs(messages) do
---@type Message ---@type Message
local returnmsg = { local msg = {
channel = "C", channel = "C",
data = channelname, data = channelname,
message = message, message = message
} }
if Heimdall_Data.config.commander.debug then if Heimdall_Data.config.commander.debug then
print(string.format("[%s] Queuing message", ModuleName)) print(string.format("[%s] Queuing message", ModuleName))
shared.dump(msg) shared.dumpTable(msg)
end
if Heimdall_Data.config.networkMessenger.enabled then
shared.NetworkMessenger.Enqueue(returnmsg)
elseif Heimdall_Data.config.messenger.enabled then
shared.Messenger.Enqueue(returnmsg)
end end
--table.insert(shared.messenger.queue, msg)
table.insert(shared.networkMessenger.queue, msg)
end end
end end
end end
end end
end) end)
print(string.format("[%s] Module initialized", ModuleName)) print("[Heimdall] Commander module loaded")
end, end
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,12 +1,10 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Configurator" local ModuleName = "Configurator"
---@class HeimdallConfiguratorConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.Configurator = {}
---@field debug boolean function shared.Configurator.Init()
print("[Heimdall] Configurator module loaded")
---@class Configurator end
shared.Configurator = {
Init = function() print(string.format("[%s] Module initialized", ModuleName)) end,
}

View File

@@ -1,19 +1,11 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "DeathReporter" local ModuleName = "DeathReporter"
---@class HeimdallDeathReporterConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.DeathReporter = {}
---@field debug boolean function shared.DeathReporter.Init()
---@field throttle number
---@field doWhisper boolean
---@field channels string[]
---@field zoneOverride string?
---@field duelThrottle number
---@class DeathReporter
shared.DeathReporter = {
Init = function()
---@type table<string, number> ---@type table<string, number>
local recentDeaths = {} local recentDeaths = {}
---@type table<string, number> ---@type table<string, number>
@@ -24,15 +16,8 @@ shared.DeathReporter = {
---@param spellName string ---@param spellName string
local function RegisterDeath(source, destination, spellName) local function RegisterDeath(source, destination, spellName)
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print( print(string.format("[%s] Processing death event - Source: %s, Target: %s, Spell: %s",
string.format( ModuleName, source, destination, spellName))
"[%s] Processing death event - Source: %s, Target: %s, Spell: %s",
ModuleName,
source,
destination,
spellName
)
)
end end
if not Heimdall_Data.config.deathReporter.enabled then if not Heimdall_Data.config.deathReporter.enabled then
@@ -42,53 +27,27 @@ shared.DeathReporter = {
return return
end end
if if recentDeaths[destination] and GetTime() - recentDeaths[destination] < Heimdall_Data.config.deathReporter.throttle then
recentDeaths[destination]
and GetTime() - recentDeaths[destination] < Heimdall_Data.config.deathReporter.throttle
then
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
local timeLeft = Heimdall_Data.config.deathReporter.throttle local timeLeft = Heimdall_Data.config.deathReporter.throttle - (GetTime() - recentDeaths[destination])
- (GetTime() - recentDeaths[destination]) print(string.format("[%s] Death report throttled for %s (%.1f seconds remaining)",
print( ModuleName, destination, timeLeft))
string.format(
"[%s] Death report throttled for %s (%.1f seconds remaining)",
ModuleName,
destination,
timeLeft
)
)
end end
return return
end end
if if recentDuels[destination] and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then
recentDuels[destination]
and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle
then
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print( print(string.format("[%s] Ignoring death report - Recent duel detected for target: %s", ModuleName,
string.format( destination))
"[%s] Ignoring death report - Recent duel detected for target: %s",
ModuleName,
destination
)
)
end end
return return
end end
if if recentDuels[source] and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle then
recentDuels[source]
and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle
then
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print( print(string.format("[%s] Ignoring death report - Recent duel detected for source: %s", ModuleName,
string.format( source))
"[%s] Ignoring death report - Recent duel detected for source: %s",
ModuleName,
source
)
)
end end
return return
end end
@@ -99,48 +58,25 @@ shared.DeathReporter = {
recentDeaths[destination] = GetTime() recentDeaths[destination] = GetTime()
C_Timer.NewTimer(3, function() C_Timer.NewTimer(3, function()
if if recentDuels[destination] and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle then
recentDuels[destination]
and GetTime() - recentDuels[destination] < Heimdall_Data.config.deathReporter.duelThrottle
then
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print( print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName,
string.format( destination))
"[%s] Cancelling delayed death report - Recent duel detected for: %s",
ModuleName,
destination
)
)
end end
return return
end end
if if recentDuels[source] and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle then
recentDuels[source]
and GetTime() - recentDuels[source] < Heimdall_Data.config.deathReporter.duelThrottle
then
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print( print(string.format("[%s] Cancelling delayed death report - Recent duel detected for: %s", ModuleName,
string.format( source))
"[%s] Cancelling delayed death report - Recent duel detected for: %s",
ModuleName,
source
)
)
end end
return return
end end
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print( print(string.format("[%s] Sending death report - %s killed %s with %s",
string.format( ModuleName, source, destination, spellName))
"[%s] Sending death report - %s killed %s with %s",
ModuleName,
source,
destination,
spellName
)
)
end end
local zone, subzone = GetZoneText() or "Unknown", GetSubZoneText() or "Unknown" local zone, subzone = GetZoneText() or "Unknown", GetSubZoneText() or "Unknown"
@@ -159,26 +95,22 @@ shared.DeathReporter = {
for _, channel in pairs(Heimdall_Data.config.deathReporter.channels) do for _, channel in pairs(Heimdall_Data.config.deathReporter.channels) do
local locale = shared.GetLocaleForChannel(channel) local locale = shared.GetLocaleForChannel(channel)
local text = string.format( local text = string.format(shared._L("killed", locale),
shared._L("killed", locale),
source, source,
destination, destination,
shared._L(spellName, locale), shared._L(spellName, locale),
shared._L(zone, locale), shared._L(zone, locale), shared._L(subzone, locale),
shared._L(subzone, locale),
zoneId, zoneId,
x * 100, x * 100, y * 100)
y * 100
)
---@type Message ---@type Message
local msg = { local msg = {
channel = "C", channel = "C",
data = channel, data = channel,
message = text, message = text
} }
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Queuing death report message", ModuleName)) print(string.format("[%s] Queuing death report message", ModuleName))
shared.dump(msg) shared.dumpTable(msg)
end end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
end end
@@ -192,33 +124,32 @@ shared.DeathReporter = {
-- print(string.format("[%s] Received combat log event", ModuleName)) -- print(string.format("[%s] Received combat log event", ModuleName))
-- end -- end
if not Heimdall_Data.config.deathReporter.enabled then return end if not Heimdall_Data.config.deathReporter.enabled then return end
local overkill, source, destination, spellName, sourceGUID, destinationGUID, err local overkill, err = CLEUParser.GetOverkill(...)
overkill, err = CLEUParser.GetOverkill(...)
if not err and overkill > 0 then if not err and overkill > 0 then
source, err = CLEUParser.GetSourceName(...) local source, err = CLEUParser.GetSourceName(...)
if err then if err then
source = "unknown" source = "unknown"
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Error getting source name", ModuleName)) print(string.format("[%s] Error getting source name", ModuleName))
end end
end end
destination, err = CLEUParser.GetDestName(...) local destination, err = CLEUParser.GetDestName(...)
if err then if err then
destination = "unknown" destination = "unknown"
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Error getting destination name", ModuleName)) print(string.format("[%s] Error getting destination name", ModuleName))
end end
end end
spellName, err = CLEUParser.GetSpellName(...) local spellName, err = CLEUParser.GetSpellName(...)
if err then if err then
spellName = "unknown" spellName = "unknown"
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Error getting spell name", ModuleName)) print(string.format("[%s] Error getting spell name", ModuleName))
end end
end end
sourceGUID, err = CLEUParser.GetSourceGUID(...) local sourceGUID, err = CLEUParser.GetSourceGUID(...)
if err or not string.match(sourceGUID, "Player") then return end if err or not string.match(sourceGUID, "Player") then return end
destinationGUID, err = CLEUParser.GetDestGUID(...) local destinationGUID, err = CLEUParser.GetDestGUID(...)
if err or not string.match(destinationGUID, "Player") then return end if err or not string.match(destinationGUID, "Player") then return end
RegisterDeath(source, destination, spellName) RegisterDeath(source, destination, spellName)
end end
@@ -231,14 +162,7 @@ shared.DeathReporter = {
local source, destination = string.match(msg, "([^ ]+) has defeated ([^ ]+) in a duel") local source, destination = string.match(msg, "([^ ]+) has defeated ([^ ]+) in a duel")
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print(string.format("[%s] Received system message: %s", ModuleName, msg)) print(string.format("[%s] Received system message: %s", ModuleName, msg))
print( print(string.format("[%s] Source: %s, Destination: %s", ModuleName, tostring(source), tostring(destination)))
string.format(
"[%s] Source: %s, Destination: %s",
ModuleName,
tostring(source),
tostring(destination)
)
)
end end
if not source or not destination then return end if not source or not destination then return end
source = string.match(source, "([^-]+)") source = string.match(source, "([^-]+)")
@@ -254,15 +178,8 @@ shared.DeathReporter = {
end) end)
if Heimdall_Data.config.deathReporter.debug then if Heimdall_Data.config.deathReporter.debug then
print( print(string.format("[%s] Module initialized with throttle: %.1fs, duel throttle: %.1fs",
string.format( ModuleName, Heimdall_Data.config.deathReporter.throttle, Heimdall_Data.config.deathReporter.duelThrottle))
"[%s] Module initialized with throttle: %.1fs, duel throttle: %.1fs",
ModuleName,
Heimdall_Data.config.deathReporter.throttle,
Heimdall_Data.config.deathReporter.duelThrottle
)
)
end end
print(string.format("[%s] Module initialized", ModuleName)) print("[Heimdall] DeathReporter loaded")
end, end
}

View File

@@ -1,15 +1,11 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Dueler" local ModuleName = "Dueler"
---@class HeimdallDuelerConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.Dueler = {}
---@field debug boolean function shared.Dueler.Init()
---@field declineOther boolean
---@class Dueler
shared.Dueler = {
Init = function()
local frame = CreateFrame("Frame") local frame = CreateFrame("Frame")
frame:RegisterEvent("DUEL_REQUESTED") frame:RegisterEvent("DUEL_REQUESTED")
frame:SetScript("OnEvent", function(self, event, sender) frame:SetScript("OnEvent", function(self, event, sender)
@@ -27,7 +23,7 @@ shared.Dueler = {
print(string.format("[%s] Checking if sender '%s' is in agents list", ModuleName, sender)) print(string.format("[%s] Checking if sender '%s' is in agents list", ModuleName, sender))
end end
local allow = shared.AgentTracker.IsAgent(sender) local allow = Heimdall_Data.config.agents[sender]
if allow then if allow then
if Heimdall_Data.config.dueler.debug then if Heimdall_Data.config.dueler.debug then
print(string.format("[%s] Accepting duel from trusted agent: %s", ModuleName, sender)) print(string.format("[%s] Accepting duel from trusted agent: %s", ModuleName, sender))
@@ -41,23 +37,15 @@ shared.Dueler = {
CancelDuel() CancelDuel()
else else
if Heimdall_Data.config.dueler.debug then if Heimdall_Data.config.dueler.debug then
print( print(string.format("[%s] Leaving duel request from %s for manual response", ModuleName, sender))
string.format("[%s] Leaving duel request from %s for manual response", ModuleName, sender)
)
end end
end end
end end
end) end)
if Heimdall_Data.config.dueler.debug then if Heimdall_Data.config.dueler.debug then
print( print(string.format("[%s] Module initialized with auto-decline: %s", ModuleName,
string.format( tostring(Heimdall_Data.config.dueler.declineOther)))
"[%s] Module initialized with auto-decline: %s",
ModuleName,
tostring(Heimdall_Data.config.dueler.declineOther)
)
)
end end
print(string.format("[%s] Module initialized", ModuleName)) print("[Heimdall] Dueler loaded")
end, end
}

View File

@@ -1,31 +1,28 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
if not shared.dump then if not shared.dumpTable then
---@param value any ---@param table table
---@param msg string?
---@param depth number? ---@param depth number?
shared.dump = function(value, msg, depth) shared.dumpTable = function(table, depth)
if not value then if not table then
print(tostring(value)) print(tostring(table))
return return
end end
if type(value) ~= "table" then if depth == nil then
print(tostring(value)) depth = 0
end
if (depth > 200) then
print("Error: Depth > 200 in dumpTable()")
return return
end end
if msg then print(msg) end for k, v in pairs(table) do
if depth == nil then depth = 0 end if (type(v) == "table") then
if depth > 200 then print(string.rep(" ", depth) .. k .. ":")
print("Error: Depth > 200 in dump()") shared.dumpTable(v, depth + 1)
return
end
for k, v in pairs(value) do
if type(v) == "table" then
print(string.rep(" ", depth) .. tostring(k) .. ":")
shared.dump(v, msg, depth + 1)
else else
print(string.rep(" ", depth) .. tostring(k) .. ": " .. tostring(v)) print(string.rep(" ", depth) .. k .. ": ", v)
end end
end end
end end

View File

@@ -1,16 +1,11 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Echoer" local ModuleName = "Echoer"
---@class HeimdallEchoerConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.Echoer = {}
---@field debug boolean function shared.Echoer.Init()
---@field channels string[]
---@field prefix string
---@class Echoer
shared.Echoer = {
Init = function()
local frame = CreateFrame("Frame") local frame = CreateFrame("Frame")
frame:RegisterEvent("CHAT_MSG_CHANNEL") frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:SetScript("OnEvent", function(self, event, msg, sender, ...) frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
@@ -42,24 +37,25 @@ shared.Echoer = {
end end
if Heimdall_Data.config.echoer.debug then if Heimdall_Data.config.echoer.debug then
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
shared.dump(Heimdall_Data.config.echoer) shared.dumpTable(Heimdall_Data.config.echoer)
end end
if string.find(msg, "^" .. Heimdall_Data.config.echoer.prefix) then if string.find(msg, "^" .. Heimdall_Data.config.echoer.prefix) then
if Heimdall_Data.config.echoer.debug then if Heimdall_Data.config.echoer.debug then
print(string.format("[%s] Found echo command in message: %s", ModuleName, msg)) print(string.format("[%s] Found echo command in message: %s", ModuleName, msg))
end end
local echomsg = string.sub(msg, string.len(Heimdall_Data.config.echoer.prefix) + 1) local msg = string.sub(msg, string.len(Heimdall_Data.config.echoer.prefix) + 1)
if Heimdall_Data.config.echoer.debug then if Heimdall_Data.config.echoer.debug then
print(string.format("[%s] Echoing message: %s", ModuleName, echomsg)) print(string.format("[%s] Echoing message: %s", ModuleName, msg))
end end
SendChatMessage(echomsg, "SAY") SendChatMessage(msg, "SAY")
elseif Heimdall_Data.config.echoer.debug then elseif Heimdall_Data.config.echoer.debug then
print(string.format("[%s] Message does not start with echo prefix", ModuleName)) print(string.format("[%s] Message does not start with echo prefix", ModuleName))
end end
end) end)
if Heimdall_Data.config.echoer.debug then print(string.format("[%s] Module initialized", ModuleName)) end if Heimdall_Data.config.echoer.debug then
print(string.format("[%s] Module initialized", ModuleName)) print(string.format("[%s] Module initialized", ModuleName))
end, end
} print("[Heimdall] Echoer loaded")
end

View File

@@ -1,16 +1,11 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Emoter" local ModuleName = "Emoter"
---@class HeimdallEmoterConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.Emoter = {}
---@field debug boolean function shared.Emoter.Init()
---@field channels string[]
---@field prefix string
---@class Emoter
shared.Emoter = {
Init = function()
local frame = CreateFrame("Frame") local frame = CreateFrame("Frame")
frame:RegisterEvent("CHAT_MSG_CHANNEL") frame:RegisterEvent("CHAT_MSG_CHANNEL")
frame:SetScript("OnEvent", function(self, event, msg, sender, ...) frame:SetScript("OnEvent", function(self, event, msg, sender, ...)
@@ -43,7 +38,7 @@ shared.Emoter = {
if Heimdall_Data.config.emoter.debug then if Heimdall_Data.config.emoter.debug then
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
shared.dump(Heimdall_Data.config.emoter) shared.dumpTable(Heimdall_Data.config.emoter)
end end
if string.find(msg, "^" .. Heimdall_Data.config.emoter.prefix) then if string.find(msg, "^" .. Heimdall_Data.config.emoter.prefix) then
@@ -60,7 +55,8 @@ shared.Emoter = {
end end
end) end)
if Heimdall_Data.config.emoter.debug then print(string.format("[%s] Module initialized", ModuleName)) end if Heimdall_Data.config.emoter.debug then
print(string.format("[%s] Module initialized", ModuleName)) print(string.format("[%s] Module initialized", ModuleName))
end, end
} print("[Heimdall] Emoter loaded")
end

View File

@@ -1,27 +1,14 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Inviter" local ModuleName = "Inviter"
---@class HeimdallInviterConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.Inviter = {}
---@field debug boolean function shared.Inviter.Init()
---@field channels string[]
---@field keyword string
---@field allAssist boolean
---@field agentsAssist boolean
---@field throttle number
---@field kickOffline boolean
---@field cleanupInterval number
---@field afkThreshold number
---@field listeningChannel table<string, boolean>
---@class Inviter
shared.Inviter = {
Init = function()
-- Fallback for old config
if type(Heimdall_Data.config.inviter.listeningChannel) == "string" then if type(Heimdall_Data.config.inviter.listeningChannel) == "string" then
Heimdall_Data.config.inviter.listeningChannel = { Heimdall_Data.config.inviter.listeningChannel = {
[Heimdall_Data.config.inviter.listeningChannel] = true, [Heimdall_Data.config.inviter.listeningChannel] = true
} }
end end
---@type Timer ---@type Timer
@@ -48,25 +35,27 @@ shared.Inviter = {
if Heimdall_Data.config.inviter.agentsAssist then if Heimdall_Data.config.inviter.agentsAssist then
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print(string.format("[%s] Processing agents for assistant promotion", ModuleName)) local agentCount = 0
for _ in pairs(Heimdall_Data.config.agents) do agentCount = agentCount + 1 end
print(string.format("[%s] Processing %d agents for assistant promotion", ModuleName, agentCount))
end end
shared.AgentTracker.ForEach(function(agent) for name, _ in pairs(Heimdall_Data.config.agents) do
if UnitInParty(agent) and not UnitIsGroupLeader(agent) and not UnitIsRaidOfficer(agent) then if UnitInParty(name) and not UnitIsGroupLeader(name) and not UnitIsRaidOfficer(name) then
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print(string.format("[%s] Promoting agent to assistant: %s", ModuleName, agent)) print(string.format("[%s] Promoting agent to assistant: %s", ModuleName, name))
end end
PromoteToAssistant(agent, true) PromoteToAssistant(name, true)
elseif Heimdall_Data.config.inviter.debug then elseif Heimdall_Data.config.inviter.debug then
if not UnitInParty(agent) then if not UnitInParty(name) then
print(string.format("[%s] Agent not in party: %s", ModuleName, agent)) print(string.format("[%s] Agent not in party: %s", ModuleName, name))
elseif UnitIsGroupLeader(agent) then elseif UnitIsGroupLeader(name) then
print(string.format("[%s] Agent is already leader: %s", ModuleName, agent)) print(string.format("[%s] Agent is already leader: %s", ModuleName, name))
elseif UnitIsRaidOfficer(agent) then elseif UnitIsRaidOfficer(name) then
print(string.format("[%s] Agent is already assistant: %s", ModuleName, agent)) print(string.format("[%s] Agent is already assistant: %s", ModuleName, name))
end
end end
end end
end)
end end
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
@@ -111,18 +100,10 @@ shared.Inviter = {
local frame = FindPlayerRaidFrame(name) local frame = FindPlayerRaidFrame(name)
if frame then if frame then
playerButtons[name] = frame playerButtons[name] = frame
-- All of these are ELVUI specific so they won't be in our meta... local button = framePool[frame.unit] or CreateFrame("Button",
---@diagnostic disable-next-line: undefined-field string.format("HeimdallKickButton%s", frame.unit, frame, "SecureActionButtonTemplate"))
local button = framePool[frame.unit]
or CreateFrame(
"Button",
---@diagnostic disable-next-line: undefined-field
string.format("HeimdallKickButton%s", frame.unit, frame, "SecureActionButtonTemplate")
)
---@diagnostic disable-next-line: undefined-field
framePool[frame.unit] = button framePool[frame.unit] = button
---@diagnostic disable-next-line: undefined-field
button:SetSize(frame.UNIT_WIDTH / 2, frame.UNIT_HEIGHT / 2) button:SetSize(frame.UNIT_WIDTH / 2, frame.UNIT_HEIGHT / 2)
button:SetPoint("CENTER", frame, "CENTER", 0, 0) button:SetPoint("CENTER", frame, "CENTER", 0, 0)
button:SetNormalTexture("Interface\\Buttons\\UI-GroupLoot-KickIcon") button:SetNormalTexture("Interface\\Buttons\\UI-GroupLoot-KickIcon")
@@ -161,7 +142,9 @@ shared.Inviter = {
groupMembers[name] = now groupMembers[name] = now
else else
local online = UnitIsConnected(unit) local online = UnitIsConnected(unit)
if online then groupMembers[name] = now end if online then
groupMembers[name] = now
end
end end
end end
end end
@@ -214,7 +197,7 @@ shared.Inviter = {
inviterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...) inviterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
--if Heimdall_Data.config.inviter.debug then --if Heimdall_Data.config.inviter.debug then
-- print(string.format("[%s] Chat message received: %s", ModuleName, msg)) -- print(string.format("[%s] Chat message received: %s", ModuleName, msg))
-- shared.dump(Heimdall_Data.config.inviter) -- shared.dumpTable(Heimdall_Data.config.inviter)
--end --end
if not Heimdall_Data.config.inviter.enabled then return end if not Heimdall_Data.config.inviter.enabled then return end
local channelId = select(6, ...) local channelId = select(6, ...)
@@ -250,26 +233,17 @@ shared.Inviter = {
end) end)
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print( print(string.format("[%s] Module initialized - All assist: %s, Agents assist: %s",
string.format(
"[%s] Module initialized - All assist: %s, Agents assist: %s",
ModuleName, ModuleName,
tostring(Heimdall_Data.config.inviter.allAssist), tostring(Heimdall_Data.config.inviter.allAssist),
tostring(Heimdall_Data.config.inviter.agentsAssist) tostring(Heimdall_Data.config.inviter.agentsAssist)))
)
)
end end
if Heimdall_Data.config.inviter.debug then if Heimdall_Data.config.inviter.debug then
print( print(string.format("[%s] Module initialized - All assist: %s, Agents assist: %s",
string.format(
"[%s] Module initialized - All assist: %s, Agents assist: %s",
ModuleName, ModuleName,
tostring(Heimdall_Data.config.inviter.allAssist), tostring(Heimdall_Data.config.inviter.allAssist),
tostring(Heimdall_Data.config.inviter.agentsAssist) tostring(Heimdall_Data.config.inviter.agentsAssist)))
)
)
end end
print(string.format("[%s] Module initialized", ModuleName)) print("[Heimdall] Inviter loaded")
end, end
}

View File

@@ -1,15 +1,17 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Macroer" local ModuleName = "Macroer"
---@class HeimdallMacroerConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.Macroer = {}
---@field debug boolean function shared.Macroer.Init()
---@field priority string[] ---@class stinky
---@field name string
---@field class string
---@field seenAt number
---@field hostile boolean
---@class Macroer
shared.Macroer = {
Init = function()
local function FindOrCreateMacro(macroName) local function FindOrCreateMacro(macroName)
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Finding or creating macro: %s", ModuleName, macroName)) print(string.format("[%s] Finding or creating macro: %s", ModuleName, macroName))
@@ -22,11 +24,13 @@ shared.Macroer = {
CreateMacro(macroName, "INV_Misc_QuestionMark", "") CreateMacro(macroName, "INV_Misc_QuestionMark", "")
end end
idx = GetMacroIndexByName(macroName) idx = GetMacroIndexByName(macroName)
if Heimdall_Data.config.macroer.debug then print(string.format("[%s] Macro index: %d", ModuleName, idx)) end if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Macro index: %d", ModuleName, idx))
end
return idx return idx
end end
---@param stinkies table<string, Stinky> ---@param stinkies table<string, stinky>
local function FixMacro(stinkies) local function FixMacro(stinkies)
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Fixing macro with %d stinkies", ModuleName, #stinkies)) print(string.format("[%s] Fixing macro with %d stinkies", ModuleName, #stinkies))
@@ -52,7 +56,9 @@ shared.Macroer = {
local sortedStinkies = {} local sortedStinkies = {}
for _, stinky in pairs(stinkies) do for _, stinky in pairs(stinkies) do
if not shared.AgentTracker.IsAgent(stinky.name) then sortedStinkies[#sortedStinkies + 1] = stinky end if not Heimdall_Data.config.agents[stinky.name] then
sortedStinkies[#sortedStinkies + 1] = stinky
end
end end
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
@@ -67,7 +73,7 @@ shared.Macroer = {
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Sorted stinkies: %d", ModuleName, #sortedStinkies)) print(string.format("[%s] Sorted stinkies: %d", ModuleName, #sortedStinkies))
shared.dump(sortedStinkies) shared.dumpTable(sortedStinkies)
end end
local lines = { "/targetenemy" } local lines = { "/targetenemy" }
for _, stinky in pairs(sortedStinkies) do for _, stinky in pairs(sortedStinkies) do
@@ -80,7 +86,6 @@ shared.Macroer = {
end end
local idx = FindOrCreateMacro("HeimdallTarget") local idx = FindOrCreateMacro("HeimdallTarget")
---@diagnostic disable-next-line: param-type-mismatch
local body = strjoin("\n", unpack(lines)) local body = strjoin("\n", unpack(lines))
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Updating macro with %d lines", ModuleName, #lines)) print(string.format("[%s] Updating macro with %d lines", ModuleName, #lines))
@@ -88,14 +93,15 @@ shared.Macroer = {
EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body) EditMacro(idx, "HeimdallTarget", "INV_Misc_QuestionMark", body)
end end
shared.StinkyTracker.OnChange(function(stinkies) shared.stinkyTracker.stinkies:onChange(function(value)
if Heimdall_Data.config.macroer.debug then if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Stinkies changed, updating macro", ModuleName)) print(string.format("[%s] Stinkies changed, updating macro", ModuleName))
shared.dump(stinkies)
end end
FixMacro(stinkies) FixMacro(value)
end) end)
if Heimdall_Data.config.macroer.debug then print(string.format("[%s] Module initialized", ModuleName)) end
if Heimdall_Data.config.macroer.debug then
print(string.format("[%s] Module initialized", ModuleName)) print(string.format("[%s] Module initialized", ModuleName))
end, end
} print("[Heimdall] Macroer loaded")
end

View File

@@ -1,29 +1,15 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Messenger" local ModuleName = "Messenger"
---@class HeimdallMessengerConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.Messenger = {}
---@field debug boolean function shared.Messenger.Init()
---@field interval number ---@class Message
---@field message string
---@class HeimdallMessengerData ---@field channel string
---@field queue ReactiveValue<table<string, Message>> ---@field data string
---@field ticker Timer?
---@class Message
---@field message string
---@field channel string
---@field data string
---@class Messenger
shared.Messenger = {
---@param message Message
Enqueue = function(message) table.insert(shared.messenger.queue, message) end,
Init = function()
shared.messenger = {
queue = ReactiveValue.new({}),
}
local function FindOrJoinChannel(channelName, password) local function FindOrJoinChannel(channelName, password)
local channelId = GetChannelName(channelName) local channelId = GetChannelName(channelName)
@@ -44,76 +30,55 @@ shared.Messenger = {
return channelId return channelId
end end
---@diagnostic disable-next-line: missing-fields
if not shared.messenger then shared.messenger = {} end
if not shared.messenger.queue then shared.messenger.queue = {} end
if not shared.messenger.ticker then if not shared.messenger.ticker then
local function DoMessage() local function DoMessage()
-- if Heimdall_Data.config.messenger.debug then --if Heimdall_Data.config.messenger.debug then
-- print( -- print(string.format("[%s] Processing message queue", ModuleName))
-- string.format( --end
-- "[%s] Processing message queue - Size: %d",
-- ModuleName,
-- #shared.messenger.queue:get()
-- )
-- )
-- end
if not Heimdall_Data.config.messenger.enabled then if not Heimdall_Data.config.messenger.enabled then
-- if Heimdall_Data.config.messenger.debug then --if Heimdall_Data.config.messenger.debug then
-- print(string.format("[%s] Module disabled, skipping message processing", ModuleName)) -- print(string.format("[%s] Module disabled, skipping message processing", ModuleName))
-- end --end
return return
end end
---@type Message ---@type Message
local message = shared.messenger.queue[1] local message = shared.messenger.queue[1]
if not message then if not message then
-- if Heimdall_Data.config.messenger.debug then --if Heimdall_Data.config.messenger.debug then
-- print(string.format("[%s] Message queue empty", ModuleName)) -- print(string.format("[%s] Message queue empty", ModuleName))
-- end --end
return return
end end
if Heimdall_Data.config.messenger.debug then shared.dump(message, "[%s] Processing message:") end
if not message.message or message.message == "" then if not message.message or message.message == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dump(message, string.format("[%s] Invalid message: empty content", ModuleName)) print(string.format("[%s] Invalid message: empty content", ModuleName))
end end
return return
end end
if not message.channel or message.channel == "" then if not message.channel or message.channel == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dump(message, string.format("[%s] Invalid message: no channel specified", ModuleName)) print(string.format("[%s] Invalid message: no channel specified", ModuleName))
end end
return return
end end
if string.find(message.channel, "^C") then if string.find(message.channel, "^C") then
if Heimdall_Data.config.messenger.debug then
shared.dump(
message,
string.format("[%s] Converting channel type from C to CHANNEL", ModuleName)
)
end
message.channel = "CHANNEL" message.channel = "CHANNEL"
elseif string.find(message.channel, "^W") then elseif string.find(message.channel, "^W") then
if Heimdall_Data.config.messenger.debug then
shared.dump(
message,
string.format("[%s] Converting channel type from W to WHISPER", ModuleName)
)
end
message.channel = "WHISPER" message.channel = "WHISPER"
end end
if message.channel == "CHANNEL" and message.data and string.match(message.data, "%D") then if message.channel == "CHANNEL" and message.data and string.match(message.data, "%D") then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dump(message, string.format("[%s] Processing channel message:", ModuleName)) print(string.format("[%s] Processing channel message: '%s' to '%s'", ModuleName, message.message,
message.data))
end end
local channelId = GetChannelName(message.data) local channelId = GetChannelName(message.data)
if channelId == 0 then if channelId == 0 then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dump(message, string.format("[%s] Channel not found, joining:", ModuleName)) print(string.format("[%s] Channel not found, attempting to join: %s", ModuleName, message.data))
end end
channelId = FindOrJoinChannel(message.data) channelId = FindOrJoinChannel(message.data)
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
@@ -126,36 +91,38 @@ shared.Messenger = {
table.remove(shared.messenger.queue, 1) table.remove(shared.messenger.queue, 1)
if not message.message or message.message == "" then if not message.message or message.message == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dump(message, string.format("[%s] Skipping empty message", ModuleName)) print(string.format("[%s] Skipping empty message", ModuleName))
end end
return return
end end
if not message.channel or message.channel == "" then if not message.channel or message.channel == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dump(message, string.format("[%s] Skipping message with no channel", ModuleName)) print(string.format("[%s] Skipping message with no channel", ModuleName))
end end
return return
end end
if not message.data or message.data == "" then if not message.data or message.data == "" then
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dump(message, string.format("[%s] Skipping message with no data", ModuleName)) print(string.format("[%s] Skipping message with no data", ModuleName))
end end
return return
end end
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
shared.dump(message, string.format("[%s] Sending message:", ModuleName)) print(string.format("[%s] Sending message: '%s' to %s:%s", ModuleName, message.message, message.channel,
message.data))
end end
if string.len(message.message) > 255 then if string.len(message.message) > 255 then
shared.dump(message, string.format("[%s] Message too long!!!!: %s", ModuleName, message.message)) print(string.format("[%s] Message too long!!!!: %s", ModuleName, message.message))
return return
end end
SendChatMessage(message.message, message.channel, nil, message.data) SendChatMessage(message.message, message.channel, nil, message.data)
end end
local function Tick() local function Tick()
-- if Heimdall_Data.config.messenger.debug then --if Heimdall_Data.config.messenger.debug then
-- print(string.format("[%s] Tick - Queue size: %d", ModuleName, #shared.messenger.queue:get())) -- local queueSize = #shared.messenger.queue
-- end -- print(string.format("[%s] Queue check - Messages pending: %d", ModuleName, queueSize))
--end
DoMessage() DoMessage()
shared.messenger.ticker = C_Timer.NewTimer(Heimdall_Data.config.messenger.interval, Tick, 1) shared.messenger.ticker = C_Timer.NewTimer(Heimdall_Data.config.messenger.interval, Tick, 1)
end end
@@ -163,14 +130,8 @@ shared.Messenger = {
end end
if Heimdall_Data.config.messenger.debug then if Heimdall_Data.config.messenger.debug then
print( print(string.format("[%s] Module initialized with interval: %s", ModuleName,
string.format( Heimdall_Data.config.messenger.interval))
"[%s] Module initialized with interval: %s",
ModuleName,
Heimdall_Data.config.messenger.interval
)
)
end end
print(string.format("[%s] Module initialized", ModuleName)) print("[Heimdall] Messenger loaded")
end, end
}

View File

@@ -1,42 +1,15 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "MinimapTagger" local ModuleName = "MinimapTagger"
---@class HeimdallMinimapTaggerConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field throttle number
---@field scale number
---@field tagTTL number
---@field tagSound boolean
---@field tagSoundFile string
---@field tagSoundThrottle number
---@field tagTextureFile string
---@field alertTTL number
---@field alertSound boolean
---@field alertSoundFile string
---@field alertSoundThrottle number
---@field alertTextureFile string
---@field combatTTL number
---@field combatSound boolean
---@field combatSoundFile string
---@field combatSoundThrottle number
---@field combatTextureFile string
---@field helpTTL number
---@field helpSound boolean
---@field helpSoundFile string
---@field helpSoundThrottle number
---@field helpTextureFile string
local HeimdallRoot = "Interface\\AddOns\\Heimdall\\" local HeimdallRoot = "Interface\\AddOns\\Heimdall\\"
local SoundRoot = HeimdallRoot .. "Sounds\\" local SoundRoot = HeimdallRoot .. "Sounds\\"
local TextureRoot = HeimdallRoot .. "Texture\\" local TextureRoot = HeimdallRoot .. "Texture\\"
--/run local a=GetChannelName("Agent")local b,c=GetPlayerMapPosition("player")b,c=b*100,c*100;local d=string.format("I need help at %s (%s) [%s](%2.2f, %2.2f)",GetZoneText(),GetSubZoneText(),GetCurrentMapAreaID(),b,c)SendChatMessage(d,"CHANNEL",nil,a) --/run local a=GetChannelName("Agent")local b,c=GetPlayerMapPosition("player")b,c=b*100,c*100;local d=string.format("I need help at %s (%s) [%s](%2.2f, %2.2f)",GetZoneText(),GetSubZoneText(),GetCurrentMapAreaID(),b,c)SendChatMessage(d,"CHANNEL",nil,a)
---@class MinimapTagger ---@diagnostic disable-next-line: missing-fields
shared.MinimapTagger = { shared.MinimapTagger = {}
Init = function() function shared.MinimapTagger.Init()
---@param x number ---@param x number
---@param y number ---@param y number
---@param frame Frame ---@param frame Frame
@@ -83,7 +56,7 @@ shared.MinimapTagger = {
self:SetAlpha(1) self:SetAlpha(1)
self.custom.busy = true self.custom.busy = true
self.custom.progress = 0 self.custom.progress = 0
self:SetScript("OnUpdate", function(selff, elapsed) self:SetScript("OnUpdate", function(self, elapsed)
self.custom.progress = self.custom.progress + elapsed self.custom.progress = self.custom.progress + elapsed
local progress = self.custom.progress / ttl local progress = self.custom.progress / ttl
-- if Heimdall_Data.config.minimapTagger.debug then -- if Heimdall_Data.config.minimapTagger.debug then
@@ -116,21 +89,14 @@ shared.MinimapTagger = {
table.insert(alertFramePool, frame) table.insert(alertFramePool, frame)
end end
local muteAlertUntil = 0 local muteAlertUntil = 0
---@param x number|nil ---@param x number
---@param y number|nil ---@param y number
---@param scale number? ---@param scale number?
---@param doTag boolean? ---@param doTag boolean?
local function PlantAlert(x, y, scale, doTag) local function PlantAlert(x, y, scale, doTag)
if x == nil or y == nil then
if Heimdall_Data.config.minimapTagger.debug then
print(string.format("[%s] Alert position is nil, ignoring", ModuleName))
end
return
end
if doTag == nil then doTag = true end if doTag == nil then doTag = true end
local frame = nil local frame = nil
for _, alertFrame in ipairs(alertFramePool) do for _, alertFrame in ipairs(alertFramePool) do
---@diagnostic disable-next-line: undefined-field
if not alertFrame.custom.busy then if not alertFrame.custom.busy then
frame = alertFrame frame = alertFrame
break break
@@ -144,13 +110,8 @@ shared.MinimapTagger = {
end end
if Heimdall_Data.config.minimapTagger.alertSound then if Heimdall_Data.config.minimapTagger.alertSound then
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
print( print(string.format("[%s] Playing alert sound: %s", ModuleName,
string.format( Heimdall_Data.config.minimapTagger.alertSoundFile))
"[%s] Playing alert sound: %s",
ModuleName,
Heimdall_Data.config.minimapTagger.alertSoundFile
)
)
end end
if muteAlertUntil > GetTime() then if muteAlertUntil > GetTime() then
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
@@ -160,17 +121,14 @@ shared.MinimapTagger = {
muteAlertUntil = GetTime() + Heimdall_Data.config.minimapTagger.alertSoundThrottle muteAlertUntil = GetTime() + Heimdall_Data.config.minimapTagger.alertSoundThrottle
local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.alertSoundFile, "Master") local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.alertSoundFile, "Master")
if not ok and Heimdall_Data.config.minimapTagger.debug then if not ok and Heimdall_Data.config.minimapTagger.debug then
print( print(string.format("[%s] Failed to play alert sound: %s", ModuleName,
string.format( Heimdall_Data.config.minimapTagger.alertSoundFile))
"[%s] Failed to play alert sound: %s",
ModuleName,
Heimdall_Data.config.minimapTagger.alertSoundFile
)
)
end end
end end
end end
if doTag then PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.alertTTL) end if doTag then
PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.alertTTL)
end
end end
--endregion --endregion
@@ -187,21 +145,14 @@ shared.MinimapTagger = {
table.insert(tagFramePool, frame) table.insert(tagFramePool, frame)
end end
local muteTagUntil = 0 local muteTagUntil = 0
---@param x number|nil ---@param x number
---@param y number|nil ---@param y number
---@param scale number? ---@param scale number?
---@param doTag boolean? ---@param doTag boolean?
local function PlantTag(x, y, scale, doTag) local function PlantTag(x, y, scale, doTag)
if x == nil or y == nil then
if Heimdall_Data.config.minimapTagger.debug then
print(string.format("[%s] Tag position is nil, ignoring", ModuleName))
end
return
end
if doTag == nil then doTag = true end if doTag == nil then doTag = true end
local frame = nil local frame = nil
for _, tagFrame in ipairs(tagFramePool) do for _, tagFrame in ipairs(tagFramePool) do
---@diagnostic disable-next-line: undefined-field
if not tagFrame.custom.busy then if not tagFrame.custom.busy then
frame = tagFrame frame = tagFrame
break break
@@ -215,13 +166,8 @@ shared.MinimapTagger = {
end end
if Heimdall_Data.config.minimapTagger.tagSound then if Heimdall_Data.config.minimapTagger.tagSound then
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
print( print(string.format("[%s] Playing tag sound: %s", ModuleName,
string.format( Heimdall_Data.config.minimapTagger.tagSoundFile))
"[%s] Playing tag sound: %s",
ModuleName,
Heimdall_Data.config.minimapTagger.tagSoundFile
)
)
end end
if muteTagUntil > GetTime() then if muteTagUntil > GetTime() then
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
@@ -231,17 +177,14 @@ shared.MinimapTagger = {
muteTagUntil = GetTime() + Heimdall_Data.config.minimapTagger.tagSoundThrottle muteTagUntil = GetTime() + Heimdall_Data.config.minimapTagger.tagSoundThrottle
local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.tagSoundFile, "Master") local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.tagSoundFile, "Master")
if not ok and Heimdall_Data.config.minimapTagger.debug then if not ok and Heimdall_Data.config.minimapTagger.debug then
print( print(string.format("[%s] Failed to play tag sound: %s", ModuleName,
string.format( Heimdall_Data.config.minimapTagger.tagSoundFile))
"[%s] Failed to play tag sound: %s",
ModuleName,
Heimdall_Data.config.minimapTagger.tagSoundFile
)
)
end end
end end
end end
if doTag then PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.tagTTL) end if doTag then
PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.tagTTL)
end
end end
--endregion --endregion
@@ -258,21 +201,14 @@ shared.MinimapTagger = {
table.insert(combatFramePool, frame) table.insert(combatFramePool, frame)
end end
local muteCombatUntil = 0 local muteCombatUntil = 0
---@param x number|nil ---@param x number
---@param y number|nil ---@param y number
---@param scale number? ---@param scale number?
---@param doTag boolean? ---@param doTag boolean?
local function PlantCombat(x, y, scale, doTag) local function PlantCombat(x, y, scale, doTag)
if x == nil or y == nil then
if Heimdall_Data.config.minimapTagger.debug then
print(string.format("[%s] Combat position is nil, ignoring", ModuleName))
end
return
end
if doTag == nil then doTag = true end if doTag == nil then doTag = true end
local frame = nil local frame = nil
for _, combatFrame in ipairs(combatFramePool) do for _, combatFrame in ipairs(combatFramePool) do
---@diagnostic disable-next-line: undefined-field
if not combatFrame.custom.busy then if not combatFrame.custom.busy then
frame = combatFrame frame = combatFrame
break break
@@ -286,13 +222,8 @@ shared.MinimapTagger = {
end end
if Heimdall_Data.config.minimapTagger.combatSound then if Heimdall_Data.config.minimapTagger.combatSound then
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
print( print(string.format("[%s] Playing combat sound: %s", ModuleName,
string.format( Heimdall_Data.config.minimapTagger.combatSoundFile))
"[%s] Playing combat sound: %s",
ModuleName,
Heimdall_Data.config.minimapTagger.combatSoundFile
)
)
end end
if muteCombatUntil > GetTime() then if muteCombatUntil > GetTime() then
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
@@ -302,17 +233,14 @@ shared.MinimapTagger = {
muteCombatUntil = GetTime() + Heimdall_Data.config.minimapTagger.combatSoundThrottle muteCombatUntil = GetTime() + Heimdall_Data.config.minimapTagger.combatSoundThrottle
local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.combatSoundFile, "Master") local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.combatSoundFile, "Master")
if not ok and Heimdall_Data.config.minimapTagger.debug then if not ok and Heimdall_Data.config.minimapTagger.debug then
print( print(string.format("[%s] Failed to play combat sound: %s", ModuleName,
string.format( Heimdall_Data.config.minimapTagger.combatSoundFile))
"[%s] Failed to play combat sound: %s",
ModuleName,
Heimdall_Data.config.minimapTagger.combatSoundFile
)
)
end end
end end
end end
if doTag then PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.combatTTL) end if doTag then
PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.combatTTL)
end
end end
--endregion --endregion
@@ -329,21 +257,14 @@ shared.MinimapTagger = {
table.insert(helpFramePool, frame) table.insert(helpFramePool, frame)
end end
local muteHelpUntil = 0 local muteHelpUntil = 0
---@param x number|nil ---@param x number
---@param y number|nil ---@param y number
---@param scale number? ---@param scale number?
---@param doTag boolean? ---@param doTag boolean?
local function PlantHelp(x, y, scale, doTag) local function PlantHelp(x, y, scale, doTag)
if x == nil or y == nil then
if Heimdall_Data.config.minimapTagger.debug then
print(string.format("[%s] Help position is nil, ignoring", ModuleName))
end
return
end
if doTag == nil then doTag = true end if doTag == nil then doTag = true end
local frame = nil local frame = nil
for _, helpFrame in ipairs(helpFramePool) do for _, helpFrame in ipairs(helpFramePool) do
---@diagnostic disable-next-line: undefined-field
if not helpFrame.custom.busy then if not helpFrame.custom.busy then
frame = helpFrame frame = helpFrame
break break
@@ -357,13 +278,8 @@ shared.MinimapTagger = {
end end
if Heimdall_Data.config.minimapTagger.helpSound then if Heimdall_Data.config.minimapTagger.helpSound then
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
print( print(string.format("[%s] Playing help sound: %s", ModuleName,
string.format( Heimdall_Data.config.minimapTagger.helpSoundFile))
"[%s] Playing help sound: %s",
ModuleName,
Heimdall_Data.config.minimapTagger.helpSoundFile
)
)
end end
if muteHelpUntil > GetTime() then if muteHelpUntil > GetTime() then
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
@@ -373,17 +289,14 @@ shared.MinimapTagger = {
muteHelpUntil = GetTime() + Heimdall_Data.config.minimapTagger.helpSoundThrottle muteHelpUntil = GetTime() + Heimdall_Data.config.minimapTagger.helpSoundThrottle
local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.helpSoundFile, "Master") local ok = PlaySoundFile(SoundRoot .. Heimdall_Data.config.minimapTagger.helpSoundFile, "Master")
if not ok and Heimdall_Data.config.minimapTagger.debug then if not ok and Heimdall_Data.config.minimapTagger.debug then
print( print(string.format("[%s] Failed to play help sound: %s", ModuleName,
string.format( Heimdall_Data.config.minimapTagger.helpSoundFile))
"[%s] Failed to play help sound: %s",
ModuleName,
Heimdall_Data.config.minimapTagger.helpSoundFile
)
)
end end
end end
end end
if doTag then PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.helpTTL) end if doTag then
PlantFrame(x, y, frame, scale, Heimdall_Data.config.minimapTagger.helpTTL)
end
end end
--endregion --endregion
@@ -410,23 +323,20 @@ shared.MinimapTagger = {
BattlefieldMinimap:SetMovable(true) BattlefieldMinimap:SetMovable(true)
BattlefieldMinimap:EnableMouse(true) BattlefieldMinimap:EnableMouse(true)
BattlefieldMinimap:RegisterForDrag("LeftButton") BattlefieldMinimap:RegisterForDrag("LeftButton")
BattlefieldMinimap:SetScript("OnDragStart", function(selff) selff:StartMoving() end) BattlefieldMinimap:SetScript("OnDragStart", function(self) self:StartMoving() end)
BattlefieldMinimap:SetScript("OnDragStop", function(selff) selff:StopMovingOrSizing() end) BattlefieldMinimap:SetScript("OnDragStop", function(self) self:StopMovingOrSizing() end)
BattlefieldMinimapBackground:Hide() BattlefieldMinimapBackground:Hide()
BattlefieldMinimapCloseButton:Hide() BattlefieldMinimapCloseButton:Hide()
BattlefieldMinimapCorner:Hide() BattlefieldMinimapCorner:Hide()
BattlefieldMinimap:HookScript("OnHide", function(selff) BattlefieldMinimap:HookScript("OnHide", function(self)
for _, alertFrame in ipairs(alertFramePool) do for _, alertFrame in ipairs(alertFramePool) do
alertFrame:Hide() alertFrame:Hide()
---@diagnostic disable-next-line: undefined-field
alertFrame.custom.busy = false alertFrame.custom.busy = false
end end
for _, tagFrame in ipairs(tagFramePool) do for _, tagFrame in ipairs(tagFramePool) do
tagFrame:Hide() tagFrame:Hide()
---@diagnostic disable-next-line: undefined-field
tagFrame.custom.busy = false tagFrame.custom.busy = false
end end
-- What the fuck is this global?
for _, battleFrame in ipairs(battleFramePool) do for _, battleFrame in ipairs(battleFramePool) do
battleFrame:Hide() battleFrame:Hide()
battleFrame.custom.busy = false battleFrame.custom.busy = false
@@ -460,20 +370,14 @@ shared.MinimapTagger = {
if not ok then if not ok then
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
print( print(string.format("[%s] Ignoring message from non-master channel: %s, need %s", ModuleName, channelname,
string.format( Heimdall_Data.config.minimapTagger.masterChannel))
"[%s] Ignoring message from non-master channel: %s, need %s",
ModuleName,
channelname,
Heimdall_Data.config.minimapTagger.masterChannel
)
)
end end
return return
end end
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
shared.dump(Heimdall_Data.config.minimapTagger) shared.dumpTable(Heimdall_Data.config.minimapTagger)
end end
local doTag = true local doTag = true
@@ -483,14 +387,8 @@ shared.MinimapTagger = {
local currentMapId = GetCurrentMapAreaID() local currentMapId = GetCurrentMapAreaID()
if currentMapId ~= messageMapId then if currentMapId ~= messageMapId then
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
print( print(string.format("[%s] Current map ID (%d) does not match message map ID (%d), ignoring message",
string.format( ModuleName, currentMapId, messageMapId))
"[%s] Current map ID (%d) does not match message map ID (%d), ignoring message",
ModuleName,
currentMapId,
messageMapId
)
)
end end
doTag = false doTag = false
end end
@@ -507,7 +405,9 @@ shared.MinimapTagger = {
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
print(string.format("[%s] Found alert position: %s, %s", ModuleName, tostring(x), tostring(y))) print(string.format("[%s] Found alert position: %s, %s", ModuleName, tostring(x), tostring(y)))
end end
if x and y then PlantTag(tonumber(x), tonumber(y), 2, doTag) end if x and y then
PlantTag(tonumber(x), tonumber(y), 2, doTag)
end
end end
--endregion --endregion
--region Combat --region Combat
@@ -525,7 +425,9 @@ shared.MinimapTagger = {
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
print(string.format("[%s] Found combat position: %s, %s", ModuleName, tostring(x), tostring(y))) print(string.format("[%s] Found combat position: %s, %s", ModuleName, tostring(x), tostring(y)))
end end
if x and y then PlantCombat(tonumber(x), tonumber(y), 2, doTag) end if x and y then
PlantCombat(tonumber(x), tonumber(y), 2, doTag)
end
end end
--endregion --endregion
--region Death --region Death
@@ -543,7 +445,9 @@ shared.MinimapTagger = {
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
print(string.format("[%s] Found death position: %s, %s", ModuleName, tostring(x), tostring(y))) print(string.format("[%s] Found death position: %s, %s", ModuleName, tostring(x), tostring(y)))
end end
if x and y then PlantAlert(tonumber(x), tonumber(y), 2, doTag) end if x and y then
PlantAlert(tonumber(x), tonumber(y), 2, doTag)
end
end end
--endregion --endregion
--region Help --region Help
@@ -564,7 +468,6 @@ shared.MinimapTagger = {
if x and y then if x and y then
x, y = tonumber(x), tonumber(y) x, y = tonumber(x), tonumber(y)
PlantHelp(x, y, 1, doTag) PlantHelp(x, y, 1, doTag)
---@diagnostic disable-next-line: undefined-global
if TomTom then if TomTom then
if Heimdall_Data.config.minimapTagger.debug then if Heimdall_Data.config.minimapTagger.debug then
print(string.format("[%s] Adding help waypoint to TomTom", ModuleName)) print(string.format("[%s] Adding help waypoint to TomTom", ModuleName))
@@ -575,7 +478,6 @@ shared.MinimapTagger = {
print(string.format("[%s] Area ID: %s", ModuleName, tostring(areaId))) print(string.format("[%s] Area ID: %s", ModuleName, tostring(areaId)))
end end
---@diagnostic disable-next-line: undefined-global
TomTom:AddMFWaypoint(areaId, nil, x / 100, y / 100, { TomTom:AddMFWaypoint(areaId, nil, x / 100, y / 100, {
title = "Help " .. sender, title = "Help " .. sender,
world = true, world = true,
@@ -592,6 +494,10 @@ shared.MinimapTagger = {
--endregion --endregion
end) end)
print(string.format("[%s] Module initialized", ModuleName)) print("[Heimdall] MinimapTagger loaded")
end, end
}
SlashCmdList["HEIMDALL_MINIMAPTAGGER"] = function(args)
shared.MinimapTagger.Init()
end
SLASH_HEIMDALL_MINIMAPTAGGER1 = "/mf"

View File

@@ -1,19 +1,11 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Network" local ModuleName = "Network"
---@class HeimdallNetworkConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.Network = {}
---@field debug boolean function shared.Network.Init()
---@field members string[]
---@field updateInterval number
---@class HeimdallNetworkData
---@field ticker Timer?
---@class Network
shared.Network = {
Init = function()
if not shared.network then shared.network = {} end if not shared.network then shared.network = {} end
local updatePending = false local updatePending = false
@@ -23,13 +15,11 @@ shared.Network = {
---@type table<string, boolean> ---@type table<string, boolean>
local friends = {} local friends = {}
for i = 1, GetNumFriends() do for i = 1, GetNumFriends() do
local name, _, _, _, connected, _, _, _ = GetFriendInfo(i) local name, level, class, area, connected, status, note, RAF = GetFriendInfo(i)
if name then if name then
friends[name] = connected friends[name] = connected
if Heimdall_Data.config.network.debug then if Heimdall_Data.config.network.debug then
print( print(string.format("[%s] Friend %s is %s", ModuleName, name, connected and "online" or "offline"))
string.format("[%s] Friend %s is %s", ModuleName, name, connected and "online" or "offline")
)
end end
else else
if Heimdall_Data.config.network.debug then if Heimdall_Data.config.network.debug then
@@ -49,8 +39,7 @@ shared.Network = {
friends[UnitName("player")] = true friends[UnitName("player")] = true
shared.networkNodes = {} shared.networkNodes = {}
-- Why are we skipping this again...? if false then shared.networkNodes[#shared.networkNodes + 1] = UnitName("player") end
-- if false then shared.networkNodes[#shared.networkNodes + 1] = UnitName("player") end
for _, player in ipairs(Heimdall_Data.config.network.members) do for _, player in ipairs(Heimdall_Data.config.network.members) do
if friends[player] then if friends[player] then
shared.networkNodes[#shared.networkNodes + 1] = player shared.networkNodes[#shared.networkNodes + 1] = player
@@ -61,16 +50,19 @@ shared.Network = {
end end
if Heimdall_Data.config.network.debug then if Heimdall_Data.config.network.debug then
print(string.format("[%s] Network nodes:", ModuleName)) print(string.format("[%s] Network nodes:", ModuleName))
shared.dump(shared.networkNodes) shared.dumpTable(shared.networkNodes)
end end
end end
local friendsFrame = CreateFrame("Frame") local friendsFrame = CreateFrame("Frame")
friendsFrame:RegisterEvent("FRIENDLIST_UPDATE") friendsFrame:RegisterEvent("FRIENDLIST_UPDATE")
friendsFrame:SetScript("OnEvent", function(self, event, ...) end) friendsFrame:SetScript("OnEvent", function(self, event, ...)
end)
local function NetworkTick() local function NetworkTick()
if Heimdall_Data.config.network.debug then print("Network module is updating.") end if Heimdall_Data.config.network.debug then
print("Network module is updating.")
end
ShowFriends() ShowFriends()
updatePending = true updatePending = true
C_Timer.After(1, function() C_Timer.After(1, function()
@@ -80,6 +72,5 @@ shared.Network = {
end end
NetworkTick() NetworkTick()
print(string.format("[%s] Module initialized", ModuleName)) print("[Heimdall] Network module loaded")
end, end
}

View File

@@ -1,27 +1,15 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "NetworkMessenger" local ModuleName = "NetworkMessenger"
---@class HeimdallNetworkMessengerConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.NetworkMessenger = {}
---@field debug boolean function shared.NetworkMessenger.Init()
---@field interval number
---@class HeimdallNetworkMessengerData
---@field queue table<string, Message>
---@field ticker Timer?
---@class NetworkMessenger
shared.NetworkMessenger = {
---@param message Message
Enqueue = function(message) table.insert(shared.networkMessenger.queue, message) end,
Init = function()
RegisterAddonMessagePrefix(Heimdall_Data.config.addonPrefix) RegisterAddonMessagePrefix(Heimdall_Data.config.addonPrefix)
shared.networkMessenger = { if not shared.networkMessenger then shared.networkMessenger = {} end
queue = ReactiveValue.new({}), if not shared.networkMessenger.queue then shared.networkMessenger.queue = {} end
}
if not shared.networkMessenger.ticker then if not shared.networkMessenger.ticker then
local function DoMessage() local function DoMessage()
--if Heimdall_Data.config.networkMessenger.debug then --if Heimdall_Data.config.networkMessenger.debug then
@@ -75,15 +63,9 @@ shared.NetworkMessenger = {
end end
if Heimdall_Data.config.networkMessenger.debug then if Heimdall_Data.config.networkMessenger.debug then
print( print(string.format("[%s] Sending network message: '%s' to %s:%s", ModuleName, message.message,
string.format(
"[%s] Sending network message: '%s' to %s:%s",
ModuleName,
message.message,
message.channel, message.channel,
message.data message.data))
)
)
end end
local payload = string.format("dmessage|%s|%s|%s", message.message, message.channel, message.data) local payload = string.format("dmessage|%s|%s|%s", message.message, message.channel, message.data)
if Heimdall_Data.config.networkMessenger.debug then if Heimdall_Data.config.networkMessenger.debug then
@@ -104,8 +86,7 @@ shared.NetworkMessenger = {
-- print(string.format("[%s] Queue check - Network messages pending: %d", ModuleName, queueSize)) -- print(string.format("[%s] Queue check - Network messages pending: %d", ModuleName, queueSize))
--end --end
DoMessage() DoMessage()
shared.networkMessenger.ticker = shared.networkMessenger.ticker = C_Timer.NewTimer(Heimdall_Data.config.networkMessenger.interval, Tick, 1)
C_Timer.NewTimer(Heimdall_Data.config.networkMessenger.interval, Tick, 1)
end end
Tick() Tick()
end end
@@ -145,29 +126,21 @@ shared.NetworkMessenger = {
local parts = shared.Split(message, "|") local parts = shared.Split(message, "|")
if Heimdall_Data.config.networkMessenger.debug then if Heimdall_Data.config.networkMessenger.debug then
print(string.format("[%s] Received message parts:", ModuleName)) print(string.format("[%s] Received message parts:", ModuleName))
shared.dump(parts) shared.dumpTable(parts)
end end
local command = strtrim(parts[1]) local command = strtrim(parts[1])
if command == "message" then if command == "message" then
local content = strtrim(tostring(parts[2])) local message = strtrim(tostring(parts[2]))
local targetchannel = strtrim(tostring(parts[3])) local channel = strtrim(tostring(parts[3]))
local target = strtrim(tostring(parts[4])) local target = strtrim(tostring(parts[4]))
if Heimdall_Data.config.networkMessenger.debug then if Heimdall_Data.config.networkMessenger.debug then
print( print(string.format("[%s] Received message command: %s %s %s", ModuleName, message, channel, target))
string.format(
"[%s] Received message command: %s %s %s",
ModuleName,
content,
targetchannel,
target
)
)
end end
---@type Message ---@type Message
local msg = { local msg = {
channel = targetchannel, channel = channel,
message = content, message = message,
data = target, data = target
} }
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
elseif command == "dmessage" then elseif command == "dmessage" then
@@ -175,15 +148,17 @@ shared.NetworkMessenger = {
print(string.format("[%s] Received dmessage command", ModuleName)) print(string.format("[%s] Received dmessage command", ModuleName))
end end
parts[1] = "message" parts[1] = "message"
local content = table.concat(parts, "|") local message = table.concat(parts, "|")
if nextIdx > #shared.networkNodes then nextIdx = 1 end if nextIdx > #shared.networkNodes then
nextIdx = 1
end
local recipient = shared.networkNodes[nextIdx] local recipient = shared.networkNodes[nextIdx]
nextIdx = nextIdx + 1 nextIdx = nextIdx + 1
if Heimdall_Data.config.networkMessenger.debug then if Heimdall_Data.config.networkMessenger.debug then
print(string.format("[%s] Sending message %s to %s", ModuleName, content, recipient)) print(string.format("[%s] Sending message %s to %s", ModuleName, message, recipient))
end end
SendAddonMessage(Heimdall_Data.config.addonPrefix, content, "WHISPER", recipient) SendAddonMessage(Heimdall_Data.config.addonPrefix, message, "WHISPER", recipient)
end end
end) end)
@@ -192,13 +167,12 @@ shared.NetworkMessenger = {
local testmsg = { local testmsg = {
channel = "W", channel = "W",
message = "Hi, mom!", message = "Hi, mom!",
data = "Secundus", data = "Secundus"
} }
for i = 1, 36 do for i = 1, 36 do
table.insert(shared.networkMessenger.queue, testmsg) table.insert(shared.networkMessenger.queue, testmsg)
end end
end end
print(string.format("[%s] Module initialized", ModuleName)) print("[Heimdall] NetworkMessenger module loaded")
end, end
}

View File

@@ -1,48 +1,47 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Noter" local ModuleName = "Noter"
---@class HeimdallNoterConfig
---@field enabled boolean
---@field debug boolean
---@field channels string[]
---@field lastNotes number
---@class Note ---@class Note
---@field source string ---@field source string
---@field for string ---@field for string
---@field date string ---@field date string
---@field note string ---@field note string
---@class Noter ---@diagnostic disable-next-line: missing-fields
shared.Noter = { shared.Noter = {}
Init = function() function shared.Noter.Init()
-- ---Hopefully this will not be necessary ---Hopefully this will not be necessary
-- ---@param text string ---@param text string
-- ---@param size number ---@param size number
-- ---@return string[] ---@return string[]
-- local function Partition(text, size) local function Partition(text, size)
-- local words = {} local words = {}
-- for word in text:gmatch("[^,]+") do for word in text:gmatch("[^,]+") do
-- words[#words + 1] = word words[#words + 1] = word
-- end end
-- local ret = {} local ret = {}
-- local currentChunk = "" local currentChunk = ""
-- for _, word in ipairs(words) do for _, word in ipairs(words) do
-- if #currentChunk + #word + 1 <= size then if #currentChunk + #word + 1 <= size then
-- currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word) currentChunk = currentChunk .. (currentChunk == "" and word or " " .. word)
-- else else
-- if #currentChunk > 0 then ret[#ret + 1] = currentChunk end if #currentChunk > 0 then
-- currentChunk = word ret[#ret + 1] = currentChunk
-- end end
-- end currentChunk = word
end
end
-- if #currentChunk > 0 then ret[#ret + 1] = currentChunk end if #currentChunk > 0 then
ret[#ret + 1] = currentChunk
end
-- return ret return ret
-- end end
---@param array any[] ---@param array any[]
---@return any[] ---@return any[]
local function Compact(array) local function Compact(array)
@@ -66,17 +65,17 @@ shared.Noter = {
end end
local indices = shared.Split(range, "..") local indices = shared.Split(range, "..")
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Indices for range deletion: %s", ModuleName, table.concat(indices, ", "))) print(string.format("[%s] Indices for range deletion: %s", ModuleName,
shared.dump(indices) table.concat(indices, ", ")))
shared.dumpTable(indices)
end end
local start = tonumber(indices[1]) local start = tonumber(indices[1])
local finish = tonumber(indices[2]) local finish = tonumber(indices[2])
if not start then if not start then
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print( print(string.format("[%s] Invalid start range for delete note: %s", ModuleName,
string.format("[%s] Invalid start range for delete note: %s", ModuleName, tostring(start)) tostring(start)))
)
end end
return return
end end
@@ -98,7 +97,7 @@ shared.Noter = {
else else
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Deleting note %s at index %s", ModuleName, name, i)) print(string.format("[%s] Deleting note %s at index %s", ModuleName, name, i))
shared.dump(Heimdall_Data.config.notes[name][i]) shared.dumpTable(Heimdall_Data.config.notes[name][i])
end end
Heimdall_Data.config.notes[name][i] = nil Heimdall_Data.config.notes[name][i] = nil
end end
@@ -119,13 +118,10 @@ shared.Noter = {
local msg = { local msg = {
channel = "C", channel = "C",
data = channel, data = channel,
message = string.format("[%s][%d] %s: %s", note.source, index, note.date, note.note), message = string.format("[%s][%d] %s: %s", note.source, index, note.date, note.note)
} }
if Heimdall_Data.config.networkMessenger.enabled then --table.insert(shared.messenger.queue, msg)
shared.NetworkMessenger.Enqueue(msg) table.insert(shared.networkMessenger.queue, msg)
elseif Heimdall_Data.config.messenger.enabled then
shared.Messenger.Enqueue(msg)
end
end end
---@param name string ---@param name string
---@param args string[] ---@param args string[]
@@ -136,13 +132,8 @@ shared.Noter = {
local range = args[3] local range = args[3]
if not range then if not range then
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print( print(string.format("[%s] No range specified for print note, defaulting to last %d notes", ModuleName,
string.format( Heimdall_Data.config.noter.lastNotes))
"[%s] No range specified for print note, defaulting to last %d notes",
ModuleName,
Heimdall_Data.config.noter.lastNotes
)
)
end end
local notes = Heimdall_Data.config.notes[name] or {} local notes = Heimdall_Data.config.notes[name] or {}
local start = math.max(1, #notes - Heimdall_Data.config.noter.lastNotes + 1) local start = math.max(1, #notes - Heimdall_Data.config.noter.lastNotes + 1)
@@ -161,15 +152,17 @@ shared.Noter = {
end end
local indices = shared.Split(range, "..") local indices = shared.Split(range, "..")
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Indices for range printing: %s", ModuleName, table.concat(indices, ", "))) print(string.format("[%s] Indices for range printing: %s", ModuleName,
shared.dump(indices) table.concat(indices, ", ")))
shared.dumpTable(indices)
end end
local start = tonumber(indices[1]) local start = tonumber(indices[1])
local finish = tonumber(indices[2]) local finish = tonumber(indices[2])
if not start then if not start then
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Invalid start range for print note: %s", ModuleName, tostring(start))) print(string.format("[%s] Invalid start range for print note: %s", ModuleName,
tostring(start)))
end end
return return
end end
@@ -188,7 +181,7 @@ shared.Noter = {
else else
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Printing note %s at index %s", ModuleName, name, i)) print(string.format("[%s] Printing note %s at index %s", ModuleName, name, i))
shared.dump(Heimdall_Data.config.notes[name][i]) shared.dumpTable(Heimdall_Data.config.notes[name][i])
end end
PrintNote(channel, i, Heimdall_Data.config.notes[name][i]) PrintNote(channel, i, Heimdall_Data.config.notes[name][i])
end end
@@ -203,7 +196,7 @@ shared.Noter = {
if not Heimdall_Data.config.notes[name] then Heimdall_Data.config.notes[name] = {} end if not Heimdall_Data.config.notes[name] then Heimdall_Data.config.notes[name] = {} end
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Adding note for: %s from: %s", ModuleName, name, sender)) print(string.format("[%s] Adding note for: %s from: %s", ModuleName, name, sender))
shared.dump(args) shared.dumpTable(args)
end end
local msgparts = {} local msgparts = {}
for i = 3, #args do for i = 3, #args do
@@ -219,12 +212,12 @@ shared.Noter = {
local note = { local note = {
source = sender, source = sender,
date = date("%Y-%m-%dT%H:%M:%S"), date = date("%Y-%m-%dT%H:%M:%S"),
note = msg, note = msg
} }
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Adding note", ModuleName)) print(string.format("[%s] Adding note", ModuleName))
shared.dump(note) shared.dumpTable(note)
end end
table.insert(Heimdall_Data.config.notes[name], note) table.insert(Heimdall_Data.config.notes[name], note)
end end
@@ -242,7 +235,7 @@ shared.Noter = {
noterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...) noterChannelFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
--if Heimdall_Data.config.noter.debug then --if Heimdall_Data.config.noter.debug then
-- print(string.format("[%s] Event received", ModuleName)) -- print(string.format("[%s] Event received", ModuleName))
-- shared.dump(Heimdall_Data.config.noter) -- shared.dumpTable(Heimdall_Data.config.noter)
--end --end
if not Heimdall_Data.config.noter.enabled then if not Heimdall_Data.config.noter.enabled then
--if Heimdall_Data.config.noter.debug then --if Heimdall_Data.config.noter.debug then
@@ -269,7 +262,7 @@ shared.Noter = {
sender = string.match(sender, "^[^-]+") sender = string.match(sender, "^[^-]+")
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Message from: %s", ModuleName, sender)) print(string.format("[%s] Message from: %s", ModuleName, sender))
shared.dump(Heimdall_Data.config.noter) shared.dumpTable(Heimdall_Data.config.noter)
end end
if not msg or msg == "" then if not msg or msg == "" then
@@ -282,7 +275,7 @@ shared.Noter = {
local args = { strsplit(" ", msg) } local args = { strsplit(" ", msg) }
if Heimdall_Data.config.noter.debug then if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Arguments received: %s", ModuleName, table.concat(args, ", "))) print(string.format("[%s] Arguments received: %s", ModuleName, table.concat(args, ", ")))
shared.dump(args) shared.dumpTable(args)
end end
local command = args[1] local command = args[1]
if command == "note" then if command == "note" then
@@ -291,7 +284,9 @@ shared.Noter = {
print(string.format("[%s] Note command received for: %s", ModuleName, name)) print(string.format("[%s] Note command received for: %s", ModuleName, name))
end end
local note = strtrim(args[3] or "") local note = strtrim(args[3] or "")
if Heimdall_Data.config.noter.debug then print(string.format("[%s] Note: %s", ModuleName, note)) end if Heimdall_Data.config.noter.debug then
print(string.format("[%s] Note: %s", ModuleName, note))
end
if note == "delete" then if note == "delete" then
DeleteNotes(name, args) DeleteNotes(name, args)
elseif string.find(note, "^[%d%.]*$") then elseif string.find(note, "^[%d%.]*$") then
@@ -302,6 +297,5 @@ shared.Noter = {
end end
end) end)
print(string.format("[%s] Module initialized", ModuleName)) print("[Heimdall] Commander module loaded")
end, end
}

View File

@@ -8,8 +8,12 @@ local function Init()
if otherType == "table" and other._type and other._type == self._type and other._value then if otherType == "table" and other._type and other._type == self._type and other._value then
return self._value + other._value return self._value + other._value
end end
if otherType == "string" and self._type == otherType then return self._value .. other end if otherType == "string" and self._type == otherType then
if otherType == "number" and self._type == otherType then return self._value + other end return self._value .. other
end
if otherType == "number" and self._type == otherType then
return self._value + other
end
return nil return nil
end, end,
---@param self ReactiveValue ---@param self ReactiveValue
@@ -20,7 +24,9 @@ local function Init()
if otherType == "table" and other._type and other._type == self._type and other._value then if otherType == "table" and other._type and other._type == self._type and other._value then
return self._value * other._value return self._value * other._value
end end
if otherType == "number" and self._type == otherType then return self._value * other end if otherType == "number" and self._type == otherType then
return self._value * other
end
return nil return nil
end, end,
---@param self ReactiveValue ---@param self ReactiveValue
@@ -31,7 +37,9 @@ local function Init()
if otherType == "table" and other._type and other._type == self._type and other._value then if otherType == "table" and other._type and other._type == self._type and other._value then
return self._value - other._value return self._value - other._value
end end
if otherType == "number" and self._type == otherType then return self._value - other end if otherType == "number" and self._type == otherType then
return self._value - other
end
return nil return nil
end, end,
---@param self ReactiveValue ---@param self ReactiveValue
@@ -42,7 +50,9 @@ local function Init()
if otherType == "table" and other._type and other._type == self._type and other._value then if otherType == "table" and other._type and other._type == self._type and other._value then
return self._value / other._value return self._value / other._value
end end
if otherType == "number" and self._type == otherType then return self._value / other end if otherType == "number" and self._type == otherType then
return self._value / other
end
return nil return nil
end, end,
---@param self ReactiveValue ---@param self ReactiveValue
@@ -53,7 +63,9 @@ local function Init()
if otherType == "table" and other._type and other._type == self._type and other._value then if otherType == "table" and other._type and other._type == self._type and other._value then
return self._value % other._value return self._value % other._value
end end
if otherType == "number" and self._type == otherType then return self._value % other end if otherType == "number" and self._type == otherType then
return self._value % other
end
return nil return nil
end, end,
---@param self ReactiveValue ---@param self ReactiveValue
@@ -64,7 +76,9 @@ local function Init()
if otherType == "table" and other._type and other._type == self._type and other._value then if otherType == "table" and other._type and other._type == self._type and other._value then
return self._value ^ other._value return self._value ^ other._value
end end
if otherType == "number" and self._type == otherType then return self._value ^ other end if otherType == "number" and self._type == otherType then
return self._value ^ other
end
return nil return nil
end, end,
---@param self ReactiveValue ---@param self ReactiveValue
@@ -120,13 +134,19 @@ local function Init()
---@param self ReactiveValue ---@param self ReactiveValue
---@return number ---@return number
__len = function(self) __len = function(self)
if self._type == "table" then return #self._value end if self._type == "table" then
if self._type == "string" then return string.len(self._value) end return #self._value
end
if self._type == "string" then
return string.len(self._value)
end
return 0 return 0
end, end,
---@param self ReactiveValue ---@param self ReactiveValue
---@return string ---@return string
__tostring = function(self) return tostring(self._value) end, __tostring = function(self)
return tostring(self._value)
end,
---@param self ReactiveValue ---@param self ReactiveValue
---@param key string ---@param key string
---@param value any ---@param value any
@@ -148,7 +168,9 @@ local function Init()
-- If the value being assigned is a ReactiveValue -- If the value being assigned is a ReactiveValue
-- Then listen to changes on it as well -- Then listen to changes on it as well
-- And propagate those changes upwards -- And propagate those changes upwards
if self._recursive and getmetatable(value) == getmetatable(self) then self:_setupListeners(key, value) end if self._recursive and getmetatable(value) == getmetatable(self) then
self:_setupListeners(key, value)
end
self:_notify() self:_notify()
self:_notifyFieldChanged(ChangedKey) self:_notifyFieldChanged(ChangedKey)
@@ -159,12 +181,18 @@ local function Init()
---@return any|nil ---@return any|nil
__index = function(self, key) __index = function(self, key)
local value = rawget(self, key) local value = rawget(self, key)
if value ~= nil then return value end if value ~= nil then
if rawget(self, "_type") ~= "table" then return nil end return value
local innerTable = rawget(self, "_value") end
if innerTable ~= nil then return rawget(innerTable, key) end if rawget(self, "_type") ~= "table" then
return nil return nil
end, end
local innerTable = rawget(self, "_value")
if innerTable ~= nil then
return rawget(innerTable, key)
end
return nil
end
-- __index = ReactiveValue -- __index = ReactiveValue
} }
@@ -315,10 +343,14 @@ local function Init()
self._recursive = recursive or false self._recursive = recursive or false
---@return any ---@return any
self.get = function(self) return self._value end self.get = function(self)
return self._value
end
---@param newValue any ---@param newValue any
self.set = function(self, newValue) self.set = function(self, newValue)
if self._value == newValue then return end if self._value == newValue then
return
end
if type(newValue) ~= self._type then if type(newValue) ~= self._type then
error("Expected " .. self._type .. ", got " .. type(newValue)) error("Expected " .. self._type .. ", got " .. type(newValue))
return return
@@ -332,16 +364,22 @@ local function Init()
return function() end return function() end
end end
self._listeners[callback] = true self._listeners[callback] = true
return function() self._listeners[callback] = nil end return function()
self._listeners[callback] = nil
end
end end
self.onFieldChange = function(self, field, callback) self.onFieldChange = function(self, field, callback)
if type(callback) ~= "function" then if type(callback) ~= "function" then
error("Expected function, got " .. type(callback)) error("Expected function, got " .. type(callback))
return function() end return function() end
end end
if self._fieldListeners[field] == nil then self._fieldListeners[field] = {} end if self._fieldListeners[field] == nil then
self._fieldListeners[field] = {}
end
self._fieldListeners[field][callback] = true self._fieldListeners[field][callback] = true
return function() self._fieldListeners[field][callback] = nil end return function()
self._fieldListeners[field][callback] = nil
end
end end
self.onAnyFieldChange = function(self, callback, depth) self.onAnyFieldChange = function(self, callback, depth)
depth = depth or 99999 depth = depth or 99999
@@ -349,9 +387,13 @@ local function Init()
error("Expected function, got " .. type(callback)) error("Expected function, got " .. type(callback))
return function() end return function() end
end end
if self._anyFieldListeners[depth] == nil then self._anyFieldListeners[depth] = {} end if self._anyFieldListeners[depth] == nil then
self._anyFieldListeners[depth] = {}
end
self._anyFieldListeners[depth][callback] = true self._anyFieldListeners[depth][callback] = true
return function() self._anyFieldListeners[depth][callback] = nil end return function()
self._anyFieldListeners[depth][callback] = nil
end
end end
self.once = function(self, callback) self.once = function(self, callback)
if type(callback) ~= "function" then if type(callback) ~= "function" then
@@ -359,11 +401,15 @@ local function Init()
return function() end return function() end
end end
self._oneTimeListeners[callback] = true self._oneTimeListeners[callback] = true
return function() self._oneTimeListeners[callback] = nil end return function()
self._oneTimeListeners[callback] = nil
end
end end
self._setupAllListenersRecursively = function(self) self._setupAllListenersRecursively = function(self)
if self._type ~= "table" then return end if self._type ~= "table" then
return
end
for key, value in pairs(self._value) do for key, value in pairs(self._value) do
self:_setupListeners(key, value, true) self:_setupListeners(key, value, true)
end end
@@ -373,8 +419,12 @@ local function Init()
---@param recursive boolean? ---@param recursive boolean?
self._setupListeners = function(self, key, value, recursive) self._setupListeners = function(self, key, value, recursive)
recursive = recursive or false recursive = recursive or false
if self._type ~= "table" then return end if self._type ~= "table" then
if getmetatable(value) ~= getmetatable(self) then return end return
end
if getmetatable(value) ~= getmetatable(self) then
return
end
value._recursive = true value._recursive = true
if value._type == "table" then if value._type == "table" then
value:onAnyFieldChange(function(key2) value:onAnyFieldChange(function(key2)
@@ -390,10 +440,14 @@ local function Init()
end) end)
end end
if recursive then value:_setupAllListenersRecursively() end if recursive then
value:_setupAllListenersRecursively()
end
end end
if recursive then self:_setupAllListenersRecursively() end if recursive then
self:_setupAllListenersRecursively()
end
self._notify = function(self) self._notify = function(self)
for listener, _ in pairs(self._oneTimeListeners) do for listener, _ in pairs(self._oneTimeListeners) do
@@ -420,7 +474,9 @@ local function Init()
end end
local strfield = table.concat(field, ".") local strfield = table.concat(field, ".")
if self._fieldListeners[strfield] == nil then return end if self._fieldListeners[strfield] == nil then
return
end
for listener, _ in pairs(self._fieldListeners[strfield]) do for listener, _ in pairs(self._fieldListeners[strfield]) do
-- task.spawn(listener, value, type(value)) -- task.spawn(listener, value, type(value))
listener(value, type(value)) listener(value, type(value))
@@ -483,7 +539,7 @@ local function Init()
-- S local clbk = test:onChange(function(value) -- S local clbk = test:onChange(function(value)
-- S invocations = invocations + 1 -- S invocations = invocations + 1
-- S print("test changed to") -- S print("test changed to")
-- S dump(value, 0) -- S dumpTable(value, 0)
-- S end) -- S end)
-- S test:set({1, 2, 3, 4}) -- S test:set({1, 2, 3, 4})
-- S assert(invocations == 1) -- S assert(invocations == 1)
@@ -516,7 +572,7 @@ local function Init()
-- S test:once(function(value) -- S test:once(function(value)
-- S invocations = invocations + 1 -- S invocations = invocations + 1
-- S print("test changed to") -- S print("test changed to")
-- S dump(value, 0) -- S dumpTable(value, 0)
-- S end) -- S end)
-- S test:set({3, 2, 1}) -- S test:set({3, 2, 1})
-- S assert(invocations == 1) -- S assert(invocations == 1)
@@ -527,7 +583,7 @@ local function Init()
-- S test:onChange(function(value) -- S test:onChange(function(value)
-- S invocations = invocations + 1 -- S invocations = invocations + 1
-- S print("test changed to") -- S print("test changed to")
-- S dump(value, 0) -- S dumpTable(value, 0)
-- S end) -- S end)
-- S test:onAnyFieldChange(function(field, value) -- S test:onAnyFieldChange(function(field, value)
-- S invocations = invocations + 1 -- S invocations = invocations + 1
@@ -605,5 +661,7 @@ local frame = CreateFrame("Frame")
frame:RegisterEvent("PLAYER_LOGIN") frame:RegisterEvent("PLAYER_LOGIN")
frame:RegisterEvent("PLAYER_ENTERING_WORLD") frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:RegisterEvent("GUILD_ROSTER_UPDATE") frame:RegisterEvent("GUILD_ROSTER_UPDATE")
frame:SetScript("OnEvent", function(self, event, ...) Init() end) frame:SetScript("OnEvent", function(self, event, ...)
Init()
end)
Init() Init()

View File

@@ -1,34 +1,32 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Sniffer" local ModuleName = "Sniffer"
---@class HeimdallSnifferConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.Sniffer = {}
---@field debug boolean function shared.Sniffer.Init()
---@field channels string[] if Heimdall_Data.config.sniffer.debug then
---@field throttle number -- throttleTime in the original code, matching config name now print(string.format("[%s] Module initializing", ModuleName))
---@field zoneOverride string? end
---@field stinky boolean
---@class Sniffer
shared.Sniffer = {
Init = function()
if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Module initializing", ModuleName)) end
local smellThrottle = {} local smellThrottle = {}
local SmellStinky = function(stinky) local SmellStinky = function(stinky)
if Heimdall_Data.config.sniffer.debug then if Heimdall_Data.config.sniffer.debug then
print(string.format("%s: SmellStinky", ModuleName)) print(string.format("%s: SmellStinky", ModuleName))
shared.dump(Heimdall_Data.config.sniffer) shared.dumpTable(Heimdall_Data.config.sniffer)
end end
if not Heimdall_Data.config.sniffer.enabled then return end if not Heimdall_Data.config.sniffer.enabled then return end
if Heimdall_Data.config.sniffer.stinky and not shared.IsStinky(stinky) then if Heimdall_Data.config.sniffer.stinky and
not shared.IsStinky(stinky) then
if Heimdall_Data.config.sniffer.debug then if Heimdall_Data.config.sniffer.debug then
print(string.format("%s: Stinky not found in config", ModuleName)) print(string.format("%s: Stinky not found in config", ModuleName))
end end
return return
end end
if smellThrottle[stinky] and GetTime() - smellThrottle[stinky] < Heimdall_Data.config.sniffer.throttle then if smellThrottle[stinky] and GetTime() - smellThrottle[stinky] < Heimdall_Data.config.sniffer.throttleTime then
if Heimdall_Data.config.sniffer.debug then print(string.format("%s: Throttled", ModuleName)) end if Heimdall_Data.config.sniffer.debug then
print(string.format("%s: Throttled", ModuleName))
end
return return
end end
smellThrottle[stinky] = GetTime() smellThrottle[stinky] = GetTime()
@@ -44,7 +42,7 @@ shared.Sniffer = {
} }
if Heimdall_Data.config.sniffer.debug then if Heimdall_Data.config.sniffer.debug then
print(string.format("[%s] Queuing sniffer message", ModuleName)) print(string.format("[%s] Queuing sniffer message", ModuleName))
shared.dump(msg) shared.dumpTable(msg)
end end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
end end
@@ -62,8 +60,7 @@ shared.Sniffer = {
end end
return return
end end
local source, destination, err local source, err = CLEUParser.GetSourceName(...)
source, err = CLEUParser.GetSourceName(...)
if Heimdall_Data.config.sniffer.debug then if Heimdall_Data.config.sniffer.debug then
print(string.format("[%s] Processing source: %s", ModuleName, source)) print(string.format("[%s] Processing source: %s", ModuleName, source))
end end
@@ -74,7 +71,7 @@ shared.Sniffer = {
return return
end end
SmellStinky(source) SmellStinky(source)
destination, err = CLEUParser.GetDestName(...) local destination, err = CLEUParser.GetDestName(...)
if Heimdall_Data.config.sniffer.debug then if Heimdall_Data.config.sniffer.debug then
print(string.format("[%s] Processing destination: %s", ModuleName, destination)) print(string.format("[%s] Processing destination: %s", ModuleName, destination))
end end
@@ -86,7 +83,8 @@ shared.Sniffer = {
end end
SmellStinky(destination) SmellStinky(destination)
end) end)
if Heimdall_Data.config.sniffer.debug then print(string.format("[%s] Module initialized", ModuleName)) end if Heimdall_Data.config.sniffer.debug then
print(string.format("[%s] Module initialized", ModuleName)) print(string.format("[%s] Module initialized", ModuleName))
end, end
} print("[Heimdall] Sniffer loaded")
end

View File

@@ -1,21 +1,11 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Spotter" local ModuleName = "Spotter"
---@class HeimdallSpotterConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.Spotter = {}
---@field debug boolean function shared.Spotter.Init()
---@field everyone boolean
---@field hostile boolean
---@field alliance boolean
---@field stinky boolean
---@field channels string[]
---@field zoneOverride string?
---@field throttleTime number
---@class Spotter
shared.Spotter = {
Init = function()
local function FormatHP(hp) local function FormatHP(hp)
if hp > 1e9 then if hp > 1e9 then
return string.format("%.1fB", hp / 1e9) return string.format("%.1fB", hp / 1e9)
@@ -42,7 +32,7 @@ shared.Spotter = {
print(string.format("[%s] Checking notification criteria for %s (%s)", ModuleName, name, faction)) print(string.format("[%s] Checking notification criteria for %s (%s)", ModuleName, name, faction))
end end
if shared.AgentTracker.IsAgent(name) then if Heimdall_Data.config.agents[name] then
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Skipping agent: %s", ModuleName, name)) print(string.format("[%s] Skipping agent: %s", ModuleName, name))
end end
@@ -77,13 +67,8 @@ shared.Spotter = {
end end
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print( print(string.format("[%s] Using everyone setting: %s", ModuleName,
string.format( tostring(Heimdall_Data.config.spotter.everyone)))
"[%s] Using everyone setting: %s",
ModuleName,
tostring(Heimdall_Data.config.spotter.everyone)
)
)
end end
return Heimdall_Data.config.spotter.everyone return Heimdall_Data.config.spotter.everyone
end end
@@ -113,9 +98,7 @@ shared.Spotter = {
if throttleTable[name] and time - throttleTable[name] < Heimdall_Data.config.spotter.throttleTime then if throttleTable[name] and time - throttleTable[name] < Heimdall_Data.config.spotter.throttleTime then
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
local remainingTime = Heimdall_Data.config.spotter.throttleTime - (time - throttleTable[name]) local remainingTime = Heimdall_Data.config.spotter.throttleTime - (time - throttleTable[name])
print( print(string.format("[%s] Player %s throttled for %.1f more seconds", ModuleName, name, remainingTime))
string.format("[%s] Player %s throttled for %.1f more seconds", ModuleName, name, remainingTime)
)
end end
return string.format("Throttled %s", tostring(name)) return string.format("Throttled %s", tostring(name))
end end
@@ -175,8 +158,7 @@ shared.Spotter = {
print(string.format("[%s] Processing channel: %s", ModuleName, channel)) print(string.format("[%s] Processing channel: %s", ModuleName, channel))
end end
local locale = shared.GetLocaleForChannel(channel) local locale = shared.GetLocaleForChannel(channel)
local text = string.format( local text = string.format(shared._L("spotterSpotted", locale),
shared._L("spotterSpotted", locale),
hostile and shared._L("hostile", locale) or shared._L("friendly", locale), hostile and shared._L("hostile", locale) or shared._L("friendly", locale),
name, name,
shared._L(class, locale), shared._L(class, locale),
@@ -186,22 +168,19 @@ shared.Spotter = {
pvpOn and shared._L("pvpOn", locale) or shared._L("pvpOff", locale), pvpOn and shared._L("pvpOn", locale) or shared._L("pvpOff", locale),
string.gsub(FormatHP(hp), "M", "kk"), string.gsub(FormatHP(hp), "M", "kk"),
string.gsub(FormatHP(maxHp), "M", "kk"), string.gsub(FormatHP(maxHp), "M", "kk"),
shared._L(zone, locale), shared._L(zone, locale), shared._L(subzone, locale),
shared._L(subzone, locale),
areaId, areaId,
x * 100, x * 100, y * 100)
y * 100
)
---@type Message ---@type Message
local msg = { local msg = {
channel = "C", channel = "C",
data = channel, data = channel,
message = text, message = text
} }
if Heimdall_Data.config.spotter.debug then if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Queuing spotter message", ModuleName)) print(string.format("[%s] Queuing spotter message", ModuleName))
shared.dump(msg) shared.dumpTable(msg)
end end
table.insert(shared.messenger.queue, msg) table.insert(shared.messenger.queue, msg)
end end
@@ -222,7 +201,9 @@ shared.Spotter = {
return return
end end
if event == "UNIT_TARGET" then unit = "target" end if event == "UNIT_TARGET" then
unit = "target"
end
local err = NotifySpotted(unit) local err = NotifySpotted(unit)
if err then if err then
@@ -232,7 +213,8 @@ shared.Spotter = {
end end
end) end)
if Heimdall_Data.config.spotter.debug then print(string.format("[%s] Module initialized", ModuleName)) end if Heimdall_Data.config.spotter.debug then
print(string.format("[%s] Module initialized", ModuleName)) print(string.format("[%s] Module initialized", ModuleName))
end, end
} print("[Heimdall] Spotter loaded")
end

View File

@@ -1,19 +1,11 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "StinkyCache" local ModuleName = "StinkyCache"
---@class HeimdallStinkyCacheConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.StinkyCache = {}
---@field debug boolean function shared.StinkyCache.Init()
---@field commander string
---@field ttl number
---@class HeimdallStinkyCacheData
---@field stinkies table<string, {value: number, timestamp: number}>
---@class StinkyCache
shared.StinkyCache = {
Init = function()
shared.stinkyCache = { shared.stinkyCache = {
stinkies = {}, stinkies = {},
} }
@@ -21,23 +13,14 @@ shared.StinkyCache = {
---@param name string ---@param name string
local function AskCommander(name) local function AskCommander(name)
if Heimdall_Data.config.stinkyCache.debug then if Heimdall_Data.config.stinkyCache.debug then
print( print(string.format("[%s] Asking commander %s about %s", ModuleName,
string.format( Heimdall_Data.config.stinkyCache.commander, name))
"[%s] Asking commander %s about %s",
ModuleName,
Heimdall_Data.config.stinkyCache.commander,
name
)
)
end end
local messageParts = { "isstinky", name } local messageParts = { "isstinky", name }
local message = table.concat(messageParts, "|") local message = table.concat(messageParts, "|")
SendAddonMessage( SendAddonMessage(Heimdall_Data.config.addonPrefix,
Heimdall_Data.config.addonPrefix, message, "WHISPER",
message, Heimdall_Data.config.stinkyCache.commander)
"WHISPER",
Heimdall_Data.config.stinkyCache.commander
)
return return
end end
@@ -46,25 +29,20 @@ shared.StinkyCache = {
addonMessageFrame:SetScript("OnEvent", function(self, event, msg, sender, ...) addonMessageFrame:SetScript("OnEvent", function(self, event, msg, sender, ...)
if sender == Heimdall_Data.config.stinkyCache.commander then if sender == Heimdall_Data.config.stinkyCache.commander then
if Heimdall_Data.config.stinkyCache.debug then if Heimdall_Data.config.stinkyCache.debug then
print( print(string.format("[%s] Received stinky from commander %s: %s", ModuleName,
string.format( Heimdall_Data.config.stinkyCache.commander, msg))
"[%s] Received stinky from commander %s: %s",
ModuleName,
Heimdall_Data.config.stinkyCache.commander,
msg
)
)
end end
local parts = { strsplit("|", msg) } local name, value = {strsplit("|", msg)}
local name, value = parts[1], parts[2]
shared.stinkyCache.stinkies[name] = { value = value, timestamp = time() } shared.stinkyCache.stinkies[name] = { value = value, timestamp = time() }
else else
if Heimdall_Data.config.stinkyCache.debug then if Heimdall_Data.config.stinkyCache.debug then
print(string.format("[%s] Received stinky from non-commander %s: %s", ModuleName, sender, msg)) print(string.format("[%s] Received stinky from non-commander %s: %s", ModuleName, sender, msg))
end end
local parts = { strsplit("|", msg) } local parts = {strsplit("|", msg)}
local command, name = parts[1], parts[2] local command, name = parts[1], parts[2]
if parts[1] == "isstinky" then local res = Heimdall_Data.config.stinkies[parts[2]] end if parts[1] == "isstinky" then
local res = Heimdall_Data.config.stinkies[parts[2]]
end
end end
end) end)
@@ -76,8 +54,7 @@ shared.StinkyCache = {
AskCommander(key) AskCommander(key)
end end
return rawget(self, key) return rawget(self, key)
end, end
}) })
print(string.format("[%s] Module initialized", ModuleName)) print("[Heimdall] StinkyCache module loaded")
end, end
}

View File

@@ -1,108 +1,18 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "StinkyTracker" local ModuleName = "StinkyTracker"
---@class Stinky ---@diagnostic disable-next-line: missing-fields
---@field name string shared.StinkyTracker = {}
---@field class string function shared.StinkyTracker.Init()
---@field seenAt number
---@field hostile boolean
---@class HeimdallStinkyTrackerConfig
---@field enabled boolean
---@field debug boolean
---@field ignoredTimeout number
---@field channels string[]
---@class StinkyTrackerData
---@field stinkies ReactiveValue<table<string, Stinky>>
---@field ignored ReactiveValue<table<string, number>>
---@class StinkyTracker
shared.StinkyTracker = {
---@param stinky Stinky
---@return boolean
Track = function(stinky)
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Request to track stinky: %s (%s)", ModuleName, stinky.name, stinky.class))
end
local ignored = shared.stinkyTracker.ignored[stinky.name]
-- TODO: Add a config option for the ignored timeout
if ignored and ignored > GetTime() - 60 then
if Heimdall_Data.config.stinkyTracker.debug then
print(
string.format(
"[%s] Stinky is ignored, not tracking: %s (%s)",
ModuleName,
stinky.name,
stinky.class
)
)
shared.dump(shared.stinkyTracker.ignored:get())
shared.dump(shared.stinkyTracker.stinkies:get())
end
return false
else
-- Timed out or was never ignored
shared.stinkyTracker.stinkies[stinky.name] = nil
end
shared.stinkyTracker.stinkies[stinky.name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Stinky is now tracked: %s (%s)", ModuleName, stinky.name, stinky.class))
shared.dump(shared.stinkyTracker.stinkies:get())
shared.dump(shared.stinkyTracker.ignored:get())
end
return true
end,
---@param name string
---@return nil
Ignore = function(name)
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Request to ignore stinky: %s", ModuleName, name))
end
shared.stinkyTracker.ignored[name] = GetTime()
shared.stinkyTracker.stinkies[name] = nil
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Stinky is now ignored: %s", ModuleName, name))
shared.dump(shared.stinkyTracker.ignored:get())
shared.dump(shared.stinkyTracker.stinkies:get())
end
end,
---@param name string
---@return boolean
IsStinky = function(name)
if not shared.stinkyTracker.stinkies then return false end
if not shared.stinkyTracker.stinkies[name] then return false end
if shared.stinkyTracker.ignored[name] then return false end
return true
end,
---@param callback fun(stinkies: table<string, Stinky>)
---@return nil
OnChange = function(callback) shared.stinkyTracker.stinkies:onChange(callback) end,
---@param callback fun(name: string, stinky: Stinky)
---@return nil
ForEach = function(callback)
---@type table<string, Stinky>
local stinkies = shared.stinkyTracker.stinkies:get()
for name, stinky in pairs(stinkies) do
callback(name, stinky)
end
end,
Init = function()
shared.stinkyTracker = { shared.stinkyTracker = {
stinkies = ReactiveValue.new({}), stinkies = ReactiveValue.new({})
ignored = ReactiveValue.new({}),
} }
local whoRegex = "([^ -/]+)-?%w*/(%w+)" local whoRegex = "([^ -/]+)-?%w*/(%w+)"
---@param msg string ---@param msg string
---@return table<string, Stinky> ---@return table<string, stinky>
local function ParseWho(msg) local function ParseWho(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Parsing WHO message: '%s'", ModuleName, msg)) print(string.format("[%s] Parsing WHO message: '%s'", ModuleName, msg))
@@ -113,19 +23,12 @@ shared.StinkyTracker = {
name = name, name = name,
class = class, class = class,
seenAt = GetTime(), seenAt = GetTime(),
hostile = true, hostile = true
} }
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print( print(string.format("[%s] Found hostile player: %s (%s) at %s", ModuleName, name, class,
string.format( date("%H:%M:%S", time())))
"[%s] Found hostile player: %s (%s) at %s", shared.dumpTable(stinkies)
ModuleName,
name,
class,
date("%H:%M:%S", time())
)
)
shared.dump(stinkies)
end end
end end
return stinkies return stinkies
@@ -133,7 +36,7 @@ shared.StinkyTracker = {
local seeRegex = "I see %((%w+)%) ([^ -/]+)-?%w*/(%w+)" local seeRegex = "I see %((%w+)%) ([^ -/]+)-?%w*/(%w+)"
---@param msg string ---@param msg string
---@return table<string, Stinky> ---@return table<string, stinky>
local function ParseSee(msg) local function ParseSee(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Parsing SEE message: '%s'", ModuleName, msg)) print(string.format("[%s] Parsing SEE message: '%s'", ModuleName, msg))
@@ -150,21 +53,13 @@ shared.StinkyTracker = {
name = name, name = name,
class = class, class = class,
seenAt = GetTime(), seenAt = GetTime(),
hostile = aggression == "hostile", hostile = aggression == "hostile"
} }
stinkies[name] = stinky stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print( print(string.format("[%s] Found stinky in SEE: %s (%s) - %s at %s", ModuleName, name, class, aggression,
string.format( date("%H:%M:%S", time())))
"[%s] Found stinky in SEE: %s (%s) - %s at %s", shared.dumpTable(stinkies)
ModuleName,
name,
class,
aggression,
date("%H:%M:%S", time())
)
)
shared.dump(stinkies)
end end
return stinkies return stinkies
end end
@@ -172,7 +67,7 @@ shared.StinkyTracker = {
local arrivedRegex = "([^ -/]+)-?%w*; c:([^;]+)" local arrivedRegex = "([^ -/]+)-?%w*; c:([^;]+)"
local arrivedRegexAlt = "([^ -/]+)-?%w*%(!!!!%); c:([^;]+)" local arrivedRegexAlt = "([^ -/]+)-?%w*%(!!!!%); c:([^;]+)"
---@param msg string ---@param msg string
---@return table<string, Stinky> ---@return table<string, stinky>
local function ParseArrived(msg) local function ParseArrived(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Parsing arrived message: %s", ModuleName, msg)) print(string.format("%s: Parsing arrived message: %s", ModuleName, msg))
@@ -192,12 +87,12 @@ shared.StinkyTracker = {
name = name, name = name,
class = class, class = class,
seenAt = GetTime(), seenAt = GetTime(),
hostile = true, hostile = true
} }
stinkies[name] = stinky stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("%s: Found stinky in arrived: %s/%s", ModuleName, name, class)) print(string.format("%s: Found stinky in arrived: %s/%s", ModuleName, name, class))
shared.dump(stinkies) shared.dumpTable(stinkies)
end end
return stinkies return stinkies
end end
@@ -231,10 +126,9 @@ shared.StinkyTracker = {
end end
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender)) print(string.format("[%s] Processing message from master channel: %s", ModuleName, sender))
shared.dump(Heimdall_Data.config.stinkyTracker) shared.dumpTable(Heimdall_Data.config.stinkyTracker)
end end
local stinkies = {}
if string.find(msg, "^who:") then if string.find(msg, "^who:") then
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Processing WHO message from %s", ModuleName, sender)) print(string.format("[%s] Processing WHO message from %s", ModuleName, sender))
@@ -242,10 +136,15 @@ shared.StinkyTracker = {
local whoStinkies = ParseWho(msg) local whoStinkies = ParseWho(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Found stinkies in WHO message", ModuleName)) print(string.format("[%s] Found stinkies in WHO message", ModuleName))
shared.dump(whoStinkies)
end end
for name, stinky in pairs(whoStinkies) do for name, stinky in pairs(whoStinkies) do
stinkies[name] = stinky if stinky.hostile then
shared.stinkyTracker.stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Added hostile stinky from WHO: %s (%s)", ModuleName, name, stinky
.class))
end
end
end end
end end
if string.find(msg, "^I see") then if string.find(msg, "^I see") then
@@ -255,10 +154,21 @@ shared.StinkyTracker = {
local seeStinkies = ParseSee(msg) local seeStinkies = ParseSee(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Found stinkies in SEE message", ModuleName)) print(string.format("[%s] Found stinkies in SEE message", ModuleName))
shared.dump(seeStinkies)
end end
for name, stinky in pairs(seeStinkies) do for name, stinky in pairs(seeStinkies) do
stinkies[name] = stinky if stinky.hostile then
shared.stinkyTracker.stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Added hostile stinky from SEE: %s (%s)", ModuleName, name, stinky
.class))
end
end
if not stinky.hostile then
shared.stinkyTracker.stinkies[name] = nil
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Removed non-hostile stinky from SEE: %s", ModuleName, name))
end
end
end end
end end
if string.find(msg, "arrived to") or string.find(msg, "moved to") then if string.find(msg, "arrived to") or string.find(msg, "moved to") then
@@ -268,23 +178,11 @@ shared.StinkyTracker = {
local arrivedStinkies = ParseArrived(msg) local arrivedStinkies = ParseArrived(msg)
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Found stinkies in ARRIVED message", ModuleName)) print(string.format("[%s] Found stinkies in ARRIVED message", ModuleName))
shared.dump(arrivedStinkies)
end end
for name, stinky in pairs(arrivedStinkies) do for name, stinky in pairs(arrivedStinkies) do
stinkies[name] = stinky
end
end
for name, stinky in pairs(stinkies) do
if shared.stinkyTracker.ignored[name] then
if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Ignoring stinky: %s (%s)", ModuleName, name, stinky.class))
end
shared.stinkyTracker.ignored[name] = nil
else
shared.stinkyTracker.stinkies[name] = stinky shared.stinkyTracker.stinkies[name] = stinky
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Added stinky: %s (%s)", ModuleName, name, stinky.class)) print(string.format("[%s] Added stinky from ARRIVED: %s (%s)", ModuleName, name, stinky.class))
end end
end end
end end
@@ -292,20 +190,18 @@ shared.StinkyTracker = {
-- Log total stinky count after processing -- Log total stinky count after processing
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
local count = 0 local count = 0
for _ in pairs(shared.stinkyTracker.stinkies:get()) do for _ in pairs(shared.stinkyTracker.stinkies:get()) do count = count + 1 end
count = count + 1
end
print(string.format("[%s] Current total stinkies tracked: %d", ModuleName, count)) print(string.format("[%s] Current total stinkies tracked: %d", ModuleName, count))
end end
shared.StinkyTracker.ForEach(function(name, stinky) for name, stinky in pairs(shared.stinkyTracker.stinkies) do
if shared.AgentTracker.IsAgent(name) then if Heimdall_Data.config.agents[name] then
shared.stinkyTracker.stinkies[name] = nil shared.stinkyTracker.stinkies[name] = nil
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Removed agent from stinkies: %s", ModuleName, name)) print(string.format("[%s] Removed agent from stinkies: %s", ModuleName, name))
end end
end end
end) end
end) end)
local targetFrame = CreateFrame("Frame") local targetFrame = CreateFrame("Frame")
@@ -314,7 +210,7 @@ shared.StinkyTracker = {
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Event received: %s for unit: %s", ModuleName, event, unit or "target")) print(string.format("[%s] Event received: %s for unit: %s", ModuleName, event, unit or "target"))
end end
unit = "target" local unit = "target"
if not Heimdall_Data.config.stinkyTracker.enabled then if not Heimdall_Data.config.stinkyTracker.enabled then
if Heimdall_Data.config.stinkyTracker.debug then if Heimdall_Data.config.stinkyTracker.debug then
@@ -340,7 +236,7 @@ shared.StinkyTracker = {
name = name, name = name,
class = UnitClass(unit), class = UnitClass(unit),
seenAt = GetTime(), seenAt = GetTime(),
hostile = true, hostile = true
} }
return return
end end
@@ -358,7 +254,8 @@ shared.StinkyTracker = {
shared.stinkyTracker.stinkies[name] = nil shared.stinkyTracker.stinkies[name] = nil
end) end)
if Heimdall_Data.config.stinkyTracker.debug then print(string.format("[%s] Module initialized", ModuleName)) end if Heimdall_Data.config.stinkyTracker.debug then
print(string.format("[%s] Module initialized", ModuleName)) print(string.format("[%s] Module initialized", ModuleName))
end, end
} print("[Heimdall] StinkyTracker loaded")
end

View File

@@ -1,25 +1,11 @@
local _, shared = ... local addonname, shared = ...
---@cast shared HeimdallShared ---@cast shared HeimdallShared
---@cast addonname string
local ModuleName = "Whoer" local ModuleName = "Whoer"
---@class HeimdallWhoConfig ---@diagnostic disable-next-line: missing-fields
---@field enabled boolean shared.Whoer = {}
---@field debug boolean function shared.Whoer.Init()
---@field ignored table<string, boolean>
---@field channels string[]
---@field ttl number
---@field doWhisper boolean
---@field zoneNotifyFor table<string, boolean>
---@field queries string
---@class HeimdallWhoData
---@field updateTicker Timer?
---@field whoTicker Timer?
local whoWaiting = false
---@class Whoer
shared.Whoer = {
Init = function()
if not Heimdall_Data.who then Heimdall_Data.who = {} end if not Heimdall_Data.who then Heimdall_Data.who = {} end
if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end if not Heimdall_Data.who.data then Heimdall_Data.who.data = {} end
@@ -46,7 +32,7 @@ shared.Whoer = {
---@return Player ---@return Player
new = function(name, guild, race, class, zone) new = function(name, guild, race, class, zone)
local self = setmetatable({}, { local self = setmetatable({}, {
__index = Player, __index = Player
}) })
self.name = name self.name = name
self.guild = guild self.guild = guild
@@ -61,15 +47,13 @@ shared.Whoer = {
end, end,
---@return string ---@return string
ToString = function(self) ToString = function(self)
local out = string.format( local out = string.format("%s %s %s\nFirst: %s Last: %s Seen: %3d",
"%s %s %s\nFirst: %s Last: %s Seen: %3d",
shared.padString(self.name, 16, true), shared.padString(self.name, 16, true),
shared.padString(self.guild, 26, false), shared.padString(self.guild, 26, false),
shared.padString(self.zone, 26, false), shared.padString(self.zone, 26, false),
shared.padString(self.firstSeen, 10, true), shared.padString(self.firstSeen, 10, true),
shared.padString(self.lastSeen, 10, true), shared.padString(self.lastSeen, 10, true),
self.seenCount self.seenCount)
)
return string.format("|cFF%s%s|r", shared.classColors[self.class], out) return string.format("|cFF%s%s|r", shared.classColors[self.class], out)
end, end,
} }
@@ -83,12 +67,12 @@ shared.Whoer = {
---@return WHOQuery ---@return WHOQuery
new = function(query, filters) new = function(query, filters)
local self = setmetatable({}, { local self = setmetatable({}, {
__index = WHOQuery, __index = WHOQuery
}) })
self.query = query self.query = query
self.filters = filters self.filters = filters
return self return self
end, end
} }
---@class WHOFilter ---@class WHOFilter
@@ -97,10 +81,12 @@ shared.Whoer = {
---@type WHOFilter ---@type WHOFilter
local NotSiegeOfOrgrimmarFilter = { local NotSiegeOfOrgrimmarFilter = {
Run = function(name, guild, level, race, class, zone) Run = function(name, guild, level, race, class, zone)
if not zone then return false end if not zone then
return false
end
return zone ~= "Siege of Orgrimmar" return zone ~= "Siege of Orgrimmar"
end, end,
key = "notsoo", key = "notsoo"
} }
---@type WHOFilter ---@type WHOFilter
local AllianceFilter = { local AllianceFilter = {
@@ -109,7 +95,7 @@ shared.Whoer = {
if not shared.raceMap[race] then return false end if not shared.raceMap[race] then return false end
return shared.raceMap[race] == "Alliance" return shared.raceMap[race] == "Alliance"
end, end,
key = "ally", key = "ally"
} }
---@class WhoQueryService ---@class WhoQueryService
@@ -124,13 +110,15 @@ shared.Whoer = {
queries = {}, queries = {},
filters = { filters = {
NotSiegeOfOrgrimmarFilter, NotSiegeOfOrgrimmarFilter,
AllianceFilter, AllianceFilter
}, },
---@param key string ---@param key string
---@return WHOFilter? ---@return WHOFilter?
getFilter = function(key) getFilter = function(key)
for _, filter in pairs(shared.WhoQueryService.filters) do for _, filter in pairs(shared.WhoQueryService.filters) do
if filter.key == key then return filter end if filter.key == key then
return filter
end
end end
return nil return nil
end, end,
@@ -176,19 +164,19 @@ shared.Whoer = {
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] WHO query: %s with %d filters", ModuleName, queryParts[1], #filters)) print(string.format("[%s] WHO query: %s with %d filters", ModuleName, queryParts[1], #filters))
end end
shared.dump(filters) shared.dumpTable(filters)
return WHOQuery.new(queryParts[1], filters) return WHOQuery.new(queryParts[1], filters)
end, end,
---@param queryStr string ---@param queries string
---@return WHOQuery[] ---@return WHOQuery[]
WhoQueriesFromString = function(queryStr) WhoQueriesFromString = function(queries)
local queries = shared.Split(queryStr, "\n") local queries = shared.Split(queries, "\n")
local ret = {} local ret = {}
for _, query in pairs(queries) do for _, query in pairs(queries) do
table.insert(ret, shared.WhoQueryService.WhoQueryFromString(query)) table.insert(ret, shared.WhoQueryService.WhoQueryFromString(query))
end end
return ret return ret
end, end
} }
shared.WhoQueryService.queries = shared.WhoQueryService.WhoQueriesFromString(Heimdall_Data.config.who.queries) shared.WhoQueryService.queries = shared.WhoQueryService.WhoQueriesFromString(Heimdall_Data.config.who.queries)
@@ -199,20 +187,9 @@ shared.Whoer = {
print(string.format("[%s] ShouldNotifyForZone %s", ModuleName, inputZone)) print(string.format("[%s] ShouldNotifyForZone %s", ModuleName, inputZone))
end end
for zone, _ in pairs(Heimdall_Data.config.who.zoneNotifyFor) do for zone, _ in pairs(Heimdall_Data.config.who.zoneNotifyFor) do
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Checking zone %s", ModuleName, zone))
end
if zone == "*" then return true end
if string.find(inputZone, zone) then if string.find(inputZone, zone) then
if not Heimdall_Data.config.who.debug then if not Heimdall_Data.config.who.debug then
print( print(string.format("[%s] ShouldNotifyForZone %s is true thanks to %s", ModuleName, inputZone, zone))
string.format(
"[%s] ShouldNotifyForZone %s is true thanks to %s",
ModuleName,
inputZone,
zone
)
)
end end
return true return true
end end
@@ -252,25 +229,6 @@ shared.Whoer = {
local function Notify(player) local function Notify(player)
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] Processing notification for player: %s", ModuleName, player.name)) print(string.format("[%s] Processing notification for player: %s", ModuleName, player.name))
print(
string.format(
"[%s] Player details - Guild: %s, Race: %s, Class: %s, Zone: %s",
ModuleName,
player.guild,
player.race,
player.class,
player.zone
)
)
print(
string.format(
"[%s] Player history - First seen: %s, Last seen: %s, Seen count: %d",
ModuleName,
player.firstSeen,
player.lastSeen,
player.seenCount
)
)
end end
if not Heimdall_Data.config.who.enabled then if not Heimdall_Data.config.who.enabled then
@@ -290,44 +248,32 @@ shared.Whoer = {
if not shared.Whoer.ShouldNotifyForZone(player.zone) then if not shared.Whoer.ShouldNotifyForZone(player.zone) then
--if not Heimdall_Data.config.who.zoneNotifyFor[player.zone] then --if not Heimdall_Data.config.who.zoneNotifyFor[player.zone] then
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print( print(string.format("[%s] Skipping notification - Zone '%s' not in notify list", ModuleName, player.zone))
string.format(
"[%s] Skipping notification - Zone '%s' not in notify list",
ModuleName,
player.zone
)
)
end end
return string.format("Not notifying for zone %s", tostring(player.zone)) return string.format("Not notifying for zone %s", tostring(player.zone))
end end
for _, channel in pairs(Heimdall_Data.config.who.channels) do for _, channel in pairs(Heimdall_Data.config.who.channels) do
local locale = shared.GetLocaleForChannel(channel) local locale = shared.GetLocaleForChannel(channel)
local text = string.format( local text = string.format(shared._L("whoerNew", locale),
shared._L("whoerNew", locale),
player.name, player.name,
player.stinky and "(!!!!)" or "", player.stinky and "(!!!!)" or "",
shared._L(player.class, locale), shared._L(player.class, locale),
--shared._L(player.race, locale), --shared._L(player.race, locale),
shared._L(shared.raceMap[player.race] or "unknown", locale), shared._L(shared.raceMap[player.race] or "unknown", locale),
player.guild, player.guild,
shared._L(player.zone, locale) shared._L(player.zone, locale))
)
---@type Message ---@type Message
local msg = { local msg = {
channel = "C", channel = "C",
data = channel, data = channel,
message = text, message = text
} }
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] Queuing channel notification", ModuleName)) print(string.format("[%s] Queuing channel notification", ModuleName))
shared.dump(msg) shared.dumpTable(msg)
end
if Heimdall_Data.config.networkMessenger.enabled then
shared.NetworkMessenger.Enqueue(msg)
elseif Heimdall_Data.config.messenger.enabled then
shared.Messenger.Enqueue(msg)
end end
table.insert(shared.networkMessenger.queue, msg)
end end
--if Heimdall_Data.config.who.doWhisper then --if Heimdall_Data.config.who.doWhisper then
@@ -365,32 +311,26 @@ shared.Whoer = {
end end
for _, channel in pairs(Heimdall_Data.config.who.channels) do for _, channel in pairs(Heimdall_Data.config.who.channels) do
local locale = shared.GetLocaleForChannel(channel) local locale = shared.GetLocaleForChannel(channel)
local text = string.format( local text = string.format(shared._L("whoerMoved", locale),
shared._L("whoerMoved", locale),
player.name, player.name,
player.stinky and "(!!!!)" or "", player.stinky and "(!!!!)" or "",
shared._L(player.class, locale), shared._L(player.class, locale),
--shared._L(player.race, locale), --shared._L(player.race, locale),
shared._L(shared.raceMap[player.race] or "unknown", locale), shared._L(shared.raceMap[player.race] or "unknown", locale),
player.guild, player.guild,
shared._L(zone, locale) shared._L(zone, locale))
)
---@type Message ---@type Message
local msg = { local msg = {
channel = "C", channel = "C",
data = channel, data = channel,
message = text, message = text
} }
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] Queuing channel notification", ModuleName)) print(string.format("[%s] Queuing channel notification", ModuleName))
shared.dump(msg) shared.dumpTable(msg)
end
if Heimdall_Data.config.networkMessenger.enabled then
shared.NetworkMessenger.Enqueue(msg)
elseif Heimdall_Data.config.messenger.enabled then
shared.Messenger.Enqueue(msg)
end end
table.insert(shared.networkMessenger.queue, msg)
end end
--if Heimdall_Data.config.who.doWhisper then --if Heimdall_Data.config.who.doWhisper then
@@ -420,32 +360,27 @@ shared.Whoer = {
for _, channel in pairs(Heimdall_Data.config.who.channels) do for _, channel in pairs(Heimdall_Data.config.who.channels) do
local locale = shared.GetLocaleForChannel(channel) local locale = shared.GetLocaleForChannel(channel)
local text = string.format( local text = string.format(shared._L("whoerGone", locale),
shared._L("whoerGone", locale),
player.name, player.name,
player.stinky and "(!!!!)" or "", player.stinky and "(!!!!)" or "",
shared._L(player.class, locale), shared._L(player.class, locale),
--shared._L(player.race, locale), --shared._L(player.race, locale),
shared._L(shared.raceMap[player.race] or "unknown", locale), shared._L(shared.raceMap[player.race] or "unknown", locale),
player.guild, player.guild,
shared._L(player.zone, locale) shared._L(player.zone, locale))
)
---@type Message ---@type Message
local msg = { local msg = {
channel = "C", channel = "C",
data = channel, data = channel,
message = text, message = text
} }
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] Queuing channel notification", ModuleName)) print(string.format("[%s] Queuing channel notification", ModuleName))
shared.dump(msg) shared.dumpTable(msg)
end
if Heimdall_Data.config.networkMessenger.enabled then
shared.NetworkMessenger.Enqueue(msg)
elseif Heimdall_Data.config.messenger.enabled then
shared.Messenger.Enqueue(msg)
end end
--table.insert(shared.messenger.queue, msg)
table.insert(shared.networkMessenger.queue, msg)
end end
--if Heimdall_Data.config.who.doWhisper then --if Heimdall_Data.config.who.doWhisper then
@@ -469,9 +404,6 @@ shared.Whoer = {
frame:SetScript("OnEvent", function(self, event, ...) frame:SetScript("OnEvent", function(self, event, ...)
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] WHO list update received", ModuleName)) print(string.format("[%s] WHO list update received", ModuleName))
print(
string.format("[%s] Query index: %d/%d", ModuleName, whoQueryIdx, #shared.WhoQueryService.queries)
)
end end
if not Heimdall_Data.config.who.enabled then if not Heimdall_Data.config.who.enabled then
@@ -498,17 +430,7 @@ shared.Whoer = {
for i = 1, results do for i = 1, results do
local name, guild, level, race, class, zone = GetWhoInfo(i) local name, guild, level, race, class, zone = GetWhoInfo(i)
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print( print(string.format("[%s] Processing result %d/%d: %s/%s/%s", ModuleName, i, results, name, class, zone))
string.format(
"[%s] Processing result %d/%d: %s/%s/%s",
ModuleName,
i,
results,
name,
class,
zone
)
)
end end
local continue = false local continue = false
@@ -516,27 +438,11 @@ shared.Whoer = {
local filters = query.filters local filters = query.filters
for _, filter in pairs(filters) do for _, filter in pairs(filters) do
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print( print(string.format("[%s] Running filter %s on %s/%s/%s", ModuleName, filter.key, name, class, zone))
string.format(
"[%s] Running filter %s on %s/%s/%s",
ModuleName,
filter.key,
name,
class,
zone
)
)
end end
if not filter.Run(name, guild, level, race, class, zone) then if not filter.Run(name, guild, level, race, class, zone) then
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print( print(string.format("[%s] Player %s filtered out by WHO filter %s", ModuleName, name, filter.key))
string.format(
"[%s] Player %s filtered out by WHO filter %s",
ModuleName,
name,
filter.key
)
)
end end
continue = true continue = true
break break
@@ -548,22 +454,18 @@ shared.Whoer = {
print(string.format("[%s] Ignoring blacklisted player: %s", ModuleName, name)) print(string.format("[%s] Ignoring blacklisted player: %s", ModuleName, name))
end end
continue = true continue = true
end else
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print(string.format("[%s] Player %s is not blacklisted", ModuleName, name)) print(string.format("[%s] Player %s is not blacklisted", ModuleName, name))
end end
if not continue then
if Heimdall_Data.config.who.debug then
print(string.format("[%s] Player %s is not filtered out", ModuleName, name))
end end
if not continue then
local timestamp = date("%Y-%m-%dT%H:%M:%S") local timestamp = date("%Y-%m-%dT%H:%M:%S")
local player = HeimdallStinkies[name] local player = HeimdallStinkies[name]
if not player then if not player then
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print( print(string.format("[%s] New player detected: %s (%s) in %s", ModuleName, name, class, zone))
string.format("[%s] New player detected: %s (%s) in %s", ModuleName, name, class, zone)
)
end end
player = Player.new(name, guild, race, class, zone) player = Player.new(name, guild, race, class, zone)
@@ -573,15 +475,8 @@ shared.Whoer = {
if existing then if existing then
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print( print(string.format("[%s] Found existing data for %s - Last seen: %s, Count: %d",
string.format( ModuleName, name, existing.lastSeen or "never", existing.seenCount or 0))
"[%s] Found existing data for %s - Last seen: %s, Count: %d",
ModuleName,
name,
existing.lastSeen or "never",
existing.seenCount or 0
)
)
end end
player.lastSeen = existing.lastSeen or "never" player.lastSeen = existing.lastSeen or "never"
player.firstSeen = existing.firstSeen or "never" player.firstSeen = existing.firstSeen or "never"
@@ -591,14 +486,7 @@ shared.Whoer = {
if player.firstSeen == "never" then if player.firstSeen == "never" then
player.firstSeen = timestamp player.firstSeen = timestamp
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print( print(string.format("[%s] First time seeing player: %s at %s", ModuleName, name, timestamp))
string.format(
"[%s] First time seeing player: %s at %s",
ModuleName,
name,
timestamp
)
)
end end
end end
@@ -609,20 +497,13 @@ shared.Whoer = {
end end
player.stinky = true player.stinky = true
--PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master") --PlaySoundFile("Interface\\Sounds\\Domination.ogg", "Master")
-- else else
-- PlaySoundFile("Interface\\Sounds\\Cloak.ogg", "Master") --PlaySoundFile("Interface\\Sounds\\Cloak.ogg", "Master")
end end
local err = Notify(player) local err = Notify(player)
if err then if err then
print( print(string.format("[%s] Error notifying for %s: %s", ModuleName, tostring(name), tostring(err)))
string.format(
"[%s] Error notifying for %s: %s",
ModuleName,
tostring(name),
tostring(err)
)
)
end end
player.lastSeen = timestamp player.lastSeen = timestamp
@@ -633,15 +514,8 @@ shared.Whoer = {
player.lastSeenInternal = GetTime() player.lastSeenInternal = GetTime()
if player.zone ~= zone then if player.zone ~= zone then
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print( print(string.format("[%s] Player %s zone changed from %s to %s", ModuleName, name, player.zone,
string.format( zone))
"[%s] Player %s zone changed from %s to %s",
ModuleName,
name,
player.zone,
zone
)
)
end end
local err = NotifyZoneChanged(player, zone) local err = NotifyZoneChanged(player, zone)
if err then if err then
@@ -658,8 +532,7 @@ shared.Whoer = {
end end
-- Turns out WA cannot do this ( -- Turns out WA cannot do this (
-- aura_env.UpdateMacro() -- aura_env.UpdateMacro()
-- No longer needed with the hook to friends frame show _G["FriendsFrameCloseButton"]:Click()
-- _G["FriendsFrameCloseButton"]:Click()
end) end)
do do
@@ -686,36 +559,18 @@ shared.Whoer = {
local query = shared.WhoQueryService.queries[whoQueryIdx] local query = shared.WhoQueryService.queries[whoQueryIdx]
if not query then if not query then
if Heimdall_Data.config.who.debug then if Heimdall_Data.config.who.debug then
print( print(string.format("[%s] Error: No WHO query found to run", ModuleName))
string.format("[%s] Error: No WHO query found to run at index %d", ModuleName, whoQueryIdx)
)
whoQueryIdx = 1
end end
return return
end end
if Heimdall_Data.config.who.debug then
print(
string.format(
"[%s] Running WHO query %d/%d: %s",
ModuleName,
whoQueryIdx,
#shared.WhoQueryService.queries,
query.query
)
)
print(string.format("[%s] Query has %d filters", ModuleName, #query.filters))
for i, filter in ipairs(query.filters) do
print(string.format("[%s] Filter %d: %s", ModuleName, i, filter.key))
end
end
whoQueryIdx = whoQueryIdx + 1 whoQueryIdx = whoQueryIdx + 1
if whoQueryIdx > #shared.WhoQueryService.queries then whoQueryIdx = 1 end if whoQueryIdx > #shared.WhoQueryService.queries then
whoQueryIdx = 1
end
lastQuery = query lastQuery = query
whoWaiting = true --print(string.format("Running who query: %s", tostring(query.query)))
---@diagnostic disable-next-line: param-type-mismatch ---@diagnostic disable-next-line: param-type-mismatch
SetWhoToUI(1) SetWhoToUI(1)
SetWhoToUI(1)
SendWho(query.query) SendWho(query.query)
end end
local function Tick() local function Tick()
@@ -724,12 +579,6 @@ shared.Whoer = {
end end
Tick() Tick()
end end
local original_FriendsFrame_OnEvent = FriendsFrame_OnEvent
local function my_FriendsFrame_OnEvent(self, event, ...)
if not (event == "WHO_LIST_UPDATE" and whoWaiting) then original_FriendsFrame_OnEvent(self, event, ...) end
end
FriendsFrame_OnEvent = my_FriendsFrame_OnEvent
print(string.format("[%s] Module initialized", ModuleName)) print("[Heimdall] Whoer loaded")
end, end
}

View File

@@ -6,7 +6,9 @@ local function StringToMap(str, deliminer)
local parts = { strsplit(deliminer, str) } local parts = { strsplit(deliminer, str) }
for _, line in ipairs(parts) do for _, line in ipairs(parts) do
line = strtrim(line) line = strtrim(line)
if line ~= "" then map[line] = true end if line ~= "" then
map[line] = true
end
end end
return map return map
end end
@@ -19,7 +21,9 @@ local function StringToArray(str, deliminer)
local array = { strsplit(deliminer, str) } local array = { strsplit(deliminer, str) }
for i, line in ipairs(array) do for i, line in ipairs(array) do
line = strtrim(line) line = strtrim(line)
if line ~= "" then ret[i] = line end if line ~= "" then
ret[i] = line
end
end end
return ret return ret
end end
@@ -35,7 +39,7 @@ local config = {
stinky = aura_env.config.spotter.stinky, stinky = aura_env.config.spotter.stinky,
notifyChannel = aura_env.config.spotter.notifyChannel, notifyChannel = aura_env.config.spotter.notifyChannel,
zoneOverride = aura_env.config.spotter.zoneOverride, zoneOverride = aura_env.config.spotter.zoneOverride,
throttleTime = aura_env.config.spotter.throttleTime, throttleTime = aura_env.config.spotter.throttleTime
}, },
who = { who = {
enabled = aura_env.config.who.enabled, enabled = aura_env.config.who.enabled,

2
_L.lua
View File

@@ -90,7 +90,6 @@ shared._Locale = {
updateInterval = "Update Interval", updateInterval = "Update Interval",
networkMessenger = "Network Messenger", networkMessenger = "Network Messenger",
queries = "Who queries", queries = "Who queries",
chatSniffer = "Chat Sniffer",
}, },
ru = { ru = {
bonkDetected = "%s ударил %s (%s)", bonkDetected = "%s ударил %s (%s)",
@@ -176,7 +175,6 @@ shared._Locale = {
updateInterval = "Интервал Обновления", updateInterval = "Интервал Обновления",
networkMessenger = "Сетевой Мессенджер", networkMessenger = "Сетевой Мессенджер",
queries = "Запросы Who", queries = "Запросы Who",
chatSniffer = "Сниффер Чата",
["Orgrimmar"] = "Оргриммар", ["Orgrimmar"] = "Оргриммар",
["Valley of Strength"] = "Долина Силы", ["Valley of Strength"] = "Долина Силы",
["Valley of Trials"] = "Долина Испытаний", ["Valley of Trials"] = "Долина Испытаний",

View File

@@ -1,61 +1,43 @@
#!/bin/bash #!/bin/bash
echo "Figuring out the tag..." # Default version increment
TAG=$(git describe --tags --exact-match 2>/dev/null || echo "") DEFAULT_INCREMENT="0.0.1"
if [ -z "$TAG" ]; then
# Get the latest tag
LATEST_TAG=$(git describe --tags $(git rev-list --tags --max-count=1))
# Increment the patch version
IFS='.' read -r -a VERSION_PARTS <<< "$LATEST_TAG"
VERSION_PARTS[2]=$((VERSION_PARTS[2]+1))
TAG="${VERSION_PARTS[0]}.${VERSION_PARTS[1]}.${VERSION_PARTS[2]}"
# Create a new tag
git tag $TAG
fi
echo "Tag: $TAG"
echo "Building the thing..." # Get the increment parameter or use the default
sed -i "s/## Version: .*/## Version: $TAG/" Heimdall.toc INCREMENT=${1:-$DEFAULT_INCREMENT}
sed -i "s/local VERSION = .*/local VERSION = \"$TAG\"/" Heimdall.lua
git add Heimdall.toc Heimdall.lua
git commit -m "Release $TAG"
git tag -f $TAG
git push origin $TAG
rm Heimdall-${TAG}.zip # Function to increment the version
mkdir Heimdall increment_version() {
cp *.lua *.toc Heimdall local version=$1
cp -r Modules Heimdall local increment=$2
cp -r Sounds Heimdall
cp -r Texture Heimdall
7z a Heimdall-${TAG}.zip Heimdall
rm -rf Heimdall
echo "Creating a release..." IFS='.' read -r -a version_parts <<< "$version"
TOKEN="$GITEA_API_KEY" IFS='.' read -r -a increment_parts <<< "$increment"
GITEA="https://git.site.quack-lab.dev"
REPO="dave/wow-heimdall"
# Create a release
RELEASE_RESPONSE=$(curl -s -X POST \
-H "Authorization: token $TOKEN" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d '{
"tag_name": "'"$TAG"'",
"name": "'"$TAG"'",
"draft": false,
"prerelease": false
}' \
$GITEA/api/v1/repos/$REPO/releases)
# Extract the release ID # Increment major, minor, and patch
echo $RELEASE_RESPONSE version_parts[0]=$((version_parts[0] + increment_parts[0]))
RELEASE_ID=$(echo $RELEASE_RESPONSE | awk -F'"id":' '{print $2+0; exit}') version_parts[1]=$((version_parts[1] + increment_parts[1]))
echo "Release ID: $RELEASE_ID" version_parts[2]=$((version_parts[2] + increment_parts[2]))
echo "Uploading the things..." # Reset minor and patch if major is incremented
curl -X POST \ if [ "${increment_parts[0]}" -gt 0 ]; then
-H "Authorization: token $TOKEN" \ version_parts[1]=0
-F "attachment=@Heimdall-${TAG}.zip" \ version_parts[2]=0
"$GITEA/api/v1/repos/$REPO/releases/${RELEASE_ID}/assets?name=Heimdall-${TAG}.zip" elif [ "${increment_parts[1]}" -gt 0 ]; then
rm Heimdall-${TAG}.zip version_parts[2]=0
fi
echo "${version_parts[0]}.${version_parts[1]}.${version_parts[2]}"
}
CURRENT_VERSION=$(grep -oP '## Version: \K[0-9]+\.[0-9]+\.[0-9]+' Heimdall.toc)
NEW_VERSION=$(increment_version "$CURRENT_VERSION" "$INCREMENT")
sed -i "s/## Version: $CURRENT_VERSION/## Version: $NEW_VERSION/" Heimdall.toc
sed -i "s/local VERSION = \"$CURRENT_VERSION\"/local VERSION = \"$NEW_VERSION\"/" Heimdall.lua
# Git operations
git add Heimdall.lua Heimdall.toc
git commit -m "Release $NEW_VERSION"
git tag "$NEW_VERSION"
echo "Deployment complete. New version: $NEW_VERSION"

View File

@@ -1,12 +0,0 @@
syntax = "All" # Specify a disambiguation for the style of Lua syntax being formatted. Possible options: All (default), Lua51, Lua52, Lua53, Lua54, LuaJIT, Luau, CfxLua
column_width = 120 # Approximate line length for printing. Used as a guide for line wrapping - this is not a hard requirement: lines may fall under or over the limit.
line_endings = "Windows" # Line endings type. Possible options: Unix (LF) or Windows (CRLF)
indent_type = "Tabs" # Indent type. Possible options: Tabs or Spaces
indent_width = 4 # Character size of single indentation. If indent_type is set to Tabs, this option is used as a heuristic to determine column width only.
quote_style = "AutoPreferDouble" # Quote style for string literals. Possible options: AutoPreferDouble, AutoPreferSingle, ForceDouble, ForceSingle. AutoPrefer styles will prefer the specified quote style, but fall back to the alternative if it has fewer string escapes. Force styles always use the specified style regardless of escapes.
call_parentheses = "Always" # Whether parentheses should be applied on function calls with a single string/table argument. Possible options: Always, NoSingleString, NoSingleTable, None, Input. Always applies parentheses in all cases. NoSingleString omits parentheses on calls with a single string argument. Similarly, NoSingleTable omits parentheses on calls with a single table argument. None omits parentheses in both cases. Note: parentheses are still kept in situations where removal can lead to obscurity (e.g. foo "bar".setup -> foo("bar").setup, since the index is on the call result, not the string). Input removes all automation and preserves parentheses only if they were present in input code: consistency is not enforced.
space_after_function_names = "Never" # Specify whether to add a space between the function name and parentheses. Possible options: Never, Definitions, Calls, or Always
collapse_simple_statement = "Always" # Specify whether to collapse simple statements. Possible options: Never, FunctionOnly, ConditionalOnly, or Always
[sort_requires]
enabled = false