diff --git a/sys/src/games/doom/m_random.c b/sys/src/games/doom/m_random.c index 09f857d0b..957bee316 100644 --- a/sys/src/games/doom/m_random.c +++ b/sys/src/games/doom/m_random.c @@ -60,6 +60,12 @@ int P_Random (void) return rndtable[prndindex]; } +int P_Random2 (void) +{ + int tmp = P_Random(); + return tmp - P_Random(); +} + int M_Random (void) { rndindex = (rndindex+1)&0xff; diff --git a/sys/src/games/doom/m_random.h b/sys/src/games/doom/m_random.h index 40b86d584..506ac3bc1 100644 --- a/sys/src/games/doom/m_random.h +++ b/sys/src/games/doom/m_random.h @@ -34,6 +34,7 @@ int M_Random (void); // As M_Random, but used only by the play simulation. int P_Random (void); +int P_Random2 (void); /* P_Raomdom() - P_Random() */ // Fix randoms for demos. void M_ClearRandom (void); diff --git a/sys/src/games/doom/p_enemy.c b/sys/src/games/doom/p_enemy.c index 7f621c97c..9ce39798c 100644 --- a/sys/src/games/doom/p_enemy.c +++ b/sys/src/games/doom/p_enemy.c @@ -789,7 +789,7 @@ void A_FaceTarget (void *_actor, void*) actor->target->y); if (actor->target->flags & MF_SHADOW) - actor->angle += (P_Random()-P_Random())<<21; + actor->angle += P_Random2()<<21; } @@ -811,7 +811,7 @@ void A_PosAttack (void *_actor, void*) slope = P_AimLineAttack (actor, angle, MISSILERANGE); S_StartSound (actor, sfx_pistol); - angle += (P_Random()-P_Random())<<20; + angle += P_Random2()<<20; damage = ((P_Random()%5)+1)*3; P_LineAttack (actor, angle, MISSILERANGE, slope, damage); } @@ -835,7 +835,7 @@ void A_SPosAttack (void *_actor, void*) for (i=0 ; i<3 ; i++) { - angle = bangle + ((P_Random()-P_Random())<<20); + angle = bangle + (P_Random2()<<20); damage = ((P_Random()%5)+1)*3; P_LineAttack (actor, angle, MISSILERANGE, slope, damage); } @@ -857,7 +857,7 @@ void A_CPosAttack (void *_actor, void*) bangle = actor->angle; slope = P_AimLineAttack (actor, bangle, MISSILERANGE); - angle = bangle + ((P_Random()-P_Random())<<20); + angle = bangle + (P_Random2()<<20); damage = ((P_Random()%5)+1)*3; P_LineAttack (actor, angle, MISSILERANGE, slope, damage); } @@ -1908,7 +1908,7 @@ void A_BrainExplode (void *_mo, void*) int z; mobj_t* th; - x = mo->x + (P_Random () - P_Random ())*2048; + x = mo->x + P_Random2()*2048; y = mo->y; z = 128 + P_Random()*2*FRACUNIT; th = P_SpawnMobj (x,y,z, MT_ROCKET); diff --git a/sys/src/games/doom/p_map.c b/sys/src/games/doom/p_map.c index b71bcd1cb..bcd176424 100644 --- a/sys/src/games/doom/p_map.c +++ b/sys/src/games/doom/p_map.c @@ -1302,8 +1302,8 @@ boolean PIT_ChangeSector (mobj_t* thing) thing->y, thing->z + thing->height/2, MT_BLOOD); - mo->momx = (P_Random() - P_Random ())<<12; - mo->momy = (P_Random() - P_Random ())<<12; + mo->momx = P_Random2()<<12; + mo->momy = P_Random2()<<12; } // keep checking (crush other things) diff --git a/sys/src/games/doom/p_mobj.c b/sys/src/games/doom/p_mobj.c index 8fcb4c1c5..07eb37a35 100644 --- a/sys/src/games/doom/p_mobj.c +++ b/sys/src/games/doom/p_mobj.c @@ -818,7 +818,7 @@ P_SpawnPuff { mobj_t* th; - z += ((P_Random()-P_Random())<<10); + z += P_Random2()<<10; th = P_SpawnMobj (x,y,z, MT_PUFF); th->momz = FRACUNIT; @@ -846,7 +846,7 @@ P_SpawnBlood { mobj_t* th; - z += ((P_Random()-P_Random())<<10); + z += P_Random2()<<10; th = P_SpawnMobj (x,y,z, MT_BLOOD); th->momz = FRACUNIT*2; th->tics -= P_Random()&3; @@ -909,7 +909,7 @@ P_SpawnMissile // fuzzy player if (dest->flags & MF_SHADOW) - an += (P_Random()-P_Random())<<20; + an += P_Random2()<<20; th->angle = an; an >>= ANGLETOFINESHIFT; diff --git a/sys/src/games/doom/p_pspr.c b/sys/src/games/doom/p_pspr.c index 83d2c44ca..a2143a696 100644 --- a/sys/src/games/doom/p_pspr.c +++ b/sys/src/games/doom/p_pspr.c @@ -471,7 +471,7 @@ A_Punch(void *_player, void* /*psp*/) damage *= 10; angle = player->mo->angle; - angle += (P_Random()-P_Random())<<18; + angle += P_Random2()<<18; slope = P_AimLineAttack (player->mo, angle, MELEERANGE); P_LineAttack (player->mo, angle, MELEERANGE, slope, damage); @@ -500,7 +500,7 @@ A_Saw(void *_player, void * /*psp*/) damage = 2*(P_Random ()%10+1); angle = player->mo->angle; - angle += (P_Random()-P_Random())<<18; + angle += P_Random2()<<18; // use meleerange + 1 se the puff doesn't skip the flash slope = P_AimLineAttack (player->mo, angle, MELEERANGE+1); @@ -622,7 +622,7 @@ P_GunShot angle = mo->angle; if (!accurate) - angle += (P_Random()-P_Random())<<18; + angle += P_Random2()<<18; P_LineAttack (mo, angle, MISSILERANGE, bulletslope, damage); } @@ -703,11 +703,11 @@ A_FireShotgun2(void *_player, void* /*psp*/) { damage = 5*(P_Random ()%3+1); angle = player->mo->angle; - angle += (P_Random()-P_Random())<<19; + angle += P_Random2()<<19; P_LineAttack (player->mo, angle, MISSILERANGE, - bulletslope + ((P_Random()-P_Random())<<5), damage); + bulletslope + (P_Random2()<<5), damage); } }