Expose P_CheckSkyHit to Lua

This commit is contained in:
SMS Alfredo 2023-05-31 23:03:22 -05:00
parent d6d424f102
commit 7a7cee7ca5
3 changed files with 27 additions and 10 deletions

View file

@ -1030,6 +1030,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));
@ -4059,6 +4073,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},

View file

@ -297,6 +297,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);

View file

@ -1753,14 +1753,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;
}
@ -1867,7 +1868,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.
@ -1887,7 +1888,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.
@ -1946,7 +1947,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.