Added PlayerThink hook

This commit is contained in:
Zachary McAlpin 2019-12-14 15:28:24 -06:00 committed by James R
parent a5db4ca572
commit 5921d17cc0
3 changed files with 23 additions and 1 deletions

View file

@ -46,6 +46,7 @@ enum hook {
hook_HurtMsg, hook_HurtMsg,
hook_PlayerSpawn, hook_PlayerSpawn,
hook_PlayerQuit, hook_PlayerQuit,
hook_PlayerThink,
hook_MusicChange, hook_MusicChange,
hook_ShouldSpin, //SRB2KART hook_ShouldSpin, //SRB2KART
hook_ShouldExplode, //SRB2KART hook_ShouldExplode, //SRB2KART
@ -110,5 +111,6 @@ boolean LUAh_PlayerCmd(player_t *player, ticcmd_t *cmd); // Allows to write to p
void LUAh_IntermissionThinker(void); // Hook for Y_Ticker void LUAh_IntermissionThinker(void); // Hook for Y_Ticker
void LUAh_VoteThinker(void); // Hook for Y_VoteTicker void LUAh_VoteThinker(void); // Hook for Y_VoteTicker
#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink
#endif #endif

View file

@ -57,6 +57,7 @@ const char *const hookNames[hook_MAX+1] = {
"HurtMsg", "HurtMsg",
"PlayerSpawn", "PlayerSpawn",
"PlayerQuit", "PlayerQuit",
"PlayerThink",
"MusicChange", "MusicChange",
"ShouldSpin", "ShouldSpin",
"ShouldExplode", "ShouldExplode",
@ -208,6 +209,7 @@ static int lib_addHook(lua_State *L)
case hook_SpinSpecial: case hook_SpinSpecial:
case hook_JumpSpinSpecial: case hook_JumpSpinSpecial:
case hook_PlayerSpawn: case hook_PlayerSpawn:
case hook_PlayerThink:
lastp = &playerhooks; lastp = &playerhooks;
break; break;
case hook_LinedefExecute: case hook_LinedefExecute:

View file

@ -8244,7 +8244,12 @@ void P_PlayerThink(player_t *player)
player->playerstate = PST_REBORN; player->playerstate = PST_REBORN;
} }
if (player->playerstate == PST_REBORN) if (player->playerstate == PST_REBORN)
{
#ifdef HAVE_BLUA
LUAh_PlayerThink(player);
#endif
return; return;
}
} }
#ifdef SEENAMES #ifdef SEENAMES
@ -8368,7 +8373,12 @@ void P_PlayerThink(player_t *player)
P_DoTimeOver(player); P_DoTimeOver(player);
if (player->playerstate == PST_DEAD) if (player->playerstate == PST_DEAD)
{
#ifdef HAVE_BLUA
LUAh_PlayerThink(player);
#endif
return; return;
}
} }
} }
@ -8432,7 +8442,9 @@ void P_PlayerThink(player_t *player)
else else
player->mo->flags2 &= ~MF2_SHADOW; player->mo->flags2 &= ~MF2_SHADOW;
P_DeathThink(player); P_DeathThink(player);
#ifdef HAVE_BLUA
LUAh_PlayerThink(player);
#endif
return; return;
} }
@ -8566,6 +8578,12 @@ void P_PlayerThink(player_t *player)
} }
else else
P_MovePlayer(player); P_MovePlayer(player);
}
#ifdef HAVE_BLUA
LUAh_PlayerThink(player);
#endif
if (!player->mo) if (!player->mo)
return; // P_MovePlayer removed player->mo. return; // P_MovePlayer removed player->mo.