-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDevilsDespair.lua
More file actions
163 lines (134 loc) · 5.83 KB
/
DevilsDespair.lua
File metadata and controls
163 lines (134 loc) · 5.83 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
--[[
Copyright © 2026, DTR
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of this addon nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
]]
_addon.name = 'Devil\'s Despair'
_addon.author = 'DTR'
_addon.version = '1.0'
_addon.desc = 'Removes Halloween Harvest Festival music by replacing it with the original zone music.'
_addon.commands = {'dd'}
require('luau')
require('strings')
local config = require('config')
local res = require('resources')
local packets = require('packets')
local send_command = windower.send_command
local add_to_chat = windower.add_to_chat
local addon_title = ('['):color(36)..('Devil\'s Despair'):color(209)..('] '):color(36)
-- Default settings
local defaults = {
enabled = true
}
local settings = config.load(defaults)
-- Zone music mapping (zone name -> music ID)
local zone_music = {
-- San d'Oria
['Port San d\'Oria'] = 107,
['Northern San d\'Oria'] = 107,
['Southern San d\'Oria'] = 107,
-- Bastok
['Bastok Markets'] = 152,
['Bastok Mines'] = 152,
['Port Bastok'] = 152,
['Metalworks'] = 154,
-- Windurst
['Windurst Waters'] = 151,
['Windurst Walls'] = 151,
['Port Windurst'] = 151,
['Windurst Woods'] = 151,
--Jeuno
['Port Jeuno'] = 110,
['Ru\'Lude Gardens'] = 110,
['Upper Jeuno'] = 110,
['Lower Jeuno'] = 110,
--Adoulin
['Western Adoulin'] = 59,
--Outdoor zones
['Misareaux Coast'] = 230,
['Qufim Island'] = 0,
-- Dungeons
['Horlais Peak'] = 0,
['Upper Delkfutt\'s Tower'] = 0
}
local current_zone = nil
local function initialize_addon()
current_zone = windower.ffxi.get_info().zone
add_to_chat(36, addon_title .. ('Addon started!'):color(36))
add_to_chat(36, addon_title .. ('Removal of Harvest Festival Music is ' .. (settings.enabled and 'enabled' or 'disabled')))
end
windower.register_event('load', initialize_addon)
windower.register_event('reload', initialize_addon)
windower.register_event('zone change', function(new_id, old_id)
current_zone = new_id
end)
windower.register_event('incoming chunk', function(id, original, modified, injected, blocked)
if not settings.enabled then return end
if id == 0x00A then
local packet = packets.parse('incoming', original)
local day_music = packet['Day Music']
local night_music = packet['Night Music']
local modified_packet = false
-- Get current zone info
local current_zone_id = windower.ffxi.get_info().zone
local zone_info = res.zones[current_zone_id]
local correct_music = zone_info and zone_music[zone_info.en]
-- Replaces day and night music with their original, appropriate music
if (day_music == 29 or night_music == 29) and correct_music then
if day_music == 29 then
packet['Day Music'] = correct_music
modified_packet = true
end
if night_music == 29 then
packet['Night Music'] = correct_music
modified_packet = true
end
end
-- Return modified packet if any changes were made
if modified_packet then
local new_packet = packets.build(packet)
return new_packet
end
end
end)
windower.register_event('addon command', function(command, ...)
command = command and command:lower() or ''
local args = {...}
if command == 'on' then
settings.enabled = true
settings:save()
add_to_chat(36, addon_title .. ('Harvest Festival Music: Disabled'))
add_to_chat(36, addon_title .. ('Please move to another area for changes to take effect.'))
elseif command == 'off' then
settings.enabled = false
settings:save()
add_to_chat(36, addon_title .. ('Harvest Festival Music: Enabled.'))
add_to_chat(36, addon_title .. ('Please move to another area for changes to take effect.'))
elseif command == 'toggle' then
settings.enabled = not settings.enabled
settings:save()
add_to_chat(36, addon_title .. ('Removal of Harvest Festival Music is now: ' .. (settings.enabled and 'enabled' or 'disabled')))
add_to_chat(36, addon_title .. ('Please move to another area for changes to take effect.'))
else
add_to_chat(36, addon_title .. ('Unknown command. Use //dd on/off or toggle.'):color(36))
end
end)