Skip to content

Commit 1a621a0

Browse files
committed
Update status_effects.lua
1 parent 63c44c4 commit 1a621a0

File tree

1 file changed

+68
-1
lines changed

1 file changed

+68
-1
lines changed

status_effects.lua

Lines changed: 68 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,64 @@ function status_effects:initialize()
99
self.is_initialized = true
1010
end
1111

12+
function status_effects:get_id_from_player_name(player_name)
13+
local player = self.party_player_ids[player_name]
14+
15+
if player then
16+
return player
17+
else
18+
return -1
19+
end
20+
end
21+
22+
function status_effects:update_target_zone(target_id, zone)
23+
if target_id == -1 then
24+
-- we don't know who it is, have to skip :(
25+
return
26+
end
27+
28+
local existing_zone = self.target_zone[target_id]
29+
30+
if existing_zone and zone == existing_zone then
31+
-- Zone hasn't changed, nothing to do
32+
return
33+
end
34+
35+
-- Handle buffs if the zone has changed
36+
if existing_zone then
37+
--print(target_id .. ' - Zone has changed from ' .. existing_zone .. ' to ' .. zone .. ', removing JA buffs.')
38+
39+
if self.buffs[target_id] then
40+
for buff_id, spell_table in pairs(self.buffs[target_id]) do
41+
for composite_key in pairs(spell_table) do
42+
local key_type = composite_key:match("^(%a+):%d+$")
43+
44+
--print(key_type .. ' ' .. composite_key)
45+
46+
if key_type == 'ja' then
47+
spell_table[composite_key] = nil -- Remove JA buff
48+
49+
-- Clean up empty buff_id entry
50+
if next(spell_table) == nil then
51+
self.buffs[target_id][buff_id] = nil
52+
end
53+
end
54+
end
55+
end
56+
57+
-- Clean up empty target_id entry
58+
if next(self.buffs[target_id]) == nil then
59+
self.buffs[target_id] = nil
60+
end
61+
end
62+
else
63+
--print('Not tracking target zone yet, setting to ' .. zone)
64+
end
65+
66+
-- Update the zone
67+
self.target_zone[target_id] = zone
68+
end
69+
1270
function status_effects:update()
1371
for target_id, target_buffs in pairs(self.buffs) do
1472
for buff_id, spell_table in pairs(target_buffs) do
@@ -455,7 +513,7 @@ function status_effects:add_buff_ma(target_id, spell_id, buff_id, type, actor_id
455513
-- Find the shortest duration song
456514
table.sort(bard_songs, function(a, b) return a.duration < b.duration end)
457515
local shortest_song = bard_songs[1]
458-
self.buffs[target_id][shortest_song.buff_id][shortest_song.spell_id] = nil -- Replace it
516+
self.buffs[target_id][shortest_song.buff_id][shortest_song.composite_id] = nil -- Replace it
459517

460518
-- Clean up if the spell table is empty
461519
if next(self.buffs[target_id][shortest_song.buff_id]) == nil then
@@ -822,6 +880,15 @@ windower.register_event('prerender', function()
822880
end
823881
end)
824882

883+
windower.register_event('incoming chunk', function(id, original, modified, injected, blocked)
884+
if id == 0x01D then -- complete load
885+
local info = windower.ffxi.get_info()
886+
status_effects.current_zone = (info.mog_house and -1) or windower.ffxi.get_info().zone
887+
status_effects:update_target_zone(windower.ffxi.get_player().id, status_effects.current_zone)
888+
status_effects:remove_all_non_party_buffs()
889+
end
890+
end)
891+
825892
windower.register_event('incoming chunk', function(id, data)
826893
if status_effects.is_initialized then
827894
if id == 0x028 then

0 commit comments

Comments
 (0)