Skip to content
Merged
5 changes: 3 additions & 2 deletions lua/pac3/core/client/parts/model.lua
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@

:SetPropertyGroup("orientation")
:GetSet("Size", 1, {editor_sensitivity = 0.25})
:GetSet("Scale", Vector(1,1,1))

Check warning on line 51 in lua/pac3/core/client/parts/model.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma

Check warning on line 51 in lua/pac3/core/client/parts/model.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma
:GetSet("BoneMerge", false)
:GetSet("LegacyTransform", false)

Expand Down Expand Up @@ -800,10 +800,11 @@
StandingHullHeight = self.StandingHullHeight,
CrouchingHullHeight = self.CrouchingHullHeight,
HullWidth = self.HullWidth,
OverrideStepSize = self.OverrideStepSize,
OverrideView = self.OverrideView,
StepSize = self.StepSize,
StandingViewOffset = self.StandingViewOffset,
CrouchingViewOffset = self.CrouchingViewOffset,
OverrideStepAndView = self.OverrideStepAndView
CrouchingViewOffset = self.CrouchingViewOffset
})

if self.Size == 1 and self.Scale == vec_one then
Expand Down
29 changes: 22 additions & 7 deletions lua/pac3/core/client/parts/model/entity.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@

PART.FriendlyName = "entity"
PART.ClassName = "entity2"
PART.Category = "entity"

Check warning on line 9 in lua/pac3/core/client/parts/model/entity.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
PART.ManualDraw = true
PART.HandleModifiersManually = true
PART.Icon = 'icon16/brick.png'

Check warning on line 12 in lua/pac3/core/client/parts/model/entity.lua

View workflow job for this annotation

GitHub Actions / lint

"Syntax inconsistency"

Inconsistent use of 'single quoted strings' and 'double quoted strings'
PART.Group = "entity"
PART.is_entity_part = true

Expand All @@ -22,13 +22,15 @@
:GetSet("NoDraw", false)
:GetSet("DrawShadow", true)
:GetSet("InverseKinematics", true)

:SetPropertyGroup("hull")
:GetSet("StandingHullHeight", 72, {editor_panel = "hull"})
:GetSet("CrouchingHullHeight", 36, {editor_panel = "hull", crouch = true})
:GetSet("HullWidth", 32, {editor_panel = "hull"})
:GetSet("OverrideStepAndView", false, {description = "When changing size, pac scales the step size and view offsets together. This overrides that."})
:SetPropertyGroup("step size and view offset")
:GetSet("OverrideStepAndView", false, {hidden = true}) --legacy property, now split in two
:GetSet("OverrideStepSize", false, {description = "When changing size, pac scales the step size. This overrides that."})
:GetSet("StepSize", 18, {description = "Height that you can step up or down without jumping. Slightly tricky and may create view transition issues."})
:GetSet("OverrideView", false, {description = "When changing size, pac scales the view offsets. This overrides that."})
:GetSet("StandingViewOffset", 64, {description = "Eye height when standing"})
:GetSet("CrouchingViewOffset", 28, {description = "Eye height when crouching"})
:EndStorableVars()
Expand Down Expand Up @@ -62,6 +64,23 @@
self.HullWidth = val
self:ApplyMatrix()
end
function PART:SetOverrideView(b)
self.OverrideView = b
self:ApplyMatrix()
end
function PART:SetOverrideStepSize(b)
self.OverrideStepSize = b
self:ApplyMatrix()
end

--backward compatibility
function PART:SetOverrideStepAndView(b)
if b == true then
self:SetOverrideStepSize(true)
self:SetOverrideView(true)
end
end

function PART:SetStandingViewOffset(val)
self.StandingViewOffset = val
self:ApplyMatrix()
Expand All @@ -74,10 +93,6 @@
self.StepSize = val
self:ApplyMatrix()
end
function PART:SetOverrideStepAndView(b)
self.OverrideStepAndView = b
self:ApplyMatrix()
end

function PART:GetNiceName()
local str = pac.PrettifyName(("/" .. self:GetModel()):match(".+/(.-)%.")) or self:GetModel()
Expand Down Expand Up @@ -201,7 +216,7 @@

if not (self.old_model == self:GetModel()) or
(pac.LocalHands:IsValid() and ent == pac.LocalHands
and not (self.real_model == pac.LocalHands:GetModel())) then

Check warning on line 219 in lua/pac3/core/client/parts/model/entity.lua

View workflow job for this annotation

GitHub Actions / lint

"Unnecessary negation"

