diff --git a/src/lua_hook.h b/src/lua_hook.h index 61e945248..0ef21490e 100644 --- a/src/lua_hook.h +++ b/src/lua_hook.h @@ -57,6 +57,7 @@ enum hook { hook_TeamSwitch, hook_ViewpointSwitch, hook_SeenPlayer, + hook_PlayerThink, hook_MAX // last hook }; @@ -108,5 +109,6 @@ UINT8 LUAh_ViewpointSwitch(player_t *player, player_t *newdisplayplayer, boolean #ifdef SEENAMES boolean LUAh_SeenPlayer(player_t *player, player_t *seenfriend); // Hook for MT_NAMECHECK #endif +#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink #endif diff --git a/src/lua_hooklib.c b/src/lua_hooklib.c index 56a4fa3f7..e2c41f54f 100644 --- a/src/lua_hooklib.c +++ b/src/lua_hooklib.c @@ -68,6 +68,7 @@ const char *const hookNames[hook_MAX+1] = { "TeamSwitch", "ViewpointSwitch", "SeenPlayer", + "PlayerThink", NULL }; @@ -216,6 +217,7 @@ static int lib_addHook(lua_State *L) case hook_SeenPlayer: case hook_ShieldSpawn: case hook_ShieldSpecial: + case hook_PlayerThink: lastp = &playerhooks; break; case hook_LinedefExecute: diff --git a/src/p_user.c b/src/p_user.c index b40e647b6..2bd856481 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11572,7 +11572,12 @@ void P_PlayerThink(player_t *player) player->playerstate = PST_REBORN; } if (player->playerstate == PST_REBORN) + { +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); +#endif return; + } } #ifdef SEENAMES @@ -11673,7 +11678,12 @@ void P_PlayerThink(player_t *player) player->lives = 0; if (player->playerstate == PST_DEAD) + { +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); +#endif return; + } } } @@ -11792,7 +11802,9 @@ void P_PlayerThink(player_t *player) { player->mo->flags2 &= ~MF2_SHADOW; P_DeathThink(player); - +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); +#endif return; } @@ -11833,7 +11845,12 @@ void P_PlayerThink(player_t *player) if (player->spectator && cmd->buttons & BT_ATTACK && !player->powers[pw_flashing] && G_GametypeHasSpectators()) { if (P_SpectatorJoinGame(player)) + { +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); +#endif return; // player->mo was removed. + } } // Even if not NiGHTS, pull in nearby objects when walking around as John Q. Elliot. @@ -11935,7 +11952,12 @@ void P_PlayerThink(player_t *player) } if (!player->mo) + { +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); +#endif return; // P_MovePlayer removed player->mo. + } // deez New User eXperiences. { @@ -12367,6 +12389,11 @@ void P_PlayerThink(player_t *player) dashmode = 0; } #undef dashmode + +#ifdef HAVE_BLUA + LUAh_PlayerThink(player); +#endif + /* // Colormap verification {