function scr_plat_snap_to_ground() { var _ground = ground; if (!instance_exists(_ground)) exit; if (_ground.is_slope) { if (_ground.plattype == 0) { var _m; with (_ground) _m = (y2 - y1) / (x2 - x1); var _b = _ground.y1; var _floorX = bbox_right - _ground.x1; if (_ground.image_xscale < 0) _floorX = bbox_left - _ground.x1; floorY = (_m * _floorX) + _b; floorY = clamp(floorY, _ground.y2, _ground.y1); var _ydist = bbox_bottom_r + 2; var _newY = floorY - _ydist; var _solid = instance_place(x, _newY, obj_plat_block); if (!instance_exists(_solid)) y = _newY; } if (_ground.plattype == 1) { var _h; with (_ground) _h = y2 - y1; var _floorX = x - _ground.x1; floorY = _ground.y - (sin((pi * _floorX) / abs(_ground.x1 - _ground.x2)) * abs(_h)); var _newY = floorY - bbox_bottom_r; var _solid = instance_place(x, _newY, obj_plat_block); if (!instance_exists(_solid)) y = _newY; } } else { var _newY = y; var _offset = bbox_bottom_r; if (!ground.quicksand) { _newY = _ground.bbox_top - _offset - 1; if (_ground.is_entity) y = _ground.y - _ground.bbox_top_r - _offset - 1; } else { _newY = _ground.bbox_top - bbox_bottom_r - 1; } if (!place_meeting(x, _newY, obj_plat_block)) y = _newY; } }