Merge branch 'caltropcalstop' into 'master'

Caltrop calstop (resolves #114)

Closes #114

See merge request KartKrew/Kart!381
This commit is contained in:
James R 2021-02-16 11:31:51 -05:00
commit 465bc55219
5 changed files with 21 additions and 18 deletions

View file

@ -1195,8 +1195,8 @@ static int lib_pGivePlayerRings(lua_State *L)
INLEVEL INLEVEL
if (!player) if (!player)
return LUA_ErrInvalid(L, "player_t"); return LUA_ErrInvalid(L, "player_t");
P_GivePlayerRings(player, num_rings); lua_pushinteger(L, P_GivePlayerRings(player, num_rings));
return 0; return 1;
} }
static int lib_pGivePlayerLives(lua_State *L) static int lib_pGivePlayerLives(lua_State *L)

View file

@ -4186,10 +4186,8 @@ void A_AttractChase(mobj_t *actor)
{ {
if (actor->extravalue1 >= 16) if (actor->extravalue1 >= 16)
{ {
if (actor->target->player->rings >= 20) if (!P_GivePlayerRings(actor->target->player, 1)) // returns 0 if addition failed
actor->target->player->kartstuff[k_ringboost] += K_GetKartRingPower(actor->target->player)+3; actor->target->player->kartstuff[k_ringboost] += K_GetKartRingPower(actor->target->player)+3;
else
P_GivePlayerRings(actor->target->player, 1);
if (actor->cvmem) // caching if (actor->cvmem) // caching
S_StartSound(actor->target, sfx_s1c5); S_StartSound(actor->target, sfx_s1c5);

View file

@ -2211,15 +2211,14 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings)
if (K_GetShieldFromItem(player->kartstuff[k_itemtype]) != KSHIELD_NONE) if (K_GetShieldFromItem(player->kartstuff[k_itemtype]) != KSHIELD_NONE)
return; return;
// 20 is the ring cap in kart // 20 is the maximum number of rings that can be taken from you at once - half the span of your counter
if (num_rings > 20) if (num_rings > 20)
num_rings = 20; num_rings = 20;
else if (num_rings <= 0) else if (num_rings <= 0)
return; return;
num_fling_rings = min(num_rings, player->rings); num_rings = -P_GivePlayerRings(player, -num_rings);
num_fling_rings = num_rings+min(0, player->rings);
P_GivePlayerRings(player, -num_rings);
// determine first angle // determine first angle
fa = player->mo->angle + ((P_RandomByte() & 1) ? -ANGLE_90 : ANGLE_90); fa = player->mo->angle + ((P_RandomByte() & 1) ? -ANGLE_90 : ANGLE_90);

View file

@ -167,7 +167,7 @@ boolean P_EndingMusic(player_t *player);
void P_SpawnShieldOrb(player_t *player); void P_SpawnShieldOrb(player_t *player);
void P_SwitchShield(player_t *player, UINT16 shieldtype); void P_SwitchShield(player_t *player, UINT16 shieldtype);
mobj_t *P_SpawnGhostMobj(mobj_t *mobj); mobj_t *P_SpawnGhostMobj(mobj_t *mobj);
void P_GivePlayerRings(player_t *player, INT32 num_rings); INT32 P_GivePlayerRings(player_t *player, INT32 num_rings);
void P_GivePlayerSpheres(player_t *player, INT32 num_spheres); void P_GivePlayerSpheres(player_t *player, INT32 num_spheres);
void P_GivePlayerLives(player_t *player, INT32 numlives); void P_GivePlayerLives(player_t *player, INT32 numlives);
UINT8 P_GetNextEmerald(void); UINT8 P_GetNextEmerald(void);

View file

@ -487,23 +487,29 @@ void P_ResetPlayer(player_t *player)
// //
// Gives rings to the player, and does any special things required. // Gives rings to the player, and does any special things required.
// Call this function when you want to increment the player's health. // Call this function when you want to increment the player's health.
// Returns the number of rings successfully given (or taken).
// //
void P_GivePlayerRings(player_t *player, INT32 num_rings) INT32 P_GivePlayerRings(player_t *player, INT32 num_rings)
{ {
INT32 test;
if (!player->mo) if (!player->mo)
return; return 0;
if ((gametyperules & GTR_BUMPERS)) // No rings in Battle Mode if ((gametyperules & GTR_BUMPERS)) // No rings in Battle Mode
return; return 0;
test = player->rings + num_rings;
if (test > 20) // Caps at 20 rings, sorry!
num_rings -= (test-20);
else if (test < -20) // Chaotix ring debt!
num_rings -= (test+20);
player->rings += num_rings; player->rings += num_rings;
//player->totalring += num_rings; // Used for GP lives later //player->totalring += num_rings; // Used for GP lives later -- maybe you might want to move this earlier to discourage ring debt...
if (player->rings > 20) return num_rings;
player->rings = 20; // Caps at 20 rings, sorry!
else if (player->rings < -20)
player->rings = -20; // Chaotix ring debt!
} }
// //