mirror of
https://git.do.srb2.org/KartKrew/Kart-Public.git
synced 2025-03-21 10:21:28 +00:00
Move Player collision check into the regular collision checking
This commit is contained in:
parent
b4a1ad4ef2
commit
e60b3e1b88
10 changed files with 42 additions and 88 deletions
|
@ -519,8 +519,6 @@ static inline void resynch_write_player(resynch_pak *rsp, const size_t i)
|
|||
rsp->powers[j] = (UINT16)SHORT(players[i].powers[j]);
|
||||
for (j = 0; j < NUMKARTSTUFF; ++j)
|
||||
rsp->kartstuff[j] = LONG(players[i].kartstuff[j]); // SRB2kart
|
||||
for (j = 0; j < MAXPLAYERS; ++j)
|
||||
rsp->collide[j] = (UINT8)players[i].collide[j]; // SRB2kart
|
||||
|
||||
// Score is resynched in the rspfirm resync packet
|
||||
rsp->health = 0; // resynched with mo health
|
||||
|
@ -653,8 +651,6 @@ static void resynch_read_player(resynch_pak *rsp)
|
|||
players[i].powers[j] = (UINT16)SHORT(rsp->powers[j]);
|
||||
for (j = 0; j < NUMKARTSTUFF; ++j)
|
||||
players[i].kartstuff[j] = LONG(rsp->kartstuff[j]); // SRB2kart
|
||||
for (j = 0; j < MAXPLAYERS; ++j)
|
||||
players[i].collide[j] = (UINT8)rsp->collide[j]; // SRB2kart
|
||||
|
||||
// Score is resynched in the rspfirm resync packet
|
||||
players[i].health = rsp->health;
|
||||
|
|
|
@ -366,7 +366,6 @@ typedef struct player_s
|
|||
|
||||
// SRB2kart stuff
|
||||
INT32 kartstuff[NUMKARTSTUFF];
|
||||
boolean collide[MAXPLAYERS];
|
||||
|
||||
// Bit flags.
|
||||
// See pflags_t, above.
|
||||
|
|
|
@ -2120,7 +2120,6 @@ static inline void G_PlayerFinishLevel(INT32 player)
|
|||
|
||||
memset(p->powers, 0, sizeof (p->powers));
|
||||
memset(p->kartstuff, 0, sizeof (p->kartstuff)); // SRB2kart
|
||||
memset(p->collide, 0, sizeof (p->collide)); // SRB2kart
|
||||
p->ringweapons = 0;
|
||||
|
||||
p->mo->flags2 &= ~MF2_SHADOW; // cancel invisibility
|
||||
|
|
80
src/k_kart.c
80
src/k_kart.c
|
@ -1039,20 +1039,6 @@ static void K_KartItemRouletteByDistance(player_t *player, ticcmd_t *cmd)
|
|||
|
||||
//{ SRB2kart p_user.c Stuff
|
||||
|
||||
boolean K_IsTouching(mobj_t *mobj1, mobj_t *mobj2)
|
||||
{
|
||||
if (mobj1 == NULL || mobj2 == NULL)
|
||||
return false;
|
||||
fixed_t absx = abs(mobj1->x - mobj2->x);
|
||||
fixed_t absy = abs(mobj1->y - mobj2->y);
|
||||
fixed_t absz = abs(mobj1->z - mobj2->z);
|
||||
|
||||
if (absx < 32*FRACUNIT && absy < 32*FRACUNIT && absz < 32*FRACUNIT)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
void K_SwapMomentum(mobj_t *mobj1, mobj_t *mobj2, boolean bounce)
|
||||
{
|
||||
fixed_t newx, newy;
|
||||
|
@ -1072,7 +1058,7 @@ void K_SwapMomentum(mobj_t *mobj1, mobj_t *mobj2, boolean bounce)
|
|||
//S_StartSound(mobj2, cv_collidesoundnum.value);
|
||||
}
|
||||
|
||||
fx = P_SpawnMobj((mobj1->x + mobj2->x)/2, (mobj1->y + mobj2->y)/2, (mobj1->z + mobj2->z)/2, MT_BUMP);
|
||||
fx = P_SpawnMobj(mobj1->x/2 + mobj2->x/2, mobj1->y/2 + mobj2->y/2, mobj1->z/2 + mobj2->z/2, MT_BUMP);
|
||||
if (mobj1->eflags & MFE_VERTICALFLIP)
|
||||
fx->eflags |= MFE_VERTICALFLIP;
|
||||
else
|
||||
|
@ -1125,58 +1111,20 @@ void K_SwapMomentum(mobj_t *mobj1, mobj_t *mobj2, boolean bounce)
|
|||
mobj1->momz = mobj2->momz;
|
||||
mobj2->momz = newz;
|
||||
}
|
||||
}
|
||||
|
||||
void K_KartBouncer(void)
|
||||
{
|
||||
fixed_t i, j;
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
|
||||
for (j = 0; j < MAXPLAYERS; j++)
|
||||
players[i].collide[j] = false;
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo)
|
||||
&& !players[i].kartstuff[k_growshrinktimer]
|
||||
&& !players[i].kartstuff[k_squishedtimer]
|
||||
&& !players[i].kartstuff[k_bootaketimer]
|
||||
&& !players[i].kartstuff[k_spinouttimer]
|
||||
&& !players[i].kartstuff[k_startimer]
|
||||
&& !players[i].kartstuff[k_justbumped])
|
||||
{
|
||||
for (j = i+1; j < MAXPLAYERS; j++)
|
||||
if (playeringame[j] && players[j].mo && !P_MobjWasRemoved(players[j].mo)
|
||||
&& !players[j].kartstuff[k_squishedtimer]
|
||||
&& !players[j].kartstuff[k_growshrinktimer]
|
||||
&& !players[j].kartstuff[k_bootaketimer]
|
||||
&& !players[j].kartstuff[k_spinouttimer]
|
||||
&& !players[j].kartstuff[k_startimer]
|
||||
&& !players[j].kartstuff[k_justbumped])
|
||||
{
|
||||
if (players[j].mo == players[i].mo)
|
||||
break;
|
||||
if (K_IsTouching(players[i].mo, players[j].mo))
|
||||
{
|
||||
if (!players[i].collide[j] && !players[j].collide[i])
|
||||
{
|
||||
if (P_IsObjectOnGround(players[j].mo) && players[i].mo->momz < 0)
|
||||
K_SwapMomentum(players[i].mo, players[j].mo, true);
|
||||
else if (P_IsObjectOnGround(players[i].mo) && players[j].mo->momz < 0)
|
||||
K_SwapMomentum(players[j].mo, players[i].mo, true);
|
||||
else
|
||||
K_SwapMomentum(players[i].mo, players[j].mo, false);
|
||||
players[i].collide[j] = true;
|
||||
players[i].kartstuff[k_justbumped] = 6; // let the animation finish before letting you bump again :V
|
||||
players[j].collide[i] = true;
|
||||
players[j].kartstuff[k_justbumped] = 6;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
players[i].collide[j] = false;
|
||||
players[j].collide[i] = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Because this is done during collision now, rmomx and rmomy need to be recalculated
|
||||
// so that friction doesn't immediately decide to stop the player if they're at a standstill
|
||||
if (mobj1->player)
|
||||
{
|
||||
mobj1->player->rmomx = mobj1->momx - mobj1->player->cmomx;
|
||||
mobj1->player->rmomy = mobj1->momy - mobj1->player->cmomy;
|
||||
}
|
||||
|
||||
if (mobj2->player)
|
||||
{
|
||||
mobj2->player->rmomx = mobj2->momx - mobj2->player->cmomx;
|
||||
mobj2->player->rmomy = mobj2->momy - mobj2->player->cmomy;
|
||||
}
|
||||
}
|
||||
|
||||
/** \brief Checks that the player is on an offroad subsector for realsies
|
||||
|
|
|
@ -15,7 +15,7 @@ UINT8 K_GetKartColorByName(const char *name);
|
|||
|
||||
void K_RegisterKartStuff(void);
|
||||
|
||||
void K_KartBouncer(void);
|
||||
void K_SwapMomentum(mobj_t *mobj1, mobj_t *mobj2, boolean bounce);
|
||||
void K_KartPlayerThink(player_t *player, ticcmd_t *cmd);
|
||||
void K_SpinPlayer(player_t *player, mobj_t *source);
|
||||
void K_SquishPlayer(player_t *player, mobj_t *source);
|
||||
|
|
|
@ -130,8 +130,6 @@ static int player_get(lua_State *L)
|
|||
LUA_PushUserdata(L, plr->powers, META_POWERS);
|
||||
else if (fastcmp(field,"kartstuff"))
|
||||
LUA_PushUserdata(L, plr->kartstuff, META_KARTSTUFF);
|
||||
else if (fastcmp(field,"collide"))
|
||||
LUA_PushUserdata(L, plr->collide, META_COLLIDE);
|
||||
else if (fastcmp(field,"pflags"))
|
||||
lua_pushinteger(L, plr->pflags);
|
||||
else if (fastcmp(field,"panim"))
|
||||
|
|
|
@ -435,7 +435,6 @@ void LUA_InvalidatePlayer(player_t *player)
|
|||
LUA_InvalidateUserdata(player);
|
||||
LUA_InvalidateUserdata(player->powers);
|
||||
LUA_InvalidateUserdata(player->kartstuff);
|
||||
LUA_InvalidateUserdata(player->collide);
|
||||
LUA_InvalidateUserdata(&player->cmd);
|
||||
}
|
||||
|
||||
|
|
29
src/p_map.c
29
src/p_map.c
|
@ -320,6 +320,7 @@ static void P_DoFanAndGasJet(mobj_t *spring, mobj_t *object)
|
|||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
static void P_DoTailsCarry(player_t *sonic, player_t *tails)
|
||||
{
|
||||
INT32 p;
|
||||
|
@ -400,6 +401,7 @@ static void P_DoTailsCarry(player_t *sonic, player_t *tails)
|
|||
sonic->pflags &= ~PF_CARRIED;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
//
|
||||
// PIT_CheckThing
|
||||
|
@ -1534,7 +1536,8 @@ static boolean PIT_CheckThing(mobj_t *thing)
|
|||
}
|
||||
|
||||
// Force solid players in hide and seek to avoid corner stacking.
|
||||
if (cv_tailspickup.value && gametype != GT_HIDEANDSEEK)
|
||||
// Kart: No Tailspickup ever, players are always solid
|
||||
/*if (cv_tailspickup.value && gametype != GT_HIDEANDSEEK)
|
||||
{
|
||||
if (tmthing->player && thing->player)
|
||||
{
|
||||
|
@ -1546,7 +1549,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
|
|||
if (thing->player-players == consoleplayer && botingame)
|
||||
CV_SetValue(&cv_analog2, true);
|
||||
thing->player->pflags &= ~PF_CARRIED;
|
||||
}
|
||||
}*/
|
||||
|
||||
if (thing->player)
|
||||
{
|
||||
|
@ -1592,6 +1595,28 @@ static boolean PIT_CheckThing(mobj_t *thing)
|
|||
&& tmthing->z <= thing->z + thing->height)
|
||||
iwassprung = P_DoSpring(thing, tmthing);
|
||||
}
|
||||
else if (thing->player) // bounce when players collide
|
||||
{
|
||||
if (thing->player->kartstuff[k_growshrinktimer] || thing->player->kartstuff[k_squishedtimer]
|
||||
|| thing->player->kartstuff[k_bootaketimer] || thing->player->kartstuff[k_spinouttimer]
|
||||
|| thing->player->kartstuff[k_startimer] || thing->player->kartstuff[k_justbumped]
|
||||
|| tmthing->player->kartstuff[k_growshrinktimer] || tmthing->player->kartstuff[k_squishedtimer]
|
||||
|| tmthing->player->kartstuff[k_bootaketimer] || tmthing->player->kartstuff[k_spinouttimer]
|
||||
|| tmthing->player->kartstuff[k_startimer] || tmthing->player->kartstuff[k_justbumped])
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (P_IsObjectOnGround(thing) && tmthing->momz < 0)
|
||||
K_SwapMomentum(tmthing, thing, true);
|
||||
else if (P_IsObjectOnGround(tmthing) && thing->momz < 0)
|
||||
K_SwapMomentum(thing, tmthing, true);
|
||||
else
|
||||
K_SwapMomentum(tmthing, thing, false);
|
||||
|
||||
thing->player->kartstuff[k_justbumped] = 6;
|
||||
tmthing->player->kartstuff[k_justbumped] = 6;
|
||||
}
|
||||
// Are you touching the side of the object you're interacting with?
|
||||
else if (thing->z - FixedMul(FRACUNIT, thing->scale) <= tmthing->z + tmthing->height
|
||||
&& thing->z + thing->height + FixedMul(FRACUNIT, thing->scale) >= tmthing->z)
|
||||
|
|
|
@ -138,8 +138,6 @@ static void P_NetArchivePlayers(void)
|
|||
WRITEUINT16(save_p, players[i].powers[j]);
|
||||
for (j = 0; j < NUMKARTSTUFF; j++)
|
||||
WRITEINT32(save_p, players[i].kartstuff[j]);
|
||||
for (j = 0; j < MAXPLAYERS; j++)
|
||||
WRITEUINT8(save_p, players[i].collide[j]);
|
||||
|
||||
WRITEUINT8(save_p, players[i].playerstate);
|
||||
WRITEUINT32(save_p, players[i].pflags);
|
||||
|
@ -321,8 +319,6 @@ static void P_NetUnArchivePlayers(void)
|
|||
players[i].powers[j] = READUINT16(save_p);
|
||||
for (j = 0; j < NUMKARTSTUFF; j++)
|
||||
players[i].kartstuff[j] = READINT32(save_p);
|
||||
for (j = 0; j < MAXPLAYERS; j++)
|
||||
players[i].collide[j] = (boolean)READUINT8(save_p);
|
||||
|
||||
players[i].playerstate = READUINT8(save_p);
|
||||
players[i].pflags = READUINT32(save_p);
|
||||
|
|
|
@ -625,9 +625,6 @@ void P_Ticker(boolean run)
|
|||
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
|
||||
P_PlayerAfterThink(&players[i]);
|
||||
|
||||
// SRB2kart - runs bounce collision for players
|
||||
K_KartBouncer();
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
LUAh_ThinkFrame();
|
||||
#endif
|
||||
|
@ -743,9 +740,6 @@ void P_PreTicker(INT32 frames)
|
|||
if (playeringame[i] && players[i].mo && !P_MobjWasRemoved(players[i].mo))
|
||||
P_PlayerAfterThink(&players[i]);
|
||||
|
||||
// SRB2kart - runs bounce collision for players
|
||||
K_KartBouncer();
|
||||
|
||||
#ifdef HAVE_BLUA
|
||||
LUAh_ThinkFrame();
|
||||
#endif
|
||||
|
|
Loading…
Reference in a new issue