local WSS_DEFAULT = { stretchstyle = 0, stretchlimit = 29, squashstyle = 0, squashforce = 18, returnstyle = 0, returnspeed = 1 } local function WSS_CopyTable(t) local new = {} for k,v in pairs(t) do new[k] = v end return new end local WSS_CONFIG = WSS_CopyTable(WSS_DEFAULT) local function WSS_LoadConfig() local file = io.openlocal("wss_config.cfg") if not file then return end local data = {} for i = 1,6 data[i] = tonumber(file:read("*l")) end file:close() if data[1] then WSS_CONFIG.stretchstyle = data[1] end if data[2] then WSS_CONFIG.stretchlimit = data[2] end if data[3] then WSS_CONFIG.squashstyle = data[3] end if data[4] then WSS_CONFIG.squashforce = data[4] end if data[5] then WSS_CONFIG.returnstyle = data[5] end if data[6] then WSS_CONFIG.returnspeed = data[6] end end local function WSS_SaveConfig(p) local file = io.openlocal("wss_config.cfg", "w") if not file then CONS_Printf(p, "\x85Failed to create config file.") return end file:write(WSS_CONFIG.stretchstyle, "\n") file:write(WSS_CONFIG.stretchlimit, "\n") file:write(WSS_CONFIG.squashstyle, "\n") file:write(WSS_CONFIG.squashforce, "\n") file:write(WSS_CONFIG.returnstyle, "\n") file:write(WSS_CONFIG.returnspeed, "\n") file:close() CONS_Printf(p, "\x82WSS configuration saved.") end local function WSS_Reset(p) WSS_CONFIG = WSS_CopyTable(WSS_DEFAULT) CONS_Printf(p, "\x82WSS configuration reset to default.") end local function ApplyConfigToPlayer(p) p.wss_stretchstyle = WSS_CONFIG.stretchstyle p.wss_stretchlimit = WSS_CONFIG.stretchlimit * FU p.wss_squashstyle = WSS_CONFIG.squashstyle p.wss_squashforce = WSS_CONFIG.squashforce * FU p.wss_returnscalestyle = WSS_CONFIG.returnstyle p.wss_returnscalespd = WSS_CONFIG.returnspeed * FU / 10 end COM_AddCommand("wss_stretch", function(p, a, b) if not a or a == "help" or a == "info" then CONS_Printf(p, "\x82--- Wacky Stretch Settings ---") CONS_Printf(p, "wss_stretch style <0/1>") CONS_Printf(p, "wss_stretch limit ") CONS_Printf(p, "") CONS_Printf(p, "Current style: "..(p.wss_stretchstyle or 0)) CONS_Printf(p, "Current limit: "..((p.wss_stretchlimit or 29*FU)/FU)) return end if a == "style" then if not b or b == "help" then CONS_Printf(p, "\x82Stretch Styles:") CONS_Printf(p, "0 = Classic (stretch on jump)") CONS_Printf(p, "1 = Airflow (based on vertical speed)") return end if b == "0" or b == "classic" then p.wss_stretchstyle = 0 WSS_CONFIG.stretchstyle = 0 ApplyConfigToPlayer(p) CONS_Printf(p, "\x83Stretch style set to: Classic") elseif b == "1" or b == "airflow" then p.wss_stretchstyle = 1 WSS_CONFIG.stretchstyle = 1 ApplyConfigToPlayer(p) CONS_Printf(p, "\x83Stretch style set to: Airflow") else CONS_Printf(p, "\x85Invalid stretch style. Type help to see options.") end elseif a == "limit" then if not b or b == "help" then CONS_Printf(p, "Current stretch limit: "..((p.wss_stretchlimit or 29*FU)/FU)) CONS_Printf(p, "Default: 29 | Type 0 to disable.") return end local num = tonumber(b) if num == nil then CONS_Printf(p, "\x85Please enter a valid number.") return end if num <= 0 then p.wss_stretchlimit = 0 WSS_CONFIG.stretchlimit = 0 ApplyConfigToPlayer(p) CONS_Printf(p, "\x83Stretch disabled.") else local value = min(num, 32) p.wss_stretchlimit = value*FU WSS_CONFIG.stretchlimit = value ApplyConfigToPlayer(p) CONS_Printf(p, "\x83Stretch limit set to: "..min(num, 32)) end end end, COM_LOCAL) COM_AddCommand("wss_squash", function(p, a, b) if not a or a == "help" or a == "info" then CONS_Printf(p, "\x82--- Wacky Squash Settings ---") CONS_Printf(p, "wss_squash style <0/1>") CONS_Printf(p, "wss_squash force ") CONS_Printf(p, "") CONS_Printf(p, "Current style: "..(p.wss_squashstyle or 0)) CONS_Printf(p, "Current force: "..((p.wss_squashforce or 18*FU)/FU)) return end if a == "style" then if not b or b == "help" then CONS_Printf(p, "\x82Squash Styles:") CONS_Printf(p, "0 = Impact (on landing)") CONS_Printf(p, "1 = Speed (based on ground speed)") return end if b == "0" or b == "impact" then p.wss_squashstyle = 0 WSS_CONFIG.squashstyle = 0 ApplyConfigToPlayer(p) CONS_Printf(p, "\x83Squash style set to: Impact") elseif b == "1" or b == "speed" then p.wss_squashstyle = 1 WSS_CONFIG.squashstyle = 1 ApplyConfigToPlayer(p) CONS_Printf(p, "\x83Squash style set to: Speed") else CONS_Printf(p, "\x85Invalid squash style. Type help to see options.") end elseif a == "force" then if not b or b == "help" then CONS_Printf(p, "Current squash force: "..((p.wss_squashforce or 18*FU)/FU)) CONS_Printf(p, "Default: 18 | Type 0 to disable.") return end local num = tonumber(b) if num == nil then CONS_Printf(p, "\x85Please enter a valid number.") return end if num <= 0 then p.wss_squashforce = 0 WSS_CONFIG.squashforce = 0 ApplyConfigToPlayer(p) CONS_Printf(p, "\x83Squash disabled.") else local value = min(num, 29) p.wss_squashforce = value*FU WSS_CONFIG.squashforce = value ApplyConfigToPlayer(p) CONS_Printf(p, "\x83Squash force set to: "..min(num, 29)) end end end, COM_LOCAL) COM_AddCommand("wss_returnscale", function(p, a, b) if not a or a == "help" or a == "info" then CONS_Printf(p, "\x82--- Return Scale Settings ---") CONS_Printf(p, "wss_returnscale style <0/1>") CONS_Printf(p, "wss_returnscale speed ") CONS_Printf(p, "") CONS_Printf(p, "Current style: "..(p.wss_returnscalestyle or 0)) CONS_Printf(p, "Current speed: "..(((p.wss_returnscalespd or FU/10)*10)/FU)) return end if a == "style" then if not b or b == "help" then CONS_Printf(p, "\x82Return Styles:") CONS_Printf(p, "0 = Sharp (linear return)") CONS_Printf(p, "1 = Smooth (exponential return)") return end if b == "0" or b == "sharp" then p.wss_returnscalestyle = 0 WSS_CONFIG.returnstyle = 0 ApplyConfigToPlayer(p) CONS_Printf(p, "\x83Return style set to: Sharp") elseif b == "1" or b == "smooth" then p.wss_returnscalestyle = 1 WSS_CONFIG.returnstyle = 1 ApplyConfigToPlayer(p) CONS_Printf(p, "\x83Return style set to: Smooth") else CONS_Printf(p, "\x85Invalid return style.") end elseif a == "speed" then if not b or b == "help" then CONS_Printf(p, "Current return speed: "..(((p.wss_returnscalespd or FU/10)*10)/FU)) CONS_Printf(p, "Default: 1") return end local num = tonumber(b) if num == nil or num <= 0 then CONS_Printf(p, "\x85Please enter a valid number above 0.") return end local value = min(num, 7) p.wss_returnscalespd = value*FU/10 WSS_CONFIG.returnspeed = value ApplyConfigToPlayer(p) CONS_Printf(p, "\x83Return speed set to: "..min(num, 7)) end end, COM_LOCAL) COM_AddCommand("wss_save", function(p) WSS_SaveConfig(p) end, COM_LOCAL) COM_AddCommand("wss_reset", function(p) WSS_Reset(p) ApplyConfigToPlayer(p) end, COM_LOCAL) local function WSS_Main(p) if p.wss_stretchstyle == nil p.wss_stretchstyle = 0 end if p.wss_stretchlimit == nil p.wss_stretchlimit = 29*FU end if p.wss_squashstyle == nil p.wss_squashstyle = 0 end if p.wss_squashforce == nil p.wss_squashforce = 18*FU end if p.wss_returnscalespd == nil p.wss_returnscalespd = FU/10 end if p.wss_returnscalestyle == nil p.wss_returnscalestyle = 0 end if p.wss_spritescale == nil p.wss_spritescale = 0 end if p.mo and p.mo.valid p.mo.spriteyscale = FU + p.wss_spritescale/34 p.mo.spritexscale = FU - p.wss_spritescale/34 if p.wss_spritescale ~= 0 if p.wss_returnscalestyle == 0 if p.wss_spritescale > 0 p.wss_spritescale = max(0, $ - p.wss_returnscalespd*10) else p.wss_spritescale = min(0, $ + p.wss_returnscalespd*10) end else local strength = min(FU-1, p.wss_returnscalespd) p.wss_spritescale = FixedMul($, FU - strength) end end if not (P_IsObjectOnGround(p.mo)) p.wss_oldmomz = p.mo.momz if (p.mo.momz > 0 and p.wss_stretchstyle == 0) and p.wss_midair == false p.wss_oldstate = p.mo.state p.wss_spritescale = p.mo.momz if p.wss_stretchstyle == 0 p.wss_midair = true if p.mo.momz > p.wss_stretchlimit p.wss_spritescale = p.wss_stretchlimit else p.wss_spritescale = p.mo.momz end end elseif p.wss_spritescale < 0 p.wss_spritescale = 0 end if p.wss_stretchstyle == 1 if p.mo.momz > 0 if p.mo.momz > p.wss_stretchlimit*2 p.wss_spritescale = p.wss_stretchlimit else p.wss_spritescale = p.mo.momz/2 end end if p.mo.momz < 0 if p.mo.momz < -p.wss_stretchlimit*2 p.wss_spritescale = p.wss_stretchlimit else p.wss_spritescale = -p.mo.momz/2 end end end end if (p.wss_oldstate ~= p.mo.state and not P_IsObjectOnGround(p.mo)) or p.mo.momz <= 0 p.wss_midair = false end if p.wss_squashstyle == 0 if (p.wss_oldstate ~= p.mo.state and P_IsObjectOnGround(p.mo)) or p.mo.state == S_PLAY_BOUNCE_LANDING or p.mo.eflags & MFE_JUSTHITFLOOR p.wss_spritescale = -p.wss_squashforce p.wss_oldstate = p.mo.state end elseif p.wss_squashstyle == 1 and P_IsObjectOnGround(p.mo) local speed = FixedHypot(p.mo.momx, p.mo.momy) if speed ~= 0 local div = 100*FU local squash = FixedMul(FixedDiv(speed, div), p.wss_squashforce) p.wss_spritescale = -min(squash, 29*FU) end end end end addHook("MobjThinker", function(mo) if mo.type == MT_TAILSOVERLAY or mo.type == MT_METALJETFUME if mo.tracer and mo.tracer.valid and mo.tracer.player and mo.tracer.player.valid mo.spritexscale = mo.tracer.spritexscale mo.spriteyscale = mo.tracer.spriteyscale elseif mo.target and mo.target.valid and mo.target.player and mo.target.player.valid mo.spritexscale = mo.target.spritexscale mo.spriteyscale = mo.target.spriteyscale end end end) addHook("PlayerSpawn", function(p) ApplyConfigToPlayer(p) p.wss_spritescale = 0 if not p.wss_config_notified then CONS_Printf(p, "\x82WSS configuration loaded with sucess.") p.wss_config_notified = true end end) addHook("PreThinkFrame", function() for player in players.iterate do WSS_Main(player); end end);