mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-17 23:21:22 +00:00
Merge branch 'spr2stuff' into 'master'
Sprite2 changes Some stuff! * Lua access to sprite2. * 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. * FF_ANIMATE support for sprite2s. The var2 of the state works identically to normal FF_ANIMATE, but var1 is completely disregarded - it just runs all of the frames available to that one sprite2 animation set. * As a result, a bunch of states which were either not previously animatable or had animated at constant speed now get animation without state changes. * P_SetMobjState now supports sprite2 defaulting like P_SetPlayerMobjState does. See merge request !51
This commit is contained in:
commit
908907d668
5 changed files with 336 additions and 274 deletions
94
src/info.c
94
src/info.c
|
@ -479,32 +479,32 @@ state_t states[NUMSTATES] =
|
|||
{SPR_THOK, FF_TRANS50, 8, {NULL}, 0, 0, S_NULL}, // S_THOK
|
||||
|
||||
// Player
|
||||
{SPR_PLAY, SPR2_STND, 105, {NULL}, 0, 0, S_PLAY_WAIT}, // S_PLAY_STND
|
||||
{SPR_PLAY, SPR2_WAIT, 16, {NULL}, 0, 0, S_PLAY_WAIT}, // S_PLAY_WAIT
|
||||
{SPR_PLAY, SPR2_WALK, 4, {NULL}, 0, 0, S_PLAY_WALK}, // S_PLAY_WALK
|
||||
{SPR_PLAY, SPR2_RUN , 2, {NULL}, 0, 0, S_PLAY_RUN}, // S_PLAY_RUN
|
||||
{SPR_PLAY, SPR2_PEEL, 2, {NULL}, 0, 0, S_PLAY_PEEL}, // S_PLAY_PEEL
|
||||
{SPR_PLAY, SPR2_PAIN, 350, {NULL}, 0, 0, S_PLAY_FALL}, // S_PLAY_PAIN
|
||||
{SPR_PLAY, SPR2_DEAD, 4, {NULL}, 0, 0, S_PLAY_DEAD}, // S_PLAY_DEAD
|
||||
{SPR_PLAY, SPR2_DRWN, 4, {NULL}, 0, 0, S_PLAY_DRWN}, // S_PLAY_DRWN
|
||||
{SPR_PLAY, SPR2_SPIN, 1, {NULL}, 0, 0, S_PLAY_SPIN}, // S_PLAY_SPIN
|
||||
{SPR_PLAY, SPR2_DASH, 2, {NULL}, 0, 0, S_PLAY_DASH}, // S_PLAY_DASH
|
||||
{SPR_PLAY, SPR2_GASP, 14, {NULL}, 0, 0, S_PLAY_WALK}, // S_PLAY_GASP
|
||||
{SPR_PLAY, SPR2_JUMP, 1, {NULL}, 0, 0, S_PLAY_JUMP}, // S_PLAY_JUMP
|
||||
{SPR_PLAY, SPR2_SPNG, 2, {NULL}, 0, 0, S_PLAY_SPRING}, // S_PLAY_SPRING
|
||||
{SPR_PLAY, SPR2_FALL, 2, {NULL}, 0, 0, S_PLAY_FALL}, // S_PLAY_FALL
|
||||
{SPR_PLAY, SPR2_EDGE, 12, {NULL}, 0, 0, S_PLAY_EDGE}, // S_PLAY_EDGE
|
||||
{SPR_PLAY, SPR2_RIDE, 4, {NULL}, 0, 0, S_PLAY_RIDE}, // S_PLAY_RIDE
|
||||
{SPR_PLAY, SPR2_STND|FF_ANIMATE, 105, {NULL}, 0, 7, S_PLAY_WAIT}, // S_PLAY_STND
|
||||
{SPR_PLAY, SPR2_WAIT|FF_ANIMATE, -1, {NULL}, 0, 16, S_NULL}, // S_PLAY_WAIT
|
||||
{SPR_PLAY, SPR2_WALK, 4, {NULL}, 0, 0, S_PLAY_WALK}, // S_PLAY_WALK
|
||||
{SPR_PLAY, SPR2_RUN , 2, {NULL}, 0, 0, S_PLAY_RUN}, // S_PLAY_RUN
|
||||
{SPR_PLAY, SPR2_PEEL, 2, {NULL}, 0, 0, S_PLAY_PEEL}, // S_PLAY_PEEL
|
||||
{SPR_PLAY, SPR2_PAIN|FF_ANIMATE, 350, {NULL}, 0, 4, S_PLAY_FALL}, // S_PLAY_PAIN
|
||||
{SPR_PLAY, SPR2_DEAD|FF_ANIMATE, -1, {NULL}, 0, 4, S_NULL}, // S_PLAY_DEAD
|
||||
{SPR_PLAY, SPR2_DRWN|FF_ANIMATE, -1, {NULL}, 0, 4, S_NULL}, // S_PLAY_DRWN
|
||||
{SPR_PLAY, SPR2_SPIN, 1, {NULL}, 0, 0, S_PLAY_SPIN}, // S_PLAY_SPIN
|
||||
{SPR_PLAY, SPR2_DASH, 2, {NULL}, 0, 0, S_PLAY_DASH}, // S_PLAY_DASH
|
||||
{SPR_PLAY, SPR2_GASP|FF_ANIMATE, 14, {NULL}, 0, 4, S_PLAY_WALK}, // S_PLAY_GASP
|
||||
{SPR_PLAY, SPR2_JUMP, 1, {NULL}, 0, 0, S_PLAY_JUMP}, // S_PLAY_JUMP
|
||||
{SPR_PLAY, SPR2_SPNG, 2, {NULL}, 0, 0, S_PLAY_SPRING}, // S_PLAY_SPRING
|
||||
{SPR_PLAY, SPR2_FALL, 2, {NULL}, 0, 0, S_PLAY_FALL}, // S_PLAY_FALL
|
||||
{SPR_PLAY, SPR2_EDGE|FF_ANIMATE, -1, {NULL}, 0, 12, S_NULL}, // S_PLAY_EDGE
|
||||
{SPR_PLAY, SPR2_RIDE, 4, {NULL}, 0, 0, S_PLAY_RIDE}, // S_PLAY_RIDE
|
||||
|
||||
// CA_FLY/CA_SWIM
|
||||
{SPR_PLAY, SPR2_FLY , 2, {NULL}, 0, 0, S_PLAY_FLY}, // S_PLAY_FLY
|
||||
{SPR_PLAY, SPR2_SWIM, 2, {NULL}, 0, 0, S_PLAY_SWIM}, // S_PLAY_SWIM
|
||||
{SPR_PLAY, SPR2_TIRE, 12, {NULL}, 0, 0, S_PLAY_FLY_TIRED}, // S_PLAY_FLY_TIRED
|
||||
{SPR_PLAY, SPR2_FLY , 2, {NULL}, 0, 0, S_PLAY_FLY}, // S_PLAY_FLY
|
||||
{SPR_PLAY, SPR2_SWIM, 2, {NULL}, 0, 0, S_PLAY_SWIM}, // S_PLAY_SWIM
|
||||
{SPR_PLAY, SPR2_TIRE, 12, {NULL}, 0, 0, S_PLAY_FLY_TIRED}, // S_PLAY_FLY_TIRED
|
||||
|
||||
// CA_GLIDEANDCLIMB
|
||||
{SPR_PLAY, SPR2_GLID, 2, {NULL}, 0, 0, S_PLAY_GLIDE}, // S_PLAY_GLIDE
|
||||
{SPR_PLAY, SPR2_CLNG, 6, {NULL}, 0, 0, S_PLAY_CLING}, // S_PLAY_CLING
|
||||
{SPR_PLAY, SPR2_CLMB, 5, {NULL}, 0, 0, S_PLAY_CLIMB}, // S_PLAY_CLIMB
|
||||
{SPR_PLAY, SPR2_GLID, 2, {NULL}, 0, 0, S_PLAY_GLIDE}, // S_PLAY_GLIDE
|
||||
{SPR_PLAY, SPR2_CLNG|FF_ANIMATE, -1, {NULL}, 0, 4, S_NULL}, // S_PLAY_CLING
|
||||
{SPR_PLAY, SPR2_CLMB, 5, {NULL}, 0, 0, S_PLAY_CLIMB}, // S_PLAY_CLIMB
|
||||
|
||||
// CA_TWINSPIN
|
||||
{SPR_PLAY, SPR2_TWIN|FF_SPR2ENDSTATE, 1, {NULL}, S_PLAY_JUMP, 0, S_PLAY_TWINSPIN}, // S_PLAY_TWINSPIN
|
||||
|
@ -514,33 +514,33 @@ state_t states[NUMSTATES] =
|
|||
{SPR_PLAY, SPR2_MLEE, 20, {NULL}, 0, 0, S_PLAY_FALL}, // S_PLAY_MELEE_FINISH
|
||||
|
||||
// SF_SUPERANIMS
|
||||
{SPR_PLAY, SPR2_SSTD, 7, {NULL}, 0, 0, S_PLAY_SUPER_STND}, // S_PLAY_SUPER_STND
|
||||
{SPR_PLAY, SPR2_SWLK, 7, {NULL}, 0, 0, S_PLAY_SUPER_WALK}, // S_PLAY_SUPER_WALK
|
||||
{SPR_PLAY, SPR2_SRUN, 7, {NULL}, 0, 0, S_PLAY_SUPER_RUN}, // S_PLAY_SUPER_RUN
|
||||
{SPR_PLAY, SPR2_SPEE, 7, {NULL}, 0, 0, S_PLAY_SUPER_PEEL}, // S_PLAY_SUPER_PEEL
|
||||
{SPR_PLAY, SPR2_SPAN, -1, {NULL}, 0, 0, S_PLAY_SUPER_STND}, // S_PLAY_SUPER_PAIN
|
||||
{SPR_PLAY, SPR2_SSTN, -1, {NULL}, 0, 0, S_PLAY_SUPER_STND}, // S_PLAY_SUPER_STUN
|
||||
{SPR_PLAY, SPR2_SDTH, 4, {NULL}, 0, 0, S_PLAY_SUPER_DEAD}, // S_PLAY_SUPER_DEAD
|
||||
{SPR_PLAY, SPR2_SDRN, 4, {NULL}, 0, 0, S_PLAY_SUPER_DRWN}, // S_PLAY_SUPER_DRWN
|
||||
{SPR_PLAY, SPR2_SSPN, 1, {NULL}, 0, 0, S_PLAY_SUPER_SPIN}, // S_PLAY_SUPER_SPIN
|
||||
{SPR_PLAY, SPR2_SGSP, 14, {NULL}, 0, 0, S_PLAY_SUPER_WALK}, // S_PLAY_SUPER_GASP
|
||||
{SPR_PLAY, SPR2_SJMP, 1, {NULL}, 0, 0, S_PLAY_SUPER_JUMP}, // S_PLAY_SUPER_JUMP
|
||||
{SPR_PLAY, SPR2_SSPG, 2, {NULL}, 0, 0, S_PLAY_SUPER_SPRING}, // S_PLAY_SUPER_SPRING
|
||||
{SPR_PLAY, SPR2_SFAL, 2, {NULL}, 0, 0, S_PLAY_SUPER_FALL}, // S_PLAY_SUPER_FALL
|
||||
{SPR_PLAY, SPR2_SEDG, 12, {NULL}, 0, 0, S_PLAY_SUPER_EDGE}, // S_PLAY_SUPER_EDGE
|
||||
{SPR_PLAY, SPR2_SRID, 4, {NULL}, 0, 0, S_PLAY_SUPER_RIDE}, // S_PLAY_SUPER_RIDE
|
||||
{SPR_PLAY, SPR2_SFLT, 7, {NULL}, 0, 0, S_PLAY_SUPER_FLOAT}, // S_PLAY_SUPER_FLOAT
|
||||
{SPR_PLAY, SPR2_SSTD|FF_ANIMATE, -1, {NULL}, 0, 7, S_NULL}, // S_PLAY_SUPER_STND
|
||||
{SPR_PLAY, SPR2_SWLK, 7, {NULL}, 0, 0, S_PLAY_SUPER_WALK}, // S_PLAY_SUPER_WALK
|
||||
{SPR_PLAY, SPR2_SRUN, 7, {NULL}, 0, 0, S_PLAY_SUPER_RUN}, // S_PLAY_SUPER_RUN
|
||||
{SPR_PLAY, SPR2_SPEE, 7, {NULL}, 0, 0, S_PLAY_SUPER_PEEL}, // S_PLAY_SUPER_PEEL
|
||||
{SPR_PLAY, SPR2_SPAN|FF_ANIMATE, 350, {NULL}, 0, 4, S_PLAY_SUPER_FALL}, // S_PLAY_SUPER_PAIN
|
||||
{SPR_PLAY, SPR2_SSTN|FF_ANIMATE, 350, {NULL}, 0, 4, S_PLAY_SUPER_FALL}, // S_PLAY_SUPER_STUN
|
||||
{SPR_PLAY, SPR2_SDTH|FF_ANIMATE, -1, {NULL}, 0, 4, S_NULL}, // S_PLAY_SUPER_DEAD
|
||||
{SPR_PLAY, SPR2_SDRN|FF_ANIMATE, -1, {NULL}, 0, 4, S_NULL}, // S_PLAY_SUPER_DRWN
|
||||
{SPR_PLAY, SPR2_SSPN, 1, {NULL}, 0, 0, S_PLAY_SUPER_SPIN}, // S_PLAY_SUPER_SPIN
|
||||
{SPR_PLAY, SPR2_SGSP|FF_ANIMATE, 14, {NULL}, 0, 4, S_PLAY_SUPER_WALK}, // S_PLAY_SUPER_GASP
|
||||
{SPR_PLAY, SPR2_SJMP, 1, {NULL}, 0, 0, S_PLAY_SUPER_JUMP}, // S_PLAY_SUPER_JUMP
|
||||
{SPR_PLAY, SPR2_SSPG, 2, {NULL}, 0, 0, S_PLAY_SUPER_SPRING}, // S_PLAY_SUPER_SPRING
|
||||
{SPR_PLAY, SPR2_SFAL, 2, {NULL}, 0, 0, S_PLAY_SUPER_FALL}, // S_PLAY_SUPER_FALL
|
||||
{SPR_PLAY, SPR2_SEDG|FF_ANIMATE, -1, {NULL}, 0, 12, S_NULL}, // S_PLAY_SUPER_EDGE
|
||||
{SPR_PLAY, SPR2_SRID, 4, {NULL}, 0, 0, S_PLAY_SUPER_RIDE}, // S_PLAY_SUPER_RIDE
|
||||
{SPR_PLAY, SPR2_SFLT, 7, {NULL}, 0, 0, S_PLAY_SUPER_FLOAT}, // S_PLAY_SUPER_FLOAT
|
||||
|
||||
// SF_SUPER
|
||||
{SPR_PLAY, SPR2_TRNS, 4, {NULL}, 0, 0, S_PLAY_SUPER_TRANS2}, // S_PLAY_SUPER_TRANS
|
||||
{SPR_PLAY, SPR2_TRNS, 4, {NULL}, 0, 0, S_PLAY_SUPER_TRANS3}, // S_PLAY_SUPER_TRANS2
|
||||
{SPR_PLAY, SPR2_TRNS|FF_FULLBRIGHT, 4, {NULL}, 0, 0, S_PLAY_SUPER_TRANS4}, // S_PLAY_SUPER_TRANS3
|
||||
{SPR_PLAY, SPR2_TRNS|FF_FULLBRIGHT, 3, {NULL}, 0, 0, S_PLAY_SUPER_TRANS5}, // S_PLAY_SUPER_TRANS4
|
||||
{SPR_PLAY, SPR2_TRNS|FF_FULLBRIGHT, 3, {NULL}, 0, 0, S_PLAY_SUPER_TRANS6}, // S_PLAY_SUPER_TRANS5
|
||||
{SPR_PLAY, SPR2_TRNS|FF_FULLBRIGHT, 3, {NULL}, 0, 0, S_PLAY_SUPER_TRANS7}, // S_PLAY_SUPER_TRANS6
|
||||
{SPR_PLAY, SPR2_TRNS|FF_FULLBRIGHT, 3, {NULL}, 0, 0, S_PLAY_SUPER_TRANS8}, // S_PLAY_SUPER_TRANS7
|
||||
{SPR_PLAY, SPR2_TRNS|FF_FULLBRIGHT, 3, {NULL}, 0, 0, S_PLAY_SUPER_TRANS9}, // S_PLAY_SUPER_TRANS8
|
||||
{SPR_PLAY, SPR2_TRNS|FF_FULLBRIGHT, 16, {NULL}, 0, 0, S_PLAY_WALK}, // S_PLAY_SUPER_TRANS9
|
||||
{SPR_PLAY, SPR2_TRNS, 4, {NULL}, 0, 0, S_PLAY_SUPER_TRANS2}, // S_PLAY_SUPER_TRANS
|
||||
{SPR_PLAY, SPR2_TRNS, 4, {NULL}, 0, 0, S_PLAY_SUPER_TRANS3}, // S_PLAY_SUPER_TRANS2
|
||||
{SPR_PLAY, SPR2_TRNS|FF_FULLBRIGHT, 4, {NULL}, 0, 0, S_PLAY_SUPER_TRANS4}, // S_PLAY_SUPER_TRANS3
|
||||
{SPR_PLAY, SPR2_TRNS|FF_FULLBRIGHT, 3, {NULL}, 0, 0, S_PLAY_SUPER_TRANS5}, // S_PLAY_SUPER_TRANS4
|
||||
{SPR_PLAY, SPR2_TRNS|FF_FULLBRIGHT, 3, {NULL}, 0, 0, S_PLAY_SUPER_TRANS6}, // S_PLAY_SUPER_TRANS5
|
||||
{SPR_PLAY, SPR2_TRNS|FF_FULLBRIGHT, 3, {NULL}, 0, 0, S_PLAY_SUPER_TRANS7}, // S_PLAY_SUPER_TRANS6
|
||||
{SPR_PLAY, SPR2_TRNS|FF_FULLBRIGHT, 3, {NULL}, 0, 0, S_PLAY_SUPER_TRANS8}, // S_PLAY_SUPER_TRANS7
|
||||
{SPR_PLAY, SPR2_TRNS|FF_FULLBRIGHT, 3, {NULL}, 0, 0, S_PLAY_SUPER_TRANS9}, // S_PLAY_SUPER_TRANS8
|
||||
{SPR_PLAY, SPR2_TRNS|FF_FULLBRIGHT, 16, {NULL}, 0, 0, S_PLAY_WALK}, // S_PLAY_SUPER_TRANS9
|
||||
|
||||
{SPR_NULL, 0, -1, {NULL}, 0, 0, S_OBJPLACE_DUMMY}, //S_OBJPLACE_DUMMY
|
||||
|
||||
|
|
|
@ -309,6 +309,19 @@ static int lib_pRemoveMobj(lua_State *L)
|
|||
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)
|
||||
{
|
||||
mobj_t *source = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
|
||||
|
@ -2036,6 +2049,7 @@ static luaL_Reg lib[] = {
|
|||
// don't add P_SetMobjState or P_SetPlayerMobjState, use "mobj.state = S_NEWSTATE" instead.
|
||||
{"P_SpawnMobj",lib_pSpawnMobj},
|
||||
{"P_RemoveMobj",lib_pRemoveMobj},
|
||||
{"P_IsValidSprite2", lib_pIsValidSprite2},
|
||||
{"P_SpawnMissile",lib_pSpawnMissile},
|
||||
{"P_SpawnXYZMissile",lib_pSpawnXYZMissile},
|
||||
{"P_SpawnPointMissile",lib_pSpawnPointMissile},
|
||||
|
|
|
@ -34,6 +34,7 @@ enum mobj_e {
|
|||
mobj_angle,
|
||||
mobj_sprite,
|
||||
mobj_frame,
|
||||
mobj_sprite2,
|
||||
mobj_anim_duration,
|
||||
mobj_touching_sectorlist,
|
||||
mobj_subsector,
|
||||
|
@ -93,6 +94,7 @@ static const char *const mobj_opt[] = {
|
|||
"angle",
|
||||
"sprite",
|
||||
"frame",
|
||||
"sprite2",
|
||||
"anim_duration",
|
||||
"touching_sectorlist",
|
||||
"subsector",
|
||||
|
@ -189,6 +191,9 @@ static int mobj_get(lua_State *L)
|
|||
case mobj_frame:
|
||||
lua_pushinteger(L, mo->frame);
|
||||
break;
|
||||
case mobj_sprite2:
|
||||
lua_pushinteger(L, mo->sprite2);
|
||||
break;
|
||||
case mobj_anim_duration:
|
||||
lua_pushinteger(L, mo->anim_duration);
|
||||
break;
|
||||
|
@ -411,6 +416,9 @@ static int mobj_set(lua_State *L)
|
|||
case mobj_frame:
|
||||
mo->frame = (UINT32)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
case mobj_sprite2:
|
||||
mo->sprite2 = P_GetMobjSprite2(mo, (UINT8)luaL_checkinteger(L, 3));
|
||||
break;
|
||||
case mobj_anim_duration:
|
||||
mo->anim_duration = (UINT16)luaL_checkinteger(L, 3);
|
||||
break;
|
||||
|
|
|
@ -212,6 +212,7 @@ void P_PrecipitationEffects(void);
|
|||
void P_RemoveMobj(mobj_t *th);
|
||||
boolean P_MobjWasRemoved(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_SetMobjState(mobj_t *mobj, statenum_t state);
|
||||
void P_RunShields(void);
|
||||
|
|
493
src/p_mobj.c
493
src/p_mobj.c
|
@ -86,9 +86,14 @@ void P_AddCachedAction(mobj_t *mobj, INT32 statenum)
|
|||
//
|
||||
FUNCINLINE static ATTRINLINE void P_SetupStateAnimation(mobj_t *mobj, state_t *st)
|
||||
{
|
||||
INT32 animlength = (mobj->skin && mobj->sprite == SPR_PLAY)
|
||||
? (INT32)(((skin_t *)mobj->skin)->sprites[mobj->sprite2].numframes) - 1
|
||||
: st->var1;
|
||||
|
||||
if (!(st->frame & FF_ANIMATE))
|
||||
return;
|
||||
if (st->var1 == 0 || st->var2 == 0)
|
||||
|
||||
if (animlength <= 0 || st->var2 == 0)
|
||||
{
|
||||
mobj->frame &= ~FF_ANIMATE;
|
||||
return; // Crash/stupidity prevention
|
||||
|
@ -102,11 +107,11 @@ FUNCINLINE static ATTRINLINE void P_SetupStateAnimation(mobj_t *mobj, state_t *s
|
|||
if (!leveltime) return;
|
||||
|
||||
mobj->anim_duration -= (leveltime + 2) % st->var2; // Duration synced to timer
|
||||
mobj->frame += ((leveltime + 2) / st->var2) % (st->var1 + 1); // Frame synced to timer (duration taken into account)
|
||||
mobj->frame += ((leveltime + 2) / st->var2) % (animlength + 1); // Frame synced to timer (duration taken into account)
|
||||
}
|
||||
else if (st->frame & FF_RANDOMANIM)
|
||||
{
|
||||
mobj->frame += P_RandomKey(st->var1 + 1); // Random starting frame
|
||||
mobj->frame += P_RandomKey(animlength + 1); // Random starting frame
|
||||
mobj->anim_duration -= P_RandomKey(st->var2); // Random duration for first frame
|
||||
}
|
||||
}
|
||||
|
@ -119,13 +124,23 @@ FUNCINLINE static ATTRINLINE void P_CycleStateAnimation(mobj_t *mobj)
|
|||
// var2 determines delay between animation frames
|
||||
if (!(mobj->frame & FF_ANIMATE) || --mobj->anim_duration != 0)
|
||||
return;
|
||||
|
||||
mobj->anim_duration = (UINT16)mobj->state->var2;
|
||||
|
||||
// compare the current sprite frame to the one we started from
|
||||
// if more than var1 away from it, swap back to the original
|
||||
// else just advance by one
|
||||
if (((++mobj->frame) & FF_FRAMEMASK) - (mobj->state->frame & FF_FRAMEMASK) > (UINT32)mobj->state->var1)
|
||||
mobj->frame = (mobj->state->frame & FF_FRAMEMASK) | (mobj->frame & ~FF_FRAMEMASK);
|
||||
if (mobj->sprite != SPR_PLAY)
|
||||
{
|
||||
// compare the current sprite frame to the one we started from
|
||||
// if more than var1 away from it, swap back to the original
|
||||
// else just advance by one
|
||||
if (((++mobj->frame) & FF_FRAMEMASK) - (mobj->state->frame & FF_FRAMEMASK) > (UINT32)mobj->state->var1)
|
||||
mobj->frame = (mobj->state->frame & FF_FRAMEMASK) | (mobj->frame & ~FF_FRAMEMASK);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// sprite2 version of above
|
||||
if (mobj->skin && (((++mobj->frame) & FF_FRAMEMASK) >= (UINT32)(((skin_t *)mobj->skin)->sprites[mobj->sprite2].numframes)))
|
||||
mobj->frame &= ~FF_FRAMEMASK;
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -170,6 +185,225 @@ static void P_CyclePlayerMobjState(mobj_t *mobj)
|
|||
}
|
||||
}
|
||||
|
||||
//
|
||||
// P_GetMobjSprite2
|
||||
//
|
||||
|
||||
UINT8 P_GetMobjSprite2(mobj_t *mobj, UINT8 spr2)
|
||||
{
|
||||
player_t *player = mobj->player;
|
||||
skin_t *skin = ((skin_t *)mobj->skin);
|
||||
boolean noalt = false;
|
||||
|
||||
if (!skin)
|
||||
return 0;
|
||||
|
||||
while ((skin->sprites[spr2].numframes <= 0)
|
||||
&& spr2 != SPR2_STND)
|
||||
{
|
||||
switch(spr2)
|
||||
{
|
||||
case SPR2_PEEL:
|
||||
spr2 = SPR2_RUN;
|
||||
break;
|
||||
case SPR2_RUN:
|
||||
spr2 = SPR2_WALK;
|
||||
break;
|
||||
case SPR2_DRWN:
|
||||
spr2 = SPR2_DEAD;
|
||||
break;
|
||||
case SPR2_DASH:
|
||||
spr2 = SPR2_SPIN;
|
||||
break;
|
||||
case SPR2_GASP:
|
||||
spr2 = SPR2_SPNG;
|
||||
break;
|
||||
case SPR2_JUMP:
|
||||
spr2 = ((player
|
||||
? player->charflags
|
||||
: skin->flags)
|
||||
& SF_NOJUMPSPIN) ? SPR2_SPNG : SPR2_SPIN;
|
||||
break;
|
||||
case SPR2_SPNG: // spring
|
||||
spr2 = SPR2_FALL;
|
||||
break;
|
||||
case SPR2_FALL:
|
||||
spr2 = SPR2_WALK;
|
||||
break;
|
||||
case SPR2_RIDE:
|
||||
spr2 = SPR2_FALL;
|
||||
break;
|
||||
|
||||
case SPR2_FLY:
|
||||
spr2 = SPR2_SPNG;
|
||||
break;
|
||||
case SPR2_SWIM:
|
||||
spr2 = SPR2_FLY;
|
||||
break;
|
||||
case SPR2_TIRE:
|
||||
spr2 = (player && player->charability == CA_SWIM) ? SPR2_SWIM : SPR2_FLY;
|
||||
break;
|
||||
|
||||
case SPR2_GLID:
|
||||
spr2 = SPR2_FLY;
|
||||
break;
|
||||
case SPR2_CLMB:
|
||||
spr2 = SPR2_SPIN;
|
||||
break;
|
||||
case SPR2_CLNG:
|
||||
spr2 = SPR2_CLMB;
|
||||
break;
|
||||
|
||||
case SPR2_TWIN:
|
||||
spr2 = SPR2_SPIN;
|
||||
break;
|
||||
|
||||
case SPR2_MLEE:
|
||||
spr2 = SPR2_TWIN;
|
||||
break;
|
||||
|
||||
// Super sprites fallback to regular sprites
|
||||
case SPR2_SWLK:
|
||||
spr2 = SPR2_WALK;
|
||||
break;
|
||||
case SPR2_SRUN:
|
||||
spr2 = SPR2_RUN;
|
||||
break;
|
||||
case SPR2_SPEE:
|
||||
spr2 = SPR2_PEEL;
|
||||
break;
|
||||
case SPR2_SPAN:
|
||||
spr2 = SPR2_PAIN;
|
||||
break;
|
||||
case SPR2_SSTN:
|
||||
spr2 = SPR2_SPAN;
|
||||
break;
|
||||
case SPR2_SDTH:
|
||||
spr2 = SPR2_DEAD;
|
||||
break;
|
||||
case SPR2_SDRN:
|
||||
spr2 = SPR2_DRWN;
|
||||
break;
|
||||
case SPR2_SSPN:
|
||||
spr2 = SPR2_SPIN;
|
||||
break;
|
||||
case SPR2_SGSP:
|
||||
spr2 = SPR2_GASP;
|
||||
break;
|
||||
case SPR2_SJMP:
|
||||
spr2 = ((player
|
||||
? player->charflags
|
||||
: skin->flags)
|
||||
& SF_NOJUMPSPIN) ? SPR2_SSPG : SPR2_SSPN;
|
||||
break;
|
||||
case SPR2_SSPG:
|
||||
spr2 = SPR2_SPNG;
|
||||
break;
|
||||
case SPR2_SFAL:
|
||||
spr2 = SPR2_FALL;
|
||||
break;
|
||||
case SPR2_SEDG:
|
||||
spr2 = SPR2_EDGE;
|
||||
break;
|
||||
case SPR2_SRID:
|
||||
spr2 = SPR2_RIDE;
|
||||
break;
|
||||
case SPR2_SFLT:
|
||||
spr2 = SPR2_SWLK;
|
||||
break;
|
||||
|
||||
// NiGHTS sprites.
|
||||
case SPR2_NTRN:
|
||||
spr2 = SPR2_TRNS;
|
||||
break;
|
||||
case SPR2_NSTD:
|
||||
spr2 = SPR2_SSTD;
|
||||
break;
|
||||
case SPR2_NFLT:
|
||||
spr2 = (skin->flags & SF_SUPERANIMS) ? SPR2_SFLT : SPR2_FALL; // This is skin-exclusive so the default NiGHTS skin changing system plays nice.
|
||||
break;
|
||||
case SPR2_NPUL:
|
||||
spr2 = SPR2_NFLT;
|
||||
break;
|
||||
case SPR2_NPAN:
|
||||
spr2 = SPR2_NPUL;
|
||||
break;
|
||||
case SPR2_NATK:
|
||||
spr2 = SPR2_SSPN;
|
||||
break;
|
||||
/*case SPR2_NGT0:
|
||||
spr2 = SPR2_STND;
|
||||
break;*/
|
||||
case SPR2_NGT1:
|
||||
case SPR2_NGT7:
|
||||
case SPR2_DRL0:
|
||||
spr2 = SPR2_NGT0;
|
||||
break;
|
||||
case SPR2_NGT2:
|
||||
case SPR2_DRL1:
|
||||
spr2 = SPR2_NGT1;
|
||||
break;
|
||||
case SPR2_NGT3:
|
||||
case SPR2_DRL2:
|
||||
spr2 = SPR2_NGT2;
|
||||
break;
|
||||
case SPR2_NGT4:
|
||||
case SPR2_DRL3:
|
||||
spr2 = SPR2_NGT3;
|
||||
break;
|
||||
case SPR2_NGT5:
|
||||
case SPR2_DRL4:
|
||||
spr2 = SPR2_NGT4;
|
||||
break;
|
||||
case SPR2_NGT6:
|
||||
case SPR2_DRL5:
|
||||
spr2 = SPR2_NGT5;
|
||||
break;
|
||||
case SPR2_DRL6:
|
||||
spr2 = SPR2_NGT6;
|
||||
break;
|
||||
case SPR2_NGT8:
|
||||
case SPR2_DRL7:
|
||||
spr2 = SPR2_NGT7;
|
||||
break;
|
||||
case SPR2_NGT9:
|
||||
case SPR2_DRL8:
|
||||
spr2 = SPR2_NGT8;
|
||||
break;
|
||||
case SPR2_NGTA:
|
||||
case SPR2_DRL9:
|
||||
spr2 = SPR2_NGT9;
|
||||
break;
|
||||
case SPR2_NGTB:
|
||||
case SPR2_DRLA:
|
||||
spr2 = SPR2_NGTA;
|
||||
break;
|
||||
case SPR2_NGTC:
|
||||
case SPR2_DRLB:
|
||||
spr2 = SPR2_NGTB;
|
||||
break;
|
||||
case SPR2_DRLC:
|
||||
spr2 = SPR2_NGTC;
|
||||
break;
|
||||
|
||||
|
||||
// Sprites for non-player objects? There's nothing we can do.
|
||||
case SPR2_SIGN:
|
||||
case SPR2_LIFE:
|
||||
noalt = true;
|
||||
break;
|
||||
|
||||
// Dunno? Just go to standing then.
|
||||
default:
|
||||
spr2 = SPR2_STND;
|
||||
break;
|
||||
}
|
||||
if (noalt)
|
||||
break;
|
||||
}
|
||||
return spr2;
|
||||
}
|
||||
|
||||
//
|
||||
// P_SetPlayerMobjState
|
||||
// Returns true if the mobj is still present.
|
||||
|
@ -396,216 +630,18 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
|
|||
}
|
||||
}
|
||||
|
||||
mobj->anim_duration = (UINT16)st->var2; // only used if FF_ANIMATE is set
|
||||
|
||||
// Player animations
|
||||
if (st->sprite == SPR_PLAY)
|
||||
{
|
||||
skin_t *skin = ((skin_t *)mobj->skin);
|
||||
boolean noalt = false;
|
||||
UINT8 spr2 = st->frame & FF_FRAMEMASK;
|
||||
UINT16 frame = (mobj->frame & FF_FRAMEMASK)+1;
|
||||
UINT8 numframes;
|
||||
|
||||
while (skin && ((numframes = skin->sprites[spr2].numframes) <= 0)
|
||||
&& spr2 != SPR2_STND)
|
||||
{
|
||||
switch(spr2)
|
||||
{
|
||||
case SPR2_PEEL:
|
||||
spr2 = SPR2_RUN;
|
||||
break;
|
||||
case SPR2_RUN:
|
||||
spr2 = SPR2_WALK;
|
||||
break;
|
||||
case SPR2_DRWN:
|
||||
spr2 = SPR2_DEAD;
|
||||
break;
|
||||
case SPR2_DASH:
|
||||
spr2 = SPR2_SPIN;
|
||||
break;
|
||||
case SPR2_GASP:
|
||||
spr2 = SPR2_SPNG;
|
||||
break;
|
||||
case SPR2_JUMP:
|
||||
spr2 = (player->charflags & SF_NOJUMPSPIN) ? SPR2_SPNG : SPR2_SPIN;
|
||||
break;
|
||||
case SPR2_SPNG: // spring
|
||||
spr2 = SPR2_FALL;
|
||||
break;
|
||||
case SPR2_FALL:
|
||||
spr2 = SPR2_WALK;
|
||||
break;
|
||||
case SPR2_RIDE:
|
||||
spr2 = SPR2_FALL;
|
||||
break;
|
||||
UINT8 spr2 = P_GetMobjSprite2(mobj, st->frame & FF_FRAMEMASK);
|
||||
|
||||
case SPR2_FLY:
|
||||
spr2 = SPR2_SPNG;
|
||||
break;
|
||||
case SPR2_SWIM:
|
||||
spr2 = SPR2_FLY;
|
||||
break;
|
||||
case SPR2_TIRE:
|
||||
spr2 = (player->charability == CA_FLY) ? SPR2_FLY : SPR2_SWIM;
|
||||
break;
|
||||
|
||||
case SPR2_GLID:
|
||||
spr2 = SPR2_FLY;
|
||||
break;
|
||||
case SPR2_CLMB:
|
||||
spr2 = SPR2_SPIN;
|
||||
break;
|
||||
case SPR2_CLNG:
|
||||
spr2 = SPR2_CLMB;
|
||||
break;
|
||||
|
||||
case SPR2_TWIN:
|
||||
spr2 = SPR2_SPIN;
|
||||
break;
|
||||
|
||||
case SPR2_MLEE:
|
||||
spr2 = SPR2_TWIN;
|
||||
break;
|
||||
|
||||
// Super sprites fallback to regular sprites
|
||||
case SPR2_SWLK:
|
||||
spr2 = SPR2_WALK;
|
||||
break;
|
||||
case SPR2_SRUN:
|
||||
spr2 = SPR2_RUN;
|
||||
break;
|
||||
case SPR2_SPEE:
|
||||
spr2 = SPR2_PEEL;
|
||||
break;
|
||||
case SPR2_SPAN:
|
||||
spr2 = SPR2_PAIN;
|
||||
break;
|
||||
case SPR2_SSTN:
|
||||
spr2 = SPR2_SPAN;
|
||||
break;
|
||||
case SPR2_SDTH:
|
||||
spr2 = SPR2_DEAD;
|
||||
break;
|
||||
case SPR2_SDRN:
|
||||
spr2 = SPR2_DRWN;
|
||||
break;
|
||||
case SPR2_SSPN:
|
||||
spr2 = SPR2_SPIN;
|
||||
break;
|
||||
case SPR2_SGSP:
|
||||
spr2 = SPR2_GASP;
|
||||
break;
|
||||
case SPR2_SJMP:
|
||||
spr2 = (player->charflags & SF_NOJUMPSPIN) ? SPR2_SSPG : SPR2_SSPN;
|
||||
break;
|
||||
case SPR2_SSPG:
|
||||
spr2 = SPR2_SPNG;
|
||||
break;
|
||||
case SPR2_SFAL:
|
||||
spr2 = SPR2_FALL;
|
||||
break;
|
||||
case SPR2_SEDG:
|
||||
spr2 = SPR2_EDGE;
|
||||
break;
|
||||
case SPR2_SRID:
|
||||
spr2 = SPR2_RIDE;
|
||||
break;
|
||||
case SPR2_SFLT:
|
||||
spr2 = SPR2_SWLK;
|
||||
break;
|
||||
|
||||
// NiGHTS sprites.
|
||||
case SPR2_NTRN:
|
||||
spr2 = SPR2_TRNS;
|
||||
break;
|
||||
case SPR2_NSTD:
|
||||
spr2 = SPR2_SSTD;
|
||||
break;
|
||||
case SPR2_NFLT:
|
||||
spr2 = (skin->flags & SF_SUPERANIMS) ? SPR2_SFLT : SPR2_FALL; // This is skin-exclusive so the default NiGHTS skin changing system plays nice.
|
||||
break;
|
||||
case SPR2_NPUL:
|
||||
spr2 = SPR2_NFLT;
|
||||
break;
|
||||
case SPR2_NPAN:
|
||||
spr2 = SPR2_NPUL;
|
||||
break;
|
||||
case SPR2_NATK:
|
||||
spr2 = SPR2_SSPN;
|
||||
break;
|
||||
/*case SPR2_NGT0:
|
||||
spr2 = SPR2_STND;
|
||||
break;*/
|
||||
case SPR2_NGT1:
|
||||
case SPR2_NGT7:
|
||||
case SPR2_DRL0:
|
||||
spr2 = SPR2_NGT0;
|
||||
break;
|
||||
case SPR2_NGT2:
|
||||
case SPR2_DRL1:
|
||||
spr2 = SPR2_NGT1;
|
||||
break;
|
||||
case SPR2_NGT3:
|
||||
case SPR2_DRL2:
|
||||
spr2 = SPR2_NGT2;
|
||||
break;
|
||||
case SPR2_NGT4:
|
||||
case SPR2_DRL3:
|
||||
spr2 = SPR2_NGT3;
|
||||
break;
|
||||
case SPR2_NGT5:
|
||||
case SPR2_DRL4:
|
||||
spr2 = SPR2_NGT4;
|
||||
break;
|
||||
case SPR2_NGT6:
|
||||
case SPR2_DRL5:
|
||||
spr2 = SPR2_NGT5;
|
||||
break;
|
||||
case SPR2_DRL6:
|
||||
spr2 = SPR2_NGT6;
|
||||
break;
|
||||
case SPR2_NGT8:
|
||||
case SPR2_DRL7:
|
||||
spr2 = SPR2_NGT7;
|
||||
break;
|
||||
case SPR2_NGT9:
|
||||
case SPR2_DRL8:
|
||||
spr2 = SPR2_NGT8;
|
||||
break;
|
||||
case SPR2_NGTA:
|
||||
case SPR2_DRL9:
|
||||
spr2 = SPR2_NGT9;
|
||||
break;
|
||||
case SPR2_NGTB:
|
||||
case SPR2_DRLA:
|
||||
spr2 = SPR2_NGTA;
|
||||
break;
|
||||
case SPR2_NGTC:
|
||||
case SPR2_DRLB:
|
||||
spr2 = SPR2_NGTB;
|
||||
break;
|
||||
case SPR2_DRLC:
|
||||
spr2 = SPR2_NGTC;
|
||||
break;
|
||||
|
||||
|
||||
// Sprites for non-player objects? There's nothing we can do.
|
||||
case SPR2_SIGN:
|
||||
case SPR2_LIFE:
|
||||
noalt = true;
|
||||
break;
|
||||
|
||||
// Dunno? Just go to standing then.
|
||||
default:
|
||||
spr2 = SPR2_STND;
|
||||
break;
|
||||
}
|
||||
if (noalt)
|
||||
break;
|
||||
}
|
||||
|
||||
if (!skin)
|
||||
if (skin)
|
||||
numframes = skin->sprites[spr2].numframes;
|
||||
else
|
||||
{
|
||||
frame = 0;
|
||||
numframes = 0;
|
||||
|
@ -628,7 +664,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
|
|||
{
|
||||
if (st->frame & FF_SPR2ENDSTATE) // no frame advancement
|
||||
{
|
||||
if (st->var1 == S_NULL)
|
||||
if (st->var1 == mobj->state-states)
|
||||
frame--;
|
||||
else
|
||||
{
|
||||
|
@ -651,9 +687,10 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
|
|||
{
|
||||
mobj->sprite = st->sprite;
|
||||
mobj->frame = st->frame;
|
||||
P_SetupStateAnimation(mobj, st);
|
||||
}
|
||||
|
||||
P_SetupStateAnimation(mobj, st);
|
||||
|
||||
// Modified handling.
|
||||
// Call action functions when the state is set
|
||||
|
||||
|
@ -723,10 +760,11 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state)
|
|||
if (st->sprite == SPR_PLAY)
|
||||
{
|
||||
skin_t *skin = ((skin_t *)mobj->skin);
|
||||
UINT8 spr2 = st->frame & FF_FRAMEMASK;
|
||||
UINT16 frame = (mobj->frame & FF_FRAMEMASK)+1;
|
||||
UINT8 numframes;
|
||||
|
||||
UINT8 spr2 = P_GetMobjSprite2(mobj, st->frame & FF_FRAMEMASK);
|
||||
|
||||
if (skin)
|
||||
numframes = skin->sprites[spr2].numframes;
|
||||
else
|
||||
|
@ -750,8 +788,17 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state)
|
|||
|
||||
if (frame >= numframes)
|
||||
{
|
||||
if (st->frame & FF_SPR2ENDSTATE)
|
||||
return P_SetPlayerMobjState(mobj, st->var1); // Differs from P_SetPlayerMobjState - allows object to be removed via S_NULL
|
||||
if (st->frame & FF_SPR2ENDSTATE) // no frame advancement
|
||||
{
|
||||
if (st->var1 == mobj->state-states)
|
||||
frame--;
|
||||
else
|
||||
{
|
||||
if (mobj->frame & FF_FRAMEMASK)
|
||||
mobj->frame--;
|
||||
return P_SetMobjState(mobj, st->var1);
|
||||
}
|
||||
}
|
||||
else
|
||||
frame = 0;
|
||||
}
|
||||
|
@ -764,9 +811,10 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state)
|
|||
{
|
||||
mobj->sprite = st->sprite;
|
||||
mobj->frame = st->frame;
|
||||
P_SetupStateAnimation(mobj, st);
|
||||
}
|
||||
|
||||
P_SetupStateAnimation(mobj, st);
|
||||
|
||||
// Modified handling.
|
||||
// Call action functions when the state is set
|
||||
|
||||
|
@ -4154,17 +4202,7 @@ static void P_PlayerMobjThinker(mobj_t *mobj)
|
|||
}
|
||||
|
||||
animonly:
|
||||
// cycle through states,
|
||||
// calling action functions at transitions
|
||||
if (mobj->tics != -1)
|
||||
{
|
||||
mobj->tics--;
|
||||
|
||||
// you can cycle through multiple states in a tic
|
||||
if (!mobj->tics)
|
||||
if (!P_SetPlayerMobjState(mobj, mobj->state->nextstate))
|
||||
return; // freed itself
|
||||
}
|
||||
P_CyclePlayerMobjState(mobj);
|
||||
}
|
||||
|
||||
static void CalculatePrecipFloor(precipmobj_t *mobj)
|
||||
|
@ -8818,6 +8856,7 @@ void P_SpawnPlayer(INT32 playernum)
|
|||
// (usefulness: when body mobj is detached from player (who respawns),
|
||||
// the dead body mobj retains the skin through the 'spritedef' override).
|
||||
mobj->skin = &skins[p->skin];
|
||||
P_SetupStateAnimation(mobj, mobj->state);
|
||||
|
||||
mobj->health = 1;
|
||||
p->rings = 0;
|
||||
|
|
Loading…
Reference in a new issue