0
0
Fork 0
mirror of https://git.do.srb2.org/STJr/SRB2.git synced 2025-03-04 16:32:39 +00:00

Fixed capsule timing logic

* Force a total time, stretch out sphere deduction within that time
* Make it more readable
This commit is contained in:
mazmazz 2018-08-15 13:38:15 -04:00
parent 59f71e4c48
commit 2e8c4b5545
2 changed files with 43 additions and 29 deletions

View file

@ -8751,11 +8751,10 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
nummaprings = -1; // no perfect bonus, rings are free nummaprings = -1; // no perfect bonus, rings are free
break; break;
case MT_EGGCAPSULE: case MT_EGGCAPSULE:
mobj->extravalue1 = -1; // sphere timer for how long a player has been at the capsule mobj->reactiontime = 0;
mobj->extravalue2 = -1; // tic timer for how long a player has been at the capsule mobj->extravalue1 = mobj->cvmem =\
mobj->lastlook = -1; mobj->cusval = mobj->movecount =\
mobj->cusval = -1; mobj->lastlook = mobj->extravalue2 = -1;
mobj->movecount = -1;
break; break;
case MT_REDTEAMRING: case MT_REDTEAMRING:
mobj->color = skincolor_redteam; mobj->color = skincolor_redteam;

View file

@ -5925,9 +5925,8 @@ static void P_NightsTransferPoints(player_t *player, fixed_t xspeed, fixed_t rad
// //
static void P_DoNiGHTSCapsule(player_t *player) static void P_DoNiGHTSCapsule(player_t *player)
{ {
INT32 i; INT32 i, spherecount, totalduration, popduration, deductinterval, deductquantity, sphereresult, firstpoptic;
INT32 tictimer = ++player->capsule->extravalue2;
player->capsule->extravalue2++;
if (abs(player->mo->x-player->capsule->x) <= 3*FRACUNIT) if (abs(player->mo->x-player->capsule->x) <= 3*FRACUNIT)
{ {
@ -5997,32 +5996,46 @@ static void P_DoNiGHTSCapsule(player_t *player)
{ {
if (player->capsule->lastlook < 0) if (player->capsule->lastlook < 0)
{ {
INT32 popduration = max(60 - player->capsule->extravalue2, 1); // Stretch the sphere deduction across the capsule time!
INT32 spherecount = min(player->spheres, player->capsule->health); // 1. Force the remaining capsule time to `popduration`
player->capsule->extravalue1 = player->capsule->health - spherecount; // 2. Given `popduration` and `spherecount`, at what tic interval do we deduct spheres? `deductinterval`
player->capsule->lastlook = max(FixedRound(FixedDiv(spherecount, popduration))/FRACUNIT, 1); // 3. And on each deduction, how many spheres do we deduct? `deductquantity`
player->capsule->cusval = max(FixedFloor(FixedDiv(popduration, spherecount))/FRACUNIT, 1); // 4. Store the expected capsule health upon completion: `sphereresult`
player->capsule->movecount = player->capsule->extravalue2; spherecount = min(player->spheres, player->capsule->health);
player->capsule->cvmem = popduration; totalduration = min(40 + spherecount, 60);
popduration = player->capsule->extravalue1 = max(totalduration - tictimer, 1);
deductinterval = player->capsule->cvmem = max(FixedFloor(FixedDiv(popduration, spherecount))/FRACUNIT, 1);
deductquantity = player->capsule->cusval = max(FixedRound(FixedDiv(spherecount, popduration))/FRACUNIT, 1);
sphereresult = player->capsule->movecount = player->capsule->health - spherecount;
firstpoptic = player->capsule->lastlook = tictimer;
}
else
{
popduration = player->capsule->extravalue1;
deductinterval = player->capsule->cvmem;
deductquantity = player->capsule->cusval;
sphereresult = player->capsule->movecount;
firstpoptic = player->capsule->lastlook;
} }
if (player->capsule->extravalue2 - player->capsule->movecount < player->capsule->cvmem) if (tictimer - firstpoptic < popduration)
{ {
if (!((player->capsule->extravalue2 - player->capsule->movecount) % player->capsule->cusval) if (!((tictimer - firstpoptic) % deductinterval)
&& player->capsule->health > player->capsule->extravalue1) && player->capsule->health > sphereresult)
{ {
player->spheres -= player->capsule->lastlook; player->spheres -= deductquantity;
player->capsule->health -= player->capsule->lastlook; player->capsule->health -= deductquantity;
if (player->spheres < 0) if (player->spheres < 0)
player->spheres = 0; player->spheres = 0;
if (player->capsule->health < player->capsule->extravalue1) if (player->capsule->health < sphereresult)
player->capsule->health = player->capsule->extravalue1; player->capsule->health = sphereresult;
} }
// Spawn a 'pop' for every 5 rings you deposit // Spawn a 'pop' for every 5 tics
if (!((player->capsule->extravalue2 - player->capsule->movecount) % 5)) if (!((tictimer - firstpoptic) % 5))
S_StartSound(P_SpawnMobj(player->capsule->x + ((P_SignedRandom()/2)<<FRACBITS), S_StartSound(P_SpawnMobj(player->capsule->x + ((P_SignedRandom()/2)<<FRACBITS),
player->capsule->y + ((P_SignedRandom()/2)<<FRACBITS), player->capsule->y + ((P_SignedRandom()/2)<<FRACBITS),
player->capsule->z + (player->capsule->height/2) + ((P_SignedRandom()/2)<<FRACBITS), player->capsule->z + (player->capsule->height/2) + ((P_SignedRandom()/2)<<FRACBITS),
@ -6030,15 +6043,15 @@ static void P_DoNiGHTSCapsule(player_t *player)
} }
else else
{ {
if (player->capsule->health > player->capsule->extravalue1) if (player->capsule->health > sphereresult)
player->capsule->health = player->capsule->extravalue1; player->capsule->health = sphereresult;
if (player->capsule->health <= 0) if (player->capsule->health <= 0)
{ {
player->capsule->flags &= ~MF_NOGRAVITY; player->capsule->flags &= ~MF_NOGRAVITY;
player->capsule->momz = 5*FRACUNIT; player->capsule->momz = 5*FRACUNIT;
player->capsule->reactiontime = 0; player->capsule->reactiontime = 0;
player->capsule->extravalue2 = -1; tictimer = -1;
for (i = 0; i < MAXPLAYERS; i++) for (i = 0; i < MAXPLAYERS; i++)
if (playeringame[i] && !player->exiting && players[i].mare == player->mare) if (playeringame[i] && !player->exiting && players[i].mare == player->mare)
@ -6124,12 +6137,14 @@ static void P_DoNiGHTSCapsule(player_t *player)
player->texttimer = 4*TICRATE; player->texttimer = 4*TICRATE;
player->textvar = 3; // Get more rings! player->textvar = 3; // Get more rings!
player->capsule->reactiontime = 0; player->capsule->reactiontime = 0;
player->capsule->extravalue1 = player->capsule->extravalue2 = player->capsule->lastlook = player->capsule->cusval = player->capsule->movecount = -1; player->capsule->extravalue1 = player->capsule->cvmem =\
player->capsule->cusval = player->capsule->movecount =\
player->capsule->lastlook = player->capsule->extravalue2 = -1;
} }
} }
} }
else else
player->capsule->extravalue1 = -1; player->capsule->lastlook = -1;
} }
// //