From bf74b81842cbda88806fddb28b6aa057e3d24108 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 21:00:05 -0400 Subject: [PATCH 1/5] Snappier NiGHTS pickup attraction * Old attraction is still used for non-NiGHTS players due to a momentum bug. The old way is good enough to sidestep the bug. * Thanks Inuyasha (KS) for original code :dog: --- src/p_inter.c | 4 ++++ src/p_mobj.c | 40 ++++++++++++++++++++++++++++++++-------- src/p_user.c | 1 + 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index 5737e2c2a..01343cfb1 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -944,6 +944,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Yay! The thing's in reach! Pull it in! mo2->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; mo2->flags2 |= MF2_NIGHTSPULL; + mo2->movecount = 24*FRACUNIT; // initialize the NightsItemChase timer P_SetTarget(&mo2->tracer, toucher); } } @@ -2122,7 +2123,10 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget target->flags |= MF_NOGRAVITY|MF_NOCLIP|MF_NOCLIPHEIGHT; // Don't drop Tails 03-08-2000 if (target->flags2 & MF2_NIGHTSPULL) + { P_SetTarget(&target->tracer, NULL); + target->movecount = 0; // reset NightsItemChase timer + } // dead target is no more shootable target->flags &= ~(MF_SHOOTABLE|MF_FLOAT|MF_SPECIAL); diff --git a/src/p_mobj.c b/src/p_mobj.c index be373fbf4..c0924050c 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6096,9 +6096,11 @@ void P_SetScale(mobj_t *mobj, fixed_t newscale) void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on your target { fixed_t dist, ndist, speedmul; + angle_t vangle; fixed_t tx = dest->x; fixed_t ty = dest->y; fixed_t tz = dest->z + (dest->height/2); // Aim for center + fixed_t xydist = P_AproxDistance(tx - source->x, ty - source->y); if (!dest || dest->health <= 0 || !dest->player || !source->tracer) return; @@ -6107,19 +6109,40 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y source->angle = R_PointToAngle2(source->x, source->y, tx, ty); // change slope - dist = P_AproxDistance(P_AproxDistance(tx - source->x, ty - source->y), tz - source->z); + dist = P_AproxDistance(xydist, tz - source->z); if (dist < 1) dist = 1; - if (nightsgrab) - speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(8*FRACUNIT, source->scale); - else - speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(source->info->speed, source->scale); + if (nightsgrab && dest->player->powers[pw_carry] == CR_NIGHTSMODE) + { + source->movecount += FRACUNIT/2; - source->momx = FixedMul(FixedDiv(tx - source->x, dist), speedmul); - source->momy = FixedMul(FixedDiv(ty - source->y, dist), speedmul); - source->momz = FixedMul(FixedDiv(tz - source->z, dist), speedmul); + if (dist < source->movecount) + { + source->momx = source->momy = source->momz = 0; + P_TeleportMove(source, tx, ty, tz); + } + else + { + vangle = R_PointToAngle2(source->z, 0, tz, xydist); + + source->momx = FixedMul(FINESINE(vangle >> ANGLETOFINESHIFT), FixedMul(FINECOSINE(source->angle >> ANGLETOFINESHIFT), source->movecount)); + source->momy = FixedMul(FINESINE(vangle >> ANGLETOFINESHIFT), FixedMul(FINESINE(source->angle >> ANGLETOFINESHIFT), source->movecount)); + source->momz = FixedMul(FINECOSINE(vangle >> ANGLETOFINESHIFT), source->movecount); + } + } + else + { + if (nightsgrab) + speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(8*FRACUNIT, source->scale); + else + speedmul = P_AproxDistance(dest->momx, dest->momy) + FixedMul(source->info->speed, source->scale); + + source->momx = FixedMul(FixedDiv(tx - source->x, dist), speedmul); + source->momy = FixedMul(FixedDiv(ty - source->y, dist), speedmul); + source->momz = FixedMul(FixedDiv(tz - source->z, dist), speedmul); + } // Instead of just unsetting NOCLIP like an idiot, let's check the distance to our target. ndist = P_AproxDistance(P_AproxDistance(tx - (source->x+source->momx), @@ -6144,6 +6167,7 @@ static void P_NightsItemChase(mobj_t *thing) { P_SetTarget(&thing->tracer, NULL); thing->flags2 &= ~MF2_NIGHTSPULL; + //thing->movecount = 0; return; } diff --git a/src/p_user.c b/src/p_user.c index 357933f14..a601c5c2f 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9762,6 +9762,7 @@ void P_PlayerThink(player_t *player) // Yay! The thing's in reach! Pull it in! mo2->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; mo2->flags2 |= MF2_NIGHTSPULL; + mo2->movecount = 24*FRACUNIT; // initialize NightsItemChase timer P_SetTarget(&mo2->tracer, player->mo); } } From b28183129f5bb147c1075d6368c97bb98e7e33a8 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 22:13:06 -0400 Subject: [PATCH 2/5] NiGHTS drill meter penalty when mashing jump button Thanks Inuyasha (KS) for code --- src/p_user.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/p_user.c b/src/p_user.c index a601c5c2f..416ca807e 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6635,6 +6635,13 @@ static void P_NiGHTSMovement(player_t *player) S_StartSound(player->mo, sfx_drill1); player->drilltimer = 32; } + else if (player->drilltimer == 32) + { + player->drilltimer = 31; + player->drillmeter -= TICRATE/2; + if (player->drillmeter <= 0) + player->drillmeter = TICRATE/10; + } else if (--player->drilltimer <= 0) { player->drilltimer = 10; From 09f4309f4566cbc841d31fbcba156c08f8ba1e34 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 9 Aug 2018 23:14:14 -0400 Subject: [PATCH 3/5] Standardize NiGHTS link timer w/ NightsLinkTics MAINCFG option --- src/dehacked.c | 5 ++++- src/doomstat.h | 1 + src/g_game.c | 1 + src/p_inter.c | 10 +++++----- src/st_stuff.c | 4 ++-- 5 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/dehacked.c b/src/dehacked.c index c4d0bc104..3a18f2a45 100644 --- a/src/dehacked.c +++ b/src/dehacked.c @@ -2730,11 +2730,14 @@ static void readmaincfg(MYFILE *f) { extralifetics = (UINT16)get_number(word2); } + else if (fastcmp(word, "NIGHTSLINKTICS")) + { + nightslinktics = (UINT16)get_number(word2); + } else if (fastcmp(word, "GAMEOVERTICS")) { gameovertics = get_number(word2); } - else if (fastcmp(word, "INTROTOPLAY")) { introtoplay = (UINT8)get_number(word2); diff --git a/src/doomstat.h b/src/doomstat.h index 24b9e5753..97710c05d 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -413,6 +413,7 @@ extern UINT16 tailsflytics; extern UINT16 underwatertics; extern UINT16 spacetimetics; extern UINT16 extralifetics; +extern UINT16 nightslinktics; extern UINT8 introtoplay; extern UINT8 creditscutscene; diff --git a/src/g_game.c b/src/g_game.c index 52358a8b9..5af4743c4 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -201,6 +201,7 @@ UINT16 tailsflytics = 8*TICRATE; UINT16 underwatertics = 30*TICRATE; UINT16 spacetimetics = 11*TICRATE + (TICRATE/2); UINT16 extralifetics = 4*TICRATE; +UINT16 nightslinktics = 2*TICRATE; INT32 gameovertics = 15*TICRATE; diff --git a/src/p_inter.c b/src/p_inter.c index 01343cfb1..f4c1afada 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -182,14 +182,14 @@ void P_DoNightsScore(player_t *player) { if (++players[i].linkcount > players[i].maxlink) players[i].maxlink = players[i].linkcount; - players[i].linktimer = 2*TICRATE; + players[i].linktimer = nightslinktics; } } else // Individual link counts { if (++player->linkcount > player->maxlink) player->maxlink = player->linkcount; - player->linktimer = 2*TICRATE; + player->linktimer = nightslinktics; } if (player->linkcount < 10) @@ -1162,7 +1162,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (!G_IsSpecialStage(gamemap)) { player->powers[pw_nights_linkfreeze] = (UINT16)special->info->speed; - player->linktimer = 2*TICRATE; + player->linktimer = nightslinktics; } else { @@ -1170,7 +1170,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) if (playeringame[i] && players[i].powers[pw_carry] == CR_NIGHTSMODE) { players[i].powers[pw_nights_linkfreeze] += (UINT16)special->info->speed; - players[i].linktimer = 2*TICRATE; + players[i].linktimer = nightslinktics; } if (special->info->deathsound != sfx_None) S_StartSound(NULL, special->info->deathsound); @@ -2185,7 +2185,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget // to make people want to actually dash towards/paraloop enemies if (++source->player->linkcount > source->player->maxlink) source->player->maxlink = source->player->linkcount; - source->player->linktimer = 2*TICRATE; + source->player->linktimer = nightslinktics; } } else diff --git a/src/st_stuff.c b/src/st_stuff.c index 3ecd0acdf..64d3db7f2 100644 --- a/src/st_stuff.c +++ b/src/st_stuff.c @@ -1535,8 +1535,8 @@ static void ST_drawNiGHTSHUD(void) else colornum = linkColor[mag][sel]; - aflag |= ((stplyr->linktimer < 2*TICRATE/3) - ? (9 - 9*stplyr->linktimer/(2*TICRATE/3)) << V_ALPHASHIFT + aflag |= ((stplyr->linktimer < nightslinktics/3) + ? (9 - 9*stplyr->linktimer/(nightslinktics/3)) << V_ALPHASHIFT : 0); y = (160+11)< Date: Sun, 12 Aug 2018 23:03:12 -0400 Subject: [PATCH 4/5] Fix attraction bug on non-NiGHTS and Nightopian Helper * Switch from mo->movecount to mo->movefactor for type compat * Adjust timings for regular and paraloop attraction --- src/p_inter.c | 4 ++-- src/p_mobj.c | 14 +++++++------- src/p_user.c | 5 ++++- 3 files changed, 13 insertions(+), 10 deletions(-) diff --git a/src/p_inter.c b/src/p_inter.c index f93a190af..46c7aeb7a 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -946,7 +946,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) // Yay! The thing's in reach! Pull it in! mo2->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; mo2->flags2 |= MF2_NIGHTSPULL; - mo2->movecount = 24*FRACUNIT; // initialize the NightsItemChase timer + mo2->movefactor = 32*FRACUNIT; // initialize the NightsItemChase timer P_SetTarget(&mo2->tracer, toucher); } } @@ -2127,7 +2127,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget if (target->flags2 & MF2_NIGHTSPULL) { P_SetTarget(&target->tracer, NULL); - target->movecount = 0; // reset NightsItemChase timer + target->movefactor = 0; // reset NightsItemChase timer } // dead target is no more shootable diff --git a/src/p_mobj.c b/src/p_mobj.c index d80d967a8..ac6091dc7 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6120,11 +6120,11 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y if (dist < 1) dist = 1; - if (nightsgrab && dest->player->powers[pw_carry] == CR_NIGHTSMODE) + if (nightsgrab && source->movefactor) { - source->movecount += FRACUNIT/2; + source->movefactor += FRACUNIT/2; - if (dist < source->movecount) + if (dist < source->movefactor) { source->momx = source->momy = source->momz = 0; P_TeleportMove(source, tx, ty, tz); @@ -6133,9 +6133,9 @@ void P_Attract(mobj_t *source, mobj_t *dest, boolean nightsgrab) // Home in on y { vangle = R_PointToAngle2(source->z, 0, tz, xydist); - source->momx = FixedMul(FINESINE(vangle >> ANGLETOFINESHIFT), FixedMul(FINECOSINE(source->angle >> ANGLETOFINESHIFT), source->movecount)); - source->momy = FixedMul(FINESINE(vangle >> ANGLETOFINESHIFT), FixedMul(FINESINE(source->angle >> ANGLETOFINESHIFT), source->movecount)); - source->momz = FixedMul(FINECOSINE(vangle >> ANGLETOFINESHIFT), source->movecount); + source->momx = FixedMul(FINESINE(vangle >> ANGLETOFINESHIFT), FixedMul(FINECOSINE(source->angle >> ANGLETOFINESHIFT), source->movefactor)); + source->momy = FixedMul(FINESINE(vangle >> ANGLETOFINESHIFT), FixedMul(FINESINE(source->angle >> ANGLETOFINESHIFT), source->movefactor)); + source->momz = FixedMul(FINECOSINE(vangle >> ANGLETOFINESHIFT), source->movefactor); } } else @@ -6173,7 +6173,7 @@ static void P_NightsItemChase(mobj_t *thing) { P_SetTarget(&thing->tracer, NULL); thing->flags2 &= ~MF2_NIGHTSPULL; - //thing->movecount = 0; + thing->movefactor = 0; return; } diff --git a/src/p_user.c b/src/p_user.c index b363cb930..2962ca5ad 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -9770,13 +9770,16 @@ void P_PlayerThink(player_t *player) || mo2->type == MT_NIGHTSCHIP || mo2->type == MT_NIGHTSSTAR)) continue; + if (mo2->flags2 & MF2_NIGHTSPULL) + continue; + if (P_AproxDistance(P_AproxDistance(mo2->x - x, mo2->y - y), mo2->z - z) > FixedMul(128*FRACUNIT, player->mo->scale)) continue; // Yay! The thing's in reach! Pull it in! mo2->flags |= MF_NOCLIP|MF_NOCLIPHEIGHT; mo2->flags2 |= MF2_NIGHTSPULL; - mo2->movecount = 24*FRACUNIT; // initialize NightsItemChase timer + mo2->movefactor = 40*FRACUNIT; // initialize the NightsItemChase timer P_SetTarget(&mo2->tracer, player->mo); } } From dae37e2749a6df0b876666b5fb44eaca11729996 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Thu, 30 Aug 2018 09:09:19 -0400 Subject: [PATCH 5/5] Drill mash penalty fix --- src/p_user.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/p_user.c b/src/p_user.c index 76842b161..12383c423 100644 --- a/src/p_user.c +++ b/src/p_user.c @@ -6668,12 +6668,16 @@ static void P_NiGHTSMovement(player_t *player) } else if (player->drilltimer == 32) { + // drill mash penalty player->drilltimer = 31; player->drillmeter -= TICRATE/2; if (player->drillmeter <= 0) player->drillmeter = TICRATE/10; } - else if (--player->drilltimer <= 0) + else if (--player->drilltimer == 11) + // give that drill mash penalty back (after 0.6 seconds) + player->drillmeter += TICRATE/2; + else if (player->drilltimer <= 0) { player->drilltimer = 10; S_StartSound(player->mo, sfx_drill2);