forked from beerman212/BuffTracker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEventHandler.lua
93 lines (77 loc) · 3.75 KB
/
EventHandler.lua
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
--ActionPacket.open_listener(action_handler)
function action_handler(action)
local actionpacket = ActionPacket.new(action)
local category = actionpacket:get_category_string()
local player = windower.ffxi.get_player()
local buffs = get_player_buffs(player)
if category == 'spell_finish' then
local actor_id = actionpacket:get_id()
local spell = actionpacket:get_spell()
local skill_name = res.skills[spell.skill].en
local time_cast = os.time()
if skill_name == "Enhancing Magic" then
if actor_id == player.id then
local equipment = windower.ffxi.get_items('equipment')
for target in actionpacket:get_targets() do
local action = target:get_actions()()
local message_id = action:get_message_id()
if no_effect_message_ids:contains(message_id) then
else
local buff = res.buffs[action.param]
local tracked_buff = TrackedBuff.new(buff, spell, player, target, equipment, time_cast)
tracked_buff:calculate_buff_duration()
tracked_buff:print_log(true)
end
end
else
end
elseif skill_name == "Enfeebling Magic" then
if actor_id == player.id then
local equipment = windower.ffxi.get_items('equipment')
for target in actionpacket:get_targets() do
local action = target:get_actions()()
local message_id = action:get_message_id()
if immunity_message_ids:contains(message_id) then
local target_name = target:get_name()
if mob_data.immunities:contains(target_name) then
if not (mob_data.immunities[target_name]:contains(action.top_level_param)) then
mob_data.immunities[target_name]:append(action.top_level_param)
end
else
mob_data.immunities:append({[target_name] = L{action.top_level_param}})
end
-- TODO: Update mob_data file
elseif no_effect_message_ids:contains(message_id) then
-- TODO: possibly notify player debuff not applied
elseif resist_message_ids:contains(message_id) then
-- TODO: possibly notify player debuff resisted
-- TODO: possibly aggregate resist data?
else
if damage_message_ids:contains(message_id) then
-- TODO: Handle Dia, Bio, Etc.
else
local buff = res.buffs[action.param]
local tracked_buff = TrackedBuff.new(buff, spell, player, target, equipment, time_cast)
tracked_buff:calculate_buff_duration()
tracked_buff:print_log(true)
end
end
end
else
end
end
end
end
windower.register_event('action message', function(id, data)
if id == 0x029 then
local action_message = {}
action_message.id = data:unpack('H', 0x19) % 32768
action_message.target_id = data:unpack('I', 0x09)
action_message.param = data:unpack('I', 0x0D)
if mob_death_message_ids:contains(action_message.id) then
-- TODO: Process tracked mob disposal
elseif wears_off_message_ids:contains(action_message.id) then
-- TODO: Process expired debuff
end
end
end)