Skip to content

Commit

Permalink
lock and hitscan fixes
Browse files Browse the repository at this point in the history
spelling issues

add some descriptions to force part and allow force actions that only do damping, without other forces (stopping momentum is a valid action to send to the server, unlike otherwise zero-force actions)
  • Loading branch information
pingu7867 committed Jan 17, 2025
1 parent f2c5c35 commit 0238b3a
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 13 deletions.
36 changes: 29 additions & 7 deletions lua/pac3/core/client/parts/force.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,31 @@ BUILDER:StartStorableVars()
:GetSet("BaseForce", 0)
:GetSet("AddedVectorForce", Vector(0,0,0))
:GetSet("Torque", Vector(0,0,0))
:GetSet("BaseForceAngleMode","Radial",{enums = {["Radial"] = "Radial", ["Locus"] = "Locus", ["Local"] = "Local"}})
:GetSet("VectorForceAngleMode", "Global", {enums = {["Global"] = "Global", ["Local"] = "Local", ["Radial"] = "Radial", ["RadialNoPitch"] = "RadialNoPitch"}})
:GetSet("TorqueMode", "TargetLocal", {enums = {["Global"] = "Global", ["TargetLocal"] = "TargetLocal", ["Local"] = "Local", ["Radial"] = "Radial"}})
:GetSet("BaseForceAngleMode","Radial",{enums = {["Radial"] = "Radial", ["Locus"] = "Locus", ["Local"] = "Local"},
description =
[[Radial points the base force outward from the force part. To point in, use negative values
Locus points out from the locus (external point)
Local points forward (red arrow) from the force part]]})
:GetSet("VectorForceAngleMode", "Global", {enums = {["Global"] = "Global", ["Local"] = "Local", ["Radial"] = "Radial", ["RadialNoPitch"] = "RadialNoPitch"},
description =
[[Global applies the vector force on world coordinates
Local applies it based on the force part's angles
Radial gets the base directions from the targets to the force part
RadialNoPitch gets the base directions from the targets to the force part, but making pitch horizon-level]]})
:GetSet("TorqueMode", "TargetLocal", {enums = {["Global"] = "Global", ["TargetLocal"] = "TargetLocal", ["Local"] = "Local", ["Radial"] = "Radial"},
description =
[[Global applies the angular force on world coordinates
TargetLocal applies it on the target's local angles
Local applies it based on the force part's angles
Radial gets the base directions from the targets to the force part]]})
:GetSetPart("Locus", nil)

:SetPropertyGroup("Behaviors")
Expand All @@ -39,9 +61,9 @@ BUILDER:StartStorableVars()
:GetSet("LevitationHeight", 0)

:SetPropertyGroup("Damping")
:GetSet("Damping", 0, {editor_clamp = {0,1}, editor_sensitivity = 0.1})
:GetSet("DampingFalloff", false, {description = "Whether the damping should fade with distance"})
:GetSet("DampingReverseFalloff", false, {description = "Whether the damping should fade with distance but reverse"})
:GetSet("Damping", 0, {editor_clamp = {0,1}, editor_sensitivity = 0.1, description = "Reduces the existing velocity before applying force, by way of multiplication by (1-damping). 0 doesn't change it, while 1 is a full negation of the initial speed."})
:GetSet("DampingFalloff", false, {description = "Whether the damping should fade with distance (further is weaker influence)"})
:GetSet("DampingReverseFalloff", false, {description = "Whether the damping should fade with distance but reverse (closer is weaker influence)"})

:SetPropertyGroup("Targets")
:GetSet("AffectSelf",false)
Expand Down Expand Up @@ -174,7 +196,7 @@ function PART:Impulse(on)
end
else locus_pos = self:GetWorldPosition() end

if self.BaseForce == 0 and not game.SinglePlayer() then
if self.BaseForce == 0 and not game.SinglePlayer() and self.Damping == 0 then
if math.abs(self.AddedVectorForce.x) < 10 and math.abs(self.AddedVectorForce.y) < 10 and math.abs(self.AddedVectorForce.z) < 10 then
if math.abs(self.Torque.x) < 10 and math.abs(self.Torque.y) < 10 and math.abs(self.Torque.z) < 10 then
return
Expand Down
4 changes: 2 additions & 2 deletions lua/pac3/core/client/parts/hitscan.lua
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ local tracer_ids = {
["HunterTracer"] = 7,
["StriderTracer"] = 8,
["GunshipTracer"] = 9,
["ToolgunTracer"] = 10,
["ToolTracer"] = 10,
["LaserTracer"] = 11
}

Expand Down Expand Up @@ -217,7 +217,7 @@ function PART:SendNetMessage()
net.WriteUInt(self.Force, 16)
net.WriteUInt(self.MaxDistance, 16)
net.WriteUInt(self.NumberBullets, 9)
net.WriteUInt(tracer_ids[self.TracerName], 4)
net.WriteUInt(tracer_ids[self.TracerName] or 0, 4)
net.WriteBool(self.DistributeDamage)

net.WriteBool(self.DamageFalloff)
Expand Down
8 changes: 4 additions & 4 deletions lua/pac3/core/client/parts/lock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ do
function PART:BreakLock(ent)
self.forcebreak = true
self.next_allowed_grab = CurTime() + 3
if self.target_ent then self.target_ent.IsGrabbedID = nil end
if self.target_ent then self.target_ent.IsGrabbedByUID = nil end
self.target_ent = nil
self.grabbing = false
pac.Message(Color(255, 50, 50), "lock break result:")
Expand Down Expand Up @@ -291,7 +291,7 @@ do
part:BreakLock(target_to_mark) --yes we will employ the aggressive lock break here
else
target_to_mark.IsGrabbed = successful_grab
target_to_mark.IsGrabbedID = uid
target_to_mark.IsGrabbedByUID = uid
target_to_mark:SetGravity(0)
end
end)
Expand Down Expand Up @@ -389,7 +389,7 @@ function PART:OnHide()
self.teleported = false
self.grabbing = false
if not IsValid(self.target_ent) then return
else self.target_ent.IsGrabbed = false self.target_ent.IsGrabbedID = nil end
else self.target_ent.IsGrabbed = false self.target_ent.IsGrabbedByUID = nil end
if util.NetworkStringToID( "pac_request_position_override_on_entity_grab" ) == 0 then self:SetError("This part is deactivated on the server") return end
self:reset_ent_ang()
end
Expand Down Expand Up @@ -505,7 +505,7 @@ function PART:CheckEntValidity()
self.valid_ent = true
end
if self.target_ent ~= nil then
if self.target_ent.IsGrabbedID and self.target_ent.IsGrabbedID ~= self.UniqueID then self.valid_ent = false end
if self.target_ent.IsGrabbedByUID and self.target_ent.IsGrabbedByUID ~= self.UniqueID then self.valid_ent = false end
end
if not self.valid_ent then self.target_ent = nil end
--print("ent check:",self.valid_ent)
Expand Down

0 comments on commit 0238b3a

Please sign in to comment.