A bunch of little things

- Minimum wall bounce speed decreased from 25*FRACUNIT to 15*FRACUNIT
- Solid objects now bump players instead of stop them
- Bounce pad strength scales with object scale
- Fixed Boo stealing being inconsistent and sometimes not stealing
anything
This commit is contained in:
TehRealSalt 2018-01-08 15:48:19 -05:00
parent a1b84e8641
commit 9908339989
5 changed files with 78 additions and 35 deletions

View File

@ -282,6 +282,7 @@ typedef enum
k_comebacktimer, // Battle mode, how long before you become a bomb after death
// Each item needs its own power slot, for the HUD and held use
// *** ADDING A NEW ITEM? ADD IT TO K_DoBooSteal PLEASE!! -Salt ***
k_magnet, // 0x1 = Magnet in inventory
k_boo, // 0x1 = Boo in inventory
k_mushroom, // 0x1 = 1 Mushroom in inventory, 0x2 = 2 Mushrooms in inventory

View File

@ -1131,7 +1131,7 @@ static void K_KartItemRouletteByDistance(player_t *player, ticcmd_t *cmd)
//{ SRB2kart p_user.c Stuff
void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce)
void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid)
{
mobj_t *fx;
fixed_t momdifx, momdify;
@ -1176,14 +1176,19 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce)
{
fixed_t newz = mobj1->momz;
mobj1->momz = mobj2->momz;
mobj2->momz = newz;
if (solid == false)
mobj2->momz = newz;
}
mass1 = mass2 = 5*FRACUNIT;
if (mobj1->player)
mass1 = (mobj1->player->kartweight)*FRACUNIT;
if (mobj2->player)
mass2 = (mobj2->player->kartweight)*FRACUNIT;
else if (solid == true)
mass2 = mass1;
momdifx = mobj1->momx - mobj2->momx;
momdify = mobj1->momy - mobj2->momy;
@ -1220,8 +1225,11 @@ void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce)
mobj1->momx = mobj1->momx - FixedMul(FixedMul(FixedDiv(2*mass2, mass1 + mass2), p), distx);
mobj1->momy = mobj1->momy - FixedMul(FixedMul(FixedDiv(2*mass2, mass1 + mass2), p), disty);
mobj2->momx = mobj2->momx - FixedMul(FixedMul(FixedDiv(2*mass1, mass1 + mass2), p), -distx);
mobj2->momy = mobj2->momy - FixedMul(FixedMul(FixedDiv(2*mass1, mass1 + mass2), p), -disty);
if (solid == false)
{
mobj2->momx = mobj2->momx - FixedMul(FixedMul(FixedDiv(2*mass1, mass1 + mass2), p), -distx);
mobj2->momy = mobj2->momy - FixedMul(FixedMul(FixedDiv(2*mass1, mass1 + mass2), p), -disty);
}
// 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
@ -2448,36 +2456,46 @@ static void K_DoBooSteal(player_t *player)
{
INT32 i, numplayers = 0;
INT32 playerswappable[MAXPLAYERS];
INT32 stealplayer = 0; // The player that's getting stolen from
INT32 stealplayer = -1; // The player that's getting stolen from
INT32 prandom = 0;
if (gametype == GT_MATCH && player->kartstuff[k_balloon] <= 0)
return;
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && players[i].mo && players[i].mo->health > 0 && players[i].playerstate == PST_LIVE
&& player != &players[i] && !players[i].exiting && !(players[i].spectator)
&& player != &players[i] && !players[i].exiting && !players[i].spectator // Player in-game
// Can steal from this player
&& ((gametype == GT_RACE && players[i].kartstuff[k_position] < player->kartstuff[k_position])
|| (gametype != GT_RACE && players[i].kartstuff[k_balloon] > 0))
&& (players[i].kartstuff[k_star] || players[i].kartstuff[k_mushroom] || players[i].kartstuff[k_goldshroom]
|| players[i].kartstuff[k_megashroom] || players[i].kartstuff[k_lightning] || players[i].kartstuff[k_blueshell]
|| players[i].kartstuff[k_greenshell] & 2 || players[i].kartstuff[k_triplegreenshell] & 8
|| players[i].kartstuff[k_redshell] & 2 || players[i].kartstuff[k_tripleredshell] & 8
|| players[i].kartstuff[k_banana] & 2 || players[i].kartstuff[k_triplebanana] & 8
|| players[i].kartstuff[k_fakeitem] & 2 || players[i].kartstuff[k_bobomb] & 2
// Has an item
&& (players[i].kartstuff[k_magnet]
|| players[i].kartstuff[k_mushroom]
|| players[i].kartstuff[k_megashroom]
|| players[i].kartstuff[k_goldshroom]
|| players[i].kartstuff[k_star]
|| players[i].kartstuff[k_banana] & 2
|| players[i].kartstuff[k_triplebanana] & 8
|| players[i].kartstuff[k_fakeitem] & 2
|| players[i].kartstuff[k_greenshell] & 2
|| players[i].kartstuff[k_triplegreenshell] & 8
|| players[i].kartstuff[k_redshell] & 2
|| players[i].kartstuff[k_tripleredshell] & 8
|| players[i].kartstuff[k_bobomb] & 2
|| players[i].kartstuff[k_lightning]
|| players[i].kartstuff[k_blueshell]
|| players[i].kartstuff[k_fireflower]
|| players[i].kartstuff[k_feather] & 1
|| players[i].kartstuff[k_boo])) // Stealing boos with boos? sounds like fun
{
playerswappable[numplayers] = i+1;
playerswappable[numplayers] = i;
numplayers++;
}
}
prandom = P_RandomFixed();
if (player->kartstuff[k_position] == 1 || numplayers < 1 || !multiplayer) // No-one can be stolen from? Get longer invisibility for nothing
if ((gametype == GT_RACE && player->kartstuff[k_position] == 1) || numplayers == 0) // No-one can be stolen from? Get longer invisibility for nothing
{
player->kartstuff[k_bootimer] = bootime;
player->kartstuff[k_bootaketimer] = boostealtime;
@ -2486,17 +2504,15 @@ static void K_DoBooSteal(player_t *player)
}
else if (numplayers == 1) // With just 2 players, we just need to set the other player to be the one to steal from
{
stealplayer = playerswappable[numplayers - 1];
stealplayer = playerswappable[numplayers-1];
}
else if (numplayers > 1) // We need to choose between the available candidates for the 2nd player
{
stealplayer = playerswappable[prandom%(numplayers-1)];
}
if (stealplayer) // Now here's where we do the stealing, has to be done here because we still know the player we're stealing from
if (stealplayer > -1) // Now here's where we do the stealing, has to be done here because we still know the player we're stealing from
{
stealplayer -= 1; // stealplayer is +1 so we know if it found there actually WAS a player
player->kartstuff[k_bootimer] = bootime;
player->kartstuff[k_bootaketimer] = boostealtime;
player->kartstuff[k_boo] = 0;
@ -2572,12 +2588,22 @@ static void K_DoBooSteal(player_t *player)
player->kartstuff[k_bobomb] |= 2;
players[stealplayer].kartstuff[k_bobomb] &= ~2;
}
else if (players[stealplayer].kartstuff[k_magnet])
{
player->kartstuff[k_magnet] = players[stealplayer].kartstuff[k_magnet];
players[stealplayer].kartstuff[k_magnet] = 0;
}
else if (players[stealplayer].kartstuff[k_fireflower])
{
player->kartstuff[k_fireflower] = players[stealplayer].kartstuff[k_fireflower];
players[stealplayer].kartstuff[k_fireflower] = 0;
}
else if (players[stealplayer].kartstuff[k_feather] & 1)
{
player->kartstuff[k_feather] |= 1;
players[stealplayer].kartstuff[k_feather] &= ~1;
}
if (players[stealplayer].kartstuff[k_boo])
else if (players[stealplayer].kartstuff[k_boo])
{
player->kartstuff[k_boo] = players[stealplayer].kartstuff[k_boo];
players[stealplayer].kartstuff[k_boo] = 0;
@ -2672,16 +2698,16 @@ void K_DoBouncePad(mobj_t *mo, fixed_t vertispeed)
thrust = FixedMul(thrust, 5*FRACUNIT/4);
else if (mo->player->kartstuff[k_startimer])
thrust = FixedMul(thrust, 9*FRACUNIT/8);
mo->momz = FixedMul(FINESINE(ANGLE_22h>>ANGLETOFINESHIFT), thrust);
mo->momz = FixedMul(FINESINE(ANGLE_22h>>ANGLETOFINESHIFT), FixedMul(thrust, mo->scale));
}
else
{
thrust = P_AproxDistance(mo->momx,mo->momy);
if (thrust < 4<<FRACBITS)
thrust = 4<<FRACBITS;
if (thrust > 8<<FRACBITS)
if (thrust < 8<<FRACBITS)
thrust = 8<<FRACBITS;
mo->momz = FixedMul(FINESINE(ANGLE_22h>>ANGLETOFINESHIFT), thrust);
if (thrust > 16<<FRACBITS)
thrust = 16<<FRACBITS;
mo->momz = FixedMul(FINESINE(ANGLE_22h>>ANGLETOFINESHIFT), FixedMul(thrust, mo->scale));
}
}
else

