Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions lua/pac3/core/client/base_movable.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,14 @@ local Angle = Angle
local NULL = NULL
local Matrix = Matrix

local default = "0"
if game.SinglePlayer() then default = "1" end
local allow_NL = CreateConVar("pac_sv_nearest_life", default, {FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY}, "Enables nearest_life aimparts and bones, abusable for aimbot-type setups (which would already be possible with CS lua)")
local NL_allow_sampling_anywhere = CreateConVar("pac_sv_nearest_life_allow_sampling_from_parts", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY}, "Restricts nearest_life aimparts and bones search to the player itself to prevent sampling from arbitrary positions\n0=sampling can only start from the player itself")
local allow_NL_bone = CreateConVar("pac_sv_nearest_life_allow_bones", default, {FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY}, "Restricts nearest_life bones, preventing placement on external entities' position")
local NL_allow_target_players = CreateConVar("pac_sv_nearest_life_allow_targeting_players", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY}, "Restricts nearest_life aimparts and bones to forbid targeting players\n0=no target players")
local NL_max_distance = CreateConVar("pac_sv_nearest_life_max_distance", "5000", {FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY}, "Restricts the radius for nearest_life aimparts and bones")

local BUILDER, PART = pac.PartTemplate("base")

PART.ClassName = "base_movable"
Expand Down Expand Up @@ -209,19 +217,22 @@ function PART:CalcAngles(ang, wpos)
end

if pac.StringFind(self.AimPartName, "NEAREST_LIFE_YAW", true, true) then
if not allow_NL:GetBool() then self:SetWarning("nearest_life isn't allowed in this server\npac_sv_nearest_life") return ang or Angle(0,0,0) end
local nearest_ent = get_nearest_ent(self)
if not IsValid(nearest_ent) then return ang or Angle(0,0,0) end
local ang = (nearest_ent:GetPos() - wpos):Angle()
return Angle(0,ang.y,0) + self.Angles
end

if pac.StringFind(self.AimPartName, "NEAREST_LIFE_POS", true, true) then
if not allow_NL:GetBool() then self:SetWarning("nearest_life isn't allowed in this server\npac_sv_nearest_life") return ang or Angle(0,0,0) end
local nearest_ent = get_nearest_ent(self)
if not IsValid(nearest_ent) then return ang or Angle(0,0,0) end
return self.Angles + (nearest_ent:GetPos() - wpos):Angle()
end

if pac.StringFind(self.AimPartName, "NEAREST_LIFE", true, true) then
if not allow_NL:GetBool() then self:SetWarning("nearest_life isn't allowed in this server\npac_sv_nearest_life") return ang or Angle(0,0,0) end
local nearest_ent = get_nearest_ent(self)
if not IsValid(nearest_ent) then return ang or Angle(0,0,0) end
return self.Angles + ( nearest_ent:GetPos() + Vector(0,0,(nearest_ent:WorldSpaceCenter() - nearest_ent:GetPos()).z * 1.5) - wpos):Angle()
Expand Down
15 changes: 9 additions & 6 deletions lua/pac3/core/client/parts/bone.lua
Original file line number Diff line number Diff line change
Expand Up @@ -290,12 +290,12 @@ function PART:GetBonePosition()
if not self.bone_index then return ent:GetPos(), ent:GetAngles() end

local m = ent:GetBoneMatrix(self.bone_index)
if not m then return ent:GetPos(), ent:GetAngles() end

local pos = m:GetTranslation()
local ang = m:GetAngles()

return pos, ang
if m then
return m:GetTranslation(), m:GetAngles()
else
return ent:GetPos(), ent:GetAngles()
end
end

function PART:GetBoneMatrix()
Expand All @@ -306,12 +306,15 @@ BUILDER:Register()

pac.AddHook("OnEntityCreated", "hide_mesh_no_crash", function(ent)
local ply = ent:GetRagdollOwner()

if ply:IsPlayer() and ply.pac_inf_scale then
for i = 0, ply:GetBoneCount() - 1 do
local scale = ply:GetManipulateBoneScale(i)

if scale == inf_scale then
scale = Vector(0,0,0)
scale = vector_origin
end

ply:ManipulateBoneScale(i, scale)
end
end
Expand Down
19 changes: 19 additions & 0 deletions lua/pac3/core/client/parts/camera.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ PART.ClassName = "camera"
PART.Group = 'entity'
PART.Icon = 'icon16/camera.png'

PART.ImplementsDoubleClickSpecified = true

BUILDER:StartStorableVars()
BUILDER:GetSet("EyeAnglesLerp", 1)
BUILDER:GetSet("DrawViewModel", false)
Expand Down Expand Up @@ -75,6 +77,12 @@ function PART:CameraTakePriority(then_view)
self.priority = true
end)
if then_view then
pace.old_ViewAngles = pace.ViewAngles
pace.old_ViewPos = pace.ViewPos

