Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spice Wars: The Revenge of the Player PF #40

Merged
merged 2 commits into from
Sep 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/Lua/HUD/hud_tooltips.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ local tooltips_hud = function(v, player)
else
v.drawString(165, 157, "\x85\* HOLD FIRE TO TELEPORT *", V_SNAPTOBOTTOM, "thin-center")
end

v.drawString(165, 157-10, "\x85\* HOLD C1 TO DASH *", V_SNAPTOBOTTOM, "thin-center")
if not player.ptsr.pizzachase then
if not (player.ptsr.pizzachase_cooldown) then
v.drawString(165, 157-20, "\x85\* PRESS C2 TO USE CHASEDOWN *", V_SNAPTOBOTTOM, "thin-center")
else
v.drawString(165, 157-20, "\x85\* COOLING DOWN *", V_SNAPTOBOTTOM, "thin-center")
end
end
end

-- Early returns start here, no pizza face code allowed beyond here --
Expand Down
4 changes: 2 additions & 2 deletions src/Lua/Init/initmap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ local function InitMap2()

PTSR.spawn_location.x = map.x*FU
PTSR.spawn_location.y = map.y*FU
PTSR.spawn_location.z = sec.floorheight+(map.z*FU)
PTSR.spawn_location.z = sec.floorheight
PTSR.spawn_location.angle = map.angle*ANG1
end

Expand All @@ -67,7 +67,7 @@ local function InitMap2()

PTSR.end_location.x = map.x*FU
PTSR.end_location.y = map.y*FU
PTSR.end_location.z = sec.floorheight+(map.z*FU)
PTSR.end_location.z = sec.floorheight

