Skip to content

Commit

Permalink
a lotta stuff
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Jiskster committed Aug 10, 2024
1 parent 048c0f1 commit c80c40c
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
19 changes: 16 additions & 3 deletions src/Lua/InbuiltModeScripts/juggernaut.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 9 additions & 9 deletions src/Lua/Libraries/hooksystem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)

8 changes: 6 additions & 2 deletions src/Lua/pizzaface.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit c80c40c

Please sign in to comment.