mirror of
https://github.com/KartKrewDev/RingRacers.git
synced 2025-10-30 08:01:28 +00:00
RNG classes, take 2
Redone version of my old branch
This commit is contained in:
parent
d0482b4905
commit
a60d4a13a1
24 changed files with 525 additions and 436 deletions
|
|
@ -5019,7 +5019,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)
|
||||
|
|
|
|||
|
|
@ -3012,7 +3012,7 @@ static void Got_Mapcmd(UINT8 **cp, INT32 playernum)
|
|||
READSTRINGN(*cp, mapname, MAX_WADPATH);
|
||||
|
||||
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.
|
||||
|
|
|
|||
41
src/g_demo.c
41
src/g_demo.c
|
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2035,7 +2043,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;
|
||||
|
|
@ -2705,7 +2716,7 @@ void G_DoPlayDemo(char *defdemoname)
|
|||
lumpnum_t l;
|
||||
char skin[17],color[MAXCOLORNAME+1],follower[17],*n,*pdemoname;
|
||||
UINT8 version,subversion;
|
||||
UINT32 randseed;
|
||||
UINT32 randseed[PRNUMCLASS];
|
||||
char msg[1024];
|
||||
|
||||
boolean spectator;
|
||||
|
|
@ -2913,7 +2924,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
|
||||
|
||||
|
|
@ -3117,7 +3131,10 @@ 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, G_BuildMapName(gamemap), true, true, false); // Doesn't matter whether you reset or not here, given changes to resetplayer.
|
||||
|
||||
for (i = 0; i < MAXPLAYERS; i++)
|
||||
|
|
@ -3622,7 +3639,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
|
||||
|
|
|
|||
10
src/g_game.c
10
src/g_game.c
|
|
@ -2546,7 +2546,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_UNDEFINED, FRACUNIT/2))) || players[playernum].ctfteam == 1) //red
|
||||
{
|
||||
if (!numredctfstarts)
|
||||
{
|
||||
|
|
@ -2557,7 +2557,7 @@ mapthing_t *G_FindTeamStart(INT32 playernum)
|
|||
|
||||
for (j = 0; j < 32; j++)
|
||||
{
|
||||
i = P_RandomKey(numredctfstarts);
|
||||
i = P_RandomKey(PR_UNDEFINED, numredctfstarts);
|
||||
if (G_CheckSpot(playernum, redctfstarts[i]))
|
||||
return redctfstarts[i];
|
||||
}
|
||||
|
|
@ -2577,7 +2577,7 @@ mapthing_t *G_FindTeamStart(INT32 playernum)
|
|||
|
||||
for (j = 0; j < 32; j++)
|
||||
{
|
||||
i = P_RandomKey(numbluectfstarts);
|
||||
i = P_RandomKey(PR_UNDEFINED, numbluectfstarts);
|
||||
if (G_CheckSpot(playernum, bluectfstarts[i]))
|
||||
return bluectfstarts[i];
|
||||
}
|
||||
|
|
@ -2598,7 +2598,7 @@ mapthing_t *G_FindBattleStart(INT32 playernum)
|
|||
{
|
||||
for (j = 0; j < 64; j++)
|
||||
{
|
||||
i = P_RandomKey(numdmstarts);
|
||||
i = P_RandomKey(PR_UNDEFINED, numdmstarts);
|
||||
if (G_CheckSpot(playernum, deathmatchstarts[i]))
|
||||
return deathmatchstarts[i];
|
||||
}
|
||||
|
|
@ -4585,7 +4585,7 @@ void G_InitNew(UINT8 pencoremode, const char *mapname, boolean resetplayer, bool
|
|||
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;
|
||||
|
|
|
|||
|
|
@ -211,7 +211,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_UNDEFINED) * 180) + angle,
|
||||
24 * mapobjectscale);
|
||||
|
||||
emerald->momz = flip * 24 * mapobjectscale;
|
||||
|
|
@ -268,8 +268,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_UNDEFINED) * 180) + angle,
|
||||
P_RandomRange(PR_UNDEFINED, 4, 12) * mapobjectscale);
|
||||
|
||||
drop->momz = flip * 12 * mapobjectscale;
|
||||
if (drop->eflags & MFE_UNDERWATER)
|
||||
|
|
@ -412,7 +412,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_UNDEFINED, 0, 359) * FRACUNIT), flip,
|
||||
firstUnspawnedEmerald
|
||||
);
|
||||
}
|
||||
|
|
@ -420,7 +420,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_UNDEFINED, 0, 359) * FRACUNIT), flip,
|
||||
0, 0
|
||||
);
|
||||
|
||||
|
|
@ -428,7 +428,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_UNDEFINED, 0, 359) * FRACUNIT), flip,
|
||||
10
|
||||
);
|
||||
}
|
||||
|
|
@ -509,7 +509,7 @@ void K_RunPaperItemSpawners(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
key = P_RandomKey(spotCount);
|
||||
key = P_RandomKey(PR_UNDEFINED, spotCount);
|
||||
}
|
||||
|
||||
r = spotMap[key];
|
||||
|
|
@ -523,7 +523,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_UNDEFINED, 0, 359) * FRACUNIT), flip,
|
||||
firstUnspawnedEmerald
|
||||
);
|
||||
}
|
||||
|
|
@ -533,7 +533,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_UNDEFINED, 0, 359) * FRACUNIT), flip,
|
||||
10
|
||||
);
|
||||
K_FlipFromObject(drop, spotList[r]);
|
||||
|
|
@ -541,7 +541,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_UNDEFINED, 0, 359) * FRACUNIT), flip,
|
||||
0, 0
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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])
|
||||
|
|
|
|||
140
src/k_kart.c
140
src/k_kart.c
|
|
@ -1086,7 +1086,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_UNDEFINED, (debtamount*FRACUNIT)/20))
|
||||
{
|
||||
K_KartGetItemResult(player, KITEM_SUPERRING);
|
||||
player->karthud[khud_itemblink] = TICRATE;
|
||||
|
|
@ -1136,7 +1136,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_UNDEFINED, totalspawnchance);
|
||||
for (i = 0; i < NUMKARTRESULTS && spawnchance[i] <= totalspawnchance; i++);
|
||||
|
||||
K_KartGetItemResult(player, i);
|
||||
|
|
@ -1720,9 +1720,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_UNDEFINED, -12, 12)*mapobjectscale),
|
||||
cury + (P_RandomRange(PR_UNDEFINED, -12, 12)*mapobjectscale),
|
||||
curz + (P_RandomRange(PR_UNDEFINED, 24, 48)*mapobjectscale),
|
||||
MT_SIGNSPARKLE);
|
||||
|
||||
if (maxdist == 0)
|
||||
|
|
@ -2191,7 +2191,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_UNDEFINED, FRACUNIT/2, FRACUNIT)),
|
||||
FixedMul(scale, player->speed));
|
||||
}
|
||||
|
||||
|
|
@ -2211,9 +2211,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_UNDEFINED,-36,36) * player->mo->scale),
|
||||
player->mo->y + (P_RandomRange(PR_UNDEFINED,-36,36) * player->mo->scale),
|
||||
player->mo->z + (player->mo->height/2) + (P_RandomRange(PR_UNDEFINED,-20,20) * player->mo->scale),
|
||||
MT_FASTLINE);
|
||||
|
||||
P_SetTarget(&fast->target, player->mo);
|
||||
|
|
@ -2261,9 +2261,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_UNDEFINED, -48, 48) * FRACUNIT,
|
||||
P_RandomRange(PR_UNDEFINED, -48, 48) * FRACUNIT,
|
||||
P_RandomRange(PR_UNDEFINED, 0, 64) * FRACUNIT,
|
||||
MT_FASTLINE);
|
||||
P_SetMobjState(fast, S_KARTINVLINES1);
|
||||
|
||||
|
|
@ -2321,9 +2321,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_UNDEFINED, -32, 32) * FRACUNIT,
|
||||
P_RandomRange(PR_UNDEFINED, -32, 32) * FRACUNIT,
|
||||
(P_RandomRange(PR_UNDEFINED, 0, 24) + (shrink ? 48 : 0)) * FRACUNIT,
|
||||
MT_GROW_PARTICLE
|
||||
);
|
||||
|
||||
|
|
@ -2849,7 +2849,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_UNDEFINED, 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))
|
||||
|
|
@ -2863,7 +2863,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_UNDEFINED, 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))
|
||||
|
|
@ -2897,7 +2897,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_UNDEFINED, 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;
|
||||
|
|
@ -4148,18 +4148,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_UNDEFINED, -radius, radius)*FRACUNIT,
|
||||
source->y + P_RandomRange(PR_UNDEFINED, -radius, radius)*FRACUNIT,
|
||||
source->z + P_RandomRange(PR_UNDEFINED, 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_UNDEFINED, -speed, speed)*FRACUNIT;
|
||||
truc->momy = P_RandomRange(PR_UNDEFINED, -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_UNDEFINED, -speed, speed)*FRACUNIT*P_MobjFlip(truc);
|
||||
if (truc->eflags & MFE_UNDERWATER)
|
||||
truc->momz = (117 * truc->momz) / 200;
|
||||
truc->color = color;
|
||||
|
|
@ -4167,30 +4167,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_UNDEFINED, -radius, radius)*FRACUNIT,
|
||||
source->y + P_RandomRange(PR_UNDEFINED, -radius, radius)*FRACUNIT,
|
||||
source->z + P_RandomRange(PR_UNDEFINED, 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_UNDEFINED, 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_UNDEFINED, -radius, radius)*FRACUNIT,
|
||||
source->y + P_RandomRange(PR_UNDEFINED, -radius, radius)*FRACUNIT,
|
||||
source->z + P_RandomRange(PR_UNDEFINED, 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_UNDEFINED, -speed, speed)*FRACUNIT;
|
||||
truc->momy = P_RandomRange(PR_UNDEFINED, -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_UNDEFINED, speed, speed2)*FRACUNIT*P_MobjFlip(truc);
|
||||
if (P_RandomChance(PR_UNDEFINED, FRACUNIT/2))
|
||||
truc->momz = -truc->momz;
|
||||
if (truc->eflags & MFE_UNDERWATER)
|
||||
truc->momz = (117 * truc->momz) / 200;
|
||||
|
|
@ -4798,9 +4798,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_UNDEFINED, -rad, rad)*FRACUNIT);
|
||||
newy = mo->y + (P_RandomRange(PR_UNDEFINED, -rad, rad)*FRACUNIT);
|
||||
newz = mo->z + (P_RandomRange(PR_UNDEFINED, 0, mo->height>>FRACBITS)*FRACUNIT);
|
||||
|
||||
sparkle = P_SpawnMobj(newx, newy, newz, MT_SPARKLETRAIL);
|
||||
|
||||
|
|
@ -4810,8 +4810,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_UNDEFINED, 0, 1) ? 1 : -1; // Rotation direction?
|
||||
sparkle->cvmem = P_RandomRange(PR_UNDEFINED, -25, 25)*mo->scale; // Vertical "angle"
|
||||
|
||||
K_FlipFromObject(sparkle, mo);
|
||||
P_SetTarget(&sparkle->target, mo);
|
||||
|
|
@ -4849,8 +4849,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_UNDEFINED,-8,8) << FRACBITS),
|
||||
mo->y + FixedMul(24*mo->scale, FINESINE(aoff>>ANGLETOFINESHIFT)) + (P_RandomRange(PR_UNDEFINED,-8,8) << FRACBITS),
|
||||
mo->z, MT_WIPEOUTTRAIL);
|
||||
|
||||
P_SetTarget(&dust->target, mo);
|
||||
|
|
@ -4988,13 +4988,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_UNDEFINED, -spawnrange, spawnrange) << FRACBITS;
|
||||
fixed_t spawny = P_RandomRange(PR_UNDEFINED, -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_UNDEFINED, -speedrange, speedrange) * spawner->scale), 3*FRACUNIT/4);
|
||||
dust->momy = FixedMul(spawner->momy + (P_RandomRange(PR_UNDEFINED, -speedrange, speedrange) * spawner->scale), 3*FRACUNIT/4);
|
||||
dust->momz = P_MobjFlip(spawner) * (P_RandomRange(PR_UNDEFINED, 1, 4) * (spawner->scale));
|
||||
P_SetScale(dust, spawner->scale/2);
|
||||
dust->destscale = spawner->scale * 3;
|
||||
dust->scalespeed = spawner->scale/12;
|
||||
|
|
@ -5456,8 +5456,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_UNDEFINED, 0, 359)*ANG1);
|
||||
mo->fuse = P_RandomRange(PR_UNDEFINED, 20, 50);
|
||||
P_SetTarget(&mo->target, player->mo);
|
||||
P_SetMobjState(mo, S_KLIT1);
|
||||
}
|
||||
|
|
@ -5496,8 +5496,8 @@ 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_UNDEFINED, 135, 225)<<FRACBITS), P_RandomRange(PR_UNDEFINED, 0, 8) * src->scale);
|
||||
smoke->momz += P_RandomRange(PR_UNDEFINED, 0, 4) * src->scale;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5508,7 +5508,7 @@ static void K_DoHyudoroSteal(player_t *player)
|
|||
INT32 playerswappable[MAXPLAYERS];
|
||||
INT32 stealplayer = -1; // The player that's getting stolen from
|
||||
INT32 prandom = 0;
|
||||
boolean sink = P_RandomChance(FRACUNIT/64);
|
||||
boolean sink = P_RandomChance(PR_UNDEFINED, FRACUNIT/64);
|
||||
INT32 hyu = hyudorotime;
|
||||
|
||||
if (gametype == GT_RACE)
|
||||
|
|
@ -5533,7 +5533,7 @@ static void K_DoHyudoroSteal(player_t *player)
|
|||
}
|
||||
}
|
||||
|
||||
prandom = P_RandomFixed();
|
||||
prandom = P_RandomFixed(PR_UNDEFINED);
|
||||
S_StartSound(player->mo, sfx_s3k92);
|
||||
|
||||
if (sink && numplayers > 0 && cv_kitchensink.value) // BEHOLD THE KITCHEN SINK
|
||||
|
|
@ -6079,7 +6079,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_UNDEFINED) * 180) + angle,
|
||||
16*mapobjectscale);
|
||||
|
||||
drop->momz = flip * 3 * mapobjectscale;
|
||||
|
|
@ -6113,7 +6113,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_UNDEFINED, totalspawnchance);
|
||||
for (i = 0; i < NUMKARTRESULTS && spawnchance[i] <= totalspawnchance; i++);
|
||||
|
||||
// TODO: this is bad!
|
||||
|
|
@ -6635,7 +6635,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;
|
||||
|
|
@ -7213,7 +7213,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_UNDEFINED,0,7) * ANGLE_45, 2 * thing->scale);
|
||||
P_SetObjectMomZ(thing, 8<<FRACBITS, false);
|
||||
thing->fuse = 120*TICRATE;
|
||||
|
||||
|
|
@ -7410,9 +7410,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_UNDEFINED, -40, 40) * player->mo->scale;
|
||||
fixed_t randy = P_RandomRange(PR_UNDEFINED, -40, 40) * player->mo->scale;
|
||||
fixed_t randz = P_RandomRange(PR_UNDEFINED, 0, player->mo->height >> FRACBITS) << FRACBITS;
|
||||
mobj_t *star = P_SpawnMobj(
|
||||
player->mo->x + randx,
|
||||
player->mo->y + randy,
|
||||
|
|
@ -9142,8 +9142,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_UNDEFINED, -48, 48)*p->mo->scale;
|
||||
sy = p->mo->y + P_RandomRange(PR_UNDEFINED, -48, 48)*p->mo->scale;
|
||||
|
||||
spdl = P_SpawnMobj(sx, sy, p->mo->z, MT_DOWNLINE);
|
||||
spdl->colorized = true;
|
||||
|
|
@ -9225,8 +9225,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_UNDEFINED, 6, 12) * parent->scale;
|
||||
fixed_t vmomentum = P_RandomRange(PR_UNDEFINED, 2, 6) * parent->scale;
|
||||
|
||||
angle_t ang = parent->player->drawangle + ANGLE_180;
|
||||
SINT8 flip = 1;
|
||||
|
|
@ -9254,9 +9254,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_UNDEFINED,-36,36) * FRACUNIT,
|
||||
P_RandomRange(PR_UNDEFINED,-36,36) * FRACUNIT,
|
||||
FixedDiv(parent->height / 2, parent->scale) + (P_RandomRange(PR_UNDEFINED,-20,20) * FRACUNIT),
|
||||
MT_SPINDASHWIND
|
||||
);
|
||||
|
||||
|
|
@ -10386,9 +10386,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_UNDEFINED, -24, 24)*player->mo->scale;
|
||||
sy = player->mo->y + P_RandomRange(PR_UNDEFINED, -24, 24)*player->mo->scale;
|
||||
sz = player->mo->z + P_RandomRange(PR_UNDEFINED, 0, 48)*player->mo->scale;
|
||||
|
||||
spdl = P_SpawnMobj(sx, sy, sz, MT_FASTLINE);
|
||||
P_SetTarget(&spdl->target, player->mo);
|
||||
|
|
|
|||
|
|
@ -4205,17 +4205,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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -515,26 +515,26 @@ void K_SetPowerLevelScrambles(SINT8 powertype)
|
|||
{
|
||||
case 5:
|
||||
speed = KARTSPEED_HARD;
|
||||
encore = P_RandomChance(FRACUNIT>>1);
|
||||
encore = P_RandomChance(PR_UNDEFINED, FRACUNIT>>1);
|
||||
break;
|
||||
case 4:
|
||||
speed = P_RandomChance((7<<FRACBITS)/10) ? KARTSPEED_HARD : KARTSPEED_NORMAL;
|
||||
encore = P_RandomChance(FRACUNIT>>1);
|
||||
speed = P_RandomChance(PR_UNDEFINED, (7<<FRACBITS)/10) ? KARTSPEED_HARD : KARTSPEED_NORMAL;
|
||||
encore = P_RandomChance(PR_UNDEFINED, FRACUNIT>>1);
|
||||
break;
|
||||
case 3:
|
||||
speed = P_RandomChance((3<<FRACBITS)/10) ? KARTSPEED_HARD : KARTSPEED_NORMAL;
|
||||
encore = P_RandomChance(FRACUNIT>>2);
|
||||
speed = P_RandomChance(PR_UNDEFINED, (3<<FRACBITS)/10) ? KARTSPEED_HARD : KARTSPEED_NORMAL;
|
||||
encore = P_RandomChance(PR_UNDEFINED, FRACUNIT>>2);
|
||||
break;
|
||||
case 2:
|
||||
speed = KARTSPEED_NORMAL;
|
||||
encore = P_RandomChance(FRACUNIT>>3);
|
||||
encore = P_RandomChance(PR_UNDEFINED, 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_UNDEFINED, (3<<FRACBITS)/10) ? KARTSPEED_EASY : KARTSPEED_NORMAL;
|
||||
encore = false;
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -539,7 +539,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_UNDEFINED, 0, ANGLE_MAX);
|
||||
}
|
||||
|
||||
dust = P_SpawnMobjFromMobj(
|
||||
|
|
@ -668,20 +668,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_UNDEFINED, 0, fs->cone / ANG1) * ANG1;
|
||||
pushAngle -= P_RandomRange(PR_UNDEFINED, 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_UNDEFINED, 0, fs->cone / ANG1) * ANG1;
|
||||
pushAngle += P_RandomRange(PR_UNDEFINED, 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_UNDEFINED, -fs->spread / FRACUNIT, fs->spread / FRACUNIT) * FRACUNIT;
|
||||
yOff = P_RandomRange(PR_UNDEFINED, -fs->spread / FRACUNIT, fs->spread / FRACUNIT) * FRACUNIT;
|
||||
}
|
||||
|
||||
dust = P_SpawnMobjFromMobj(
|
||||
|
|
|
|||
|
|
@ -398,10 +398,13 @@ static int lib_mMapNumber(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;
|
||||
}
|
||||
|
|
@ -409,7 +412,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;
|
||||
}
|
||||
|
|
@ -421,7 +424,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;
|
||||
}
|
||||
|
|
@ -439,7 +442,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;
|
||||
}
|
||||
|
|
@ -448,7 +451,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;
|
||||
}
|
||||
|
|
@ -457,7 +460,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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
117
src/m_random.c
117
src/m_random.c
|
|
@ -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,59 @@ 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.
|
||||
*
|
||||
* \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;
|
||||
}
|
||||
|
||||
/** Initializes random seeds for all classes.
|
||||
* Used at the beginning of the 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 +281,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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,11 @@
|
|||
|
||||
//#define DEBUGRANDOM
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PR_UNDEFINED, // Before release, cases of this RNG class should be removed, only kept as the default for Lua.
|
||||
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 +37,46 @@ 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 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 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)
|
||||
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);
|
||||
#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);
|
||||
#endif
|
||||
|
||||
void P_ClearRandom(UINT32 seed);
|
||||
UINT32 M_RandomizedSeed(void);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -332,8 +332,8 @@ static void ShrinkLaserThinker(mobj_t *pohbee, mobj_t *gun, mobj_t *laser)
|
|||
|
||||
particle = P_SpawnMobjFromMobj(
|
||||
laser,
|
||||
P_RandomRange(-16, 16) * FRACUNIT,
|
||||
P_RandomRange(-16, 16) * FRACUNIT,
|
||||
P_RandomRange(PR_UNDEFINED, -16, 16) * FRACUNIT,
|
||||
P_RandomRange(PR_UNDEFINED, -16, 16) * FRACUNIT,
|
||||
0,
|
||||
MT_SHRINK_PARTICLE
|
||||
);
|
||||
|
|
@ -694,7 +694,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_UNDEFINED, GUN_SWINGTIME);
|
||||
|
||||
overlay = P_SpawnMobjFromMobj(gun, 0, 0, 0, MT_OVERLAY);
|
||||
|
||||
|
|
|
|||
236
src/p_enemy.c
236
src/p_enemy.c
|
|
@ -478,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;
|
||||
|
|
@ -575,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;
|
||||
}
|
||||
|
||||
|
|
@ -626,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];
|
||||
|
|
@ -664,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++)
|
||||
{
|
||||
|
|
@ -719,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;
|
||||
|
||||
|
|
@ -1013,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)
|
||||
|
|
@ -2132,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;
|
||||
|
|
@ -2298,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;
|
||||
|
|
@ -2934,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);
|
||||
}
|
||||
|
|
@ -3134,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;
|
||||
|
|
@ -3150,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;
|
||||
|
|
@ -3168,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++)
|
||||
{
|
||||
|
|
@ -3272,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_UNDEFINED, 360)*FRACUNIT)>>ANGLETOFINESHIFT) & FINEMASK;
|
||||
else
|
||||
{
|
||||
actor->movecount += 4*16;
|
||||
|
|
@ -3289,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_UNDEFINED, (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_UNDEFINED)<<(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_UNDEFINED)<<(FRACBITS-2)) - 8*FRACUNIT, actor->scale);
|
||||
|
||||
mo = P_SpawnMobj(x, y, z, explodetype);
|
||||
if (actor->eflags & MFE_VERTICALFLIP)
|
||||
|
|
@ -3810,7 +3810,7 @@ void A_BubbleSpawn(mobj_t *actor)
|
|||
return; // don't make bubble!
|
||||
}
|
||||
|
||||
prandom = P_RandomByte();
|
||||
prandom = P_RandomByte(PR_UNDEFINED);
|
||||
|
||||
if (leveltime % (3*TICRATE) < 8)
|
||||
bubble = P_SpawnMobj(actor->x, actor->y, actor->z + (actor->height / 2), MT_EXTRALARGEBUBBLE);
|
||||
|
|
@ -3858,7 +3858,7 @@ void A_FanBubbleSpawn(mobj_t *actor)
|
|||
return; // don't make bubble!
|
||||
}
|
||||
|
||||
prandom = P_RandomByte();
|
||||
prandom = P_RandomByte(PR_UNDEFINED);
|
||||
|
||||
if ((prandom & 0x7) == 0x7)
|
||||
bubble = P_SpawnMobj(actor->x, actor->y, hz, MT_SMALLBUBBLE);
|
||||
|
|
@ -3898,7 +3898,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_UNDEFINED);
|
||||
if (!(prandom & 0x7)) // *****000
|
||||
{
|
||||
P_InstaThrust(actor, prandom & 0x70 ? actor->angle + ANGLE_90 : actor->angle,
|
||||
|
|
@ -4106,7 +4106,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_UNDEFINED,0,7) * ANGLE_45, 2<<FRACBITS);
|
||||
newring->momz = 8<<FRACBITS;
|
||||
newring->fuse = 120*TICRATE;
|
||||
P_RemoveMobj(actor);
|
||||
|
|
@ -4116,7 +4116,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_UNDEFINED,0,7) * ANGLE_45, 2 * actor->scale);
|
||||
P_SetObjectMomZ(actor, 8<<FRACBITS, false);
|
||||
actor->fuse = 120*TICRATE;
|
||||
#endif
|
||||
|
|
@ -4205,7 +4205,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);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -4245,7 +4245,7 @@ void A_SetSolidSteam(mobj_t *actor)
|
|||
|
||||
if (!(actor->flags2 & MF2_AMBUSH))
|
||||
{
|
||||
if (P_RandomChance(FRACUNIT/8))
|
||||
if (P_RandomChance(PR_UNDEFINED, FRACUNIT/8))
|
||||
{
|
||||
if (actor->info->deathsound)
|
||||
S_StartSound(actor, actor->info->deathsound); // Hiss!
|
||||
|
|
@ -4357,7 +4357,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;
|
||||
|
|
@ -4598,8 +4598,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;
|
||||
|
||||
|
|
@ -4792,7 +4792,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);
|
||||
|
|
@ -4841,7 +4841,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;
|
||||
|
|
@ -5248,7 +5248,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_UNDEFINED) * (FRACUNIT/32);
|
||||
else
|
||||
randomoomph = 0;
|
||||
|
||||
|
|
@ -5410,7 +5410,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);
|
||||
}
|
||||
|
||||
|
|
@ -5425,8 +5425,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)
|
||||
{
|
||||
|
|
@ -5454,7 +5454,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)
|
||||
|
|
@ -5475,8 +5475,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
|
||||
}
|
||||
|
|
@ -5796,7 +5796,7 @@ void A_MixUp(mobj_t *actor)
|
|||
{
|
||||
if (counter > 255) // fail-safe to avoid endless loop
|
||||
break;
|
||||
prandom = P_RandomByte();
|
||||
prandom = P_RandomByte(PR_UNDEFINED);
|
||||
prandom %= numplayers; // I love modular arithmetic, don't you?
|
||||
if (prandom) // Make sure it's not a useless mix
|
||||
break;
|
||||
|
|
@ -5914,7 +5914,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);
|
||||
|
|
@ -5936,7 +5936,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
|
||||
|
|
@ -5974,7 +5974,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -5999,13 +5999,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));
|
||||
|
|
@ -6092,12 +6092,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;
|
||||
|
|
@ -6231,8 +6231,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);
|
||||
|
|
@ -6270,10 +6270,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.
|
||||
|
|
@ -6310,10 +6310,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!
|
||||
|
|
@ -7121,7 +7121,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_UNDEFINED) & 3;
|
||||
if (th->tics < 1)
|
||||
th->tics = 1;
|
||||
}
|
||||
|
|
@ -7219,7 +7219,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);
|
||||
|
|
@ -7238,7 +7238,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_UNDEFINED, amin, amax));
|
||||
}
|
||||
|
||||
// Function: A_ChangeAngleAbsolute
|
||||
|
|
@ -7252,7 +7252,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);
|
||||
|
|
@ -7271,7 +7271,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_UNDEFINED, amin, amax));
|
||||
}
|
||||
|
||||
// Function: A_RollAngle
|
||||
|
|
@ -7320,7 +7320,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_UNDEFINED, amin, amax));
|
||||
}
|
||||
|
||||
// Function: A_ChangeRollAngleAbsolute
|
||||
|
|
@ -7345,7 +7345,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_UNDEFINED, amin, amax));
|
||||
}
|
||||
|
||||
// Function: A_PlaySound
|
||||
|
|
@ -7535,7 +7535,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_UNDEFINED, locvar1, locvar2);
|
||||
}
|
||||
|
||||
// Function: A_ChangeColorRelative
|
||||
|
|
@ -7980,7 +7980,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_UNDEFINED, FRACUNIT/2) ? locvar1 : locvar2);
|
||||
}
|
||||
|
||||
// Function: A_RandomStateRange
|
||||
|
|
@ -7998,7 +7998,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_UNDEFINED, locvar1, locvar2));
|
||||
}
|
||||
|
||||
// Function: A_StateRangeByAngle
|
||||
|
|
@ -8570,8 +8570,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)
|
||||
{
|
||||
|
|
@ -8752,7 +8752,7 @@ void A_CheckRandom(mobj_t *actor)
|
|||
chance *= (locvar1 >> 16);
|
||||
chance /= (locvar1 & 0xFFFF);
|
||||
|
||||
if (P_RandomChance(chance))
|
||||
if (P_RandomChance(PR_UNDEFINED, chance))
|
||||
P_SetMobjState(actor, locvar2);
|
||||
}
|
||||
|
||||
|
|
@ -10052,7 +10052,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);
|
||||
|
|
@ -10084,7 +10084,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);
|
||||
}
|
||||
|
|
@ -10352,7 +10352,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];
|
||||
}
|
||||
}
|
||||
|
|
@ -10374,8 +10374,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)
|
||||
|
|
@ -10438,7 +10438,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
|
||||
}
|
||||
|
|
@ -10515,7 +10515,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;
|
||||
|
|
@ -10607,7 +10607,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;
|
||||
}
|
||||
|
||||
|
|
@ -10631,9 +10631,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;
|
||||
}
|
||||
}
|
||||
|
|
@ -10805,9 +10805,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);
|
||||
}
|
||||
|
||||
|
|
@ -10936,9 +10936,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_UNDEFINED, rad, -rad)<<FRACBITS,
|
||||
P_RandomRange(PR_UNDEFINED, rad, -rad)<<FRACBITS,
|
||||
P_RandomRange(PR_UNDEFINED, hei/2, hei)<<FRACBITS,
|
||||
type);
|
||||
P_SetObjectMomZ(particle, 2<<FRACBITS, false);
|
||||
}
|
||||
|
|
@ -11072,20 +11072,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_UNDEFINED)*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_UNDEFINED)*FINESINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/128;
|
||||
actor->momy = (P_SignedRandom(PR_UNDEFINED)*FINECOSINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/128;
|
||||
actor->momz = (P_SignedRandom(PR_UNDEFINED)*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_UNDEFINED)*FINESINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/2,
|
||||
actor->spawnpoint->y*FRACUNIT + (P_SignedRandom(PR_UNDEFINED)*FINECOSINE(((actor->spawnpoint->angle*ANG1)>>ANGLETOFINESHIFT) & FINEMASK))/2,
|
||||
actor->spawnpoint->z*FRACUNIT + (P_SignedRandom(PR_UNDEFINED)*FRACUNIT)/2);
|
||||
}
|
||||
|
||||
// Function: A_MineExplode
|
||||
|
|
@ -11124,9 +11124,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_UNDEFINED, -dist, dist)*FRACUNIT,
|
||||
actor->y+P_RandomRange(PR_UNDEFINED, -dist, dist)*FRACUNIT,
|
||||
actor->z+P_RandomRange(PR_UNDEFINED, ((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));
|
||||
|
|
@ -11613,7 +11613,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)
|
||||
|
|
@ -11787,7 +11787,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;
|
||||
|
||||
|
|
@ -11997,7 +11997,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);
|
||||
|
|
@ -12007,7 +12007,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))
|
||||
|
|
@ -12086,10 +12086,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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -12276,7 +12276,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);
|
||||
|
|
@ -12595,7 +12595,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)
|
||||
|
|
@ -12694,7 +12694,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);
|
||||
|
|
@ -12754,8 +12754,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);
|
||||
|
|
@ -13388,17 +13388,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_UNDEFINED, -8, 8)*FRACUNIT, actor->y + P_RandomRange(PR_UNDEFINED, -8, 8)*FRACUNIT,
|
||||
actor->z + P_RandomRange(PR_UNDEFINED, 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_UNDEFINED, -speed, speed)*FRACUNIT;
|
||||
truc->momy = P_RandomRange(PR_UNDEFINED, -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_UNDEFINED, speed, speed2)*FRACUNIT;
|
||||
truc->tics = TICRATE*2;
|
||||
truc->color = SKINCOLOR_KETCHUP;
|
||||
|
||||
|
|
@ -13505,9 +13505,9 @@ static void SpawnSPBAIZDust(mobj_t *mo, INT32 dir)
|
|||
// Used for seeking and when SPB is trailing its target from way too close!
|
||||
static void SpawnSPBSpeedLines(mobj_t *actor)
|
||||
{
|
||||
mobj_t *fast = P_SpawnMobj(actor->x + (P_RandomRange(-24,24) * actor->scale),
|
||||
actor->y + (P_RandomRange(-24,24) * actor->scale),
|
||||
actor->z + (actor->height/2) + (P_RandomRange(-24,24) * actor->scale),
|
||||
mobj_t *fast = P_SpawnMobj(actor->x + (P_RandomRange(PR_UNDEFINED,-24,24) * actor->scale),
|
||||
actor->y + (P_RandomRange(PR_UNDEFINED,-24,24) * actor->scale),
|
||||
actor->z + (actor->height/2) + (P_RandomRange(PR_UNDEFINED,-24,24) * actor->scale),
|
||||
MT_FASTLINE);
|
||||
|
||||
P_SetTarget(&fast->target, actor);
|
||||
|
|
@ -13988,8 +13988,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_UNDEFINED, -3, 3)*actor->scale/2;
|
||||
expl->momy = P_RandomRange(PR_UNDEFINED, -3, 3)*actor->scale/2;
|
||||
|
||||
// 100/45 = 2.22 fu/t
|
||||
expl->momz = ((i+1)*actor->scale*5/2)*P_MobjFlip(expl);
|
||||
|
|
@ -14073,11 +14073,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_UNDEFINED, -rad, rad)*actor->scale), actor->y + (P_RandomRange(PR_UNDEFINED, -rad, rad)*actor->scale),
|
||||
actor->z + (P_RandomRange(PR_UNDEFINED, 0, 72)*actor->scale), MT_THOK);
|
||||
|
||||
P_SetMobjState(smoke, S_FZEROSMOKE1);
|
||||
smoke->tics += P_RandomRange(-3, 4);
|
||||
smoke->tics += P_RandomRange(PR_UNDEFINED, -3, 4);
|
||||
smoke->scale = actor->scale*3;
|
||||
}
|
||||
return;
|
||||
|
|
@ -14097,7 +14097,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_UNDEFINED, 0, 6);
|
||||
P_SetScale(fake, FRACUNIT*3/2);
|
||||
fake->scale = FRACUNIT*3/2;
|
||||
fake->destscale = FRACUNIT*3/2;
|
||||
|
|
@ -14200,7 +14200,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_UNDEFINED, 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)
|
||||
|
|
@ -14240,7 +14240,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_UNDEFINED, -256, 256)<<FRACBITS), actor->y + (P_RandomRange(PR_UNDEFINED, -256, 256)<<FRACBITS), actor->z + (P_RandomRange(PR_UNDEFINED, 48, 256)<<FRACBITS), MT_MEMENTOSPARTICLE);
|
||||
particle->frame = 0;
|
||||
particle->color = ((i%2) ? (SKINCOLOR_RED) : (SKINCOLOR_BLACK));
|
||||
particle->destscale = 1;
|
||||
|
|
@ -14303,7 +14303,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_UNDEFINED, -60, 60)<<FRACBITS), actor->y + (P_RandomRange(PR_UNDEFINED, -60, 60)<<FRACBITS), actor->z, MT_THOK);
|
||||
particle->momz = 20<<FRACBITS;
|
||||
particle->color = ((i%2 !=0) ? (SKINCOLOR_RED) : (SKINCOLOR_BLACK));
|
||||
particle->frame = 0;
|
||||
|
|
|
|||
|
|
@ -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_UNDEFINED, 36)*ANG10; // irrelevant for default objects but might make sense for some custom ones
|
||||
|
||||
if (flags & ML_EFFECT1)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -447,8 +447,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_UNDEFINED, 1,8)*special->scale);
|
||||
P_SetObjectMomZ(firework, P_RandomRange(PR_UNDEFINED, 1,8)*special->scale, false);
|
||||
firework->color = toucher->color;
|
||||
}
|
||||
|
||||
|
|
@ -567,7 +567,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_UNDEFINED, special->info->mass)));
|
||||
}
|
||||
return;
|
||||
|
||||
|
|
@ -1205,7 +1205,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);
|
||||
|
|
@ -1294,7 +1294,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_UNDEFINED) & 1)
|
||||
{
|
||||
flingAngle -= ANGLE_45;
|
||||
}
|
||||
|
|
@ -1337,7 +1337,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_UNDEFINED));
|
||||
INT16 spacing = (target->radius >> 1) / target->scale;
|
||||
|
||||
// set respawn fuse
|
||||
|
|
@ -1362,9 +1362,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_UNDEFINED, -spacing, spacing) * FRACUNIT,
|
||||
P_RandomRange(PR_UNDEFINED, -spacing, spacing) * FRACUNIT,
|
||||
P_RandomRange(PR_UNDEFINED, 0, 4*spacing) * FRACUNIT,
|
||||
MT_SPINDASHDUST
|
||||
);
|
||||
|
||||
|
|
@ -1644,7 +1644,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_UNDEFINED, FRACUNIT/2);
|
||||
|
||||
#define makechunk(angtweak, xmov, ymov) \
|
||||
chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_WALLSPIKE);\
|
||||
|
|
@ -1657,7 +1657,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_UNDEFINED, 5, 7)*scale;\
|
||||
if (flip)\
|
||||
chunk->momz *= -1;\
|
||||
if (sprflip)\
|
||||
|
|
@ -1670,7 +1670,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_UNDEFINED, FRACUNIT/2);
|
||||
|
||||
chunk = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_WALLSPIKE);
|
||||
|
||||
|
|
@ -1683,7 +1683,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_UNDEFINED, 5, 7)*scale;
|
||||
if (flip)
|
||||
chunk->momz *= -1;
|
||||
if (sprflip)
|
||||
|
|
@ -1697,7 +1697,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_UNDEFINED, 5, 7)*scale;
|
||||
if (flip)
|
||||
target->momz *= -1;
|
||||
if (!sprflip)
|
||||
|
|
@ -2244,7 +2244,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_UNDEFINED) & 1) ? -ANGLE_90 : ANGLE_90);
|
||||
|
||||
for (i = 0; i < num_fling_rings; i++)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
162
src/p_mobj.c
162
src/p_mobj.c
|
|
@ -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_UNDEFINED, 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_UNDEFINED, 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_UNDEFINED, FRACUNIT/2))
|
||||
frame = numframes/2;
|
||||
else
|
||||
frame = 0;
|
||||
|
|
@ -2485,12 +2485,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_UNDEFINED, 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_UNDEFINED, FRACUNIT/2))
|
||||
mom.y += FixedMul(6*FRACUNIT, mo->scale);
|
||||
else
|
||||
mom.y -= FixedMul(6*FRACUNIT, mo->scale);
|
||||
|
|
@ -2513,7 +2513,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_UNDEFINED, mo->info->reactiontime));
|
||||
|
||||
mom.z /= 2; // Rocks not so bouncy
|
||||
|
||||
|
|
@ -2920,7 +2920,7 @@ boolean P_SceneryZMovement(mobj_t *mo)
|
|||
|
||||
for (i = 0; i < 4; ++i) // split into four
|
||||
{
|
||||
prandom = P_RandomByte();
|
||||
prandom = P_RandomByte(PR_UNDEFINED);
|
||||
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);
|
||||
|
|
@ -2929,7 +2929,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_UNDEFINED, 5));
|
||||
//note that we assign the bubble sound to one of the new bubbles.
|
||||
// in other words, IT ACTUALLY GETS USED YAAAAAAAY
|
||||
|
||||
|
|
@ -2952,7 +2952,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)
|
||||
{
|
||||
|
|
@ -3315,10 +3315,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_UNDEFINED);
|
||||
prandom[1] = P_RandomByte(PR_UNDEFINED);
|
||||
prandom[2] = P_RandomByte(PR_UNDEFINED);
|
||||
prandom[3] = P_RandomByte(PR_UNDEFINED);
|
||||
|
||||
bubbletype = MT_SMALLBUBBLE;
|
||||
if (!(prandom[0] & 0x3)) // medium bubble chance up to 64 from 32
|
||||
|
|
@ -4249,7 +4249,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)
|
||||
|
|
@ -4324,7 +4324,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;
|
||||
}
|
||||
|
||||
|
|
@ -5345,7 +5345,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_UNDEFINED, 36)*ANG10; // irrelevant for default objects but might make sense for some custom ones
|
||||
|
||||
mobj->angle += mobj->movedir;
|
||||
}
|
||||
|
|
@ -5456,7 +5456,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_UNDEFINED, mobj->info->mass));
|
||||
return;
|
||||
}
|
||||
break;
|
||||
|
|
@ -5609,22 +5609,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_UNDEFINED, -35, 35)*mobj->scale;
|
||||
fixed_t y = P_RandomRange(PR_UNDEFINED, -35, 35)*mobj->scale;
|
||||
fixed_t z = P_RandomRange(PR_UNDEFINED, 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_UNDEFINED, 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_UNDEFINED, -16, 16)*mobj->scale;
|
||||
fixed_t y = P_RandomRange(PR_UNDEFINED, -16, 16)*mobj->scale;
|
||||
fixed_t z = P_RandomRange(PR_UNDEFINED, 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);
|
||||
|
|
@ -5709,9 +5709,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_UNDEFINED, -spacing, spacing) * FRACUNIT,
|
||||
P_RandomRange(PR_UNDEFINED, -spacing, spacing) * FRACUNIT,
|
||||
P_RandomRange(PR_UNDEFINED, -spacing, spacing) * FRACUNIT,
|
||||
MT_BATTLEBUMPER_DEBRIS
|
||||
);
|
||||
|
||||
|
|
@ -5740,9 +5740,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_UNDEFINED, -spacing, spacing) * FRACUNIT,
|
||||
P_RandomRange(PR_UNDEFINED, -spacing, spacing) * FRACUNIT,
|
||||
P_RandomRange(PR_UNDEFINED, -spacing, spacing) * FRACUNIT,
|
||||
MT_SPINDASHDUST
|
||||
);
|
||||
|
||||
|
|
@ -6310,9 +6310,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);
|
||||
}
|
||||
|
|
@ -6405,9 +6405,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_UNDEFINED, -amt, amt) * mobj->scale;
|
||||
fixed_t yoffset = P_RandomRange(PR_UNDEFINED, -amt, amt) * mobj->scale;
|
||||
fixed_t zoffset = P_RandomRange(PR_UNDEFINED, -(amt >> 1), (amt >> 1)) * mobj->scale;
|
||||
|
||||
dust = P_SpawnMobj(mobj->x + xoffset, mobj->y + yoffset,
|
||||
mobj->z + (mobj->height >> 1) + zoffset, MT_EXPLODE);
|
||||
|
|
@ -7063,9 +7063,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_UNDEFINED, -48, 48) * FRACUNIT,
|
||||
P_RandomRange(PR_UNDEFINED, -48, 48) * FRACUNIT,
|
||||
P_RandomRange(PR_UNDEFINED, 0, 64) * FRACUNIT,
|
||||
MT_EMERALDSPARK
|
||||
);
|
||||
|
||||
|
|
@ -7301,7 +7301,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_UNDEFINED, 135, 225)<<FRACBITS), P_RandomRange(PR_UNDEFINED, 0, 8) * mobj->target->scale);
|
||||
}
|
||||
break;
|
||||
case MT_INVULNFLASH:
|
||||
|
|
@ -7758,9 +7758,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_UNDEFINED, -36,36) * mobj->scale),
|
||||
mobj->y + (P_RandomRange(PR_UNDEFINED, -36,36) * mobj->scale),
|
||||
mobj->z + (mobj->height/2) + (P_RandomRange(PR_UNDEFINED, -20,20) * mobj->scale),
|
||||
MT_FASTLINE);
|
||||
|
||||
P_InitAngle(fast, mobj->angle);
|
||||
|
|
@ -8022,7 +8022,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_UNDEFINED, plistlen)]];
|
||||
newskin = ((skin_t*)p->mo->skin) - skins;
|
||||
newcolor = p->skincolor;
|
||||
}
|
||||
|
|
@ -8094,7 +8094,7 @@ static boolean P_MobjRegularThink(mobj_t *mobj)
|
|||
mobj->movecount = 3;
|
||||
|
||||
{
|
||||
angle_t facing = P_RandomRange(0, 90);
|
||||
angle_t facing = P_RandomRange(PR_UNDEFINED, 0, 90);
|
||||
if (facing >= 45)
|
||||
facing = InvAngle((facing - 45)*ANG1);
|
||||
else
|
||||
|
|
@ -8127,23 +8127,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_UNDEFINED, -32, 32)*mobj->scale), mobj->y + (P_RandomRange(PR_UNDEFINED, -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_UNDEFINED, 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_UNDEFINED, -16, 16)*mobj->scale), mobj->y + (P_RandomRange(PR_UNDEFINED, -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_UNDEFINED, 3, 10)*mobj->scale;
|
||||
smoke->destscale = mobj->scale*4;
|
||||
smoke->scalespeed = mobj->scale/24;
|
||||
}
|
||||
|
|
@ -8200,7 +8200,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);
|
||||
}
|
||||
|
|
@ -8330,7 +8330,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)
|
||||
|
|
@ -8363,11 +8363,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);
|
||||
|
|
@ -8481,7 +8481,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;
|
||||
|
|
@ -8570,7 +8570,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;
|
||||
}
|
||||
|
|
@ -8639,7 +8639,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_UNDEFINED, -abs(mobj->cvmem), abs(mobj->cvmem))<<FRACBITS));
|
||||
|
||||
if (mobj->movecount > 4*TICRATE)
|
||||
{
|
||||
|
|
@ -9140,7 +9140,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
|
||||
|
|
@ -9256,9 +9256,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_UNDEFINED, 0,360)<<FRACBITS));
|
||||
P_InstaThrust(debris, debris->angle, P_RandomRange(PR_UNDEFINED, 3,18)*(FRACUNIT/4));
|
||||
debris->momz = P_RandomRange(PR_UNDEFINED, 4,8)<<FRACBITS;
|
||||
if (!i) // kinda hacky :V
|
||||
S_StartSound(debris, sfx_s3k82);
|
||||
}
|
||||
|
|
@ -10126,7 +10126,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:
|
||||
{
|
||||
|
|
@ -10138,7 +10138,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_UNDEFINED, sizeof(BALLOONCOLORS))];
|
||||
}
|
||||
break;
|
||||
case MT_POGOSPRING:
|
||||
|
|
@ -10148,8 +10148,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_UNDEFINED, 13);
|
||||
mobj->color = FIRSTRAINBOWCOLOR + P_RandomKey(PR_UNDEFINED, FIRSTSUPERCOLOR - FIRSTRAINBOWCOLOR);
|
||||
break;
|
||||
case MT_HIVEELEMENTAL:
|
||||
mobj->extravalue1 = 5;
|
||||
|
|
@ -10245,15 +10245,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_UNDEFINED, FRACUNIT/3))
|
||||
mobj->threshold = KITEM_SUPERRING;
|
||||
else if (P_RandomChance(FRACUNIT/3))
|
||||
else if (P_RandomChance(PR_UNDEFINED, FRACUNIT/3))
|
||||
mobj->threshold = KITEM_SPB;
|
||||
else if (P_RandomChance(FRACUNIT/3))
|
||||
else if (P_RandomChance(PR_UNDEFINED, 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_UNDEFINED, 1, NUMKARTITEMS - 1);
|
||||
mobj->movecount = P_RandomChance(PR_UNDEFINED, FRACUNIT/3) ? 1 : P_RandomKey(PR_UNDEFINED, 32) + 1;
|
||||
#else
|
||||
mobj->threshold = KITEM_SUPERRING; // default item is super ring
|
||||
mobj->movecount = 1;
|
||||
|
|
@ -10300,7 +10300,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?
|
||||
{
|
||||
|
|
@ -10317,7 +10317,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;
|
||||
|
|
@ -10326,7 +10326,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;
|
||||
}
|
||||
|
||||
|
|
@ -10397,8 +10397,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_UNDEFINED, -mobj->info->mass, mobj->info->mass)<<FRACBITS);
|
||||
fixed_t newy = mobj->y + (P_RandomRange(PR_UNDEFINED, -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);
|
||||
|
|
@ -10412,10 +10412,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);
|
||||
|
|
@ -10939,7 +10939,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_UNDEFINED, 8192));
|
||||
}
|
||||
else if (sounds_thunder || effects_lightning)
|
||||
{
|
||||
|
|
@ -12543,8 +12543,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_UNDEFINED, FRACUNIT/2) ? offset : -offset;
|
||||
mobj->momy += P_RandomChance(PR_UNDEFINED, FRACUNIT/2) ? offset : -offset;
|
||||
mobj->momz += offset;
|
||||
}
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -4448,7 +4448,10 @@ static void P_NetArchiveMisc(boolean resending)
|
|||
WRITEUINT32(save_p, pig);
|
||||
}
|
||||
|
||||
WRITEUINT32(save_p, P_GetRandSeed());
|
||||
for (i = 0; i < PRNUMCLASS; i++)
|
||||
{
|
||||
WRITEUINT32(save_p, P_GetRandSeed(i));
|
||||
}
|
||||
|
||||
WRITEUINT32(save_p, tokenlist);
|
||||
|
||||
|
|
@ -4607,7 +4610,10 @@ static inline boolean P_NetUnArchiveMisc(boolean reloading)
|
|||
}
|
||||
}
|
||||
|
||||
P_SetRandSeed(READUINT32(save_p));
|
||||
for (i = 0; i < PRNUMCLASS; i++)
|
||||
{
|
||||
P_SetRandSeed(i, READUINT32(save_p));
|
||||
}
|
||||
|
||||
tokenlist = READUINT32(save_p);
|
||||
|
||||
|
|
@ -4859,10 +4865,15 @@ boolean P_LoadGame(INT16 mapoverride)
|
|||
|
||||
boolean P_LoadNetGame(boolean reloading)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
CV_LoadNetVars(&save_p);
|
||||
|
||||
if (!P_NetUnArchiveMisc(reloading))
|
||||
return false;
|
||||
|
||||
P_NetUnArchivePlayers();
|
||||
|
||||
if (gamestate == GS_LEVEL)
|
||||
{
|
||||
P_NetUnArchiveWorld();
|
||||
|
|
@ -4875,10 +4886,14 @@ 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());
|
||||
for (i = 0; i < PRNUMCLASS; i++)
|
||||
{
|
||||
P_SetRandSeed(i, P_GetInitSeed(i));
|
||||
}
|
||||
|
||||
// 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,
|
||||
|
|
|
|||
10
src/p_spec.c
10
src/p_spec.c
|
|
@ -3298,9 +3298,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_UNDEFINED, rvalue1, rvalue2);
|
||||
else
|
||||
result = P_RandomRange(rvalue2, rvalue1);
|
||||
result = P_RandomRange(PR_UNDEFINED, rvalue2, rvalue1);
|
||||
|
||||
P_LinedefExecute((INT16)result, mo, NULL);
|
||||
break;
|
||||
|
|
@ -3696,9 +3696,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
|
||||
{
|
||||
|
|
|
|||
16
src/p_user.c
16
src/p_user.c
|
|
@ -1723,12 +1723,12 @@ static void P_DoBubbleBreath(player_t *player)
|
|||
|
||||
if (player->charflags & SF_MACHINE)
|
||||
{
|
||||
if (P_RandomChance(FRACUNIT/5))
|
||||
if (P_RandomChance(PR_UNDEFINED, 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_UNDEFINED, r, -r)<<FRACBITS);
|
||||
y += (P_RandomRange(PR_UNDEFINED, r, -r)<<FRACBITS);
|
||||
z += (P_RandomKey(PR_UNDEFINED, player->mo->height>>FRACBITS)<<FRACBITS);
|
||||
bubble = P_SpawnMobj(x, y, z, MT_WATERZAP);
|
||||
S_StartSound(bubble, sfx_beelec);
|
||||
}
|
||||
|
|
@ -1740,9 +1740,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_UNDEFINED, FRACUNIT/16))
|
||||
bubble = P_SpawnMobj(x, y, z, MT_SMALLBUBBLE);
|
||||
else if (P_RandomChance(3*FRACUNIT/256))
|
||||
else if (P_RandomChance(PR_UNDEFINED, 3*FRACUNIT/256))
|
||||
bubble = P_SpawnMobj(x, y, z, MT_MEDIUMBUBBLE);
|
||||
}
|
||||
|
||||
|
|
@ -2358,7 +2358,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_UNDEFINED, FRACUNIT/2) && leveltime % TICRATE == 0)
|
||||
S_StartSound(player->mo, sfx_floush);
|
||||
}
|
||||
|
||||
|
|
@ -3694,7 +3694,7 @@ boolean P_SpectatorJoinGame(player_t *player)
|
|||
else if (redscore > bluescore)
|
||||
changeto = 2;
|
||||
else
|
||||
changeto = (P_RandomFixed() & 1) + 1;
|
||||
changeto = (P_RandomFixed(PR_UNDEFINED) & 1) + 1;
|
||||
|
||||
if (!LUA_HookTeamSwitch(player, changeto, true, false, false))
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue