Skip to content

Commit

Permalink
Improved map bound checking logic
Browse files Browse the repository at this point in the history
- The projectile effect will now actually attempt to check if it's inside the map rather than using hardcoded bounds, should improve compatibility with InfMap.
  • Loading branch information
TwistedTail committed May 20, 2024
1 parent 97e45a7 commit b8cd70b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions lua/effects/acf_projectile.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
local util = util
local ACF = ACF
local Bullets = ACF.BulletEffect
local AmmoTypes = ACF.Classes.AmmoTypes
local Clock = ACF.Utilities.Clock
local Trace = { collisiongroup = COLLISION_GROUP_WORLD }

local Actions = {
[0] = "Create",
Expand All @@ -10,6 +11,13 @@ local Actions = {
[3] = "Ricochet"
}

function EFFECT.HasLeftWorld(Position)
Trace.start = Position
Trace.endpos = Position

return util.TraceLine(Trace).HitWorld
end

function EFFECT:Init(Data)
local Index = Data:GetDamageType()
local Action = Actions[Data:GetScale()]
Expand Down Expand Up @@ -157,15 +165,13 @@ end
function EFFECT:ApplyMovement(Bullet)
local Position = Bullet.Pos

--TODO: Replace this logic, map bounds might not be compliant with this in all cases
if math.abs(Position.x) > 16380 or math.abs(Position.y) > 16380 or Position.z < -16380 then
if self.HasLeftWorld(Position) then
--print("Bullet #" .. Bullet.Index .. " has left the world, removing.")
return false
end

if Position.z < 16380 then
self:SetAngles(Bullet.Flight:Angle())
self:SetPos(Position)
end
self:SetAngles(Bullet.Flight:Angle())
self:SetPos(Position)

return true
end

0 comments on commit b8cd70b

Please sign in to comment.