-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathDebuffer.lua
More file actions
183 lines (149 loc) · 6.12 KB
/
Debuffer.lua
File metadata and controls
183 lines (149 loc) · 6.12 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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
_addon.name = "Debuffer"
_addon.version = '0.1'
require "luau"
packets = require('packets')
texts = require('texts')
require "Enfeebling"
require "GearEquipping"
require "maps"
require "Events"
require "Display"
frame_time = 0
debuffed_mobs = {}
function get_spell_info(spell_id)
return res.spells[spell_id] or nil
end
function get_buff_info(status_id)
return res.buffs[status_id] or nil
end
function handle_mob_enfeeble(packet, spell_info)
for _, target in pairs(packet.targets) do
add_debuffed_mob(target.id)
local mob_debuffs = debuffed_mobs[target.id]
local buff_info = get_buff_info(target.actions[1].param)
local expected_duration = custom_durations[spell_info.id] or spell_info.duration or 0
if spell_info.skill == 35 then
expected_duration = calculate_enfeebling_magic_expected_duration(spell_info)
end
if custom_overwrites[spell_info.id] then
for _, overwrite_status_id in pairs(custom_overwrites[spell_info.id]) do
remove_debuff_mob(target.id, overwrite_status_id)
end
elseif spell_info.overwrites then
for _, overwrite_status_id in pairs(spell_info.overwrites) do
remove_debuff_mob(target.id, overwrite_status_id)
end
end
apply_debuff_mob(target.id, buff_info, spell_info, expected_duration)
end
end
function handle_dia_spell(packet, spell_info)
for _, target in pairs(packet.targets) do
add_debuffed_mob(target.id)
local mob_debuffs = debuffed_mobs[target.id]
local buff_info = get_buff_info(target.actions[1].param)
local expected_duration = custom_durations[spell_info.id] or spell_info.duration or 0
if spell_info.skill == 35 then
expected_duration = calculate_enfeebling_magic_expected_duration(spell_info)
end
if mob_debuffs[134] then
if custom_overwrites[spell_info.id] and custom_overwrites[spell_info.id]:contains(mob_debuffs[134].spell_id) then
remove_debuffed_mob(mob_id, 134)
apply_debuff_mob(target.id, buff_info, spell_info, expected_duration)
elseif spell_info.overwrites and spell_info.overwrites:contains(mob_debuffs[134].spell_id) then
remove_debuffed_mob(mob_id, 134)
apply_debuff_mob(target.id, buff_info, spell_info, expected_duration)
else
return
end
elseif mob_debuffs[135]
if custom_overwrites[spell_info.id] and custom_overwrites[spell_info.id]:contains(mob_debuffs[135].spell_id) then
remove_debuffed_mob(mob_id, 135)
apply_debuff_mob(target.id, buff_info, spell_info, expected_duration)
elseif spell_info.overwrites and spell_info.overwrites:contains(mob_debuffs[135].spell_id) then
remove_debuffed_mob(mob_id, 135)
apply_debuff_mob(target.id, buff_info, spell_info, expected_duration)
else
return
end
end
end
end
function handle_helix_spell(packet, spell_info)
local target = packet.targets[1]
add_debuffed_mob(target.id)
local expected_duration = custom_durations[spell_info.id] or spell_info.duration or 0
local buff_info = get_buff_info(target.actions[1].param)
apply_debuff_mob(target.id, buff_info, spell_info, expected_duration)
end
function handle_ja_spell(packet, spell_info)
for _, target in pairs(packet.targets) do
add_debuffed_mob(target.id)
local mob_debuffs = debuffed_mobs[target.id]
local status_id = target.actions[1].param
local expected_duration = custom_durations[spell_info.id] or spell_info.duration or 60
if mob_debuffs[1000] and mob_debuffs[1000].spell_name:startswith(ja_spell_effects[spell_info.id]) then
raise_ja_debuff_tier(target.id, spell_info)
else
apply_ja_debuff_mob(target.id, status_id, spell_info, expected_duration)
end
end
end
function add_debuffed_mob(mob_id)
if not debuffed_mobs[mob_id] then
debuffed_mobs[mob_id] = {}
end
end
function remove_debuffed_mob(mob_id)
if debuffed_mobs[mob_id] then
debuffed_mobs[mob_id] = nil
end
end
function apply_debuff_mob(mob_id, buff_info, spell_info, expected_duration)
if debuffed_mobs[mob_id][buff_info.id] ~= nil then
debuffed_mobs[mob_id][buff_info.id] = nil
end
debuffed_mobs[mob_id][buff_info.id] = {
buff = buff_info,
spell = spell_info,
spell_start_time = os.clock(),
spell_duration = expected_duration
}
end
function apply_ja_debuff_mob(mob_id, status_id, spell_info, expected_duration)
if debuffed_mobs[mob_id][status_id] ~= nil then
debuffed_mobs[mob_id][status_id] = nil
end
debuffed_mobs[mob_id][status_id] = {
spell = spell_info,
spell_start_time = os.clock(),
spell_duration = expected_duration,
ja_tier = 1,
spell_effect = ja_spell_effects[spell_info.id] .. '5%',
remove_at_end_of_timer = true
}
end
function raise_ja_debuff_tier(mob_id, spell_info)
if not debuffed_mobs[mob_id] then return end
local current_ja_status = debuffed_mobs[mob_id][1000] or nil
current_ja_status.ja_tier = current_ja_status.ja_tier + 1
current_ja_status.spell_effect = ja_spell_effects[spell_info.id] .. tostring(current_ja_status.ja_tier * 5) .. '%'
end
function remove_debuff_mob(mob_id, status_id)
if debuffed_mobs[mob_id] then
debuffed_mobs[mob_id][status_id] = nil
end
end
function clear_debuffed_mobs()
debuffed_mobs = {}
end
function get_buff_info_string(buff_info)
local time = os.clock()
local info_string = buff_info.buff.en .. '(' .. buff_info.spell.en .. ') : ' .. string.format( "%.0f",(buff_info.spell_start_time + buff_info.expected_duration) - time)
return info_string
end
function get_ja_buff_info_string(buff_info)
local time = os.clock()
local info_string = buff_info.spell_effect .. '(' .. buff_info.spell_name .. ') : ' .. string.format("%.0f", (buff_info.spell_start_time + buff_info.expected_duration) - time)
return info_string
end