-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathSydneyHUD.lua
450 lines (395 loc) · 15.7 KB
/
SydneyHUD.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
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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
--[[
_____ __ __ ____ ______
/ ___/__ ______/ /___ ___ __ __/ / / / / / / __ \ ____
\__ \/ / / / __ / __ \/ _ \/ / / / /_/ / / / / / / / _ __/ / /
___/ / /_/ / /_/ / / / / __/ /_/ / __ / /_/ / /_/ / | |/ /_ _/
/____/\__, /\__,_/_/ /_/\___/\__, /_/ /_/\____/_____/ |___/ /_/
/____/ /____/
All-In-One mod for PAYDAY2 Developed by SydneyMOD Team
]]
if not Steam then
return
end
--[[
We setup the global table for our mod, along with some path variables, and a data table.
We cache the ModPath directory, so that when our hooks are called, we aren't using the ModPath from a
different mod.
]]
if not SydneyHUD then
SydneyHUD =
{
--[[
Alias for EZ to write log
Info: Information Log. Something succeeded.
Warn: Warning Log. Something Errored, but can keep working.
Error: Error Log. Something Errored. Can not keep working.
Dev: Develop Log. Printing var, Breakpoint.
]]
info = "[SydneyHUD Info] ",
warn = "[SydneyHUD Warn] ",
error = "[SydneyHUD Error] ",
dev = "[SydneyHUD Dev] ",
_cache = {},
SaveDataVer = 3,
ModVersion = ModInstance and tostring(ModInstance:GetVersion()) or "N/A",
EasterEgg =
{
FSS =
{
AIReactionTimeTooHigh = false
}
},
_down_count = {},
_language =
{
[1] = "english",
[2] = "japanese",
[3] = "french",
[4] = "russian",
[5] = "portuguese",
[6] = "spanish",
[7] = "korean"
},
-- var for util
assets_path = "./assets/mod_overrides/",
ModPath = ModPath,
LuaPath = ModPath .. "lua/",
LocPath = ModPath .. "loc/",
SaveDataPath = SavePath .. "SydneyHUD.json",
PocoPath = SavePath .. "hud3_config.json",
settings = {},
_menus = {
"sydneyhud_menu",
"sydneyhud_core",
"sydneyhud_gadget_options",
"sydneyhud_gadget_options_player",
"sydneyhud_gadget_options_sniper",
"sydneyhud_gadget_options_turret",
"sydneyhud_hudlist_options",
"sydneyhud_hudlist_options_left",
"sydneyhud_hudlist_options_right",
"sydneyhud_hudlist_options_right_ignore",
"sydneyhud_hudlist_options_buff",
"sydneyhud_hudlist_options_buff_options",
"sydneyhud_hudlist_options_buff_options_skills",
"sydneyhud_hudlist_options_buff_options_skills_mastermind",
"sydneyhud_hudlist_options_buff_options_skills_enforcer",
"sydneyhud_hudlist_options_buff_options_skills_technician",
"sydneyhud_hudlist_options_buff_options_skills_ghost",
"sydneyhud_hudlist_options_buff_options_skills_fugitive",
"sydneyhud_hudlist_options_buff_options_composite",
"sydneyhud_hudlist_options_buff_options_perks",
"sydneyhud_hudlist_options_buff_options_perks_crew_chief",
"sydneyhud_hudlist_options_buff_options_perks_muscle",
"sydneyhud_hudlist_options_buff_options_perks_armorer",
"sydneyhud_hudlist_options_buff_options_perks_hitman",
"sydneyhud_hudlist_options_buff_options_perks_infiltrator",
"sydneyhud_hudlist_options_buff_options_perks_sociopath",
"sydneyhud_hudlist_options_buff_options_perks_gambler",
"sydneyhud_hudlist_options_buff_options_perks_grinder",
"sydneyhud_hudlist_options_buff_options_perks_yakuza",
"sydneyhud_hudlist_options_buff_options_perks_maniac",
"sydneyhud_hudlist_options_buff_options_perks_anarchist",
"sydneyhud_hudlist_options_buff_options_perks_biker",
"sydneyhud_hudlist_options_buff_options_perks_kingpin",
"sydneyhud_hudlist_options_buff_options_perks_sicario",
"sydneyhud_hudlist_options_buff_options_perks_stoic",
"sydneyhud_hudlist_options_buff_options_perks_hacker",
"sydneyhud_hudlist_options_buff_options_boosts",
"sydneyhud_hudlist_options_buff_player_actions",
"sydneyhud_hudlist_options_color",
"sydneyhud_chat_info",
"sydneyhud_experimental",
"sydneyhud_gameplay_tweaks",
"sydneyhud_interact_tweaks",
"sydneyhud_menu_tweaks",
"sydneyhud_hud_tweaks",
"sydneyhud_hud_tweaks_assault",
"sydneyhud_hud_tweaks_interact",
"sydneyhud_hud_tweaks_name",
"sydneyhud_hud_tweaks_panel",
"sydneyhud_hud_tweaks_waypoint",
"sydneyhud_hud_tweaks_kill_counter",
"sydneyhud_hud_tweaks_hps_meter",
"sydneyhud_music_tweaks",
"sydneyhud_optimization_tweaks"
},
_poco_conflicting_defaults = {
buff = {
mirrorDirection = true,
showBoost = true,
showCharge = true,
showECM = true,
showInteraction = true,
showReload = true,
showShield = true,
showStamina = true,
showSwanSong = true,
showTapeLoop = true,
simpleBusyIndicator = true
},
game = {
interactionClickStick = true
},
playerBottom = {
showRank = true,
uppercaseNames = true
}
}
}
--[[
A simple save function that json encodes our _data table and saves it to a file.
]]
function SydneyHUD:Save()
local file = io.open(self.SaveDataPath, "w+")
if file then
self.settings.SaveDataVer = self.SaveDataVer
self.settings.SydneyHUDVersion = self:GetVersion()
file:write(json.encode(self.settings))
file:close()
end
end
--[[
A simple load function that decodes the saved json _data table if it exists.
]]
function SydneyHUD:Load()
self:LoadDefaults()
local file = io.open(self.SaveDataPath, "r")
if file then
local table = json.decode(file:read("*all")) or {}
file:close()
if table.SaveDataVer and table.SaveDataVer == self.SaveDataVer then
for k, v in pairs(table) do
if self.settings[k] ~= nil then
self.settings[k] = v
end
end
else
self.SaveDataNotCompatible = true
self:Save()
end
end
self:CheckPoco()
end
function SydneyHUD:GetOption(id)
return self.settings[id]
end
function SydneyHUD:GetModOption(mod_name, id)
return self:GetOption(mod_name .. "_" .. id)
end
function SydneyHUD:GetHUDListItemOption(item_name)
return self:GetOption("hudlist_ignore_item_" .. item_name)
end
function SydneyHUD:GetHUDListBuffOption(buff_name)
return self:GetOption("hudlist_ignore_buff_" .. buff_name)
end
function SydneyHUD:GetHUDListPlayerActionOption(action_name)
return self:GetOption("hudlist_ignore_player_action_" .. action_name)
end
function SydneyHUD:LoadDefaults()
local default_file = io.open(self.ModPath .."menu/default_values.json")
self.settings = json.decode(default_file:read("*all"))
default_file:close()
end
function SydneyHUD:CheckPoco()
local file = io.open(self.PocoPath)
if file then
self._poco_conf = json.decode(file:read("*all"))
file:close()
end
end
function SydneyHUD:ApplyFixedPocoSettings()
local file = io.open(self.PocoPath, "w+")
if file and self._fixed_poco_conf then
file:write(json.encode(self._fixed_poco_conf))
file:close()
local menu_title = managers.localization:text("sydneyhud_pocohud_config_fixed")
local menu_message = managers.localization:text("sydneyhud_pocohud_config_fixed_desc")
local menu_options = {
[1] = {
text = managers.localization:text("sydneyhud_pocohud_i_understand"),
is_cancel_button = true,
}
}
QuickMenu:new(menu_title, menu_message, menu_options, true)
end
end
function SydneyHUD:MakeOutlineText(panel, bg, txt)
bg.name = nil
local bgs = {}
for i = 1, 4 do
table.insert(bgs, panel:text(bg))
end
bgs[1]:set_x(txt:x() - 1)
bgs[1]:set_y(txt:y() - 1)
bgs[2]:set_x(txt:x() + 1)
bgs[2]:set_y(txt:y() - 1)
bgs[3]:set_x(txt:x() - 1)
bgs[3]:set_y(txt:y() + 1)
bgs[4]:set_x(txt:x() + 1)
bgs[4]:set_y(txt:y() + 1)
return bgs
end
function SydneyHUD:GetVersion()
return self.ModVersion
end
function SydneyHUD:SendChatMessage(name, message, isfeed, color)
if not message then
message = name
name = ""
end
isfeed = isfeed or false
--[[
if not tostring(color):find('Color') then
color = nil
end
--]]
if color and #color == 6 then
color = Color(color)
end
message = tostring(message)
--if managers and managers.chat and managers.chat._receives and managers.chat._receivers[1] then
for __, rcvr in pairs(managers.chat._receivers[1]) do
rcvr:receive_message(name or "*", message, color or tweak_data.chat_colors[5])
end
--end
if Network:is_server() and isfeed then
local num_player_slots = BigLobbyGlobals and BigLobbyGlobals:num_player_slots() or 4
for i=2,num_player_slots do
local peer = managers.network:session():peer(i)
if peer then
peer:send("send_chat_message", ChatManager.GAME, name .. ": " .. message)
end
end
end
end
function SydneyHUD:Replenish(peer_id)
local peer = managers.network:session():peer(peer_id)
if peer then
local down = "down"
-- NOTE: Add existence check of _down_count (can be nil when not downed)
if self._down_count[peer_id] and self._down_count[peer_id] > 1 then
down = "downs"
end
-- NOTE: Display 0 instead of nil
local message = peer:name() .. " +" .. tostring(self._down_count[peer_id] or 0) .. " " .. down
local is_feed = self:GetOption("replenished_chat_info_feed")
if self:GetOption("replenished_chat_info") then
self:SendChatMessage("Replenished", message, is_feed, "00ff04")
end
self._down_count[peer_id] = 0
end
end
function SydneyHUD:Down(peer_id, local_peer)
local peer = managers.network:session():peer(peer_id)
if peer then
local warn_down = Global.game_settings.one_down and 1 or 3
if local_peer then
local nine_lives = managers.player:upgrade_value('player', 'additional_lives', 0) or 0
warn_down = warn_down + nine_lives
end
self._down_count[peer_id] = (self._down_count[peer_id] or 0) + 1
local is_feed
if self._down_count[peer_id] == warn_down and self:GetOption("critical_down_warning_chat_info") then
local message = peer:name() .. " was downed " .. tostring(self._down_count[peer_id]) .. " times"
is_feed = self:GetOption("critical_down_warning_chat_info_feed")
self:SendChatMessage("Warning!", message, is_feed, "ff0000")
elseif self:GetOption("down_warning_chat_info") then
local message = peer:name() .. " was downed (" .. tostring(self._down_count[peer_id]) .. "/" .. warn_down .. ")"
is_feed = self:GetOption("down_warning_chat_info_feed")
self:SendChatMessage("Warning", message, is_feed, "ff0000")
end
end
end
function SydneyHUD:Custody(criminal_name, local_peer)
local peer_id = criminal_name
if not local_peer then
for __, data in pairs(managers.criminals._characters) do
if data.token and criminal_name == data.name then
peer_id = data.peer_id
break
end
end
end
local peer = managers.network:session():peer(peer_id)
if peer then
SydneyHUD._down_count[peer_id] = 0
end
end
function SydneyHUD:Peer_id_To_Peer(peer_id)
local session = managers.network:session()
return session and session:peer(peer_id) or nil
end
function SydneyHUD:Peer(input)
local t = type(input)
if t == 'userdata' then
return alive(input) and input:network():peer()
elseif t == 'number' then
return self:Peer_id_To_Peer(input)
elseif t == 'string' then
return self:Peer(managers.criminals:character_peer_id_by_name(input))
end
end
function SydneyHUD:Peer_Info(input)
local peer = self:Peer(input)
return peer and peer:id() or 0
end
function SydneyHUD:GetColor(color, extension)
if not color then
return Color.white
end
extension = extension or ""
return Color(255, self.settings[color .. "_r" .. extension], self.settings[color .. "_g" .. extension], self.settings[color .. "_b" .. extension]) / 255
end
function SydneyHUD:IsOr(string, ...)
for i = 1, select("#", ...) do
if string == select(i, ...) then
return true
end
end
return false
end
function SydneyHUD:DelayCall(name, t, func)
DelayedCalls:Add(name, t, func)
end
function SydneyHUD:Hook(object, func, post_call)
Hooks:PostHook(object, func, "SydneyHUD_" .. func, post_call)
end
function SydneyHUD:PreHook(object, func, pre_call)
Hooks:PreHook(object, func, "SydneyHUD_Pre_" .. func, pre_call)
end
--[[ function SydneyHUD:Unhook(mod, id)
Hooks:RemovePostHook((mod and (mod .. "_") or "BAI_") .. id)
end ]]
function SydneyHUD:EasterEggInit()
self.EasterEgg.FSS.AIReactionTimeTooHigh = (FullSpeedSwarm and (FullSpeedSwarm.settings.task_throughput ~= 60 and Network:is_server() and Global.game_settings.difficulty == "sm_wish")) or
(managers.crime_spree and managers.crime_spree:is_active() and managers.crime_spree:server_spree_level() >= 500 or false)
end
function SydneyHUD:SyncAssaultState(state, override, stealth_broken, no_as_mod)
if Network:is_client() then
return
end
if state then
if not self:IsOr(state, "control", "anticipation", "build") or stealth_broken then
LuaNetworking:SendToPeers("BAI_AssaultState" .. (override and "Override" or ""), state)
end
if not no_as_mod then
LuaNetworking:SendToPeers("AssaultStates_Net", state)
LuaNetworking:SendToPeers("SyncAssaultPhase", state) -- KineticHUD and NobleHUD
end
end
end
function SydneyHUD:Init()
managers.mission:add_global_event_listener("SydneyHUD_OnPeerRemoved", {
"on_peer_removed"
}, callback(self, self, "OnPeerLeft"))
end
function SydneyHUD:OnPeerLeft(peer_id)
if not peer_id then -- Just in case
return
end
self._down_count[peer_id] = nil
end
SydneyHUD:Load()
log(SydneyHUD.info .. "SydneyHUD loaded.")
end