mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-18 15:32:33 +00:00
Merge branch 'unsteal-ideya-spheres' into 'next'
Fix Ideya Capture sometimes stealing extra spheres See merge request STJr/SRB2!1768
This commit is contained in:
commit
2b9af0ff24
1 changed files with 13 additions and 9 deletions
22
src/p_user.c
22
src/p_user.c
|
@ -6705,7 +6705,7 @@ static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t rad
|
|||
//
|
||||
static void P_DoNiGHTSCapsule(player_t *player)
|
||||
{
|
||||
INT32 i, spherecount, totalduration, popduration, deductinterval, deductquantity, sphereresult, firstpoptic, startingspheres;
|
||||
INT32 i, spherecount, totalduration, popduration, deductinterval, deductquantity, sphereresult, firstpoptic;
|
||||
INT32 tictimer = ++player->capsule->extravalue2;
|
||||
|
||||
if (abs(player->mo->x-player->capsule->x) <= 3*FRACUNIT)
|
||||
|
@ -6828,15 +6828,20 @@ static void P_DoNiGHTSCapsule(player_t *player)
|
|||
|
||||
if (player->capsule->health > sphereresult && player->spheres > 0)
|
||||
{
|
||||
// If spherecount isn't a multiple of deductquantity, the final deduction might steal too many spheres from the player
|
||||
// E.g. with 80 capsule health, deductquantity is 3, 3*26 is 78, 78+3=81, and then it'll have stolen more than the 80 that it was meant to!
|
||||
// So let's adjust deductquantity accordingly for the final deduction
|
||||
deductquantity = min(deductquantity, player->capsule->health - sphereresult);
|
||||
|
||||
player->spheres -= deductquantity;
|
||||
player->capsule->health -= deductquantity;
|
||||
|
||||
if (player->spheres < 0) // This can't happen... without Lua, setrings, et cetera
|
||||
player->spheres = 0;
|
||||
|
||||
//if (player->capsule->health < sphereresult) // This can't happen
|
||||
//player->capsule->health = sphereresult;
|
||||
}
|
||||
|
||||
if (player->spheres < 0)
|
||||
player->spheres = 0;
|
||||
|
||||
if (player->capsule->health < sphereresult)
|
||||
player->capsule->health = sphereresult;
|
||||
}
|
||||
|
||||
// Spawn a 'pop' for every 2 tics
|
||||
|
@ -6857,9 +6862,8 @@ static void P_DoNiGHTSCapsule(player_t *player)
|
|||
}
|
||||
else
|
||||
{
|
||||
startingspheres = player->spheres - player->capsule->health;
|
||||
player->spheres -= player->capsule->health;
|
||||
player->capsule->health = 0;
|
||||
player->spheres = startingspheres;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue