P_CeilingzAtPos
This commit is contained in:
1 parent
3a0419703d
commit
91c943263e
3 files changed
+61
-11
No files matched your search
@@ -1145,6 +1145,17 @@ static int lib_pFloorzAtPos(lua_State *L)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_pCeilingzAtPos(lua_State *L)
|
||||
{
|
||||
fixed_t x = luaL_checkfixed(L, 1);
|
||||
fixed_t y = luaL_checkfixed(L, 2);
|
||||
fixed_t z = luaL_checkfixed(L, 3);
|
||||
fixed_t height = luaL_checkfixed(L, 4);
|
||||
//HUDSAFE
|
||||
lua_pushfixed(L, P_CeilingzAtPos(x, y, z, height));
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int lib_pDoSpring(lua_State *L)
|
||||
{
|
||||
mobj_t *spring = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||
@@ -3099,6 +3110,7 @@ static luaL_Reg lib[] = {
|
||||
{"P_CheckHoopPosition",lib_pCheckHoopPosition},
|
||||
{"P_RadiusAttack",lib_pRadiusAttack},
|
||||
{"P_FloorzAtPos",lib_pFloorzAtPos},
|
||||
{"P_CeilingzAtPos",lib_pCeilingzAtPos},
|
||||
{"P_DoSpring",lib_pDoSpring},
|
||||
|
||||
// p_inter
|
||||
|
||||
@@ -371,6 +371,7 @@ void P_Initsecnode(void);
|
||||
void P_RadiusAttack(mobj_t *spot, mobj_t *source, fixed_t damagedist);
|
||||
|
||||
fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height);
|
||||
fixed_t P_CeilingzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height);
|
||||
boolean PIT_PushableMoved(mobj_t *thing);
|
||||
|
||||
boolean P_DoSpring(mobj_t *spring, mobj_t *object);
|
||||
|
||||
+48
-11
@@ -4606,10 +4606,7 @@ void P_MapEnd(void)
|
||||
fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
|
||||
{
|
||||
sector_t *sec = R_PointInSubsector(x, y)->sector;
|
||||
fixed_t floorz = sec->floorheight;
|
||||
|
||||
if (sec->f_slope)
|
||||
floorz = P_GetZAt(sec->f_slope, x, y);
|
||||
fixed_t floorz = P_GetSectorFloorZAt(sec, x, y);
|
||||
|
||||
// Intercept the stupid 'fall through 3dfloors' bug Tails 03-17-2002
|
||||
if (sec->ffloors)
|
||||
@@ -4626,13 +4623,8 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
|
||||
if ((!(rover->flags & FF_SOLID || rover->flags & FF_QUICKSAND) || (rover->flags & FF_SWIMMABLE)))
|
||||
continue;
|
||||
|
||||
topheight = *rover->topheight;
|
||||
bottomheight = *rover->bottomheight;
|
||||
|
||||
if (*rover->t_slope)
|
||||
topheight = P_GetZAt(*rover->t_slope, x, y);
|
||||
if (*rover->b_slope)
|
||||
bottomheight = P_GetZAt(*rover->b_slope, x, y);
|
||||
topheight = P_GetFFloorTopZAt (rover, x, y);
|
||||
bottomheight = P_GetFFloorBottomZAt(rover, x, y);
|
||||
|
||||
if (rover->flags & FF_QUICKSAND)
|
||||
{
|
||||
@@ -4653,3 +4645,48 @@ fixed_t P_FloorzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
|
||||
|
||||
return floorz;
|
||||
}
|
||||
|
||||
// P_CeilingZAtPos
|
||||
// Returns the ceilingz of the XYZ position
|
||||
fixed_t P_CeilingzAtPos(fixed_t x, fixed_t y, fixed_t z, fixed_t height)
|
||||
{
|
||||
sector_t *sec = R_PointInSubsector(x, y)->sector;
|
||||
fixed_t ceilingz = P_GetSectorCeilingZAt(sec, x, y);
|
||||
|
||||
if (sec->ffloors)
|
||||
{
|
||||
ffloor_t *rover;
|
||||
fixed_t delta1, delta2, thingtop = z + height;
|
||||
|
||||
for (rover = sec->ffloors; rover; rover = rover->next)
|
||||
{
|
||||
fixed_t topheight, bottomheight;
|
||||
if (!(rover->flags & FF_EXISTS))
|
||||
continue;
|
||||
|
||||
if ((!(rover->flags & FF_SOLID || rover->flags & FF_QUICKSAND) || (rover->flags & FF_SWIMMABLE)))
|
||||
continue;
|
||||
|
||||
topheight = P_GetFFloorTopZAt (rover, x, y);
|
||||
bottomheight = P_GetFFloorBottomZAt(rover, x, y);
|
||||
|
||||
if (rover->flags & FF_QUICKSAND)
|
||||
{
|
||||
if (thingtop > bottomheight && topheight > z)
|
||||
{
|
||||
if (ceilingz > thingtop)
|
||||
ceilingz = thingtop;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
delta1 = z - (bottomheight + ((topheight - bottomheight)/2));
|
||||
delta2 = thingtop - (bottomheight + ((topheight - bottomheight)/2));
|
||||
if (bottomheight < ceilingz && abs(delta1) > abs(delta2))
|
||||
ceilingz = bottomheight;
|
||||
}
|
||||
}
|
||||
|
||||
return ceilingz;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user