Expose FollowMobj-related functions

This commit is contained in:
SMS Alfredo 2023-05-31 22:28:53 -05:00
parent d6d424f102
commit 16e44e1b6e
3 changed files with 76 additions and 23 deletions

View file

@ -1714,6 +1714,48 @@ static int lib_pSwitchShield(lua_State *L)
return 0; return 0;
} }
static int lib_pDoTailsOverlay(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
mobj_t *tails = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
NOHUD
INLEVEL
if (!player)
return LUA_ErrInvalid(L, "player_t");
if (!tails)
return LUA_ErrInvalid(L, "mobj_t");
P_DoTailsOverlay(player, tails);
return 0;
}
static int lib_pDoMetalJetFume(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
mobj_t *fume = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
NOHUD
INLEVEL
if (!player)
return LUA_ErrInvalid(L, "player_t");
if (!fume)
return LUA_ErrInvalid(L, "mobj_t");
P_DoMetalJetFume(player, fume);
return 0;
}
static int lib_pDoFollowMobj(lua_State *L)
{
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
mobj_t *followmobj = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
NOHUD
INLEVEL
if (!player)
return LUA_ErrInvalid(L, "player_t");
if (!followmobj)
return LUA_ErrInvalid(L, "mobj_t");
P_DoFollowMobj(player, followmobj);
return 0;
}
static int lib_pPlayerCanEnterSpinGaps(lua_State *L) static int lib_pPlayerCanEnterSpinGaps(lua_State *L)
{ {
player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER));
@ -4115,6 +4157,9 @@ static luaL_Reg lib[] = {
{"P_SpawnSpinMobj",lib_pSpawnSpinMobj}, {"P_SpawnSpinMobj",lib_pSpawnSpinMobj},
{"P_Telekinesis",lib_pTelekinesis}, {"P_Telekinesis",lib_pTelekinesis},
{"P_SwitchShield",lib_pSwitchShield}, {"P_SwitchShield",lib_pSwitchShield},
{"P_DoTailsOverlay",lib_pDoTailsOverlay},
{"P_DoMetalJetFume",lib_pDoMetalJetFume},
{"P_DoFollowMobj",lib_pDoFollowMobj},
{"P_PlayerCanEnterSpinGaps",lib_pPlayerCanEnterSpinGaps}, {"P_PlayerCanEnterSpinGaps",lib_pPlayerCanEnterSpinGaps},
{"P_PlayerShouldUseSpinHeight",lib_pPlayerShouldUseSpinHeight}, {"P_PlayerShouldUseSpinHeight",lib_pPlayerShouldUseSpinHeight},

View file

@ -213,6 +213,10 @@ void P_SpawnThokMobj(player_t *player);
void P_SpawnSpinMobj(player_t *player, mobjtype_t type); void P_SpawnSpinMobj(player_t *player, mobjtype_t type);
void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range); void P_Telekinesis(player_t *player, fixed_t thrust, fixed_t range);
void P_DoTailsOverlay(player_t *player, mobj_t *tails);
void P_DoMetalJetFume(player_t *player, mobj_t *fume);
void P_DoFollowMobj(player_t *player, mobj_t *followmobj);
void P_PlayLivesJingle(player_t *player); void P_PlayLivesJingle(player_t *player);
#define P_PlayRinglossSound(s) S_StartSound(s, (mariomode) ? sfx_mario8 : sfx_altow1 + P_RandomKey(4)); #define P_PlayRinglossSound(s) S_StartSound(s, (mariomode) ? sfx_mario8 : sfx_altow1 + P_RandomKey(4));
#define P_PlayDeathSound(s) S_StartSound(s, sfx_altdi1 + P_RandomKey(4)); #define P_PlayDeathSound(s) S_StartSound(s, sfx_altdi1 + P_RandomKey(4));

View file

@ -11103,7 +11103,7 @@ static void P_MinecartThink(player_t *player)
} }
// Handle Tails' fluff // Handle Tails' fluff
static void P_DoTailsOverlay(player_t *player, mobj_t *tails) void P_DoTailsOverlay(player_t *player, mobj_t *tails)
{ {
// init... // init...
boolean smilesonground = P_IsObjectOnGround(player->mo); boolean smilesonground = P_IsObjectOnGround(player->mo);
@ -11308,7 +11308,7 @@ static void P_DoTailsOverlay(player_t *player, mobj_t *tails)
} }
// Metal Sonic's jet fume // Metal Sonic's jet fume
static void P_DoMetalJetFume(player_t *player, mobj_t *fume) void P_DoMetalJetFume(player_t *player, mobj_t *fume)
{ {
static const UINT8 FUME_SKINCOLORS[] = static const UINT8 FUME_SKINCOLORS[] =
{ {
@ -11439,6 +11439,30 @@ static void P_DoMetalJetFume(player_t *player, mobj_t *fume)
P_SpawnGhostMobj(fume); P_SpawnGhostMobj(fume);
} }
// Handle Followmobj behavior
void P_DoFollowMobj(player_t *player, mobj_t *followmobj)
{
if (LUAh_FollowMobj(player, followmobj) || P_MobjWasRemoved(followmobj))
{;}
else
{
switch (followmobj->type)
{
case MT_TAILSOVERLAY: // c:
P_DoTailsOverlay(player, followmobj);
break;
case MT_METALJETFUME:
P_DoMetalJetFume(player, followmobj);
break;
default:
var1 = 1;
var2 = 0;
A_CapeChase(followmobj);
break;
}
}
}
// //
// P_PlayerThink // P_PlayerThink
// //
@ -12894,27 +12918,7 @@ void P_PlayerAfterThink(player_t *player)
} }
if (player->followmobj) if (player->followmobj)
{ P_DoFollowMobj(player, player->followmobj);
if (LUA_HookFollowMobj(player, player->followmobj) || P_MobjWasRemoved(player->followmobj))
{;}
else
{
switch (player->followmobj->type)
{
case MT_TAILSOVERLAY: // c:
P_DoTailsOverlay(player, player->followmobj);
break;
case MT_METALJETFUME:
P_DoMetalJetFume(player, player->followmobj);
break;
default:
var1 = 1;
var2 = 0;
A_CapeChase(player->followmobj);
break;
}
}
}
} }
P_DoPlayerHeadSigns(player); // Spawn Tag/CTF signs over player's head P_DoPlayerHeadSigns(player); // Spawn Tag/CTF signs over player's head