mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2024-11-15 01:01:33 +00:00
Added PlayerThink hook
This commit is contained in:
parent
14f4fa2e9c
commit
87b816e408
3 changed files with 26 additions and 1 deletions
|
@ -51,6 +51,7 @@ enum hook {
|
|||
hook_PlayerCanDamage,
|
||||
hook_PlayerQuit,
|
||||
hook_IntermissionThinker,
|
||||
hook_PlayerThink,
|
||||
|
||||
hook_MAX // last hook
|
||||
};
|
||||
|
@ -93,5 +94,6 @@ boolean LUAh_FollowMobj(player_t *player, mobj_t *mobj); // Hook for P_PlayerAft
|
|||
UINT8 LUAh_PlayerCanDamage(player_t *player, mobj_t *mobj); // Hook for P_PlayerCanDamage
|
||||
void LUAh_PlayerQuit(player_t *plr, int reason); // Hook for player quitting
|
||||
void LUAh_IntermissionThinker(void); // Hook for Y_Ticker
|
||||
#define LUAh_PlayerThink(player) LUAh_PlayerHook(player, hook_PlayerThink) // Hook for P_PlayerThink
|
||||
|
||||
#endif
|
||||
|
|
|
@ -62,6 +62,7 @@ const char *const hookNames[hook_MAX+1] = {
|
|||
"PlayerCanDamage",
|
||||
"PlayerQuit",
|
||||
"IntermissionThinker",
|
||||
"PlayerThink",
|
||||
NULL
|
||||
};
|
||||
|
||||
|
@ -205,6 +206,7 @@ static int lib_addHook(lua_State *L)
|
|||
case hook_PlayerCanDamage:
|
||||
case hook_ShieldSpawn:
|
||||
case hook_ShieldSpecial:
|
||||
case hook_PlayerThink:
|
||||
lastp = &playerhooks;
|
||||
break;
|
||||
case hook_LinedefExecute:
|
||||
|
|
23
src/p_user.c
23
src/p_user.c
|
@ -11313,7 +11313,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
|
||||
|
@ -11414,7 +11419,12 @@ void P_PlayerThink(player_t *player)
|
|||
player->lives = 0;
|
||||
|
||||
if (player->playerstate == PST_DEAD)
|
||||
{
|
||||
#ifdef HAVE_BLUA
|
||||
LUAh_PlayerThink(player);
|
||||
return;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -11533,7 +11543,9 @@ void P_PlayerThink(player_t *player)
|
|||
{
|
||||
player->mo->flags2 &= ~MF2_SHADOW;
|
||||
P_DeathThink(player);
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
LUAh_PlayerThink(player);
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -11574,7 +11586,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.
|
||||
|
@ -11675,6 +11692,10 @@ void P_PlayerThink(player_t *player)
|
|||
P_MovePlayer(player);
|
||||
}
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
LUAh_PlayerThink(player);
|
||||
#endif
|
||||
|
||||
if (!player->mo)
|
||||
return; // P_MovePlayer removed player->mo.
|
||||
|
||||
|
|
Loading…
Reference in a new issue