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 :/
This commit is contained in:
SeventhSentinel 2019-01-02 14:08:00 -05:00
parent b27c709879
commit 8391dd520a
9 changed files with 71 additions and 94 deletions

View file

@ -473,14 +473,12 @@ extern SINT8 pickedvote;
/** Battle overtime information /** 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 radius, minradius; ///< Radius of kill field
fixed_t x, y, z; ///< Position to center on fixed_t x, y, z; ///< Position to center on
} battleovertime_t; } battleovertime;
extern battleovertime_t *battleovertime;
extern tic_t hidetime; extern tic_t hidetime;

View file

@ -261,7 +261,7 @@ SINT8 votes[MAXPLAYERS]; // Each player's vote
SINT8 pickedvote; // What vote the host rolls SINT8 pickedvote; // What vote the host rolls
// Battle overtime system // Battle overtime system
battleovertime_t *battleovertime = {NULL}; struct battleovertime battleovertime;
// Server-sided, synched variables // Server-sided, synched variables
SINT8 battlewanted[4]; // WANTED players in battle, worth x2 points SINT8 battlewanted[4]; // WANTED players in battle, worth x2 points

View file

@ -3395,7 +3395,7 @@ state_t states[NUMSTATES] =
{SPR_FWRK, 4|FF_FULLBRIGHT, TICRATE, {NULL}, 0, 0, S_NULL}, // S_KARMAFIREWORKTRAIL {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, 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 {SPR_OTFG, 3|FF_FULLBRIGHT, 1, {NULL}, 0, 0, S_NULL}, // S_OVERTIMEBEAM
#ifdef SEENAMES #ifdef SEENAMES

View file

@ -1033,10 +1033,6 @@ static fixed_t K_GetMobjWeight(mobj_t *mobj, mobj_t *against)
{ {
fixed_t weight = 5<<FRACBITS; fixed_t weight = 5<<FRACBITS;
// HACK for battle overtime camping on top of items
/*if (against->type == MT_RANDOMITEM)
return 10<<FRACBITS;*/
switch (mobj->type) switch (mobj->type)
{ {
case MT_PLAYER: 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_respawn] && !player->powers[pw_flashing])
{ {
player->kartstuff[k_wanted]++; 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]++; player->kartstuff[k_killfield]++;
if (player->kartstuff[k_killfield] > 4*TICRATE) if (player->kartstuff[k_killfield] > 4*TICRATE)
@ -7437,15 +7433,15 @@ static void K_drawKartMinimap(void)
y -= SHORT(AutomapPic->topoffset); y -= SHORT(AutomapPic->topoffset);
// Draw the super item in Battle // 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; const INT32 prevsplitflags = splitflags;
splitflags &= ~V_HUDTRANSHALF; splitflags &= ~V_HUDTRANSHALF;
splitflags |= V_HUDTRANS; splitflags |= V_HUDTRANS;
colormap = R_GetTranslationColormap(TC_RAINBOW, (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1))), GTC_CACHE); 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; splitflags = prevsplitflags;
} }
} }

View file

