diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 7f9d6dd95..ecd3e2fa8 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1031,6 +1031,20 @@ static int lib_pRailThinker(lua_State *L) return 1; } +static int lib_pCheckSkyHit(lua_State *L) +{ + mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); + line_t *line = *((line_t **)luaL_checkudata(L, 2, META_LINE)); + //HUDSAFE + INLEVEL + if (!mobj) + return LUA_ErrInvalid(L, "mobj_t"); + if (!line) + return LUA_ErrInvalid(L, "line_t"); + lua_pushboolean(L, P_CheckSkyHit(mobj, line)); + return 1; +} + static int lib_pXYMovement(lua_State *L) { mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); @@ -4206,6 +4220,7 @@ static luaL_Reg lib[] = { {"P_CreateFloorSpriteSlope",lib_pCreateFloorSpriteSlope}, {"P_RemoveFloorSpriteSlope",lib_pRemoveFloorSpriteSlope}, {"P_RailThinker",lib_pRailThinker}, + {"P_CheckSkyHit",lib_pCheckSkyHit}, {"P_XYMovement",lib_pXYMovement}, {"P_RingXYMovement",lib_pRingXYMovement}, {"P_SceneryXYMovement",lib_pSceneryXYMovement}, diff --git a/src/p_local.h b/src/p_local.h index a6df3b7f2..c26c09860 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -303,6 +303,7 @@ void P_RunOverlays(void); void P_HandleMinecartSegments(mobj_t *mobj); void P_MobjThinker(mobj_t *mobj); boolean P_RailThinker(mobj_t *mobj); +boolean P_CheckSkyHit(mobj_t *mo, line_t *line); void P_PushableThinker(mobj_t *mobj); void P_SceneryThinker(mobj_t *mobj); diff --git a/src/p_mobj.c b/src/p_mobj.c index 8bc74e3b8..4b17b7c11 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -1779,14 +1779,15 @@ bustupdone: // // P_CheckSkyHit // -static boolean P_CheckSkyHit(mobj_t *mo) +boolean P_CheckSkyHit(mobj_t *mo, line_t *line) { - if (ceilingline && ceilingline->backsector - && ceilingline->backsector->ceilingpic == skyflatnum - && ceilingline->frontsector - && ceilingline->frontsector->ceilingpic == skyflatnum - && (mo->z >= ceilingline->frontsector->ceilingheight - || mo->z >= ceilingline->backsector->ceilingheight)) + if (line && (line->special == 41 || + (line->backsector + && line->backsector->ceilingpic == skyflatnum + && line->frontsector + && line->frontsector->ceilingpic == skyflatnum + && (mo->z >= line->frontsector->ceilingheight + || mo->z >= line->backsector->ceilingheight)))) return true; return false; } @@ -1893,7 +1894,7 @@ void P_XYMovement(mobj_t *mo) mo->fuse += ((5 - mo->threshold) * TICRATE); // Check for hit against sky here - if (P_CheckSkyHit(mo)) + if (P_CheckSkyHit(mo, ceilingline)) { // Hack to prevent missiles exploding // against the sky. @@ -1913,7 +1914,7 @@ void P_XYMovement(mobj_t *mo) mo->flags &= ~MF_STICKY; //Don't check again! // Check for hit against sky here - if (P_CheckSkyHit(mo)) + if (P_CheckSkyHit(mo, ceilingline)) { // Hack to prevent missiles exploding // against the sky. @@ -1972,7 +1973,7 @@ void P_XYMovement(mobj_t *mo) else if (mo->flags & MF_MISSILE) { // explode a missile - if (P_CheckSkyHit(mo)) + if (P_CheckSkyHit(mo, ceilingline)) { // Hack to prevent missiles exploding // against the sky.