Skip to content

Commit

Permalink
- replaced RANDOM_RANGE macro with direct calls to RandomRange
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Oct 10, 2021
1 parent cc912fb commit 2af688d
Show file tree
Hide file tree
Showing 28 changed files with 281 additions and 289 deletions.
32 changes: 16 additions & 16 deletions source/games/sw/src/actor.cpp
Expand Up @@ -157,7 +157,7 @@ DoActorDie(short SpriteNum, short weapon)
}
else
{
if (RANDOM_RANGE(1000) > 500)
if (RandomRange(1000) > 500)
{
SPRITEp wp = &sprite[weapon];
InitPlasmaFountain(wp, sp);
Expand All @@ -166,16 +166,16 @@ DoActorDie(short SpriteNum, short weapon)
ChangeState(SpriteNum, u->StateEnd);
u->RotNum = 0;
u->ActorActionFunc = nullptr;
sp->xvel = 200 + RANDOM_RANGE(200);
u->jump_speed = -200 - RANDOM_RANGE(250);
sp->xvel = 200 + RandomRange(200);
u->jump_speed = -200 - RandomRange(250);
DoActorBeginJump(SpriteNum);
sprite[SpriteNum].ang = sprite[weapon].ang;
}
}
else
{
// test for gibable dead bodies
if (RANDOM_RANGE(1000) > 500)
if (RandomRange(1000) > 500)
SET(sp->cstat, CSTAT_SPRITE_YFLIP);
ChangeState(SpriteNum, u->StateEnd);
sp->xvel = 0;
Expand Down Expand Up @@ -203,21 +203,21 @@ DoActorDie(short SpriteNum, short weapon)
break;

case UZI_SMOKE:
if (RANDOM_RANGE(1000) > 500)
if (RandomRange(1000) > 500)
SET(sp->cstat, CSTAT_SPRITE_YFLIP);
ChangeState(SpriteNum, u->StateEnd);
u->RotNum = 0;
// Rippers still gotta jump or they fall off walls weird
if (u->ID == RIPPER_RUN_R0 || u->ID == RIPPER2_RUN_R0)
{
sp->xvel <<= 1;
u->jump_speed = -100 - RANDOM_RANGE(250);
u->jump_speed = -100 - RandomRange(250);
DoActorBeginJump(SpriteNum);
}
else
{
sp->xvel = 0;
u->jump_speed = -10 - RANDOM_RANGE(25);
u->jump_speed = -10 - RandomRange(25);
DoActorBeginJump(SpriteNum);
}
u->ActorActionFunc = nullptr;
Expand All @@ -226,21 +226,21 @@ DoActorDie(short SpriteNum, short weapon)
break;

case UZI_SMOKE+1: // Shotgun
if (RANDOM_RANGE(1000) > 500)
if (RandomRange(1000) > 500)
SET(sp->cstat, CSTAT_SPRITE_YFLIP);
ChangeState(SpriteNum, u->StateEnd);
u->RotNum = 0;

// Rippers still gotta jump or they fall off walls weird
if (u->ID == RIPPER_RUN_R0 || u->ID == RIPPER2_RUN_R0)
{
sp->xvel = 75 + RANDOM_RANGE(100);
u->jump_speed = -100 - RANDOM_RANGE(150);
sp->xvel = 75 + RandomRange(100);
u->jump_speed = -100 - RandomRange(150);
}
else
{
sp->xvel = 100 + RANDOM_RANGE(200);
u->jump_speed = -100 - RANDOM_RANGE(250);
sp->xvel = 100 + RandomRange(200);
u->jump_speed = -100 - RandomRange(250);
}
DoActorBeginJump(SpriteNum);
u->ActorActionFunc = nullptr;
Expand All @@ -258,19 +258,19 @@ DoActorDie(short SpriteNum, short weapon)
break;

default:
if (RANDOM_RANGE(1000) > 700)
if (RandomRange(1000) > 700)
{
SPRITEp wp = &sprite[weapon];
InitPlasmaFountain(wp, sp);
}

if (RANDOM_RANGE(1000) > 500)
if (RandomRange(1000) > 500)
SET(sp->cstat, CSTAT_SPRITE_YFLIP);
ChangeState(SpriteNum, u->StateEnd);
u->RotNum = 0;
u->ActorActionFunc = nullptr;
sp->xvel = 300 + RANDOM_RANGE(400);
u->jump_speed = -300 - RANDOM_RANGE(350);
sp->xvel = 300 + RandomRange(400);
u->jump_speed = -300 - RandomRange(350);
DoActorBeginJump(SpriteNum);
sprite[SpriteNum].ang = sprite[weapon].ang;
break;
Expand Down
2 changes: 1 addition & 1 deletion source/games/sw/src/ai.cpp
Expand Up @@ -678,7 +678,7 @@ DoActorActionDecide(short SpriteNum)
// If target was actor, retarget to player it actor died
// or just randomly give the target actor a break
//if ((User[u->tgt_sp-sprite] &&
// User[u->tgt_sp-sprite]->Health <= 0) || RANDOM_RANGE(1000) > 950)
// User[u->tgt_sp-sprite]->Health <= 0) || RandomRange(1000) > 950)
// {
// DoActorPickClosePlayer(SpriteNum);
// InitActorReposition(SpriteNum);
Expand Down
30 changes: 15 additions & 15 deletions source/games/sw/src/bunny.cpp
Expand Up @@ -986,7 +986,7 @@ DoBunnyQuickJump(short SpriteNum)

// Kill a rival
// Only males fight
if (tu->spal == sp->pal && RANDOM_RANGE(1000) > 995)
if (tu->spal == sp->pal && RandomRange(1000) > 995)
{
if (u->spal == PALETTE_PLAYER8 && tu->spal == PALETTE_PLAYER8)
{
Expand Down Expand Up @@ -1032,7 +1032,7 @@ DoBunnyQuickJump(short SpriteNum)
{
PLAYERp pp = nullptr;

if (RANDOM_RANGE(1000) < 995 && tu->spal != PALETTE_PLAYER0) return false;
if (RandomRange(1000) < 995 && tu->spal != PALETTE_PLAYER0) return false;

DoActorPickClosePlayer(SpriteNum);

Expand All @@ -1059,7 +1059,7 @@ DoBunnyQuickJump(short SpriteNum)
}
else
{
if (pp && RANDOM_RANGE(1000) > 200)
if (pp && RandomRange(1000) > 200)
{
short choose_snd;
int straightsnds[] = {DIGI_RABBITHUMP1,DIGI_RABBITHUMP2,
Expand Down Expand Up @@ -1156,7 +1156,7 @@ int DoBunnyStandKill(short SpriteNum)
NullBunny(SpriteNum);

// Growl like the bad ass bunny you are!
if (RANDOM_RANGE(1000) > 800)
if (RandomRange(1000) > 800)
PlaySound(DIGI_BUNNYATTACK, sp, v3df_none);

if ((u->WaitTics -= ACTORMOVETICS) <= 0)
Expand Down Expand Up @@ -1198,13 +1198,13 @@ void BunnyHatch(short Weapon)

// make immediately active
SET(nu->Flags, SPR_ACTIVE);
if (RANDOM_RANGE(1000) > 500) // Boy or Girl?
if (RandomRange(1000) > 500) // Boy or Girl?
nu->spal = np->pal = PALETTE_PLAYER0; // Girl
else
{
nu->spal = np->pal = PALETTE_PLAYER8; // Boy
// Oops, mommy died giving birth to a boy
if (RANDOM_RANGE(1000) > 500)
if (RandomRange(1000) > 500)
{
wu->Health = 0;
Bunny_Count--; // Bunny died
Expand Down Expand Up @@ -1267,7 +1267,7 @@ int BunnyHatch2(short Weapon)

// make immediately active
SET(nu->Flags, SPR_ACTIVE);
if (RANDOM_RANGE(1000) > 500) // Boy or Girl?
if (RandomRange(1000) > 500) // Boy or Girl?
{
nu->spal = np->pal = PALETTE_PLAYER0; // Girl
nu->Flag1 = SEC(5);
Expand All @@ -1285,12 +1285,12 @@ int BunnyHatch2(short Weapon)
DoActorSetSpeed(New, FAST_SPEED);
if (TEST_BOOL3(wp))
{
PickJumpMaxSpeed(New, -600-RANDOM_RANGE(600));
PickJumpMaxSpeed(New, -600-RandomRange(600));
np->xrepeat = np->yrepeat = 64;
np->xvel = 150 + RANDOM_RANGE(1000);
np->xvel = 150 + RandomRange(1000);
nu->Health = 1; // Easy to pop. Like shootn' skeet.
np->ang -= RANDOM_RANGE(128);
np->ang += RANDOM_RANGE(128);
np->ang -= RandomRange(128);
np->ang += RandomRange(128);
}
else
PickJumpMaxSpeed(New, -600);
Expand Down Expand Up @@ -1358,7 +1358,7 @@ DoBunnyMove(short SpriteNum)

DoActorSectorDamage(SpriteNum);

if (RANDOM_RANGE(1000) > 985 && sp->pal != PALETTE_PLAYER1 && u->track < 0)
if (RandomRange(1000) > 985 && sp->pal != PALETTE_PLAYER1 && u->track < 0)
{
switch (sector[sp->sectnum].floorpicnum)
{
Expand All @@ -1375,7 +1375,7 @@ DoBunnyMove(short SpriteNum)
NewStateGroup(SpriteNum,sg_BunnyStand);
break;
default:
sp->ang = NORM_ANGLE(RANDOM_RANGE(2048 << 6) >> 6);
sp->ang = NORM_ANGLE(RandomRange(2048 << 6) >> 6);
u->jump_speed = -350;
DoActorBeginJump(SpriteNum);
u->ActorActionFunc = DoActorMoveJump;
Expand Down Expand Up @@ -1436,7 +1436,7 @@ DoBunnyEat(short SpriteNum)
case 3562:
case 3563:
case 3564:
if (RANDOM_RANGE(1000) > 970)
if (RandomRange(1000) > 970)
NewStateGroup(SpriteNum,sg_BunnyRun);
break;
default:
Expand Down Expand Up @@ -1469,7 +1469,7 @@ DoBunnyScrew(short SpriteNum)

DoActorSectorDamage(SpriteNum);

if (RANDOM_RANGE(1000) > 990) // Bunny sex sounds
if (RandomRange(1000) > 990) // Bunny sex sounds
{
PlaySound(DIGI_BUNNYATTACK, sp, v3df_follow);
}
Expand Down
8 changes: 4 additions & 4 deletions source/games/sw/src/coolg.cpp
Expand Up @@ -651,7 +651,7 @@ int DoCoolgMatchPlayerZ(short SpriteNum)
zdiff = (SPRITEp_MID(tsp)) - u->sz;

// check z diff of the player and the sprite
zdist = Z(20 + RANDOM_RANGE(100)); // put a random amount
zdist = Z(20 + RandomRange(100)); // put a random amount
//zdist = Z(20);
if (labs(zdiff) > zdist)
{
Expand Down Expand Up @@ -735,7 +735,7 @@ int InitCoolgCircle(short SpriteNum)
if (labs(u->sz - u->hiz) < labs(u->sz - u->loz))
u->jump_speed = -u->jump_speed;

u->WaitTics = (RANDOM_RANGE(3)+1) * 120;
u->WaitTics = (RandomRange(3)+1) * 120;

(*u->ActorActionFunc)(SpriteNum);

Expand Down Expand Up @@ -847,7 +847,7 @@ int DoCoolgMove(short SpriteNum)
PlaySound(DIGI_VOID3, sp, v3df_follow);
RESET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT);
SET(sp->cstat, CSTAT_SPRITE_INVISIBLE);
u->ShellNum = SEC(1) + SEC(RANDOM_RANGE(2));
u->ShellNum = SEC(1) + SEC(RandomRange(2));
break;
case 2:
SET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT);
Expand All @@ -858,7 +858,7 @@ int DoCoolgMove(short SpriteNum)
PlaySound(DIGI_VOID3, sp, v3df_follow);
RESET(sp->cstat, CSTAT_SPRITE_TRANSLUCENT);
RESET(sp->cstat, CSTAT_SPRITE_INVISIBLE);
u->ShellNum = SEC(2) + SEC(RANDOM_RANGE(3));
u->ShellNum = SEC(2) + SEC(RandomRange(3));
break;
default:
u->FlagOwner = 0;
Expand Down
2 changes: 1 addition & 1 deletion source/games/sw/src/coolie.cpp
Expand Up @@ -562,7 +562,7 @@ int SpawnCoolg(short SpriteNum)
{

// Don't do a ghost every time
if (RANDOM_RANGE(1000) > 700 || Skill < MinEnemySkill - 1)
if (RandomRange(1000) > 700 || Skill < MinEnemySkill - 1)
{
return(0);
}
Expand Down
6 changes: 3 additions & 3 deletions source/games/sw/src/eel.cpp
Expand Up @@ -487,7 +487,7 @@ int DoEelMatchPlayerZ(short SpriteNum)
zdiff = (SPRITEp_BOS(tsp) - Z(8)) - u->sz;

// check z diff of the player and the sprite
zdist = Z(20 + RANDOM_RANGE(64)); // put a random amount
zdist = Z(20 + RandomRange(64)); // put a random amount
if (labs(zdiff) > zdist)
{
if (zdiff > 0)
Expand Down Expand Up @@ -588,9 +588,9 @@ DoEelDeath(short SpriteNum)
if (sp->z >= u->loz)
{
RESET(u->Flags, SPR_FALLING|SPR_SLIDING);
if (RANDOM_RANGE(1000) > 500)
if (RandomRange(1000) > 500)
SET(sp->cstat, CSTAT_SPRITE_XFLIP);
if (RANDOM_RANGE(1000) > 500)
if (RandomRange(1000) > 500)
SET(sp->cstat, CSTAT_SPRITE_YFLIP);
NewStateGroup(SpriteNum, u->ActorActionSet->Dead);
return 0;
Expand Down
5 changes: 0 additions & 5 deletions source/games/sw/src/game.h
Expand Up @@ -116,11 +116,6 @@ inline int RANDOM(void)
}

#define RANDOM_P2(pwr_of_2) (MOD_P2(RANDOM(),(pwr_of_2)))
#define RANDOM_RANGE(range) (RandomRange(range))


#define PRINT(line,str) DebugPrint(line,str)


//
// Map directions/degrees
Expand Down
4 changes: 2 additions & 2 deletions source/games/sw/src/hornet.cpp
Expand Up @@ -362,7 +362,7 @@ int DoHornetMatchPlayerZ(short SpriteNum)
zdiff = (SPRITEp_MID(tsp)) - u->sz;

// check z diff of the player and the sprite
zdist = Z(20 + RANDOM_RANGE(200)); // put a random amount
zdist = Z(20 + RandomRange(200)); // put a random amount
if (labs(zdiff) > zdist)
{
if (zdiff > 0)
Expand Down Expand Up @@ -446,7 +446,7 @@ int InitHornetCircle(short SpriteNum)
if (labs(u->sz - u->hiz) < labs(u->sz - u->loz))
u->jump_speed = -u->jump_speed;

u->WaitTics = (RANDOM_RANGE(3)+1) * 60;
u->WaitTics = (RandomRange(3)+1) * 60;

(*u->ActorActionFunc)(SpriteNum);

Expand Down
2 changes: 1 addition & 1 deletion source/games/sw/src/inv.cpp
Expand Up @@ -304,7 +304,7 @@ void UseInventoryCloak(PLAYERp pp)
sp->shade = 100;

PlaySound(DIGI_GASPOP, pp, v3df_none);
//if(RANDOM_RANGE(1000) > 950)
//if(RandomRange(1000) > 950)
if (pp == Player+myconnectindex)
PlayerSound(DIGI_IAMSHADOW, v3df_follow|v3df_dontpan,pp);
}
Expand Down

0 comments on commit 2af688d

Please sign in to comment.