local signposts = {} local antigravdisabled = false local checkedcezboss = false local playimpossible = false local function StandingOnSky(player) local thing = true --If your skies are intentionally not pits, then I guess you can mark that if mapheaderinfo[gamemap].antigravnoskypits != nil then thing = nil end --So I found out that ACZ3 is actually possible --Annoying, but possible if G_BuildMapName(gamemap) == "MAP15" and G_BuildMapTitle(gamemap) == "Arid Canyon" then //thing = nil end if thing != nil then if player.antigrav.wasflipped if player.mo.ceilingrover then if player.mo.ceilingrover.bottompic == "F_SKY1" or player.mo.ceilingrover.bottompic == "PIT" or player.mo.ceilingrover.bottompic == "~PIT" then P_KillMobj(player.mo) end else if player.mo.subsector.sector.ceilingpic == "F_SKY1" or player.mo.subsector.sector.ceilingpic == "PIT" or player.mo.subsector.sector.ceilingpic == "~PIT" then P_KillMobj(player.mo) end end else if player.mo.floorrover then if player.mo.floorrover.toppic == "F_SKY1" or player.mo.floorrover.toppic == "PIT" or player.mo.floorrover.toppic == "~PIT" then P_KillMobj(player.mo) end else if player.mo.subsector.sector.floorpic == "F_SKY1" or player.mo.subsector.sector.floorpic == "PIT" or player.mo.subsector.sector.floorpic == "~PIT" then P_KillMobj(player.mo) end end end end end local function LandOnFloor(player) --So we don't land on the same floor we jumped from if (player.pflags & PF_JUMPED) then return true end --If we were already on the floor, we don't have to land on it again //if P_IsObjectOnGround(player.mo) then return true end --Don't do this in a zoom tube if player.mo.tracer then if player.mo.tracer.valid then return true end end local height = player.mo.z local surface = P_FloorzAtPos(player.mo.x, player.mo.y, player.mo.z, player.mo.height) if player.antigrav.wasflipped height = player.mo.z + player.mo.height surface = P_CeilingzAtPos(player.mo.x, player.mo.y, player.mo.z, player.mo.height) end if abs(height - surface) >= FixedMul(player.mo.scale, 20*FRACUNIT) then return true end if not(player.antigrav.wasflipped and player.mo.momz >= -FRACUNIT or not player.antigrav.wasflipped and player.mo.momz <= FRACUNIT) then return true end StandingOnSky(player) return false end local function LandOnCeiling(player) //if (player.pflags & PF_JUMPED) then return true end if P_IsObjectOnGround(player.mo) then return true end --Don't do this in a zoom tube if player.mo.tracer then if player.mo.tracer.valid then return true end end local height = player.mo.z + player.mo.height local surface = P_CeilingzAtPos(player.mo.x, player.mo.y, player.mo.z, player.mo.height) if player.antigrav.wasflipped height = player.mo.z surface = P_FloorzAtPos(player.mo.x, player.mo.y, player.mo.z, player.mo.height) end if abs(height - surface) >= FixedMul(player.mo.scale, 20*FRACUNIT) then return true end if not(player.antigrav.wasflipped and player.mo.momz <= FRACUNIT or (not player.antigrav.wasflipped) and player.mo.momz >= -FRACUNIT) then return true end player.antigrav.wasflipped = not $ if player.mo.eflags & MFE_VERTICALFLIP then player.mo.eflags = $ & ~MFE_VERTICALFLIP else player.mo.eflags = $ | MFE_VERTICALFLIP end if player.antigrav.wasflipped then player.mo.momz = 4*FRACUNIT else player.mo.momz = -4*FRACUNIT end StandingOnSky(player) return false end COM_AddCommand("antigravflip",function(player) if antigravdisabled == true or checkedcezboss == false then CONS_Printf(player, "Antigrav is currently disabled. Sorry.") return end if player.antigrav == nil then player.antigrav = {} end player.antigrav.wasflipped = not $ if player.mo.eflags & MFE_VERTICALFLIP then player.mo.eflags = $ & ~MFE_VERTICALFLIP else player.mo.eflags = $ | MFE_VERTICALFLIP end end, 0) COM_AddCommand("emergencygrav",function(player) if antigravdisabled == true or checkedcezboss == false then CONS_Printf(player, "Antigrav is currently disabled. Sorry.") return end player.mo.flags = $ & ~MF_NOGRAVITY end, 0) COM_AddCommand("antigravimpossible",function(player) playimpossible = not $ if playimpossible == true then print("Impossible levels will be played with Antigrav enabled. They're probably impossible though.") else print("Impossible levels will be played normally.") end print("Reload the map to apply the change.") end, 0) addHook("MapLoad", function() checkedcezboss = false local foundcezboss = false antigravdisabled = false for mobj in mobjs.iterate() do if mobj.type == MT_SIGN then table.insert(signposts, mobj) end if playimpossible == false then if mobj.type == MT_EGGMOBILE4 and foundcezboss == false then foundcezboss = true print("An Egg Colosseum has been found, disabling Antigrav to make the level possible.") end --Fang is technically possible with a lot of hoping he bounces to your level, as well as waiting. if mobj.type == MT_FANG and foundcezboss == false then foundcezboss = true print("Fang has been found, disabling Antigrav to make the level not overly tedious.") end --Metal Sonic is possible as Fang, but Sonic is better. if mobj.type == MT_METALSONIC_BATTLE and foundcezboss == false then foundcezboss = true print("Metal Sonic has been found, disabling Antigrav to make the level possible.") end end end --It only breaks in ERZ, not the Metal Sonic race. if foundcezboss == false and playimpossible == false then for line in lines.iterate do --The sector-based gravity special if line.special == 1 then foundcezboss = true print("A reverse-gravity sector has been found, disabling Antigrav as to not break your vision.") break end end end checkedcezboss = true antigravdisabled = foundcezboss if antigravdisabled == false or playimpossible == true then for mobj in mobjs.iterate() do --To make THZ's boss actually able to hurt you for the first five hits if mobj.type == MT_GOOP then return end --To make ACZ1 possible if mobj.type == MT_PROXIMITYTNT then return end --To make ACZ2 possible if mobj.type == MT_MINECART then return end if mobj.type == MT_PLAYER then --The player thinker will set the NOGRAVITY flag mobj.player.jumpfactor = skins[mobj.player.skin].jumpfactor*2 else --Here so that BC3 can actually start quickly mobj.flags = $ | MF_NOGRAVITY end end else for player in players.iterate() do player.mo.flags = $ & ~MF_NOGRAVITY end end --This makes FOF's not fall, making CEZ2 impossible, and fixes CEZ1's bridge (in a bad way). //gravity = 0 end) addHook("NetVars", function(network) signposts = network($) antigravdisabled = network($) end) addHook("PlayerSpawn", function(player) player.jumpfactor = skins[player.skin].jumpfactor if antigravdisabled == true or checkedcezboss == false then CONS_Printf(player, "Antigrav is disabled. Check the console for more information.") end if player.mo then if player.mo.valid and player.mo.health then if player.antigrav == nil then player.antigrav = {} end player.antigrav.wasflipped = ((player.mo.flags2 & MF2_OBJECTFLIP) > 0) player.mo.flags = $ | MF_NOGRAVITY end end end) addHook("PlayerThink", function(player) if antigravdisabled == true or checkedcezboss == false then return end if player.mo then if player.playerstate == PST_DEAD then player.antigrav.justspawned = true end if player.mo.valid and player.mo.health then if P_IsObjectOnGround(player.mo) then player.mo.flags = $ | MF_NOGRAVITY end if player.antigrav == nil then player.antigrav = {} end if player.antigrav.justjumped == nil then player.antigrav.justjumped = 1 end if player.antigrav.letgoofjump != true and player.antigrav.letgoofjump != false then player.antigrav.letgoofjump = true end if player.antigrav.jumped != true and player.antigrav.jumped != false then player.antigrav.jumped = false end if player.antigrav.wasflipped != true and player.antigrav.wasflipped != false then player.antigrav.wasflipped = ((player.mo.flags2 & MF2_OBJECTFLIP) > 0) end if player.antigrav.vertflipped != true and player.antigrav.vertflipped != false then //player.antigrav.vertflipped = ((player.mo.flags2 & MF2_OBJECTFLIP) > 0) end if (player.pflags & PF_JUMPED) and player.antigrav.letgoofjump == true and player.antigrav.jumped == false then player.antigrav.justjumped = 0 player.antigrav.jumped = true player.antigrav.letgoofjump = false elseif (player.pflags & ~PF_JUMPED) then player.antigrav.justjumped = $+1 player.antigrav.letgoofjump = true else player.antigrav.justjumped = $+1 end if P_IsObjectOnGround(player.mo) then player.antigrav.jumped = false end --To make levels look cooler if player.antigrav.justjumped == 0 or player.mo.eflags & MFE_SPRUNG then if player.antigrav.justjumped == 0 then player.antigrav.wasflipped = not $ if player.mo.eflags & MFE_VERTICALFLIP then player.mo.eflags = $ & ~MFE_VERTICALFLIP else player.mo.eflags = $ | MFE_VERTICALFLIP end elseif player.mo.momz > 0 then player.antigrav.wasflipped = true player.mo.eflags = $ | MFE_VERTICALFLIP elseif player.mo.momz > 0 then player.antigrav.wasflipped = false player.mo.eflags = $ & ~MFE_VERTICALFLIP end end if LandOnCeiling(player) then LandOnFloor(player) end --Remove other gravity changing effects, since, on their own, they don't actually work player.powers[pw_gravityboots] = 0 if player.antigrav.wasflipped then player.mo.flags2 = $ | MF2_OBJECTFLIP else player.mo.flags2 = $ & ~MF2_OBJECTFLIP end end end end) addHook("MobjThinker", function(mo) if antigravdisabled == true or not checkedcezboss == false then return end if mo then if mo.valid and mo.health then --Flip the sign's gravity when it starts spinning if mo.antigravtriggered == nil then mo.antigravtriggered = true if mo.flags2 & MF2_OBJECTFLIP then mo.flags2 = $ & ~MF2_OBJECTFLIP else mo.flags2 = $|MF2_OBJECTFLIP end end end end end, MT_SIGN)