@ -373,14 +373,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
return; return;
case MT_RANDOMITEM: // SRB2kart case MT_RANDOMITEM: // SRB2kart
if (!P_CanPickupItem(player, 1)) if (!P_CanPickupItem(player, 1))
{
if (G_BattleGametype() && special->threshold == 70 && special->health)
{
K_KartBouncing(toucher, special, false, false);
special->extravalue1 = 6;
}
return; return;
}
if (G_BattleGametype() && player->kartstuff[k_bumper] <= 0) 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, /** 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 * unless you are in overtime. In which case leveltime may stretch out beyond
* timelimitintics and overtime's status will be checked here each tick. * 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 //Optional tie-breaker for Match/CTF
else*/
#define TESTOVERTIMEINFREEPLAY
if (cv_overtime.value) if (cv_overtime.value)
{ {
#ifndef TESTOVERTIMEINFREEPLAY #ifndef TESTOVERTIMEINFREEPLAY
@ -1812,9 +1807,9 @@ void P_CheckTimeLimit(void)
{ {
#endif #endif
// Initiate the kill zone // Initiate the kill zone
if (!battleovertime->enabled) if (!battleovertime.enabled)
{ {
UINT8 b = 0; INT32 b = 0;
thinker_t *th; thinker_t *th;
mobj_t *item = NULL; mobj_t *item = NULL;
@ -1843,12 +1838,12 @@ void P_CheckTimeLimit(void)
return; return;
item->threshold = 70; // Set constant respawn item->threshold = 70; // Set constant respawn
battleovertime->x = item->x; battleovertime.x = item->x;
battleovertime->y = item->y; battleovertime.y = item->y;
battleovertime->z = item->z; battleovertime.z = item->z;
battleovertime->radius = 4096*mapheaderinfo[gamemap-1]->mobj_scale; battleovertime.radius = 4096*mapheaderinfo[gamemap-1]->mobj_scale;
battleovertime->minradius = (cv_overtime.value == 2 ? 40 : 512)*mapheaderinfo[gamemap-1]->mobj_scale; battleovertime.minradius = (cv_overtime.value == 2 ? 40 : 512)*mapheaderinfo[gamemap-1]->mobj_scale;
battleovertime->enabled++; battleovertime.enabled = 1;
S_StartSound(NULL, sfx_kc47); S_StartSound(NULL, sfx_kc47);
} }
return; 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. /** 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 * Verify that the value of ::cv_pointlimit is greater than zero before
* calling this function. * calling this function.

View file

@ -6431,7 +6431,7 @@ static void P_SpawnOvertimeParticles(fixed_t x, fixed_t y, mobjtype_t type, bool
scale *= 4; scale *= 4;
break; break;
case MT_OVERTIMEORB: case MT_OVERTIMEORB:
scale += battleovertime->radius/1024; scale += battleovertime.radius/1024;
break; break;
default: default:
break; 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; mo->momz = P_RandomRange(1,8)*mo->scale;
break; break;
case MT_OVERTIMEORB: case MT_OVERTIMEORB:
mo->destscale = mo->scale/4; //mo->destscale = mo->scale/4;
if ((leveltime/2) & 1) if ((leveltime/2) & 1)
mo->frame++; mo->frame++;
if (battleovertime->enabled < 5*TICRATE) if (battleovertime.enabled < 5*TICRATE)
mo->flags2 |= MF2_SHADOW; mo->flags2 |= MF2_SHADOW;
/*if (i == 0 && !((leveltime/2) % 3 == 0)) mo->angle = R_PointToAngle2(mo->x, mo->y, battleovertime.x, battleovertime.y) + ANGLE_90;
S_StartSoundAtVolume(mo, sfx_s1b1, 64);*/
break; break;
default: default:
break; break;
@ -6527,22 +6526,22 @@ static void P_SpawnOvertimeParticles(fixed_t x, fixed_t y, mobjtype_t type, bool
void P_RunBattleOvertime(void) void P_RunBattleOvertime(void)
{ {
UINT8 i, j; UINT8 i, j;
UINT16 orbs = 16; UINT16 orbs = 32;
if (battleovertime->enabled < 5*TICRATE) if (battleovertime.enabled < 5*TICRATE)
{ {
battleovertime->enabled++; battleovertime.enabled++;
if (battleovertime->enabled == TICRATE) if (battleovertime.enabled == TICRATE)
S_StartSound(NULL, sfx_bhurry); S_StartSound(NULL, sfx_bhurry);
if (battleovertime->enabled == 5*TICRATE) if (battleovertime.enabled == 5*TICRATE)
S_StartSound(NULL, sfx_kc40); S_StartSound(NULL, sfx_kc40);
} }
else else
{ {
if (battleovertime->radius > battleovertime->minradius) if (battleovertime.radius > battleovertime.minradius)
battleovertime->radius -= mapheaderinfo[gamemap-1]->mobj_scale; battleovertime.radius -= mapheaderinfo[gamemap-1]->mobj_scale;
else else
battleovertime->radius = battleovertime->minradius; battleovertime.radius = battleovertime.minradius;
} }
if (leveltime & 1) if (leveltime & 1)
@ -6551,45 +6550,45 @@ void P_RunBattleOvertime(void)
if (!splitscreen && players[displayplayer].mo) 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)); transparency = max(0, NUMTRANSMAPS - ((256 + (dist>>FRACBITS)) / 256));
} }
if (transparency < NUMTRANSMAPS) 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); P_SetScale(beam, beam->scale*2);
if (transparency > 0) if (transparency > 0)
beam->frame |= transparency<<FF_TRANSSHIFT; beam->frame |= transparency<<FF_TRANSSHIFT;
} }
} }
// 16 orbs at the normal minimum size of 512 // 32 orbs at the normal minimum size of 512
orbs = max(4, FixedDiv(battleovertime->radius, 16*mapheaderinfo[gamemap-1]->mobj_scale)>>FRACBITS); orbs = max(4, FixedDiv(battleovertime.radius, 16*mapheaderinfo[gamemap-1]->mobj_scale)>>FRACBITS);
for (i = 0; i < orbs; i++) for (i = 0; i < orbs; i++)
{ {
angle_t ang = FixedAngle(((360/orbs) * i * (FRACUNIT>>1)) + (((leveltime*2) % 360)<<FRACBITS)); angle_t ang = FixedAngle(((360/orbs) * i * (FRACUNIT>>1)) + (((leveltime*2) % 360)<<FRACBITS));
fixed_t x = battleovertime->x + P_ReturnThrustX(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); fixed_t y = battleovertime.y + P_ReturnThrustY(NULL, ang, battleovertime.radius);
P_SpawnOvertimeParticles(x, y, MT_OVERTIMEORB, true); P_SpawnOvertimeParticles(x, y, MT_OVERTIMEORB, true);
} }
if (battleovertime->enabled < 5*TICRATE) if (battleovertime.enabled < 5*TICRATE)
return; return;
if (!S_IdPlaying(sfx_s3kd4s)) // global ambience /*if (!S_IdPlaying(sfx_s3kd4s)) // global ambience
S_StartSoundAtVolume(NULL, sfx_s3kd4s, min(255, ((4096*mapheaderinfo[gamemap-1]->mobj_scale) - battleovertime->radius)>>FRACBITS / 2)); S_StartSoundAtVolume(NULL, sfx_s3kd4s, min(255, ((4096*mapheaderinfo[gamemap-1]->mobj_scale) - battleovertime.radius)>>FRACBITS / 2));*/
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
j = 0; j = 0;
while (j < 32) // max attempts while (j < 32) // max attempts
{ {
fixed_t x = battleovertime->x + ((P_RandomRange(-64,64) * 128)<<FRACBITS); fixed_t x = battleovertime.x + ((P_RandomRange(-64,64) * 128)<<FRACBITS);
fixed_t y = battleovertime->y + ((P_RandomRange(-64,64) * 128)<<FRACBITS); fixed_t y = battleovertime.y + ((P_RandomRange(-64,64) * 128)<<FRACBITS);
fixed_t closestdist = battleovertime->radius + (8*mobjinfo[MT_OVERTIMEFOG].radius); fixed_t closestdist = battleovertime.radius + (8*mobjinfo[MT_OVERTIMEFOG].radius);
j++; j++;
if (P_AproxDistance(x-battleovertime->x, y-battleovertime->y) < closestdist) if (P_AproxDistance(x-battleovertime.x, y-battleovertime.y) < closestdist)
continue; continue;
P_SpawnOvertimeParticles(x, y, MT_OVERTIMEFOG, false); P_SpawnOvertimeParticles(x, y, MT_OVERTIMEFOG, false);
break; break;
@ -9303,26 +9302,15 @@ void P_MobjThinker(mobj_t *mobj)
case MT_RANDOMITEM: case MT_RANDOMITEM:
if (G_BattleGametype() && mobj->threshold == 70) if (G_BattleGametype() && mobj->threshold == 70)
{ {
mobj->color = (1 + (leveltime % (MAXSKINCOLORS-1))); mobj->color = (UINT8)(1 + (leveltime % (MAXSKINCOLORS-1)));
mobj->colorized = true; mobj->colorized = true;
if (mobj->extravalue1)
mobj->extravalue1--; if (battleovertime.enabled)
else if (battleovertime->enabled)
{ {
fixed_t dist = P_AproxDistance(P_AproxDistance(battleovertime->x-mobj->x, battleovertime->y-mobj->y), battleovertime->z-mobj->z); fixed_t dist = min((4096*mapheaderinfo[gamemap-1]->mobj_scale - battleovertime.radius) / 2, 512*mapheaderinfo[gamemap-1]->mobj_scale);
if (dist > mobj->scale) angle_t ang = FixedAngle((leveltime % 360) << FRACBITS);
{ P_TeleportMove(mobj, battleovertime.x + P_ReturnThrustX(NULL, ang, dist),
angle_t hang = R_PointToAngle2(mobj->x, mobj->y, battleovertime->x, battleovertime->y); battleovertime.y + P_ReturnThrustY(NULL, ang, dist), battleovertime.z);
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);
}
} }
} }
else else

View file

@ -3299,12 +3299,12 @@ static void P_NetArchiveMisc(void)
WRITESINT8(save_p, battlewanted[i]); WRITESINT8(save_p, battlewanted[i]);
// battleovertime_t // battleovertime_t
WRITEUINT8(save_p, battleovertime->enabled); WRITEUINT16(save_p, battleovertime.enabled);
WRITEFIXED(save_p, battleovertime->radius); WRITEFIXED(save_p, battleovertime.radius);
WRITEFIXED(save_p, battleovertime->minradius); WRITEFIXED(save_p, battleovertime.minradius);
WRITEFIXED(save_p, battleovertime->x); WRITEFIXED(save_p, battleovertime.x);
WRITEFIXED(save_p, battleovertime->y); WRITEFIXED(save_p, battleovertime.y);
WRITEFIXED(save_p, battleovertime->z); WRITEFIXED(save_p, battleovertime.z);
WRITEUINT32(save_p, wantedcalcdelay); WRITEUINT32(save_p, wantedcalcdelay);
WRITEUINT32(save_p, indirectitemcooldown); WRITEUINT32(save_p, indirectitemcooldown);
@ -3414,12 +3414,12 @@ static inline boolean P_NetUnArchiveMisc(void)
battlewanted[i] = READSINT8(save_p); battlewanted[i] = READSINT8(save_p);
// battleovertime_t // battleovertime_t
battleovertime->enabled = READUINT8(save_p); battleovertime.enabled = READUINT16(save_p);
battleovertime->radius = READFIXED(save_p); battleovertime.radius = READFIXED(save_p);
battleovertime->minradius = READFIXED(save_p); battleovertime.minradius = READFIXED(save_p);
battleovertime->x = READFIXED(save_p); battleovertime.x = READFIXED(save_p);
battleovertime->y = READFIXED(save_p); battleovertime.y = READFIXED(save_p);
battleovertime->z = READFIXED(save_p); battleovertime.z = READFIXED(save_p);
wantedcalcdelay = READUINT32(save_p); wantedcalcdelay = READUINT32(save_p);
indirectitemcooldown = READUINT32(save_p); indirectitemcooldown = READUINT32(save_p);

View file

@ -2374,9 +2374,7 @@ static void P_LevelInitStuff(void)
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
battlewanted[i] = -1; battlewanted[i] = -1;
if (!battleovertime) memset(&battleovertime, 0, sizeof(struct battleovertime));
battleovertime = Z_Malloc(sizeof(battleovertime_t), PU_STATIC, NULL);
memset(battleovertime, 0, sizeof(battleovertime_t));
} }
// //

View file

@ -621,7 +621,7 @@ void P_Ticker(boolean run)
if (run) if (run)
{ {
P_RunThinkers(); P_RunThinkers();
if (G_BattleGametype() && battleovertime->enabled) if (G_BattleGametype() && battleovertime.enabled)
P_RunBattleOvertime(); P_RunBattleOvertime();
// Run any "after all the other thinkers" stuff // Run any "after all the other thinkers" stuff
@ -762,7 +762,7 @@ void P_PreTicker(INT32 frames)
} }
P_RunThinkers(); P_RunThinkers();
if (G_BattleGametype() && battleovertime->enabled) if (G_BattleGametype() && battleovertime.enabled)
P_RunBattleOvertime(); P_RunBattleOvertime();
// Run any "after all the other thinkers" stuff // Run any "after all the other thinkers" stuff