Merge branch 'expos-follow' into 'next'

Expose FollowMobj-related functions to Lua

See merge request STJr/SRB2!1994
This commit is contained in:
Krabs 2023-11-01 16:26:39 +00:00
commit a97ba3fc87
3 changed files with 76 additions and 23 deletions

View file

@ -1742,6 +1742,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));
@ -4211,6 +4253,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},

View file

@ -214,6 +214,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));

View file

@ -11191,7 +11191,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);
@ -11396,7 +11396,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[] =
{
@ -11534,6 +11534,30 @@ static void P_DoMetalJetFume(player_t *player, mobj_t *fume)
}
}
// Handle Followmobj behavior
void P_DoFollowMobj(player_t *player, mobj_t *followmobj)
{
if (LUA_HookFollowMobj(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
//
@ -13010,27 +13034,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