From 8391dd520ab9b9eb686140004559b586e31c5dbb Mon Sep 17 00:00:00 2001 From: SeventhSentinel Date: Wed, 2 Jan 2019 14:08:00 -0500 Subject: [PATCH] Add item spinning, turn into papersprites, spawn more orbs Also tried to fix a memory issue I only get from Sev's compiles by removing the need to free memory for this... but didn't fix anything :/ --- src/doomstat.h | 8 ++---- src/g_game.c | 2 +- src/info.c | 2 +- src/k_kart.c | 14 ++++------ src/p_inter.c | 31 ++++++++++---------- src/p_mobj.c | 76 +++++++++++++++++++++----------------------------- src/p_saveg.c | 24 ++++++++-------- src/p_setup.c | 4 +-- src/p_tick.c | 4 +-- 9 files changed, 71 insertions(+), 94 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index aa92e45ed..2c810dcfe 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -473,14 +473,12 @@ extern SINT8 pickedvote; /** Battle overtime information */ -typedef struct +extern struct battleovertime { - UINT8 enabled; ///< Has this been initalized yet? + UINT16 enabled; ///< Has this been initalized yet? fixed_t radius, minradius; ///< Radius of kill field fixed_t x, y, z; ///< Position to center on -} battleovertime_t; - -extern battleovertime_t *battleovertime; +} battleovertime; extern tic_t hidetime; diff --git a/src/g_game.c b/src/g_game.c index 75e7440b8..42652a4de 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -261,7 +261,7 @@ SINT8 votes[MAXPLAYERS]; // Each player's vote SINT8 pickedvote; // What vote the host rolls // Battle overtime system -battleovertime_t *battleovertime = {NULL}; +struct battleovertime battleovertime; // Server-sided, synched variables SINT8 battlewanted[4]; // WANTED players in battle, worth x2 points diff --git a/src/info.c b/src/info.c index 917e5ddec..50e10ba6b 100644 --- a/src/info.c +++ b/src/info.c @@ -3395,7 +3395,7 @@ state_t states[NUMSTATES] = {SPR_FWRK, 4|FF_FULLBRIGHT, TICRATE, {NULL}, 0, 0, S_NULL}, // S_KARMAFIREWORKTRAIL {SPR_OTFG, FF_FULLBRIGHT|FF_TRANS50, TICRATE, {NULL}, 0, 0, S_NULL}, // S_OVERTIMEFOG - {SPR_OTFG, 1|FF_FULLBRIGHT, 1, {NULL}, 0, 0, S_NULL}, // S_OVERTIMEORB + {SPR_OTFG, 1|FF_FULLBRIGHT|FF_TRANS30|FF_PAPERSPRITE, 1, {NULL}, 0, 0, S_NULL}, // S_OVERTIMEORB {SPR_OTFG, 3|FF_FULLBRIGHT, 1, {NULL}, 0, 0, S_NULL}, // S_OVERTIMEBEAM #ifdef SEENAMES diff --git a/src/k_kart.c b/src/k_kart.c index 87a655436..7dfddcb8a 100644 --- a/src/k_kart.c +++ b/src/k_kart.c @@ -1033,10 +1033,6 @@ static fixed_t K_GetMobjWeight(mobj_t *mobj, mobj_t *against) { fixed_t weight = 5<type == MT_RANDOMITEM) - return 10<type) { case MT_PLAYER: @@ -4398,9 +4394,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd) && !player->kartstuff[k_respawn] && !player->powers[pw_flashing]) { player->kartstuff[k_wanted]++; - if (battleovertime->enabled >= 5*TICRATE) + if (battleovertime.enabled >= 5*TICRATE) { - if (P_AproxDistance(player->mo->x - battleovertime->x, player->mo->y - battleovertime->y) > battleovertime->radius) + if (P_AproxDistance(player->mo->x - battleovertime.x, player->mo->y - battleovertime.y) > battleovertime.radius) { player->kartstuff[k_killfield]++; if (player->kartstuff[k_killfield] > 4*TICRATE) @@ -7437,15 +7433,15 @@ static void K_drawKartMinimap(void) y -= SHORT(AutomapPic->topoffset); // Draw the super item in Battle - if (G_BattleGametype() && battleovertime->enabled) + if (G_BattleGametype() && battleovertime.enabled) { - if (battleovertime->enabled >= 5*TICRATE || (battleovertime->enabled & 1)) + if (battleovertime.enabled >= 5*TICRATE || (battleovertime.enabled & 1)) { const INT32 prevsplitflags = splitflags; splitflags &= ~V_HUDTRANSHALF; splitflags |= V_HUDTRANS; colormap = R_GetTranslationColormap(TC_RAINBOW, (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))), GTC_CACHE); - K_drawKartMinimapHead(battleovertime->x, battleovertime->y, x, y, splitflags, kp_itemminimap, colormap, AutomapPic); + K_drawKartMinimapHead(battleovertime.x, battleovertime.y, x, y, splitflags, kp_itemminimap, colormap, AutomapPic); splitflags = prevsplitflags; } } diff --git a/src/p_inter.c b/src/p_inter.c index 6e4b6f0e9..f6eb9db65 100644 --- a/src/p_inter.c +++ b/src/p_inter.c @@ -373,14 +373,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) return; case MT_RANDOMITEM: // SRB2kart if (!P_CanPickupItem(player, 1)) - { - if (G_BattleGametype() && special->threshold == 70 && special->health) - { - K_KartBouncing(toucher, special, false, false); - special->extravalue1 = 6; - } return; - } if (G_BattleGametype() && player->kartstuff[k_bumper] <= 0) { @@ -1752,6 +1745,9 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck) } } +// Easily make it so that overtime works offline +#define TESTOVERTIMEINFREEPLAY + /** Checks if the level timer is over the timelimit and the round should end, * unless you are in overtime. In which case leveltime may stretch out beyond * timelimitintics and overtime's status will be checked here each tick. @@ -1796,10 +1792,9 @@ void P_CheckTimeLimit(void) } } } + else*/ //Optional tie-breaker for Match/CTF - else*/ -#define TESTOVERTIMEINFREEPLAY if (cv_overtime.value) { #ifndef TESTOVERTIMEINFREEPLAY @@ -1812,9 +1807,9 @@ void P_CheckTimeLimit(void) { #endif // Initiate the kill zone - if (!battleovertime->enabled) + if (!battleovertime.enabled) { - UINT8 b = 0; + INT32 b = 0; thinker_t *th; mobj_t *item = NULL; @@ -1843,12 +1838,12 @@ void P_CheckTimeLimit(void) return; item->threshold = 70; // Set constant respawn - battleovertime->x = item->x; - battleovertime->y = item->y; - battleovertime->z = item->z; - battleovertime->radius = 4096*mapheaderinfo[gamemap-1]->mobj_scale; - battleovertime->minradius = (cv_overtime.value == 2 ? 40 : 512)*mapheaderinfo[gamemap-1]->mobj_scale; - battleovertime->enabled++; + battleovertime.x = item->x; + battleovertime.y = item->y; + battleovertime.z = item->z; + battleovertime.radius = 4096*mapheaderinfo[gamemap-1]->mobj_scale; + battleovertime.minradius = (cv_overtime.value == 2 ? 40 : 512)*mapheaderinfo[gamemap-1]->mobj_scale; + battleovertime.enabled = 1; S_StartSound(NULL, sfx_kc47); } return; @@ -1870,6 +1865,8 @@ void P_CheckTimeLimit(void) } } +#undef TESTOVERTIMEINFREEPLAY + /** Checks if a player's score is over the pointlimit and the round should end. * Verify that the value of ::cv_pointlimit is greater than zero before * calling this function. diff --git a/src/p_mobj.c b/src/p_mobj.c index a37c26d78..1279ec7a8 100644 --- a/src/p_mobj.c +++ b/src/p_mobj.c @@ -6431,7 +6431,7 @@ static void P_SpawnOvertimeParticles(fixed_t x, fixed_t y, mobjtype_t type, bool scale *= 4; break; case MT_OVERTIMEORB: - scale += battleovertime->radius/1024; + scale += battleovertime.radius/1024; break; default: break; @@ -6509,13 +6509,12 @@ static void P_SpawnOvertimeParticles(fixed_t x, fixed_t y, mobjtype_t type, bool mo->momz = P_RandomRange(1,8)*mo->scale; break; case MT_OVERTIMEORB: - mo->destscale = mo->scale/4; + //mo->destscale = mo->scale/4; if ((leveltime/2) & 1) mo->frame++; - if (battleovertime->enabled < 5*TICRATE) + if (battleovertime.enabled < 5*TICRATE) mo->flags2 |= MF2_SHADOW; - /*if (i == 0 && !((leveltime/2) % 3 == 0)) - S_StartSoundAtVolume(mo, sfx_s1b1, 64);*/ + mo->angle = R_PointToAngle2(mo->x, mo->y, battleovertime.x, battleovertime.y) + ANGLE_90; break; default: break; @@ -6527,22 +6526,22 @@ static void P_SpawnOvertimeParticles(fixed_t x, fixed_t y, mobjtype_t type, bool void P_RunBattleOvertime(void) { UINT8 i, j; - UINT16 orbs = 16; + UINT16 orbs = 32; - if (battleovertime->enabled < 5*TICRATE) + if (battleovertime.enabled < 5*TICRATE) { - battleovertime->enabled++; - if (battleovertime->enabled == TICRATE) + battleovertime.enabled++; + if (battleovertime.enabled == TICRATE) S_StartSound(NULL, sfx_bhurry); - if (battleovertime->enabled == 5*TICRATE) + if (battleovertime.enabled == 5*TICRATE) S_StartSound(NULL, sfx_kc40); } else { - if (battleovertime->radius > battleovertime->minradius) - battleovertime->radius -= mapheaderinfo[gamemap-1]->mobj_scale; + if (battleovertime.radius > battleovertime.minradius) + battleovertime.radius -= mapheaderinfo[gamemap-1]->mobj_scale; else - battleovertime->radius = battleovertime->minradius; + battleovertime.radius = battleovertime.minradius; } if (leveltime & 1) @@ -6551,45 +6550,45 @@ void P_RunBattleOvertime(void) if (!splitscreen && players[displayplayer].mo) { - INT32 dist = P_AproxDistance(battleovertime->x-players[displayplayer].mo->x, battleovertime->y-players[displayplayer].mo->y); + INT32 dist = P_AproxDistance(battleovertime.x-players[displayplayer].mo->x, battleovertime.y-players[displayplayer].mo->y); transparency = max(0, NUMTRANSMAPS - ((256 + (dist>>FRACBITS)) / 256)); } if (transparency < NUMTRANSMAPS) { - mobj_t *beam = P_SpawnMobj(battleovertime->x, battleovertime->y, battleovertime->z + (mobjinfo[MT_RANDOMITEM].height/2), MT_OVERTIMEBEAM); + mobj_t *beam = P_SpawnMobj(battleovertime.x, battleovertime.y, battleovertime.z + (mobjinfo[MT_RANDOMITEM].height/2), MT_OVERTIMEBEAM); P_SetScale(beam, beam->scale*2); if (transparency > 0) beam->frame |= transparency<radius, 16*mapheaderinfo[gamemap-1]->mobj_scale)>>FRACBITS); + // 32 orbs at the normal minimum size of 512 + orbs = max(4, FixedDiv(battleovertime.radius, 16*mapheaderinfo[gamemap-1]->mobj_scale)>>FRACBITS); for (i = 0; i < orbs; i++) { angle_t ang = FixedAngle(((360/orbs) * i * (FRACUNIT>>1)) + (((leveltime*2) % 360)<x + P_ReturnThrustX(NULL, ang, battleovertime->radius); - fixed_t y = battleovertime->y + P_ReturnThrustY(NULL, ang, battleovertime->radius); + fixed_t x = battleovertime.x + P_ReturnThrustX(NULL, ang, battleovertime.radius); + fixed_t y = battleovertime.y + P_ReturnThrustY(NULL, ang, battleovertime.radius); P_SpawnOvertimeParticles(x, y, MT_OVERTIMEORB, true); } - if (battleovertime->enabled < 5*TICRATE) + if (battleovertime.enabled < 5*TICRATE) return; - if (!S_IdPlaying(sfx_s3kd4s)) // global ambience - S_StartSoundAtVolume(NULL, sfx_s3kd4s, min(255, ((4096*mapheaderinfo[gamemap-1]->mobj_scale) - battleovertime->radius)>>FRACBITS / 2)); + /*if (!S_IdPlaying(sfx_s3kd4s)) // global ambience + S_StartSoundAtVolume(NULL, sfx_s3kd4s, min(255, ((4096*mapheaderinfo[gamemap-1]->mobj_scale) - battleovertime.radius)>>FRACBITS / 2));*/ for (i = 0; i < 16; i++) { j = 0; while (j < 32) // max attempts { - fixed_t x = battleovertime->x + ((P_RandomRange(-64,64) * 128)<y + ((P_RandomRange(-64,64) * 128)<radius + (8*mobjinfo[MT_OVERTIMEFOG].radius); + fixed_t x = battleovertime.x + ((P_RandomRange(-64,64) * 128)<x, y-battleovertime->y) < closestdist) + if (P_AproxDistance(x-battleovertime.x, y-battleovertime.y) < closestdist) continue; P_SpawnOvertimeParticles(x, y, MT_OVERTIMEFOG, false); break; @@ -9303,26 +9302,15 @@ void P_MobjThinker(mobj_t *mobj) case MT_RANDOMITEM: if (G_BattleGametype() && mobj->threshold == 70) { - mobj->color = (1 + (leveltime % (MAXSKINCOLORS-1))); + mobj->color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))); mobj->colorized = true; - if (mobj->extravalue1) - mobj->extravalue1--; - else if (battleovertime->enabled) + + if (battleovertime.enabled) { - fixed_t dist = P_AproxDistance(P_AproxDistance(battleovertime->x-mobj->x, battleovertime->y-mobj->y), battleovertime->z-mobj->z); - if (dist > mobj->scale) - { - angle_t hang = R_PointToAngle2(mobj->x, mobj->y, battleovertime->x, battleovertime->y); - angle_t vang = R_PointToAngle2(mobj->z, 0, battleovertime->z, dist); - mobj->momx += FixedMul(FixedMul(mobj->scale, FINECOSINE(hang>>ANGLETOFINESHIFT)), FINECOSINE(vang>>ANGLETOFINESHIFT)); - mobj->momy += FixedMul(FixedMul(mobj->scale, FINESINE(hang>>ANGLETOFINESHIFT)), FINECOSINE(vang>>ANGLETOFINESHIFT)); - mobj->momz += FixedMul(mobj->scale, FINESINE(vang>>ANGLETOFINESHIFT)); - } - else - { - mobj->momx = mobj->momy = mobj->momz = 0; - P_TeleportMove(mobj, battleovertime->x, battleovertime->y, battleovertime->z); - } + fixed_t dist = min((4096*mapheaderinfo[gamemap-1]->mobj_scale - battleovertime.radius) / 2, 512*mapheaderinfo[gamemap-1]->mobj_scale); + angle_t ang = FixedAngle((leveltime % 360) << FRACBITS); + P_TeleportMove(mobj, battleovertime.x + P_ReturnThrustX(NULL, ang, dist), + battleovertime.y + P_ReturnThrustY(NULL, ang, dist), battleovertime.z); } } else diff --git a/src/p_saveg.c b/src/p_saveg.c index f23179280..5d4b88f84 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -3299,12 +3299,12 @@ static void P_NetArchiveMisc(void) WRITESINT8(save_p, battlewanted[i]); // battleovertime_t - WRITEUINT8(save_p, battleovertime->enabled); - WRITEFIXED(save_p, battleovertime->radius); - WRITEFIXED(save_p, battleovertime->minradius); - WRITEFIXED(save_p, battleovertime->x); - WRITEFIXED(save_p, battleovertime->y); - WRITEFIXED(save_p, battleovertime->z); + WRITEUINT16(save_p, battleovertime.enabled); + WRITEFIXED(save_p, battleovertime.radius); + WRITEFIXED(save_p, battleovertime.minradius); + WRITEFIXED(save_p, battleovertime.x); + WRITEFIXED(save_p, battleovertime.y); + WRITEFIXED(save_p, battleovertime.z); WRITEUINT32(save_p, wantedcalcdelay); WRITEUINT32(save_p, indirectitemcooldown); @@ -3414,12 +3414,12 @@ static inline boolean P_NetUnArchiveMisc(void) battlewanted[i] = READSINT8(save_p); // battleovertime_t - battleovertime->enabled = READUINT8(save_p); - battleovertime->radius = READFIXED(save_p); - battleovertime->minradius = READFIXED(save_p); - battleovertime->x = READFIXED(save_p); - battleovertime->y = READFIXED(save_p); - battleovertime->z = READFIXED(save_p); + battleovertime.enabled = READUINT16(save_p); + battleovertime.radius = READFIXED(save_p); + battleovertime.minradius = READFIXED(save_p); + battleovertime.x = READFIXED(save_p); + battleovertime.y = READFIXED(save_p); + battleovertime.z = READFIXED(save_p); wantedcalcdelay = READUINT32(save_p); indirectitemcooldown = READUINT32(save_p); diff --git a/src/p_setup.c b/src/p_setup.c index 01b231116..4bfb0ff88 100644 --- a/src/p_setup.c +++ b/src/p_setup.c @@ -2374,9 +2374,7 @@ static void P_LevelInitStuff(void) for (i = 0; i < 4; i++) battlewanted[i] = -1; - if (!battleovertime) - battleovertime = Z_Malloc(sizeof(battleovertime_t), PU_STATIC, NULL); - memset(battleovertime, 0, sizeof(battleovertime_t)); + memset(&battleovertime, 0, sizeof(struct battleovertime)); } // diff --git a/src/p_tick.c b/src/p_tick.c index def074d60..90b1835b6 100644 --- a/src/p_tick.c +++ b/src/p_tick.c @@ -621,7 +621,7 @@ void P_Ticker(boolean run) if (run) { P_RunThinkers(); - if (G_BattleGametype() && battleovertime->enabled) + if (G_BattleGametype() && battleovertime.enabled) P_RunBattleOvertime(); // Run any "after all the other thinkers" stuff @@ -762,7 +762,7 @@ void P_PreTicker(INT32 frames) } P_RunThinkers(); - if (G_BattleGametype() && battleovertime->enabled) + if (G_BattleGametype() && battleovertime.enabled) P_RunBattleOvertime(); // Run any "after all the other thinkers" stuff