Skip to content

Commit

Permalink
fix parry hitlag lap portal bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Saxashitter committed Aug 10, 2024
1 parent d453c82 commit 12ad8d4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 22 deletions.
1 change: 1 addition & 0 deletions src/Lua/Gimmicks/pizzaportal.lua
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ addHook("TouchSpecial", function(special, toucher)
if PTSR_DoHook("onlap", toucher) == true then
return
end
PTSR.StopParryHitlag(tplayer, true)
toucher.pizza_in = portal_time
PTSR:FillCombo(tplayer)
S_StartSound(toucher, sfx_lapin)
Expand Down
67 changes: 46 additions & 21 deletions src/Lua/PlayerScripts/player_parry.lua
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,47 @@ PTSR.DoParry = function(parrier, victim)
end
end

PTSR.DoParryHitlag = function(player)
-- remove to debug the shit for now

local data = player.ptsr.parryhitlagdata

data.x = player.mo.x
data.y = player.mo.y
data.z = player.mo.z

if data.momx == nil
or data.momy == nil
or data.momz == nil then
data.momx = player.mo.momx
data.momy = player.mo.momy
data.momz = player.mo.momz
end

data.a = player.drawangle
data.state = player.mo.state
data.frame = player.mo.frame

player.ptsr.parryhitlag = true
player.ptsr.parryhitlagtime = leveltime
end

PTSR.StopParryHitlag = function(player, dontapplymom)
local data = player.ptsr.parryhitlagdata

if not dontapplymom then
player.mo.momx = data.momx
player.mo.momy = data.momy
player.mo.momz = data.momz
end

data.momx = nil
data.momy = nil
data.momz = nil

player.ptsr.parryhitlag = false
end

-- Parry Stuff

-- helper function so we can get whose pizzaface easily
Expand Down Expand Up @@ -144,11 +185,7 @@ addHook("PlayerThink", function(player)
local ptime = leveltime-player.ptsr.parryhitlagtime

if ptime >= PTSR.ParryHitLagFrames then
player.mo.momx = data.momx
player.mo.momy = data.momy
player.mo.momz = data.momz

player.ptsr.parryhitlag = false
PTSR.StopParryHitlag(player)
else
P_SetOrigin(player.mo,
data.x,
Expand All @@ -170,7 +207,9 @@ addHook("PlayerThink", function(player)
end
end

if not player.mo.ptsr.parry_cooldown then
if not player.mo.ptsr.parry_cooldown
and not player.mo.pizza_in
and not player.mo.pizza_out then
if cmd.buttons & BT_ATTACK then
if not player.mo.pre_parry then -- pre parry start
local failparrysfx = {
Expand Down Expand Up @@ -234,21 +273,7 @@ addHook("PlayerThink", function(player)
PTSR.DoParryAnim(player.mo, true, _isPF(foundmobj) and player.rings >= PTSR.ParrySpendRequirement)
PTSR.DoParryAnim(foundmobj)

if not player.ptsr.parryhitlag then
local data = player.ptsr.parryhitlagdata
data.x = player.mo.x
data.y = player.mo.y
data.z = player.mo.z
data.momx = player.mo.momx
data.momy = player.mo.momy
data.momz = player.mo.momz
data.a = player.drawangle
data.state = player.mo.state
data.frame = player.mo.frame
end

player.ptsr.parryhitlag = true
player.ptsr.parryhitlagtime = leveltime
PTSR.DoParryHitlag(player)

gotanobject = true
end
Expand Down
2 changes: 1 addition & 1 deletion src/Lua/main_game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ PTSR.default_playervars = {
cantparry = false, --this is for the pizzaface parry - saxa
parryhitlag = false, --hit lag now
parryhitlagtime = 0, --this to make sure about shit
parryhitlagdata = {x=0,y=0,z=0,a=0,momx=0,momy=0,momz=0,on=false},
parryhitlagdata = {x=0,y=0,z=0,a=0},
hudstuff = PTSR_shallowcopy(PTSR.hudstuff)
}

Expand Down

0 comments on commit 12ad8d4

Please sign in to comment.