--it should be relative if we use camera follow entity
pace.old_ViewPos_delta = pace.ViewPos - pace.GetViewEntity():GetPos()

timer.Simple(0.2, function() pace.CameraPartSwapView(true) end)
end
end
Expand Down Expand Up @@ -351,6 +359,17 @@ function pac.HandleCameraPart(ply, pos, ang, fov, nearz, farz)
--until we make reversible first person a thing, letting some non-drawable parts think, this is the best solution I could come up with
end

function PART:OnDoubleClickSpecified()
if self ~= pac.active_camera then
self:CameraTakePriority(true)
else
pac.active_camera = nil
self.priority = false
self:RemoveSmallIcon()
pace.CameraPartSwapView()
end
end

function pac.HasRemainingCameraPart()
pac.RebuildCameras()
return table.Count(pac.LocalPlayer.pac_cameras) ~= 0
Expand Down
15 changes: 15 additions & 0 deletions lua/pac3/core/client/parts/clip.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,16 @@ do
function PART:PreOnDraw()
bclip = render_EnableClipping(true)

-- this fixes clip planes lagging behind when parented to a bone on a model part
local owner = self:GetParentOwner()
if owner:IsValid() and not owner.pac_clip_bonessetup and owner.PACPart then
-- in case there are multiple clips on one model part, only the first one needs to call SetupBones
self.pac_clip_owner = owner
owner.pac_clip_bonessetup = true

pac.SetupBones(owner)
end

local pos, ang = LocalToWorld(self.Position + self.PositionOffset, self:CalcAngles(self.Angles + self.AngleOffset), self:GetBonePosition())
local normal = ang:Forward()

Expand All @@ -49,6 +59,11 @@ do
local render_PopCustomClipPlane = render.PopCustomClipPlane

function PART:PostOnDraw()
if self.pac_clip_owner then
self.pac_clip_owner.pac_clip_bonessetup = nil
self.pac_clip_owner = nil
end

render_PopCustomClipPlane()

render_EnableClipping(bclip)
Expand Down
41 changes: 37 additions & 4 deletions lua/pac3/core/client/parts/event.lua
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function PART:fix_event_operator()
end

elseif event_type == "string" then
if self.Operator ~= "find" and self.Operator ~= "find simple" and self.Operator ~= "equal" then
if self.Operator ~= "find" and self.Operator ~= "find simple" and self.Operator ~= "equal" and self.Operator ~= "not equal" then
self.Operator = PART.Events[self.Event].preferred_operator --find simple
self:SetInfo("The operator was automatically changed to work with this event type, which handles strings (text)")
end
Expand Down Expand Up @@ -384,7 +384,6 @@ function PART:SetMultipleTargetParts(str)
end
self.ExtraHermites_Property = "MultipleTargetParts"
end

end

local function get_default(typ)
Expand Down Expand Up @@ -2884,8 +2883,42 @@ PART.OldEvents = {
end
return true
end,
}
},

is_no_draw = {
operator_type = "none",
tutorial = "activates when the current entity is flagged with nodraw",
callback = function(self, ent)
return ent:GetNoDraw()
end,
},

viewer_steamid = {
operator_type = "string", preferred_operator = "equal",
tutorial = "activates when the local player has the steamID specified",
arguments = {{find = "string"}, {include_owner = "boolean"}},
callback = function(self, ent, find, include_owner)
if include_owner then
find = find .. ";" .. self:GetOwner():SteamID()
end

return self:StringOperator(pac.LocalPlayer:SteamID(), find)
end,
nice = function(self, ent, find, include_owner)
local count = #string.Split(find, ";")

local idSumm
if count == 0 or find == "" then
idSumm = (include_owner and "owner id" or "\"\"")
elseif count == 1 then
idSumm = string.format("\"%s\"%s", find, include_owner and " + owner id" or "")
else
idSumm = string.format("1 of %d entries%s", count, include_owner and " + owner id" or "")
end

return string.format("steamid: [%s %s]", self.Operator, idSumm)
end
},
}


