This commit is contained in:
lifestorm
2024-08-04 22:55:00 +03:00
parent 0e770b2b49
commit 94063e4369
7342 changed files with 1718932 additions and 14 deletions

View File

@@ -0,0 +1,69 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
pac.EffectsBlackList =
{
"frozen_steam",
"portal_rift_01",
"explosion_silo",
"citadel_shockwave_06",
"citadel_shockwave",
"choreo_launch_rocket_start",
"choreo_launch_rocket_jet",
}
if not pac_loaded_particle_effects then
pac_loaded_particle_effects = {}
local files = file.Find("particles/*.pcf", "GAME")
for key, file_name in pairs(files) do
if not pac_loaded_particle_effects[file_name] and not pac.BlacklistedParticleSystems[file_name:lower()] then
game.AddParticles("particles/" .. file_name)
end
pac_loaded_particle_effects[file_name] = true
end
pac.Message('Loaded total ', #files, ' particle systems')
end
util.AddNetworkString("pac_effect_precached")
util.AddNetworkString("pac_request_precache")
function pac.PrecacheEffect(name)
PrecacheParticleSystem(name)
net.Start("pac_effect_precached")
net.WriteString(name)
net.Broadcast()
end
local queue = {}
net.Receive("pac_request_precache", function(len, pl)
local name = net.ReadString()
if table.HasValue(pac.EffectsBlackList, name) then return end
-- Each player gets a 50 length queue
local plqueue = queue[pl]
if plqueue then
if #plqueue<50 then plqueue[#plqueue+1] = name end
else
plqueue = {name}
queue[pl] = plqueue
local function processQueue()
if #plqueue == 0 then
queue[pl] = nil
else
timer.Simple(0.5, processQueue)
pac.PrecacheEffect(table.remove(plqueue,1))
end
end
processQueue()
end
end)

View File

@@ -0,0 +1,87 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
util.AddNetworkString("pac_proxy")
util.AddNetworkString("pac_event")
-- event
concommand.Add("pac_event", function(ply, _, args)
if not args[1] then return end
local event = args[1]
local extra = tonumber(args[2]) or 0
if extra == 2 or args[2] == "toggle" then
ply.pac_event_toggles = ply.pac_event_toggles or {}
ply.pac_event_toggles[event] = not ply.pac_event_toggles[event]
extra = ply.pac_event_toggles[event] and 1 or 0
end
net.Start("pac_event", true)
net.WriteEntity(ply)
net.WriteString(event)
net.WriteInt(extra, 8)
net.Broadcast()
end)
concommand.Add("+pac_event", function(ply, _, args)
if not args[1] then return end
if args[2] == "2" or args[2] == "toggle" then
local event = args[1]
ply.pac_event_toggles = ply.pac_event_toggles or {}
ply.pac_event_toggles[event] = true
net.Start("pac_event", true)
net.WriteEntity(ply)
net.WriteString(event)
net.WriteInt(1, 8)
net.Broadcast()
else
net.Start("pac_event", true)
net.WriteEntity(ply)
net.WriteString(args[1] .. "_on")
net.Broadcast()
end
end)
concommand.Add("-pac_event", function(ply, _, args)
if not args[1] then return end
if args[2] == "2" or args[2] == "toggle" then
local event = args[1]
ply.pac_event_toggles = ply.pac_event_toggles or {}
ply.pac_event_toggles[event] = false
net.Start("pac_event", true)
net.WriteEntity(ply)
net.WriteString(event)
net.WriteInt(0, 8)
net.Broadcast()
else
net.Start("pac_event", true)
net.WriteEntity(ply)
net.WriteString(args[1] .. "_off")
net.Broadcast()
end
end)
-- proxy
concommand.Add("pac_proxy", function(ply, _, args)
net.Start("pac_proxy", true)
net.WriteEntity(ply)
net.WriteString(args[1])
net.WriteFloat(tonumber(args[2]) or 0)
net.WriteFloat(tonumber(args[3]) or 0)
net.WriteFloat(tonumber(args[4]) or 0)
net.Broadcast()
end)

View File

@@ -0,0 +1,38 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
hook.Add("InitPostEntity","pac_get_sky_camera",function()
local sky_camera = ents.FindByClass("sky_camera")[1]
if sky_camera then
local nwVarName = "pac_in_skybox"
local in_skybox = {}
timer.Create("pac_in_skybox", 0.5, 0, function()
if not IsValid(sky_camera) then
sky_camera = ents.FindByClass("sky_camera")[1]
end
local new_in_skybox = {}
for _, ent in ipairs(ents.FindInPVS(sky_camera:GetPos())) do
if not in_skybox[ent] then
ent:SetNW2Bool(nwVarName, true)
end
new_in_skybox[ent] = true
end
for ent in pairs(in_skybox) do
if not new_in_skybox[ent] and ent:IsValid() then
ent:SetNW2Bool(nwVarName, false)
end
end
in_skybox = new_in_skybox
end)
end
end)

View File

@@ -0,0 +1,33 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
pac = pac or {}
pac.Parts = pac.Parts or {}
pac.Errors = {}
pac.resource = include("pac3/libraries/resource.lua")
CreateConVar("has_pac3", "1", {FCVAR_NOTIFY})
CreateConVar("pac_allow_blood_color", "1", {FCVAR_NOTIFY}, "Allow to use custom blood color")
CreateConVar('pac_allow_mdl', '1', CLIENT and {FCVAR_REPLICATED} or {FCVAR_ARCHIVE, FCVAR_REPLICATED}, 'Allow to use custom MDLs')
CreateConVar('pac_allow_mdl_entity', '1', CLIENT and {FCVAR_REPLICATED} or {FCVAR_ARCHIVE, FCVAR_REPLICATED}, 'Allow to use custom MDLs as Entity')
include("util.lua")
include("pac3/core/shared/init.lua")
include("effects.lua")
include("event.lua")
include("net_messages.lua")
include("test_suite_backdoor.lua")
include("in_skybox.lua")
hook.Run("pac_Initialized")

View File

@@ -0,0 +1,41 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
util.AddNetworkString("pac.AllowPlayerButtons")
util.AddNetworkString("pac.BroadcastPlayerButton")
do -- button event
net.Receive("pac.AllowPlayerButtons", function(length, client)
local key = net.ReadUInt(8)
client.pac_broadcast_buttons = client.pac_broadcast_buttons or {}
client.pac_broadcast_buttons[key] = true
end)
local function broadcast_key(ply, key, down)
if not ply.pac_broadcast_buttons then return end
if not ply.pac_broadcast_buttons[key] then return end
net.Start("pac.BroadcastPlayerButton")
net.WriteEntity(ply)
net.WriteUInt(key, 8)
net.WriteBool(down)
net.Broadcast()
end
pac.AddHook("PlayerButtonDown", "event", function(ply, key)
broadcast_key(ply, key, true)
end)
pac.AddHook("PlayerButtonUp", "event", function(ply, key)
broadcast_key(ply, key, false)
end)
end

View File

@@ -0,0 +1,37 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
-- this is for the test suite, it is technically a lua run backdoor
-- the test suite is a utility for the pac developers to ensure that pac works and don't break
-- after making changes to it
util.AddNetworkString("pac3_test_suite_backdoor_receive_results")
util.AddNetworkString("pac3_test_suite_backdoor")
net.Receive("pac3_test_suite_backdoor", function(len, ply)
-- needs to be enabled through lua first, eg lua_run pac.test_suite_backdoor_enabled = true
if not pac.test_suite_backdoor_enabled then return end
-- need to be at least super admin
if not ply:IsSuperAdmin() then return end
local id = net.ReadString()
local lua_code = net.ReadString()
local func = CompileString(lua_code, "pac3_test_suite_backdoor")
local res = {func()}
net.Start("pac3_test_suite_backdoor_receive_results")
net.WriteString(id)
net.WriteTable(res)
net.Send(ply)
end)

View File

@@ -0,0 +1,109 @@
--[[
| This file was obtained through the combined efforts
| of Madbluntz & Plymouth Antiquarian Society.
|
| Credits: lifestorm, Gregory Wayne Rossel JR.,
| Maloy, DrPepper10 @ RIP, Atle!
|
| Visit for more: https://plymouth.thetwilightzone.ru/
--]]
local CurTime = CurTime
local math_Clamp = math.Clamp
function pac.dprint(fmt, ...)
if pac.debug then
MsgN("\n")
MsgN(">>>PAC3>>>")
MsgN(fmt:format(...))
if pac.debug_trace then
MsgN("==TRACE==")
debug.Trace()
MsgN("==TRACE==")
end
MsgN("<<<PAC3<<<")
MsgN("\n")
end
end
function pac.CallHook(str, ...)
return hook.Call("pac_" .. str, GAMEMODE, ...)
end
function pac.AddHook(str, id, func, priority)
id = "pac_" .. id
if not DLib and not ULib then
priority = nil
end
hook.Add(str, id, function(...)
local status, a, b, c, d, e, f, g = pcall(func, ...)
if not status then
pac.Message('Error on hook ' .. str .. ' (' .. id .. ')! ', a)
return
end
return a, b, c, d, e, f, g
end, priority)
end
function pac.RemoveHook(str, id)
id = "pac_" .. id
hook.Remove(str, id)
end
function pac.RatelimitAlert( ply, id, message )
if not ply.pac_ratelimit_alerts then
ply.pac_ratelimit_alerts = {}
end
if CurTime() >= ( ply.pac_ratelimit_alerts[id] or 0 ) then
ply.pac_ratelimit_alerts[id] = CurTime() + 3
if isstring(message) then
pac.Message(message)
end
if istable(message) then
pac.Message(unpack(message))
end
end
end
local RatelimitAlert = pac.RatelimitAlert
function pac.RatelimitPlayer( ply, name, buffer, refill, message )
local ratelimitName = "pac_ratelimit_" .. name
local checkName = "pac_ratelimit_check_" .. name
if not ply[ratelimitName] then ply[ratelimitName] = buffer end
local curTime = CurTime()
if not ply[checkName] then ply[checkName] = curTime end
local dripSize = curTime - ply[checkName]
ply[checkName] = curTime
local drip = dripSize / refill
local newVal = ply[ratelimitName] + drip
ply[ratelimitName] = math_Clamp(newVal, 0, buffer)
if ply[ratelimitName] >= 1 then
ply[ratelimitName] = ply[ratelimitName] - 1
return true
else
if message then
RatelimitAlert(ply, name, message)
end
return false
end
end
function pac.GetRateLimitPlayerBuffer( ply, name )
local ratelimitName = "pac_ratelimit_" .. name
return ply[ratelimitName] or 0
end