mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2026-04-28 04:51:42 +00:00
Re-attempt at hitlag
I remember when I tried to fix wolfs' branch I was having issues, but this ended up working pretty much fine? Don't remember why the old branch was messed up though (it was simply too old & not substantial enough to try and work off of imo)
This commit is contained in:
parent
0060a30bc4
commit
c9b17c456d
8 changed files with 52 additions and 5 deletions
|
|
@ -48,6 +48,7 @@ boolean K_OrbinautJawzCollide(mobj_t *t1, mobj_t *t2)
|
||||||
P_DamageMobj(t2, t1, t1->target, 1);
|
P_DamageMobj(t2, t1, t1->target, 1);
|
||||||
K_KartBouncing(t2, t1, false, false);
|
K_KartBouncing(t2, t1, false, false);
|
||||||
S_StartSound(t2, sfx_s3k7b);
|
S_StartSound(t2, sfx_s3k7b);
|
||||||
|
t2->hitlag = TICRATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
damageitem = true;
|
damageitem = true;
|
||||||
|
|
@ -99,6 +100,8 @@ boolean K_OrbinautJawzCollide(mobj_t *t1, mobj_t *t2)
|
||||||
else
|
else
|
||||||
t1->z += t1->height;
|
t1->z += t1->height;
|
||||||
|
|
||||||
|
t1->hitlag = TICRATE;
|
||||||
|
|
||||||
S_StartSound(t1, t1->info->deathsound);
|
S_StartSound(t1, t1->info->deathsound);
|
||||||
P_KillMobj(t1, t2, t2);
|
P_KillMobj(t1, t2, t2);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -87,6 +87,7 @@ enum mobj_e {
|
||||||
mobj_standingslope,
|
mobj_standingslope,
|
||||||
#endif
|
#endif
|
||||||
mobj_colorized,
|
mobj_colorized,
|
||||||
|
mobj_hitlag,
|
||||||
mobj_shadowscale,
|
mobj_shadowscale,
|
||||||
mobj_whiteshadow,
|
mobj_whiteshadow,
|
||||||
mobj_sprxoff,
|
mobj_sprxoff,
|
||||||
|
|
@ -156,6 +157,7 @@ static const char *const mobj_opt[] = {
|
||||||
"standingslope",
|
"standingslope",
|
||||||
#endif
|
#endif
|
||||||
"colorized",
|
"colorized",
|
||||||
|
"hitlag",
|
||||||
"shadowscale",
|
"shadowscale",
|
||||||
"whiteshadow",
|
"whiteshadow",
|
||||||
"sprxoff",
|
"sprxoff",
|
||||||
|
|
@ -375,6 +377,9 @@ static int mobj_get(lua_State *L)
|
||||||
case mobj_colorized:
|
case mobj_colorized:
|
||||||
lua_pushboolean(L, mo->colorized);
|
lua_pushboolean(L, mo->colorized);
|
||||||
break;
|
break;
|
||||||
|
case mobj_hitlag:
|
||||||
|
lua_pushinteger(L, mo->hitlag);
|
||||||
|
break;
|
||||||
case mobj_shadowscale:
|
case mobj_shadowscale:
|
||||||
lua_pushfixed(L, mo->shadowscale);
|
lua_pushfixed(L, mo->shadowscale);
|
||||||
break;
|
break;
|
||||||
|
|
@ -710,6 +715,9 @@ static int mobj_set(lua_State *L)
|
||||||
case mobj_colorized:
|
case mobj_colorized:
|
||||||
mo->colorized = luaL_checkboolean(L, 3);
|
mo->colorized = luaL_checkboolean(L, 3);
|
||||||
break;
|
break;
|
||||||
|
case mobj_hitlag:
|
||||||
|
mo->hitlag = luaL_checkinteger(L, 3);
|
||||||
|
break;
|
||||||
case mobj_shadowscale:
|
case mobj_shadowscale:
|
||||||
mo->shadowscale = luaL_checkfixed(L, 3);
|
mo->shadowscale = luaL_checkfixed(L, 3);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -2598,6 +2598,12 @@ boolean P_TryMove(mobj_t *thing, fixed_t x, fixed_t y, boolean allowdropoff)
|
||||||
if (radius < mapobjectscale)
|
if (radius < mapobjectscale)
|
||||||
radius = mapobjectscale;
|
radius = mapobjectscale;
|
||||||
|
|
||||||
|
if (thing->hitlag > 0)
|
||||||
|
{
|
||||||
|
// Do not move during hitlag
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
do {
|
do {
|
||||||
if (thing->flags & MF_NOCLIP) {
|
if (thing->flags & MF_NOCLIP) {
|
||||||
tryx = x;
|
tryx = x;
|
||||||
|
|
|
||||||
|
|
@ -6392,6 +6392,12 @@ void P_MobjThinker(mobj_t *mobj)
|
||||||
if (mobj->flags & MF_NOTHINK)
|
if (mobj->flags & MF_NOTHINK)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (mobj->hitlag > 0)
|
||||||
|
{
|
||||||
|
mobj->hitlag--;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// Remove dead target/tracer.
|
// Remove dead target/tracer.
|
||||||
if (mobj->target && P_MobjWasRemoved(mobj->target))
|
if (mobj->target && P_MobjWasRemoved(mobj->target))
|
||||||
P_SetTarget(&mobj->target, NULL);
|
P_SetTarget(&mobj->target, NULL);
|
||||||
|
|
@ -10875,6 +10881,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
|
||||||
|
|
||||||
mobj->colorized = false;
|
mobj->colorized = false;
|
||||||
|
|
||||||
|
mobj->hitlag = 0;
|
||||||
|
|
||||||
// Set shadowscale here, before spawn hook so that Lua can change it
|
// Set shadowscale here, before spawn hook so that Lua can change it
|
||||||
P_DefaultMobjShadowScale(mobj);
|
P_DefaultMobjShadowScale(mobj);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -410,6 +410,8 @@ typedef struct mobj_s
|
||||||
|
|
||||||
fixed_t sprxoff, spryoff, sprzoff; // Sprite offsets in real space, does NOT affect position or collision
|
fixed_t sprxoff, spryoff, sprzoff; // Sprite offsets in real space, does NOT affect position or collision
|
||||||
|
|
||||||
|
INT32 hitlag;
|
||||||
|
|
||||||
// WARNING: New fields must be added separately to savegame and Lua.
|
// WARNING: New fields must be added separately to savegame and Lua.
|
||||||
} mobj_t;
|
} mobj_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1000,6 +1000,7 @@ typedef enum
|
||||||
#endif
|
#endif
|
||||||
MD2_SHADOWSCALE = 1<<14,
|
MD2_SHADOWSCALE = 1<<14,
|
||||||
MD2_DRAWFLAGS = 1<<15,
|
MD2_DRAWFLAGS = 1<<15,
|
||||||
|
MD2_HITLAG = 1<<16
|
||||||
} mobj_diff2_t;
|
} mobj_diff2_t;
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
|
|
@ -1196,12 +1197,14 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
|
||||||
if (mobj->standingslope)
|
if (mobj->standingslope)
|
||||||
diff2 |= MD2_SLOPE;
|
diff2 |= MD2_SLOPE;
|
||||||
#endif
|
#endif
|
||||||
|
if (mobj->colorized)
|
||||||
|
diff2 |= MD2_COLORIZED;
|
||||||
if (mobj->shadowscale)
|
if (mobj->shadowscale)
|
||||||
diff2 |= MD2_SHADOWSCALE;
|
diff2 |= MD2_SHADOWSCALE;
|
||||||
if (mobj->drawflags)
|
if (mobj->drawflags)
|
||||||
diff2 |= MD2_DRAWFLAGS;
|
diff2 |= MD2_DRAWFLAGS;
|
||||||
if (mobj->colorized)
|
if (mobj->hitlag)
|
||||||
diff2 |= MD2_COLORIZED;
|
diff2 |= MD2_HITLAG;
|
||||||
if (mobj == waypointcap)
|
if (mobj == waypointcap)
|
||||||
diff2 |= MD2_WAYPOINTCAP;
|
diff2 |= MD2_WAYPOINTCAP;
|
||||||
if (mobj == kitemcap)
|
if (mobj == kitemcap)
|
||||||
|
|
@ -1342,6 +1345,8 @@ static void SaveMobjThinker(const thinker_t *th, const UINT8 type)
|
||||||
|
|
||||||
WRITEUINT16(save_p, df);
|
WRITEUINT16(save_p, df);
|
||||||
}
|
}
|
||||||
|
if (diff2 & MD2_HITLAG)
|
||||||
|
WRITEINT32(save_p, mobj->hitlag);
|
||||||
|
|
||||||
WRITEUINT32(save_p, mobj->mobjnum);
|
WRITEUINT32(save_p, mobj->mobjnum);
|
||||||
}
|
}
|
||||||
|
|
@ -2273,6 +2278,8 @@ static void LoadMobjThinker(actionf_p1 thinker)
|
||||||
mobj->shadowscale = READFIXED(save_p);
|
mobj->shadowscale = READFIXED(save_p);
|
||||||
if (diff2 & MD2_DRAWFLAGS)
|
if (diff2 & MD2_DRAWFLAGS)
|
||||||
mobj->drawflags = READUINT16(save_p);
|
mobj->drawflags = READUINT16(save_p);
|
||||||
|
if (diff2 & MD2_HITLAG)
|
||||||
|
mobj->hitlag = READINT32(save_p);
|
||||||
|
|
||||||
if (diff & MD_REDFLAG)
|
if (diff & MD_REDFLAG)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -8677,6 +8677,11 @@ void P_PlayerThink(player_t *player)
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (player->mo->hitlag > 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (player->awayviewmobj && P_MobjWasRemoved(player->awayviewmobj))
|
if (player->awayviewmobj && P_MobjWasRemoved(player->awayviewmobj))
|
||||||
{
|
{
|
||||||
P_SetTarget(&player->awayviewmobj, NULL); // remove awayviewmobj asap if invalid
|
P_SetTarget(&player->awayviewmobj, NULL); // remove awayviewmobj asap if invalid
|
||||||
|
|
|
||||||
|
|
@ -1429,9 +1429,9 @@ static void R_ProjectDropShadow(mobj_t *thing, vissprite_t *vis, fixed_t scale,
|
||||||
//
|
//
|
||||||
static void R_ProjectSprite(mobj_t *thing)
|
static void R_ProjectSprite(mobj_t *thing)
|
||||||
{
|
{
|
||||||
const fixed_t thingxpos = thing->x + thing->sprxoff;
|
fixed_t thingxpos = thing->x + thing->sprxoff;
|
||||||
const fixed_t thingypos = thing->y + thing->spryoff;
|
fixed_t thingypos = thing->y + thing->spryoff;
|
||||||
const fixed_t thingzpos = thing->z + thing->sprzoff;
|
fixed_t thingzpos = thing->z + thing->sprzoff;
|
||||||
|
|
||||||
fixed_t tr_x, tr_y;
|
fixed_t tr_x, tr_y;
|
||||||
fixed_t gxt, gyt;
|
fixed_t gxt, gyt;
|
||||||
|
|
@ -1468,6 +1468,14 @@ static void R_ProjectSprite(mobj_t *thing)
|
||||||
INT32 light = 0;
|
INT32 light = 0;
|
||||||
fixed_t this_scale = thing->scale;
|
fixed_t this_scale = thing->scale;
|
||||||
|
|
||||||
|
// hitlag vibrating
|
||||||
|
if (thing->hitlag > 0 && (leveltime & 1))
|
||||||
|
{
|
||||||
|
thingxpos += thing->momx;
|
||||||
|
thingypos += thing->momy;
|
||||||
|
thingzpos += thing->momz;
|
||||||
|
}
|
||||||
|
|
||||||
// transform the origin point
|
// transform the origin point
|
||||||
tr_x = thingxpos - viewx;
|
tr_x = thingxpos - viewx;
|
||||||
tr_y = thingypos - viewy;
|
tr_y = thingypos - viewy;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue