Use the predictable input_sequence variable for some random sequences.

This will soon be replaced by a more elaborate shared random number
generator of sorts.
This commit is contained in:
Marco Cawthorne 2019-09-17 20:46:00 +02:00
parent dff926c468
commit 91d1c2250f
15 changed files with 43 additions and 24 deletions

View file

@ -190,7 +190,8 @@ w_displacer_release(void)
return;
}
if (random() < 0.5) {
int r = (float)input_sequence % 3;
if (r == 1) {
Weapons_ViewAnimation(DISP_IDLE1);
} else {
Weapons_ViewAnimation(DISP_IDLE2);

View file

@ -122,8 +122,24 @@ w_eagle_release(void)
}
#endif
Weapons_ViewAnimation(EAGLE_IDLE1 + floor(random(0,5)));
pl.w_idle_next = 15.0f;
int r = (float)input_sequence % 4;
switch (r) {
case 0:
Weapons_ViewAnimation(EAGLE_IDLE1);
pl.w_idle_next = 2.5f;
break;
case 1:
Weapons_ViewAnimation(EAGLE_IDLE2);
pl.w_idle_next = 2.5f;
break;
case 2:
Weapons_ViewAnimation(EAGLE_IDLE3);
pl.w_idle_next = 1.633333f;
break;
default:
Weapons_ViewAnimation(EAGLE_IDLE4);
pl.w_idle_next = 2.5f;
}
}
void

View file

@ -107,7 +107,7 @@ w_knife_primary(void)
pl.w_idle_next = 2.5f;
#ifdef CSQC
r = floor(random(0,3));
r = (float)input_sequence % 3;
switch (r) {
case 0:
anim = trace_fraction >= 1 ? KNIFE_ATTACK1MISS:KNIFE_ATTACK1HIT;
@ -126,7 +126,7 @@ w_knife_primary(void)
Animation_PlayerTopTemp(ANIM_CR_SHOOTCROWBAR, 0.42f);
}
r = floor(random(0,3));
r = (float)input_sequence % 3;
switch (r) {
case 0:
sound(pl, CHAN_WEAPON, "weapons/knife1.wav", 1, ATTN_NORM);
@ -134,9 +134,8 @@ w_knife_primary(void)
case 1:
sound(pl, CHAN_WEAPON, "weapons/knife2.wav", 1, ATTN_NORM);
break;
case 2:
default:
sound(pl, CHAN_WEAPON, "weapons/knife3.wav", 1, ATTN_NORM);
break;
}
if (trace_fraction >= 1.0) {
@ -195,7 +194,6 @@ w_knife_release(void)
default:
Weapons_ViewAnimation(KNIFE_IDLE3);
pl.w_idle_next = 5.3f;
break;
}
}

View file

@ -181,7 +181,7 @@ w_penguin_deploy(void)
void
w_penguin_primary(void)
{
player pl = (player)self;
player pl = (player)self;
if (pl.w_attack_next > 0.0) {
return;
}
@ -238,7 +238,7 @@ w_penguin_release(void)
return;
}
r = floor(random(0,3));
r = (float)input_sequence % 3;
switch (r) {
case 0:
Weapons_ViewAnimation(PENGUIN_IDLE);

View file

@ -115,7 +115,7 @@ w_pipewrench_primary(void)
pl.w_idle_next = 2.5f;
#ifdef CSQC
int r = floor(random(0,3));
int r = (float)input_sequence % 3;
switch (r) {
case 0:
anim = trace_fraction >= 1 ? PIPE_ATTACK1MISS:PIPE_ATTACK1HIT;

View file

@ -200,7 +200,8 @@ w_sniperrifle_release(void)
return;
}
if (random() < 0.5) {
int r = (float)input_sequence % 2;
if (r == 1) {
Weapons_ViewAnimation(SNIPER_IDLE1);
} else {
Weapons_ViewAnimation(SNIPER_IDLE2);

View file

@ -193,7 +193,7 @@ void w_sporelauncher_release(void)
}
if (pl.a_ammo3 == SLSTATE_IDLE) {
int r = floor(random(0,3));
int r = (float)input_sequence % 3;
switch (r) {
case 0:
Weapons_ViewAnimation(SPORE_IDLE1);

View file

@ -269,7 +269,8 @@ w_crossbow_release(void)
}
#ifdef CSQC
if (random() < 0.75) {
int r = (float)input_sequence % 2;
if (r == 1) {
if (pl.a_ammo1) {
Weapons_ViewAnimation(CROSSBOW_IDLE1);
} else {

View file

@ -103,7 +103,7 @@ w_crowbar_primary(void)
pl.w_idle_next = 2.5f;
#ifdef CSQC
r = floor(random(0,3));
r = (float)input_sequence % 3;
switch (r) {
case 0:
anim = trace_fraction >= 1 ? CBAR_ATTACK1MISS:CBAR_ATTACK1HIT;
@ -142,7 +142,7 @@ w_crowbar_primary(void)
return;
}
r = floor(random(0,3));
r = (float)input_sequence % 3;
switch (r) {
case 0:
sound(pl, 8, "weapons/cbar_hitbod1.wav", 1, ATTN_NORM);
@ -150,12 +150,13 @@ w_crowbar_primary(void)
case 1:
sound(pl, 8, "weapons/cbar_hitbod2.wav", 1, ATTN_NORM);
break;
case 2:
default:
sound(pl, 8, "weapons/cbar_hitbod3.wav", 1, ATTN_NORM);
break;
}
} else {
if (random() < 0.5) {
r = (float)input_sequence % 2;
if (r == 1) {
sound(pl, 8, "weapons/cbar_hit1.wav", 1, ATTN_NORM);
} else {
sound(pl, 8, "weapons/cbar_hit2.wav", 1, ATTN_NORM);

View file

@ -236,7 +236,7 @@ w_glock_release(void)
return;
}
r = floor(random(0,3));
r = (float)input_sequence % 3;
switch (r) {
case 1:
Weapons_ViewAnimation(GLOCK_IDLE2);

View file

@ -144,7 +144,7 @@ w_hornetgun_release(void)
}
int r;
r = floor(random(0,3));
r = (float)input_sequence % 3;
switch (r) {
case 0:
Weapons_ViewAnimation(HORNETGUN_IDLE);

View file

@ -252,7 +252,8 @@ w_mp5_release(void)
return;
}
if (random() < 0.5) {
int r = (float)input_sequence % 3;
if (r == 1) {
Weapons_ViewAnimation(MP5_IDLE1);
} else {
Weapons_ViewAnimation(MP5_IDLE2);

View file

@ -207,7 +207,7 @@ w_python_release(void)
return;
}
int r = floor(random(0, 4));
int r = (float)input_sequence % 4;
switch (r) {
case 0:
Weapons_ViewAnimation(PYTHON_IDLE1);

View file

@ -188,7 +188,7 @@ void w_snark_release(void)
return;
}
r = floor(random(0,3));
r = (float)input_sequence % 3;
switch (r) {
case 0:
Weapons_ViewAnimation(SNARK_IDLE);

View file

@ -237,7 +237,7 @@ void w_tripmine_release(void)
return;
}
r = floor(random(0,3));
r = (float)input_sequence % 3;
switch (r) {
case 0: