diff --git a/src/lua_baselib.c b/src/lua_baselib.c index 25fa38769..7f64b7ddf 100644 --- a/src/lua_baselib.c +++ b/src/lua_baselib.c @@ -1714,6 +1714,48 @@ static int lib_pSwitchShield(lua_State *L) 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) { player_t *player = *((player_t **)luaL_checkudata(L, 1, META_PLAYER)); @@ -4115,6 +4157,9 @@ static luaL_Reg lib[] = { {"P_SpawnSpinMobj",lib_pSpawnSpinMobj}, {"P_Telekinesis",lib_pTelekinesis}, {"P_SwitchShield",lib_pSwitchShield}, + {"P_DoTailsOverlay",lib_pDoTailsOverlay}, + {"P_DoMetalJetFume",lib_pDoMetalJetFume}, + {"P_DoFollowMobj",lib_pDoFollowMobj}, {"P_PlayerCanEnterSpinGaps",lib_pPlayerCanEnterSpinGaps}, {"P_PlayerShouldUseSpinHeight",lib_pPlayerShouldUseSpinHeight}, diff --git a/src/p_local.h b/src/p_local.h index cc060e4ee..776e9e122 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -213,6 +213,10 @@ void P_SpawnThokMobj(player_t *player); void P_SpawnSpinMobj(player_t *player, mobjtype_t type); 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); #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)); diff --git a/src/p_user.c b/src/p_user.c index 0f3282da5..253161c04 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -11103,7 +11103,7 @@ static void P_MinecartThink(player_t *player) } // Handle Tails' fluff -static void P_DoTailsOverlay(player_t *player, mobj_t *tails) +void P_DoTailsOverlay(player_t *player, mobj_t *tails) { // init... 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 -static void P_DoMetalJetFume(player_t *player, mobj_t *fume) +void P_DoMetalJetFume(player_t *player, mobj_t *fume) { static const UINT8 FUME_SKINCOLORS[] = { @@ -11439,6 +11439,30 @@ static void P_DoMetalJetFume(player_t *player, mobj_t *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 // @@ -12894,27 +12918,7 @@ void P_PlayerAfterThink(player_t *player) } if (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_DoFollowMobj(player, player->followmobj); } P_DoPlayerHeadSigns(player); // Spawn Tag/CTF signs over player's head