This commit is contained in:
lifestorm
2024-08-04 23:54:45 +03:00
parent 0e770b2b49
commit df294d03aa
7526 changed files with 4011945 additions and 15 deletions

View File

@@ -0,0 +1,95 @@
--[[
| 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 PLUGIN = PLUGIN
local COLOR_MODIFY = {
["$pp_colour_addr"] = 0,
["$pp_colour_addg"] = 0,
["$pp_colour_addb"] = 0,
["$pp_colour_brightness"] = 0,
["$pp_colour_contrast"] = 1,
["$pp_colour_colour"] = 0,
["$pp_colour_mulr"] = 0,
["$pp_colour_mulg"] = 0,
["$pp_colour_mulb"] = 0
}
PLUGIN.currentType = ix.inebriation.types.SOBER
function PLUGIN:HUDPaint()
if (IsValid(LocalPlayer())) then
if (PLUGIN.textAlpha and PLUGIN.textAlpha > 0) then
draw.SimpleText(
PLUGIN.currentType.description or "",
"WNBleedingTextBold",
ScrW() * 0.5,
ScrH() - SScaleMin(135 / 3),
Color(255, 78, 69, PLUGIN.textAlpha or 0),
TEXT_ALIGN_CENTER
)
end
end
end
local drunkColor = Color(69, 255, 69)
function PLUGIN:PopulateCharacterInfo(client, character, tooltip)
local inebriation = client:GetInebriation()
if (inebriation < 10) then return end
local _type = ix.inebriation:GetType(inebriation)
if (client:GetInebriation() > 40) then
local drunkText = tooltip:AddRowAfter("name", "drunk")
drunkText:SetBackgroundColor(drunkColor)
drunkText:SetText(..string.lower(_type.name).." gibi görünüyor.")
drunkText:SizeToContents()
end
end
function PLUGIN:Think()
local inebriation = LocalPlayer():GetInebriation()
if (inebriation < 10) then return end
local lerpTo = 0
local _type = ix.inebriation:GetType(inebriation)
if (_type != PLUGIN.currentType) then
PLUGIN.currentType = _type
PLUGIN.textAlpha = 0
PLUGIN.changeTime = SysTime()
PLUGIN.animateTime = SysTime()
PLUGIN.textShouldFadeOut = true
elseif (SysTime() - PLUGIN.changeTime > 15) then
lerpTo = 0
if (PLUGIN.textShouldFadeOut) then
PLUGIN.textShouldFadeOut = false
PLUGIN.animateTime = SysTime()
end
else
lerpTo = 255
end
PLUGIN.textAlpha = Lerp((SysTime() - PLUGIN.animateTime) / 0.9, PLUGIN.textAlpha, lerpTo)
end
function PLUGIN:RenderScreenspaceEffects()
local _ineb = LocalPlayer():GetInebriation()
if (_ineb < 10) then return end
local percent = math.Clamp(_ineb / 100, 0, 1)
local cMul = 1 - percent
COLOR_MODIFY["$pp_colour_mulr"] = cMul
COLOR_MODIFY["$pp_colour_mulg"] = cMul
COLOR_MODIFY["$pp_colour_mulb"] = cMul
DrawColorModify(COLOR_MODIFY)
DrawBloom(0.5, percent * 0.5, 9, 7, 5, 1, 1, 1, 1)
DrawMaterialOverlay("effects/water_warp01", percent * 0.05)
DrawBokehDOF(3 * percent, 1, 12 * percent)
end

View File

@@ -0,0 +1,185 @@
--[[
| 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 PLUGIN = PLUGIN
PLUGIN.name = "Inebriation"
PLUGIN.author = "M!NT"
PLUGIN.description = "Adds a more immersive system for drinking alchohol."
ix.char.RegisterVar("inebriation", {
field = "inebriation",
fieldType = ix.type.number,
default = 0,
bNoDisplay = true
})
CAMI.RegisterPrivilege({
Name = "Helix - Inebriation Control",
MinAccess = "admin"
})
ix.command.Add("SetInebriation", {
description = "Set how drunk a character is (0-100).",
arguments = {
ix.type.character,
ix.type.number
},
privilege = "Inebriation Control",
OnRun = function(self, client, character, inebriationPercent)
if (inebriationPercent < 0 or inebriationPercent > 100) then
return "Invalid percentage."
end
if (!ix.inebriation.allowedFactions[character:GetFaction()]) then
return "Faction not allowed to be drunk."
end
character:GetPlayer():SetNetVar("inebriation", inebriationPercent)
character:SetInebriation(inebriationPercent)
end
})
ix.config.Add("inebriationDecay", 0.2, "How much inebriation decays per interval.", nil, {
data = {min = 0, max = 5, decimals = 3}
})
ix.inebriation = {}
ix.inebriation.types = {
["SOBER"] = {
name = "Ayık",
description = "Tamamen ayıksın.",
threshold = 0
},
["SLIGHTLY_DRUNK"] = {
name = "Hafif sarhoş",
description = "Biraz sarhoş hissediyorsun.",
threshold = 10
},
["DRUNK"] = {
name = "Sarhoş",
description = "Kendini sarhoş hissediyorsun.",
threshold = 40
},
["VERY_DRUNK"] = {
name = "Baya sarhoş",
description = "Kendini çok sarhoş hissediyorsun.",
threshold = 70
},
["WASTED"] = {
name = "Baştan aşağı sarhoş",
description = "Baştan aşağı sarhoş durumdasın.",
threshold = 90
}
}
ix.inebriation.allowedFactions = {
FACTION_ADMIN,
FACTION_BMDFLAGSYSTEM,
FACTION_CITIZEN,
FACTION_CP,
FACTION_MOE,
FACTION_MCP,
FACTION_MEDICAL,
FACTION_RESISTANCE,
FACTION_WORKERS
}
ix.inebriation.grades = {
["LOW"] = {
appendText = "Bu düşük kaliteli bir içecektir.",
damage = 15
},
["MEDIUM"] = {
appendText = "Bu orta kaliteli bir içecektir.",
damage = 5
},
["HIGH"] = {
appendText = "Bu yüksek kaliteli bir içecektir.",
damage = 0
}
}
function ix.inebriation:GetType(inebriation)
if (inebriation < 10) then
return self.types.SOBER
elseif (inebriation < 40) then
return self.types.SLIGHTLY_DRUNK
elseif (inebriation < 70) then
return self.types.DRUNK
elseif (inebriation < 90) then
return self.types.VERY_DRUNK
else
return self.types.WASTED
end
end
do
local PLAYER = FindMetaTable("Player")
function PLAYER:GetInebriation()
return self:GetNetVar("inebriation", 0)
end
function PLAYER:IsDrunk()
return self:GetInebriation() > 39
end
end
-- unreliable
function PLUGIN:SetupMove(ply, mv, cmd)
if (ply:GetNetVar("inebriation", 0) < 10) then
return
end
if (ply:GetMoveType() == MOVETYPE_FLY) then
return
end
local isWalking = cmd:KeyDown(IN_FORWARD) or cmd:KeyDown(IN_BACK) or cmd:KeyDown(IN_MOVELEFT) or cmd:KeyDown(IN_MOVERIGHT)
local isRunning = cmd:KeyDown(IN_SPEED) or cmd:KeyDown(IN_RUN)
local fElastic = math.ease.InOutElastic(math.abs(math.sin(CurTime() / 6)), 2, 3)
local fElastic2 = math.ease.InOutElastic(math.abs(math.sin(CurTime() / 4)), 2, 4)
local fSin = math.sin(CurTime() / fElastic)
local ineb = ply:GetNetVar("inebriation", 0) / 100
local maxReduce = 0
local newSpeed = 0
local inBack = cmd:KeyDown(IN_BACK) and -1 or 1
if (isWalking and !isRunning) then
maxReduce = ply:GetWalkSpeed() * 0.6 * ineb
newSpeed = (ply:GetWalkSpeed() - maxReduce) + (maxReduce * fSin)
elseif (isRunning) then
maxReduce = ply:GetRunSpeed() * 0.6 * ineb
newSpeed = (ply:GetRunSpeed() - maxReduce) + (maxReduce * fSin)
end
mv:SetForwardSpeed(inBack * newSpeed)
cmd:SetForwardMove(inBack * newSpeed)
if (isWalking or isRunning) then
local fCos = math.cos(CurTime() / math.Clamp(fElastic2, 1, 4))
local sideSpeed = cmd:GetSideMove()
if (sideSpeed == 0) then
-- need to give them some side speed anyways -_-
sideSpeed = (fCos < 0 and -1 * ply:GetWalkSpeed() or ply:GetWalkSpeed()) * ineb
end
local sideStumble = sideSpeed + (fCos * 100 * ineb)
if (math.abs(sideStumble) > 30) then
mv:SetSideSpeed(sideStumble)
cmd:SetSideMove(sideStumble)
end
end
end
ix.util.Include("cl_plugin.lua")
ix.util.Include("sv_plugin.lua")

View File

@@ -0,0 +1,66 @@
--[[
| 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 PLUGIN = PLUGIN
function PLUGIN:PlayerLoadedCharacter(client, character)
if (!ix.inebriation.allowedFactions[character:GetFaction()]) then
client:SetNetVar("inebriation", 0)
return
end
client:SetNetVar("inebriation", character:GetInebriation() or 0)
local uniqueID = "ixInebriateTracker "..client:SteamID64()
timer.Create(uniqueID, 10, 0, function()
if (IsValid(client)) then
local iPercent = client:GetNetVar("inebriation", 0)
if (client:GetNetVar("inebriation", 0) > 0) then
local toDecrement = math.Clamp(iPercent - ix.config.Get("inebriationDecay", 10), 0, 100)
client:SetNetVar("inebriation", toDecrement)
character:SetInebriation(toDecrement)
local isRunning = client:KeyDown(IN_SPEED) or client:KeyDown(IN_RUN)
if (client.GetRagdolled and client:GetRagdolled()) then
return
end
local gotTrolled
if (client:IsDrunk() and toDecrement > math.random(0, 200) and isRunning) then
-- troll
client:SetRagdolled(true, 3)
if (ix.autochat) then
ix.chat.Send(client, "autochat_message", "", false, ix.autochat:GetRecievers(client), {
autochatType = "DRUNK_FALL_OVER"
})
end
gotTrolled = true
end
if (!gotTrolled and client:IsDrunk() and toDecrement > math.random(0, 2500)) then
if (client:GetNetVar("actEnterAngle")) then
-- they're in some kind of act sequence currently.
return
end
if (ix.autochat) then
ix.chat.Send(client, "autochat_message", "", false, ix.autochat:GetRecievers(client), {
autochatType = "DRUNK_FALL_OVER"
})
end
client:SetRagdolled(true, 30)
end
end
else
timer.Remove(uniqueID)
end
end)
end