mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-11 07:12:16 +00:00
- cleaned up use of the random function in script files.
Many uses of random() & value have been turned into random(0, value). This is not only more efficient, it also ensures better random distribution because the parameter-less variant only returns values between 0 and 255.
This commit is contained in:
parent
a44e63babd
commit
0770c0022c
50 changed files with 122 additions and 121 deletions
|
@ -691,7 +691,7 @@ class Actor : Thinker native
|
|||
{
|
||||
return false;
|
||||
}
|
||||
movecount = random[TryWalk]() & 15;
|
||||
movecount = random[TryWalk](0, 15);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -495,7 +495,7 @@ extend class Actor
|
|||
bo.PlaySpawnSound(self);
|
||||
if (xyvel != 0)
|
||||
bo.Speed = xyvel;
|
||||
bo.Angle = Angle + (((random[grenade]()&7) - 4) * (360./256.));
|
||||
bo.Angle = Angle + (random[grenade](-4, 3) * (360./256.));
|
||||
|
||||
let pitch = -self.Pitch;
|
||||
let angle = bo.Angle;
|
||||
|
|
|
@ -47,7 +47,7 @@ extend class Actor
|
|||
// make fall forwards sometimes
|
||||
if ((damage < 40) && (damage > health)
|
||||
&& (pos.Z - origin.pos.Z > 64)
|
||||
&& (random[Kickback]() & 1)
|
||||
&& random[Kickback](0, 1)
|
||||
// [RH] But only if not too fast and not flying
|
||||
&& thrust < 10
|
||||
&& !bNoGravity
|
||||
|
|
|
@ -37,7 +37,7 @@ extend class StateProvider
|
|||
State flash = weap.FindState('Flash');
|
||||
if (flash != null)
|
||||
{
|
||||
player.SetSafeFlash(weap, flash, random[FireRail]()&1);
|
||||
player.SetSafeFlash(weap, flash, random[FireRail](0, 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -475,7 +475,7 @@ class ScriptedMarine : Actor
|
|||
double pitch = AimLineAttack (angle, MISSILERANGE);
|
||||
for (int i = 0; i < 20; ++i)
|
||||
{
|
||||
int damage = 5*(random[SMarineFireSSG]()%3+1);
|
||||
int damage = 5*(random[SMarineFireSSG](1, 3));
|
||||
double ang = angle + Random2[SMarineFireSSG]() * (11.25 / 256);
|
||||
|
||||
LineAttack (ang, MISSILERANGE, pitch + Random2[SMarineFireSSG]() * (7.097 / 256), damage, 'Hitscan', "BulletPuff");
|
||||
|
|
|
@ -120,8 +120,8 @@ extend class StateProvider
|
|||
double SavedPlayerPitch = pitch;
|
||||
for (int i = 0; i < 2; i++) // Spawn two plasma balls in sequence
|
||||
{
|
||||
angle += ((random[OldBFG]() & 127) - 64) * (90./768);
|
||||
pitch += ((random[OldBFG]() & 127) - 64) * (90./640);
|
||||
angle += random[OldBFG](-64, 63) * (90./768);
|
||||
pitch += random[OldBFG](-64, 63) * (90./640);
|
||||
SpawnPlayerMissile (i == 0? (class<Actor>)("PlasmaBall1") : (class<Actor>)("PlasmaBall2"));
|
||||
// Restore saved values
|
||||
angle = SavedPlayerAngle;
|
||||
|
|
|
@ -139,7 +139,7 @@ extend class StateProvider
|
|||
State flash = weap.FindState('Flash');
|
||||
if (flash != null)
|
||||
{
|
||||
player.SetSafeFlash(weap, flash, random[FirePlasma]()&1);
|
||||
player.SetSafeFlash(weap, flash, random[FirePlasma](0, 1));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -331,7 +331,7 @@ extend class Actor
|
|||
}
|
||||
else
|
||||
{ // Death
|
||||
count = 5 + (random[Feathers]()&3);
|
||||
count = 5 + (random[Feathers](0, 3));
|
||||
}
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
|
@ -342,7 +342,7 @@ extend class Actor
|
|||
mo.Vel.X = Random2[Feathers]() / 256.;
|
||||
mo.Vel.Y = Random2[Feathers]() / 256.;
|
||||
mo.Vel.Z = 1. + random[Feathers]() / 128.;
|
||||
mo.SetState (mo.SpawnState + (random[Feathers]()&7));
|
||||
mo.SetState (mo.SpawnState + (random[Feathers](0, 7)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -283,7 +283,7 @@ class Volcano : Actor
|
|||
|
||||
void A_VolcanoSet ()
|
||||
{
|
||||
tics = 105 + (random[VolcanoSet]() & 127);
|
||||
tics = random[VolcanoSet](105, 232);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
|
|
|
@ -345,7 +345,7 @@ class Whirlwind : Actor
|
|||
}
|
||||
if ((threshold -= 3) < 0)
|
||||
{
|
||||
threshold = 58 + (random[WhirlwindSeek]() & 31);
|
||||
threshold = random[WhirlwindSeek](58, 89);
|
||||
A_PlaySound("ironlich/attack3", CHAN_BODY);
|
||||
}
|
||||
if (tracer && tracer.bShadow)
|
||||
|
|
|
@ -132,7 +132,7 @@ class BlasterFX1 : FastProjectile
|
|||
{
|
||||
if (target is "Ironlich")
|
||||
{ // Less damage to Ironlich bosses
|
||||
damage = random[BlasterFX]() & 1;
|
||||
damage = random[BlasterFX](0, 1);
|
||||
if (!damage)
|
||||
{
|
||||
return -1;
|
||||
|
@ -224,7 +224,7 @@ class Ripper : Actor
|
|||
{
|
||||
if (target is "Ironlich")
|
||||
{ // Less damage to Ironlich bosses
|
||||
damage = random[Ripper]() & 1;
|
||||
damage = random[Ripper](0, 1);
|
||||
if (!damage)
|
||||
{
|
||||
return -1;
|
||||
|
|
|
@ -67,8 +67,8 @@ class Gauntlets : Weapon
|
|||
if (!weapon.DepleteAmmo (weapon.bAltFire))
|
||||
return;
|
||||
|
||||
player.GetPSprite(PSP_WEAPON).x = ((random[GauntletAtk]() & 3) - 2);
|
||||
player.GetPSprite(PSP_WEAPON).y = WEAPONTOP + (random[GauntletAtk]() & 3);
|
||||
player.GetPSprite(PSP_WEAPON).x = ((random[GauntletAtk](0, 3)) - 2);
|
||||
player.GetPSprite(PSP_WEAPON).y = WEAPONTOP + (random[GauntletAtk](0, 3));
|
||||
}
|
||||
double ang = angle;
|
||||
if (power)
|
||||
|
|
|
@ -74,9 +74,9 @@ class Mace : HereticWeapon
|
|||
}
|
||||
else
|
||||
{
|
||||
player.GetPSprite(PSP_WEAPON).x = ((random[MaceAtk]() & 3) - 2);
|
||||
player.GetPSprite(PSP_WEAPON).y = WEAPONTOP + (random[MaceAtk]() & 3);
|
||||
Actor ball = SpawnPlayerMissile("MaceFX1", angle + (((random[MaceAtk]() & 7) - 4) * (360. / 256)));
|
||||
player.GetPSprite(PSP_WEAPON).x = random[MaceAtk](-2, 1);
|
||||
player.GetPSprite(PSP_WEAPON).y = WEAPONTOP + random[MaceAtk](0, 3);
|
||||
Actor ball = SpawnPlayerMissile("MaceFX1", angle + (random[MaceAtk](-4, 3) * (360. / 256)));
|
||||
if (ball)
|
||||
{
|
||||
ball.special1 = 16; // tics till dropoff
|
||||
|
|
|
@ -327,8 +327,8 @@ class HornRodFX2 : Actor
|
|||
{ // Fudge rain frequency
|
||||
return;
|
||||
}
|
||||
double xo = ((Random[SkullRodStorm]() & 127) - 64);
|
||||
double yo = ((Random[SkullRodStorm]() & 127) - 64);
|
||||
double xo = Random[SkullRodStorm](-64, 63);
|
||||
double yo = Random[SkullRodStorm](-64, 63);
|
||||
Vector3 spawnpos = Vec2OffsetZ(xo, yo, pos.z);
|
||||
Actor mo = Spawn("RainPillar", spawnpos, ALLOW_REPLACE);
|
||||
if (!mo) return;
|
||||
|
|
|
@ -59,7 +59,7 @@ class GoldWand : HereticWeapon
|
|||
return;
|
||||
}
|
||||
double pitch = BulletSlope();
|
||||
int damage = 7 + (random[FireGoldWand]() & 7);
|
||||
int damage = random[FireGoldWand](7, 14);
|
||||
double ang = angle;
|
||||
if (player.refire)
|
||||
{
|
||||
|
|
|
@ -73,7 +73,7 @@ extend class Actor
|
|||
{
|
||||
piece.Vel = self.Vel + AngleToVector(i * 120., 1);
|
||||
piece.bDropped = true;
|
||||
j = (j == 0) ? (random[PieceDrop]() & 1) + 1 : 3-j;
|
||||
j = (j == 0) ? random[PieceDrop](1, 2) : 3-j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,12 +51,12 @@ class BatSpawner : SwitchableDecoration
|
|||
int delta = args[1];
|
||||
if (delta == 0) delta = 1;
|
||||
|
||||
double ang = Angle + (((random[BatSpawn]() % delta) - (delta >> 1)) * (360 / 256.));
|
||||
double ang = Angle + ((random[BatSpawn](0, delta-1) - (delta >> 1)) * (360 / 256.));
|
||||
|
||||
Actor mo = SpawnMissileAngle ("Bat", ang, 0);
|
||||
if (mo)
|
||||
{
|
||||
mo.args[0] = random[BatSpawn]() & 63; // floatbob index
|
||||
mo.args[0] = random[BatSpawn](0, 63); // floatbob index
|
||||
mo.args[4] = args[4]; // turn degrees
|
||||
mo.special2 = args[3] << 3; // Set lifetime
|
||||
mo.target = self;
|
||||
|
|
|
@ -96,7 +96,7 @@ class Bishop : Actor
|
|||
targ.TraceBleed (newdam > 0 ? newdam : damage, self);
|
||||
return;
|
||||
}
|
||||
missilecount = (random[BishopAttack]() & 3) + 5;
|
||||
missilecount = random[BishopAttack](5, 8);
|
||||
}
|
||||
|
||||
//============================================================================
|
||||
|
@ -145,7 +145,7 @@ class Bishop : Actor
|
|||
|
||||
void A_BishopDoBlur()
|
||||
{
|
||||
missilecount = (random[BishopDoBlur]() & 3) + 3; // Random number of blurs
|
||||
missilecount = random[BishopDoBlur](3, 6); // Random number of blurs
|
||||
if (random[BishopDoBlur]() < 120)
|
||||
{
|
||||
Thrust(11, Angle + 90);
|
||||
|
|
|
@ -305,7 +305,7 @@ class CFlameMissile : FastProjectile
|
|||
mo.VelFromAngle(CircleFlame.FLAMESPEED);
|
||||
mo.specialf1 = mo.Vel.X;
|
||||
mo.specialf2 = mo.Vel.Y;
|
||||
mo.tics -= random[FlameMissile]()&3;
|
||||
mo.tics -= random[FlameMissile](0, 3);
|
||||
}
|
||||
an += 180;
|
||||
mo = Spawn("CircleFlame", BlockingMobj.Vec3Angle(dist, an, 5), ALLOW_REPLACE);
|
||||
|
@ -316,7 +316,7 @@ class CFlameMissile : FastProjectile
|
|||
mo.VelFromAngle(-CircleFlame.FLAMESPEED);
|
||||
mo.specialf1 = mo.Vel.X;
|
||||
mo.specialf2 = mo.Vel.Y;
|
||||
mo.tics -= random[FlameMissile]()&3;
|
||||
mo.tics -= random[FlameMissile](0, 3);
|
||||
}
|
||||
}
|
||||
SetState (SpawnState);
|
||||
|
|
|
@ -228,17 +228,17 @@ class HolyMissile : Actor
|
|||
{ // float bob index
|
||||
|
||||
case 0:
|
||||
mo.WeaveIndexZ = random[HolyAtk2]() & 7; // upper-left
|
||||
mo.WeaveIndexZ = random[HolyAtk2](0, 7); // upper-left
|
||||
break;
|
||||
case 1:
|
||||
mo.WeaveIndexZ = 32 + (random[HolyAtk2]() & 7); // upper-right
|
||||
mo.WeaveIndexZ = random[HolyAtk2](32, 39); // upper-right
|
||||
break;
|
||||
case 2:
|
||||
mo.WeaveIndexXY = 32 + (random[HolyAtk2]() & 7); // lower-left
|
||||
mo.WeaveIndexXY = random[HolyAtk2](32, 39); // lower-left
|
||||
break;
|
||||
case 3:
|
||||
mo.WeaveIndexXY = 32 + (random[HolyAtk2]() & 7);
|
||||
mo.WeaveIndexZ = 32 + (random[HolyAtk2]() & 7);
|
||||
mo.WeaveIndexXY = random[HolyAtk2](32, 39);
|
||||
mo.WeaveIndexZ = random[HolyAtk2](32, 39);
|
||||
break;
|
||||
}
|
||||
mo.SetZ(pos.z);
|
||||
|
@ -497,7 +497,7 @@ class HolySpirit : Actor
|
|||
Vel.Y /= 4;
|
||||
Vel.Z = 0;
|
||||
SetStateLabel ("Death");
|
||||
tics -= random[HolySeeker]()&3;
|
||||
tics -= random[HolySeeker](0, 3);
|
||||
return;
|
||||
}
|
||||
if (tracer)
|
||||
|
@ -509,8 +509,8 @@ class HolySpirit : Actor
|
|||
}
|
||||
}
|
||||
|
||||
int xyspeed = (random[HolySeeker]() % 5);
|
||||
int zspeed = (random[HolySeeker]() % 5);
|
||||
int xyspeed = random[HolySeeker](0, 4);
|
||||
int zspeed = random[HolySeeker](0, 4);
|
||||
A_Weave(xyspeed, zspeed, 4., 2.);
|
||||
}
|
||||
|
||||
|
|
|
@ -60,7 +60,7 @@ class CWeapMace : ClericWeapon
|
|||
return;
|
||||
}
|
||||
|
||||
int damage = 25+(random[MaceAtk]()&15);
|
||||
int damage = random[MaceAtk](25, 40);
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
for (int j = 1; j >= -1; j -= 2)
|
||||
|
|
|
@ -67,7 +67,7 @@ class CWeapStaff : ClericWeapon
|
|||
}
|
||||
Weapon weapon = player.ReadyWeapon;
|
||||
|
||||
int damage = 20 + (random[StaffCheck]() & 15);
|
||||
int damage = random[StaffCheck](20, 35);
|
||||
int max = player.mo.GetMaxHealth();
|
||||
for (int i = 0; i < 3; i++)
|
||||
{
|
||||
|
|
|
@ -224,8 +224,8 @@ class FWeapAxe : FighterWeapon
|
|||
return;
|
||||
}
|
||||
|
||||
int damage = 40+(random[AxeAtk]() & 15);
|
||||
damage += random[AxeAtk]() & 7;
|
||||
int damage = random[AxeAtk](40, 55);
|
||||
damage += random[AxeAtk](0, 7);
|
||||
int power = 0;
|
||||
Weapon weapon = player.ReadyWeapon;
|
||||
class<Actor> pufftype;
|
||||
|
|
|
@ -99,7 +99,7 @@ class FWeapFist : FighterWeapon
|
|||
return;
|
||||
}
|
||||
|
||||
int damage = 40 + (random[FighterAtk]() & 15);
|
||||
int damage = random[FighterAtk](40, 55);
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
if (TryPunch(angle + i*(45./16), damage, 2) ||
|
||||
|
|
|
@ -65,7 +65,7 @@ class FWeapHammer : FighterWeapon
|
|||
return;
|
||||
}
|
||||
|
||||
int damage = 60+(random[HammerAtk]() & 63);
|
||||
int damage = random[HammerAtk](60, 123);
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
for (int j = 1; j >= -1; j -= 2)
|
||||
|
|
|
@ -208,7 +208,7 @@ class FSwordMissile : Actor
|
|||
|
||||
void A_FSwordFlames()
|
||||
{
|
||||
for (int i = 1+(random[FSwordFlame]()&3); i; i--)
|
||||
for (int i = random[FSwordFlame](1, 4); i; i--)
|
||||
{
|
||||
double xo = (random[FSwordFlame]() - 128) / 16.;
|
||||
double yo = (random[FSwordFlame]() - 128) / 16.;
|
||||
|
|
|
@ -333,7 +333,7 @@ class ArtiPoisonBag3 : ArtiPoisonBag
|
|||
Actor mo = Spawn("ThrowingBomb", Owner.Pos + (0,0,35. - Owner.Floorclip + (Owner.player? Owner.player.crouchoffset : 0)), ALLOW_REPLACE);
|
||||
if (mo)
|
||||
{
|
||||
mo.angle = Owner.angle + (((random[PoisonBag]() & 7) - 4) * (360./256.));
|
||||
mo.angle = Owner.angle + (random[PoisonBag](-4, 3) * (360./256.));
|
||||
|
||||
/* Original flight code from Hexen
|
||||
* mo.momz = 4*F.RACUNIT+((player.lookdir)<<(F.RACBITS-4));
|
||||
|
@ -358,7 +358,7 @@ class ArtiPoisonBag3 : ArtiPoisonBag
|
|||
mo.AddZ(mo.Speed * sin(modpitch));
|
||||
|
||||
mo.target = Owner;
|
||||
mo.tics -= random[PoisonBag]()&3;
|
||||
mo.tics -= random[PoisonBag](0, 3);
|
||||
mo.CheckMissileSpawn(Owner.radius);
|
||||
return true;
|
||||
}
|
||||
|
@ -467,7 +467,7 @@ class PoisonCloud : Actor
|
|||
override void BeginPlay ()
|
||||
{
|
||||
Vel.X = MinVel; // missile objects must move to impact other objects
|
||||
special1 = 24+(random[PoisonCloud]() & 7);
|
||||
special1 = random[PoisonCloud](24, 31);
|
||||
special2 = 0;
|
||||
}
|
||||
|
||||
|
@ -495,7 +495,7 @@ class PoisonCloud : Actor
|
|||
|
||||
if (dopoison)
|
||||
{
|
||||
damage = 15 + (random[PoisonCloud]() & 15);
|
||||
damage = random[PoisonCloud](15, 30);
|
||||
if (mate)
|
||||
{
|
||||
damage = (int)(damage * level.teamdamage);
|
||||
|
@ -506,7 +506,7 @@ class PoisonCloud : Actor
|
|||
damage = victim.ApplyDamageFactor(damagetype, damage);
|
||||
if (damage > 0)
|
||||
{
|
||||
victim.player.PoisonDamage (self, 15 + (random[PoisonCloud]() & 15), false); // Don't play painsound
|
||||
victim.player.PoisonDamage (self, random[PoisonCloud](15, 30), false); // Don't play painsound
|
||||
|
||||
// If successful, play the poison sound.
|
||||
if (victim.player.PoisonPlayer (self, self.target, 50))
|
||||
|
|
|
@ -59,10 +59,10 @@ class FogSpawner : Actor
|
|||
{
|
||||
int delta = args[1];
|
||||
if (delta == 0) delta = 1;
|
||||
mo.angle = angle + (((random[FogSpawn]() % delta) - (delta >> 1)) * (360 / 256.));
|
||||
mo.angle = angle + ((random[FogSpawn](0, delta-1) - (delta >> 1)) * (360 / 256.));
|
||||
mo.target = self;
|
||||
if (args[0] < 1) args[0] = 1;
|
||||
mo.args[0] = (random[FogSpawn]() % (args[0]))+1; // Random speed
|
||||
mo.args[0] = random[FogSpawn](1, args[0]); // Random speed
|
||||
mo.args[3] = args[3]; // Set lifetime
|
||||
mo.args[4] = 1; // Set to moving
|
||||
mo.WeaveIndexZ = random[FogSpawn](0, 63);
|
||||
|
|
|
@ -67,7 +67,7 @@ class ArtiHealingRadius : Inventory
|
|||
|
||||
case 'Mana':
|
||||
{
|
||||
int amount = 50 + (random[HealRadius]() % 50);
|
||||
int amount = random[HealRadius](50, 99);
|
||||
|
||||
if (mo.GiveAmmo ("Mana1", amount) ||
|
||||
mo.GiveAmmo ("Mana2", amount))
|
||||
|
@ -79,7 +79,7 @@ class ArtiHealingRadius : Inventory
|
|||
|
||||
default:
|
||||
//case NAME_Health:
|
||||
gotsome = mo.GiveBody (50 + (random[HealRadius]() % 50));
|
||||
gotsome = mo.GiveBody (random[HealRadius](50, 99));
|
||||
break;
|
||||
}
|
||||
if (gotsome)
|
||||
|
|
|
@ -245,9 +245,9 @@ class Heresiarch : Actor
|
|||
Actor mo = Spawn("SorcSpark1", pos, ALLOW_REPLACE);
|
||||
if (mo)
|
||||
{
|
||||
double rangle = Angle + (random[Heresiarch]() % 5) * (4096 / 360.);
|
||||
mo.Vel.X = (random[Heresiarch]() % speed) * cos(rangle);
|
||||
mo.Vel.Y = (random[Heresiarch]() % speed) * sin(rangle);
|
||||
double rangle = Angle + random[Heresiarch](0, 4) * (4096 / 360.);
|
||||
mo.Vel.X = random[Heresiarch](0, speed - 1) * cos(rangle);
|
||||
mo.Vel.Y = random[Heresiarch](0, speed - 1) * sin(rangle);
|
||||
mo.Vel.Z = 2;
|
||||
}
|
||||
}
|
||||
|
@ -529,9 +529,9 @@ class SorcBall : Actor
|
|||
bNoGravity = false;
|
||||
Gravity = 1. / 8;
|
||||
|
||||
Vel.X = ((random[Heresiarch]()%10)-5);
|
||||
Vel.Y = ((random[Heresiarch]()%10)-5);
|
||||
Vel.Z = (2+(random[Heresiarch]()%3));
|
||||
Vel.X = random[Heresiarch](-5, 4);
|
||||
Vel.Y = random[Heresiarch](-5, 4);
|
||||
Vel.Z = random[Heresiarch](2, 4);
|
||||
args[4] = Heresiarch.BOUNCE_TIME_UNIT; // Bounce time unit
|
||||
args[3] = 5; // Bounce time in seconds
|
||||
}
|
||||
|
|
|
@ -117,15 +117,15 @@ class Pottery1 : Actor
|
|||
Actor mo = null;
|
||||
int i;
|
||||
|
||||
for(i = (random[Pottery]()&3)+3; i; i--)
|
||||
for(i = random[Pottery](3, 6); i; i--)
|
||||
{
|
||||
mo = Spawn ("PotteryBit", Pos, ALLOW_REPLACE);
|
||||
if (mo)
|
||||
{
|
||||
mo.SetState (mo.SpawnState + (random[Pottery]()%5));
|
||||
mo.SetState (mo.SpawnState + random[Pottery](0, 4));
|
||||
mo.Vel.X = random2[Pottery]() / 64.;
|
||||
mo.Vel.Y = random2[Pottery]() / 64.;
|
||||
mo.Vel.Z = ((random[Pottery]() & 7) + 5) * 0.75;
|
||||
mo.Vel.Z = random[Pottery](5, 12) * 0.75;
|
||||
}
|
||||
}
|
||||
mo.A_PlaySound ("PotteryExplode", CHAN_BODY);
|
||||
|
@ -227,7 +227,7 @@ class PotteryBit : Actor
|
|||
void A_PotteryChooseBit()
|
||||
{
|
||||
static const statelabel bits[] = { "Pottery1", "Pottery2", "Pottery3", "Pottery4", "Pottery5" };
|
||||
LoopState = FindState(bits[random[PotteryBit]() % 5]); // Save the state for jumping back to.
|
||||
LoopState = FindState(bits[random[PotteryBit](0, 4)]); // Save the state for jumping back to.
|
||||
SetState (LoopState);
|
||||
tics = 256 + (random[PotteryBit]() << 1);
|
||||
}
|
||||
|
@ -395,15 +395,15 @@ class ZCorpseSitting : Actor
|
|||
{
|
||||
Actor mo;
|
||||
|
||||
for (int i = (random[CorpseExplode]() & 3) + 3; i; i--)
|
||||
for (int i = random[CorpseExplode](3, 6); i; i--)
|
||||
{
|
||||
mo = Spawn ("CorpseBit", Pos, ALLOW_REPLACE);
|
||||
if (mo)
|
||||
{
|
||||
mo.SetState (mo.SpawnState + (random[CorpseExplode]() % 3));
|
||||
mo.SetState (mo.SpawnState + random[CorpseExplode](0, 2));
|
||||
mo.Vel.X = random2[CorpseExplode]() / 64.;
|
||||
mo.Vel.Y = random2[CorpseExplode]() / 64.;
|
||||
mo.Vel.Z = ((random[CorpseExplode]() & 7) + 5) * 0.75;
|
||||
mo.Vel.Z = random[CorpseExplode](5, 12) * 0.75;
|
||||
}
|
||||
}
|
||||
// Spawn a skull
|
||||
|
@ -413,7 +413,7 @@ class ZCorpseSitting : Actor
|
|||
mo.SetState (mo.SpawnState + 3);
|
||||
mo.Vel.X = random2[CorpseExplode]() / 64.;
|
||||
mo.Vel.Y = random2[CorpseExplode]() / 64.;
|
||||
mo.Vel.Z = ((random[CorpseExplode]() & 7) + 5) * 0.75;
|
||||
mo.Vel.Z = random[CorpseExplode](5, 12) * 0.75;
|
||||
}
|
||||
A_PlaySound (DeathSound, CHAN_BODY);
|
||||
Destroy ();
|
||||
|
@ -449,12 +449,12 @@ class LeafSpawner : Actor
|
|||
{
|
||||
static const class<Actor> leaves[] = { "Leaf1", "Leaf2" };
|
||||
|
||||
for (int i = (random[LeafSpawn]() & 3) + 1; i; i--)
|
||||
for (int i = random[LeafSpawn](1, 4); i; i--)
|
||||
{
|
||||
double xo = random2[LeafSpawn]() / 4.;
|
||||
double yo = random2[LeafSpawn]() / 4.;
|
||||
double zo = random[LeafSpawn]() / 4.;
|
||||
Actor mo = Spawn (leaves[random[LeafSpawn]()&1], Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
|
||||
Actor mo = Spawn (leaves[random[LeafSpawn](0, 1)], Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
|
||||
|
||||
if (mo)
|
||||
{
|
||||
|
@ -769,7 +769,7 @@ class ZSuitOfArmor : Actor
|
|||
mo.SetState (mo.SpawnState + i);
|
||||
mo.Vel.X = random2[SoAExplode]() / 64.;
|
||||
mo.Vel.Y = random2[SoAExplode]() / 64.;
|
||||
mo.Vel.Z = (random[SoAExplode]() & 7) + 5;
|
||||
mo.Vel.Z = random[SoAExplode](5, 12);
|
||||
}
|
||||
}
|
||||
// Spawn an item?
|
||||
|
|
|
@ -62,7 +62,7 @@ class IceGuy : Actor
|
|||
|
||||
double dist = (random[IceGuyLook]() - 128) * radius / 128.;
|
||||
double an = angle + 90;
|
||||
Actor mo = Spawn(WispTypes[random[IceGuyLook]() & 1], Vec3Angle(dist, an, 60.), ALLOW_REPLACE);
|
||||
Actor mo = Spawn(WispTypes[random[IceGuyLook](0, 1)], Vec3Angle(dist, an, 60.), ALLOW_REPLACE);
|
||||
if (mo)
|
||||
{
|
||||
mo.Vel = Vel;
|
||||
|
|
|
@ -229,7 +229,7 @@ class Korax : Actor
|
|||
spirit.health = KORAX_SPIRIT_LIFETIME;
|
||||
|
||||
spirit.tracer = self; // Swarm around korax
|
||||
spirit.WeaveIndexZ = 32 + (random[Kspiritnit]() & 7); // Float bob index
|
||||
spirit.WeaveIndexZ = random[Kspiritnit](32, 39); // Float bob index
|
||||
spirit.args[0] = 10; // initial turn value
|
||||
spirit.args[1] = 0; // initial look angle
|
||||
|
||||
|
@ -258,7 +258,7 @@ class Korax : Actor
|
|||
{
|
||||
"WraithMissileFire", "DemonMissileFire", "DemonMissileFire", "FireDemonAttack", "CentaurLeaderAttack", "SerpentLeaderAttack"
|
||||
};
|
||||
int type = random[KoraxMissile]() % 6;
|
||||
int type = random[KoraxMissile](0, 5);
|
||||
|
||||
A_PlaySound("KoraxAttack", CHAN_VOICE);
|
||||
|
||||
|
@ -370,7 +370,7 @@ class Korax : Actor
|
|||
numcommands = 4;
|
||||
}
|
||||
|
||||
ACS_Execute(250 + (random[KoraxCommand]()%numcommands), 0);
|
||||
ACS_Execute(250 + (random[KoraxCommand](0, numcommands)), 0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -471,8 +471,8 @@ class KoraxSpirit : Actor
|
|||
{
|
||||
KSpiritSeeker(args[0], args[0] * 2.);
|
||||
}
|
||||
int xyspeed = (random[KoraxRoam]() % 5);
|
||||
int zspeed = (random[KoraxRoam]() % 5);
|
||||
int xyspeed = random[KoraxRoam](0, 4);
|
||||
int zspeed = random[KoraxRoam](0, 4);
|
||||
A_Weave(xyspeed, zspeed, 4., 2.);
|
||||
|
||||
if (random[KoraxRoam]() < 50)
|
||||
|
|
|
@ -68,7 +68,7 @@ class MWeapFrost : MageWeapon
|
|||
}
|
||||
A_PlaySound ("MageShardsFire", CHAN_WEAPON);
|
||||
|
||||
int damage = 90+(random[MageCone]() & 15);
|
||||
int damage = random[MageCone](90, 105);
|
||||
for (int i = 0; i < 16; i++)
|
||||
{
|
||||
double ang = angle + i*(45./16);
|
||||
|
|
|
@ -911,7 +911,7 @@ class PowerTorch : PowerLightAmp
|
|||
}
|
||||
else
|
||||
{
|
||||
NewTorch = (random[torch]() & 7) + 1;
|
||||
NewTorch = random[torch](1, 8);
|
||||
NewTorchDelta = (NewTorch == Owner.player.fixedlightlevel) ?
|
||||
0 : ((NewTorch > player.fixedlightlevel) ? 1 : -1);
|
||||
}
|
||||
|
|
|
@ -409,13 +409,13 @@ class Minotaur : Actor
|
|||
if (random[MinotaurRoam]() < 6)
|
||||
{
|
||||
//Choose new direction
|
||||
movedir = random[MinotaurRoam]() % 8;
|
||||
movedir = random[MinotaurRoam](0, 7);
|
||||
FaceMovementDirection ();
|
||||
}
|
||||
if (!MonsterMove())
|
||||
{
|
||||
// Turn
|
||||
if (random[MinotaurRoam]() & 1)
|
||||
if (random[MinotaurRoam](0, 1))
|
||||
movedir = (movedir + 1) % 8;
|
||||
else
|
||||
movedir = (movedir + 7) % 8;
|
||||
|
|
|
@ -24,7 +24,7 @@ class IceChunk : Actor
|
|||
|
||||
void A_IceSetTics ()
|
||||
{
|
||||
tics = 70 + (random[IceTics]() & 63);
|
||||
tics = random[IceTics](70, 133);
|
||||
Name dtype = GetFloorTerrain().DamageMOD;
|
||||
if (dtype == 'Fire')
|
||||
{
|
||||
|
@ -134,7 +134,7 @@ extend class Actor
|
|||
// things break up into more shards than smaller things.
|
||||
// An actor with radius 20 and height 64 creates ~40 chunks.
|
||||
int numChunks = max(4, int(radius * Height)/32);
|
||||
int i = Random[FreezeDeathChunks]() % (numChunks/4);
|
||||
int i = Random[FreezeDeathChunks](0, numChunks/4 - 1);
|
||||
for (i = max(24, numChunks + i); i >= 0; i--)
|
||||
{
|
||||
double xo = (random[FreezeDeathChunks]() - 128)*radius / 128;
|
||||
|
@ -144,7 +144,7 @@ extend class Actor
|
|||
Actor mo = Spawn("IceChunk", Vec3Offset(xo, yo, zo), ALLOW_REPLACE);
|
||||
if (mo)
|
||||
{
|
||||
mo.SetState (mo.SpawnState + (random[FreezeDeathChunks]()%3));
|
||||
mo.SetState (mo.SpawnState + random[FreezeDeathChunks](0, 2));
|
||||
mo.Vel.X = random2[FreezeDeathChunks]() / 128.;
|
||||
mo.Vel.Y = random2[FreezeDeathChunks]() / 128.;
|
||||
mo.Vel.Z = (mo.pos.Z - pos.Z) / Height * 4;
|
||||
|
|
|
@ -160,7 +160,7 @@ class EntityBoss : SpectralMonster
|
|||
{
|
||||
// Apparent Strife bug: Case 5 was unreachable because they used % 5 instead of % 6.
|
||||
// I've fixed that by making case 1 duplicate it, since case 1 did nothing.
|
||||
switch (random[Entity]() % 5)
|
||||
switch (random[Entity](0, 4))
|
||||
{
|
||||
case 0:
|
||||
A_SpotLightning();
|
||||
|
|
|
@ -94,7 +94,7 @@ class Programmer : Actor
|
|||
|
||||
A_PlaySound("programmer/clank", CHAN_WEAPON);
|
||||
|
||||
int damage = ((random[Programmer]() % 10) + 1) * 6;
|
||||
int damage = random[Programmer](1, 10) * 6;
|
||||
int newdam = target.DamageMobj (self, self, damage, 'Melee');
|
||||
target.TraceBleed (newdam > 0 ? newdam : damage, self);
|
||||
}
|
||||
|
|
|
@ -79,7 +79,7 @@ extend class Actor
|
|||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
double ang = bangle + Random2[ReaverAttack]() * (22.5 / 256);
|
||||
int damage = ((random[ReaverAttack]() & 7) + 1) * 3;
|
||||
int damage = random[ReaverAttack](1, 8) * 3;
|
||||
LineAttack (ang, MISSILERANGE, pitch, damage, 'Hitscan', "StrifePuff");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,13 +28,13 @@ class SpectralMonster : Actor
|
|||
{
|
||||
int t;
|
||||
|
||||
t = random[SpectreChunk]() & 15;
|
||||
foo.Vel.X = (t - (random[SpectreChunk]() & 7));
|
||||
t = random[SpectreChunk](0, 7);
|
||||
foo.Vel.X = t - random[SpectreChunk](0, 15);
|
||||
|
||||
t = random[SpectreChunk]() & 15;
|
||||
foo.Vel.Y = (t - (random[SpectreChunk]() & 7));
|
||||
t = random[SpectreChunk](0, 7);
|
||||
foo.Vel.Y = t - random[SpectreChunk](0, 15);
|
||||
|
||||
foo.Vel.Z = (random[SpectreChunk]() & 15);
|
||||
foo.Vel.Z = random[SpectreChunk](0, 15);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,13 +46,13 @@ class SpectralMonster : Actor
|
|||
{
|
||||
int t;
|
||||
|
||||
t = random[SpectreChunk]() & 7;
|
||||
foo.Vel.X = (t - (random[SpectreChunk]() & 15));
|
||||
t = random[SpectreChunk](0, 7);
|
||||
foo.Vel.X = t - random[SpectreChunk](0, 15);
|
||||
|
||||
t = random[SpectreChunk]() & 7;
|
||||
foo.Vel.Y = (t - (random[SpectreChunk]() & 15));
|
||||
t = random[SpectreChunk](0, 7);
|
||||
foo.Vel.Y = t - random[SpectreChunk](0, 15);
|
||||
|
||||
foo.Vel.Z = (random[SpectreChunk]() & 7);
|
||||
foo.Vel.Z = random[SpectreChunk](0, 7);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ class Stalker : Actor
|
|||
if (CheckMeleeRange ())
|
||||
{
|
||||
let targ = target;
|
||||
int damage = (random[Stalker]() & 7) * 2 + 2;
|
||||
int damage = random[Stalker](1, 8) * 2;
|
||||
|
||||
int newdam = targ.DamageMobj (self, self, damage, 'Melee');
|
||||
targ.TraceBleed (newdam > 0 ? newdam : damage, self);
|
||||
|
|
|
@ -66,9 +66,9 @@ extend class Actor
|
|||
return;
|
||||
}
|
||||
|
||||
gib.Angle = random[GibTosser]() * (360 / 256.f);
|
||||
gib.VelFromAngle(random[GibTosser]() & 15);
|
||||
gib.Vel.Z = random[GibTosser]() & 15;
|
||||
gib.Angle = random[GibTosser]() * (360 / 256.);
|
||||
gib.VelFromAngle(random[GibTosser](0, 15));
|
||||
gib.Vel.Z = random[GibTosser](0, 15);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -83,7 +83,7 @@ extend class Actor
|
|||
A_PlaySound ("monsters/rifle", CHAN_WEAPON);
|
||||
A_FaceTarget ();
|
||||
double pitch = AimLineAttack (angle, MISSILERANGE);
|
||||
LineAttack (Angle + Random2[ShootGun]() * (11.25 / 256), MISSILERANGE, pitch, 3*(random[ShootGun]() % 5 + 1), 'Hitscan', "StrifePuff");
|
||||
LineAttack (Angle + Random2[ShootGun]() * (11.25 / 256), MISSILERANGE, pitch, 3*random[ShootGun](1, 5), 'Hitscan', "StrifePuff");
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
@ -113,7 +113,7 @@ extend class Actor
|
|||
void A_GetHurt()
|
||||
{
|
||||
bInCombat = true;
|
||||
if ((random[HurtMe]() % 5) == 0)
|
||||
if (random[HurtMe](0, 4) == 0)
|
||||
{
|
||||
A_PlaySound (PainSound, CHAN_VOICE);
|
||||
health--;
|
||||
|
|
|
@ -1927,7 +1927,7 @@ class Meat : Actor
|
|||
override void BeginPlay ()
|
||||
{
|
||||
// Strife used mod 19, but there are 20 states. Hmm.
|
||||
SetState (SpawnState + random[GibTosser]() % 20);
|
||||
SetState (SpawnState + random[GibTosser](0, 19));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -74,7 +74,7 @@ class Templar : Actor
|
|||
|
||||
for (int i = 0; i < 10; ++i)
|
||||
{
|
||||
int damage = (random[Templar]() & 4) * 2;
|
||||
int damage = random[Templar](1, 4) * 2;
|
||||
double ang = angle + random2[Templar]() * (11.25 / 256);
|
||||
LineAttack (ang, MISSILERANGE+64., pitch + random2[Templar]() * (7.097 / 256), damage, 'Hitscan', "MaulerPuff");
|
||||
}
|
||||
|
|
|
@ -3,8 +3,8 @@ extend class Actor
|
|||
|
||||
void A_Bang4Cloud()
|
||||
{
|
||||
double xo = (random[Bang4Cloud]() & 3) * (10. / 64);
|
||||
double yo = (random[Bang4Cloud]() & 3) * (10. / 64);
|
||||
double xo = random[Bang4Cloud](0, 3) * (10. / 64);
|
||||
double yo = random[Bang4Cloud](0, 3) * (10. / 64);
|
||||
Spawn("Bang4Cloud", Vec3Offset(xo, yo, 0.), ALLOW_REPLACE);
|
||||
}
|
||||
|
||||
|
@ -221,10 +221,11 @@ class PowerCrystal : Actor
|
|||
Actor foo = Spawn("Rubble1", Pos, ALLOW_REPLACE);
|
||||
if (foo != NULL)
|
||||
{
|
||||
int t = random[LightOut]() & 15;
|
||||
foo.Vel.X = t - (random[LightOut]() & 7);
|
||||
foo.Vel.Y = random2[LightOut]() & 7;
|
||||
foo.Vel.Z = 7 + (random[LightOut]() & 3);
|
||||
int t = random[LightOut](0, 7);
|
||||
foo.Vel.X = t - random[LightOut](0, 15);
|
||||
t = random[LightOut](0, 7);
|
||||
foo.Vel.Y = t - random[LightOut](0, 15);
|
||||
foo.Vel.Z = random[LightOut](7, 10);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -62,7 +62,7 @@ extend class StateProvider
|
|||
}
|
||||
player.mo.PlayAttacking2 ();
|
||||
|
||||
int damage = 4*(random[StrifeGun]() % 3 + 1);
|
||||
int damage = 4 * random[StrifeGun](1, 3);
|
||||
double ang = angle;
|
||||
|
||||
if (player.refire)
|
||||
|
|
|
@ -49,7 +49,7 @@ class PunchDagger : StrifeWeapon
|
|||
else
|
||||
{
|
||||
int power = MIN(10, stamina / 10);
|
||||
damage = (random[JabDagger]() % (power + 8)) * (power + 2);
|
||||
damage = random[JabDagger](0, power + 7) * (power + 2);
|
||||
|
||||
if (FindInventory("PowerStrength"))
|
||||
{
|
||||
|
|
|
@ -113,7 +113,7 @@ class FlameMissile : Actor
|
|||
void A_FlameDie ()
|
||||
{
|
||||
bNoGravity = true;
|
||||
Vel.Z = random[FlameDie]() & 3;
|
||||
Vel.Z = random[FlameDie](0, 3);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -312,7 +312,7 @@ class PhosphorousFire : Actor
|
|||
drop.Vel.X = Vel.X + random2[PHBurn] (7);
|
||||
drop.Vel.Y = Vel.Y + random2[PHBurn] (7);
|
||||
drop.Vel.Z = Vel.Z - 1;
|
||||
drop.reactiontime = (random[PHBurn]() & 3) + 2;
|
||||
drop.reactiontime = random[PHBurn](2, 5);
|
||||
drop.bDropped = true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue