change how spritescales and offsets work
- now theres realoffsets aswell - allows better control of changing things per lua and still do funky stuff in hardcode without conflicts - spritescales and offsets now get reset centralised before any thinkers run
This commit is contained in:
1 parent
7d621b5b1d
commit
bd489bd462
7 files changed
+76
-54
No files matched your search
+19
-44
@@ -107,21 +107,11 @@ consvar_t cv_newspeedometer = {"newspeedometer", "Default", CV_SAVE, speedo_cons
|
||||
consvar_t cv_battlespeedo = {"battlespeedo", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL}; //toggle for showing the speedometer in battlemode
|
||||
|
||||
// funn-E streeetch
|
||||
static void gravstretch_onchange(void);
|
||||
static CV_PossibleValue_t stretchfactor_t[] = {
|
||||
{0, "Off"}, {FRACUNIT/4, "0.250"},
|
||||
{3*FRACUNIT/8, "0.375"}, {FRACUNIT/2, "0.500"}, {5*FRACUNIT/8, "0.625"},
|
||||
{3*FRACUNIT/4, "0.750"}, {7*FRACUNIT/8, "0.875"}, {FRACUNIT, "Max"}, {0, NULL}};
|
||||
consvar_t cv_gravstretch = {"gravstretch", "0", CV_SAVE|CV_CALL|CV_NOINIT, stretchfactor_t, gravstretch_onchange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static void gravstretch_onchange(void)
|
||||
{
|
||||
// reset everything when toggling gravstretch off
|
||||
if (cv_gravstretch.value == 0)
|
||||
{
|
||||
K_ResetPlayerSpriteStuff();
|
||||
}
|
||||
}
|
||||
consvar_t cv_gravstretch = {"gravstretch", "0", CV_SAVE, stretchfactor_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static CV_PossibleValue_t slamsound_t[] = {{0, "Off"}, {1, "On"}, {0, NULL}};
|
||||
consvar_t cv_slamsound = {"slamsound", "1", CV_SAVE, slamsound_t, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
@@ -149,7 +139,24 @@ static void saltyhop_onchange(void)
|
||||
// reset everything when toggling saltyhop off
|
||||
if (!cv_saltyhop.value)
|
||||
{
|
||||
K_ResetPlayerSpriteStuff();
|
||||
if (gamestate != GS_LEVEL)
|
||||
return;
|
||||
|
||||
for (INT32 i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
player_t *player = &players[i];
|
||||
|
||||
if (!playeringame[i] || P_MobjWasRemoved(player->mo))
|
||||
continue;
|
||||
|
||||
player->mo->salty_jump = false;
|
||||
player->mo->salty_zoffset = 0;
|
||||
player->mo->salty_momz = 0;
|
||||
|
||||
player->mo->salty_ready = false;
|
||||
player->mo->salty_tapping = false;
|
||||
player->mo->init_salty = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -890,34 +897,6 @@ void K_RegisterKartStuff(void)
|
||||
|
||||
//}
|
||||
|
||||
void K_ResetPlayerSpriteStuff(void)
|
||||
{
|
||||
if (gamestate != GS_LEVEL)
|
||||
return;
|
||||
|
||||
for (INT32 i = 0; i < MAXPLAYERS; i++)
|
||||
{
|
||||
player_t *player = &players[i];
|
||||
|
||||
if (!playeringame[i] || P_MobjWasRemoved(player->mo))
|
||||
continue;
|
||||
|
||||
player->mo->spritexoffset = 0;
|
||||
player->mo->spriteyoffset = 0;
|
||||
player->mo->spritexscale = player->mo->realxscale;
|
||||
player->mo->spriteyscale = player->mo->realyscale;
|
||||
|
||||
// reset saltyhop stuffs too
|
||||
player->mo->salty_jump = false;
|
||||
player->mo->salty_zoffset = 0;
|
||||
player->mo->salty_momz = 0;
|
||||
|
||||
player->mo->salty_ready = false;
|
||||
player->mo->salty_tapping = false;
|
||||
player->mo->init_salty = false;
|
||||
}
|
||||
}
|
||||
|
||||
boolean K_IsPlayerLosing(player_t *player)
|
||||
{
|
||||
INT32 winningpos = 1;
|
||||
@@ -3360,8 +3339,6 @@ static void K_StretchPlayerGravity(player_t *p)
|
||||
{
|
||||
if (cv_gravstretch.value == 0)
|
||||
{
|
||||
p->mo->spritexscale = p->mo->realxscale;
|
||||
p->mo->spriteyscale = p->mo->realyscale;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -4844,8 +4821,6 @@ static void K_MoveHeldObjects(player_t *player)
|
||||
targz -= 8*(2*FRACUNIT)/7;
|
||||
}*/
|
||||
|
||||
cur->spriteyoffset = 0;
|
||||
|
||||
if (cv_bananajitter.value && P_IsObjectOnGround(player->mo) && player->speed > 0 && player->kartstuff[k_bananadrag] > TICRATE
|
||||
&& M_RandomChance(min(FRACUNIT/2, FixedDiv(player->speed, K_GetKartSpeed(player, false))/2)))
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@
|
||||
|
||||
#define KART_FULLTURN 800
|
||||
|
||||
void K_ResetPlayerSpriteStuff(void);
|
||||
|
||||
extern UINT8 colortranslations[MAXTRANSLATIONS][16];
|
||||
extern const char *KartColor_Names[MAXSKINCOLORS];
|
||||
|
||||
+23
-2
@@ -40,6 +40,7 @@ int mobj_sprev_unimplemented(lua_State *L);
|
||||
int mobj_angle_setter(lua_State *L);
|
||||
int mobj_sloperoll_noop(lua_State *L);
|
||||
int mobj_spritescale_setter(lua_State *L);
|
||||
int mobj_spriteoffset_setter(lua_State *L);
|
||||
int mobj_touching_sectorlist_unimplemented(lua_State *L);
|
||||
int mobj_radius_setter(lua_State *L);
|
||||
int mobj_height_setter(lua_State *L);
|
||||
@@ -94,8 +95,8 @@ static const udata_field_t mobj_fields[] = {
|
||||
FIELD(mobj_t, anim_duration, udatalib_getter_uint16, udatalib_setter_uint16),
|
||||
FIELD(mobj_t, spritexscale, udatalib_getter_fixed, mobj_spritescale_setter),
|
||||
FIELD(mobj_t, spriteyscale, udatalib_getter_fixed, mobj_spritescale_setter),
|
||||
FIELD(mobj_t, spritexoffset, udatalib_getter_fixed, udatalib_setter_fixed),
|
||||
FIELD(mobj_t, spriteyoffset, udatalib_getter_fixed, udatalib_setter_fixed),
|
||||
FIELD(mobj_t, spritexoffset, udatalib_getter_fixed, mobj_spriteoffset_setter),
|
||||
FIELD(mobj_t, spriteyoffset, udatalib_getter_fixed, mobj_spriteoffset_setter),
|
||||
FIELD(mobj_t, touching_sectorlist, mobj_touching_sectorlist_unimplemented, mobj_touching_sectorlist_unimplemented),
|
||||
FIELD(mobj_t, lightlevel, udatalib_getter_int16, udatalib_setter_int16),
|
||||
FIELD(mobj_t, subsector, udatalib_getter_subsector, mobj_nosetpos_subsector),
|
||||
@@ -278,6 +279,26 @@ int mobj_spritescale_setter(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mobj_spriteoffset_setter(lua_State *L)
|
||||
{
|
||||
mobj_t *mo = GETMO();
|
||||
|
||||
fixed_t *spriteoffset;
|
||||
UDATALIB_GETFIELD(fixed_t, spriteoffset);
|
||||
|
||||
if (!mo->player)
|
||||
*spriteoffset = luaL_checkfixed(L, 2);
|
||||
else
|
||||
{
|
||||
// Mmm yea
|
||||
if (spriteoffset == &mo->spritexoffset)
|
||||
mo->realxoffset = luaL_checkfixed(L, 2);
|
||||
else
|
||||
mo->realyoffset = luaL_checkfixed(L, 2);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int mobj_radius_setter(lua_State *L)
|
||||
{
|
||||
mobj_t *mo = GETMO();
|
||||
|
||||
+3
-1
@@ -9458,7 +9458,9 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
|
||||
mobj->realxscale = mobj->realyscale = mobj->scale;
|
||||
mobj->spritexscale = mobj->realxscale;
|
||||
mobj->spriteyscale = mobj->realyscale;
|
||||
mobj->spritexoffset = mobj->spriteyoffset = 0;
|
||||
mobj->realxoffset = mobj->realyoffset = 0;
|
||||
mobj->spritexoffset = mobj->realxoffset;
|
||||
mobj->spriteyoffset = mobj->realyoffset;
|
||||
|
||||
// Funni slam sound when landing
|
||||
mobj->slamsoundtimer = 0;
|
||||
|
||||
@@ -296,6 +296,7 @@ typedef struct mobj_s
|
||||
INT16 lightlevel; // Add to sector lightlevel, -255 - 255
|
||||
|
||||
fixed_t realxscale, realyscale; // funn-E streeetch
|
||||
fixed_t realxoffset, realyoffset;
|
||||
|
||||
fixed_t stretchslam; // "squish" effect when you land
|
||||
|
||||
@@ -449,6 +450,7 @@ typedef struct precipmobj_s
|
||||
INT16 lightlevel; // Add to sector lightlevel, -255 - 255
|
||||
|
||||
fixed_t realxscale, realyscale; // funn-E streeetch
|
||||
fixed_t realxoffset, realyoffset;
|
||||
|
||||
fixed_t stretchslam; // "squish" effect when you land
|
||||
|
||||
|
||||
+4
-6
@@ -2147,12 +2147,10 @@ static void LoadMobjThinker(savebuffer_t *save, actionf_p1 thinker)
|
||||
mobj->mirrored = 0;
|
||||
|
||||
// Sprite Rendering stuff
|
||||
mobj->spritexoffset = 0;
|
||||
mobj->spriteyoffset = 0;
|
||||
mobj->spritexscale = FRACUNIT;
|
||||
mobj->spriteyscale = FRACUNIT;
|
||||
mobj->realxscale = FRACUNIT;
|
||||
mobj->realyscale = FRACUNIT;
|
||||
mobj->spritexoffset = mobj->realxoffset = 0;
|
||||
mobj->spriteyoffset = mobj->realxoffset = 0;
|
||||
mobj->spritexscale = mobj->realxscale = FRACUNIT;
|
||||
mobj->spriteyscale = mobj->realyscale = FRACUNIT;
|
||||
mobj->stretchslam = 0;
|
||||
|
||||
// Timer for slam sound effect
|
||||
|
||||
@@ -502,6 +502,29 @@ static void P_RunQuakes(void)
|
||||
--quake.time;
|
||||
}
|
||||
|
||||
static inline void P_ResetSpriteStuff(void)
|
||||
{
|
||||
thinker_t *th;
|
||||
|
||||
for (th = thinkercap.next; th != &thinkercap; th = th->next)
|
||||
{
|
||||
mobj_t *mo;
|
||||
|
||||
if (th->function.acp1 != (actionf_p1)P_MobjThinker) // not a mobj
|
||||
continue;
|
||||
|
||||
mo = (mobj_t *)th;
|
||||
|
||||
if (mo->type == MT_SHADOW || mo->sprite == SPR_NULL)
|
||||
continue;
|
||||
|
||||
mo->spritexscale = mo->realxscale;
|
||||
mo->spriteyscale = mo->realyscale;
|
||||
mo->spritexoffset = mo->realxoffset;
|
||||
mo->spriteyoffset = mo->realyoffset;
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
// P_Ticker
|
||||
//
|
||||
@@ -602,6 +625,8 @@ void P_Ticker(boolean run)
|
||||
ps_lua_mobjhooks.value.i = 0;
|
||||
ps_checkposition_calls.value.i = 0;
|
||||
|
||||
P_ResetSpriteStuff();
|
||||
|
||||
PS_START_TIMING(ps_lua_prethinkframe_time);
|
||||
LUA_HookPreThinkFrame();
|
||||
PS_STOP_TIMING(ps_lua_prethinkframe_time);
|
||||
|
||||
Reference in new issue
Block a user