* Introducing new Lua-exclusive function, P_IsValidSprite2(mo, spr2). Basically just a wrapper for (((skin_t *)mobj->skin)->sprites[spr2].numframes > 0), useful for creating custom sprite2 defaulting functions since hooking into P_GetMobjSprite2 wouldn't be worth it.
* All Lua-originated sprite2 settings are now forced through P_GetMobjSprite2. Makes sense because of SPR2_JUMP, which none of the main characters have sprites for yet all use. * Cleaned up P_GetMobjSprite2 to not set irrelevant, otherwise-unused variable.
This commit is contained in:
parent
4756b4ce2c
commit
20677c7a66
|
@ -309,6 +309,19 @@ static int lib_pRemoveMobj(lua_State *L)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// P_IsValidSprite2 technically doesn't exist, and probably never should... but too much would need to be exposed to allow this to be checked by other methods.
|
||||||
|
|
||||||
|
static int lib_pIsValidSprite2(lua_State *L)
|
||||||
|
{
|
||||||
|
mobj_t *mobj = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||||
|
UINT8 spr2 = (UINT8)luaL_checkinteger(L, 2);
|
||||||
|
//HUDSAFE
|
||||||
|
if (!mobj)
|
||||||
|
return LUA_ErrInvalid(L, "mobj_t");
|
||||||
|
lua_pushboolean(L, (mobj->skin && (((skin_t *)mobj->skin)->sprites[spr2].numframes > 0)));
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
static int lib_pSpawnMissile(lua_State *L)
|
static int lib_pSpawnMissile(lua_State *L)
|
||||||
{
|
{
|
||||||
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||||
|
@ -2005,6 +2018,7 @@ static luaL_Reg lib[] = {
|
||||||
// don't add P_SetMobjState or P_SetPlayerMobjState, use "mobj.state = S_NEWSTATE" instead.
|
// don't add P_SetMobjState or P_SetPlayerMobjState, use "mobj.state = S_NEWSTATE" instead.
|
||||||
{"P_SpawnMobj",lib_pSpawnMobj},
|
{"P_SpawnMobj",lib_pSpawnMobj},
|
||||||
{"P_RemoveMobj",lib_pRemoveMobj},
|
{"P_RemoveMobj",lib_pRemoveMobj},
|
||||||
|
{"P_IsValidSprite2", lib_pIsValidSprite2},
|
||||||
{"P_SpawnMissile",lib_pSpawnMissile},
|
{"P_SpawnMissile",lib_pSpawnMissile},
|
||||||
{"P_SpawnXYZMissile",lib_pSpawnXYZMissile},
|
{"P_SpawnXYZMissile",lib_pSpawnXYZMissile},
|
||||||
{"P_SpawnPointMissile",lib_pSpawnPointMissile},
|
{"P_SpawnPointMissile",lib_pSpawnPointMissile},
|
||||||
|
|
|
@ -417,7 +417,7 @@ static int mobj_set(lua_State *L)
|
||||||
mo->frame = (UINT32)luaL_checkinteger(L, 3);
|
mo->frame = (UINT32)luaL_checkinteger(L, 3);
|
||||||
break;
|
break;
|
||||||
case mobj_sprite2:
|
case mobj_sprite2:
|
||||||
mo->sprite2 = (UINT8)luaL_checkinteger(L, 3);
|
mo->sprite2 = P_GetMobjSprite2(mo, (UINT8)luaL_checkinteger(L, 3));
|
||||||
break;
|
break;
|
||||||
case mobj_anim_duration:
|
case mobj_anim_duration:
|
||||||
mo->anim_duration = (UINT16)luaL_checkinteger(L, 3);
|
mo->anim_duration = (UINT16)luaL_checkinteger(L, 3);
|
||||||
|
|
|
@ -211,6 +211,7 @@ void P_PrecipitationEffects(void);
|
||||||
void P_RemoveMobj(mobj_t *th);
|
void P_RemoveMobj(mobj_t *th);
|
||||||
boolean P_MobjWasRemoved(mobj_t *th);
|
boolean P_MobjWasRemoved(mobj_t *th);
|
||||||
void P_RemoveSavegameMobj(mobj_t *th);
|
void P_RemoveSavegameMobj(mobj_t *th);
|
||||||
|
UINT8 P_GetMobjSprite2(mobj_t *mobj, UINT8 spr2);
|
||||||
boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state);
|
boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state);
|
||||||
boolean P_SetMobjState(mobj_t *mobj, statenum_t state);
|
boolean P_SetMobjState(mobj_t *mobj, statenum_t state);
|
||||||
void P_RunShields(void);
|
void P_RunShields(void);
|
||||||
|
|
|
@ -189,17 +189,16 @@ static void P_CyclePlayerMobjState(mobj_t *mobj)
|
||||||
// P_GetMobjSprite2
|
// P_GetMobjSprite2
|
||||||
//
|
//
|
||||||
|
|
||||||
static UINT8 P_GetMobjSprite2(mobj_t *mobj, UINT8 spr2)
|
UINT8 P_GetMobjSprite2(mobj_t *mobj, UINT8 spr2)
|
||||||
{
|
{
|
||||||
player_t *player = mobj->player;
|
player_t *player = mobj->player;
|
||||||
skin_t *skin = ((skin_t *)mobj->skin);
|
skin_t *skin = ((skin_t *)mobj->skin);
|
||||||
boolean noalt = false;
|
boolean noalt = false;
|
||||||
UINT8 numframes;
|
|
||||||
|
|
||||||
if (!skin)
|
if (!skin)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
while (((numframes = skin->sprites[spr2].numframes) <= 0)
|
while ((skin->sprites[spr2].numframes <= 0)
|
||||||
&& spr2 != SPR2_STND)
|
&& spr2 != SPR2_STND)
|
||||||
{
|
{
|
||||||
switch(spr2)
|
switch(spr2)
|
||||||
|
|
Loading…
Reference in New Issue