diff --git a/lua/pac3/core/client/parts/model.lua b/lua/pac3/core/client/parts/model.lua index c6fa9c76c..9aee7fe73 100644 --- a/lua/pac3/core/client/parts/model.lua +++ b/lua/pac3/core/client/parts/model.lua @@ -800,10 +800,11 @@ function PART:ApplyMatrix() 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 diff --git a/lua/pac3/core/client/parts/model/entity.lua b/lua/pac3/core/client/parts/model/entity.lua index 3a3b5de19..d9b66c8b0 100644 --- a/lua/pac3/core/client/parts/model/entity.lua +++ b/lua/pac3/core/client/parts/model/entity.lua @@ -22,15 +22,17 @@ BUILDER:StartStorableVars() :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."}) - :GetSet("StepSize", 18, {description = "Height that you can step up or down without jumping. Slightly tricky and may create view transition issues."}) - :GetSet("StandingViewOffset", 64, {description = "Eye height when standing"}) - :GetSet("CrouchingViewOffset", 28, {description = "Eye height when crouching"}) + :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.", editor_panel = "hull", step = true}) + :GetSet("OverrideView", false, {description = "When changing size, pac scales the view offsets. This overrides that."}) + :GetSet("StandingViewOffset", 64, {description = "Eye height when standing", editor_panel = "hull", view = true}) + :GetSet("CrouchingViewOffset", 28, {description = "Eye height when crouching", editor_panel = "hull", crouch = true, view = true}) :EndStorableVars() BUILDER:RemoveProperty("BoneMerge") @@ -62,6 +64,24 @@ function PART:SetHullWidth(val) 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.OverrideStepSize = b + self.OverrideView = b + self:ApplyMatrix() + end +end + function PART:SetStandingViewOffset(val) self.StandingViewOffset = val self:ApplyMatrix() @@ -74,10 +94,6 @@ function PART:SetStepSize(val) 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() diff --git a/lua/pac3/core/shared/entity_mutators/size.lua b/lua/pac3/core/shared/entity_mutators/size.lua index b3b3a39a5..f5cc0d830 100644 --- a/lua/pac3/core/shared/entity_mutators/size.lua +++ b/lua/pac3/core/shared/entity_mutators/size.lua @@ -8,16 +8,25 @@ local allow_viewoffset = CreateConVar("pac_modifier_viewoffset", "0", CLIENT and 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 @@ -48,9 +57,12 @@ function MUTATOR:ReadArguments() 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 @@ -79,7 +91,7 @@ end local functions = { "ViewOffset", "ViewOffsetDucked", - "StepSize", + "StepSize" } function MUTATOR:Mutate(multiplier, other, hidden_state) @@ -131,26 +143,29 @@ function MUTATOR:Mutate(multiplier, other, hidden_state) 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)) + end + end + if other.OverrideView then + local soffset = other.StandingViewOffset + local coffset = other.CrouchingViewOffset + if ent.SetViewOffset then + ent:SetViewOffset(Vector(0,0,soffset)) 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)) end end else + ent:ResetHull() + end end end -pac.emut.Register(MUTATOR) \ No newline at end of file +pac.emut.Register(MUTATOR) diff --git a/lua/pac3/editor/client/panels/extra_properties.lua b/lua/pac3/editor/client/panels/extra_properties.lua index f332492df..60acd36aa 100644 --- a/lua/pac3/editor/client/panels/extra_properties.lua +++ b/lua/pac3/editor/client/panels/extra_properties.lua @@ -1348,40 +1348,103 @@ do -- hull PANEL.ClassName = "properties_hull" PANEL.Base = "pace_properties_number" + local hull_color = Color(255, 204, 51, 255) function PANEL:OnValueSet() local function stop() RunConsoleCommand("-duck") hook.Remove("PostDrawOpaqueRenderables", "pace_draw_hull") + hook.Remove("PostDrawOpaqueRenderables", "pace_draw_hull2") + hook.Remove("PostDrawOpaqueRenderables", "pace_draw_hull3") end local time = os.clock() + 3 - hook.Add("PostDrawOpaqueRenderables", "pace_draw_hull", function() + local udata = self.udata + if udata then + if udata.step then + if not self.first_time then self.first_time = true return end + hook.Add("PostDrawOpaqueRenderables", "pace_draw_hull3", function() - if not pace.current_part:IsValid() then stop() return end - if pace.current_part.ClassName ~= "entity2" then stop() return end + if not pace.current_part:IsValid() then stop() return end + if pace.current_part.ClassName ~= "entity2" then stop() return end - local ent = pace.current_part:GetOwner() - if not ent.GetHull then stop() return end - if not ent.GetHullDuck then stop() return end + local ent = pace.current_part:GetOwner() + if not ent.GetHull then stop() return end + if not ent.GetHullDuck then stop() return end - local min, max = ent:GetHull() + local min, max = ent:GetHull() - if self.udata and self.udata.crouch then - min, max = ent:GetHullDuck() - RunConsoleCommand("+duck") - end + local part = pace.current_part + local height = part.StepSize + min = Vector(-part.HullWidth/2,-part.HullWidth/2,0) + max = Vector(part.HullWidth/2,part.HullWidth/2,0) + render.DrawWireframeBox( ent:GetPos() + Vector(0,0,height), Angle(0), min, max, hull_color, true ) - min = min * ent:GetModelScale() - max = max * ent:GetModelScale() + if time < os.clock() then + stop() + end + end) + elseif udata.view then + if not self.first_time then self.first_time = true return end + hook.Add("PostDrawOpaqueRenderables", "pace_draw_hull2", function() - render.DrawWireframeBox( ent:GetPos(), Angle(0), min, max, Color(255, 204, 51, 255), true ) + if not pace.current_part:IsValid() then stop() return end + if pace.current_part.ClassName ~= "entity2" then stop() return end - if time < os.clock() then - stop() + local ent = pace.current_part:GetOwner() + if not ent.GetHull then stop() return end + if not ent.GetHullDuck then stop() return end + + local min, max = ent:GetHull() + + if udata.crouch then + min, max = ent:GetHullDuck() + RunConsoleCommand("+duck") + end + + min = min * ent:GetModelScale() + max = max * ent:GetModelScale() + + local part = pace.current_part + local height = part.StandingViewOffset + if udata.crouch then + height = part.CrouchingViewOffset + end + render.DrawWireframeSphere( ent:GetPos() + Vector(0, 0, height), 8, 8, 8, hull_color, true ) + + if time < os.clock() then + stop() + end + end) + else + hook.Add("PostDrawOpaqueRenderables", "pace_draw_hull", function() + + if not pace.current_part:IsValid() then stop() return end + if pace.current_part.ClassName ~= "entity2" then stop() return end + + local ent = pace.current_part:GetOwner() + if not ent.GetHull then stop() return end + if not ent.GetHullDuck then stop() return end + + local min, max = ent:GetHull() + + if udata.crouch then + min, max = ent:GetHullDuck() + RunConsoleCommand("+duck") + end + + min = min * ent:GetModelScale() + max = max * ent:GetModelScale() + + render.DrawWireframeBox( ent:GetPos(), Angle(0), min, max, hull_color, true ) + + if time < os.clock() then + stop() + end + end) end - end) + end end pace.RegisterPanel(PANEL)