local meteors = CV_RegisterVar({"meteors", "On", CV_NETVAR, CV_OnOff}) local meteorsFallIntensity = CV_RegisterVar({"intensity", "300", CV_NETVAR, {MIN = 1, MAX = 1000}}) local meteorsFallDistance = CV_RegisterVar({"distance", "4096", CV_NETVAR, CV_Natural}) local quake = CV_RegisterVar({"quake", "Off", CV_NETVAR, CV_OnOff}) local continuousMeteorsFall = CV_RegisterVar({"continuous", "On", CV_NETVAR, CV_OnOff}) local falling = false local nextMeteorsFall = P_RandomRange(1, 256) local function meteorsFall() if meteors.value if not continuousMeteorsFall.value nextMeteorsFall = $1 - 1 if nextMeteorsFall == 0 falling = not falling if falling nextMeteorsFall = P_RandomRange(64, 1024) else nextMeteorsFall = P_RandomRange(32, 256) end end if not falling return end end for _ = 1, meteorsFallIntensity.value if quake.value P_StartQuake(meteorsFallIntensity.value * FRACUNIT / 40, 1) end local x, y = P_RandomRange(-32768, 32767) * FRACUNIT, P_RandomRange(-32768, 32767) * FRACUNIT for player in players.iterate if not player.mo continue end if FixedHypot(x - player.mo.x, y - player.mo.y) <= meteorsFallDistance.value * FRACUNIT local mobj = P_SpawnMobj(x, y, player.mo.subsector.sector.ceilingheight, MT_FALLINGROCK) mobj.scale = FRACUNIT + P_Random() * FRACUNIT / 64 mobj.z = mobj.subsector.sector.ceilingheight - mobj.height if P_CheckPosition(mobj, x, y, mobj.z) if mobj.subsector.sector.ceilingpic == "F_SKY1\0\0" if mobj.subsector.sector.ceilingheight - mobj.subsector.sector.floorheight >= mobj.height mobj.momz = -16 * FRACUNIT - P_Random() * (FRACUNIT / 16) else P_RemoveMobj(mobj) end else P_RemoveMobj(mobj) end else P_RemoveMobj(mobj) end break end end end end end local function mapChange() falling = false nextMeteorsFall = P_RandomRange(1, 256) end addHook("ThinkFrame", meteorsFall) addHook("MapChange", mapChange)