PTSR.end_location.angle = map.angle*ANG1
local john = P_SpawnMobj(
Expand Down
3 changes: 1 addition & 2 deletions src/Lua/PlayerScripts/player_laptp.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ PTSR.LapTP = function(player, invincibility)

player.ptsr.outofgame = 0

local floorz = P_FloorzAtPos(PTSR.end_location.x, PTSR.end_location.y, PTSR.end_location.z, player.mo.height)
P_SetOrigin(player.mo, PTSR.end_location.x,PTSR.end_location.y, floorz)
P_SetOrigin(player.mo, PTSR.end_location.x,PTSR.end_location.y, PTSR.end_location.z)

player.mo.angle = PTSR.end_location.angle - ANGLE_90

Expand Down
3 changes: 1 addition & 2 deletions src/Lua/PlayerScripts/pmo_pizzatimetrigger.lua
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,7 @@ PTSR.PizzaTimeTrigger = function(mobj)
if not (pmo and pmo.valid) then continue end
player.ptsr.laps = 1

local floorz = P_FloorzAtPos(PTSR.end_location.x, PTSR.end_location.y, PTSR.end_location.z, pmo.height)
P_SetOrigin(pmo, PTSR.end_location.x,PTSR.end_location.y, floorz)
P_SetOrigin(pmo, PTSR.end_location.x,PTSR.end_location.y, PTSR.end_location.z)

pmo.angle = PTSR.end_location.angle - ANGLE_90

Expand Down
2 changes: 1 addition & 1 deletion src/Lua/PlayerScripts/pmo_startnewlap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PTSR.StartNewLap = function(mobj)
end
else -- FAKE LAP --
mobj.pfstuntime = TICRATE*CV_PTSR.fakelapstun.value
P_SetOrigin(mobj, PTSR.end_location.x*FRACUNIT,PTSR.end_location.y*FRACUNIT, PTSR.end_location.z*FRACUNIT)
P_SetOrigin(mobj, PTSR.end_location.x,PTSR.end_location.y, PTSR.end_location.z)
mobj.angle = PTSR.end_location.angle - ANGLE_90
end
end
13 changes: 5 additions & 8 deletions src/Lua/main_game.lua
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@ PTSR.default_playervars = {
rank_scaleTime = 0,

pizzaface = false,
pizzachase = false,
pizzachase_cooldown = 0,
pizzachase_time = 0,
pizzamask = nil,

laps = 0,
Expand Down Expand Up @@ -206,23 +209,17 @@ PTSR.gm_juggernaut = PTSR.RegisterGamemode("Juggernaut", {
disable_pizzatime_penalty = true,
})

/*
PTSR.gm_playerpf = PTSR.RegisterGamemode("Player PF", {
parry_friendlyfire = false,
dustdevil = false,
allowrevive = true,
player_pizzaface = true,
ring_score = 10,
enemy_score = 100,
ringlapbonus = 5,
lapbonus = 300,
player_pizzaface = true
})
*/

PTSR.ChangeGamemode = function(gm)
local newgamemode = gm or 1
local gm_metadata = PTSR.gamemode_list[gm]

if newgamemode ~= PTSR.gamemode then -- dont print this if new gamemode is the same
local output_text = "PTSR Gamemode changed to " .. (gm_metadata.name or "Unnamed Mode")
print(output_text)
Expand Down
127 changes: 116 additions & 11 deletions src/Lua/pizzaface.lua
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,6 @@ addHook("TouchSpecial", function(special, toucher)
return true
end, MT_PIZZA_ENEMY)

-- Player touches human pizzaface
addHook("MobjCollide", function(peppino, pizza)
local player = peppino.player
local pizza_player = pizza.player
Expand All @@ -364,7 +363,6 @@ addHook("MobjCollide", function(peppino, pizza)
PTSR:PizzaCollision(peppino, pizza)
end, MT_PLAYER)


addHook("PlayerCmd", function (player, cmd)
if player.ptsr.pizzaface and player.realmo.pfstuntime then
cmd.buttons = 0
Expand Down Expand Up @@ -611,7 +609,107 @@ addHook("MobjSpawn", function(mobj)
mobj.pfstuntime = multiplayer and CV_PTSR.pizzatimestun.value*TICRATE or TICRATE
end, MT_PIZZA_ENEMY)

local function controls_angle(p)
local forwardmove = p.cmd.forwardmove
local sidemove = p.cmd.sidemove
if not (p.mo and p.mo.flags2 & MF2_TWOD) then
local camera_angle = (p.cmd.angleturn<<16)
local controls_angle = R_PointToAngle2(0,0, forwardmove*FU, -sidemove*FU)

return camera_angle+controls_angle
end

if sidemove > 0 then
return ANGLE_45
elseif sidemove < 0 then
return InvAngle(ANGLE_45)
end
end

local function handle_pf_player_movement(player)
-- handle movement
-- community feedback recommended us that we do this
-- literallymario/saxa

player.mo.momx = 0
player.mo.momy = 0
player.mo.momz = 0

local speed = 28

if not player.ptsr.pizzachase then
player.ptsr.pizzachase_cooldown = max(0, $-1)

if player.ptsr.pfbuttons & BT_CUSTOM1 then
speed = $*3/2
end

if player.cmd.forwardmove or player.cmd.sidemove then
local angle = controls_angle(player)
local hypot = FixedHypot(player.cmd.sidemove*FU, player.cmd.forwardmove*FU)

player.mo.momx = speed*FixedMul(cos(angle), hypot/50)
player.mo.momy = speed*FixedMul(sin(angle), hypot/50)
end

if player.ptsr.pfbuttons & BT_JUMP then
player.mo.momz = speed*FU
elseif player.ptsr.pfbuttons & BT_SPIN then
player.mo.momz = speed*-FU
end

if not (player.ptsr.pizzachase_cooldown)
and player.ptsr.pfbuttons & BT_CUSTOM2 then
player.ptsr.pizzachase = true
player.ptsr.pizzachase_time = 10*TICRATE
S_StartSound(player.mo, PTSR.PFMaskData[player.ptsr.pizzastyle].sound)
end
else
local found_player
for p in players.iterate do
if not (p
and p.mo
and p.mo.health
and p.ptsr
and not p.ptsr.pizzaface
and PTSR.PlayerIsChasable(p)) then continue end
if not (found_player and found_player.valid) then
found_player = p.mo
end

if p.mo.x < found_player.x
and p.mo.y < found_player.y
and p.mo.z < found_player.z then
found_player = p.mo
end
end

if found_player and found_player.valid then
P_FlyTo(player.mo,found_player.x,found_player.y,found_player.z,speed*(FU*3/2),true)
end

player.ptsr.pizzachase_time = max(0, $-1)
if not (player.ptsr.pizzachase_time)
or not (found_player and found_player.valid) then
player.ptsr.pizzachase = false
player.ptsr.pizzachase_cooldown = 30*TICRATE
end
end
end

--Player Pizza Face Thinker

addHook("PreThinkFrame", do
if not PTSR.IsPTSR() then return end
if PTSR.gameover then return end
for p in players.iterate do
if not (p.ptsr and p.ptsr.pizzaface) then continue end
-- to prevent weird shit lmfao
p.ptsr.pfbuttons = p.cmd.buttons
p.cmd.buttons = 0
end
end)

addHook("PlayerThink", function(player)
player.ptsr.pizzastyle = $ or 1
player.realmo.pfstuntime = $ or 0
Expand All @@ -629,12 +727,9 @@ addHook("PlayerThink", function(player)
if player.realmo.pfstuntime then -- player freeze decrement (mainly for pizza faces)
player.realmo.pfstuntime = $ - 1
-- # No Momentum # --
if not player.realmo.pfstunmomentum then
player.mo.momx = 0
player.mo.momy = 0
player.mo.momz = 0
L_SpeedCap(player.mo, 0)
end
player.mo.momx = 0
player.mo.momy = 0
player.mo.momz = 0
-- # No Momentum # --
--player.pflags = $|PF_FULLSTASIS
if not player.realmo.pfstuntime then -- once it hits zero, LAUGH AHHHHAHHAAHAHAHHAHAH
Expand All @@ -652,7 +747,10 @@ addHook("PlayerThink", function(player)

player.realmo.pfstunmomentum = false
elseif PTSR.pizzatime_tics < CV_PTSR.pizzatimestun.value*TICRATE then
player.mo.momz = P_MobjFlip(player.mo)*-FU
player.mo.momx = 0
player.mo.momy = 0
player.mo.momz = 0

if player.facechangecooldown then
player.facechangecooldown = $ - 1
else
Expand All @@ -676,8 +774,16 @@ addHook("PlayerThink", function(player)
end
end
end
else
-- player is not stunned? neat!
handle_pf_player_movement(player)
end

if player.mo.skin ~= "sonic" then
-- compatibility issues might occur, quick, switch back to sonic!
R_SetPlayerSkin(player, "sonic")
end

if (not player.ptsr.pizzamask or not player.ptsr.pizzamask.valid) then
player.ptsr.pizzamask = P_SpawnMobj(player.realmo.x,player.realmo.y,player.realmo.z,MT_PIZZAMASK)
player.ptsr.pizzamask.targetplayer = player --dream reference
Expand All @@ -691,7 +797,6 @@ addHook("PlayerThink", function(player)
player.mo.colorized = true
end


if not (leveltime % 3) and player.ptsr.pizzamask and player.ptsr.pizzamask.valid and player.speed > FRACUNIT then
if (player ~= displayplayer) or (camera.chase and player == displayplayer) then
local colors = PTSR.PFMaskData[player.ptsr.pizzastyle].trails
Expand All @@ -714,7 +819,7 @@ addHook("PlayerThink", function(player)
player.pizzacharge = 0
end
if not player.ptsr.outofgame and (player.cmd.buttons & BT_ATTACK)
and not PTSR.quitting and not player.realmo.pfstuntime and not player.pizzachargecooldown then -- basically check if you're active in general
and not player.ptsr.pizzachase and not PTSR.quitting and not player.realmo.pfstuntime and not player.pizzachargecooldown then -- basically check if you're active in general
if player.pizzacharge < TICRATE then
player.pizzacharge = $ + 1
else
Expand Down
2 changes: 1 addition & 1 deletion src/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ mobjinfo[MT_PIZZAMASK] = {
spawnstate = S_PIZZAFACE,
spawnhealth = 1000,
deathstate = S_NULL,
radius = 16*FU,
radius = 24*FU,
height = 48*FU,
flags = MF_NOCLIP|MF_NOGRAVITY
}
Expand Down