Merge branch 'expos-sky' into 'next'

Expose P_CheckSkyHit to Lua

See merge request STJr/SRB2!2000
This commit is contained in:
Krabs 2023-11-01 17:47:42 +00:00
commit 5ac297475c
3 changed files with 27 additions and 10 deletions

View file

@ -1031,6 +1031,20 @@ static int lib_pRailThinker(lua_State *L)
return 1; 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) static int lib_pXYMovement(lua_State *L)
{ {
mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ)); mobj_t *actor = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
@ -4206,6 +4220,7 @@ static luaL_Reg lib[] = {
{"P_CreateFloorSpriteSlope",lib_pCreateFloorSpriteSlope}, {"P_CreateFloorSpriteSlope",lib_pCreateFloorSpriteSlope},
{"P_RemoveFloorSpriteSlope",lib_pRemoveFloorSpriteSlope}, {"P_RemoveFloorSpriteSlope",lib_pRemoveFloorSpriteSlope},
{"P_RailThinker",lib_pRailThinker}, {"P_RailThinker",lib_pRailThinker},
{"P_CheckSkyHit",lib_pCheckSkyHit},
{"P_XYMovement",lib_pXYMovement}, {"P_XYMovement",lib_pXYMovement},
{"P_RingXYMovement",lib_pRingXYMovement}, {"P_RingXYMovement",lib_pRingXYMovement},
{"P_SceneryXYMovement",lib_pSceneryXYMovement}, {"P_SceneryXYMovement",lib_pSceneryXYMovement},

View file

@ -303,6 +303,7 @@ void P_RunOverlays(void);
void P_HandleMinecartSegments(mobj_t *mobj); void P_HandleMinecartSegments(mobj_t *mobj);
void P_MobjThinker(mobj_t *mobj); void P_MobjThinker(mobj_t *mobj);
boolean P_RailThinker(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_PushableThinker(mobj_t *mobj);
void P_SceneryThinker(mobj_t *mobj); void P_SceneryThinker(mobj_t *mobj);

View file

@ -1779,14 +1779,15 @@ bustupdone:
// //
// P_CheckSkyHit // P_CheckSkyHit
// //
static boolean P_CheckSkyHit(mobj_t *mo) boolean P_CheckSkyHit(mobj_t *mo, line_t *line)
{ {
if (ceilingline && ceilingline->backsector if (line && (line->special == 41 ||
&& ceilingline->backsector->ceilingpic == skyflatnum (line->backsector
&& ceilingline->frontsector && line->backsector->ceilingpic == skyflatnum
&& ceilingline->frontsector->ceilingpic == skyflatnum && line->frontsector
&& (mo->z >= ceilingline->frontsector->ceilingheight && line->frontsector->ceilingpic == skyflatnum
|| mo->z >= ceilingline->backsector->ceilingheight)) && (mo->z >= line->frontsector->ceilingheight
|| mo->z >= line->backsector->ceilingheight))))
return true; return true;
return false; return false;
} }
@ -1893,7 +1894,7 @@ void P_XYMovement(mobj_t *mo)
mo->fuse += ((5 - mo->threshold) * TICRATE); mo->fuse += ((5 - mo->threshold) * TICRATE);
// Check for hit against sky here // Check for hit against sky here
if (P_CheckSkyHit(mo)) if (P_CheckSkyHit(mo, ceilingline))
{ {
// Hack to prevent missiles exploding // Hack to prevent missiles exploding
// against the sky. // against the sky.
@ -1913,7 +1914,7 @@ void P_XYMovement(mobj_t *mo)
mo->flags &= ~MF_STICKY; //Don't check again! mo->flags &= ~MF_STICKY; //Don't check again!
// Check for hit against sky here // Check for hit against sky here
if (P_CheckSkyHit(mo)) if (P_CheckSkyHit(mo, ceilingline))
{ {
// Hack to prevent missiles exploding // Hack to prevent missiles exploding
// against the sky. // against the sky.
@ -1972,7 +1973,7 @@ void P_XYMovement(mobj_t *mo)
else if (mo->flags & MF_MISSILE) else if (mo->flags & MF_MISSILE)
{ {
// explode a missile // explode a missile
if (P_CheckSkyHit(mo)) if (P_CheckSkyHit(mo, ceilingline))
{ {
// Hack to prevent missiles exploding // Hack to prevent missiles exploding
// against the sky. // against the sky.