Parachute: Fix spawn check reference points

This commit is contained in:
Wuzzy 2022-08-09 14:51:40 +02:00
parent 94a1054de7
commit b78a24ab9c

View File

@ -41,10 +41,8 @@ end
-- * `"on_ground"`: Player standing on ground -- * `"on_ground"`: Player standing on ground
-- * `"no_space"`: Not enough space -- * `"no_space"`: Not enough space
local check_parachute_spawnable = function(pos, player) local check_parachute_spawnable = function(pos, player)
-- We do 5 raycasts, which are all vertical. -- We do multiple raycasts, each testing
-- 4 raycasts for the 4 vertical edges of the -- an edge of the (soon-to-exist) parachute collisionbox.
-- (soon-to-exist) parachute collisionbox and
-- 1 raycast for the center.
-- The position is only treated as OK -- The position is only treated as OK
-- when all raycasts find nothing except the player. -- when all raycasts find nothing except the player.
@ -57,13 +55,11 @@ local check_parachute_spawnable = function(pos, player)
local y_extend = 1 -- Check a little bit below the potential collisionbox as well local y_extend = 1 -- Check a little bit below the potential collisionbox as well
-- so the parachute isn't spawned when standing on the ground -- so the parachute isn't spawned when standing on the ground
local side = CBOX_SIDE + tiny local side = CBOX_SIDE + tiny
local bottom = CBOX_BOTTOM - y_extend - tiny local bottom = - y_extend - tiny
local top = CBOX_TOP + tiny local top = (CBOX_TOP - CBOX_BOTTOM) + tiny
local offsets = { local offsets = {
-- Xmin, Ymin, Zmin, Xmax, Ymax, Zmax -- Xmin, Ymin, Zmin, Xmax, Ymax, Zmax
-- for testing the middle
{ 0, bottom, 0, 0, top, 0 },
-- for testing the 4 vertical edges of the collisionbox -- for testing the 4 vertical edges of the collisionbox
{ -side, bottom, -side, -side, top, -side }, { -side, bottom, -side, -side, top, -side },
{ -side, bottom, side, -side, top, side }, { -side, bottom, side, -side, top, side },