View File

@ -18,7 +18,7 @@ UINT8 K_GetKartColorByName(const char *name);
void K_RegisterKartStuff(void);
UINT8 K_GetKartCC(void);
void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce);
void K_KartBouncing(mobj_t *mobj1, mobj_t *mobj2, boolean bounce, boolean solid);
void K_LakituChecker(player_t *player);
void K_KartMoveAnimation(player_t *player);
void K_KartPlayerThink(player_t *player, ticcmd_t *cmd);

View File

@ -2005,12 +2005,13 @@ static int lib_kKartBouncing(lua_State *L)
mobj_t *mobj1 = *((mobj_t **)luaL_checkudata(L, 1, META_MOBJ));
mobj_t *mobj2 = *((mobj_t **)luaL_checkudata(L, 2, META_MOBJ));
boolean bounce = luaL_checkboolean(L, 3);
boolean solid = luaL_checkboolean(L, 4);
NOHUD
if (!mobj1)
return LUA_ErrInvalid(L, "mobj_t");
if (!mobj2)
return LUA_ErrInvalid(L, "mobj_t");
K_KartBouncing(mobj1, mobj2, bounce);
K_KartBouncing(mobj1, mobj2, bounce, solid);
return 0;
}

View File

@ -1232,7 +1232,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
return true; // overhead
if (tmthing->z + tmthing->height < thing->z)
return true; // underneath
K_KartBouncing(thing, tmthing, false);
K_KartBouncing(thing, tmthing, false, false);
}
if ((thing->type == MT_SPRINGSHELL || thing->type == MT_YELLOWSHELL) && thing->health > 0
@ -1679,7 +1679,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
if (P_IsObjectOnGround(thing) && tmthing->momz < 0)
{
K_KartBouncing(tmthing, thing, true);
K_KartBouncing(tmthing, thing, true, false);
if (gametype != GT_RACE && tmthing->player->kartstuff[k_feather] & 2)
{
K_StealBalloon(tmthing->player, thing->player, false);
@ -1688,7 +1688,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
}
else if (P_IsObjectOnGround(tmthing) && thing->momz < 0)
{
K_KartBouncing(thing, tmthing, true);
K_KartBouncing(thing, tmthing, true, false);
if (gametype != GT_RACE && thing->player->kartstuff[k_feather] & 2)
{
K_StealBalloon(thing->player, tmthing->player, false);
@ -1696,7 +1696,7 @@ static boolean PIT_CheckThing(mobj_t *thing)
}
}
else
K_KartBouncing(tmthing, thing, false);
K_KartBouncing(tmthing, thing, false, false);
if (gametype != GT_RACE)
{
@ -1714,6 +1714,21 @@ static boolean PIT_CheckThing(mobj_t *thing)
return true;
}
else if (thing->flags & MF_SOLID)
{
// see if it went over / under
if (tmthing->z > thing->z + thing->height)
return true; // overhead
if (tmthing->z + tmthing->height < thing->z)
return true; // underneath
if (P_IsObjectOnGround(thing) && tmthing->momz < 0)
K_KartBouncing(tmthing, thing, true, true);
else
K_KartBouncing(tmthing, thing, false, true);
return true;
}
// 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)
@ -3177,8 +3192,8 @@ static void P_HitBounceLine(line_t *ld)
movelen = P_AproxDistance(tmxmove, tmymove);
if (slidemo->player && movelen < 25*FRACUNIT)
movelen = 25*FRACUNIT;
if (slidemo->player && movelen < 15*FRACUNIT)
movelen = 15*FRACUNIT;
tmxmove += FixedMul(movelen, FINECOSINE(lineangle));
tmymove += FixedMul(movelen, FINESINE(lineangle));