Expand Down Expand Up @@ -4732,7 +4765,7 @@ net.Receive("pac_update_healthbars", function(len)
if cached_part then
tbl[i][cached_part.UniqueID] = value
end

end
end
--PrintTable(tbl)
Expand Down
1 change: 0 additions & 1 deletion lua/pac3/core/client/parts/hitscan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ PART.ImplementsDoubleClickSpecified = true
BUILDER:StartStorableVars()
:GetSet("ServerBullets", true, {description = "serverside bullets can do damage and exert a physical impact force"})
:SetPropertyGroup("bullet properties")
:GetSet("BulletImpact", false)
:GetSet("Damage", 1, {editor_onchange = function (self,val) return math.floor(math.Clamp(val,0,268435455)) end})
:GetSet("Force",1000, {editor_onchange = function (self,val) return math.floor(math.Clamp(val,0,65535)) end})
:GetSet("AffectSelf", false, {description = "whether to allow to damage yourself"})
Expand Down
6 changes: 6 additions & 0 deletions lua/pac3/core/client/parts/model/entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,12 @@ function PART:GetNiceName()
class_name = ent:GetClass()
end

if str ~= "" then
return (str and str:gsub("%d", "") or "error") .. " " .. class_name .. " model"
elseif IsValid(self:GetOwner()) then
str = "[" .. string.GetFileFromFilename(string.StripExtension(self:GetOwner():GetModel())) .. "] "
return str .. class_name .. " model"
end
return (str and str:gsub("%d", "") or "error") .. " " .. class_name .. " model"
end

Expand Down
8 changes: 8 additions & 0 deletions lua/pac3/core/server/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,14 @@ CreateConVar("pac_allow_blood_color", "1", {FCVAR_NOTIFY}, "Allow to use custom
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")

local default = "0"
if game.SinglePlayer() then default = "1" end
CreateConVar("pac_sv_nearest_life", default, {FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY}, "Enables nearest_life aimparts and bones, abusable for aimbot-type setups (which would already be possible with CS lua)")
CreateConVar("pac_sv_nearest_life_allow_sampling_from_parts", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY}, "Restricts nearest_life aimparts and bones search to the player itself to prevent sampling from arbitrary positions\n0=sampling can only start from the player itself")
CreateConVar("pac_sv_nearest_life_allow_bones", default, {FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY}, "Restricts nearest_life bones, preventing placement on external entities' position")
CreateConVar("pac_sv_nearest_life_allow_targeting_players", "1", {FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY}, "Restricts nearest_life aimparts and bones to forbid targeting players\n0=no target players")
CreateConVar("pac_sv_nearest_life_max_distance", "5000", {FCVAR_ARCHIVE, FCVAR_REPLICATED, FCVAR_NOTIFY}, "Restricts the radius for nearest_life aimparts and bones")

include("util.lua")

include("pac3/core/shared/init.lua")
Expand Down
1 change: 1 addition & 0 deletions lua/pac3/core/shared/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ CreateConVar("pac_sv_draw_distance", 0, CLIENT and FCVAR_REPLICATED or bit.bor(F
do
local tohash = {
-- Crash
'eye_muzzle.pcf', -- E.Y.E: Divine Cybermancy effect that crashes gmod. https://github.com/CapsAdmin/pac3/issues/1410
'weapon_unusual_isotope.pcf',

-- Invalid
Expand Down
11 changes: 11 additions & 0 deletions lua/pac3/editor/client/animation_timeline.lua
Original file line number Diff line number Diff line change
Expand Up @@ -334,14 +334,25 @@ function timeline.Open(part)
timeline.Stop()
end

local editing_part
pac.AddHook("pace_OnPartSelected", "pac3_timeline", function(part)
if part.ClassName == "timeline_dummy_bone" then return end
if part.ClassName == "custom_animation" then
if timeline.editing then
timeline.Close()
end
timeline.Open(part)
editing_part = part
elseif timeline.editing then
if editing_part then
local part2 = editing_part
if part2.AnimationType ~= "gesture" and not part2:IsHidden() then
timer.Simple(0, function()
part2:OnHide()
part2:OnShow()
end)
end
end
timeline.Close()
end
end)
Expand Down
2 changes: 1 addition & 1 deletion lua/pac3/editor/client/asset_browser.lua
Original file line number Diff line number Diff line change
Expand Up @@ -942,7 +942,7 @@ function pace.AssetBrowser(callback, browse_types_str, part_key)

play:SetImage("icon16/control_stop.png")

local snd = CreateSound(pac.LocalPlayer, sound)
local snd = CreateSound(LocalPlayer(), sound)
snd:Play()
pace.asset_browser_snd = snd

Expand Down
1 change: 1 addition & 0 deletions lua/pac3/editor/client/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ local showInEditor = CreateConVar("pac_show_in_editor", "1", {FCVAR_ARCHIVE}, "S
pace.pac_show_uniqueid = CreateConVar("pac_show_uniqueid", "0", {FCVAR_ARCHIVE}, "Show uniqueids of parts inside editor")

function pace.OpenEditor()
if not pac.LocalPlayer then pac.LocalPlayer = LocalPlayer() end
pace.CloseEditor()

if hook.Run("PrePACEditorOpen", pac.LocalPlayer) == false then return end
Expand Down
2 changes: 2 additions & 0 deletions lua/pac3/editor/client/panels/editor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ function PANEL:Init()

if remember_width:GetBool() then
self.init_w = math.max(self:GetCookieNumber("width"), 200)
else
self.init_w = 280
end
if remember_divider:GetBool() then
pace.vertical_div_height = self:GetCookieNumber("y_divider")
Expand Down
33 changes: 32 additions & 1 deletion lua/pac3/editor/client/panels/extra_properties.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,10 @@ do -- script proxy
pnl.Paint = function(...)
if not self:IsValid() then pnl:Remove() return end
local x, y = self:LocalToScreen()
y = math.Clamp(y,0,ScrH() - self:GetTall())
local _,prop_y = pace.properties:LocalToScreen(0,0)
local overflow = y < prop_y or y > ScrH() - self:GetTall()
y = math.Clamp(y,prop_y,ScrH() - self:GetTall())

pnl:SetPos(x + 5 + inset_x, y)
surface.SetFont(pnl:GetFont())
local w = surface.GetTextSize(pnl:GetText()) + 6
Expand All @@ -1271,6 +1274,34 @@ do -- script proxy
old(...)
end

local skincolor = self:GetSkin().Colours.Category.Line.Button
local col = Color(skincolor.r,skincolor.g,skincolor.b, 255)

pac.AddHook('PostRenderVGUI', hookID .. "2", function(code)
if not IsValid(self) or not IsValid(pnl) then pac.RemoveHook('Think', hookID .. "2") return end
local _,prop_y = pace.properties:LocalToScreen(0,0)
local x, y = self:LocalToScreen()
local overflow = y < prop_y or y > ScrH() - self:GetTall()
if overflow then
local str = ""
if y > ScrH() then
str = "↓↓"
else
str = "↑↑"
end
local container = self:GetParent()
y = math.Clamp(y,prop_y,ScrH() - self:GetTall())
surface.SetFont(pnl:GetFont())
local w2 = surface.GetTextSize(str .. " " .. self.CurrentKey .. " " .. str)

surface.SetDrawColor(col)
surface.DrawRect(x - w2, y, w2, pnl:GetTall())
surface.SetTextColor(self:GetSkin().Colours.Category.Line.Text)
surface.SetTextPos(x - w2, y)
surface.DrawText(str .. " " .. self.CurrentKey .. " " .. str)
end
end)

pace.BusyWithProperties = pnl
end

Expand Down
21 changes: 20 additions & 1 deletion lua/pac3/editor/client/panels/properties.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,26 @@ do -- base editable
mat = string.gsub(mat, "^materials/", "")
local mat_no_ext = string.StripExtension(mat)

if string.find(mat, "%[%d+,%d+%]") then --find the bracket notation
if string.sub(mat, 1, 7) == "folder:" then
local path = string.sub(mat, 8, #mat)
local menu3, pnl2 = menu2:AddSubMenu(string.GetFileFromFilename(path), function()
end)
pnl2:SetImage("icon16/folder.png") pnl2:SetTooltip(mat)

local files = get_files_recursively(nil, path, {"vmt"})

for i,file in ipairs(files) do
local mat_no_ext = string.StripExtension(string.sub(file,11,#file)) --"materials/"
menu3:AddOption(mat_no_ext, function()
self:SetValue(mat_no_ext)
if self.CurrentKey == "Material" then
pace.current_part:SetMaterial(mat_no_ext)
elseif self.CurrentKey == "SpritePath" then
pace.current_part:SetSpritePath(mat_no_ext)
end
end):SetMaterial(mat_no_ext)
end
elseif string.find(mat, "%[%d+,%d+%]") then --find the bracket notation
mat_no_ext = string.gsub(mat_no_ext, "%[%d+,%d+%]", "")
pace.AddSubmenuWithBracketExpansion(menu2, function(str)
str = str or ""
Expand Down
Loading
Loading