-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.lua
More file actions
163 lines (139 loc) · 7.31 KB
/
init.lua
File metadata and controls
163 lines (139 loc) · 7.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
-- doesitstack by Algar
-- version 1.1 - Enhanced by Claude Code
-- A script to iterate through your buff and song list to check stacking of each effect with a provided spellId
-- Usage: /doesitstack <spellID> [triggers|trigger|t]
-- Optional second argument checks triggered spells for stacking conflicts
local mq = require('mq')
print("DoesItStack: Use '/doesitstack <spellID>' to check effect stacking with your current buffs/songs.")
print("DoesItStack: Add 'trigger', or 't' as a second argument to also check triggered spells.")
print("DoesItStack: Example: /doesitstack 12345 t")
print("Please note that exposed stacking information is not 100% accurate!")
mq.bind("/doesitstack", function(...)
local args = { ..., }
if not args[1] or args[1]:len() == 0 then
print("DoesItStack: Please enter a valid spell ID to check!")
return
end
local spellId = tonumber(args[1])
local checkTriggers = false
-- Check if second argument is provided for trigger checking
if args[2] and args[2]:len() > 0 then
local triggerArg = args[2]:lower()
if triggerArg == "trigger" or triggerArg == "t" then
checkTriggers = true
end
end
if type(spellId) == 'number' then
local spell = mq.TLO.Spell(spellId)
if spell and spell() then
local spellName = spell.Name() or "Error"
local noStack = 0
local buffSlots = mq.TLO.Me.MaxBuffSlots()
local songSlots = mq.TLO.MacroQuest.BuildName():lower() == "emu" and 20 or 30
printf("DoesItStack: Starting stacking check for %s(ID: %d).", spellName, spellId)
for i = 1, buffSlots do
local buff = mq.TLO.Me.Buff(i)
local buffId = buff() and buff.Spell.ID() or 0
local buffName = buff() and buff.Spell.Name() or "Error"
if buffId > 0 then
---@diagnostic disable-next-line: redundant-parameter
local stacks = spell.StacksWith(buffId)()
if not stacks then
printf("DoesItStack: This effect does NOT appear to stack with Buff slot %d - %s(ID: %d).", i, buffName, buffId)
noStack = noStack + 1
end
end
end
for i = 1, songSlots do
local song = mq.TLO.Me.Song(i)
local songId = song() and song.Spell.ID() or 0
local songName = song() and song.Spell.Name() or "Error"
if songId > 0 then
---@diagnostic disable-next-line: redundant-parameter
local stacks = spell.StacksWith(songId)()
if not stacks then
printf("DoesItStack: This effect does NOT appear to stack with Song slot %d - %s(ID: %d).", i, songName, songId)
noStack = noStack + 1
end
end
end
if noStack == 1 then
printf("DoesItStack: There is one reported effect that may prevent %s(ID: %d) from being applied.", spellName, spellId)
else
printf("DoesItStack: There are %s reported effects that may prevent %s(ID: %d) from being applied.", (noStack > 0 and noStack or "no"), spellName, spellId)
if noStack == 0 then
local willLand = spell.WillLand() or 0
-- some effects that go to the song window will return 0, some will return a number that appears to be indexed to buff slots... don't report willand for songs
if willLand > 0 and willLand <= buffSlots then
printf("This effect is expected to land in Buff slot %d.", willLand)
end
end
end
-- Check triggered spells if requested
if checkTriggers then
local numEffects = spell.NumEffects() or 0
local triggersChecked = 0
local triggerConflicts = 0
for i = 1, numEffects do
local triggerSpell = spell.Trigger(i)
if triggerSpell and triggerSpell() and triggerSpell.ID() > 0 then
triggersChecked = triggersChecked + 1
local triggerName = triggerSpell.Name() or "Unknown"
local triggerId = triggerSpell.ID()
local triggerNoStack = 0
-- Check trigger against buffs
for j = 1, buffSlots do
local buff = mq.TLO.Me.Buff(j)
local buffId = buff() and buff.Spell.ID() or 0
local buffName = buff() and buff.Spell.Name() or "Error"
if buffId > 0 then
---@diagnostic disable-next-line: redundant-parameter
local stacks = triggerSpell.StacksWith(buffId)()
if not stacks then
printf("DoesItStack: Triggered spell %s(ID: %d) does NOT appear to stack with Buff slot %d - %s(ID: %d).", triggerName, triggerId, j, buffName,
buffId)
triggerNoStack = triggerNoStack + 1
triggerConflicts = triggerConflicts + 1
end
end
end
-- Check trigger against songs
for j = 1, songSlots do
local song = mq.TLO.Me.Song(j)
local songId = song() and song.Spell.ID() or 0
local songName = song() and song.Spell.Name() or "Error"
if songId > 0 then
---@diagnostic disable-next-line: redundant-parameter
local stacks = triggerSpell.StacksWith(songId)()
if not stacks then
printf("DoesItStack: Triggered spell %s(ID: %d) does NOT appear to stack with Song slot %d - %s(ID: %d).", triggerName, triggerId, j, songName,
songId)
triggerNoStack = triggerNoStack + 1
triggerConflicts = triggerConflicts + 1
end
end
end
end
end
if triggersChecked == 0 then
print("DoesItStack: This spell has no triggered effects.")
elseif triggerConflicts == 1 then
printf("DoesItStack: There is one reported effect that may prevent a triggered spell from being applied.")
else
printf("DoesItStack: There are %s reported effects that may prevent a triggered spell from being applied.", (triggerConflicts > 0 and triggerConflicts or "no"))
end
end
else
print("DoesItStack: No spell detected with that ID!")
end
else
print("DoesItStack: Please enter a valid spell ID to check!")
end
end
)
local function main()
while true do
mq.delay(500)
end
end
main()