diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 3f62ef890..e9596fa9c 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1113,6 +1113,16 @@ static int lib_pPlayerCanDamage(lua_State *L) return 1; } +static int lib_pPlayerFullbright(lua_State *L) +{ + player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); + INLEVEL + if (!player) + return LUA_ErrInvalid(L, "player_t"); + lua_pushboolean(L, P_PlayerFullbright(player)); + return 1; +} + static int lib_pIsObjectInGoop(lua_State *L) { @@ -3386,6 +3396,7 @@ static luaL_Reg lib[] = { {"P_DoPlayerPain",lib_pDoPlayerPain}, {"P_ResetPlayer",lib_pResetPlayer}, {"P_PlayerCanDamage",lib_pPlayerCanDamage}, + {"P_PlayerFullbright",lib_pPlayerFullbright}, {"P_IsObjectInGoop",lib_pIsObjectInGoop}, {"P_IsObjectOnGround",lib_pIsObjectOnGround}, {"P_InSpaceSector",lib_pInSpaceSector}, diff --git a/src/p_local.h b/src/p_local.h index b6c34f357..4077fecf6 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -142,6 +142,7 @@ void P_SetPlayerAngle(player_t *player, angle_t angle); angle_t P_GetLocalAngle(player_t *player); void P_SetLocalAngle(player_t *player, angle_t angle); void P_ForceLocalAngle(player_t *player, angle_t angle); +boolean P_PlayerFullbright(player_t *player); boolean P_IsObjectInGoop(mobj_t *mo); boolean P_IsObjectOnGround(mobj_t *mo); diff --git a/src/p_mobj.c b/src/p_mobj.c index 6f3f53559..9cd5667da 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -442,7 +442,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state) mobj->sprite2 = spr2; mobj->frame = frame|(st->frame&~FF_FRAMEMASK); - if (player->powers[pw_super] || (player->powers[pw_carry] == CR_NIGHTSMODE && (player->charflags & (SF_SUPER|SF_NONIGHTSSUPER)) == SF_SUPER)) // Super colours? Super bright! + if (P_PlayerFullbright(player)) mobj->frame |= FF_FULLBRIGHT; } // Regular sprites diff --git a/src/p_user.c b/src/p_user.c index 679f4064b..8b8bf1714 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -7975,20 +7975,13 @@ void P_MovePlayer(player_t *player) // Locate the capsule for this mare. else if (maptol & TOL_NIGHTS) { - if ((player->powers[pw_carry] == CR_NIGHTSMODE) - && (player->exiting - || !(player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1] - && player->mo->state < &states[S_PLAY_NIGHTS_TRANS6]))) // Note the < instead of <= + if (P_PlayerFullbright(player)) { - skin_t *skin = ((skin_t *)(player->mo->skin)); - if (( skin->flags & (SF_SUPER|SF_NONIGHTSSUPER) ) == SF_SUPER) - { - player->mo->color = skin->supercolor - + ((player->nightstime == player->startedtime) - ? 4 - : abs((((signed)leveltime >> 1) % 9) - 4)); // This is where super flashing is handled. - G_GhostAddColor(GHC_SUPER); - } + player->mo->color = ((skin_t *)player->mo->skin)->supercolor + + ((player->nightstime == player->startedtime) + ? 4 + : abs((((signed)leveltime >> 1) % 9) - 4)); // This is where super flashing is handled. + G_GhostAddColor(GHC_SUPER); } if (!player->capsule && !player->bonustime) @@ -12895,3 +12888,12 @@ void P_ForceLocalAngle(player_t *player, angle_t angle) else if (player == &players[secondarydisplayplayer]) localangle2 = angle; } + +boolean P_PlayerFullbright(player_t *player) +{ + return (player->powers[pw_super] + || ((player->powers[pw_carry] == CR_NIGHTSMODE && (((skin_t *)player->mo->skin)->flags & (SF_SUPER|SF_NONIGHTSSUPER)) == SF_SUPER) // Super colours? Super bright! + && (player->exiting + || !(player->mo->state >= &states[S_PLAY_NIGHTS_TRANS1] + && player->mo->state < &states[S_PLAY_NIGHTS_TRANS6])))); // Note the < instead of <= +}