From c80c40c06edeb458e424fb980c7b41975edcaf7d Mon Sep 17 00:00:00 2001 From: Jisk <37682565+Jiskster@users.noreply.github.com> Date: Fri, 9 Aug 2024 19:43:25 -0500 Subject: [PATCH] a lotta stuff improved hooks, allowing for dynamic returns (not just returning true anymore) new hook pfplayerfind new hook pfplayertpfind now in juggernaut, the person with the crown is immune to pizza face instead. --- src/Lua/InbuiltModeScripts/juggernaut.lua | 19 ++++++++++++++++--- src/Lua/Libraries/hooksystem.lua | 18 +++++++++--------- src/Lua/pizzaface.lua | 8 ++++++-- 3 files changed, 31 insertions(+), 14 deletions(-) diff --git a/src/Lua/InbuiltModeScripts/juggernaut.lua b/src/Lua/InbuiltModeScripts/juggernaut.lua index 788ecd1..03d4f4a 100644 --- a/src/Lua/InbuiltModeScripts/juggernaut.lua +++ b/src/Lua/InbuiltModeScripts/juggernaut.lua @@ -98,19 +98,32 @@ PTSR_AddHook("onparry", function(pmo, victim) end end) + PTSR_AddHook("pfthink", function(pizza) if PTSR.gamemode ~= PTSR.gm_juggernaut then return end - pizza.pizza_target = PTSR.juggernaut_crownholder + if pizza.pizza_target == PTSR.juggernaut_crownholder then + pizza.pizza_target = nil + end +end) + +PTSR_AddHook("pfplayerfind", function(player) + if PTSR.gamemode ~= PTSR.gm_juggernaut then return end + + if player.mo and player.mo.valid then + if PTSR.juggernaut_crownholder == player.mo then + return false + end + end end) +-- true == override PTSR_AddHook("pfdamage", function(toucher, pizza) if PTSR.gamemode ~= PTSR.gm_juggernaut then return end - if PTSR.juggernaut_crownholder ~= toucher then + if PTSR.juggernaut_crownholder == toucher then return true else - P_SetOrigin(pizza, pizza.x, pizza.y, pizza.z + 512*FU) return false end end) diff --git a/src/Lua/Libraries/hooksystem.lua b/src/Lua/Libraries/hooksystem.lua index e9694ec..e88b81a 100644 --- a/src/Lua/Libraries/hooksystem.lua +++ b/src/Lua/Libraries/hooksystem.lua @@ -12,8 +12,10 @@ hooks.pfthink = {} hooks.pfprestunthink = {} hooks.pfdamage = {} hooks.pfteleport = {} +hooks.pfplayerfind = {} +hooks.pfplayertpfind = {} -local override_register = false +local override_register = nil /* It's called override_register because a common use of hooks is to override Ingame actions. @@ -38,16 +40,14 @@ rawset(_G, "PTSR_DoHook", function(hooktype, ...) end for i,v in ipairs(hooks[hooktype]) do - if v(...) == true then - override_register = true - end + override_register = v(...) end - if override_register == true then - override_register = false - return true - else - return false + if override_register ~= nil then + local register_copy = override_register + + override_register = nil + return register_copy end end) diff --git a/src/Lua/pizzaface.lua b/src/Lua/pizzaface.lua index 9b565c6..c4b01f8 100644 --- a/src/Lua/pizzaface.lua +++ b/src/Lua/pizzaface.lua @@ -165,7 +165,7 @@ function PTSR:RNGPizzaTP(pizza, uselaugh) for peppino in players.iterate() do if not peppino.ptsr.pizzaface and (peppino.mo and peppino.mo.valid) and not peppino.spectator and not peppino.ptsr.outofgame and (peppino.playerstate ~= PST_DEAD) - and not peppino.quittime then + and not peppino.quittime and PTSR_DoHook("pfplayertpfind", player) ~= false then table.insert(peppinos, #peppino) end end @@ -293,7 +293,11 @@ local function PF_FindNewPlayer(mobj) for player in players.iterate do if player.mo and player.mo.valid and PTSR.PlayerIsChasable(player) then - table.insert(activeplayers, player) + local hookreturn = PTSR_DoHook("pfplayerfind", player) + + if hookreturn ~= false then + table.insert(activeplayers, player) + end end end