Silly negation. Use '~='
self.old_model = self:GetModel()
self:SetModel(self:GetModel())
end
Expand Down Expand Up @@ -277,4 +292,4 @@
end
end

BUILDER:Register()
BUILDER:Register()
59 changes: 37 additions & 22 deletions lua/pac3/core/shared/entity_mutators/size.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,25 @@

function MUTATOR:WriteArguments(multiplier, other)
net.WriteFloat(multiplier)
if other and (other.StandingHullHeight ~= nil and other.CrouchingHullHeight ~= nil and other.HullWidth ~= nil and other.StandingHullHeight ~= nil and other.StepSize ~= nil and other.StandingViewOffset ~= nil and other.CrouchingViewOffset ~= nil) then
if other then
net.WriteBool(true)
net.WriteFloat(other.StandingHullHeight)
net.WriteFloat(other.CrouchingHullHeight)
net.WriteFloat(other.HullWidth)
if other.OverrideStepAndView and (allow_step:GetBool() or allow_viewoffset:GetBool()) then
net.WriteBool(true)
net.WriteFloat(other.StepSize)
net.WriteFloat(other.StandingViewOffset)
net.WriteFloat(other.CrouchingViewOffset)
if allow_step:GetBool() then
if other.OverrideStepSize ~= nil and other.StepSize ~= nil then
net.WriteBool(other.OverrideStepSize)
net.WriteFloat(other.StepSize)
end
else
net.WriteBool(false)
end
if allow_viewoffset:GetBool() then
if other.OverrideView ~= nil and other.StandingViewOffset ~= nil and other.CrouchingViewOffset ~= nil then
net.WriteBool(other.OverrideView)
net.WriteFloat(other.StandingViewOffset)
net.WriteFloat(other.CrouchingViewOffset)
end
else
net.WriteBool(false)
end
Expand Down Expand Up @@ -48,9 +57,12 @@
other.StandingHullHeight = net.ReadFloat()
other.CrouchingHullHeight = net.ReadFloat()
other.HullWidth = net.ReadFloat()
other.OverrideStepAndView = net.ReadBool()
if other.OverrideStepAndView then
other.OverrideStepSize = net.ReadBool()
if allow_step:GetBool() then
other.StepSize = net.ReadFloat()
end
other.OverrideView = net.ReadBool()
if allow_viewoffset:GetBool() then
other.StandingViewOffset = net.ReadFloat()
other.CrouchingViewOffset = net.ReadFloat()
end
Expand Down Expand Up @@ -79,7 +91,7 @@
local functions = {
"ViewOffset",
"ViewOffsetDucked",
"StepSize",
"StepSize"
}

function MUTATOR:Mutate(multiplier, other, hidden_state)
Expand Down Expand Up @@ -131,26 +143,29 @@
ent:SetHull(smin, smax)
ent:SetHullDuck(cmin, cmax)

if other.OverrideStepAndView then
if ent.SetStepSize and allow_step:GetBool() then
ent:SetStepSize(math.max(other.StepSize,0))
if other.OverrideStepSize then
local SSize = other.StepSize
if ent.SetStepSize then
ent:SetStepSize(math.max(SSize,0))

Check warning on line 149 in lua/pac3/core/shared/entity_mutators/size.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma
end
end
if other.OverrideView then
local soffset = other.StandingViewOffset
local coffset = other.CrouchingViewOffset
if ent.SetViewOffset then
ent:SetViewOffset(Vector(0,0,soffset))

Check warning on line 156 in lua/pac3/core/shared/entity_mutators/size.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma

Check warning on line 156 in lua/pac3/core/shared/entity_mutators/size.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma
end
if allow_viewoffset:GetBool() then
local soffset = other.StandingViewOffset
if ent.SetViewOffset then
ent:SetViewOffset(Vector(0,0,soffset))
end
local coffset = other.CrouchingViewOffset
if ent.SetViewOffsetDucked then
ent:SetViewOffsetDucked(Vector(0,0,coffset))
end
if ent.SetViewOffsetDucked then
ent:SetViewOffsetDucked(Vector(0,0,coffset))

Check warning on line 159 in lua/pac3/core/shared/entity_mutators/size.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma

Check warning on line 159 in lua/pac3/core/shared/entity_mutators/size.lua

View workflow job for this annotation

GitHub Actions / lint

"Space after comma"

Style: Please add a space after the comma
end
end

else

ent:ResetHull()

end
end
end

pac.emut.Register(MUTATOR)
pac.emut.Register(MUTATOR)
Loading