local function CheckAndCrumble2(mo, sec)
  for fof in sec.ffloors()
    if not (fof.flags & FF_EXISTS) continue end -- Does it exist?
    if not (fof.flags & FF_BUSTUP) continue end -- Is it bustable?
    
    if mo.z + mo.momz + mo.height < fof.bottomheight continue end -- Are we too low?
    if mo.z + mo.momz > fof.topheight continue end -- Are we too high?

    -- Check for whatever else you may want to    

    EV_CrumbleChain(fof) -- Crumble
  end
end

addHook("PlayerThink", function(p)
  if not p.mo return end
  if p.mo.skin != "bowser" return end
  if p.mo.state != S_PLAY_BOWSER_MELEE and p.mo.state != S_PLAY_BOWSER_STOMP_END return end
	CheckAndCrumble2(p.mo, p.mo.subsector.sector)
end)

addHook("MobjLineCollide", function(mo, line)
  if not mo.player return end
  if mo.skin != "bowser" return end
  if mo.state != S_PLAY_BOWSER_MELEE and mo.state != S_PLAY_BOWSER_STOMP_END return end
  for _, sec in ipairs({line.frontsector, line.backsector})
    CheckAndCrumble2(mo, sec)
  end
end, MT_PLAYER)
local spikekiller = function(thing, tmthing)
	if not (thing and thing.valid and tmthing and tmthing.valid) return end
	if tmthing.player and tmthing.skin == "bowser" and ((tmthing.state == S_PLAY_BOWSER_MELEE or tmthing.state == S_PLAY_BOWSER_STOMP_END or (tmthing.player.pflags & PF_SPINNING)))
	and (abs(thing.z - tmthing.z) <= 60*tmthing.scale)
		if tmthing.z >= thing.z-tmthing.height and tmthing.z <= thing.z+thing.height+tmthing.height
			P_KillMobj(thing, tmthing)
			return true
		end
	end
end
addHook("MobjCollide", function(thing, tmthing) spikekiller(thing, tmthing) end, MT_SPIKE)
addHook("MobjCollide", function(thing, tmthing) spikekiller(thing, tmthing) end, MT_WALLSPIKE)