Merge branch 'master' into better-splash

This commit is contained in:
Sally Coolatta 2022-09-25 20:01:27 -04:00
commit 21d32511a5
41 changed files with 1587 additions and 1257 deletions

View file

@ -5020,7 +5020,19 @@ static INT16 Consistancy(void)
// I give up
// Coop desynching enemies is painful
if (gamestate == GS_LEVEL)
ret += P_GetRandSeed();
{
for (i = 0; i < PRNUMCLASS; i++)
{
if (i & 1)
{
ret -= P_GetRandSeed(i);
}
else
{
ret += P_GetRandSeed(i);
}
}
}
#ifdef MOBJCONSISTANCY
if (gamestate == GS_LEVEL)

View file

@ -74,6 +74,7 @@
#include "k_grandprix.h"
#include "k_boss.h"
#include "doomstat.h"
#include "m_random.h" // P_ClearRandom
#ifdef CMAKECONFIG
#include "config.h"
@ -1225,6 +1226,11 @@ void D_SRB2Main(void)
// initialise locale code
M_StartupLocale();
// This will be done more properly on
// level load, but for now at least make
// sure that it is initalized at all
P_ClearRandom(0);
// get parameters from a response file (eg: srb2 @parms.txt)
M_FindResponseFile();

View file

@ -3012,7 +3012,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
mapnumber = READINT16(*cp);
if (netgame)
P_SetRandSeed(READUINT32(*cp));
P_ClearRandom(READUINT32(*cp));
if (!skipprecutscene)
{
@ -3266,7 +3266,9 @@ static void Got_RandomSeed(UINT8 **cp, INT32 playernum)
if (playernum != serverplayer) // it's not from the server, wtf?
return;
P_SetRandSeed(seed);
// Sal: this seems unused, so this is probably fine?
// If it needs specific RNG classes, then it should be easy to add.
P_ClearRandom(seed);
}
/** Clears all players' scores in a netgame.

View file

@ -309,7 +309,6 @@ actionpointer_t actionpointers[] =
// SRB2Kart
{{A_ItemPop}, "A_ITEMPOP"},
{{A_JawzChase}, "A_JAWZCHASE"},
{{A_JawzExplode}, "A_JAWZEXPLODE"},
{{A_SSMineSearch}, "A_SSMINESEARCH"},
{{A_SSMineExplode}, "A_SSMINEEXPLODE"},
@ -3512,14 +3511,6 @@ const char *const STATE_LIST[] = { // array length left dynamic for sanity testi
"S_JAWZ6",
"S_JAWZ7",
"S_JAWZ8",
"S_JAWZ_DUD1",
"S_JAWZ_DUD2",
"S_JAWZ_DUD3",
"S_JAWZ_DUD4",
"S_JAWZ_DUD5",
"S_JAWZ_DUD6",
"S_JAWZ_DUD7",
"S_JAWZ_DUD8",
"S_JAWZ_SHIELD1",
"S_JAWZ_SHIELD2",
"S_JAWZ_SHIELD3",
@ -5326,7 +5317,6 @@ const char *const MOBJTYPE_LIST[] = { // array length left dynamic for sanity t
"MT_ORBINAUT_SHIELD",
"MT_JAWZ", // Jawz stuff
"MT_JAWZ_DUD",
"MT_JAWZ_SHIELD",
"MT_PLAYERRETICULE", // Jawz reticule

View file

@ -392,14 +392,18 @@ void G_ReadDemoExtraData(void)
switch (p)
{
case DW_RNG:
rng = READUINT32(demo_p);
if (P_GetRandSeed() != rng)
for (i = 0; i < PRNUMCLASS; i++)
{
P_SetRandSeed(rng);
rng = READUINT32(demo_p);
if (demosynced)
CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (RNG)!\n"));
demosynced = false;
if (P_GetRandSeed(i) != rng)
{
P_SetRandSeed(i, rng);
if (demosynced)
CONS_Alert(CONS_WARNING, M_GetText("Demo playback has desynced (RNG)!\n"));
demosynced = false;
}
}
}
@ -514,7 +518,11 @@ void G_WriteDemoExtraData(void)
demo_writerng = 0;
timeout = 16;
WRITEUINT8(demo_p, DW_RNG);
WRITEUINT32(demo_p, P_GetRandSeed());
for (i = 0; i < PRNUMCLASS; i++)
{
WRITEUINT32(demo_p, P_GetRandSeed(i));
}
}
}
@ -1134,7 +1142,13 @@ void G_GhostTicker(void)
g->p++; // ditto
}
else if (ziptic == DW_RNG)
g->p += 4; // RNG seed
{
INT32 i;
for (i = 0; i < PRNUMCLASS; i++)
{
g->p += 4; // RNG seed
}
}
else
I_Error("Ghost is not a record attack ghost DXD"); //@TODO lmao don't blow up like this
@ -2035,7 +2049,10 @@ void G_BeginRecording(void)
break;
}
WRITEUINT32(demo_p,P_GetInitSeed());
for (i = 0; i < PRNUMCLASS; i++)
{
WRITEUINT32(demo_p, P_GetInitSeed(i));
}
// Reserved for extrainfo location from start of file
demoinfo_p = demo_p;
@ -2530,14 +2547,14 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
UINT8 *infobuffer, *info_p, *extrainfo_p;
UINT8 version, subversion, pdemoflags;
UINT16 pdemoversion, count;
char mapname[MAXMAPLUMPNAME];
INT32 i;
if (!FIL_ReadFile(pdemo->filepath, &infobuffer))
{
CONS_Alert(CONS_ERROR, M_GetText("Failed to read file '%s'.\n"), pdemo->filepath);
pdemo->type = MD_INVALID;
sprintf(pdemo->title, "INVALID REPLAY");
return;
infobuffer = NULL;
goto badreplay;
}
info_p = infobuffer;
@ -2545,10 +2562,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
if (memcmp(info_p, DEMOHEADER, 12))
{
CONS_Alert(CONS_ERROR, M_GetText("%s is not a Ring Racers replay file.\n"), pdemo->filepath);
pdemo->type = MD_INVALID;
sprintf(pdemo->title, "INVALID REPLAY");
Z_Free(infobuffer);
return;
goto badreplay;
}
pdemo->type = MD_LOADED;
@ -2570,10 +2584,7 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
// too old, cannot support.
default:
CONS_Alert(CONS_ERROR, M_GetText("%s is an incompatible replay format and cannot be played.\n"), pdemo->filepath);
pdemo->type = MD_INVALID;
sprintf(pdemo->title, "INVALID REPLAY");
Z_Free(infobuffer);
return;
goto badreplay;
}
if (version != VERSION || subversion != SUBVERSION)
@ -2583,13 +2594,11 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
if (memcmp(info_p, "PLAY", 4))
{
CONS_Alert(CONS_ERROR, M_GetText("%s is the wrong type of recording and cannot be played.\n"), pdemo->filepath);
pdemo->type = MD_INVALID;
sprintf(pdemo->title, "INVALID REPLAY");
Z_Free(infobuffer);
return;
goto badreplay;
}
info_p += 4; // "PLAY"
pdemo->map = READINT16(info_p);
READSTRINGN(info_p, mapname, sizeof(mapname));
pdemo->map = G_MapNumber(mapname);
info_p += 16; // mapmd5
pdemoflags = READUINT8(info_p);
@ -2606,7 +2615,11 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
pdemo->numlaps = READUINT8(info_p);
pdemo->addonstatus = G_CheckDemoExtraFiles(&info_p, true);
info_p += 4; // RNG seed
for (i = 0; i < PRNUMCLASS; i++)
{
info_p += 4; // RNG seed
}
extrainfo_p = infobuffer + READUINT32(info_p); // The extra UINT32 read is for a blank 4 bytes?
@ -2640,7 +2653,6 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
while (READUINT8(extrainfo_p) == DW_STANDING) // Assume standings are always first in the extrainfo
{
INT32 i;
char temp[16];
pdemo->standings[count].ranking = READUINT8(extrainfo_p);
@ -2681,6 +2693,12 @@ void G_LoadDemoInfo(menudemo_t *pdemo)
// I think that's everything we need?
Z_Free(infobuffer);
return;
badreplay:
pdemo->type = MD_INVALID;
sprintf(pdemo->title, "INVALID REPLAY");
Z_Free(infobuffer);
}
//
@ -2705,7 +2723,7 @@ void G_DoPlayDemo(char *defdemoname)
lumpnum_t l;
char skin[17],color[MAXCOLORNAME+1],follower[17],mapname[MAXMAPLUMPNAME],*n,*pdemoname;
UINT8 version,subversion;
UINT32 randseed;
UINT32 randseed[PRNUMCLASS];
char msg[1024];
boolean spectator;
@ -2914,7 +2932,10 @@ void G_DoPlayDemo(char *defdemoname)
}
// Random seed
randseed = READUINT32(demo_p);
for (i = 0; i < PRNUMCLASS; i++)
{
randseed[i] = READUINT32(demo_p);
}
demo_p += 4; // Extrainfo location
@ -3118,7 +3139,11 @@ void G_DoPlayDemo(char *defdemoname)
R_ExecuteSetViewSize();
P_SetRandSeed(randseed);
for (i = 0; i < PRNUMCLASS; i++)
{
P_SetRandSeed(i, randseed[i]);
}
G_InitNew(demoflags & DF_ENCORE, gamemap, true, true, false); // Doesn't matter whether you reset or not here, given changes to resetplayer.
for (i = 0; i < MAXPLAYERS; i++)
@ -3272,7 +3297,11 @@ void G_AddGhost(char *defdemoname)
break;
}
p += 4; // random seed
for (i = 0; i < PRNUMCLASS; i++)
{
p += 4; // random seed
}
p += 4; // Extra data location reference
// net var data
@ -3430,6 +3459,7 @@ void G_UpdateStaffGhostName(lumpnum_t l)
UINT8 *buffer,*p;
UINT16 ghostversion;
UINT8 flags;
INT32 i;
buffer = p = W_CacheLumpNum(l, PU_CACHE);
@ -3490,7 +3520,11 @@ void G_UpdateStaffGhostName(lumpnum_t l)
break;
}
p += 4; // random seed
for (i = 0; i < PRNUMCLASS; i++)
{
p += 4; // random seed
}
p += 4; // Extrainfo location marker
// Ehhhh don't need ghostversion here (?) so I'll reuse the var here
@ -3624,7 +3658,7 @@ static void WriteDemoChecksum(void)
#ifdef NOMD5
UINT8 i;
for (i = 0; i < 16; i++, p++)
*p = P_RandomByte(); // This MD5 was chosen by fair dice roll and most likely < 50% correct.
*p = P_RandomByte(PR_UNDEFINED); // This MD5 was chosen by fair dice roll and most likely < 50% correct.
#else
md5_buffer((char *)p+16, demo_p - (p+16), p); // make a checksum of everything after the checksum in the file.
#endif

View file

@ -2570,7 +2570,7 @@ mapthing_t *G_FindTeamStart(INT32 playernum)
return NULL;
}
if ((!players[playernum].ctfteam && numredctfstarts && (!numbluectfstarts || P_RandomChance(FRACUNIT/2))) || players[playernum].ctfteam == 1) //red
if ((!players[playernum].ctfteam && numredctfstarts && (!numbluectfstarts || P_RandomChance(PR_PLAYERSTARTS, FRACUNIT/2))) || players[playernum].ctfteam == 1) //red
{
if (!numredctfstarts)
{
@ -2581,7 +2581,7 @@ mapthing_t *G_FindTeamStart(INT32 playernum)
for (j = 0; j < 32; j++)
{
i = P_RandomKey(numredctfstarts);
i = P_RandomKey(PR_PLAYERSTARTS, numredctfstarts);
if (G_CheckSpot(playernum, redctfstarts[i]))
return redctfstarts[i];
}
@ -2601,7 +2601,7 @@ mapthing_t *G_FindTeamStart(INT32 playernum)
for (j = 0; j < 32; j++)
{
i = P_RandomKey(numbluectfstarts);
i = P_RandomKey(PR_PLAYERSTARTS, numbluectfstarts);
if (G_CheckSpot(playernum, bluectfstarts[i]))
return bluectfstarts[i];
}
@ -2622,7 +2622,7 @@ mapthing_t *G_FindBattleStart(INT32 playernum)
{
for (j = 0; j < 64; j++)
{
i = P_RandomKey(numdmstarts);
i = P_RandomKey(PR_PLAYERSTARTS, numdmstarts);
if (G_CheckSpot(playernum, deathmatchstarts[i]))
return deathmatchstarts[i];
}
@ -4721,7 +4721,7 @@ void G_InitNew(UINT8 pencoremode, INT32 map, boolean resetplayer, boolean skippr
comebackshowninfo = false;
if (!demo.playback && !netgame) // Netgame sets random seed elsewhere, demo playback sets seed just before us!
P_SetRandSeed(M_RandomizedSeed()); // Use a more "Random" random seed
P_ClearRandom(M_RandomizedSeed()); // Use a more "Random" random seed
// Clear a bunch of variables
redscore = bluescore = lastmap = 0;

View file

@ -4091,23 +4091,14 @@ state_t states[NUMSTATES] =
{SPR_ORBN, 11, 3, {NULL}, 0, 0, S_ORBINAUT_SHIELD1}, // S_ORBINAUT_SHIELD6
{SPR_ORBN, 6, 175, {NULL}, 0, 0, S_NULL}, // S_ORBINAUT_SHIELDDEAD
{SPR_JAWZ, 0, 1, {A_JawzChase}, 0, 0, S_JAWZ2}, // S_JAWZ1
{SPR_JAWZ, 4, 1, {A_JawzChase}, 0, 0, S_JAWZ3}, // S_JAWZ2
{SPR_JAWZ, 1, 1, {A_JawzChase}, 0, 0, S_JAWZ4}, // S_JAWZ3
{SPR_JAWZ, 4, 1, {A_JawzChase}, 0, 0, S_JAWZ5}, // S_JAWZ4
{SPR_JAWZ, 2, 1, {A_JawzChase}, 0, 0, S_JAWZ6}, // S_JAWZ5
{SPR_JAWZ, 4, 1, {A_JawzChase}, 0, 0, S_JAWZ7}, // S_JAWZ6
{SPR_JAWZ, 3, 1, {A_JawzChase}, 0, 0, S_JAWZ8}, // S_JAWZ7
{SPR_JAWZ, 4, 1, {A_JawzChase}, 0, 0, S_JAWZ1}, // S_JAWZ8
{SPR_JAWZ, 0, 1, {NULL}, 0, 0, S_JAWZ_DUD2}, // S_JAWZ_DUD1
{SPR_JAWZ, 4, 1, {NULL}, 0, 0, S_JAWZ_DUD3}, // S_JAWZ_DUD2
{SPR_JAWZ, 1, 1, {NULL}, 0, 0, S_JAWZ_DUD4}, // S_JAWZ_DUD3
{SPR_JAWZ, 4, 1, {NULL}, 0, 0, S_JAWZ_DUD5}, // S_JAWZ_DUD4
{SPR_JAWZ, 2, 1, {NULL}, 0, 0, S_JAWZ_DUD6}, // S_JAWZ_DUD5
{SPR_JAWZ, 4, 1, {NULL}, 0, 0, S_JAWZ_DUD7}, // S_JAWZ_DUD6
{SPR_JAWZ, 3, 1, {NULL}, 0, 0, S_JAWZ_DUD8}, // S_JAWZ_DUD7
{SPR_JAWZ, 4, 1, {NULL}, 0, 0, S_JAWZ_DUD1}, // S_JAWZ_DUD8
{SPR_JAWZ, 0, 1, {NULL}, 0, 0, S_JAWZ2}, // S_JAWZ1
{SPR_JAWZ, 4, 1, {NULL}, 0, 0, S_JAWZ3}, // S_JAWZ2
{SPR_JAWZ, 1, 1, {NULL}, 0, 0, S_JAWZ4}, // S_JAWZ3
{SPR_JAWZ, 4, 1, {NULL}, 0, 0, S_JAWZ5}, // S_JAWZ4
{SPR_JAWZ, 2, 1, {NULL}, 0, 0, S_JAWZ6}, // S_JAWZ5
{SPR_JAWZ, 4, 1, {NULL}, 0, 0, S_JAWZ7}, // S_JAWZ6
{SPR_JAWZ, 3, 1, {NULL}, 0, 0, S_JAWZ8}, // S_JAWZ7
{SPR_JAWZ, 4, 1, {NULL}, 0, 0, S_JAWZ1}, // S_JAWZ8
{SPR_JAWZ, 0, 1, {NULL}, 0, 0, S_JAWZ_SHIELD2}, // S_JAWZ_SHIELD1
{SPR_JAWZ, 4, 1, {NULL}, 0, 0, S_JAWZ_SHIELD3}, // S_JAWZ_SHIELD2
@ -23506,33 +23497,6 @@ mobjinfo_t mobjinfo[NUMMOBJTYPES] =
S_NULL // raisestate
},
{ // MT_JAWZ_DUD
-1, // doomednum
S_JAWZ_DUD1, // spawnstate
1, // spawnhealth
S_NULL, // seestate
sfx_tossed, // seesound
8, // reactiontime
sfx_None, // attacksound
S_NULL, // painstate
0, // painchance
sfx_None, // painsound
S_NULL, // meleestate
S_NULL, // missilestate
S_JAWZ_DEAD1, // deathstate
S_JAWZ_DEAD2, // xdeathstate
sfx_s3k5d, // deathsound
64*FRACUNIT, // speed
16*FRACUNIT, // radius
32*FRACUNIT, // height
0, // display offset
100, // mass
1, // damage
sfx_s3kc0s, // activesound
MF_SHOOTABLE|MF_DONTENCOREMAP|MF_APPLYTERRAIN, // flags
S_NULL // raisestate
},
{ // MT_JAWZ_SHIELD
-1, // doomednum
S_JAWZ_SHIELD1, // spawnstate

View file

@ -273,7 +273,6 @@ enum actionnum
A_DRAGONSEGMENT,
A_CHANGEHEIGHT,
A_ITEMPOP,
A_JAWZCHASE,
A_JAWZEXPLODE,
A_SSMINESEARCH,
A_SSMINEEXPLODE,
@ -545,7 +544,6 @@ void A_ChangeHeight();
// SRB2Kart
//
void A_ItemPop();
void A_JawzChase();
void A_JawzExplode();
void A_SSMineSearch();
void A_SSMineExplode();
@ -4522,14 +4520,6 @@ typedef enum state
S_JAWZ6,
S_JAWZ7,
S_JAWZ8,
S_JAWZ_DUD1,
S_JAWZ_DUD2,
S_JAWZ_DUD3,
S_JAWZ_DUD4,
S_JAWZ_DUD5,
S_JAWZ_DUD6,
S_JAWZ_DUD7,
S_JAWZ_DUD8,
S_JAWZ_SHIELD1,
S_JAWZ_SHIELD2,
S_JAWZ_SHIELD3,
@ -6372,7 +6362,6 @@ typedef enum mobj_type
MT_ORBINAUT_SHIELD,
MT_JAWZ, // Jawz stuff
MT_JAWZ_DUD,
MT_JAWZ_SHIELD,
MT_PLAYERRETICULE, // Jawz reticule

View file

@ -212,7 +212,7 @@ mobj_t *K_SpawnChaosEmerald(fixed_t x, fixed_t y, fixed_t z, angle_t angle, SINT
mobj_t *overlay;
P_Thrust(emerald,
FixedAngle(P_RandomFixed() * 180) + angle,
FixedAngle(P_RandomFixed(PR_ITEM_ROULETTE) * 180) + angle,
24 * mapobjectscale);
emerald->momz = flip * 24 * mapobjectscale;
@ -269,8 +269,8 @@ mobj_t *K_SpawnSphereBox(fixed_t x, fixed_t y, fixed_t z, angle_t angle, SINT8 f
P_InitAngle(drop, angle);
P_Thrust(drop,
FixedAngle(P_RandomFixed() * 180) + angle,
P_RandomRange(4, 12) * mapobjectscale);
FixedAngle(P_RandomFixed(PR_ITEM_ROULETTE) * 180) + angle,
P_RandomRange(PR_ITEM_ROULETTE, 4, 12) * mapobjectscale);
drop->momz = flip * 12 * mapobjectscale;
if (drop->eflags & MFE_UNDERWATER)
@ -413,7 +413,7 @@ void K_RunPaperItemSpawners(void)
{
K_SpawnChaosEmerald(
battleovertime.x, battleovertime.y, battleovertime.z + (128 * mapobjectscale * flip),
FixedAngle(P_RandomRange(0, 359) * FRACUNIT), flip,
FixedAngle(P_RandomRange(PR_ITEM_ROULETTE, 0, 359) * FRACUNIT), flip,
firstUnspawnedEmerald
);
}
@ -421,7 +421,7 @@ void K_RunPaperItemSpawners(void)
{
K_CreatePaperItem(
battleovertime.x, battleovertime.y, battleovertime.z + (128 * mapobjectscale * flip),
FixedAngle(P_RandomRange(0, 359) * FRACUNIT), flip,
FixedAngle(P_RandomRange(PR_ITEM_ROULETTE, 0, 359) * FRACUNIT), flip,
0, 0
);
@ -429,7 +429,7 @@ void K_RunPaperItemSpawners(void)
{
K_SpawnSphereBox(
battleovertime.x, battleovertime.y, battleovertime.z + (128 * mapobjectscale * flip),
FixedAngle(P_RandomRange(0, 359) * FRACUNIT), flip,
FixedAngle(P_RandomRange(PR_ITEM_ROULETTE, 0, 359) * FRACUNIT), flip,
10
);
}
@ -510,7 +510,7 @@ void K_RunPaperItemSpawners(void)
}
else
{
key = P_RandomKey(spotCount);
key = P_RandomKey(PR_ITEM_ROULETTE, spotCount);
}
r = spotMap[key];
@ -524,7 +524,7 @@ void K_RunPaperItemSpawners(void)
{
drop = K_SpawnChaosEmerald(
spotList[r]->x, spotList[r]->y, spotList[r]->z + (128 * mapobjectscale * flip),
FixedAngle(P_RandomRange(0, 359) * FRACUNIT), flip,
FixedAngle(P_RandomRange(PR_ITEM_ROULETTE, 0, 359) * FRACUNIT), flip,
firstUnspawnedEmerald
);
}
@ -534,7 +534,7 @@ void K_RunPaperItemSpawners(void)
{
drop = K_SpawnSphereBox(
spotList[r]->x, spotList[r]->y, spotList[r]->z + (128 * mapobjectscale * flip),
FixedAngle(P_RandomRange(0, 359) * FRACUNIT), flip,
FixedAngle(P_RandomRange(PR_ITEM_ROULETTE, 0, 359) * FRACUNIT), flip,
10
);
K_FlipFromObject(drop, spotList[r]);
@ -542,7 +542,7 @@ void K_RunPaperItemSpawners(void)
drop = K_CreatePaperItem(
spotList[r]->x, spotList[r]->y, spotList[r]->z + (128 * mapobjectscale * flip),
FixedAngle(P_RandomRange(0, 359) * FRACUNIT), flip,
FixedAngle(P_RandomRange(PR_ITEM_ROULETTE, 0, 359) * FRACUNIT), flip,
0, 0
);
}

View file

@ -413,7 +413,6 @@ static BlockItReturn_t K_FindObjectsForNudging(mobj_t *thing)
case MT_ORBINAUT:
case MT_ORBINAUT_SHIELD:
case MT_JAWZ:
case MT_JAWZ_DUD:
case MT_JAWZ_SHIELD:
case MT_SSMINE:
case MT_SSMINE_SHIELD:

View file

@ -37,104 +37,6 @@ angle_t K_GetCollideAngle(mobj_t *t1, mobj_t *t2)
return R_PointToAngle2(0, 0, momux, momuy);
}
boolean K_OrbinautJawzCollide(mobj_t *t1, mobj_t *t2)
{
boolean damageitem = false;
boolean sprung = false;
if ((t1->threshold > 0 && t2->hitlag > 0) || (t2->threshold > 0 && t1->hitlag > 0))
return true;
if (((t1->target == t2) || (!(t2->flags & (MF_ENEMY|MF_BOSS)) && (t1->target == t2->target))) && ((t1->threshold > 0 && t2->type == MT_PLAYER) || (t2->type != MT_PLAYER && t2->threshold > 0)))
return true;
if (t1->health <= 0 || t2->health <= 0)
return true;
if ((t1->type == MT_ORBINAUT_SHIELD || t1->type == MT_JAWZ_SHIELD) && t1->lastlook
&& (t2->type == MT_ORBINAUT_SHIELD || t2->type == MT_JAWZ_SHIELD) && t2->lastlook
&& (t1->target == t2->target)) // Don't hit each other if you have the same target
return true;
if (t2->player)
{
if ((t2->player->flashing > 0 && t2->hitlag == 0)
&& !(t1->type == MT_ORBINAUT || t1->type == MT_JAWZ || t1->type == MT_JAWZ_DUD))
return true;
if (t2->player->hyudorotimer)
return true; // no interaction
if (t2->player->flamedash && t2->player->itemtype == KITEM_FLAMESHIELD)
{
// Melt item
S_StartSound(t2, sfx_s3k43);
}
else
{
// Player Damage
P_DamageMobj(t2, t1, t1->target, 1, DMG_WIPEOUT|DMG_WOMBO);
K_KartBouncing(t2, t1);
S_StartSound(t2, sfx_s3k7b);
}
damageitem = true;
}
else if (t2->type == MT_ORBINAUT || t2->type == MT_JAWZ || t2->type == MT_JAWZ_DUD
|| t2->type == MT_ORBINAUT_SHIELD || t2->type == MT_JAWZ_SHIELD
|| t2->type == MT_BANANA || t2->type == MT_BANANA_SHIELD
|| t2->type == MT_BALLHOG)
{
// Other Item Damage
angle_t bounceangle = K_GetCollideAngle(t1, t2);
S_StartSound(t2, t2->info->deathsound);
P_KillMobj(t2, t1, t1, DMG_NORMAL);
P_SetObjectMomZ(t2, 8*FRACUNIT, false);
P_InstaThrust(t2, bounceangle, 16*FRACUNIT);
P_SpawnMobj(t2->x/2 + t1->x/2, t2->y/2 + t1->y/2, t2->z/2 + t1->z/2, MT_ITEMCLASH);
damageitem = true;
}
else if (t2->type == MT_SSMINE_SHIELD || t2->type == MT_SSMINE || t2->type == MT_LANDMINE)
{
damageitem = true;
// Bomb death
P_KillMobj(t2, t1, t1, DMG_NORMAL);
}
else if (t2->flags & MF_SPRING && (t1->type != MT_ORBINAUT_SHIELD && t1->type != MT_JAWZ_SHIELD))
{
// Let thrown items hit springs!
sprung = P_DoSpring(t2, t1);
}
else if (t2->flags & MF_SHOOTABLE)
{
// Shootable damage
P_DamageMobj(t2, t1, t1->target, 1, DMG_NORMAL);
damageitem = true;
}
if (damageitem)
{
// This Item Damage
angle_t bounceangle = K_GetCollideAngle(t2, t1);
S_StartSound(t1, t1->info->deathsound);
P_KillMobj(t1, t2, t2, DMG_NORMAL);
P_SetObjectMomZ(t1, 8*FRACUNIT, false);
P_InstaThrust(t1, bounceangle, 16*FRACUNIT);
}
if (sprung)
{
return false;
}
return true;
}
boolean K_BananaBallhogCollide(mobj_t *t1, mobj_t *t2)
{
boolean damageitem = false;
@ -178,7 +80,7 @@ boolean K_BananaBallhogCollide(mobj_t *t1, mobj_t *t2)
}
else if (t2->type == MT_BANANA || t2->type == MT_BANANA_SHIELD
|| t2->type == MT_ORBINAUT || t2->type == MT_ORBINAUT_SHIELD
|| t2->type == MT_JAWZ || t2->type == MT_JAWZ_DUD || t2->type == MT_JAWZ_SHIELD
|| t2->type == MT_JAWZ || t2->type == MT_JAWZ_SHIELD
|| t2->type == MT_BALLHOG)
{
// Other Item Damage
@ -432,7 +334,7 @@ boolean K_MineCollide(mobj_t *t1, mobj_t *t2)
K_PuntMine(t1, t2);
}
}
else if (t2->type == MT_ORBINAUT || t2->type == MT_JAWZ || t2->type == MT_JAWZ_DUD
else if (t2->type == MT_ORBINAUT || t2->type == MT_JAWZ
|| t2->type == MT_ORBINAUT_SHIELD || t2->type == MT_JAWZ_SHIELD)
{
// Bomb death
@ -493,7 +395,7 @@ boolean K_LandMineCollide(mobj_t *t1, mobj_t *t2)
}
else if (t2->type == MT_BANANA || t2->type == MT_BANANA_SHIELD
|| t2->type == MT_ORBINAUT || t2->type == MT_ORBINAUT_SHIELD
|| t2->type == MT_JAWZ || t2->type == MT_JAWZ_DUD || t2->type == MT_JAWZ_SHIELD
|| t2->type == MT_JAWZ || t2->type == MT_JAWZ_SHIELD
|| t2->type == MT_BALLHOG)
{
// Other Item Damage

View file

@ -6,8 +6,6 @@
angle_t K_GetCollideAngle(mobj_t *t1, mobj_t *t2);
boolean K_OrbinautJawzCollide(mobj_t *t1, mobj_t *t2);
boolean K_BananaBallhogCollide(mobj_t *t1, mobj_t *t2);
boolean K_EggItemCollide(mobj_t *t1, mobj_t *t2);

View file

@ -590,7 +590,7 @@ void K_RetireBots(void)
if (bot->pflags & PF_NOCONTEST)
{
UINT8 skinnum = P_RandomKey(numskins);
UINT8 skinnum = P_RandomKey(PR_UNDEFINED, numskins);
UINT8 loops = 0;
while (!skinusable[skinnum])

View file

@ -1280,7 +1280,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
if (!(gametyperules & GTR_SPHERES) && mashed && player->rings < 0 && cv_superring.value)
{
INT32 debtamount = min(20, abs(player->rings));
if (P_RandomChance((debtamount*FRACUNIT)/20))
if (P_RandomChance(PR_ITEM_ROULETTE, (debtamount*FRACUNIT)/20))
{
K_KartGetItemResult(player, KITEM_SUPERRING);
player->karthud[khud_itemblink] = TICRATE;
@ -1328,7 +1328,7 @@ static void K_KartItemRoulette(player_t *player, ticcmd_t *cmd)
// Award the player whatever power is rolled
if (totalspawnchance > 0)
{
totalspawnchance = P_RandomKey(totalspawnchance);
totalspawnchance = P_RandomKey(PR_ITEM_ROULETTE, totalspawnchance);
for (i = 0; i < NUMKARTRESULTS && spawnchance[i] <= totalspawnchance; i++);
K_KartGetItemResult(player, i);
@ -1421,7 +1421,6 @@ fixed_t K_GetMobjWeight(mobj_t *mobj, mobj_t *against)
weight = K_PlayerWeight(against, NULL);
break;
case MT_JAWZ:
case MT_JAWZ_DUD:
case MT_JAWZ_SHIELD:
if (against->player)
weight = K_PlayerWeight(against, NULL) + (3*FRACUNIT);
@ -1912,9 +1911,9 @@ static void K_DrawDraftCombiring(player_t *player, player_t *victim, fixed_t cur
{
if (offset == 0)
{
mobj_t *band = P_SpawnMobj(curx + (P_RandomRange(-12,12)*mapobjectscale),
cury + (P_RandomRange(-12,12)*mapobjectscale),
curz + (P_RandomRange(24,48)*mapobjectscale),
mobj_t *band = P_SpawnMobj(curx + (P_RandomRange(PR_DECORATION, -12, 12)*mapobjectscale),
cury + (P_RandomRange(PR_DECORATION, -12, 12)*mapobjectscale),
curz + (P_RandomRange(PR_DECORATION, 24, 48)*mapobjectscale),
MT_SIGNSPARKLE);
if (maxdist == 0)
@ -2383,7 +2382,7 @@ void K_SpawnDriftBoostClip(player_t *player)
clip->momz += momz;
P_InstaThrust(clip, player->mo->angle +
P_RandomFlip(P_RandomRange(FRACUNIT/2, FRACUNIT)),
P_RandomFlip(P_RandomRange(PR_DECORATION, FRACUNIT/2, FRACUNIT)),
FixedMul(scale, player->speed));
}
@ -2403,9 +2402,9 @@ void K_SpawnDriftBoostClipSpark(mobj_t *clip)
void K_SpawnNormalSpeedLines(player_t *player)
{
mobj_t *fast = P_SpawnMobj(player->mo->x + (P_RandomRange(-36,36) * player->mo->scale),
player->mo->y + (P_RandomRange(-36,36) * player->mo->scale),
player->mo->z + (player->mo->height/2) + (P_RandomRange(-20,20) * player->mo->scale),
mobj_t *fast = P_SpawnMobj(player->mo->x + (P_RandomRange(PR_DECORATION,-36,36) * player->mo->scale),
player->mo->y + (P_RandomRange(PR_DECORATION,-36,36) * player->mo->scale),
player->mo->z + (player->mo->height/2) + (P_RandomRange(PR_DECORATION,-20,20) * player->mo->scale),
MT_FASTLINE);
P_SetTarget(&fast->target, player->mo);
@ -2453,9 +2452,9 @@ void K_SpawnNormalSpeedLines(player_t *player)
void K_SpawnInvincibilitySpeedLines(mobj_t *mo)
{
mobj_t *fast = P_SpawnMobjFromMobj(mo,
P_RandomRange(-48, 48) * FRACUNIT,
P_RandomRange(-48, 48) * FRACUNIT,
P_RandomRange(0, 64) * FRACUNIT,
P_RandomRange(PR_DECORATION, -48, 48) * FRACUNIT,
P_RandomRange(PR_DECORATION, -48, 48) * FRACUNIT,
P_RandomRange(PR_DECORATION, 0, 64) * FRACUNIT,
MT_FASTLINE);
P_SetMobjState(fast, S_KARTINVLINES1);
@ -2513,9 +2512,9 @@ static void K_SpawnGrowShrinkParticles(mobj_t *mo, INT32 timer)
particle = P_SpawnMobjFromMobj(
mo,
P_RandomRange(-32, 32) * FRACUNIT,
P_RandomRange(-32, 32) * FRACUNIT,
(P_RandomRange(0, 24) + (shrink ? 48 : 0)) * FRACUNIT,
P_RandomRange(PR_DECORATION, -32, 32) * FRACUNIT,
P_RandomRange(PR_DECORATION, -32, 32) * FRACUNIT,
(P_RandomRange(PR_DECORATION, 0, 24) + (shrink ? 48 : 0)) * FRACUNIT,
MT_GROW_PARTICLE
);
@ -3041,7 +3040,7 @@ static void K_RegularVoiceTimers(player_t *player)
void K_PlayAttackTaunt(mobj_t *source)
{
sfxenum_t pick = P_RandomKey(2); // Gotta roll the RNG every time this is called for sync reasons
sfxenum_t pick = P_RandomKey(PR_VOICES, 2); // Gotta roll the RNG every time this is called for sync reasons
boolean tasteful = (!source->player || !source->player->karthud[khud_tauntvoices]);
if (cv_kartvoices.value && (tasteful || cv_kartvoices.value == 2))
@ -3055,7 +3054,7 @@ void K_PlayAttackTaunt(mobj_t *source)
void K_PlayBoostTaunt(mobj_t *source)
{
sfxenum_t pick = P_RandomKey(2); // Gotta roll the RNG every time this is called for sync reasons
sfxenum_t pick = P_RandomKey(PR_VOICES, 2); // Gotta roll the RNG every time this is called for sync reasons
boolean tasteful = (!source->player || !source->player->karthud[khud_tauntvoices]);
if (cv_kartvoices.value && (tasteful || cv_kartvoices.value == 2))
@ -3089,7 +3088,7 @@ void K_PlayOvertakeSound(mobj_t *source)
void K_PlayPainSound(mobj_t *source, mobj_t *other)
{
sfxenum_t pick = P_RandomKey(2); // Gotta roll the RNG every time this is called for sync reasons
sfxenum_t pick = P_RandomKey(PR_VOICES, 2); // Gotta roll the RNG every time this is called for sync reasons
sfxenum_t sfx_id = ((skin_t *)source->skin)->soundsid[S_sfx[sfx_khurt1 + pick].skinsound];
boolean alwaysHear = false;
@ -4606,18 +4605,18 @@ void K_SpawnMineExplosion(mobj_t *source, UINT8 color)
dust->scalespeed = source->scale/12;
P_InstaThrust(dust, dust->angle, FixedMul(20*FRACUNIT, source->scale));
truc = P_SpawnMobj(source->x + P_RandomRange(-radius, radius)*FRACUNIT,
source->y + P_RandomRange(-radius, radius)*FRACUNIT,
source->z + P_RandomRange(0, height)*FRACUNIT, MT_BOOMEXPLODE);
truc = P_SpawnMobj(source->x + P_RandomRange(PR_EXPLOSION, -radius, radius)*FRACUNIT,
source->y + P_RandomRange(PR_EXPLOSION, -radius, radius)*FRACUNIT,
source->z + P_RandomRange(PR_EXPLOSION, 0, height)*FRACUNIT, MT_BOOMEXPLODE);
K_MatchGenericExtraFlags(truc, source);
P_SetScale(truc, source->scale);
truc->destscale = source->scale*6;
truc->scalespeed = source->scale/12;
speed = FixedMul(10*FRACUNIT, source->scale)>>FRACBITS;
truc->momx = P_RandomRange(-speed, speed)*FRACUNIT;
truc->momy = P_RandomRange(-speed, speed)*FRACUNIT;
truc->momx = P_RandomRange(PR_EXPLOSION, -speed, speed)*FRACUNIT;
truc->momy = P_RandomRange(PR_EXPLOSION, -speed, speed)*FRACUNIT;
speed = FixedMul(20*FRACUNIT, source->scale)>>FRACBITS;
truc->momz = P_RandomRange(-speed, speed)*FRACUNIT*P_MobjFlip(truc);
truc->momz = P_RandomRange(PR_EXPLOSION, -speed, speed)*FRACUNIT*P_MobjFlip(truc);
if (truc->eflags & MFE_UNDERWATER)
truc->momz = (117 * truc->momz) / 200;
truc->color = color;
@ -4625,30 +4624,30 @@ void K_SpawnMineExplosion(mobj_t *source, UINT8 color)
for (i = 0; i < 16; i++)
{
dust = P_SpawnMobj(source->x + P_RandomRange(-radius, radius)*FRACUNIT,
source->y + P_RandomRange(-radius, radius)*FRACUNIT,
source->z + P_RandomRange(0, height)*FRACUNIT, MT_SMOKE);
dust = P_SpawnMobj(source->x + P_RandomRange(PR_EXPLOSION, -radius, radius)*FRACUNIT,
source->y + P_RandomRange(PR_EXPLOSION, -radius, radius)*FRACUNIT,
source->z + P_RandomRange(PR_EXPLOSION, 0, height)*FRACUNIT, MT_SMOKE);
P_SetMobjState(dust, S_OPAQUESMOKE1);
P_SetScale(dust, source->scale);
dust->destscale = source->scale*10;
dust->scalespeed = source->scale/12;
dust->tics = 30;
dust->momz = P_RandomRange(FixedMul(3*FRACUNIT, source->scale)>>FRACBITS, FixedMul(7*FRACUNIT, source->scale)>>FRACBITS)*FRACUNIT;
dust->momz = P_RandomRange(PR_EXPLOSION, FixedMul(3*FRACUNIT, source->scale)>>FRACBITS, FixedMul(7*FRACUNIT, source->scale)>>FRACBITS)*FRACUNIT;
truc = P_SpawnMobj(source->x + P_RandomRange(-radius, radius)*FRACUNIT,
source->y + P_RandomRange(-radius, radius)*FRACUNIT,
source->z + P_RandomRange(0, height)*FRACUNIT, MT_BOOMPARTICLE);
truc = P_SpawnMobj(source->x + P_RandomRange(PR_EXPLOSION, -radius, radius)*FRACUNIT,
source->y + P_RandomRange(PR_EXPLOSION, -radius, radius)*FRACUNIT,
source->z + P_RandomRange(PR_EXPLOSION, 0, height)*FRACUNIT, MT_BOOMPARTICLE);
K_MatchGenericExtraFlags(truc, source);
P_SetScale(truc, source->scale);
truc->destscale = source->scale*5;
truc->scalespeed = source->scale/12;
speed = FixedMul(20*FRACUNIT, source->scale)>>FRACBITS;
truc->momx = P_RandomRange(-speed, speed)*FRACUNIT;
truc->momy = P_RandomRange(-speed, speed)*FRACUNIT;
truc->momx = P_RandomRange(PR_EXPLOSION, -speed, speed)*FRACUNIT;
truc->momy = P_RandomRange(PR_EXPLOSION, -speed, speed)*FRACUNIT;
speed = FixedMul(15*FRACUNIT, source->scale)>>FRACBITS;
speed2 = FixedMul(45*FRACUNIT, source->scale)>>FRACBITS;
truc->momz = P_RandomRange(speed, speed2)*FRACUNIT*P_MobjFlip(truc);
if (P_RandomChance(FRACUNIT/2))
truc->momz = P_RandomRange(PR_EXPLOSION, speed, speed2)*FRACUNIT*P_MobjFlip(truc);
if (P_RandomChance(PR_EXPLOSION, FRACUNIT/2))
truc->momz = -truc->momz;
if (truc->eflags & MFE_UNDERWATER)
truc->momz = (117 * truc->momz) / 200;
@ -4674,7 +4673,7 @@ fixed_t K_ItemScaleForPlayer(player_t *player)
}
}
static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, INT32 flags2, fixed_t speed)
static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, INT32 flags2, fixed_t speed, SINT8 dir)
{
mobj_t *th;
fixed_t x, y, z;
@ -4688,20 +4687,20 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I
if (source->player->itemscale == ITEMSCALE_SHRINK)
{
// Nerf the base item speed a bit.
finalspeed = FixedMul(finalspeed, SHRINK_PHYSICS_SCALE);
speed = finalspeed = FixedMul(speed, SHRINK_PHYSICS_SCALE);
}
if (source->player->speed > topspeed)
{
angle_t input = source->angle - an;
boolean invert = (input > ANGLE_180);
if (invert)
input = InvAngle(input);
angle_t delta = AngleDelta(source->angle, an);
finalspeed = max(speed, FixedMul(speed, FixedMul(
FixedDiv(source->player->speed, topspeed), // Multiply speed to be proportional to your own, boosted maxspeed.
(((180<<FRACBITS) - AngleFixed(input)) / 180) // multiply speed based on angle diff... i.e: don't do this for firing backward :V
)));
finalspeed = max(speed, FixedMul(
speed,
FixedMul(
FixedDiv(source->player->speed, topspeed), // Multiply speed to be proportional to your own, boosted maxspeed.
FixedDiv(AngleFixed(ANGLE_180 - delta), 180 * FRACUNIT) // multiply speed based on angle diff... i.e: don't do this for firing backward :V
)
));
}
finalscale = K_ItemScaleForPlayer(source->player);
@ -4712,6 +4711,12 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I
finalscale = source->scale;
}
if (dir == -1 && (type == MT_ORBINAUT || type == MT_BALLHOG))
{
// Backwards nerfs
finalspeed /= 8;
}
x = source->x + source->momx + FixedMul(finalspeed, FINECOSINE(an>>ANGLETOFINESHIFT));
y = source->y + source->momy + FixedMul(finalspeed, FINESINE(an>>ANGLETOFINESHIFT));
z = source->z; // spawn on the ground please
@ -4763,31 +4768,11 @@ static mobj_t *K_SpawnKartMissile(mobj_t *source, mobjtype_t type, angle_t an, I
switch (type)
{
case MT_ORBINAUT:
if (source && source->player)
th->color = source->player->skincolor;
else
th->color = SKINCOLOR_GREY;
th->movefactor = finalspeed;
Obj_OrbinautThrown(th, finalspeed, dir);
break;
case MT_JAWZ:
if (source && source->player)
{
INT32 lasttarg = source->player->lastjawztarget;
th->cvmem = source->player->skincolor;
if ((lasttarg >= 0 && lasttarg < MAXPLAYERS)
&& playeringame[lasttarg]
&& !players[lasttarg].spectator
&& players[lasttarg].mo)
{
P_SetTarget(&th->tracer, players[lasttarg].mo);
}
}
else
th->cvmem = SKINCOLOR_KETCHUP;
/* FALLTHRU */
case MT_JAWZ_DUD:
S_StartSound(th, th->info->activesound);
/* FALLTHRU */
Obj_JawzThrown(th, finalspeed, dir);
break;
case MT_SPB:
th->movefactor = finalspeed;
break;
@ -5261,9 +5246,9 @@ void K_SpawnSparkleTrail(mobj_t *mo)
//CONS_Printf("%d\n", index);
newx = mo->x + (P_RandomRange(-rad, rad)*FRACUNIT);
newy = mo->y + (P_RandomRange(-rad, rad)*FRACUNIT);
newz = mo->z + (P_RandomRange(0, mo->height>>FRACBITS)*FRACUNIT);
newx = mo->x + (P_RandomRange(PR_DECORATION, -rad, rad)*FRACUNIT);
newy = mo->y + (P_RandomRange(PR_DECORATION, -rad, rad)*FRACUNIT);
newz = mo->z + (P_RandomRange(PR_DECORATION, 0, mo->height>>FRACBITS)*FRACUNIT);
sparkle = P_SpawnMobj(newx, newy, newz, MT_SPARKLETRAIL);
@ -5273,8 +5258,8 @@ void K_SpawnSparkleTrail(mobj_t *mo)
//CONS_Printf("movefactor: %d\n", sparkle->movefactor/FRACUNIT);
sparkle->extravalue1 = (sparkle->z - mo->z); // Keep track of our Z position relative to the player's, I suppose.
sparkle->extravalue2 = P_RandomRange(0, 1) ? 1 : -1; // Rotation direction?
sparkle->cvmem = P_RandomRange(-25, 25)*mo->scale; // Vertical "angle"
sparkle->extravalue2 = P_RandomRange(PR_DECORATION, 0, 1) ? 1 : -1; // Rotation direction?
sparkle->cvmem = P_RandomRange(PR_DECORATION, -25, 25)*mo->scale; // Vertical "angle"
K_FlipFromObject(sparkle, mo);
P_SetTarget(&sparkle->target, mo);
@ -5312,8 +5297,8 @@ void K_SpawnWipeoutTrail(mobj_t *mo)
else
aoff += ANGLE_45;
dust = P_SpawnMobj(mo->x + FixedMul(24*mo->scale, FINECOSINE(aoff>>ANGLETOFINESHIFT)) + (P_RandomRange(-8,8) << FRACBITS),
mo->y + FixedMul(24*mo->scale, FINESINE(aoff>>ANGLETOFINESHIFT)) + (P_RandomRange(-8,8) << FRACBITS),
dust = P_SpawnMobj(mo->x + FixedMul(24*mo->scale, FINECOSINE(aoff>>ANGLETOFINESHIFT)) + (P_RandomRange(PR_DECORATION,-8,8) << FRACBITS),
mo->y + FixedMul(24*mo->scale, FINESINE(aoff>>ANGLETOFINESHIFT)) + (P_RandomRange(PR_DECORATION,-8,8) << FRACBITS),
mo->z, MT_WIPEOUTTRAIL);
P_SetTarget(&dust->target, mo);
@ -5451,13 +5436,13 @@ void K_DriftDustHandling(mobj_t *spawner)
if (anglediff > ANG10*4) // Trying to turn further than 40 degrees
{
fixed_t spawnx = P_RandomRange(-spawnrange, spawnrange) << FRACBITS;
fixed_t spawny = P_RandomRange(-spawnrange, spawnrange) << FRACBITS;
fixed_t spawnx = P_RandomRange(PR_DECORATION, -spawnrange, spawnrange) << FRACBITS;
fixed_t spawny = P_RandomRange(PR_DECORATION, -spawnrange, spawnrange) << FRACBITS;
INT32 speedrange = 2;
mobj_t *dust = P_SpawnMobj(spawner->x + spawnx, spawner->y + spawny, spawner->z, MT_DRIFTDUST);
dust->momx = FixedMul(spawner->momx + (P_RandomRange(-speedrange, speedrange) * spawner->scale), 3*FRACUNIT/4);
dust->momy = FixedMul(spawner->momy + (P_RandomRange(-speedrange, speedrange) * spawner->scale), 3*FRACUNIT/4);
dust->momz = P_MobjFlip(spawner) * (P_RandomRange(1, 4) * (spawner->scale));
dust->momx = FixedMul(spawner->momx + (P_RandomRange(PR_DECORATION, -speedrange, speedrange) * spawner->scale), 3*FRACUNIT/4);
dust->momy = FixedMul(spawner->momy + (P_RandomRange(PR_DECORATION, -speedrange, speedrange) * spawner->scale), 3*FRACUNIT/4);
dust->momz = P_MobjFlip(spawner) * (P_RandomRange(PR_DECORATION, 1, 4) * (spawner->scale));
P_SetScale(dust, spawner->scale/2);
dust->destscale = spawner->scale * 3;
dust->scalespeed = spawner->scale/12;
@ -5623,15 +5608,15 @@ mobj_t *K_ThrowKartItem(player_t *player, boolean missile, mobjtype_t mapthing,
if (missile) // Shootables
{
if (dir == -1 && mapthing != MT_SPB)
if (dir < 0 && mapthing != MT_SPB)
{
// Shoot backward
mo = K_SpawnKartMissile(player->mo, mapthing, (player->mo->angle + ANGLE_180) + angleOffset, 0, PROJSPEED/8);
mo = K_SpawnKartMissile(player->mo, mapthing, (player->mo->angle + ANGLE_180) + angleOffset, 0, PROJSPEED, dir);
}
else
{
// Shoot forward
mo = K_SpawnKartMissile(player->mo, mapthing, player->mo->angle + angleOffset, 0, PROJSPEED);
mo = K_SpawnKartMissile(player->mo, mapthing, player->mo->angle + angleOffset, 0, PROJSPEED, dir);
}
if (mapthing == MT_DROPTARGET && mo)
@ -5894,8 +5879,8 @@ static void K_DoLightningShield(player_t *player)
for (i=0; i<7; i++)
{
mo = P_SpawnMobj(player->mo->x, player->mo->y, player->mo->z, MT_THOK);
P_InitAngle(mo, P_RandomRange(0, 359)*ANG1);
mo->fuse = P_RandomRange(20, 50);
P_InitAngle(mo, P_RandomRange(PR_DECORATION, 0, 359)*ANG1);
mo->fuse = P_RandomRange(PR_DECORATION, 20, 50);
P_SetTarget(&mo->target, player->mo);
P_SetMobjState(mo, S_KLIT1);
}
@ -5934,91 +5919,11 @@ static void K_FlameDashLeftoverSmoke(mobj_t *src)
smoke->momy = 3*src->momy/4;
smoke->momz = 3*P_GetMobjZMovement(src)/4;
P_Thrust(smoke, src->angle + FixedAngle(P_RandomRange(135, 225)<<FRACBITS), P_RandomRange(0, 8) * src->scale);
smoke->momz += P_RandomRange(0, 4) * src->scale;
P_Thrust(smoke, src->angle + FixedAngle(P_RandomRange(PR_DECORATION, 135, 225)<<FRACBITS), P_RandomRange(PR_DECORATION, 0, 8) * src->scale);
smoke->momz += P_RandomRange(PR_DECORATION, 0, 4) * src->scale;
}
}
#if 0
static void K_DoHyudoroSteal(player_t *player)
{
INT32 i, numplayers = 0;
INT32 playerswappable[MAXPLAYERS];
INT32 stealplayer = -1; // The player that's getting stolen from
INT32 prandom = 0;
boolean sink = P_RandomChance(FRACUNIT/64);
INT32 hyu = hyudorotime;
if (gametype == GT_RACE)
hyu *= 2; // double in race
for (i = 0; i < MAXPLAYERS; i++)
{
if (playeringame[i] && players[i].mo && players[i].mo->health > 0 && players[i].playerstate == PST_LIVE
&& player != &players[i] && !players[i].exiting && !players[i].spectator // Player in-game
// Can steal from this player
&& (gametype == GT_RACE //&& players[i].position < player->position)
|| ((gametyperules & GTR_BUMPERS) && players[i].bumpers > 0))
// Has an item
&& (players[i].itemtype
&& players[i].itemamount
&& !(players[i].pflags & PF_ITEMOUT)))
{
playerswappable[numplayers] = i;
numplayers++;
}
}
prandom = P_RandomFixed();
S_StartSound(player->mo, sfx_s3k92);
if (sink && numplayers > 0 && cv_kitchensink.value) // BEHOLD THE KITCHEN SINK
{
player->hyudorotimer = hyu;
player->stealingtimer = stealtime;
player->itemtype = KITEM_KITCHENSINK;
player->itemamount = 1;
K_UnsetItemOut(player);
return;
}
else if ((gametype == GT_RACE && player->position == 1) || numplayers == 0) // No-one can be stolen from? Oh well...
{
player->hyudorotimer = hyu;
player->stealingtimer = stealtime;
return;
}
else if (numplayers == 1) // With just 2 players, we just need to set the other player to be the one to steal from
{
stealplayer = playerswappable[numplayers-1];
}
else if (numplayers > 1) // We need to choose between the available candidates for the 2nd player
{
stealplayer = playerswappable[prandom%(numplayers-1)];
}
if (stealplayer > -1) // Now here's where we do the stealing, has to be done here because we still know the player we're stealing from
{
player->hyudorotimer = hyu;
player->stealingtimer = stealtime;
players[stealplayer].stealingtimer = -stealtime;
player->itemtype = players[stealplayer].itemtype;
player->itemamount = players[stealplayer].itemamount;
K_UnsetItemOut(player);
players[stealplayer].itemtype = KITEM_NONE;
players[stealplayer].itemamount = 0;
K_UnsetItemOut(&players[stealplayer]);
if (P_IsDisplayPlayer(&players[stealplayer]) && !r_splitscreen)
S_StartSound(NULL, sfx_s3k92);
}
}
#endif
void K_DoSneaker(player_t *player, INT32 type)
{
const fixed_t intendedboost = FRACUNIT/2;
@ -6345,7 +6250,7 @@ void K_DropHnextList(player_t *player, boolean keepshields)
break;
case MT_JAWZ_SHIELD:
orbit = true;
type = MT_JAWZ_DUD;
type = MT_JAWZ;
break;
// Kart trailing items
case MT_BANANA_SHIELD:
@ -6402,6 +6307,12 @@ void K_DropHnextList(player_t *player, boolean keepshields)
dropwork->health = work->health; // will never be set to 0 as long as above guard exists
dropwork->hitlag = work->hitlag;
if (orbit == true)
{
// Projectile item; set fuse
dropwork->fuse = RR_PROJECTILE_FUSE;
}
// Copy interp data
dropwork->old_angle = work->old_angle;
dropwork->old_x = work->old_x;
@ -6463,7 +6374,7 @@ void K_DropHnextList(player_t *player, boolean keepshields)
dropwork->tics = -1;
if (type == MT_JAWZ_DUD)
if (type == MT_JAWZ)
{
dropwork->z += 20*flip*dropwork->scale;
}
@ -6516,7 +6427,7 @@ mobj_t *K_CreatePaperItem(fixed_t x, fixed_t y, fixed_t z, angle_t angle, SINT8
P_InitAngle(drop, angle);
P_Thrust(drop,
FixedAngle(P_RandomFixed() * 180) + angle,
FixedAngle(P_RandomFixed(PR_ITEM_ROULETTE) * 180) + angle,
16*mapobjectscale);
drop->momz = flip * 3 * mapobjectscale;
@ -6549,7 +6460,7 @@ mobj_t *K_CreatePaperItem(fixed_t x, fixed_t y, fixed_t z, angle_t angle, SINT8
UINT8 newType;
UINT8 newAmount;
totalspawnchance = P_RandomKey(totalspawnchance);
totalspawnchance = P_RandomKey(PR_ITEM_ROULETTE, totalspawnchance);
for (i = 0; i < NUMKARTRESULTS && spawnchance[i] <= totalspawnchance; i++);
// TODO: this is bad!
@ -6851,8 +6762,11 @@ static void K_MoveHeldObjects(player_t *player)
if (!player->mo->hnext)
{
player->bananadrag = 0;
if (player->pflags & PF_EGGMANOUT)
{
player->pflags &= ~PF_EGGMANOUT;
}
else if (player->pflags & PF_ITEMOUT)
{
player->itemamount = 0;
@ -6867,14 +6781,18 @@ static void K_MoveHeldObjects(player_t *player)
// we need this here too because this is done in afterthink - pointers are cleaned up at the START of each tic...
P_SetTarget(&player->mo->hnext, NULL);
player->bananadrag = 0;
if (player->pflags & PF_EGGMANOUT)
{
player->pflags &= ~PF_EGGMANOUT;
}
else if (player->pflags & PF_ITEMOUT)
{
player->itemamount = 0;
K_UnsetItemOut(player);
player->itemtype = KITEM_NONE;
}
return;
}
@ -6885,80 +6803,9 @@ static void K_MoveHeldObjects(player_t *player)
case MT_ORBINAUT_SHIELD: // Kart orbit items
case MT_JAWZ_SHIELD:
{
mobj_t *cur = player->mo->hnext;
fixed_t speed = ((8 - min(4, player->itemamount)) * cur->info->speed) / 7;
player->bananadrag = 0; // Just to make sure
while (cur && !P_MobjWasRemoved(cur))
{
const fixed_t radius = FixedHypot(player->mo->radius, player->mo->radius) + FixedHypot(cur->radius, cur->radius); // mobj's distance from its Target, or Radius.
fixed_t z;
if (!cur->health)
{
cur = cur->hnext;
continue;
}
cur->color = player->skincolor;
cur->angle -= ANGLE_90;
cur->angle += FixedAngle(speed);
if (cur->extravalue1 < radius)
cur->extravalue1 += P_AproxDistance(cur->extravalue1, radius) / 12;
if (cur->extravalue1 > radius)
cur->extravalue1 = radius;
// If the player is on the ceiling, then flip your items as well.
if (player && player->mo->eflags & MFE_VERTICALFLIP)
cur->eflags |= MFE_VERTICALFLIP;
else
cur->eflags &= ~MFE_VERTICALFLIP;
// Shrink your items if the player shrunk too.
P_SetScale(cur, (cur->destscale = FixedMul(FixedDiv(cur->extravalue1, radius), finalscale)));
if (P_MobjFlip(cur) > 0)
z = player->mo->z;
else
z = player->mo->z + player->mo->height - cur->height;
cur->flags |= MF_NOCLIPTHING; // temporarily make them noclip other objects so they can't hit anyone while in the player
P_MoveOrigin(cur, player->mo->x, player->mo->y, z);
cur->momx = FixedMul(FINECOSINE(cur->angle>>ANGLETOFINESHIFT), cur->extravalue1);
cur->momy = FixedMul(FINESINE(cur->angle>>ANGLETOFINESHIFT), cur->extravalue1);
cur->flags &= ~MF_NOCLIPTHING;
if (!P_TryMove(cur, player->mo->x + cur->momx, player->mo->y + cur->momy, true))
P_SlideMove(cur);
if (P_IsObjectOnGround(player->mo))
{
if (P_MobjFlip(cur) > 0)
{
if (cur->floorz > player->mo->z - cur->height)
z = cur->floorz;
}
else
{
if (cur->ceilingz < player->mo->z + player->mo->height + cur->height)
z = cur->ceilingz - cur->height;
}
}
// Center it during the scale up animation
z += (FixedMul(mobjinfo[cur->type].height, finalscale - cur->scale)>>1) * P_MobjFlip(cur);
cur->z = z;
cur->momx = cur->momy = 0;
cur->angle += ANGLE_90;
cur = cur->hnext;
}
Obj_OrbinautJawzMoveHeld(player);
break;
}
break;
case MT_BANANA_SHIELD: // Kart trailing items
case MT_SSMINE_SHIELD:
case MT_DROPTARGET_SHIELD:
@ -7037,7 +6884,7 @@ static void K_MoveHeldObjects(player_t *player)
/*
if (P_IsObjectOnGround(player->mo) && player->speed > 0 && player->bananadrag > TICRATE
&& P_RandomChance(min(FRACUNIT/2, FixedDiv(player->speed, K_GetKartSpeed(player, false, false))/2)))
&& P_RandomChance(PR_UNDEFINED, min(FRACUNIT/2, FixedDiv(player->speed, K_GetKartSpeed(player, false, false))/2)))
{
if (leveltime & 1)
targz += 8*(2*FRACUNIT)/7;
@ -7168,94 +7015,110 @@ static void K_MoveHeldObjects(player_t *player)
}
}
player_t *K_FindJawzTarget(mobj_t *actor, player_t *source)
player_t *K_FindJawzTarget(mobj_t *actor, player_t *source, angle_t range)
{
fixed_t best = -1;
fixed_t best = INT32_MAX;
player_t *wtarg = NULL;
INT32 i;
for (i = 0; i < MAXPLAYERS; i++)
{
angle_t thisang;
player_t *player;
angle_t thisang = ANGLE_MAX;
fixed_t thisdist = INT32_MAX;
fixed_t thisScore = INT32_MAX;
player_t *player = NULL;
if (!playeringame[i])
if (playeringame[i] == false)
{
continue;
}
player = &players[i];
if (player->spectator)
continue; // spectator
if (!player->mo)
continue;
if (player->mo->health <= 0)
continue; // dead
// Don't target yourself, stupid.
if (player == source)
{
continue;
}
// Don't home in on teammates.
if (G_GametypeHasTeams() && source->ctfteam == player->ctfteam)
if (player->spectator)
{
// Spectators
continue;
}
// Invisible, don't bother
if (player->hyudorotimer)
if (player->mo == NULL || P_MobjWasRemoved(player->mo) == true)
{
// Invalid mobj
continue;
}
// Find the angle, see who's got the best.
thisang = actor->angle - R_PointToAngle2(actor->x, actor->y, player->mo->x, player->mo->y);
if (thisang > ANGLE_180)
thisang = InvAngle(thisang);
if (player->mo->health <= 0)
{
// dead
continue;
}
if (G_GametypeHasTeams() && source != NULL && source->ctfteam == player->ctfteam)
{
// Don't home in on teammates.
continue;
}
if (player->hyudorotimer > 0)
{
// Invisible player
continue;
}
thisdist = P_AproxDistance(player->mo->x - (actor->x + actor->momx), player->mo->y - (actor->y + actor->momy));
// Jawz only go after the person directly ahead of you in race... sort of literally now!
if (gametyperules & GTR_CIRCUIT)
{
// Don't go for people who are behind you
if (thisang > ANGLE_67h)
continue;
// Don't pay attention to people who aren't above your position
if (player->position >= source->position)
continue;
if ((best == -1) || (player->position > best))
{
wtarg = player;
best = player->position;
// Don't pay attention to people who aren't above your position
continue;
}
}
else
{
fixed_t thisdist;
fixed_t thisavg;
// Don't go for people who are behind you
if (thisang > ANGLE_45)
continue;
// Don't pay attention to dead players
if (player->bumpers <= 0)
{
// Don't pay attention to dead players
continue;
}
// Z pos too high/low
if (abs(player->mo->z - (actor->z + actor->momz)) > RING_DIST/8)
continue;
thisdist = P_AproxDistance(player->mo->x - (actor->x + actor->momx), player->mo->y - (actor->y + actor->momy));
if (thisdist > 2*RING_DIST) // Don't go for people who are too far away
continue;
thisavg = (AngleFixed(thisang) + thisdist) / 2;
//CONS_Printf("got avg %d from player # %d\n", thisavg>>FRACBITS, i);
if ((best == -1) || (thisavg < best))
if (abs(player->mo->z - (actor->z + actor->momz)) > FixedMul(RING_DIST/8, mapobjectscale))
{
wtarg = player;
best = thisavg;
continue;
}
// Distance too far away
if (thisdist > FixedMul(RING_DIST*2, mapobjectscale))
{
continue;
}
}
// Find the angle, see who's got the best.
thisang = AngleDelta(actor->angle, R_PointToAngle2(actor->x, actor->y, player->mo->x, player->mo->y));
// Don't go for people who are behind you
if (thisang > range)
{
continue;
}
thisScore = (AngleFixed(thisang) * 8) + (thisdist / 32);
//CONS_Printf("got score %f from player # %d\n", FixedToFloat(thisScore), i);
if (thisScore < best)
{
wtarg = player;
best = thisScore;
}
}
@ -7615,7 +7478,7 @@ static inline BlockItReturn_t PIT_AttractingRings(mobj_t *thing)
thing->info = &mobjinfo[thing->type];
thing->flags = thing->info->flags;
P_InstaThrust(thing, P_RandomRange(0,7) * ANGLE_45, 2 * thing->scale);
P_InstaThrust(thing, P_RandomRange(PR_ITEM_RINGS, 0, 7) * ANGLE_45, 2 * thing->scale);
P_SetObjectMomZ(thing, 8<<FRACBITS, false);
thing->fuse = 120*TICRATE;
@ -7810,9 +7673,9 @@ void K_KartPlayerThink(player_t *player, ticcmd_t *cmd)
if (player->springstars && (leveltime & 1))
{
fixed_t randx = P_RandomRange(-40, 40) * player->mo->scale;
fixed_t randy = P_RandomRange(-40, 40) * player->mo->scale;
fixed_t randz = P_RandomRange(0, player->mo->height >> FRACBITS) << FRACBITS;
fixed_t randx = P_RandomRange(PR_DECORATION, -40, 40) * player->mo->scale;
fixed_t randy = P_RandomRange(PR_DECORATION, -40, 40) * player->mo->scale;
fixed_t randz = P_RandomRange(PR_DECORATION, 0, player->mo->height >> FRACBITS) << FRACBITS;
mobj_t *star = P_SpawnMobj(
player->mo->x + randx,
player->mo->y + randy,
@ -8327,19 +8190,69 @@ void K_KartPlayerAfterThink(player_t *player)
// Jawz reticule (seeking)
if (player->itemtype == KITEM_JAWZ && (player->pflags & PF_ITEMOUT))
{
INT32 lasttarg = player->lastjawztarget;
player_t *targ;
mobj_t *ret;
INT32 lastTargID = player->lastjawztarget;
player_t *lastTarg = NULL;
player_t *targ = NULL;
mobj_t *ret = NULL;
if (player->jawztargetdelay && playeringame[lasttarg] && !players[lasttarg].spectator)
if ((lastTargID >= 0 && lastTargID <= MAXPLAYERS)
&& playeringame[lastTargID] == true)
{
targ = &players[lasttarg];
player->jawztargetdelay--;
if (players[lastTargID].spectator == false)
{
lastTarg = &players[lastTargID];
}
}
if (player->throwdir == -1)
{
// Backwards Jawz targets yourself.
targ = player;
player->jawztargetdelay = 0;
}
else
targ = K_FindJawzTarget(player->mo, player);
{
// Find a new target.
targ = K_FindJawzTarget(player->mo, player, ANGLE_45);
}
if (!targ || !targ->mo || P_MobjWasRemoved(targ->mo))
if (targ != NULL && targ->mo != NULL && P_MobjWasRemoved(targ->mo) == false)
{
if (targ - players == lastTargID)
{
// Increment delay.
if (player->jawztargetdelay < 10)
{
player->jawztargetdelay++;
}
}
else
{
if (player->jawztargetdelay > 0)
{
// Wait a bit before swapping...
player->jawztargetdelay--;
targ = lastTarg;
}
else
{
// Allow a swap.
if (P_IsDisplayPlayer(player) || P_IsDisplayPlayer(targ))
{
S_StartSound(NULL, sfx_s3k89);
}
else
{
S_StartSound(targ->mo, sfx_s3k89);
}
player->lastjawztarget = targ - players;
player->jawztargetdelay = 5;
}
}
}
if (targ == NULL || targ->mo == NULL || P_MobjWasRemoved(targ->mo) == true)
{
player->lastjawztarget = -1;
player->jawztargetdelay = 0;
@ -8354,17 +8267,6 @@ void K_KartPlayerAfterThink(player_t *player)
ret->frame |= ((leveltime % 10) / 2);
ret->tics = 1;
ret->color = player->skincolor;
if (targ-players != lasttarg)
{
if (P_IsDisplayPlayer(player) || P_IsDisplayPlayer(targ))
S_StartSound(NULL, sfx_s3k89);
else
S_StartSound(targ->mo, sfx_s3k89);
player->lastjawztarget = targ-players;
player->jawztargetdelay = 5;
}
}
else
{
@ -9551,8 +9453,8 @@ void K_KartEbrakeVisuals(player_t *p)
if (!p->spindash)
{
// Spawn downwards fastline
sx = p->mo->x + P_RandomRange(-48, 48)*p->mo->scale;
sy = p->mo->y + P_RandomRange(-48, 48)*p->mo->scale;
sx = p->mo->x + P_RandomRange(PR_DECORATION, -48, 48)*p->mo->scale;
sy = p->mo->y + P_RandomRange(PR_DECORATION, -48, 48)*p->mo->scale;
spdl = P_SpawnMobj(sx, sy, p->mo->z, MT_DOWNLINE);
spdl->colorized = true;
@ -9634,8 +9536,8 @@ static void K_KartSpindashDust(mobj_t *parent)
for (i = 0; i < 2; i++)
{
fixed_t hmomentum = P_RandomRange(6, 12) * parent->scale;
fixed_t vmomentum = P_RandomRange(2, 6) * parent->scale;
fixed_t hmomentum = P_RandomRange(PR_DECORATION, 6, 12) * parent->scale;
fixed_t vmomentum = P_RandomRange(PR_DECORATION, 2, 6) * parent->scale;
angle_t ang = parent->player->drawangle + ANGLE_180;
SINT8 flip = 1;
@ -9663,9 +9565,9 @@ static void K_KartSpindashDust(mobj_t *parent)
static void K_KartSpindashWind(mobj_t *parent)
{
mobj_t *wind = P_SpawnMobjFromMobj(parent,
P_RandomRange(-36,36) * FRACUNIT,
P_RandomRange(-36,36) * FRACUNIT,
FixedDiv(parent->height / 2, parent->scale) + (P_RandomRange(-20,20) * FRACUNIT),
P_RandomRange(PR_DECORATION,-36,36) * FRACUNIT,
P_RandomRange(PR_DECORATION,-36,36) * FRACUNIT,
FixedDiv(parent->height / 2, parent->scale) + (P_RandomRange(PR_DECORATION,-20,20) * FRACUNIT),
MT_SPINDASHWIND
);
@ -10358,10 +10260,7 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
}
else if (ATTACK_IS_DOWN && HOLDING_ITEM && (player->pflags & PF_ITEMOUT)) // Jawz thrown
{
if (player->throwdir == 1 || player->throwdir == 0)
K_ThrowKartItem(player, true, MT_JAWZ, 1, 0, 0);
else if (player->throwdir == -1) // Throwing backward gives you a dud that doesn't home in
K_ThrowKartItem(player, true, MT_JAWZ_DUD, -1, 0, 0);
K_ThrowKartItem(player, true, MT_JAWZ, 1, 0, 0);
K_PlayAttackTaunt(player->mo);
player->itemamount--;
K_UpdateHnextList(player, false);
@ -10847,9 +10746,9 @@ void K_MoveKartPlayer(player_t *player, boolean onground)
{
for (n=0; n < maxlines; n++)
{
sx = player->mo->x + P_RandomRange(-24, 24)*player->mo->scale;
sy = player->mo->y + P_RandomRange(-24, 24)*player->mo->scale;
sz = player->mo->z + P_RandomRange(0, 48)*player->mo->scale;
sx = player->mo->x + P_RandomRange(PR_DECORATION, -24, 24)*player->mo->scale;
sy = player->mo->y + P_RandomRange(PR_DECORATION, -24, 24)*player->mo->scale;
sz = player->mo->z + P_RandomRange(PR_DECORATION, 0, 48)*player->mo->scale;
spdl = P_SpawnMobj(sx, sy, sz, MT_FASTLINE);
P_SetTarget(&spdl->target, player->mo);

View file

@ -28,6 +28,8 @@ Make sure this matches the actual number of states
#define GROW_PHYSICS_SCALE (3*FRACUNIT/2)
#define SHRINK_PHYSICS_SCALE (3*FRACUNIT/4)
#define RR_PROJECTILE_FUSE (8*TICRATE)
#define STUMBLE_STEEP_VAL ANG60
#define STUMBLE_STEEP_VAL_AIR (ANG30 + ANG10)
@ -116,7 +118,7 @@ void K_UpdateHnextList(player_t *player, boolean clean);
void K_DropHnextList(player_t *player, boolean keepshields);
void K_RepairOrbitChain(mobj_t *orbit);
void K_CalculateBananaSlope(mobj_t *mobj, fixed_t x, fixed_t y, fixed_t z, fixed_t radius, fixed_t height, boolean flip, boolean player);
player_t *K_FindJawzTarget(mobj_t *actor, player_t *source);
player_t *K_FindJawzTarget(mobj_t *actor, player_t *source, angle_t range);
INT32 K_GetKartRingPower(player_t *player, boolean boosted);
void K_UpdateDistanceFromFinishLine(player_t *const player);
boolean K_CheckPlayersRespawnColliding(INT32 playernum, fixed_t x, fixed_t y);

View file

@ -1062,7 +1062,6 @@ void M_DrawExtrasMovingButton(void);
void M_DrawExtras(void);
void M_DrawReplayHut(void);
void M_DrawReplayStartMenu(void);
void M_DrawReplayHutReplayInfo(void);
// Misc menus:
#define LOCATIONSTRING1 "Visit \x83SRB2.ORG/MODS\x80 to get & make addons!"

View file

@ -3807,13 +3807,13 @@ void M_DrawPlaybackMenu(void)
#define SCALEDVIEWWIDTH (vid.width/vid.dupx)
#define SCALEDVIEWHEIGHT (vid.height/vid.dupy)
void M_DrawReplayHutReplayInfo(void)
static void M_DrawReplayHutReplayInfo(menudemo_t *demoref)
{
patch_t *patch = NULL;
UINT8 *colormap;
INT32 x, y, w, h;
switch (extrasmenu.demolist[dir_on[menudepthleft]].type)
switch (demoref->type)
{
case MD_NOTLOADED:
V_DrawCenteredString(160, 40, V_SNAPTOTOP, "Loading replay information...");
@ -3834,22 +3834,20 @@ void M_DrawReplayHutReplayInfo(void)
x = 15; y = 15;
// A 160x100 image of the level as entry MAPxxP
//CONS_Printf("%d %s\n", extrasmenu.demolist[dir_on[menudepthleft]].map, G_BuildMapName(extrasmenu.demolist[dir_on[menudepthleft]].map));
if (mapheaderinfo[extrasmenu.demolist[dir_on[menudepthleft]].map])
if (demoref->map < nummapheaders && mapheaderinfo[demoref->map])
{
patch = mapheaderinfo[extrasmenu.demolist[dir_on[menudepthleft]].map]->thumbnailPic;
patch = mapheaderinfo[demoref->map]->thumbnailPic;
if (!patch)
{
patch = blanklvl;
}
}
else if (!patch)
else
{
patch = W_CachePatchName("M_NOLVL", PU_CACHE);
}
if (!(extrasmenu.demolist[dir_on[menudepthleft]].kartspeed & DF_ENCORE))
if (!(demoref->kartspeed & DF_ENCORE))
V_DrawSmallScaledPatch(x, y, V_SNAPTOTOP, patch);
else
{
@ -3867,43 +3865,42 @@ void M_DrawReplayHutReplayInfo(void)
x += 85;
if (mapheaderinfo[extrasmenu.demolist[dir_on[menudepthleft]].map-1])
V_DrawString(x, y, V_SNAPTOTOP, G_BuildMapTitle(extrasmenu.demolist[dir_on[menudepthleft]].map));
if (demoref->map < nummapheaders && mapheaderinfo[demoref->map])
V_DrawString(x, y, V_SNAPTOTOP, G_BuildMapTitle(demoref->map+1));
else
V_DrawString(x, y, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT, "Level is not loaded.");
if (extrasmenu.demolist[dir_on[menudepthleft]].numlaps)
V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("(%d laps)", extrasmenu.demolist[dir_on[menudepthleft]].numlaps));
if (demoref->numlaps)
V_DrawThinString(x, y+9, V_SNAPTOTOP|V_ALLOWLOWERCASE, va("(%d laps)", demoref->numlaps));
V_DrawString(x, y+20, V_SNAPTOTOP|V_ALLOWLOWERCASE, extrasmenu.demolist[dir_on[menudepthleft]].gametype == GT_RACE ?
va("Race (%s speed)", kartspeed_cons_t[(extrasmenu.demolist[dir_on[menudepthleft]].kartspeed & ~DF_ENCORE) + 1].strvalue) :
V_DrawString(x, y+20, V_SNAPTOTOP|V_ALLOWLOWERCASE, demoref->gametype == GT_RACE ?
va("Race (%s speed)", kartspeed_cons_t[(demoref->kartspeed & ~DF_ENCORE) + 1].strvalue) :
"Battle Mode");
if (!extrasmenu.demolist[dir_on[menudepthleft]].standings[0].ranking)
if (!demoref->standings[0].ranking)
{
// No standings were loaded!
V_DrawString(x, y+39, V_SNAPTOTOP|V_ALLOWLOWERCASE|V_TRANSLUCENT, "No standings available.");
break;
}
V_DrawThinString(x, y+29, V_SNAPTOTOP|highlightflags, "WINNER");
V_DrawString(x+38, y+30, V_SNAPTOTOP|V_ALLOWLOWERCASE, extrasmenu.demolist[dir_on[menudepthleft]].standings[0].name);
V_DrawString(x+38, y+30, V_SNAPTOTOP|V_ALLOWLOWERCASE, demoref->standings[0].name);
if (extrasmenu.demolist[dir_on[menudepthleft]].gametype == GT_RACE)
if (demoref->gametype == GT_RACE)
{
V_DrawThinString(x, y+39, V_SNAPTOTOP|highlightflags, "TIME");
V_DrawRightAlignedString(x+84, y+40, V_SNAPTOTOP, va("%d'%02d\"%02d",
G_TicsToMinutes(extrasmenu.demolist[dir_on[menudepthleft]].standings[0].timeorscore, true),
G_TicsToSeconds(extrasmenu.demolist[dir_on[menudepthleft]].standings[0].timeorscore),
G_TicsToCentiseconds(extrasmenu.demolist[dir_on[menudepthleft]].standings[0].timeorscore)
G_TicsToMinutes(demoref->standings[0].timeorscore, true),
G_TicsToSeconds(demoref->standings[0].timeorscore),
G_TicsToCentiseconds(demoref->standings[0].timeorscore)
));
}
else
{
V_DrawThinString(x, y+39, V_SNAPTOTOP|highlightflags, "SCORE");
V_DrawString(x+32, y+40, V_SNAPTOTOP, va("%d", extrasmenu.demolist[dir_on[menudepthleft]].standings[0].timeorscore));
V_DrawString(x+32, y+40, V_SNAPTOTOP, va("%d", demoref->standings[0].timeorscore));
}
// Character face!
@ -3911,12 +3908,12 @@ void M_DrawReplayHutReplayInfo(void)
// Lat: 08/06/2020: For some reason missing skins have their value set to 255 (don't even ask me why I didn't write this)
// and for an even STRANGER reason this passes the first check below, so we're going to make sure that the skin here ISN'T 255 before we do anything stupid.
if (extrasmenu.demolist[dir_on[menudepthleft]].standings[0].skin != 0xFF)
if (demoref->standings[0].skin != 0xFF)
{
patch = faceprefix[extrasmenu.demolist[dir_on[menudepthleft]].standings[0].skin][FACE_WANTED];
patch = faceprefix[demoref->standings[0].skin][FACE_WANTED];
colormap = R_GetTranslationColormap(
extrasmenu.demolist[dir_on[menudepthleft]].standings[0].skin,
extrasmenu.demolist[dir_on[menudepthleft]].standings[0].color,
demoref->standings[0].skin,
demoref->standings[0].color,
GTC_MENUCACHE);
}
else
@ -3924,7 +3921,7 @@ void M_DrawReplayHutReplayInfo(void)
patch = W_CachePatchName("M_NOWANT", PU_CACHE);
colormap = R_GetTranslationColormap(
TC_RAINBOW,
extrasmenu.demolist[dir_on[menudepthleft]].standings[0].color,
demoref->standings[0].color,
GTC_MENUCACHE);
}
@ -4073,7 +4070,7 @@ void M_DrawReplayHut(void)
if (itemOn == replaylistitem)
{
M_DrawReplayHutReplayInfo();
M_DrawReplayHutReplayInfo(&extrasmenu.demolist[dir_on[menudepthleft]]);
}
}
@ -4081,42 +4078,43 @@ void M_DrawReplayStartMenu(void)
{
const char *warning;
UINT8 i;
menudemo_t *demoref = &extrasmenu.demolist[dir_on[menudepthleft]];
M_DrawEggaChannel();
M_DrawGenericMenu();
#define STARTY 62-(extrasmenu.replayScrollTitle>>1)
// Draw rankings beyond first
for (i = 1; i < MAXPLAYERS && extrasmenu.demolist[dir_on[menudepthleft]].standings[i].ranking; i++)
for (i = 1; i < MAXPLAYERS && demoref->standings[i].ranking; i++)
{
patch_t *patch;
UINT8 *colormap;
V_DrawRightAlignedString(BASEVIDWIDTH-100, STARTY + i*20, V_SNAPTOTOP|highlightflags, va("%2d", extrasmenu.demolist[dir_on[menudepthleft]].standings[i].ranking));
V_DrawThinString(BASEVIDWIDTH-96, STARTY + i*20, V_SNAPTOTOP|V_ALLOWLOWERCASE, extrasmenu.demolist[dir_on[menudepthleft]].standings[i].name);
V_DrawRightAlignedString(BASEVIDWIDTH-100, STARTY + i*20, V_SNAPTOTOP|highlightflags, va("%2d", demoref->standings[i].ranking));
V_DrawThinString(BASEVIDWIDTH-96, STARTY + i*20, V_SNAPTOTOP|V_ALLOWLOWERCASE, demoref->standings[i].name);
if (extrasmenu.demolist[dir_on[menudepthleft]].standings[i].timeorscore == UINT32_MAX-1)
if (demoref->standings[i].timeorscore == UINT32_MAX-1)
V_DrawThinString(BASEVIDWIDTH-92, STARTY + i*20 + 9, V_SNAPTOTOP, "NO CONTEST");
else if (extrasmenu.demolist[dir_on[menudepthleft]].gametype == GT_RACE)
else if (demoref->gametype == GT_RACE)
V_DrawRightAlignedString(BASEVIDWIDTH-40, STARTY + i*20 + 9, V_SNAPTOTOP, va("%d'%02d\"%02d",
G_TicsToMinutes(extrasmenu.demolist[dir_on[menudepthleft]].standings[i].timeorscore, true),
G_TicsToSeconds(extrasmenu.demolist[dir_on[menudepthleft]].standings[i].timeorscore),
G_TicsToCentiseconds(extrasmenu.demolist[dir_on[menudepthleft]].standings[i].timeorscore)
G_TicsToMinutes(demoref->standings[i].timeorscore, true),
G_TicsToSeconds(demoref->standings[i].timeorscore),
G_TicsToCentiseconds(demoref->standings[i].timeorscore)
));
else
V_DrawString(BASEVIDWIDTH-92, STARTY + i*20 + 9, V_SNAPTOTOP, va("%d", extrasmenu.demolist[dir_on[menudepthleft]].standings[i].timeorscore));
V_DrawString(BASEVIDWIDTH-92, STARTY + i*20 + 9, V_SNAPTOTOP, va("%d", demoref->standings[i].timeorscore));
// Character face!
// Lat: 08/06/2020: For some reason missing skins have their value set to 255 (don't even ask me why I didn't write this)
// and for an even STRANGER reason this passes the first check below, so we're going to make sure that the skin here ISN'T 255 before we do anything stupid.
if (extrasmenu.demolist[dir_on[menudepthleft]].standings[i].skin != 0xFF)
if (demoref->standings[i].skin != 0xFF)
{
patch = faceprefix[extrasmenu.demolist[dir_on[menudepthleft]].standings[i].skin][FACE_RANK];
patch = faceprefix[demoref->standings[i].skin][FACE_RANK];
colormap = R_GetTranslationColormap(
extrasmenu.demolist[dir_on[menudepthleft]].standings[i].skin,
extrasmenu.demolist[dir_on[menudepthleft]].standings[i].color,
demoref->standings[i].skin,
demoref->standings[i].color,
GTC_MENUCACHE);
}
else
@ -4124,7 +4122,7 @@ void M_DrawReplayStartMenu(void)
patch = W_CachePatchName("M_NORANK", PU_CACHE);
colormap = R_GetTranslationColormap(
TC_RAINBOW,
extrasmenu.demolist[dir_on[menudepthleft]].standings[i].color,
demoref->standings[i].color,
GTC_MENUCACHE);
}
@ -4157,12 +4155,12 @@ void M_DrawReplayStartMenu(void)
}
V_DrawFill(10, 10, 300, 60, V_SNAPTOTOP|159);
M_DrawReplayHutReplayInfo();
M_DrawReplayHutReplayInfo(demoref);
V_DrawString(10, 72, V_SNAPTOTOP|highlightflags|V_ALLOWLOWERCASE, extrasmenu.demolist[dir_on[menudepthleft]].title);
V_DrawString(10, 72, V_SNAPTOTOP|highlightflags|V_ALLOWLOWERCASE, demoref->title);
// Draw a warning prompt if needed
switch (extrasmenu.demolist[dir_on[menudepthleft]].addonstatus)
switch (demoref->addonstatus)
{
case DFILE_ERROR_CANNOTLOAD:
warning = "Some addons in this replay cannot be loaded.\nYou can watch anyway, but desyncs may occur.";

View file

@ -4207,17 +4207,17 @@ void M_ServerListFillDebug(void)
serverlist[i].info.numberofplayer = min(i, 8);
serverlist[i].info.maxplayer = 8;
serverlist[i].info.avgpwrlv = P_RandomRange(500, 1500);
serverlist[i].info.time = P_RandomRange(16, 500); // ping
serverlist[i].info.avgpwrlv = P_RandomRange(PR_UNDEFINED, 500, 1500);
serverlist[i].info.time = P_RandomRange(PR_UNDEFINED, 1, 8); // ping
strcpy(serverlist[i].info.servername, va("Serv %d", i+1));
strcpy(serverlist[i].info.gametypename, i & 1 ? "Race" : "Battle");
P_RandomRange(0, 5); // change results...
serverlist[i].info.kartvars = P_RandomRange(0, 3) & SV_SPEEDMASK;
P_RandomRange(PR_UNDEFINED, 0, 5); // change results...
serverlist[i].info.kartvars = P_RandomRange(PR_UNDEFINED, 0, 3) & SV_SPEEDMASK;
serverlist[i].info.modifiedgame = P_RandomRange(0, 1);
serverlist[i].info.modifiedgame = P_RandomRange(PR_UNDEFINED, 0, 1);
CONS_Printf("Serv %d | %d...\n", i, serverlist[i].info.modifiedgame);
}

View file

@ -29,4 +29,14 @@ void Obj_SPBTouch(mobj_t *spb, mobj_t *toucher);
void Obj_MantaRingThink(mobj_t *manta);
mobj_t *Obj_MantaRingCreate(mobj_t *spb, mobj_t *owner, mobj_t *chase);
/* Orbinaut */
void Obj_OrbinautThink(mobj_t *th);
boolean Obj_OrbinautJawzCollide(mobj_t *t1, mobj_t *t2);
void Obj_OrbinautThrown(mobj_t *th, fixed_t finalSpeed, SINT8 dir);
void Obj_OrbinautJawzMoveHeld(player_t *player);
/* Jawz */
void Obj_JawzThink(mobj_t *th);
void Obj_JawzThrown(mobj_t *th, fixed_t finalSpeed, SINT8 dir);
#endif/*k_objects_H*/

View file

@ -515,26 +515,26 @@ void K_SetPowerLevelScrambles(SINT8 powertype)
{
case 5:
speed = KARTSPEED_HARD;
encore = P_RandomChance(FRACUNIT>>1);
encore = P_RandomChance(PR_RULESCRAMBLE, FRACUNIT>>1);
break;
case 4:
speed = P_RandomChance((7<<FRACBITS)/10) ? KARTSPEED_HARD : KARTSPEED_NORMAL;
encore = P_RandomChance(FRACUNIT>>1);
speed = P_RandomChance(PR_RULESCRAMBLE, (7<<FRACBITS)/10) ? KARTSPEED_HARD : KARTSPEED_NORMAL;
encore = P_RandomChance(PR_RULESCRAMBLE, FRACUNIT>>1);
break;
case 3:
speed = P_RandomChance((3<<FRACBITS)/10) ? KARTSPEED_HARD : KARTSPEED_NORMAL;
encore = P_RandomChance(FRACUNIT>>2);
speed = P_RandomChance(PR_RULESCRAMBLE, (3<<FRACBITS)/10) ? KARTSPEED_HARD : KARTSPEED_NORMAL;
encore = P_RandomChance(PR_RULESCRAMBLE, FRACUNIT>>2);
break;
case 2:
speed = KARTSPEED_NORMAL;
encore = P_RandomChance(FRACUNIT>>3);
encore = P_RandomChance(PR_RULESCRAMBLE, FRACUNIT>>3);
break;
case 1: default:
speed = KARTSPEED_NORMAL;
encore = false;
break;
case 0:
speed = P_RandomChance((3<<FRACBITS)/10) ? KARTSPEED_EASY : KARTSPEED_NORMAL;
speed = P_RandomChance(PR_RULESCRAMBLE, (3<<FRACBITS)/10) ? KARTSPEED_EASY : KARTSPEED_NORMAL;
encore = false;
break;
}

View file

@ -628,7 +628,7 @@ static void K_SpawnSplashParticles(mobj_t *mo, t_splash_t *s, fixed_t impact)
if (numParticles == 1)
{
// Random angle.
pushAngle = P_RandomRange(0, ANGLE_MAX);
pushAngle = P_RandomRange(PR_TERRAIN, 0, ANGLE_MAX);
}
if (s->spread > 0)
@ -783,20 +783,20 @@ static void K_SpawnFootstepParticle(mobj_t *mo, t_footstep_t *fs, tic_t timer)
if (((timer / fs->frequency) / 2) & 1)
{
tireAngle -= ANGLE_45;
tireAngle -= P_RandomRange(0, fs->cone / ANG1) * ANG1;
pushAngle -= P_RandomRange(0, fs->cone / ANG1) * ANG1;
tireAngle -= P_RandomRange(PR_TERRAIN, 0, fs->cone / ANG1) * ANG1;
pushAngle -= P_RandomRange(PR_TERRAIN, 0, fs->cone / ANG1) * ANG1;
}
else
{
tireAngle += ANGLE_45;
tireAngle += P_RandomRange(0, fs->cone / ANG1) * ANG1;
pushAngle += P_RandomRange(0, fs->cone / ANG1) * ANG1;
tireAngle += P_RandomRange(PR_TERRAIN, 0, fs->cone / ANG1) * ANG1;
pushAngle += P_RandomRange(PR_TERRAIN, 0, fs->cone / ANG1) * ANG1;
}
if (fs->spread > 0)
{
xOff = P_RandomRange(-fs->spread / FRACUNIT, fs->spread / FRACUNIT) * FRACUNIT;
yOff = P_RandomRange(-fs->spread / FRACUNIT, fs->spread / FRACUNIT) * FRACUNIT;
xOff = P_RandomRange(PR_TERRAIN, -fs->spread / FRACUNIT, fs->spread / FRACUNIT) * FRACUNIT;
yOff = P_RandomRange(PR_TERRAIN, -fs->spread / FRACUNIT, fs->spread / FRACUNIT) * FRACUNIT;
}
dust = P_SpawnMobjFromMobj(

View file

@ -380,10 +380,13 @@ static int lib_pGetEffectiveFollowerColor(lua_State *L)
// M_RANDOM
//////////////
// TODO: Lua needs a way to set RNG class, which will break compatibility.
// It will be more desireable to do it when RNG classes can be freeslotted.
static int lib_pRandomFixed(lua_State *L)
{
NOHUD
lua_pushfixed(L, P_RandomFixed());
lua_pushfixed(L, P_RandomFixed(PR_UNDEFINED));
demo_writerng = 2;
return 1;
}
@ -391,7 +394,7 @@ static int lib_pRandomFixed(lua_State *L)
static int lib_pRandomByte(lua_State *L)
{
NOHUD
lua_pushinteger(L, P_RandomByte());
lua_pushinteger(L, P_RandomByte(PR_UNDEFINED));
demo_writerng = 2;
return 1;
}
@ -403,7 +406,7 @@ static int lib_pRandomKey(lua_State *L)
NOHUD
if (a > 65536)
LUA_UsageWarning(L, "P_RandomKey: range > 65536 is undefined behavior");
lua_pushinteger(L, P_RandomKey(a));
lua_pushinteger(L, P_RandomKey(PR_UNDEFINED, a));
demo_writerng = 2;
return 1;
}
@ -421,7 +424,7 @@ static int lib_pRandomRange(lua_State *L)
}
if ((b-a+1) > 65536)
LUA_UsageWarning(L, "P_RandomRange: range > 65536 is undefined behavior");
lua_pushinteger(L, P_RandomRange(a, b));
lua_pushinteger(L, P_RandomRange(PR_UNDEFINED, a, b));
demo_writerng = 2;
return 1;
}
@ -430,7 +433,7 @@ static int lib_pRandomRange(lua_State *L)
static int lib_pSignedRandom(lua_State *L)
{
NOHUD
lua_pushinteger(L, P_SignedRandom());
lua_pushinteger(L, P_SignedRandom(PR_UNDEFINED));
demo_writerng = 2;
return 1;
}
@ -439,7 +442,7 @@ static int lib_pRandomChance(lua_State *L)
{
fixed_t p = luaL_checkfixed(L, 1);
NOHUD
lua_pushboolean(L, P_RandomChance(p));
lua_pushboolean(L, P_RandomChance(PR_UNDEFINED, p));
demo_writerng = 2;
return 1;
}
@ -3632,7 +3635,7 @@ static int lib_kFindJawzTarget(lua_State *L)
return LUA_ErrInvalid(L, "mobj_t");
if (!source)
return LUA_ErrInvalid(L, "player_t");
LUA_PushUserdata(L, K_FindJawzTarget(actor, source), META_PLAYER);
LUA_PushUserdata(L, K_FindJawzTarget(actor, source, ANGLE_45), META_PLAYER);
return 1;
}

View file

@ -682,9 +682,9 @@ void Command_CauseCfail_f(void)
}
P_UnsetThingPosition(players[consoleplayer].mo);
P_RandomFixed();
P_RandomByte();
P_RandomFixed();
P_RandomFixed(PR_UNDEFINED);
P_RandomByte(PR_UNDEFINED);
P_RandomFixed(PR_UNDEFINED);
players[consoleplayer].mo->x = 0;
players[consoleplayer].mo->y = 123311; //cfail cansuled kthxbye
players[consoleplayer].mo->z = 123311;

View file

@ -82,23 +82,27 @@ INT32 M_RandomRange(INT32 a, INT32 b)
// PRNG functions (synched)
// ------------------------
// Holds the current seed.
static UINT32 randomseed = 0xBADE4404;
#define DEFAULT_SEED (0xBADE4404)
// Holds the INITIAL seed value. Used for demos, possibly other debugging.
static UINT32 initialseed = 0xBADE4404;
typedef struct
{
UINT32 seed[PRNUMCLASS]; // Holds each block's current seed.
UINT32 init[PRNUMCLASS]; // Holds the INITIAL seed value. Used for demos, possibly other debugging
} rng_t;
static rng_t rng; // The entire PRNG state
/** Provides a random fixed point number.
* This is a variant of an xorshift PRNG; state fits in a 32 bit integer structure.
*
* \return A random fixed point number from [0,1).
*/
ATTRINLINE static fixed_t FUNCINLINE __internal_prng__(void)
ATTRINLINE static fixed_t FUNCINLINE __internal_prng__(pr_class_t pr_class)
{
randomseed ^= randomseed >> 13;
randomseed ^= randomseed >> 11;
randomseed ^= randomseed << 21;
return ( (randomseed*36548569) >> 4) & (FRACUNIT-1);
rng.seed[pr_class] ^= rng.seed[pr_class] >> 13;
rng.seed[pr_class] ^= rng.seed[pr_class] >> 11;
rng.seed[pr_class] ^= rng.seed[pr_class] << 21;
return ( (rng.seed[pr_class] * 36548569) >> 4) & (FRACUNIT-1);
}
/** Provides a random fixed point number. Distribution is uniform.
@ -107,14 +111,14 @@ ATTRINLINE static fixed_t FUNCINLINE __internal_prng__(void)
* \return A random fixed point number from [0,1).
*/
#ifndef DEBUGRANDOM
fixed_t P_RandomFixed(void)
fixed_t P_RandomFixed(pr_class_t pr_class)
{
#else
fixed_t P_RandomFixedD(const char *rfile, INT32 rline)
fixed_t P_RandomFixedD(const char *rfile, INT32 rline, pr_class_t pr_class)
{
CONS_Printf("P_RandomFixed() at: %sp %d\n", rfile, rline);
CONS_Printf("P_RandomFixed(%u) at: %sp %d\n", pr_class, rfile, rline);
#endif
return __internal_prng__();
return __internal_prng__(pr_class);
}
/** Provides a random byte. Distribution is uniform.
@ -125,14 +129,14 @@ fixed_t P_RandomFixedD(const char *rfile, INT32 rline)
* \sa __internal_prng__
*/
#ifndef DEBUGRANDOM
UINT8 P_RandomByte(void)
UINT8 P_RandomByte(pr_class_t pr_class)
{
#else
UINT8 P_RandomByteD(const char *rfile, INT32 rline)
UINT8 P_RandomByteD(const char *rfile, INT32 rline, pr_class_t pr_class)
{
CONS_Printf("P_RandomByte() at: %sp %d\n", rfile, rline);
CONS_Printf("P_RandomByte(%u) at: %sp %d\n", pr_class, rfile, rline);
#endif
return (UINT8)((__internal_prng__()&0xFF00)>>8);
return (UINT8)((__internal_prng__(pr_class) & 0xFF00) >> 8);
}
/** Provides a random integer for picking random elements from an array.
@ -144,14 +148,14 @@ UINT8 P_RandomByteD(const char *rfile, INT32 rline)
* \sa __internal_prng__
*/
#ifndef DEBUGRANDOM
INT32 P_RandomKey(INT32 a)
INT32 P_RandomKey(pr_class_t pr_class, INT32 a)
{
#else
INT32 P_RandomKeyD(const char *rfile, INT32 rline, INT32 a)
INT32 P_RandomKeyD(const char *rfile, INT32 rline, pr_class_t pr_class, INT32 a)
{
CONS_Printf("P_RandomKey() at: %sp %d\n", rfile, rline);
CONS_Printf("P_RandomKey(%u) at: %sp %d\n", pr_class, rfile, rline);
#endif
return (INT32)(((INT64)__internal_prng__() * a) >> FRACBITS);
return (INT32)(((INT64)__internal_prng__(pr_class) * a) >> FRACBITS);
}
/** Provides a random integer in a given range.
@ -164,14 +168,14 @@ INT32 P_RandomKeyD(const char *rfile, INT32 rline, INT32 a)
* \sa __internal_prng__
*/
#ifndef DEBUGRANDOM
INT32 P_RandomRange(INT32 a, INT32 b)
INT32 P_RandomRange(pr_class_t pr_class, INT32 a, INT32 b)
{
#else
INT32 P_RandomRangeD(const char *rfile, INT32 rline, INT32 a, INT32 b)
INT32 P_RandomRangeD(const char *rfile, INT32 rline, pr_class_t pr_class, INT32 a, INT32 b)
{
CONS_Printf("P_RandomRange() at: %sp %d\n", rfile, rline);
CONS_Printf("P_RandomRange(%u) at: %sp %d\n", pr_class, rfile, rline);
#endif
return (INT32)(((INT64)__internal_prng__() * (b-a+1)) >> FRACBITS) + a;
return (INT32)(((INT64)__internal_prng__(pr_class) * (b - a + 1)) >> FRACBITS) + a;
}
@ -186,11 +190,11 @@ INT32 P_RandomRangeD(const char *rfile, INT32 rline, INT32 a, INT32 b)
* \return A 'random' fixed point number from [0,1).
* \sa __internal_prng__
*/
fixed_t P_RandomPeek(void)
fixed_t P_RandomPeek(pr_class_t pr_class)
{
UINT32 r = randomseed;
fixed_t ret = __internal_prng__();
randomseed = r;
UINT32 r = rng.seed[pr_class];
fixed_t ret = __internal_prng__(pr_class);
rng.seed[pr_class] = r;
return ret;
}
@ -200,14 +204,14 @@ fixed_t P_RandomPeek(void)
* \sa P_SetRandSeed
*/
#ifndef DEBUGRANDOM
UINT32 P_GetRandSeed(void)
UINT32 P_GetRandSeed(pr_class_t pr_class)
{
#else
UINT32 P_GetRandSeedD(const char *rfile, INT32 rline)
UINT32 P_GetRandSeedD(const char *rfile, INT32 rline, pr_class_t pr_class)
{
CONS_Printf("P_GetRandSeed() at: %sp %d\n", rfile, rline);
CONS_Printf("P_GetRandSeed(%u) at: %sp %d\n", pr_class, rfile, rline);
#endif
return randomseed;
return rng.seed[pr_class];
}
/** Gets the initial random seed. Used by demos.
@ -216,34 +220,82 @@ UINT32 P_GetRandSeedD(const char *rfile, INT32 rline)
* \sa P_SetRandSeed
*/
#ifndef DEBUGRANDOM
UINT32 P_GetInitSeed(void)
UINT32 P_GetInitSeed(pr_class_t pr_class)
{
#else
UINT32 P_GetInitSeedD(const char *rfile, INT32 rline)
UINT32 P_GetInitSeedD(const char *rfile, INT32 rline, pr_class_t pr_class)
{
CONS_Printf("P_GetInitSeed() at: %sp %d\n", rfile, rline);
CONS_Printf("P_GetInitSeed(%u) at: %sp %d\n", pr_class, rfile, rline);
#endif
return initialseed;
return rng.init[pr_class];
}
/** Sets the random seed.
* Used at the beginning of the game, and also for netgames.
* Used at the beginning of a game.
*
* \param rindex New random index.
* \param pr_class RNG class to adjust.
* \param seed New random seed.
* \sa P_GetRandSeed
*/
#ifndef DEBUGRANDOM
void P_SetRandSeed(UINT32 seed)
void P_SetRandSeed(pr_class_t pr_class, UINT32 seed)
{
#else
void P_SetRandSeedD(const char *rfile, INT32 rline, UINT32 seed)
void P_SetRandSeedD(const char *rfile, INT32 rline, pr_class_t pr_class, UINT32 seed)
{
CONS_Printf("P_SetRandSeed() at: %sp %d\n", rfile, rline);
CONS_Printf("P_SetRandSeed(%u) at: %sp %d\n", pr_class, rfile, rline);
#endif
// xorshift requires a nonzero seed
// this should never happen, but just in case it DOES, we check
if (!seed) seed = 0xBADE4404;
randomseed = initialseed = seed;
if (!seed) seed = DEFAULT_SEED;
rng.seed[pr_class] = rng.init[pr_class] = seed;
}
/** Sets both the initial seed and the current seed.
* Used for netgame sync.
*
* \param pr_class RNG class to adjust.
* \param init Sent initial seed.
* \param seed Sent current seed.
* \sa P_SetRandSeed
*/
#ifndef DEBUGRANDOM
void P_SetRandSeedNet(pr_class_t pr_class, UINT32 init, UINT32 seed)
{
#else
void P_SetRandSeedNetD(const char *rfile, INT32 rline, pr_class_t pr_class, UINT32 init, UINT32 seed)
{
CONS_Printf("P_SetRandSeedNet(%u) at: %sp %d\n", pr_class, rfile, rline);
#endif
if (!init) init = DEFAULT_SEED;
rng.init[pr_class] = init;
if (!seed) seed = DEFAULT_SEED;
rng.seed[pr_class] = seed;
}
/** Initializes random seeds for all classes.
* Used at the beginning of a game.
*
* \param rindex New random index.
* \sa P_SetRandSeed
*/
void P_ClearRandom(UINT32 seed)
{
size_t i;
if (!seed) seed = DEFAULT_SEED;
for (i = 0; i < PRNUMCLASS; i++)
{
P_SetRandSeed(i, seed);
// Different XOR from __internal_prng__
// so that it's not as predictable.
seed ^= seed >> 13;
seed ^= seed << 25;
seed ^= seed >> 11;
}
}
/** Gets a randomized seed for setting the random seed.
@ -252,5 +304,5 @@ void P_SetRandSeedD(const char *rfile, INT32 rline, UINT32 seed)
*/
UINT32 M_RandomizedSeed(void)
{
return ((totalplaytime & 0xFFFF) << 16)|M_RandomFixed();
return ((totalplaytime & 0xFFFF) << 16) | M_RandomFixed();
}

View file

@ -20,6 +20,50 @@
//#define DEBUGRANDOM
typedef enum
{
// Before release, cases of this RNG class should
// be removed, only kept as the default for Lua.
PR_UNDEFINED,
// The rule for RNG classes:
// Don't mix up gameplay & decorative RNG.
// Decorative RNG is a lot less important
// and can be lumped together. If it's used enough,
// it might be nice to give it's own, though.
// However each instance of RNG being used for
// gameplay should be split up as much as possible.
PR_EXECUTOR, // Linedef executor
PR_DECORATION, // Generic decoration
PR_TERRAIN, // TERRAIN particles
PR_BUBBLE, // Decorative air bubbles
PR_RANDOMANIM, // FF_ANIMATE|FF_RANDOMANIM
PR_PLAYERSTARTS, // Player starts
PR_VOICES, // Player voice sounds
PR_RULESCRAMBLE, // Netgame rule scrambing events
PR_ITEM_ROULETTE, // Item results
PR_ITEM_RINGS, // Flung ring/bumper/player (on death)
PR_ITEM_SHRINK, // Shrink gun offsets
PR_ITEM_BUBBLE, // Item bubbles
PR_ITEM_DEBRIS, // Item debris
PR_ITEM_BOOST, // Boost
PR_EXPLOSION, // Explosion VFX
PR_SMOLDERING, // Smoldering particles
PR_SPARKLE, // Endsign and/or Emerald
PR_MOVINGTARGET, // Randomised moving targets
PRNUMCLASS
} pr_class_t;
// M_Random functions pull random numbers of various types that aren't network synced.
// P_Random functions pulls random bytes from a PRNG that is network synced.
@ -32,44 +76,49 @@ INT32 M_RandomRange(INT32 a, INT32 b);
// PRNG functions
#ifdef DEBUGRANDOM
#define P_RandomFixed() P_RandomFixedD(__FILE__, __LINE__)
#define P_RandomByte() P_RandomByteD(__FILE__, __LINE__)
#define P_RandomKey(c) P_RandomKeyD(__FILE__, __LINE__, c)
#define P_RandomRange(c, d) P_RandomRangeD(__FILE__, __LINE__, c, d)
fixed_t P_RandomFixedD(const char *rfile, INT32 rline);
UINT8 P_RandomByteD(const char *rfile, INT32 rline);
INT32 P_RandomKeyD(const char *rfile, INT32 rline, INT32 a);
INT32 P_RandomRangeD(const char *rfile, INT32 rline, INT32 a, INT32 b);
#define P_RandomFixed(c) P_RandomFixedD(__FILE__, __LINE__, c)
#define P_RandomByte(c) P_RandomByteD(__FILE__, __LINE__, c)
#define P_RandomKey(c, d) P_RandomKeyD(__FILE__, __LINE__, c, d)
#define P_RandomRange(c, d, e) P_RandomRangeD(__FILE__, __LINE__, c, d, e)
fixed_t P_RandomFixedD(const char *rfile, INT32 rline, pr_class_t pr_class);
UINT8 P_RandomByteD(const char *rfile, INT32 rline, pr_class_t pr_class);
INT32 P_RandomKeyD(const char *rfile, INT32 rline, pr_class_t pr_class, INT32 a);
INT32 P_RandomRangeD(const char *rfile, INT32 rline, pr_class_t pr_class, INT32 a, INT32 b);
#else
fixed_t P_RandomFixed(void);
UINT8 P_RandomByte(void);
INT32 P_RandomKey(INT32 a);
INT32 P_RandomRange(INT32 a, INT32 b);
fixed_t P_RandomFixed(pr_class_t pr_class);
UINT8 P_RandomByte(pr_class_t pr_class);
INT32 P_RandomKey(pr_class_t pr_class, INT32 a);
INT32 P_RandomRange(pr_class_t pr_class, INT32 a, INT32 b);
#endif
// Macros for other functions
#define M_SignedRandom() ((INT32)M_RandomByte() - 128) // [-128, 127] signed byte, originally a
#define P_SignedRandom() ((INT32)P_RandomByte() - 128) // function of its own, moved to a macro
#define M_SignedRandom() ((INT32)M_RandomByte() - 128) // [-128, 127] signed byte, originally a
#define P_SignedRandom(pr) ((INT32)P_RandomByte(pr) - 128) // function of its own, moved to a macro
#define M_RandomChance(p) (M_RandomFixed() < p) // given fixed point probability, p, between 0 (0%)
#define P_RandomChance(p) (P_RandomFixed() < p) // and FRACUNIT (100%), returns true p% of the time
#define M_RandomChance(p) (M_RandomFixed() < p) // given fixed point probability, p, between 0 (0%)
#define P_RandomChance(pr, p) (P_RandomFixed(pr) < p) // and FRACUNIT (100%), returns true p% of the time
// Debugging
fixed_t P_RandomPeek(void);
fixed_t P_RandomPeek(pr_class_t pr_class);
// Working with the seed for PRNG
#ifdef DEBUGRANDOM
#define P_GetRandSeed() P_GetRandSeedD(__FILE__, __LINE__)
#define P_GetInitSeed() P_GetInitSeedD(__FILE__, __LINE__)
#define P_SetRandSeed(s) P_SetRandSeedD(__FILE__, __LINE__, s)
UINT32 P_GetRandSeedD(const char *rfile, INT32 rline);
UINT32 P_GetInitSeedD(const char *rfile, INT32 rline);
void P_SetRandSeedD(const char *rfile, INT32 rline, UINT32 seed);
#define P_GetRandSeed(pr) P_GetRandSeedD(__FILE__, __LINE__, pr)
#define P_GetInitSeed(pr) P_GetInitSeedD(__FILE__, __LINE__, pr)
#define P_SetRandSeed(pr, s) P_SetRandSeedD(__FILE__, __LINE__, pr, s)
#define P_SetRandSeedNet(pr, i, s) P_SetRandSeedD(__FILE__, __LINE__, pr, i, s)
UINT32 P_GetRandSeedD(const char *rfile, INT32 rline, pr_class_t pr_class);
UINT32 P_GetInitSeedD(const char *rfile, INT32 rline, pr_class_t pr_class);
void P_SetRandSeedD(const char *rfile, INT32 rline, pr_class_t pr_class, UINT32 seed);
void P_SetRandSeedNetD(const char *rfile, INT32 rline, pr_class_t pr_class, UINT32 init, UINT32 seed);
#else
UINT32 P_GetRandSeed(void);
UINT32 P_GetInitSeed(void);
void P_SetRandSeed(UINT32 seed);
UINT32 P_GetRandSeed(pr_class_t pr_class);
UINT32 P_GetInitSeed(pr_class_t pr_class);
void P_SetRandSeed(pr_class_t pr_class, UINT32 seed);
void P_SetRandSeedNet(pr_class_t pr_class, UINT32 init, UINT32 seed);
#endif
void P_ClearRandom(UINT32 seed);
UINT32 M_RandomizedSeed(void);
#endif

View file

@ -3,3 +3,5 @@ shrink.c
item-debris.c
spb.c
manta-ring.c
orbinaut.c
jawz.c

View file

@ -95,9 +95,9 @@ spawn_cloud
{
mobj_t *puff = P_SpawnMobjFromMobj(
collectible,
P_RandomRange(-spacing, spacing) * FRACUNIT,
P_RandomRange(-spacing, spacing) * FRACUNIT,
P_RandomRange(0, 4 * spacing) * FRACUNIT,
P_RandomRange(PR_UNDEFINED, -spacing, spacing) * FRACUNIT,
P_RandomRange(PR_UNDEFINED, -spacing, spacing) * FRACUNIT,
P_RandomRange(PR_UNDEFINED, 0, 4 * spacing) * FRACUNIT,
MT_SPINDASHDUST
);

292
src/objects/jawz.c Normal file
View file

@ -0,0 +1,292 @@
// DR. ROBOTNIK'S RING RACERS
//-----------------------------------------------------------------------------
// Copyright (C) 2022 by Sally "TehRealSalt" Cochenour
// Copyright (C) 2022 by Kart Krew
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file jawz.c
/// \brief Jawz item code.
#include "../doomdef.h"
#include "../doomstat.h"
#include "../info.h"
#include "../k_kart.h"
#include "../k_objects.h"
#include "../m_random.h"
#include "../p_local.h"
#include "../r_main.h"
#include "../s_sound.h"
#include "../g_game.h"
#include "../z_zone.h"
#include "../k_waypoint.h"
#include "../k_respawn.h"
#include "../k_collide.h"
#define MAX_JAWZ_TURN (ANGLE_90 / 15) // We can turn a maximum of 6 degrees per frame at regular max speed
#define jawz_speed(o) ((o)->movefactor)
#define jawz_selfdelay(o) ((o)->threshold)
#define jawz_dropped(o) ((o)->flags2 & MF2_AMBUSH)
#define jawz_droptime(o) ((o)->movecount)
#define jawz_retcolor(o) ((o)->cvmem)
#define jawz_stillturn(o) ((o)->cusval)
#define jawz_owner(o) ((o)->target)
#define jawz_chase(o) ((o)->tracer)
static void JawzChase(mobj_t *th, boolean grounded)
{
fixed_t thrustamount = 0;
fixed_t frictionsafety = (th->friction == 0) ? 1 : th->friction;
fixed_t topspeed = jawz_speed(th);
if (jawz_chase(th) != NULL && P_MobjWasRemoved(jawz_chase(th)) == false)
{
if (jawz_chase(th)->health > 0)
{
const angle_t targetangle = R_PointToAngle2(
th->x, th->y,
jawz_chase(th)->x, jawz_chase(th)->y
);
angle_t angledelta = th->angle - targetangle;
mobj_t *ret = NULL;
if (gametyperules & GTR_CIRCUIT)
{
const fixed_t distbarrier = FixedMul(
512 * mapobjectscale,
FRACUNIT + ((gamespeed-1) * (FRACUNIT/4))
);
const fixed_t distaway = P_AproxDistance(
jawz_chase(th)->x - th->x,
jawz_chase(th)->y - th->y
);
if (distaway < distbarrier)
{
if (jawz_chase(th)->player != NULL)
{
fixed_t speeddifference = abs(
topspeed - min(
jawz_chase(th)->player->speed,
K_GetKartSpeed(jawz_chase(th)->player, false, false)
)
);
topspeed = topspeed - FixedMul(speeddifference, FRACUNIT - FixedDiv(distaway, distbarrier));
}
}
}
if (angledelta != 0)
{
angle_t turnSpeed = MAX_JAWZ_TURN;
boolean turnclockwise = true;
// MAX_JAWZ_TURN gets stronger the slower the top speed of jawz
if (topspeed < jawz_speed(th))
{
if (topspeed == 0)
{
turnSpeed = ANGLE_180;
}
else
{
fixed_t anglemultiplier = FixedDiv(jawz_speed(th), topspeed);
turnSpeed += FixedAngle(FixedMul(AngleFixed(turnSpeed), anglemultiplier));
}
}
if (angledelta > ANGLE_180)
{
angledelta = InvAngle(angledelta);
turnclockwise = false;
}
if (angledelta > turnSpeed)
{
angledelta = turnSpeed;
}
if (turnclockwise == true)
{
th->angle -= angledelta;
}
else
{
th->angle += angledelta;
}
}
ret = P_SpawnMobjFromMobj(jawz_chase(th), 0, 0, 0, MT_PLAYERRETICULE);
ret->old_x = jawz_chase(th)->old_x;
ret->old_y = jawz_chase(th)->old_y;
ret->old_z = jawz_chase(th)->old_z;
P_SetTarget(&ret->target, jawz_chase(th));
ret->frame |= ((leveltime % 10) / 2) + 5;
ret->color = jawz_retcolor(th);
ret->renderflags = (ret->renderflags & ~RF_DONTDRAW) | (th->renderflags & RF_DONTDRAW);
}
else
{
P_SetTarget(&jawz_chase(th), NULL);
}
}
if (jawz_chase(th) == NULL || P_MobjWasRemoved(jawz_chase(th)) == true)
{
th->angle = K_MomentumAngle(th);
if (jawz_owner(th) != NULL && P_MobjWasRemoved(jawz_owner(th)) == false
&& jawz_owner(th)->player != NULL)
{
player_t *newPlayer = K_FindJawzTarget(th, jawz_owner(th)->player, ANGLE_90);
if (newPlayer != NULL)
{
P_SetTarget(&jawz_chase(th), newPlayer->mo);
}
}
}
if (jawz_stillturn(th) > 0)
{
// When beginning to chase your own owner,
// we should turn but not thrust quite yet.
return;
}
if (grounded == true)
{
const fixed_t currentspeed = R_PointToDist2(0, 0, th->momx, th->momy);
if (currentspeed >= topspeed)
{
// Thrust as if you were at top speed, slow down naturally
thrustamount = FixedDiv(topspeed, frictionsafety) - topspeed;
}
else
{
const fixed_t beatfriction = FixedDiv(currentspeed, frictionsafety) - currentspeed;
// Thrust to immediately get to top speed
thrustamount = beatfriction + FixedDiv(topspeed - currentspeed, frictionsafety);
}
P_Thrust(th, th->angle, thrustamount);
}
}
void Obj_JawzThink(mobj_t *th)
{
mobj_t *ghost = P_SpawnGhostMobj(th);
boolean grounded = P_IsObjectOnGround(th);
if (th->fuse > 0 && th->fuse <= TICRATE)
{
th->renderflags ^= RF_DONTDRAW;
}
if (jawz_dropped(th))
{
if (grounded && (th->flags & MF_NOCLIPTHING))
{
th->momx = 1;
th->momy = 0;
S_StartSound(th, th->info->deathsound);
th->flags &= ~MF_NOCLIPTHING;
}
return;
}
if (jawz_owner(th) != NULL && P_MobjWasRemoved(jawz_owner(th)) == false
&& jawz_owner(th)->player != NULL)
{
ghost->color = jawz_owner(th)->player->skincolor;
ghost->colorized = true;
}
if (!(gametyperules & GTR_CIRCUIT))
{
th->friction = max(0, 3 * th->friction / 4);
}
JawzChase(th, grounded);
K_DriftDustHandling(th);
if (P_MobjTouchingSectorSpecial(th, 3, 1, true))
{
K_DoPogoSpring(th, 0, 1);
}
if (jawz_selfdelay(th) > 0)
{
jawz_selfdelay(th)--;
}
if (jawz_stillturn(th) > 0)
{
jawz_stillturn(th)--;
}
if (leveltime % TICRATE == 0)
{
S_StartSound(th, th->info->activesound);
}
}
void Obj_JawzThrown(mobj_t *th, fixed_t finalSpeed, SINT8 dir)
{
INT32 lastTarg = -1;
if (jawz_owner(th) != NULL && P_MobjWasRemoved(jawz_owner(th)) == false
&& jawz_owner(th)->player != NULL)
{
lastTarg = jawz_owner(th)->player->lastjawztarget;
jawz_retcolor(th) = jawz_owner(th)->player->skincolor;
}
else
{
jawz_retcolor(th) = SKINCOLOR_KETCHUP;
}
if (dir == -1)
{
// Thrown backwards, init self-chase
P_SetTarget(&jawz_chase(th), jawz_owner(th));
// Stop it here.
th->momx = 0;
th->momy = 0;
// Slow down the top speed.
finalSpeed = FixedMul(finalSpeed, 4*FRACUNIT/5);
// Set a fuse.
th->fuse = RR_PROJECTILE_FUSE;
// Stay still while you turn towards the player
jawz_stillturn(th) = ANGLE_180 / MAX_JAWZ_TURN;
}
else
{
if ((lastTarg >= 0 && lastTarg < MAXPLAYERS)
&& playeringame[lastTarg] == true)
{
player_t *tryPlayer = &players[lastTarg];
if (tryPlayer->spectator == false)
{
P_SetTarget(&jawz_chase(th), tryPlayer->mo);
}
}
}
S_StartSound(th, th->info->activesound);
jawz_speed(th) = finalSpeed;
}

379
src/objects/orbinaut.c Normal file
View file

@ -0,0 +1,379 @@
// DR. ROBOTNIK'S RING RACERS
//-----------------------------------------------------------------------------
// Copyright (C) 2022 by Sally "TehRealSalt" Cochenour
// Copyright (C) 2022 by Kart Krew
//
// This program is free software distributed under the
// terms of the GNU General Public License, version 2.
// See the 'LICENSE' file for more details.
//-----------------------------------------------------------------------------
/// \file orbinaut.c
/// \brief Orbinaut item code.
#include "../doomdef.h"
#include "../doomstat.h"
#include "../info.h"
#include "../k_kart.h"
#include "../k_objects.h"
#include "../m_random.h"
#include "../p_local.h"
#include "../r_main.h"
#include "../s_sound.h"
#include "../g_game.h"
#include "../z_zone.h"
#include "../k_waypoint.h"
#include "../k_respawn.h"
#include "../k_collide.h"
#define ORBINAUT_MAXTURN (ANGLE_67h)
#define ORBINAUT_TURNLERP (16)
#define orbinaut_speed(o) ((o)->movefactor)
#define orbinaut_selfdelay(o) ((o)->threshold)
#define orbinaut_dropped(o) ((o)->flags2 & MF2_AMBUSH)
#define orbinaut_droptime(o) ((o)->movecount)
#define orbinaut_turn(o) ((o)->extravalue1)
#define orbinaut_owner(o) ((o)->target)
#define orbinaut_shield_dist(o) ((o)->extravalue1)
void Obj_OrbinautThink(mobj_t *th)
{
boolean grounded = P_IsObjectOnGround(th);
mobj_t *ghost = NULL;
if (th->fuse > 0 && th->fuse <= TICRATE)
{
th->renderflags ^= RF_DONTDRAW;
}
if (orbinaut_dropped(th))
{
if (grounded && (th->flags & MF_NOCLIPTHING))
{
th->momx = 1;
th->momy = 0;
th->frame = 3;
S_StartSound(th, th->info->activesound);
th->flags &= ~MF_NOCLIPTHING;
}
else if (orbinaut_droptime(th))
{
orbinaut_droptime(th)--;
}
else if (th->frame < 3)
{
orbinaut_droptime(th) = 2;
th->frame++;
}
return;
}
ghost = P_SpawnGhostMobj(th);
ghost->colorized = true; // already has color!
th->angle = K_MomentumAngle(th);
if (orbinaut_turn(th) != 0)
{
th->angle += orbinaut_turn(th);
if (abs(orbinaut_turn(th)) < ORBINAUT_MAXTURN)
{
if (orbinaut_turn(th) < 0)
{
orbinaut_turn(th) -= ORBINAUT_MAXTURN / ORBINAUT_TURNLERP;
}
else
{
orbinaut_turn(th) += ORBINAUT_MAXTURN / ORBINAUT_TURNLERP;
}
}
}
if (grounded == true)
{
fixed_t finalspeed = orbinaut_speed(th);
const fixed_t currentspeed = R_PointToDist2(0, 0, th->momx, th->momy);
fixed_t thrustamount = 0;
fixed_t frictionsafety = (th->friction == 0) ? 1 : th->friction;
if (th->health <= 5)
{
INT32 i;
for (i = 5; i >= th->health; i--)
{
finalspeed = FixedMul(finalspeed, FRACUNIT-FRACUNIT/4);
}
}
if (currentspeed >= finalspeed)
{
// Thrust as if you were at top speed, slow down naturally
thrustamount = FixedDiv(finalspeed, frictionsafety) - finalspeed;
}
else
{
const fixed_t beatfriction = FixedDiv(currentspeed, frictionsafety) - currentspeed;
// Thrust to immediately get to top speed
thrustamount = beatfriction + FixedDiv(finalspeed - currentspeed, frictionsafety);
}
P_Thrust(th, th->angle, thrustamount);
}
if (P_MobjTouchingSectorSpecial(th, 3, 1, true))
{
K_DoPogoSpring(th, 0, 1);
}
if (orbinaut_selfdelay(th) > 0)
{
orbinaut_selfdelay(th)--;
}
if (leveltime % 6 == 0)
{
S_StartSound(th, th->info->activesound);
}
}
boolean Obj_OrbinautJawzCollide(mobj_t *t1, mobj_t *t2)
{
boolean damageitem = false;
boolean sprung = false;
if ((orbinaut_selfdelay(t1) > 0 && t2->hitlag > 0)
|| (orbinaut_selfdelay(t2) > 0 && t1->hitlag > 0))
{
return true;
}
if (t1->health <= 0 || t2->health <= 0)
{
return true;
}
if ((orbinaut_owner(t1) == t2)
|| (!(t2->flags & (MF_ENEMY|MF_BOSS)) && (orbinaut_owner(t1) == t2->target)))
{
if ((orbinaut_selfdelay(t1) > 0 && t2->type == MT_PLAYER)
|| (orbinaut_selfdelay(t2) > 0 && t2->type != MT_PLAYER))
{
return true;
}
}
if ((t1->type == MT_ORBINAUT_SHIELD || t1->type == MT_JAWZ_SHIELD) && t1->lastlook
&& (t2->type == MT_ORBINAUT_SHIELD || t2->type == MT_JAWZ_SHIELD) && t2->lastlook
&& (orbinaut_owner(t1) == t2->target)) // Don't hit each other if you have the same target
{
return true;
}
if (t2->player)
{
if ((t2->player->flashing > 0 && t2->hitlag == 0)
&& !(t1->type == MT_ORBINAUT || t1->type == MT_JAWZ))
return true;
if (t2->player->hyudorotimer)
return true; // no interaction
if (t2->player->flamedash && t2->player->itemtype == KITEM_FLAMESHIELD)
{
// Melt item
S_StartSound(t2, sfx_s3k43);
}
else
{
// Player Damage
P_DamageMobj(t2, t1, t1->target, 1, DMG_WIPEOUT|DMG_WOMBO);
K_KartBouncing(t2, t1);
S_StartSound(t2, sfx_s3k7b);
}
damageitem = true;
}
else if (t2->type == MT_ORBINAUT || t2->type == MT_JAWZ
|| t2->type == MT_ORBINAUT_SHIELD || t2->type == MT_JAWZ_SHIELD
|| t2->type == MT_BANANA || t2->type == MT_BANANA_SHIELD
|| t2->type == MT_BALLHOG)
{
// Other Item Damage
angle_t bounceangle = K_GetCollideAngle(t1, t2);
S_StartSound(t2, t2->info->deathsound);
P_KillMobj(t2, t1, t1, DMG_NORMAL);
P_SetObjectMomZ(t2, 8*FRACUNIT, false);
P_InstaThrust(t2, bounceangle, 16*FRACUNIT);
P_SpawnMobj(t2->x/2 + t1->x/2, t2->y/2 + t1->y/2, t2->z/2 + t1->z/2, MT_ITEMCLASH);
damageitem = true;
}
else if (t2->type == MT_SSMINE_SHIELD || t2->type == MT_SSMINE || t2->type == MT_LANDMINE)
{
damageitem = true;
// Bomb death
P_KillMobj(t2, t1, t1, DMG_NORMAL);
}
else if (t2->flags & MF_SPRING && (t1->type != MT_ORBINAUT_SHIELD && t1->type != MT_JAWZ_SHIELD))
{
// Let thrown items hit springs!
sprung = P_DoSpring(t2, t1);
}
else if (t2->flags & MF_SHOOTABLE)
{
// Shootable damage
P_DamageMobj(t2, t1, t1->target, 1, DMG_NORMAL);
damageitem = true;
}
if (damageitem)
{
// This Item Damage
angle_t bounceangle = K_GetCollideAngle(t2, t1);
S_StartSound(t1, t1->info->deathsound);
P_KillMobj(t1, t2, t2, DMG_NORMAL);
P_SetObjectMomZ(t1, 8*FRACUNIT, false);
P_InstaThrust(t1, bounceangle, 16*FRACUNIT);
}
if (sprung)
{
return false;
}
return true;
}
void Obj_OrbinautThrown(mobj_t *th, fixed_t finalSpeed, SINT8 dir)
{
if (orbinaut_owner(th) != NULL && P_MobjWasRemoved(orbinaut_owner(th)) == false
&& orbinaut_owner(th)->player != NULL)
{
th->color = orbinaut_owner(th)->player->skincolor;
}
else
{
th->color = SKINCOLOR_GREY;
}
th->fuse = RR_PROJECTILE_FUSE;
orbinaut_speed(th) = finalSpeed;
if (dir == -1)
{
// Thrown backwards, init orbiting in place
orbinaut_turn(th) = ORBINAUT_MAXTURN / ORBINAUT_TURNLERP;
th->angle -= ANGLE_45;
th->momx = FixedMul(finalSpeed, FINECOSINE(th->angle >> ANGLETOFINESHIFT));
th->momy = FixedMul(finalSpeed, FINESINE(th->angle >> ANGLETOFINESHIFT));
}
}
void Obj_OrbinautJawzMoveHeld(player_t *player)
{
fixed_t finalscale = K_ItemScaleForPlayer(player);
fixed_t speed = 0;
mobj_t *cur = NULL;
player->bananadrag = 0; // Just to make sure
cur = player->mo->hnext;
speed = ((8 - min(4, player->itemamount)) * cur->info->speed) / 7;
while (cur != NULL && P_MobjWasRemoved(cur) == false)
{
const fixed_t radius = FixedHypot(player->mo->radius, player->mo->radius) + FixedHypot(cur->radius, cur->radius); // mobj's distance from its Target, or Radius.
fixed_t z;
if (!cur->health)
{
cur = cur->hnext;
continue;
}
cur->color = player->skincolor;
cur->angle -= ANGLE_90;
cur->angle += FixedAngle(speed) / 3;
if (orbinaut_shield_dist(cur) < radius)
{
orbinaut_shield_dist(cur) += P_AproxDistance(orbinaut_shield_dist(cur), radius) / 12;
}
if (orbinaut_shield_dist(cur) > radius)
{
orbinaut_shield_dist(cur) = radius;
}
// If the player is on the ceiling, then flip your items as well.
if (player && player->mo->eflags & MFE_VERTICALFLIP)
{
cur->eflags |= MFE_VERTICALFLIP;
}
else
{
cur->eflags &= ~MFE_VERTICALFLIP;
}
// Shrink your items if the player shrunk too.
cur->destscale = FixedMul(FixedDiv(orbinaut_shield_dist(cur), radius), finalscale);
P_SetScale(cur, cur->destscale);
if (P_MobjFlip(cur) > 0)
{
z = player->mo->z;
}
else
{
z = player->mo->z + player->mo->height - cur->height;
}
cur->flags |= MF_NOCLIPTHING; // temporarily make them noclip other objects so they can't hit anyone while in the player
P_MoveOrigin(cur, player->mo->x, player->mo->y, z);
cur->momx = FixedMul(FINECOSINE(cur->angle >> ANGLETOFINESHIFT), orbinaut_shield_dist(cur));
cur->momy = FixedMul(FINESINE(cur->angle >> ANGLETOFINESHIFT), orbinaut_shield_dist(cur));
cur->flags &= ~MF_NOCLIPTHING;
if (!P_TryMove(cur, player->mo->x + cur->momx, player->mo->y + cur->momy, true))
{
P_SlideMove(cur);
}
if (P_IsObjectOnGround(player->mo))
{
if (P_MobjFlip(cur) > 0)
{
if (cur->floorz > player->mo->z - cur->height)
{
z = cur->floorz;
}
}
else
{
if (cur->ceilingz < player->mo->z + player->mo->height + cur->height)
{
z = cur->ceilingz - cur->height;
}
}
}
// Center it during the scale up animation
z += (FixedMul(cur->info->height, finalscale - cur->scale) >> 1) * P_MobjFlip(cur);
cur->z = z;
cur->momx = cur->momy = 0;
cur->angle += ANGLE_90;
cur = cur->hnext;
}
}

View file

@ -330,13 +330,10 @@ static void ShrinkLaserThinker(mobj_t *pohbee, mobj_t *gun, mobj_t *laser)
laser->spriteyscale = FixedDiv(FixedDiv(gunZ - gun->floorz, mapobjectscale), laser->info->height);
particle = P_SpawnMobjFromMobj(
laser,
P_RandomRange(-16, 16) * FRACUNIT,
P_RandomRange(-16, 16) * FRACUNIT,
0,
MT_SHRINK_PARTICLE
);
particle = P_SpawnMobjFromMobj(laser, 0, 0, 0, MT_SHRINK_PARTICLE);
particle->sprxoff = P_RandomRange(PR_DECORATION, -16, 16) * laser->scale;
particle->spryoff = P_RandomRange(PR_DECORATION, -16, 16) * laser->scale;
P_SetTarget(&gun_pohbee(particle), pohbee);
@ -702,7 +699,7 @@ static void CreatePohbee(player_t *owner, waypoint_t *start, waypoint_t *end, UI
P_SetTarget(&pohbee_guns(prevGun), gun);
gun_numsegs(gun) = numSegs;
gun_offset(gun) = P_RandomKey(GUN_SWINGTIME);
gun_offset(gun) = P_RandomKey(PR_ITEM_SHRINK, GUN_SWINGTIME);
overlay = P_SpawnMobjFromMobj(gun, 0, 0, 0, MT_OVERLAY);

View file

@ -209,9 +209,9 @@ static void SpawnSPBSliptide(mobj_t *spb, SINT8 dir)
static void SpawnSPBSpeedLines(mobj_t *spb)
{
mobj_t *fast = P_SpawnMobjFromMobj(spb,
P_RandomRange(-24, 24) * FRACUNIT,
P_RandomRange(-24, 24) * FRACUNIT,
(spb->info->height / 2) + (P_RandomRange(-24, 24) * FRACUNIT),
P_RandomRange(PR_DECORATION, -24, 24) * FRACUNIT,
P_RandomRange(PR_DECORATION, -24, 24) * FRACUNIT,
(spb->info->height / 2) + (P_RandomRange(PR_DECORATION, -24, 24) * FRACUNIT),
MT_FASTLINE
);

View file

@ -310,7 +310,6 @@ void A_ChangeHeight(mobj_t *actor);
// SRB2Kart
//
void A_ItemPop(mobj_t *actor);
void A_JawzChase(mobj_t *actor);
void A_JawzExplode(mobj_t *actor);
void A_SSMineSearch(mobj_t *actor);
void A_SSMineExplode(mobj_t *actor);
@ -479,7 +478,7 @@ boolean P_CheckMissileRange(mobj_t *actor)
if (actor->type == MT_EGGMOBILE && dist > 160)
dist = 160;
if (P_RandomByte() < dist)
if (P_RandomByte(PR_UNDEFINED) < dist)
return false;
return true;
@ -576,7 +575,7 @@ static boolean P_TryWalk(mobj_t *actor)
{
if (!P_Move(actor, actor->info->speed))
return false;
actor->movecount = P_RandomByte() & 15;
actor->movecount = P_RandomByte(PR_UNDEFINED) & 15;
return true;
}
@ -627,7 +626,7 @@ void P_NewChaseDir(mobj_t *actor)
}
// try other directions
if (P_RandomChance(25*FRACUNIT/32) || abs(deltay) > abs(deltax))
if (P_RandomChance(PR_UNDEFINED, 25*FRACUNIT/32) || abs(deltay) > abs(deltax))
{
tdir = d[1];
d[1] = d[2];
@ -665,7 +664,7 @@ void P_NewChaseDir(mobj_t *actor)
}
// randomly determine direction of search
if (P_RandomChance(FRACUNIT/2))
if (P_RandomChance(PR_UNDEFINED, FRACUNIT/2))
{
for (tdir = DI_EAST; tdir <= DI_SOUTHEAST; tdir++)
{
@ -720,7 +719,7 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed
// BP: first time init, this allow minimum lastlook changes
if (actor->lastlook < 0)
actor->lastlook = P_RandomByte();
actor->lastlook = P_RandomByte(PR_UNDEFINED);
actor->lastlook %= MAXPLAYERS;
@ -1014,7 +1013,7 @@ static void P_SharpDust(mobj_t *actor, mobjtype_t type, angle_t ang)
-P_ReturnThrustX(actor, ang, 16<<FRACBITS),
-P_ReturnThrustY(actor, ang, 16<<FRACBITS),
0, type);
P_SetObjectMomZ(dust, P_RandomRange(1, 4)<<FRACBITS, false);
P_SetObjectMomZ(dust, P_RandomRange(PR_UNDEFINED, 1, 4)<<FRACBITS, false);
}
static void P_FaceStabFlume(mobj_t *actor)
@ -2133,7 +2132,7 @@ static void P_VultureHoverParticle(mobj_t *actor)
fixed_t pz = P_FloorzAtPos(px, py, actor->z, actor->height);
dust = P_SpawnMobj(px, py, pz, MT_ARIDDUST);
P_SetMobjState(dust, (statenum_t)(dust->state - states + P_RandomRange(0, 2)));
P_SetMobjState(dust, (statenum_t)(dust->state - states + P_RandomRange(PR_UNDEFINED, 0, 2)));
P_Thrust(dust, angle, FixedDiv(12*FRACUNIT, max(FRACUNIT, fdist/2)));
dust->momx += actor->momx;
dust->momy += actor->momy;
@ -2299,7 +2298,7 @@ void A_VultureFly(mobj_t *actor)
P_VultureHoverParticle(actor);
dust = P_SpawnMobj(actor->x + P_RandomFixed() - FRACUNIT/2, actor->y + P_RandomFixed() - FRACUNIT/2, actor->z + actor->height/2 + P_RandomFixed() - FRACUNIT/2, MT_PARTICLE);
dust = P_SpawnMobj(actor->x + P_RandomFixed(PR_UNDEFINED) - FRACUNIT/2, actor->y + P_RandomFixed(PR_UNDEFINED) - FRACUNIT/2, actor->z + actor->height/2 + P_RandomFixed(PR_UNDEFINED) - FRACUNIT/2, MT_PARTICLE);
P_SetScale(dust, 2*FRACUNIT);
dust->destscale = FRACUNIT/3;
dust->scalespeed = FRACUNIT/40;
@ -2935,8 +2934,8 @@ void A_Boss1Laser(mobj_t *actor)
UINT8 size = 3;
mobj_t *steam = P_SpawnMobj(x, y, point->watertop - size*mobjinfo[MT_DUST].height, MT_DUST);
P_SetScale(steam, size*actor->scale);
P_SetObjectMomZ(steam, FRACUNIT + 2*P_RandomFixed(), true);
P_InstaThrust(steam, FixedAngle(P_RandomKey(360)*FRACUNIT), 2*P_RandomFixed());
P_SetObjectMomZ(steam, FRACUNIT + 2*P_RandomFixed(PR_UNDEFINED), true);
P_InstaThrust(steam, FixedAngle(P_RandomKey(PR_UNDEFINED, 360)*FRACUNIT), 2*P_RandomFixed(PR_UNDEFINED));
if (point->info->painsound)
S_StartSound(steam, point->info->painsound);
}
@ -3135,7 +3134,7 @@ void A_SkullAttack(mobj_t *actor)
if (locvar1 == 1)
actor->angle += ANGLE_180;
else if (locvar1 == 2)
actor->angle += (P_RandomChance(FRACUNIT/2)) ? ANGLE_90 : -ANGLE_90;
actor->angle += (P_RandomChance(PR_UNDEFINED, FRACUNIT/2)) ? ANGLE_90 : -ANGLE_90;
else if (locvar1 == 3)
{
statenum_t oldspawnstate = mobjinfo[MT_RAY].spawnstate;
@ -3151,7 +3150,7 @@ void A_SkullAttack(mobj_t *actor)
mobjinfo[MT_RAY].radius = mobjinfo[actor->type].radius;
mobjinfo[MT_RAY].height = mobjinfo[actor->type].height;
if (P_RandomChance(FRACUNIT/2)) // port priority 1?
if (P_RandomChance(PR_UNDEFINED, FRACUNIT/2)) // port priority 1?
{
i = 9;
j = 27;
@ -3169,7 +3168,7 @@ void A_SkullAttack(mobj_t *actor)
P_ReturnThrustY(actor, testang, dist + 2*actor->radius),\
true)) break;
if (P_RandomChance(FRACUNIT/2)) // port priority 2?
if (P_RandomChance(PR_UNDEFINED, FRACUNIT/2)) // port priority 2?
{
for (k = 0; k < 9; k++)
{
@ -3273,7 +3272,7 @@ void A_BossScream(mobj_t *actor)
return;
if (locvar1 & 1)
fa = (FixedAngle(P_RandomKey(360)*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK;
fa = (FixedAngle(P_RandomKey(PR_EXPLOSION, 360)*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK;
else
{
actor->movecount += 4*16;
@ -3290,11 +3289,11 @@ void A_BossScream(mobj_t *actor)
explodetype = (mobjtype_t)locvar2;
if (locvar1 & 2)
z = actor->z + (P_RandomKey((actor->height - mobjinfo[explodetype].height)>>FRACBITS)<<FRACBITS);
z = actor->z + (P_RandomKey(PR_EXPLOSION, (actor->height - mobjinfo[explodetype].height)>>FRACBITS)<<FRACBITS);
else if (actor->eflags & MFE_VERTICALFLIP)
z = actor->z + actor->height - mobjinfo[explodetype].height - FixedMul((P_RandomByte()<<(FRACBITS-2)) - 8*FRACUNIT, actor->scale);
z = actor->z + actor->height - mobjinfo[explodetype].height - FixedMul((P_RandomByte(PR_EXPLOSION)<<(FRACBITS-2)) - 8*FRACUNIT, actor->scale);
else
z = actor->z + FixedMul((P_RandomByte()<<(FRACBITS-2)) - 8*FRACUNIT, actor->scale);
z = actor->z + FixedMul((P_RandomByte(PR_EXPLOSION)<<(FRACBITS-2)) - 8*FRACUNIT, actor->scale);
mo = P_SpawnMobj(x, y, z, explodetype);
if (actor->eflags & MFE_VERTICALFLIP)
@ -3789,7 +3788,7 @@ void A_BubbleSpawn(mobj_t *actor)
return; // don't make bubble!
}
prandom = P_RandomByte();
prandom = P_RandomByte(PR_BUBBLE);
if (leveltime % (3*TICRATE) < 8)
bubble = P_SpawnMobj(actor->x, actor->y, actor->z + (actor->height / 2), MT_EXTRALARGEBUBBLE);
@ -3837,7 +3836,7 @@ void A_FanBubbleSpawn(mobj_t *actor)
return; // don't make bubble!
}
prandom = P_RandomByte();
prandom = P_RandomByte(PR_BUBBLE);
if ((prandom & 0x7) == 0x7)
bubble = P_SpawnMobj(actor->x, actor->y, hz, MT_SMALLBUBBLE);
@ -3877,7 +3876,7 @@ void A_BubbleRise(mobj_t *actor)
// Move around slightly to make it look like it's bending around the water
if (!locvar1)
{
UINT8 prandom = P_RandomByte();
UINT8 prandom = P_RandomByte(PR_BUBBLE);
if (!(prandom & 0x7)) // *****000
{
P_InstaThrust(actor, prandom & 0x70 ? actor->angle + ANGLE_90 : actor->angle,
@ -4085,7 +4084,7 @@ void A_AttractChase(mobj_t *actor)
#if 0 // old
mobj_t *newring;
newring = P_SpawnMobj(actor->x, actor->y, actor->z, actor->info->reactiontime);
P_InstaThrust(newring, P_RandomRange(0,7) * ANGLE_45, 2<<FRACBITS);
P_InstaThrust(newring, P_RandomRange(PR_ITEM_RINGS, 0, 7) * ANGLE_45, 2<<FRACBITS);
newring->momz = 8<<FRACBITS;
newring->fuse = 120*TICRATE;
P_RemoveMobj(actor);
@ -4095,7 +4094,7 @@ void A_AttractChase(mobj_t *actor)
actor->info = &mobjinfo[actor->type];
actor->flags = actor->info->flags;
P_InstaThrust(actor, P_RandomRange(0,7) * ANGLE_45, 2 * actor->scale);
P_InstaThrust(actor, P_RandomRange(PR_ITEM_RINGS, 0, 7) * ANGLE_45, 2 * actor->scale);
P_SetObjectMomZ(actor, 8<<FRACBITS, false);
actor->fuse = 120*TICRATE;
#endif
@ -4184,7 +4183,7 @@ void A_FishJump(mobj_t *actor)
if (i < MAXPLAYERS)
{
fixed_t rad = actor->radius>>FRACBITS;
P_SpawnMobjFromMobj(actor, P_RandomRange(rad, -rad)<<FRACBITS, P_RandomRange(rad, -rad)<<FRACBITS, 0, (mobjtype_t)locvar2);
P_SpawnMobjFromMobj(actor, P_RandomRange(PR_UNDEFINED, rad, -rad)<<FRACBITS, P_RandomRange(PR_UNDEFINED, rad, -rad)<<FRACBITS, 0, (mobjtype_t)locvar2);
}
}
@ -4224,7 +4223,7 @@ void A_SetSolidSteam(mobj_t *actor)
if (!(actor->flags2 & MF2_AMBUSH))
{
if (P_RandomChance(FRACUNIT/8))
if (P_RandomChance(PR_DECORATION, FRACUNIT/8))
{
if (actor->info->deathsound)
S_StartSound(actor, actor->info->deathsound); // Hiss!
@ -4336,7 +4335,7 @@ void A_JetChase(mobj_t *actor)
if (actor->reactiontime)
actor->reactiontime--;
if (P_RandomChance(FRACUNIT/32))
if (P_RandomChance(PR_UNDEFINED, FRACUNIT/32))
{
actor->momx = actor->momx / 2;
actor->momy = actor->momy / 2;
@ -4577,8 +4576,8 @@ void A_MinusDigging(mobj_t *actor)
INT32 rad = 32;
angle_t fa = (actor->angle >> ANGLETOFINESHIFT) & FINEMASK;
fixed_t dis = actor->info->speed*4;
fixed_t x = FINECOSINE(fa)*dis + actor->x + FRACUNIT*P_RandomRange(-rad, rad);
fixed_t y = FINESINE(fa)*dis + actor->y + FRACUNIT*P_RandomRange(-rad, rad);
fixed_t x = FINECOSINE(fa)*dis + actor->x + FRACUNIT*P_RandomRange(PR_UNDEFINED, -rad, rad);
fixed_t y = FINESINE(fa)*dis + actor->y + FRACUNIT*P_RandomRange(PR_UNDEFINED, -rad, rad);
fixed_t mz = (actor->eflags & MFE_VERTICALFLIP) ? actor->ceilingz : actor->floorz;
mobj_t *par;
@ -4771,7 +4770,7 @@ void A_JetgThink(mobj_t *actor)
if (actor->target)
{
if (P_RandomChance(FRACUNIT/8) && !actor->reactiontime)
if (P_RandomChance(PR_UNDEFINED, FRACUNIT/8) && !actor->reactiontime)
P_SetMobjState(actor, actor->info->missilestate);
else
A_JetChase (actor);
@ -4820,7 +4819,7 @@ void A_MouseThink(mobj_t *actor)
|| (actor->eflags & MFE_VERTICALFLIP && actor->z + actor->height == actor->ceilingz))
&& !actor->reactiontime)
{
if (P_RandomChance(FRACUNIT/2))
if (P_RandomChance(PR_UNDEFINED, FRACUNIT/2))
actor->angle += ANGLE_90;
else
actor->angle -= ANGLE_90;
@ -5227,7 +5226,7 @@ void A_RockSpawn(mobj_t *actor)
type = MT_ROCKCRUMBLE1 + (sides[line->sidenum[0]].rowoffset >> FRACBITS);
if (line->flags & ML_NOCLIMB)
randomoomph = P_RandomByte() * (FRACUNIT/32);
randomoomph = P_RandomByte(PR_DECORATION) * (FRACUNIT/32);
else
randomoomph = 0;
@ -5389,7 +5388,7 @@ void A_CrawlaCommanderThink(mobj_t *actor)
if (locvar1)
{
if (actor->health < 2 && P_RandomChance(FRACUNIT/128))
if (actor->health < 2 && P_RandomChance(PR_UNDEFINED, FRACUNIT/128))
P_SpawnMissile(actor, actor->target, locvar1);
}
@ -5404,8 +5403,8 @@ void A_CrawlaCommanderThink(mobj_t *actor)
actor->threshold = 0;
// Roam around, somewhat in the player's direction.
actor->angle += (P_RandomByte()<<10);
actor->angle -= (P_RandomByte()<<10);
actor->angle += (P_RandomByte(PR_UNDEFINED)<<10);
actor->angle -= (P_RandomByte(PR_UNDEFINED)<<10);
if (hovermode)
{
@ -5433,7 +5432,7 @@ void A_CrawlaCommanderThink(mobj_t *actor)
S_StartSound(actor, actor->info->attacksound);
}
}
actor->reactiontime = 3*TICRATE + (P_RandomByte()>>2);
actor->reactiontime = 3*TICRATE + (P_RandomByte(PR_UNDEFINED)>>2);
}
if (actor->health == 1)
@ -5454,8 +5453,8 @@ void A_CrawlaCommanderThink(mobj_t *actor)
}
else
{
UINT8 prandom = P_RandomByte();
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_RandomChance(FRACUNIT/2) ? -prandom : +prandom);
UINT8 prandom = P_RandomByte(PR_UNDEFINED);
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_RandomChance(PR_UNDEFINED, FRACUNIT/2) ? -prandom : +prandom);
P_InstaThrust(actor, actor->angle, FixedDiv(FixedMul(locvar2, actor->scale), 3*FRACUNIT/2));
actor->momz = FixedMul(locvar2, actor->scale); // Bounce up in air
}
@ -5775,7 +5774,7 @@ void A_MixUp(mobj_t *actor)
{
if (counter > 255) // fail-safe to avoid endless loop
break;
prandom = P_RandomByte();
prandom = P_RandomByte(PR_PLAYERSTARTS);
prandom %= numplayers; // I love modular arithmetic, don't you?
if (prandom) // Make sure it's not a useless mix
break;
@ -5893,7 +5892,7 @@ void A_Boss1Chase(mobj_t *actor)
{
if (actor->health > actor->info->damage)
{
if (P_RandomChance(FRACUNIT/2))
if (P_RandomChance(PR_UNDEFINED, FRACUNIT/2))
P_SetMobjState(actor, actor->info->missilestate);
else
P_SetMobjState(actor, actor->info->meleestate);
@ -5915,7 +5914,7 @@ void A_Boss1Chase(mobj_t *actor)
// ?
nomissile:
// possibly choose another target
if (multiplayer && P_RandomChance(FRACUNIT/128))
if (multiplayer && P_RandomChance(PR_UNDEFINED, FRACUNIT/128))
{
if (P_LookForPlayers(actor, true, false, 0))
return; // got a new target
@ -5953,7 +5952,7 @@ nomissile:
deltay = actor->target->y - actor->y;
actor->movedir = diags[((deltay < 0)<<1) + (deltax > 0)];
actor->movecount = P_RandomByte() & 15;
actor->movecount = P_RandomByte(PR_UNDEFINED) & 15;
}
}
@ -5978,13 +5977,13 @@ void A_Boss2Chase(mobj_t *actor)
// Startup randomness
if (actor->reactiontime <= -666)
actor->reactiontime = 2*TICRATE + P_RandomByte();
actor->reactiontime = 2*TICRATE + P_RandomByte(PR_UNDEFINED);
// When reactiontime hits zero, he will go the other way
if (--actor->reactiontime <= 0)
{
reverse = true;
actor->reactiontime = 2*TICRATE + P_RandomByte();
actor->reactiontime = 2*TICRATE + P_RandomByte(PR_UNDEFINED);
}
P_SetTarget(&actor->target, P_GetClosestAxis(actor));
@ -6071,12 +6070,12 @@ void A_Boss2Chase(mobj_t *actor)
if (actor->info->attacksound)
S_StartAttackSound(actor, actor->info->attacksound);
if (P_RandomChance(FRACUNIT/2))
if (P_RandomChance(PR_UNDEFINED, FRACUNIT/2))
{
goop->momx *= 2;
goop->momy *= 2;
}
else if (P_RandomChance(129*FRACUNIT/256))
else if (P_RandomChance(PR_UNDEFINED, 129*FRACUNIT/256))
{
goop->momx *= 3;
goop->momy *= 3;
@ -6210,8 +6209,8 @@ void A_Boss2PogoSFX(mobj_t *actor)
}
else
{
UINT8 prandom = P_RandomByte();
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_RandomChance(FRACUNIT/2) ? -prandom : +prandom);
UINT8 prandom = P_RandomByte(PR_UNDEFINED);
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_RandomChance(PR_UNDEFINED, FRACUNIT/2) ? -prandom : +prandom);
P_InstaThrust(actor, actor->angle, FixedMul(FixedMul(actor->info->speed,(locvar2)), actor->scale));
}
if (actor->info->activesound) S_StartSound(actor, actor->info->activesound);
@ -6249,10 +6248,10 @@ void A_Boss2PogoTarget(mobj_t *actor)
// Target hit, retreat!
if ((actor->target->player && actor->target->player->flashing > TICRATE) || actor->flags2 & MF2_FRET)
{
UINT8 prandom = P_RandomByte();
UINT8 prandom = P_RandomByte(PR_UNDEFINED);
actor->z++; // unstick from the floor
actor->momz = FixedMul(locvar1, actor->scale); // Bounce up in air
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_RandomChance(FRACUNIT/2) ? -prandom : +prandom); // Pick a direction, and randomize it.
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_RandomChance(PR_UNDEFINED, FRACUNIT/2) ? -prandom : +prandom); // Pick a direction, and randomize it.
P_InstaThrust(actor, actor->angle+ANGLE_180, FixedMul(FixedMul(actor->info->speed,(locvar2)), actor->scale)); // Move at wandering speed
}
// Try to land on top of the player.
@ -6289,10 +6288,10 @@ void A_Boss2PogoTarget(mobj_t *actor)
// Wander semi-randomly towards the player to get closer.
else
{
UINT8 prandom = P_RandomByte();
UINT8 prandom = P_RandomByte(PR_UNDEFINED);
actor->z++; // unstick from the floor
actor->momz = FixedMul(locvar1, actor->scale); // Bounce up in air
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_RandomChance(FRACUNIT/2) ? -prandom : +prandom); // Pick a direction, and randomize it.
actor->angle = R_PointToAngle2(actor->x, actor->y, actor->target->x, actor->target->y) + (P_RandomChance(PR_UNDEFINED, FRACUNIT/2) ? -prandom : +prandom); // Pick a direction, and randomize it.
P_InstaThrust(actor, actor->angle, FixedMul(FixedMul(actor->info->speed,(locvar2)), actor->scale)); // Move at wandering speed
}
// Boing!
@ -7100,7 +7099,7 @@ void A_SmokeTrailer(mobj_t *actor)
P_SetObjectMomZ(th, FRACUNIT, false);
th->destscale = actor->scale;
P_SetScale(th, actor->scale);
th->tics -= P_RandomByte() & 3;
th->tics -= P_RandomByte(PR_SMOLDERING) & 3;
if (th->tics < 1)
th->tics = 1;
}
@ -7198,7 +7197,7 @@ void A_ChangeAngleRelative(mobj_t *actor)
// rather than the ranges, so <0 and >360 work as possible values. -Red
INT32 locvar1 = var1;
INT32 locvar2 = var2;
//angle_t angle = (P_RandomByte()+1)<<24;
//angle_t angle = (P_RandomByte(PR_UNDEFINED)+1)<<24;
const fixed_t amin = locvar1*FRACUNIT;
const fixed_t amax = locvar2*FRACUNIT;
//const angle_t amin = FixedAngle(locvar1*FRACUNIT);
@ -7217,7 +7216,7 @@ void A_ChangeAngleRelative(mobj_t *actor)
if (angle > amax)
angle = amax;*/
actor->angle += FixedAngle(P_RandomRange(amin, amax));
actor->angle += FixedAngle(P_RandomRange(PR_RANDOMANIM, amin, amax));
}
// Function: A_ChangeAngleAbsolute
@ -7231,7 +7230,7 @@ void A_ChangeAngleAbsolute(mobj_t *actor)
{
INT32 locvar1 = var1;
INT32 locvar2 = var2;
//angle_t angle = (P_RandomByte()+1)<<24;
//angle_t angle = (P_RandomByte(PR_UNDEFINED)+1)<<24;
const fixed_t amin = locvar1*FRACUNIT;
const fixed_t amax = locvar2*FRACUNIT;
//const angle_t amin = FixedAngle(locvar1*FRACUNIT);
@ -7250,7 +7249,7 @@ void A_ChangeAngleAbsolute(mobj_t *actor)
if (angle > amax)
angle = amax;*/
actor->angle = FixedAngle(P_RandomRange(amin, amax));
actor->angle = FixedAngle(P_RandomRange(PR_RANDOMANIM, amin, amax));
}
// Function: A_RollAngle
@ -7299,7 +7298,7 @@ void A_ChangeRollAngleRelative(mobj_t *actor)
I_Error("A_ChangeRollAngleRelative: var1 is greater than var2");
#endif
actor->rollangle += FixedAngle(P_RandomRange(amin, amax));
actor->rollangle += FixedAngle(P_RandomRange(PR_RANDOMANIM, amin, amax));
}
// Function: A_ChangeRollAngleAbsolute
@ -7324,7 +7323,7 @@ void A_ChangeRollAngleAbsolute(mobj_t *actor)
I_Error("A_ChangeRollAngleAbsolute: var1 is greater than var2");
#endif
actor->rollangle = FixedAngle(P_RandomRange(amin, amax));
actor->rollangle = FixedAngle(P_RandomRange(PR_RANDOMANIM, amin, amax));
}
// Function: A_PlaySound
@ -7514,7 +7513,7 @@ void A_SetRandomTics(mobj_t *actor)
if (LUA_CallAction(A_SETRANDOMTICS, actor))
return;
actor->tics = P_RandomRange(locvar1, locvar2);
actor->tics = P_RandomRange(PR_RANDOMANIM, locvar1, locvar2);
}
// Function: A_ChangeColorRelative
@ -7959,7 +7958,7 @@ void A_RandomState(mobj_t *actor)
if (LUA_CallAction(A_RANDOMSTATE, actor))
return;
P_SetMobjState(actor, P_RandomChance(FRACUNIT/2) ? locvar1 : locvar2);
P_SetMobjState(actor, P_RandomChance(PR_RANDOMANIM, FRACUNIT/2) ? locvar1 : locvar2);
}
// Function: A_RandomStateRange
@ -7977,7 +7976,7 @@ void A_RandomStateRange(mobj_t *actor)
if (LUA_CallAction(A_RANDOMSTATERANGE, actor))
return;
P_SetMobjState(actor, P_RandomRange(locvar1, locvar2));
P_SetMobjState(actor, P_RandomRange(PR_RANDOMANIM, locvar1, locvar2));
}
// Function: A_StateRangeByAngle
@ -8549,8 +8548,8 @@ void A_MultiShot(mobj_t *actor)
z = actor->z + actor->height - FixedMul(48*FRACUNIT + locvar2*FRACUNIT, actor->scale);
else
z = actor->z + FixedMul(48*FRACUNIT + locvar2*FRACUNIT, actor->scale);
xr = FixedMul((P_SignedRandom()/3)<<FRACBITS, actor->scale); // please note p_mobj.c's P_Rand() abuse
yr = FixedMul((P_SignedRandom()/3)<<FRACBITS, actor->scale); // of rand(), RAND_MAX and signness mess
xr = FixedMul((P_SignedRandom(PR_UNDEFINED)/3)<<FRACBITS, actor->scale); // please note p_mobj.c's P_Rand() abuse
yr = FixedMul((P_SignedRandom(PR_UNDEFINED)/3)<<FRACBITS, actor->scale); // of rand(), RAND_MAX and signness mess
while(count <= loc1lw && loc1lw >= 1)
{
@ -8731,7 +8730,7 @@ void A_CheckRandom(mobj_t *actor)
chance *= (locvar1 >> 16);
chance /= (locvar1 & 0xFFFF);
if (P_RandomChance(chance))
if (P_RandomChance(PR_RANDOMANIM, chance))
P_SetMobjState(actor, locvar2);
}
@ -10031,7 +10030,7 @@ void A_BrakChase(mobj_t *actor)
{
// Check if we should use "melee" attack first. (Yes, this still runs outside of melee range. Quiet, you.)
if (actor->info->meleestate
&& actor->health <= P_RandomRange(actor->info->spawnhealth/4, (actor->info->spawnhealth * 3)/4)) // Guaranteed true if <= 1/4 health, guaranteed false if > 3/4 health
&& actor->health <= P_RandomRange(PR_UNDEFINED, actor->info->spawnhealth/4, (actor->info->spawnhealth * 3)/4)) // Guaranteed true if <= 1/4 health, guaranteed false if > 3/4 health
{
if (actor->info->attacksound)
S_StartAttackSound(actor, actor->info->attacksound);
@ -10063,7 +10062,7 @@ void A_BrakChase(mobj_t *actor)
S_StartSound(actor, (sfxenum_t)locvar2);
// make active sound
if (actor->info->activesound && P_RandomChance(3*FRACUNIT/256))
if (actor->info->activesound && P_RandomChance(PR_UNDEFINED, 3*FRACUNIT/256))
{
S_StartSound(actor, actor->info->activesound);
}
@ -10331,7 +10330,7 @@ mobj_t *P_InternalFlickySpawn(mobj_t *actor, mobjtype_t flickytype, fixed_t momz
return NULL;
else
{
INT32 prandom = P_RandomKey(mapheaderinfo[gamemap-1]->numFlickies);
INT32 prandom = P_RandomKey(PR_UNDEFINED, mapheaderinfo[gamemap-1]->numFlickies);
flickytype = mapheaderinfo[gamemap-1]->flickies[prandom];
}
}
@ -10353,8 +10352,8 @@ mobj_t *P_InternalFlickySpawn(mobj_t *actor, mobjtype_t flickytype, fixed_t momz
momz = FixedDiv(momz, FixedSqrt(3*FRACUNIT));
P_SetObjectMomZ(flicky, momz, false);
flicky->movedir = (P_RandomChance(FRACUNIT/2) ? -1 : 1);
flicky->fuse = P_RandomRange(595, 700); // originally 300, 350
flicky->movedir = (P_RandomChance(PR_UNDEFINED, FRACUNIT/2) ? -1 : 1);
flicky->fuse = P_RandomRange(PR_UNDEFINED, 595, 700); // originally 300, 350
flicky->threshold = 0;
if (lookforplayers)
@ -10417,7 +10416,7 @@ void P_InternalFlickySetColor(mobj_t *actor, UINT8 extrainfo)
if (extrainfo == 0)
// until we can customize flicky colors by level header, just stick to SRB2's defaults
actor->color = flickycolors[P_RandomKey(2)]; //flickycolors[P_RandomKey(sizeof(flickycolors))];
actor->color = flickycolors[P_RandomKey(PR_UNDEFINED, 2)]; //flickycolors[P_RandomKey(sizeof(flickycolors))];
else
actor->color = flickycolors[min(extrainfo-1, 14)]; // sizeof(flickycolors)-1
}
@ -10494,7 +10493,7 @@ void A_FlickyCenter(mobj_t *actor)
else if (actor->flags & MF_SLIDEME) // aimless
{
actor->tracer->fuse = 0; // less than 2*TICRATE means move aimlessly.
P_InitAngle(actor->tracer, P_RandomKey(180)*ANG2);
P_InitAngle(actor->tracer, P_RandomKey(PR_UNDEFINED, 180)*ANG2);
}
else //orbit
actor->tracer->fuse = FRACUNIT;
@ -10586,7 +10585,7 @@ void A_FlickyAim(mobj_t *actor)
if (!actor->target)
{
P_LookForPlayers(actor, true, false, 0);
actor->angle = P_RandomKey(36)*ANG10;
actor->angle = P_RandomKey(PR_UNDEFINED, 36)*ANG10;
return;
}
@ -10610,9 +10609,9 @@ void A_FlickyAim(mobj_t *actor)
else if (flickyhitwall)
{
if (actor->target && P_IsFlickyCenter(actor->target->type))
actor->angle = R_PointToAngle2(actor->target->x, actor->target->y, actor->x, actor->y) + P_RandomRange(112, 248) * ANG1;
actor->angle = R_PointToAngle2(actor->target->x, actor->target->y, actor->x, actor->y) + P_RandomRange(PR_UNDEFINED, 112, 248) * ANG1;
else
actor->angle += P_RandomRange(112, 248)*ANG1;
actor->angle += P_RandomRange(PR_UNDEFINED, 112, 248)*ANG1;
actor->threshold = 0;
}
}
@ -10784,9 +10783,9 @@ void A_FlickyFlounder(mobj_t *actor)
if (LUA_CallAction(A_FLICKYFLOUNDER, actor))
return;
locvar1 *= (P_RandomKey(2) + 1);
locvar2 *= (P_RandomKey(2) + 1);
hopangle = (actor->angle + (P_RandomKey(9) - 4)*ANG2);
locvar1 *= (P_RandomKey(PR_UNDEFINED, 2) + 1);
locvar2 *= (P_RandomKey(PR_UNDEFINED, 2) + 1);
hopangle = (actor->angle + (P_RandomKey(PR_UNDEFINED, 9) - 4)*ANG2);
P_InternalFlickyHop(actor, locvar1, locvar2, hopangle);
}
@ -10915,9 +10914,9 @@ void A_FlameParticle(mobj_t *actor)
rad = actor->radius>>FRACBITS;
hei = actor->height>>FRACBITS;
particle = P_SpawnMobjFromMobj(actor,
P_RandomRange(rad, -rad)<<FRACBITS,
P_RandomRange(rad, -rad)<<FRACBITS,
P_RandomRange(hei/2, hei)<<FRACBITS,
P_RandomRange(PR_DECORATION, rad, -rad)<<FRACBITS,
P_RandomRange(PR_DECORATION, rad, -rad)<<FRACBITS,
P_RandomRange(PR_DECORATION, hei/2, hei)<<FRACBITS,
type);
P_SetObjectMomZ(particle, 2<<FRACBITS, false);
}
@ -11051,20 +11050,20 @@ void A_LightBeamReset(mobj_t *actor)
if (LUA_CallAction(A_LIGHTBEAMRESET, actor))
return;
actor->destscale = FRACUNIT + P_SignedRandom()*FRACUNIT/256;
actor->destscale = FRACUNIT + P_SignedRandom(PR_DECORATION)*FRACUNIT/256;
P_SetScale(actor, actor->destscale);
if (!actor->spawnpoint)
return; // this can't work properly welp
actor->momx = -(P_SignedRandom()*FINESINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/128;
actor->momy = (P_SignedRandom()*FINECOSINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/128;
actor->momz = (P_SignedRandom()*FRACUNIT)/128;
actor->momx = -(P_SignedRandom(PR_DECORATION)*FINESINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/128;
actor->momy = (P_SignedRandom(PR_DECORATION)*FINECOSINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/128;
actor->momz = (P_SignedRandom(PR_DECORATION)*FRACUNIT)/128;
P_SetOrigin(actor,
actor->spawnpoint->x*FRACUNIT - (P_SignedRandom()*FINESINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/2,
actor->spawnpoint->y*FRACUNIT + (P_SignedRandom()*FINECOSINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/2,
actor->spawnpoint->z*FRACUNIT + (P_SignedRandom()*FRACUNIT)/2);
actor->spawnpoint->x*FRACUNIT - (P_SignedRandom(PR_DECORATION)*FINESINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/2,
actor->spawnpoint->y*FRACUNIT + (P_SignedRandom(PR_DECORATION)*FINECOSINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/2,
actor->spawnpoint->z*FRACUNIT + (P_SignedRandom(PR_DECORATION)*FRACUNIT)/2);
}
// Function: A_MineExplode
@ -11103,9 +11102,9 @@ void A_MineExplode(mobj_t *actor)
P_SpawnMobj(actor->x, actor->y, actor->z, type);
for (i = 0; i < 16; i++)
{
mobj_t *b = P_SpawnMobj(actor->x+P_RandomRange(-dist, dist)*FRACUNIT,
actor->y+P_RandomRange(-dist, dist)*FRACUNIT,
actor->z+P_RandomRange(((actor->eflags & MFE_UNDERWATER) ? -dist : 0), dist)*FRACUNIT,
mobj_t *b = P_SpawnMobj(actor->x+P_RandomRange(PR_EXPLOSION, -dist, dist)*FRACUNIT,
actor->y+P_RandomRange(PR_EXPLOSION, -dist, dist)*FRACUNIT,
actor->z+P_RandomRange(PR_EXPLOSION, ((actor->eflags & MFE_UNDERWATER) ? -dist : 0), dist)*FRACUNIT,
type);
fixed_t dx = b->x - actor->x, dy = b->y - actor->y, dz = b->z - actor->z;
fixed_t dm = P_AproxDistance(dz, P_AproxDistance(dy, dx));
@ -11592,7 +11591,7 @@ void A_Boss5FindWaypoint(mobj_t *actor)
goto nowaypoints; // ???
}
key = P_RandomKey(numfangwaypoints);
key = P_RandomKey(PR_UNDEFINED, numfangwaypoints);
P_SetTarget(&actor->tracer, fangwaypoints[key]);
if (actor->tracer->type == MT_FANGWAYPOINT)
@ -11766,7 +11765,7 @@ void A_Boss5ExtraRepeat(mobj_t *actor)
calc = (locvar1*(locspawn - lochealth))/locspawn;
if (calc > 2)
actor->extravalue2 = 1 + calc/2 + P_RandomKey(calc/2);
actor->extravalue2 = 1 + calc/2 + P_RandomKey(PR_UNDEFINED, calc/2);
else
actor->extravalue2 = 1 + calc;
@ -11976,7 +11975,7 @@ void A_Boss5MakeJunk(mobj_t *actor)
return;
}
ang = FixedAngle((P_RandomKey(36)*10)<<FRACBITS);
ang = FixedAngle((P_RandomKey(PR_UNDEFINED, 36)*10)<<FRACBITS);
while (i--)
{
broked = P_SpawnMobjFromMobj(actor, 0, 0, FRACUNIT, MT_BROKENROBOT);
@ -11986,7 +11985,7 @@ void A_Boss5MakeJunk(mobj_t *actor)
broked->fuse = (((locvar2 & 1) ? 4 : 2)*TICRATE)/3;
P_InitAngle(broked, ang);
P_InstaThrust(broked, ang, ((locvar2 & 2) ? 8 : 5)*actor->scale);
P_SetObjectMomZ(broked, (((locvar2) ? 4 : 0) + P_RandomRange(2, 5))<<FRACBITS, false);
P_SetObjectMomZ(broked, (((locvar2) ? 4 : 0) + P_RandomRange(PR_UNDEFINED, 2, 5))<<FRACBITS, false);
if (locvar1 > 0)
P_SetMobjState(broked, locvar1);
if (!P_MobjWasRemoved(broked))
@ -12065,10 +12064,10 @@ static void P_DustRing(mobjtype_t mobjtype, UINT32 div, fixed_t x, fixed_t y, fi
P_InitAngle(dust, ang*i + ANGLE_90);
P_SetScale(dust, FixedMul(initscale, scale));
dust->destscale = FixedMul(4*FRACUNIT + P_RandomFixed(), scale);
dust->destscale = FixedMul(4*FRACUNIT + P_RandomFixed(PR_UNDEFINED), scale);
dust->scalespeed = scale/24;
P_Thrust(dust, ang*i, speed + FixedMul(P_RandomFixed(), scale));
dust->momz = P_SignedRandom()*scale/64;
P_Thrust(dust, ang*i, speed + FixedMul(P_RandomFixed(PR_UNDEFINED), scale));
dust->momz = P_SignedRandom(PR_UNDEFINED)*scale/64;
}
}
@ -12255,7 +12254,7 @@ void A_DebrisRandom(mobj_t *actor)
if (LUA_CallAction(A_DEBRISRANDOM, actor))
return;
actor->frame |= P_RandomRange(0, locvar1);
actor->frame |= P_RandomRange(PR_UNDEFINED, 0, locvar1);
var1 = 0;
var2 = 359;
A_ChangeAngleAbsolute(actor);
@ -12574,7 +12573,7 @@ void A_SnapperThinker(mobj_t *actor)
if (actor->reactiontime < 4)
{
mobj_t *dust = P_SpawnMobj(x0, y0, actor->z, MT_SPINDUST);
P_Thrust(dust, ang + ANGLE_180 + FixedAngle(P_RandomRange(-20, 20)*FRACUNIT), speed*FRACUNIT);
P_Thrust(dust, ang + ANGLE_180 + FixedAngle(P_RandomRange(PR_UNDEFINED, -20, 20)*FRACUNIT), speed*FRACUNIT);
}
if (actor->extravalue2 == 0)
@ -12673,7 +12672,7 @@ void A_MinecartSparkThink(mobj_t *actor)
return;
if (actor->momz == 0 && P_IsObjectOnGround(actor))
actor->momz = P_RandomRange(2, 4)*FRACUNIT;
actor->momz = P_RandomRange(PR_UNDEFINED, 2, 4)*FRACUNIT;
dz = actor->momz;
dm = FixedHypot(FixedHypot(dx, dy), dz);
@ -12733,8 +12732,8 @@ void A_LavafallRocks(mobj_t *actor)
if (i < MAXPLAYERS)
{
angle_t fa = (FixedAngle(P_RandomKey(360) << FRACBITS) >> ANGLETOFINESHIFT) & FINEMASK;
fixed_t offset = P_RandomRange(4, 12) << FRACBITS;
angle_t fa = (FixedAngle(P_RandomKey(PR_UNDEFINED, 360) << FRACBITS) >> ANGLETOFINESHIFT) & FINEMASK;
fixed_t offset = P_RandomRange(PR_UNDEFINED, 4, 12) << FRACBITS;
fixed_t xoffs = FixedMul(FINECOSINE(fa), actor->radius + offset);
fixed_t yoffs = FixedMul(FINESINE(fa), actor->radius + offset);
P_SpawnMobjFromMobj(actor, xoffs, yoffs, 0, MT_LAVAFALLROCK);
@ -13185,132 +13184,6 @@ void A_ItemPop(mobj_t *actor)
}
}
void A_JawzChase(mobj_t *actor)
{
player_t *player;
fixed_t thrustamount = 0;
fixed_t frictionsafety = (actor->friction == 0) ? 1 : actor->friction;
fixed_t topspeed = actor->movefactor;
if (LUA_CallAction(A_JAWZCHASE, actor))
return;
if (actor->tracer)
{
/*if ((gametyperules & GTR_CIRCUIT)) // Stop looking after first target in race
actor->extravalue1 = 1;*/
if (actor->tracer->health)
{
const angle_t targetangle = R_PointToAngle2(actor->x, actor->y, actor->tracer->x, actor->tracer->y);
mobj_t *ret;
angle_t angledelta = actor->angle - targetangle;
boolean turnclockwise = true;
if (gametyperules & GTR_CIRCUIT)
{
const fixed_t distbarrier = FixedMul(512*mapobjectscale, FRACUNIT + ((gamespeed-1) * (FRACUNIT/4)));
const fixed_t distaway = P_AproxDistance(actor->tracer->x - actor->x, actor->tracer->y - actor->y);
if (distaway < distbarrier)
{
if (actor->tracer->player)
{
fixed_t speeddifference = abs(topspeed - min(actor->tracer->player->speed, K_GetKartSpeed(actor->tracer->player, false, false)));
topspeed = topspeed - FixedMul(speeddifference, FRACUNIT-FixedDiv(distaway, distbarrier));
}
}
}
if (angledelta != 0)
{
angle_t MAX_JAWZ_TURN = ANGLE_90/15; // We can turn a maximum of 6 degrees per frame at regular max speed
// MAX_JAWZ_TURN gets stronger the slower the top speed of jawz
if (topspeed < actor->movefactor)
{
if (topspeed == 0)
{
MAX_JAWZ_TURN = ANGLE_180;
}
else
{
fixed_t anglemultiplier = FixedDiv(actor->movefactor, topspeed);
MAX_JAWZ_TURN += FixedAngle(FixedMul(AngleFixed(MAX_JAWZ_TURN), anglemultiplier));
}
}
if (angledelta > ANGLE_180)
{
angledelta = InvAngle(angledelta);
turnclockwise = false;
}
if (angledelta > MAX_JAWZ_TURN)
{
angledelta = MAX_JAWZ_TURN;
}
if (turnclockwise)
{
actor->angle -= angledelta;
}
else
{
actor->angle += angledelta;
}
}
ret = P_SpawnMobj(actor->tracer->x, actor->tracer->y, actor->tracer->z, MT_PLAYERRETICULE);
ret->old_x = actor->tracer->old_x;
ret->old_y = actor->tracer->old_y;
ret->old_z = actor->tracer->old_z;
P_SetTarget(&ret->target, actor->tracer);
ret->frame |= ((leveltime % 10) / 2) + 5;
ret->color = actor->cvmem;
}
else
P_SetTarget(&actor->tracer, NULL);
}
if (!actor->tracer)
{
actor->angle = K_MomentumAngle(actor);
}
if (P_IsObjectOnGround(actor))
{
const fixed_t currentspeed = R_PointToDist2(0, 0, actor->momx, actor->momy);
if (currentspeed >= topspeed)
{
// Thrust as if you were at top speed, slow down naturally
thrustamount = FixedDiv(topspeed, frictionsafety) - topspeed;
}
else
{
const fixed_t beatfriction = FixedDiv(currentspeed, frictionsafety) - currentspeed;
// Thrust to immediately get to top speed
thrustamount = beatfriction + FixedDiv(topspeed - currentspeed, frictionsafety);
}
P_Thrust(actor, actor->angle, thrustamount);
}
if ((actor->tracer != NULL) && (actor->tracer->health > 0))
return;
if (actor->extravalue1) // Disable looking by setting this
return;
if (!actor->target || P_MobjWasRemoved(actor->target)) // No source!
return;
player = K_FindJawzTarget(actor, actor->target->player);
if (player)
P_SetTarget(&actor->tracer, player->mo);
return;
}
void A_JawzExplode(mobj_t *actor)
{
INT32 shrapnel = 2;
@ -13327,17 +13200,17 @@ void A_JawzExplode(mobj_t *actor)
{
INT32 speed, speed2;
truc = P_SpawnMobj(actor->x + P_RandomRange(-8, 8)*FRACUNIT, actor->y + P_RandomRange(-8, 8)*FRACUNIT,
actor->z + P_RandomRange(0, 8)*FRACUNIT, MT_BOOMPARTICLE);
truc = P_SpawnMobj(actor->x + P_RandomRange(PR_EXPLOSION, -8, 8)*FRACUNIT, actor->y + P_RandomRange(PR_EXPLOSION, -8, 8)*FRACUNIT,
actor->z + P_RandomRange(PR_EXPLOSION, 0, 8)*FRACUNIT, MT_BOOMPARTICLE);
truc->scale = actor->scale*2;
speed = FixedMul(7*FRACUNIT, actor->scale)>>FRACBITS;
truc->momx = P_RandomRange(-speed, speed)*FRACUNIT;
truc->momy = P_RandomRange(-speed, speed)*FRACUNIT;
truc->momx = P_RandomRange(PR_EXPLOSION, -speed, speed)*FRACUNIT;
truc->momy = P_RandomRange(PR_EXPLOSION, -speed, speed)*FRACUNIT;
speed = FixedMul(5*FRACUNIT, actor->scale)>>FRACBITS;
speed2 = FixedMul(15*FRACUNIT, actor->scale)>>FRACBITS;
truc->momz = P_RandomRange(speed, speed2)*FRACUNIT;
truc->momz = P_RandomRange(PR_EXPLOSION, speed, speed2)*FRACUNIT;
truc->tics = TICRATE*2;
truc->color = SKINCOLOR_KETCHUP;
@ -13417,8 +13290,8 @@ void A_LandMineExplode(mobj_t *actor)
//K_MatchGenericExtraFlags(expl, actor);
P_SetScale(expl, actor->scale*4);
expl->momx = P_RandomRange(-3, 3)*actor->scale/2;
expl->momy = P_RandomRange(-3, 3)*actor->scale/2;
expl->momx = P_RandomRange(PR_EXPLOSION, -3, 3)*actor->scale/2;
expl->momy = P_RandomRange(PR_EXPLOSION, -3, 3)*actor->scale/2;
// 100/45 = 2.22 fu/t
expl->momz = ((i+1)*actor->scale*5/2)*P_MobjFlip(expl);
@ -13502,11 +13375,11 @@ void A_FZBoomSmoke(mobj_t *actor)
for (i = 0; i < 8+(4*var1); i++)
{
mobj_t *smoke = P_SpawnMobj(actor->x + (P_RandomRange(-rad, rad)*actor->scale), actor->y + (P_RandomRange(-rad, rad)*actor->scale),
actor->z + (P_RandomRange(0, 72)*actor->scale), MT_THOK);
mobj_t *smoke = P_SpawnMobj(actor->x + (P_RandomRange(PR_SMOLDERING, -rad, rad)*actor->scale), actor->y + (P_RandomRange(PR_SMOLDERING, -rad, rad)*actor->scale),
actor->z + (P_RandomRange(PR_SMOLDERING, 0, 72)*actor->scale), MT_THOK);
P_SetMobjState(smoke, S_FZEROSMOKE1);
smoke->tics += P_RandomRange(-3, 4);
smoke->tics += P_RandomRange(PR_SMOLDERING, -3, 4);
smoke->scale = actor->scale*3;
}
return;
@ -13526,7 +13399,7 @@ void A_RandomShadowFrame(mobj_t *actor)
{
fake = P_SpawnMobj(actor->x, actor->y, actor->z, MT_THOK);
fake->sprite = SPR_ENM1;
fake->frame = P_RandomRange(0, 6);
fake->frame = P_RandomRange(PR_DECORATION, 0, 6);
P_SetScale(fake, FRACUNIT*3/2);
fake->scale = FRACUNIT*3/2;
fake->destscale = FRACUNIT*3/2;
@ -13629,7 +13502,7 @@ void A_MayonakaArrow(mobj_t *actor)
iswarning = actor->spawnpoint->options & MTF_OBJECTSPECIAL; // is our object a warning sign?
// "animtimer" is replaced by "extravalue1" here.
actor->extravalue1 = ((actor->extravalue1) ? (actor->extravalue1+1) : (P_RandomRange(0, (iswarning) ? (TICRATE/2) : TICRATE*3)));
actor->extravalue1 = ((actor->extravalue1) ? (actor->extravalue1+1) : (P_RandomRange(PR_DECORATION, 0, (iswarning) ? (TICRATE/2) : TICRATE*3)));
flip = ((actor->spawnpoint->options & 1) ? (3) : (0)); // flip adds 3 frames, which is the flipped version of the sign.
// special warning behavior:
if (iswarning)
@ -13669,7 +13542,7 @@ void A_MementosTPParticles(mobj_t *actor)
for (; i<4; i++)
{
particle = P_SpawnMobj(actor->x + (P_RandomRange(-256, 256)<<FRACBITS), actor->y + (P_RandomRange(-256, 256)<<FRACBITS), actor->z + (P_RandomRange(48, 256)<<FRACBITS), MT_MEMENTOSPARTICLE);
particle = P_SpawnMobj(actor->x + (P_RandomRange(PR_DECORATION, -256, 256)<<FRACBITS), actor->y + (P_RandomRange(PR_DECORATION, -256, 256)<<FRACBITS), actor->z + (P_RandomRange(PR_DECORATION, 48, 256)<<FRACBITS), MT_MEMENTOSPARTICLE);
particle->frame = 0;
particle->color = ((i%2) ? (SKINCOLOR_RED) : (SKINCOLOR_BLACK));
particle->destscale = 1;
@ -13732,7 +13605,7 @@ void A_ReaperThinker(mobj_t *actor)
// Spawn particles as we grow out of the floor, ゴ ゴ ゴ ゴ
for (; i<16; i++)
{
particle = P_SpawnMobj(actor->x + (P_RandomRange(-60, 60)<<FRACBITS), actor->y + (P_RandomRange(-60, 60)<<FRACBITS), actor->z, MT_THOK);
particle = P_SpawnMobj(actor->x + (P_RandomRange(PR_DECORATION, -60, 60)<<FRACBITS), actor->y + (P_RandomRange(PR_DECORATION, -60, 60)<<FRACBITS), actor->z, MT_THOK);
particle->momz = 20<<FRACBITS;
particle->color = ((i%2 !=0) ? (SKINCOLOR_RED) : (SKINCOLOR_BLACK));
particle->frame = 0;
@ -14008,9 +13881,9 @@ A_SpawnItemDebrisCloud (mobj_t *actor)
mobj_t *puff = P_SpawnMobjFromMobj(
target,
P_RandomRange(-spacing, spacing) * FRACUNIT,
P_RandomRange(-spacing, spacing) * FRACUNIT,
P_RandomRange(0, 4 * spacing) * FRACUNIT,
P_RandomRange(PR_ITEM_DEBRIS, -spacing, spacing) * FRACUNIT,
P_RandomRange(PR_ITEM_DEBRIS, -spacing, spacing) * FRACUNIT,
P_RandomRange(PR_ITEM_DEBRIS, 0, 4 * spacing) * FRACUNIT,
MT_SPINDASHDUST
);

View file

@ -2202,7 +2202,7 @@ void EV_CrumbleChain(sector_t *sec, ffloor_t *rover)
for (c = topz; c > bottomz; c -= spacing)
{
spawned = P_SpawnMobj(a, b, c, type);
spawned->angle += P_RandomKey(36)*ANG10; // irrelevant for default objects but might make sense for some custom ones
spawned->angle += P_RandomKey(PR_TERRAIN, 36)*ANG10; // irrelevant for default objects but might make sense for some custom ones
if (flags & ML_EFFECT1)
{

View file

@ -416,8 +416,8 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
firework->momx = toucher->momx;
firework->momy = toucher->momy;
firework->momz = toucher->momz;
P_Thrust(firework, FixedAngle((72*i)<<FRACBITS), P_RandomRange(1,8)*special->scale);
P_SetObjectMomZ(firework, P_RandomRange(1,8)*special->scale, false);
P_Thrust(firework, FixedAngle((72*i)<<FRACBITS), P_RandomRange(PR_ITEM_DEBRIS, 1,8)*special->scale);
P_SetObjectMomZ(firework, P_RandomRange(PR_ITEM_DEBRIS, 1,8)*special->scale, false);
firework->color = toucher->color;
}
@ -536,7 +536,7 @@ void P_TouchSpecialThing(mobj_t *special, mobj_t *toucher, boolean heightcheck)
special->momz = 0;
special->flags |= MF_NOGRAVITY;
P_SetMobjState (special, special->info->deathstate);
S_StartSound (special, special->info->deathsound+(P_RandomKey(special->info->mass)));
S_StartSound (special, special->info->deathsound+(P_RandomKey(PR_DECORATION, special->info->mass)));
}
return;
@ -916,7 +916,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
// SRB2kart
if (target->type != MT_PLAYER && !(target->flags & MF_MONITOR)
&& !(target->type == MT_ORBINAUT || target->type == MT_ORBINAUT_SHIELD
|| target->type == MT_JAWZ || target->type == MT_JAWZ_DUD || target->type == MT_JAWZ_SHIELD
|| target->type == MT_JAWZ || target->type == MT_JAWZ_SHIELD
|| target->type == MT_BANANA || target->type == MT_BANANA_SHIELD
|| target->type == MT_DROPTARGET || target->type == MT_DROPTARGET_SHIELD
|| target->type == MT_EGGMANITEM || target->type == MT_EGGMANITEM_SHIELD
@ -1181,7 +1181,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
mo->destscale = mo->scale/8;
mo->scalespeed = (mo->scale - mo->destscale)/(2*TICRATE);
mo->momz = mo->info->speed;
mo->angle = FixedAngle((P_RandomKey(36)*10)<<FRACBITS);
mo->angle = FixedAngle((P_RandomKey(PR_UNDEFINED, 36)*10)<<FRACBITS);
mo2 = P_SpawnMobjFromMobj(mo, 0, 0, 0, MT_BOSSJUNK);
P_InitAngle(mo2, mo->angle);
@ -1270,7 +1270,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
{
flingAngle = target->angle + ANGLE_180;
if (P_RandomByte() & 1)
if (P_RandomByte(PR_ITEM_RINGS) & 1)
{
flingAngle -= ANGLE_45;
}
@ -1313,7 +1313,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
UINT8 i;
mobj_t *attacker = inflictor ? inflictor : source;
mobj_t *part = target->hnext;
angle_t angle = FixedAngle(360*P_RandomFixed());
angle_t angle = FixedAngle(360*P_RandomFixed(PR_ITEM_DEBRIS));
INT16 spacing = (target->radius >> 1) / target->scale;
// set respawn fuse
@ -1338,9 +1338,9 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
{
mobj_t *puff = P_SpawnMobjFromMobj(
target,
P_RandomRange(-spacing, spacing) * FRACUNIT,
P_RandomRange(-spacing, spacing) * FRACUNIT,
P_RandomRange(0, 4*spacing) * FRACUNIT,
P_RandomRange(PR_ITEM_DEBRIS, -spacing, spacing) * FRACUNIT,
P_RandomRange(PR_ITEM_DEBRIS, -spacing, spacing) * FRACUNIT,
P_RandomRange(PR_ITEM_DEBRIS, 0, 4*spacing) * FRACUNIT,
MT_SPINDASHDUST
);
@ -1497,7 +1497,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
break;
}
if ((target->type == MT_JAWZ || target->type == MT_JAWZ_DUD || target->type == MT_JAWZ_SHIELD) && !(target->flags2 & MF2_AMBUSH))
if ((target->type == MT_JAWZ || target->type == MT_JAWZ_SHIELD) && !(target->flags2 & MF2_AMBUSH))
{
target->z += P_MobjFlip(target)*20*target->scale;
}
@ -1620,7 +1620,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
if (target->info->xdeathstate != S_NULL)
{
sprflip = P_RandomChance(FRACUNIT/2);
sprflip = P_RandomChance(PR_DECORATION, FRACUNIT/2);
#define makechunk(angtweak, xmov, ymov) \
chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_WALLSPIKE);\
@ -1633,7 +1633,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
chunk->y += ymov - forwardyoffs;\
P_SetThingPosition(chunk);\
P_InstaThrust(chunk, angtweak, 4*scale);\
chunk->momz = P_RandomRange(5, 7)*scale;\
chunk->momz = P_RandomRange(PR_DECORATION, 5, 7)*scale;\
if (flip)\
chunk->momz *= -1;\
if (sprflip)\
@ -1646,7 +1646,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
#undef makechunk
}
sprflip = P_RandomChance(FRACUNIT/2);
sprflip = P_RandomChance(PR_DECORATION, FRACUNIT/2);
chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_WALLSPIKE);
@ -1659,7 +1659,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
chunk->y += forwardyoffs - yoffs;
P_SetThingPosition(chunk);
P_InstaThrust(chunk, ang + ANGLE_180, 2*scale);
chunk->momz = P_RandomRange(5, 7)*scale;
chunk->momz = P_RandomRange(PR_DECORATION, 5, 7)*scale;
if (flip)
chunk->momz *= -1;
if (sprflip)
@ -1673,7 +1673,7 @@ void P_KillMobj(mobj_t *target, mobj_t *inflictor, mobj_t *source, UINT8 damaget
target->y += forwardyoffs + yoffs;
P_SetThingPosition(target);
P_InstaThrust(target, ang, 2*scale);
target->momz = P_RandomRange(5, 7)*scale;
target->momz = P_RandomRange(PR_DECORATION, 5, 7)*scale;
if (flip)
target->momz *= -1;
if (!sprflip)
@ -2221,7 +2221,7 @@ void P_PlayerRingBurst(player_t *player, INT32 num_rings)
num_fling_rings = num_rings+min(0, player->rings);
// determine first angle
fa = player->mo->angle + ((P_RandomByte() & 1) ? -ANGLE_90 : ANGLE_90);
fa = player->mo->angle + ((P_RandomByte(PR_ITEM_RINGS) & 1) ? -ANGLE_90 : ANGLE_90);
for (i = 0; i < num_fling_rings; i++)
{

View file

@ -51,7 +51,7 @@ void T_FireFlicker(fireflicker_t *flick)
if (--flick->count)
return;
amount = (INT16)((UINT8)(P_RandomByte() & 3) * 16);
amount = (INT16)((UINT8)(P_RandomByte(PR_UNDEFINED) & 3) * 16);
if (flick->sector->lightlevel - amount < flick->minlight)
flick->sector->lightlevel = (INT16)flick->minlight;
@ -235,7 +235,7 @@ strobe_t *P_SpawnAdjustableStrobeFlash(sector_t *minsector, sector_t *maxsector,
flash->minlight = 0;
if (!inSync)
flash->count = (P_RandomByte() & 7) + 1;
flash->count = (P_RandomByte(PR_UNDEFINED) & 7) + 1;
else
flash->count = 1;

View file

@ -863,7 +863,7 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
// Bubble Shield reflect
if (((thing->type == MT_BUBBLESHIELD && thing->target->player && thing->target->player->bubbleblowup)
|| (thing->player && thing->player->bubbleblowup))
&& (tmthing->type == MT_ORBINAUT || tmthing->type == MT_JAWZ || tmthing->type == MT_JAWZ_DUD
&& (tmthing->type == MT_ORBINAUT || tmthing->type == MT_JAWZ
|| tmthing->type == MT_BANANA || tmthing->type == MT_EGGMANITEM || tmthing->type == MT_BALLHOG
|| tmthing->type == MT_SSMINE || tmthing->type == MT_LANDMINE || tmthing->type == MT_SINK
|| (tmthing->type == MT_PLAYER && thing->target != tmthing)))
@ -878,7 +878,7 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
}
else if (((tmthing->type == MT_BUBBLESHIELD && tmthing->target->player && tmthing->target->player->bubbleblowup)
|| (tmthing->player && tmthing->player->bubbleblowup))
&& (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ || thing->type == MT_JAWZ_DUD
&& (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ
|| thing->type == MT_BANANA || thing->type == MT_EGGMANITEM || thing->type == MT_BALLHOG
|| thing->type == MT_SSMINE || tmthing->type == MT_LANDMINE || thing->type == MT_SINK
|| (thing->type == MT_PLAYER && tmthing->target != thing)))
@ -898,7 +898,7 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
// Droptarget reflect
if ((thing->type == MT_DROPTARGET || thing->type == MT_DROPTARGET_SHIELD)
&& (tmthing->type == MT_ORBINAUT || tmthing->type == MT_JAWZ || tmthing->type == MT_JAWZ_DUD
&& (tmthing->type == MT_ORBINAUT || tmthing->type == MT_JAWZ
|| tmthing->type == MT_BANANA || tmthing->type == MT_EGGMANITEM || tmthing->type == MT_BALLHOG
|| tmthing->type == MT_SSMINE || tmthing->type == MT_LANDMINE || tmthing->type == MT_SINK
|| (tmthing->type == MT_PLAYER)))
@ -912,7 +912,7 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
return K_DropTargetCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT;
}
else if ((tmthing->type == MT_DROPTARGET || tmthing->type == MT_DROPTARGET_SHIELD)
&& (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ || thing->type == MT_JAWZ_DUD
&& (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ
|| thing->type == MT_BANANA || thing->type == MT_EGGMANITEM || thing->type == MT_BALLHOG
|| thing->type == MT_SSMINE || tmthing->type == MT_LANDMINE || thing->type == MT_SINK
|| (thing->type == MT_PLAYER)))
@ -931,7 +931,7 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
|| thing->type == MT_DROPTARGET_SHIELD || tmthing->type == MT_DROPTARGET_SHIELD)
return BMIT_CONTINUE;
if (tmthing->type == MT_ORBINAUT || tmthing->type == MT_JAWZ || tmthing->type == MT_JAWZ_DUD
if (tmthing->type == MT_ORBINAUT || tmthing->type == MT_JAWZ
|| tmthing->type == MT_ORBINAUT_SHIELD || tmthing->type == MT_JAWZ_SHIELD)
{
// see if it went over / under
@ -940,9 +940,9 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
if (tmthing->z + tmthing->height < thing->z)
return BMIT_CONTINUE; // underneath
return K_OrbinautJawzCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT;
return Obj_OrbinautJawzCollide(tmthing, thing) ? BMIT_CONTINUE : BMIT_ABORT;
}
else if (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ || thing->type == MT_JAWZ_DUD
else if (thing->type == MT_ORBINAUT || thing->type == MT_JAWZ
|| thing->type == MT_ORBINAUT_SHIELD || thing->type == MT_JAWZ_SHIELD)
{
// see if it went over / under
@ -951,7 +951,7 @@ static BlockItReturn_t PIT_CheckThing(mobj_t *thing)
if (tmthing->z + tmthing->height < thing->z)
return BMIT_CONTINUE; // underneath
return K_OrbinautJawzCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT;
return Obj_OrbinautJawzCollide(thing, tmthing) ? BMIT_CONTINUE : BMIT_ABORT;
}
if (tmthing->type == MT_BANANA || tmthing->type == MT_BANANA_SHIELD || tmthing->type == MT_BALLHOG)

View file

@ -92,7 +92,7 @@ static inline INT32 randomframe (mobj_t *mobj, INT32 n)
{
// Only mobj thinkers should use synced RNG
if (mobj->thinker.function.acp1 == (actionf_p1)P_MobjThinker)
return P_RandomKey(n);
return P_RandomKey(PR_RANDOMANIM, n);
else
return M_RandomKey(n);
}
@ -316,7 +316,7 @@ boolean P_SetPlayerMobjState(mobj_t *mobj, statenum_t state)
}
else if (mobj->sprite2 != spr2)
{
if ((st->frame & FF_SPR2MIDSTART) && numframes && P_RandomChance(FRACUNIT/2))
if ((st->frame & FF_SPR2MIDSTART) && numframes && P_RandomChance(PR_RANDOMANIM, FRACUNIT/2))
frame = numframes/2;
else
frame = 0;
@ -442,7 +442,7 @@ boolean P_SetMobjState(mobj_t *mobj, statenum_t state)
}
else if (mobj->sprite2 != spr2)
{
if ((st->frame & FF_SPR2MIDSTART) && numframes && P_RandomChance(FRACUNIT/2))
if ((st->frame & FF_SPR2MIDSTART) && numframes && P_RandomChance(PR_RANDOMANIM, FRACUNIT/2))
frame = numframes/2;
else
frame = 0;
@ -1743,7 +1743,6 @@ void P_XYMovement(mobj_t *mo)
/*FALLTHRU*/
case MT_JAWZ:
case MT_JAWZ_DUD:
if (mo->health == 1)
{
// This Item Damage
@ -2186,7 +2185,6 @@ boolean P_ZMovement(mobj_t *mo)
case MT_BANANA:
case MT_ORBINAUT:
case MT_JAWZ:
case MT_JAWZ_DUD:
case MT_BALLHOG:
case MT_SSMINE:
case MT_LANDMINE:
@ -2509,12 +2507,12 @@ boolean P_ZMovement(mobj_t *mo)
// If deafed, give the tumbleweed another random kick if it runs out of steam.
mom.z += P_MobjFlip(mo)*FixedMul(6*FRACUNIT, mo->scale);
if (P_RandomChance(FRACUNIT/2))
if (P_RandomChance(PR_DECORATION, FRACUNIT/2))
mom.x += FixedMul(6*FRACUNIT, mo->scale);
else
mom.x -= FixedMul(6*FRACUNIT, mo->scale);
if (P_RandomChance(FRACUNIT/2))
if (P_RandomChance(PR_DECORATION, FRACUNIT/2))
mom.y += FixedMul(6*FRACUNIT, mo->scale);
else
mom.y -= FixedMul(6*FRACUNIT, mo->scale);
@ -2537,7 +2535,7 @@ boolean P_ZMovement(mobj_t *mo)
else if (mo->type == MT_FALLINGROCK)
{
if (P_MobjFlip(mo)*mom.z > FixedMul(2*FRACUNIT, mo->scale))
S_StartSound(mo, mo->info->activesound + P_RandomKey(mo->info->reactiontime));
S_StartSound(mo, mo->info->activesound + P_RandomKey(PR_DECORATION, mo->info->reactiontime));
mom.z /= 2; // Rocks not so bouncy
@ -2989,7 +2987,7 @@ boolean P_SceneryZMovement(mobj_t *mo)
for (i = 0; i < 4; ++i) // split into four
{
prandom = P_RandomByte();
prandom = P_RandomByte(PR_BUBBLE);
explodemo = P_SpawnMobj(mo->x, mo->y, mo->z, MT_SMALLBUBBLE);
explodemo->momx += ((prandom & 0x0F) << (FRACBITS-2)) * (i & 2 ? -1 : 1);
explodemo->momy += ((prandom & 0xF0) << (FRACBITS-6)) * (i & 1 ? -1 : 1);
@ -2998,7 +2996,7 @@ boolean P_SceneryZMovement(mobj_t *mo)
}
if (mo->threshold != 42) // Don't make pop sound if threshold is 42.
S_StartSound(explodemo, sfx_bubbl1 + P_RandomKey(5));
S_StartSound(explodemo, sfx_bubbl1 + P_RandomKey(PR_BUBBLE, 5));
//note that we assign the bubble sound to one of the new bubbles.
// in other words, IT ACTUALLY GETS USED YAAAAAAAY
@ -3021,7 +3019,7 @@ boolean P_SceneryZMovement(mobj_t *mo)
if ((!(mo->eflags & MFE_VERTICALFLIP) && mo->z <= mo->floorz)
|| (mo->eflags & MFE_VERTICALFLIP && mo->z+mo->height >= mo->ceilingz))
{
mobjtype_t flowertype = ((P_RandomChance(FRACUNIT/2)) ? MT_GFZFLOWER1 : MT_GFZFLOWER3);
mobjtype_t flowertype = ((P_RandomChance(PR_UNDEFINED, FRACUNIT/2)) ? MT_GFZFLOWER1 : MT_GFZFLOWER3);
mobj_t *flower = P_SpawnMobjFromMobj(mo, 0, 0, 0, flowertype);
if (flower)
{
@ -3384,10 +3382,10 @@ void P_MobjCheckWater(mobj_t *mobj)
// P_RandomByte()s are called individually to allow consistency
// across various compilers, since the order of function calls
// in C is not part of the ANSI specification.
prandom[0] = P_RandomByte();
prandom[1] = P_RandomByte();
prandom[2] = P_RandomByte();
prandom[3] = P_RandomByte();
prandom[0] = P_RandomByte(PR_BUBBLE);
prandom[1] = P_RandomByte(PR_BUBBLE);
prandom[2] = P_RandomByte(PR_BUBBLE);
prandom[3] = P_RandomByte(PR_BUBBLE);
bubbletype = MT_SMALLBUBBLE;
if (!(prandom[0] & 0x3)) // medium bubble chance up to 64 from 32
@ -4319,7 +4317,7 @@ boolean P_BossTargetPlayer(mobj_t *actor, boolean closest)
// first time init, this allow minimum lastlook changes
if (actor->lastlook < 0)
actor->lastlook = P_RandomByte();
actor->lastlook = P_RandomByte(PR_UNDEFINED);
actor->lastlook &= PLAYERSMASK;
for( ; ; actor->lastlook = (actor->lastlook+1) & PLAYERSMASK)
@ -4394,7 +4392,7 @@ boolean P_SupermanLook4Players(mobj_t *actor)
if (!stop)
return false;
P_SetTarget(&actor->target, playersinthegame[P_RandomKey(stop)]->mo);
P_SetTarget(&actor->target, playersinthegame[P_RandomKey(PR_UNDEFINED, stop)]->mo);
return true;
}
@ -5000,7 +4998,7 @@ boolean P_IsKartItem(INT32 type)
type == MT_BANANA || type == MT_BANANA_SHIELD ||
type == MT_DROPTARGET || type == MT_DROPTARGET_SHIELD ||
type == MT_ORBINAUT || type == MT_ORBINAUT_SHIELD ||
type == MT_JAWZ || type == MT_JAWZ_DUD || type == MT_JAWZ_SHIELD ||
type == MT_JAWZ || type == MT_JAWZ_SHIELD ||
type == MT_SSMINE || type == MT_SSMINE_SHIELD ||
type == MT_SINK || type == MT_SINK_SHIELD ||
type == MT_SPB || type == MT_BALLHOG || type == MT_BUBBLESHIELDTRAP ||
@ -5415,7 +5413,7 @@ static boolean P_ParticleGenSceneryThink(mobj_t *mobj)
spawn->scalespeed = spawn->scale/mobj->health;
spawn->tics = (tic_t)mobj->health;
spawn->flags2 |= (mobj->flags2 & MF2_OBJECTFLIP);
spawn->angle += P_RandomKey(36)*ANG10; // irrelevant for default objects but might make sense for some custom ones
spawn->angle += P_RandomKey(PR_DECORATION, 36)*ANG10; // irrelevant for default objects but might make sense for some custom ones
mobj->angle += mobj->movedir;
}
@ -5526,7 +5524,7 @@ static void P_MobjSceneryThink(mobj_t *mobj)
{
mobj->health = 0;
P_SetMobjState(mobj, mobj->info->deathstate);
S_StartSound(mobj, mobj->info->deathsound + P_RandomKey(mobj->info->mass));
S_StartSound(mobj, mobj->info->deathsound + P_RandomKey(PR_DECORATION, mobj->info->mass));
return;
}
break;
@ -5679,22 +5677,22 @@ static void P_MobjSceneryThink(mobj_t *mobj)
case MT_SMOLDERING:
if (leveltime % 2 == 0)
{
fixed_t x = P_RandomRange(-35, 35)*mobj->scale;
fixed_t y = P_RandomRange(-35, 35)*mobj->scale;
fixed_t z = P_RandomRange(0, 70)*mobj->scale;
fixed_t x = P_RandomRange(PR_SMOLDERING, -35, 35)*mobj->scale;
fixed_t y = P_RandomRange(PR_SMOLDERING, -35, 35)*mobj->scale;
fixed_t z = P_RandomRange(PR_SMOLDERING, 0, 70)*mobj->scale;
mobj_t *smoke = P_SpawnMobj(mobj->x + x, mobj->y + y, mobj->z + z, MT_SMOKE);
P_SetMobjState(smoke, S_OPAQUESMOKE1);
K_MatchGenericExtraFlags(smoke, mobj);
smoke->scale = mobj->scale * 2;
smoke->destscale = mobj->scale * 6;
smoke->momz = P_RandomRange(4, 9)*FRACUNIT*P_MobjFlip(smoke);
smoke->momz = P_RandomRange(PR_SMOLDERING, 4, 9)*FRACUNIT*P_MobjFlip(smoke);
}
break;
case MT_BOOMPARTICLE:
{
fixed_t x = P_RandomRange(-16, 16)*mobj->scale;
fixed_t y = P_RandomRange(-16, 16)*mobj->scale;
fixed_t z = P_RandomRange(0, 32)*mobj->scale*P_MobjFlip(mobj);
fixed_t x = P_RandomRange(PR_EXPLOSION, -16, 16)*mobj->scale;
fixed_t y = P_RandomRange(PR_EXPLOSION, -16, 16)*mobj->scale;
fixed_t z = P_RandomRange(PR_EXPLOSION, 0, 32)*mobj->scale*P_MobjFlip(mobj);
if (leveltime % 2 == 0)
{
mobj_t *smoke = P_SpawnMobj(mobj->x + x, mobj->y + y, mobj->z + z, MT_BOSSEXPLODE);
@ -5779,9 +5777,9 @@ static void P_MobjSceneryThink(mobj_t *mobj)
{
mobj_t *debris = P_SpawnMobjFromMobj(
mobj,
P_RandomRange(-spacing, spacing) * FRACUNIT,
P_RandomRange(-spacing, spacing) * FRACUNIT,
P_RandomRange(-spacing, spacing) * FRACUNIT,
P_RandomRange(PR_ITEM_RINGS, -spacing, spacing) * FRACUNIT,
P_RandomRange(PR_ITEM_RINGS, -spacing, spacing) * FRACUNIT,
P_RandomRange(PR_ITEM_RINGS, -spacing, spacing) * FRACUNIT,
MT_BATTLEBUMPER_DEBRIS
);
@ -5810,9 +5808,9 @@ static void P_MobjSceneryThink(mobj_t *mobj)
{
mobj_t *puff = P_SpawnMobjFromMobj(
mobj,
P_RandomRange(-spacing, spacing) * FRACUNIT,
P_RandomRange(-spacing, spacing) * FRACUNIT,
P_RandomRange(-spacing, spacing) * FRACUNIT,
P_RandomRange(PR_ITEM_RINGS, -spacing, spacing) * FRACUNIT,
P_RandomRange(PR_ITEM_RINGS, -spacing, spacing) * FRACUNIT,
P_RandomRange(PR_ITEM_RINGS, -spacing, spacing) * FRACUNIT,
MT_SPINDASHDUST
);
@ -6308,9 +6306,9 @@ static boolean P_MobjDeadThink(mobj_t *mobj)
{
fixed_t r = mobj->radius >> FRACBITS;
mobj_t *explosion = P_SpawnMobj(
mobj->x + (P_RandomRange(r, -r) << FRACBITS),
mobj->y + (P_RandomRange(r, -r) << FRACBITS),
mobj->z + (P_RandomKey(mobj->height >> FRACBITS) << FRACBITS),
mobj->x + (P_RandomRange(PR_UNDEFINED, r, -r) << FRACBITS),
mobj->y + (P_RandomRange(PR_UNDEFINED, r, -r) << FRACBITS),
mobj->z + (P_RandomKey(PR_UNDEFINED, mobj->height >> FRACBITS) << FRACBITS),
MT_SONIC3KBOSSEXPLODE);
S_StartSound(explosion, sfx_s3kb4);
}
@ -6335,7 +6333,6 @@ static boolean P_MobjDeadThink(mobj_t *mobj)
mobj->renderflags ^= RF_DONTDRAW;
break;
case MT_JAWZ:
case MT_JAWZ_DUD:
if (P_IsObjectOnGround(mobj))
P_SetMobjState(mobj, mobj->info->xdeathstate);
/* FALLTHRU */
@ -6403,9 +6400,9 @@ static boolean P_MobjDeadThink(mobj_t *mobj)
for (i = 0; i < 2; i++)
{
fixed_t xoffset = P_RandomRange(-amt, amt) * mobj->scale;
fixed_t yoffset = P_RandomRange(-amt, amt) * mobj->scale;
fixed_t zoffset = P_RandomRange(-(amt >> 1), (amt >> 1)) * mobj->scale;
fixed_t xoffset = P_RandomRange(PR_ITEM_DEBRIS, -amt, amt) * mobj->scale;
fixed_t yoffset = P_RandomRange(PR_ITEM_DEBRIS, -amt, amt) * mobj->scale;
fixed_t zoffset = P_RandomRange(PR_ITEM_DEBRIS, -(amt >> 1), (amt >> 1)) * mobj->scale;
dust = P_SpawnMobj(mobj->x + xoffset, mobj->y + yoffset,
mobj->z + (mobj->height >> 1) + zoffset, MT_EXPLODE);
@ -6719,164 +6716,12 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
break;
case MT_ORBINAUT:
{
boolean grounded = P_IsObjectOnGround(mobj);
if (mobj->flags2 & MF2_AMBUSH)
{
if (grounded && (mobj->flags & MF_NOCLIPTHING))
{
mobj->momx = 1;
mobj->momy = 0;
mobj->frame = 3;
S_StartSound(mobj, mobj->info->activesound);
mobj->flags &= ~MF_NOCLIPTHING;
}
else if (mobj->movecount)
mobj->movecount--;
else if (mobj->frame < 3)
{
mobj->movecount = 2;
mobj->frame++;
}
}
else
{
mobj_t *ghost = P_SpawnGhostMobj(mobj);
ghost->colorized = true; // already has color!
mobj->angle = K_MomentumAngle(mobj);
if (P_IsObjectOnGround(mobj))
{
fixed_t finalspeed = mobj->movefactor;
const fixed_t currentspeed = R_PointToDist2(0, 0, mobj->momx, mobj->momy);
fixed_t thrustamount = 0;
fixed_t frictionsafety = (mobj->friction == 0) ? 1 : mobj->friction;
if (!grounded)
{
// No friction in the air
frictionsafety = FRACUNIT;
}
if (mobj->health <= 5)
{
INT32 i;
for (i = 5; i >= mobj->health; i--)
finalspeed = FixedMul(finalspeed, FRACUNIT-FRACUNIT/4);
}
if (currentspeed >= finalspeed)
{
// Thrust as if you were at top speed, slow down naturally
thrustamount = FixedDiv(finalspeed, frictionsafety) - finalspeed;
}
else
{
const fixed_t beatfriction = FixedDiv(currentspeed, frictionsafety) - currentspeed;
// Thrust to immediately get to top speed
thrustamount = beatfriction + FixedDiv(finalspeed - currentspeed, frictionsafety);
}
P_Thrust(mobj, mobj->angle, thrustamount);
}
if (P_MobjTouchingSectorSpecial(mobj, 3, 1, true))
K_DoPogoSpring(mobj, 0, 1);
if (mobj->threshold > 0)
mobj->threshold--;
if (leveltime % 6 == 0)
S_StartSound(mobj, mobj->info->activesound);
}
Obj_OrbinautThink(mobj);
break;
}
case MT_JAWZ:
{
mobj_t *ghost = P_SpawnGhostMobj(mobj);
if (mobj->target && !P_MobjWasRemoved(mobj->target) && mobj->target->player)
{
ghost->color = mobj->target->player->skincolor;
ghost->colorized = true;
}
if (mobj->threshold > 0)
mobj->threshold--;
if (leveltime % TICRATE == 0)
S_StartSound(mobj, mobj->info->activesound);
// Movement handling has ALL been moved to A_JawzChase
K_DriftDustHandling(mobj);
if (P_MobjTouchingSectorSpecial(mobj, 3, 1, true))
K_DoPogoSpring(mobj, 0, 1);
if (!(gametyperules & GTR_CIRCUIT))
mobj->friction = max(0, 3 * mobj->friction / 4);
break;
}
case MT_JAWZ_DUD:
{
boolean grounded = P_IsObjectOnGround(mobj);
if (mobj->flags2 & MF2_AMBUSH)
{
if (grounded && (mobj->flags & MF_NOCLIPTHING))
{
mobj->momx = 1;
mobj->momy = 0;
S_StartSound(mobj, mobj->info->deathsound);
mobj->flags &= ~MF_NOCLIPTHING;
}
}
else
{
mobj_t *ghost = P_SpawnGhostMobj(mobj);
const fixed_t currentspeed = R_PointToDist2(0, 0, mobj->momx, mobj->momy);
fixed_t frictionsafety = (mobj->friction == 0) ? 1 : mobj->friction;
fixed_t thrustamount = 0;
if (mobj->target && !P_MobjWasRemoved(mobj->target) && mobj->target->player)
{
ghost->color = mobj->target->player->skincolor;
ghost->colorized = true;
}
if (!grounded)
{
// No friction in the air
frictionsafety = FRACUNIT;
}
if (currentspeed >= mobj->movefactor)
{
// Thrust as if you were at top speed, slow down naturally
thrustamount = FixedDiv(mobj->movefactor, frictionsafety) - mobj->movefactor;
}
else
{
const fixed_t beatfriction = FixedDiv(currentspeed, frictionsafety) - currentspeed;
// Thrust to immediately get to top speed
thrustamount = beatfriction + FixedDiv(mobj->movefactor - currentspeed, frictionsafety);
}
mobj->angle = K_MomentumAngle(mobj);
P_Thrust(mobj, mobj->angle, thrustamount);
if (P_MobjTouchingSectorSpecial(mobj, 3, 1, true))
K_DoPogoSpring(mobj, 0, 1);
if (mobj->threshold > 0)
mobj->threshold--;
if (leveltime % TICRATE == 0)
S_StartSound(mobj, mobj->info->activesound);
}
Obj_JawzThink(mobj);
break;
}
case MT_EGGMANITEM:
@ -7073,9 +6918,9 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
{
mobj_t *sparkle = P_SpawnMobjFromMobj(
mobj,
P_RandomRange(-48, 48) * FRACUNIT,
P_RandomRange(-48, 48) * FRACUNIT,
P_RandomRange(0, 64) * FRACUNIT,
P_RandomRange(PR_SPARKLE, -48, 48) * FRACUNIT,
P_RandomRange(PR_SPARKLE, -48, 48) * FRACUNIT,
P_RandomRange(PR_SPARKLE, 0, 64) * FRACUNIT,
MT_EMERALDSPARK
);
@ -7311,7 +7156,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
smoke->momy = mobj->target->momy/2;
smoke->momz = mobj->target->momz/2;
P_Thrust(smoke, mobj->angle+FixedAngle(P_RandomRange(135, 225)<<FRACBITS), P_RandomRange(0, 8) * mobj->target->scale);
P_Thrust(smoke, mobj->angle+FixedAngle(P_RandomRange(PR_ITEM_BOOST, 135, 225)<<FRACBITS), P_RandomRange(PR_ITEM_BOOST, 0, 8) * mobj->target->scale);
}
break;
case MT_INVULNFLASH:
@ -7768,9 +7613,9 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
for (i = 0; i < nl; i++)
{
mobj_t *fast = P_SpawnMobj(mobj->x + (P_RandomRange(-36,36) * mobj->scale),
mobj->y + (P_RandomRange(-36,36) * mobj->scale),
mobj->z + (mobj->height/2) + (P_RandomRange(-20,20) * mobj->scale),
mobj_t *fast = P_SpawnMobj(mobj->x + (P_RandomRange(PR_ITEM_BOOST, -36,36) * mobj->scale),
mobj->y + (P_RandomRange(PR_ITEM_BOOST, -36,36) * mobj->scale),
mobj->z + (mobj->height/2) + (P_RandomRange(PR_ITEM_BOOST, -20,20) * mobj->scale),
MT_FASTLINE);
P_InitAngle(fast, mobj->angle);
@ -8037,7 +7882,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
else
{
// Pick another player in the server!
player_t *p = &players[plist[P_RandomKey(plistlen)]];
player_t *p = &players[plist[P_RandomKey(PR_SPARKLE, plistlen)]];
newskin = ((skin_t*)p->mo->skin) - skins;
newcolor = p->skincolor;
}
@ -8109,7 +7954,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
mobj->movecount = 3;
{
angle_t facing = P_RandomRange(0, 90);
angle_t facing = P_RandomRange(PR_MOVINGTARGET, 0, 90);
if (facing >= 45)
facing = InvAngle((facing - 45)*ANG1);
else
@ -8142,23 +7987,23 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
else // fire + smoke pillar
{
UINT8 i;
mobj_t *fire = P_SpawnMobj(mobj->x + (P_RandomRange(-32, 32)*mobj->scale), mobj->y + (P_RandomRange(-32, 32)*mobj->scale), mobj->z, MT_THOK);
mobj_t *fire = P_SpawnMobj(mobj->x + (P_RandomRange(PR_SMOLDERING, -32, 32)*mobj->scale), mobj->y + (P_RandomRange(PR_SMOLDERING, -32, 32)*mobj->scale), mobj->z, MT_THOK);
fire->sprite = SPR_FPRT;
fire->frame = FF_FULLBRIGHT|FF_TRANS30;
fire->scale = mobj->scale*4;
fire->momz = P_RandomRange(2, 3)*mobj->scale;
fire->momz = P_RandomRange(PR_SMOLDERING, 2, 3)*mobj->scale;
fire->scalespeed = mobj->scale/12;
fire->destscale = 1;
fire->tics = TICRATE;
for (i = 0; i < 2; i++)
{
mobj_t *smoke = P_SpawnMobj(mobj->x + (P_RandomRange(-16, 16)*mobj->scale), mobj->y + (P_RandomRange(-16, 16)*mobj->scale), mobj->z, MT_SMOKE);
mobj_t *smoke = P_SpawnMobj(mobj->x + (P_RandomRange(PR_SMOLDERING, -16, 16)*mobj->scale), mobj->y + (P_RandomRange(PR_SMOLDERING, -16, 16)*mobj->scale), mobj->z, MT_SMOKE);
P_SetMobjState(smoke, S_FZSLOWSMOKE1);
smoke->scale = mobj->scale;
smoke->momz = P_RandomRange(3, 10)*mobj->scale;
smoke->momz = P_RandomRange(PR_SMOLDERING, 3, 10)*mobj->scale;
smoke->destscale = mobj->scale*4;
smoke->scalespeed = mobj->scale/24;
}
@ -8215,7 +8060,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
{
if (mobj->flags2 & MF2_AMBUSH)
{
mobj->momz = P_RandomRange(12, 16)<<FRACBITS;
mobj->momz = P_RandomRange(PR_UNDEFINED, 12, 16)<<FRACBITS;
S_StartSound(mobj, sfx_s3kb1);
P_SetMobjState(mobj, S_FROGGER_JUMP);
}
@ -8345,7 +8190,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
else
{
if (!mobj->extravalue2)
mobj->extravalue2 = P_RandomRange(64, 192);
mobj->extravalue2 = P_RandomRange(PR_UNDEFINED, 64, 192);
}
if (mobj->reactiontime)
@ -8378,11 +8223,11 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
if ((mobj->tracer && !P_MobjWasRemoved(mobj->tracer)) && !(leveltime % 10))
{
mobj_t *dust = P_SpawnMobj(mobj->x + (P_RandomRange(-4, 4)<<FRACBITS),
mobj->y + (P_RandomRange(-4, 4)<<FRACBITS),
mobj->z + (P_RandomRange(0, 2)<<FRACBITS), MT_BBZDUST);
mobj_t *dust = P_SpawnMobj(mobj->x + (P_RandomRange(PR_UNDEFINED, -4, 4)<<FRACBITS),
mobj->y + (P_RandomRange(PR_UNDEFINED, -4, 4)<<FRACBITS),
mobj->z + (P_RandomRange(PR_UNDEFINED, 0, 2)<<FRACBITS), MT_BBZDUST);
P_SetScale(dust, mobj->scale/2);
P_InstaThrust(dust, FixedAngle(P_RandomRange(0,359)<<FRACBITS), abs(mobj->tracer->momz)/2);
P_InstaThrust(dust, FixedAngle(P_RandomRange(PR_UNDEFINED, 0,359)<<FRACBITS), abs(mobj->tracer->momz)/2);
if (abs(mobj->tracer->momz) >= 2<<FRACBITS)
S_StartSound(mobj, sfx_s3k7e);
@ -8496,7 +8341,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
player->mo->y + P_ReturnThrustY(NULL, player->mo->angle, player->mo->radius)
+ P_ReturnThrustY(NULL, player->mo->angle+ANGLE_90, (mobj->threshold)<<FRACBITS),
player->mo->z + (player->mo->height/2 * P_MobjFlip(player->mo))
+ (P_RandomRange(-abs(mobj->threshold), abs(mobj->threshold))<<FRACBITS));
+ (P_RandomRange(PR_UNDEFINED, -abs(mobj->threshold), abs(mobj->threshold))<<FRACBITS));
mobj->threshold /= 2;
mobj->momz = 0;
@ -8585,7 +8430,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
{
mobj_t *dust = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_DRIFTDUST);
P_InstaThrust(dust, FixedAngle(((360*FRACUNIT)/8) * i), mobj->info->speed/8);
dust->momz = P_MobjFlip(mobj) * (P_RandomRange(1,4)<<FRACBITS);
dust->momz = P_MobjFlip(mobj) * (P_RandomRange(PR_UNDEFINED, 1,4)<<FRACBITS);
dust->scale = mobj->scale/2;
dust->destscale = mobj->scale*3;
}
@ -8654,7 +8499,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
P_MoveOrigin(mobj,
mobj->tracer->x + P_ReturnThrustX(NULL, mobj->tracer->angle+ANGLE_90, (mobj->cvmem)<<FRACBITS),
mobj->tracer->y + P_ReturnThrustY(NULL, mobj->tracer->angle+ANGLE_90, (mobj->cvmem)<<FRACBITS),
mobj->tracer->z - (4*mobj->tracer->scale) + (P_RandomRange(-abs(mobj->cvmem), abs(mobj->cvmem))<<FRACBITS));
mobj->tracer->z - (4*mobj->tracer->scale) + (P_RandomRange(PR_ITEM_BUBBLE, -abs(mobj->cvmem), abs(mobj->cvmem))<<FRACBITS));
if (mobj->movecount > 4*TICRATE)
{
@ -9155,7 +9000,7 @@ for (i = ((mobj->flags2 & MF2_STRONGBOX) ? strongboxamt : weakboxamt); i; --i) s
#undef SETMONITORCHANCES
i = P_RandomKey(numchoices); // Gotta love those random numbers!
i = P_RandomKey(PR_UNDEFINED, numchoices); // Gotta love those random numbers!
newmobj = P_SpawnMobj(mobj->x, mobj->y, mobj->z, spawnchance[i]);
}
else
@ -9271,9 +9116,9 @@ static boolean P_FuseThink(mobj_t *mobj)
for (i = 0; i < 5; i++)
{
mobj_t *debris = P_SpawnMobj(mobj->x, mobj->y, mobj->z, MT_SMK_ICEBLOCK_DEBRIS);
P_InitAngle(debris, FixedAngle(P_RandomRange(0,360)<<FRACBITS));
P_InstaThrust(debris, debris->angle, P_RandomRange(3,18)*(FRACUNIT/4));
debris->momz = P_RandomRange(4,8)<<FRACBITS;
P_InitAngle(debris, FixedAngle(P_RandomRange(PR_DECORATION, 0,360)<<FRACBITS));
P_InstaThrust(debris, debris->angle, P_RandomRange(PR_DECORATION, 3,18)*(FRACUNIT/4));
debris->momz = P_RandomRange(PR_DECORATION, 4,8)<<FRACBITS;
if (!i) // kinda hacky :V
S_StartSound(debris, sfx_s3k82);
}
@ -9457,7 +9302,7 @@ void P_MobjThinker(mobj_t *mobj)
// Destroy items sector special
if (mobj->type == MT_BANANA || mobj->type == MT_EGGMANITEM
|| mobj->type == MT_ORBINAUT || mobj->type == MT_BALLHOG
|| mobj->type == MT_JAWZ || mobj->type == MT_JAWZ_DUD
|| mobj->type == MT_JAWZ
|| mobj->type == MT_SSMINE || mobj->type == MT_BUBBLESHIELDTRAP
|| mobj->type == MT_LANDMINE)
{
@ -9546,7 +9391,7 @@ void P_MobjThinker(mobj_t *mobj)
|| mobj->type == MT_CANNONBALLDECOR
|| mobj->type == MT_FALLINGROCK
|| mobj->type == MT_ORBINAUT
|| mobj->type == MT_JAWZ || mobj->type == MT_JAWZ_DUD
|| mobj->type == MT_JAWZ
|| (mobj->type == MT_DROPTARGET && mobj->reactiontime))
{
P_TryMove(mobj, mobj->x, mobj->y, true); // Sets mo->standingslope correctly
@ -9849,7 +9694,6 @@ static void P_DefaultMobjShadowScale(mobj_t *thing)
case MT_ORBINAUT:
case MT_ORBINAUT_SHIELD:
case MT_JAWZ:
case MT_JAWZ_DUD:
case MT_JAWZ_SHIELD:
case MT_SSMINE:
case MT_SSMINE_SHIELD:
@ -10149,7 +9993,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
mobj->flags2 |= MF2_INVERTAIMABLE;
break;
case MT_FLICKY_08:
mobj->color = (P_RandomChance(FRACUNIT/2) ? SKINCOLOR_RED : SKINCOLOR_AQUAMARINE);
mobj->color = (P_RandomChance(PR_UNDEFINED, FRACUNIT/2) ? SKINCOLOR_RED : SKINCOLOR_AQUAMARINE);
break;
case MT_BALLOON:
{
@ -10161,7 +10005,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
SKINCOLOR_JET
};
mobj->color = BALLOONCOLORS[P_RandomKey(sizeof(BALLOONCOLORS))];
mobj->color = BALLOONCOLORS[P_RandomKey(PR_DECORATION, sizeof(BALLOONCOLORS))];
}
break;
case MT_POGOSPRING:
@ -10171,8 +10015,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
mobj->color = SKINCOLOR_RED;
break;
case MT_EGGROBO1:
mobj->movecount = P_RandomKey(13);
mobj->color = FIRSTRAINBOWCOLOR + P_RandomKey(FIRSTSUPERCOLOR - FIRSTRAINBOWCOLOR);
mobj->movecount = P_RandomKey(PR_DECORATION, 13);
mobj->color = FIRSTRAINBOWCOLOR + P_RandomKey(PR_DECORATION, FIRSTSUPERCOLOR - FIRSTRAINBOWCOLOR);
break;
case MT_HIVEELEMENTAL:
mobj->extravalue1 = 5;
@ -10268,15 +10112,15 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
{
// set default item & count
#if 0 // set to 1 to test capsules with random items, e.g. with objectplace
if (P_RandomChance(FRACUNIT/3))
if (P_RandomChance(PR_ITEM_ROULETTE, FRACUNIT/3))
mobj->threshold = KITEM_SUPERRING;
else if (P_RandomChance(FRACUNIT/3))
else if (P_RandomChance(PR_ITEM_ROULETTE, FRACUNIT/3))
mobj->threshold = KITEM_SPB;
else if (P_RandomChance(FRACUNIT/3))
else if (P_RandomChance(PR_ITEM_ROULETTE, FRACUNIT/3))
mobj->threshold = KITEM_ORBINAUT;
else
mobj->threshold = P_RandomRange(1, NUMKARTITEMS - 1);
mobj->movecount = P_RandomChance(FRACUNIT/3) ? 1 : P_RandomKey(32) + 1;
mobj->threshold = P_RandomRange(PR_ITEM_ROULETTE, 1, NUMKARTITEMS - 1);
mobj->movecount = P_RandomChance(PR_ITEM_ROULETTE, FRACUNIT/3) ? 1 : P_RandomKey(PR_ITEM_ROULETTE, 32) + 1;
#else
mobj->threshold = KITEM_SUPERRING; // default item is super ring
mobj->movecount = 1;
@ -10323,7 +10167,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
break;
case MT_RANDOMAUDIENCE:
{
fixed_t randu = P_RandomFixed();
fixed_t randu = P_RandomFixed(PR_UNDEFINED);
P_SetScale(mobj, (mobj->destscale <<= 1));
if (randu < (FRACUNIT/9)) // a fan of someone?
{
@ -10340,7 +10184,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
if (pcount)
{
mobj->threshold = pnum[P_RandomKey(pcount)];
mobj->threshold = pnum[P_RandomKey(PR_UNDEFINED, pcount)];
mobj->color = players[mobj->threshold].skincolor;
mobj->colorized = true;
break;
@ -10349,7 +10193,7 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
if (randu > (FRACUNIT/2))
{
mobj->color = P_RandomKey(numskincolors-1)+1;
mobj->color = P_RandomKey(PR_UNDEFINED, numskincolors-1)+1;
break;
}
@ -10420,8 +10264,8 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
UINT16 i;
for (i = 0; i < mobj->info->mass; i++)
{
fixed_t newx = mobj->x + (P_RandomRange(-mobj->info->mass, mobj->info->mass)<<FRACBITS);
fixed_t newy = mobj->y + (P_RandomRange(-mobj->info->mass, mobj->info->mass)<<FRACBITS);
fixed_t newx = mobj->x + (P_RandomRange(PR_DECORATION, -mobj->info->mass, mobj->info->mass)<<FRACBITS);
fixed_t newy = mobj->y + (P_RandomRange(PR_DECORATION, -mobj->info->mass, mobj->info->mass)<<FRACBITS);
if (P_FloorzAtPos(newx, newy, mobj->z, 8<<FRACBITS) == mobj->z)
P_SpawnMobj(newx, newy, mobj->z, MT_EERIEFOG);
@ -10435,10 +10279,10 @@ mobj_t *P_SpawnMobj(fixed_t x, fixed_t y, fixed_t z, mobjtype_t type)
mobj->renderflags |= RF_FULLBRIGHT;
break;
case MT_SMK_MOLE:
mobj->reactiontime = P_RandomRange(0, 3*mobj->info->reactiontime/2); // Random delay on start of level
mobj->reactiontime = P_RandomRange(PR_UNDEFINED, 0, 3*mobj->info->reactiontime/2); // Random delay on start of level
break;
case MT_SMK_THWOMP:
mobj->reactiontime = P_RandomRange(0, 3*mobj->info->reactiontime); // Random delay on start of level
mobj->reactiontime = P_RandomRange(PR_UNDEFINED, 0, 3*mobj->info->reactiontime); // Random delay on start of level
if (mobj->z == mobj->floorz)
mobj->z += (256<<FRACBITS);
mobj->movefactor = mobj->z + (256<<FRACBITS);
@ -10964,7 +10808,7 @@ void P_PrecipitationEffects(void)
// with global rain and switched players to anything else ...
// If the global weather has lightning strikes,
// EVERYONE gets them at the SAME time!
thunderchance = (P_RandomKey(8192));
thunderchance = (P_RandomKey(PR_DECORATION, 8192));
}
else if (sounds_thunder || effects_lightning)
{
@ -12556,8 +12400,8 @@ static boolean P_SetupSpawnedMapThing(mapthing_t *mthing, mobj_t *mobj, boolean
if (mthing->options & MTF_AMBUSH)
{
fixed_t offset = FixedMul(16*FRACUNIT, mobj->scale);
mobj->momx += P_RandomChance(FRACUNIT/2) ? offset : -offset;
mobj->momy += P_RandomChance(FRACUNIT/2) ? offset : -offset;
mobj->momx += P_RandomChance(PR_DECORATION, FRACUNIT/2) ? offset : -offset;
mobj->momy += P_RandomChance(PR_DECORATION, FRACUNIT/2) ? offset : -offset;
mobj->momz += offset;
}
break;

View file

@ -53,6 +53,7 @@ UINT8 *save_p;
#define ARCHIVEBLOCK_THINKERS 0x7F37037C
#define ARCHIVEBLOCK_SPECIALS 0x7F228378
#define ARCHIVEBLOCK_WAYPOINTS 0x7F46498F
#define ARCHIVEBLOCK_RNG 0x7FAAB5BD
// Note: This cannot be bigger
// than an UINT16
@ -4483,8 +4484,6 @@ static void P_NetArchiveMisc(boolean resending)
WRITEUINT32(save_p, pig);
}
WRITEUINT32(save_p, P_GetRandSeed());
WRITEUINT32(save_p, tokenlist);
WRITEUINT8(save_p, encoremode);
@ -4638,8 +4637,6 @@ static inline boolean P_NetUnArchiveMisc(boolean reloading)
}
}
P_SetRandSeed(READUINT32(save_p));
tokenlist = READUINT32(save_p);
encoremode = (boolean)READUINT8(save_p);
@ -4816,6 +4813,35 @@ static inline boolean P_UnArchiveLuabanksAndConsistency(void)
return true;
}
static void P_NetArchiveRNG(void)
{
size_t i;
WRITEUINT32(save_p, ARCHIVEBLOCK_RNG);
for (i = 0; i < PRNUMCLASS; i++)
{
WRITEUINT32(save_p, P_GetInitSeed(i));
WRITEUINT32(save_p, P_GetRandSeed(i));
}
}
static inline void P_NetUnArchiveRNG(void)
{
size_t i;
if (READUINT32(save_p) != ARCHIVEBLOCK_RNG)
I_Error("Bad $$$.sav at archive block RNG");
for (i = 0; i < PRNUMCLASS; i++)
{
UINT32 init = READUINT32(save_p);
UINT32 seed = READUINT32(save_p);
P_SetRandSeedNet(i, init, seed);
}
}
void P_SaveGame(INT16 mapnum)
{
P_ArchiveMisc(mapnum);
@ -4860,6 +4886,8 @@ void P_SaveNetGame(boolean resending)
}
LUA_Archive(&save_p);
P_NetArchiveRNG();
P_ArchiveLuabanksAndConsistency();
}
@ -4887,9 +4915,12 @@ boolean P_LoadGame(INT16 mapoverride)
boolean P_LoadNetGame(boolean reloading)
{
CV_LoadNetVars(&save_p);
if (!P_NetUnArchiveMisc(reloading))
return false;
P_NetUnArchivePlayers();
if (gamestate == GS_LEVEL)
{
P_NetUnArchiveWorld();
@ -4902,10 +4933,10 @@ boolean P_LoadNetGame(boolean reloading)
P_RelinkPointers();
P_FinishMobjs();
}
LUA_UnArchive(&save_p);
// This is stupid and hacky, but maybe it'll work!
P_SetRandSeed(P_GetInitSeed());
P_NetUnArchiveRNG();
// The precipitation would normally be spawned in P_SetupLevel, which is called by
// P_NetUnArchiveMisc above. However, that would place it up before P_NetUnArchiveThinkers,

View file

@ -3302,9 +3302,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
INT32 result;
if (rvalue1 <= rvalue2)
result = P_RandomRange(rvalue1, rvalue2);
result = P_RandomRange(PR_EXECUTOR, rvalue1, rvalue2);
else
result = P_RandomRange(rvalue2, rvalue1);
result = P_RandomRange(PR_EXECUTOR, rvalue2, rvalue1);
P_LinedefExecute((INT16)result, mo, NULL);
break;
@ -3700,9 +3700,9 @@ static void P_ProcessLineSpecial(line_t *line, mobj_t *mo, sector_t *callsec)
{
if (line->sidenum[1] != 0xffff) // Make sure the linedef has a back side
{
x = P_RandomRange(sides[line->sidenum[0]].textureoffset>>FRACBITS, sides[line->sidenum[1]].textureoffset>>FRACBITS)<<FRACBITS;
y = P_RandomRange(sides[line->sidenum[0]].rowoffset>>FRACBITS, sides[line->sidenum[1]].rowoffset>>FRACBITS)<<FRACBITS;
z = P_RandomRange(line->frontsector->floorheight>>FRACBITS, line->frontsector->ceilingheight>>FRACBITS)<<FRACBITS;
x = P_RandomRange(PR_UNDEFINED, sides[line->sidenum[0]].textureoffset>>FRACBITS, sides[line->sidenum[1]].textureoffset>>FRACBITS)<<FRACBITS;
y = P_RandomRange(PR_UNDEFINED, sides[line->sidenum[0]].rowoffset>>FRACBITS, sides[line->sidenum[1]].rowoffset>>FRACBITS)<<FRACBITS;
z = P_RandomRange(PR_UNDEFINED, line->frontsector->floorheight>>FRACBITS, line->frontsector->ceilingheight>>FRACBITS)<<FRACBITS;
}
else
{

View file

@ -1750,12 +1750,12 @@ static void P_DoBubbleBreath(player_t *player)
if (player->charflags & SF_MACHINE)
{
if (P_RandomChance(FRACUNIT/5))
if (P_RandomChance(PR_BUBBLE, FRACUNIT/5))
{
fixed_t r = player->mo->radius>>FRACBITS;
x += (P_RandomRange(r, -r)<<FRACBITS);
y += (P_RandomRange(r, -r)<<FRACBITS);
z += (P_RandomKey(player->mo->height>>FRACBITS)<<FRACBITS);
x += (P_RandomRange(PR_BUBBLE, r, -r)<<FRACBITS);
y += (P_RandomRange(PR_BUBBLE, r, -r)<<FRACBITS);
z += (P_RandomKey(PR_BUBBLE, player->mo->height>>FRACBITS)<<FRACBITS);
bubble = P_SpawnMobj(x, y, z, MT_WATERZAP);
S_StartSound(bubble, sfx_beelec);
}
@ -1767,9 +1767,9 @@ static void P_DoBubbleBreath(player_t *player)
else
z += FixedDiv(player->mo->height,5*(FRACUNIT/4));
if (P_RandomChance(FRACUNIT/16))
if (P_RandomChance(PR_BUBBLE, FRACUNIT/16))
bubble = P_SpawnMobj(x, y, z, MT_SMALLBUBBLE);
else if (P_RandomChance(3*FRACUNIT/256))
else if (P_RandomChance(PR_BUBBLE, 3*FRACUNIT/256))
bubble = P_SpawnMobj(x, y, z, MT_MEDIUMBUBBLE);
}
@ -2382,7 +2382,7 @@ void P_MovePlayer(player_t *player)
// Little water sound while touching water - just a nicety.
if ((player->mo->eflags & MFE_TOUCHWATER) && !(player->mo->eflags & MFE_UNDERWATER) && !player->spectator)
{
if (P_RandomChance(FRACUNIT/2) && leveltime % TICRATE == 0)
if (P_RandomChance(PR_BUBBLE, FRACUNIT/2) && leveltime % TICRATE == 0)
S_StartSound(player->mo, sfx_floush);
}
@ -3718,7 +3718,7 @@ boolean P_SpectatorJoinGame(player_t *player)
else if (redscore > bluescore)
changeto = 2;
else
changeto = (P_RandomFixed() & 1) + 1;
changeto = (P_RandomFixed(PR_RULESCRAMBLE) & 1) + 1;
if (!LUA_HookTeamSwitch(player, changeto, true, false, false))
return false;

View file

@ -406,12 +406,16 @@ static void ST_drawDebugInfo(void)
if (cv_debug & DBG_RANDOMIZER) // randomizer testing
{
fixed_t peekres = P_RandomPeek();
// TODO: this only accounts for the undefined class,
// which should be phased out as much as possible anyway.
// Figure out some other way to display all of the RNG classes.
fixed_t peekres = P_RandomPeek(PR_UNDEFINED);
peekres *= 10000; // Change from fixed point
peekres >>= FRACBITS; // to displayable decimal
V_DrawRightAlignedString(320, height - 16, V_MONOSPACE, va("Init: %08x", P_GetInitSeed()));
V_DrawRightAlignedString(320, height - 8, V_MONOSPACE, va("Seed: %08x", P_GetRandSeed()));
V_DrawRightAlignedString(320, height - 16, V_MONOSPACE, va("Init: %08x", P_GetInitSeed(PR_UNDEFINED)));
V_DrawRightAlignedString(320, height - 8, V_MONOSPACE, va("Seed: %08x", P_GetRandSeed(PR_UNDEFINED)));
V_DrawRightAlignedString(320, height, V_MONOSPACE, va("== : .%04d", peekres));
height -= 32;