Merged Xylemon's diff that changes hard-coded sounds to sound shaders!

This commit is contained in:
Marco Cawthorne 2021-03-13 03:08:24 +01:00
parent 1b57acb5b7
commit 1d832d131e
4 changed files with 101 additions and 35 deletions

View file

@ -34,11 +34,7 @@ void
w_cannon_precache(void)
{
#ifdef SERVER
precache_sound("cannon/cin.wav");
precache_sound("cannon/close.wav");
precache_sound("cannon/cout.wav");
precache_sound("cannon/fire.wav");
precache_sound("cannon/open.wav");
Sound_Precache("weapon_cannon.shoot");
#else
precache_model("models/v_cannon.mdl");
precache_model("models/p_cannon.mdl");
@ -141,7 +137,7 @@ w_cannon_primary(void)
dmg = Skill_GetValue("plr_cannon", 5);
TraceAttack_FireBullets(20, pl.origin + pl.view_ofs, dmg, [0.08716,0.04362], WEAPON_CANNON);
pl.cannon_mag -= 2;
Weapons_PlaySound(pl, CHAN_WEAPON, "cannon/fire.wav", 1, ATTN_NORM);
Sound_Play(pl, CHAN_WEAPON, "weapon_cannon.shoot");
Weapons_UpdateAmmo(pl, pl.cannon_mag, pl.ammo_buckshot, __NULL__);
#endif
Weapons_ViewPunchAngle([-5,0,0]);
@ -171,7 +167,7 @@ w_cannon_secondary(void)
dmg = Skill_GetValue("plr_cannon", 5);
TraceAttack_FireBullets(10, pl.origin + pl.view_ofs, dmg, [0.08716,0.04362], WEAPON_CANNON);
pl.cannon_mag--;
Weapons_PlaySound(pl, CHAN_WEAPON, "cannon/fire.wav", 1, ATTN_NORM);
Sound_Play(pl, CHAN_WEAPON, "weapon_cannon.shoot");
#endif
if (pl.cannon_mag == 2) {

View file

@ -32,12 +32,11 @@ enum
void w_chainsaw_precache(void)
{
#ifdef SERVER
precache_sound("sh/chainsaw_cutinto.wav");
precache_sound("sh/chainsaw_cutintoflesh.wav");
precache_sound("sh/chainsaw_idle.wav");
precache_sound("sh/chainsaw_idle2.wav");
precache_sound("sh/chainsaw_pullout.wav");
precache_sound("sh/chainsaw_startup.wav");
Sound_Precache("weapon_chainsaw.attack");
Sound_Precache("weapon_chainsaw.hit");
Sound_Precache("weapon_chainsaw.hitflesh");
Sound_Precache("weapon_chainsaw.idle");
Sound_Precache("weapon_chainsaw.startup");
#else
precache_model("models/v_chainsaw.mdl");
precache_model("models/p_saw.mdl");
@ -60,8 +59,14 @@ string w_chainsaw_deathmsg(void)
void w_chainsaw_draw(void)
{
player pl = (player)self;
Weapons_SetModel("models/v_chainsaw.mdl");
Weapons_ViewAnimation(CHAINSAW_DEPLOY);
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_chainsaw.startup");
#endif
}
void w_chainsaw_holster(void)
@ -85,7 +90,7 @@ void w_chainsaw_primary(void)
traceline(src, src + (v_forward * 32), FALSE, pl);
if (trace_fraction >= 1.0) {
Weapons_PlaySound(pl, CHAN_WEAPON, "sh/chainsaw_idle2.wav", 1, ATTN_NORM);
Sound_Play(pl, CHAN_WEAPON, "weapon_chainsaw.attack");
pl.w_attack_next = 0.2f;
} else {
int dmg;
@ -93,15 +98,16 @@ void w_chainsaw_primary(void)
if (trace_ent.takedamage) {
if (trace_ent.iBleeds) {
FX_Blood(trace_endpos, [1,0,0]);
/* Push the player towards the victim */
pl.velocity = normalize(trace_ent.origin - pl.origin) * 240;
}
dmg = Skill_GetValue("plr_chainsaw", 10);
Damage_Apply(trace_ent, self, dmg, WEAPON_CHAINSAW, DMG_BLUNT);
Weapons_PlaySound(pl, CHAN_WEAPON, "sh/chainsaw_cutintoflesh.wav", 1, ATTN_NORM);
Sound_Play(pl, CHAN_WEAPON, "weapon_chainsaw.hitflesh");
} else {
FX_Spark(trace_endpos, trace_plane_normal);
Weapons_PlaySound(pl, CHAN_WEAPON, "sh/chainsaw_cutinto.wav", 1, ATTN_NORM);
Sound_Play(pl, CHAN_WEAPON, "weapon_chainsaw.hit");
}
pl.w_attack_next = 0.1f;
}
@ -124,14 +130,29 @@ void w_chainsaw_release(void)
Weapons_ViewAnimation(CHAINSAW_STOPFIRE);
return;
} else {
pl.w_idle_next = 10.0f;
}
/* TODO make these play right */
if (random() < 0.5) {
Weapons_ViewAnimation(CHAINSAW_IDLE1);
} else {
Weapons_ViewAnimation(CHAINSAW_IDLE2);
}
if (pl.w_idle_next > 0.0f) {
/* Loop idle sound */
if (pl.ammo_chainsaw_state == 0) {
#ifdef SERVER
Sound_Play(pl, CHAN_WEAPON, "weapon_chainsaw.idle");
#endif
}
pl.w_idle_next = 1.5f;
}
pl.w_attack_next = 0.2f;
}
float w_chainsaw_aimanim(void)

View file

@ -34,11 +34,9 @@ enum
void w_hammer_precache(void)
{
#ifdef SERVER
precache_sound("sh/ham_hitbod1.wav");
precache_sound("sh/ham_hitbod2.wav");
precache_sound("sh/ham_hitbod3.wav");
precache_sound("sh/ham_hitw.wav");
precache_sound("sh/ham_swing.wav");
Sound_Precache("weapon_hammer.hit");
Sound_Precache("weapon_hammer.hitflesh");
Sound_Precache("weapon_hammer.miss");
#else
precache_model("models/p_hammer.mdl");
precache_model("models/v_hammer.mdl");
@ -120,7 +118,10 @@ void w_hammer_release(void)
if (pl.ammo_hammer_state == 1) {
#ifdef SERVER
if (trace_ent.takedamage) {
hitsound = floor(random(1, 4));
if (trace_ent.iBleeds) {
FX_Blood(trace_endpos, [1,0,0]);
}
hitsound = floor(random(1, 2));
/* players only take half damage */
if (trace_ent.classname == "player")
@ -138,7 +139,7 @@ void w_hammer_release(void)
}
} else {
if (trace_fraction < 1.0) {
hitsound = 4;
hitsound = 2;
}
}
#endif
@ -147,12 +148,15 @@ void w_hammer_release(void)
} else if (pl.ammo_hammer_state == 2) {
#ifdef SERVER
if (trace_ent.takedamage) {
hitsound = floor(random(1, 4));
if (trace_ent.iBleeds) {
FX_Blood(trace_endpos, [1,0,0]);
}
hitsound = floor(random(1, 2));
hdmg = Skill_GetValue("plr_hammeralt", 200);
Damage_Apply(trace_ent, self, hdmg, WEAPON_HAMMER, DMG_BLUNT);
} else {
if (trace_fraction < 1.0) {
hitsound = 4;
hitsound = 2;
}
}
#endif
@ -162,22 +166,16 @@ void w_hammer_release(void)
#ifdef SERVER
if (pl.ammo_hammer_state > 0) {
string snd = "sh/ham_swing.wav";
string snd = "weapon_hammer.miss";
switch (hitsound) {
case 1:
snd = "sh/ham_hitbod1.wav";
snd = "weapon_hammer.hitflesh";
break;
case 2:
snd = "sh/ham_hitbod2.wav";
break;
case 3:
snd = "sh/ham_hitbod3.wav";
break;
case 4:
snd = "sh/ham_hitw.wav";
snd = "weapon_hammer.hit";
break;
}
Weapons_PlaySound(pl, CHAN_WEAPON, snd, 1.0f, ATTN_NORM);
Sound_Play(pl, CHAN_WEAPON, snd);
}
#endif

View file

@ -0,0 +1,51 @@
weapon_cannon.shoot
{
sample cannon/fire.wav
}
weapon_chainsaw.attack
{
sample sh/chainsaw_idle2.wav
}
weapon_chainsaw.draw
{
sample sh/chainsaw_pullout.wav
}
weapon_chainsaw.hit
{
sample sh/chainsaw_cutinto.wav
}
weapon_chainsaw.hitflesh
{
sample sh/chainsaw_cutintoflesh.wav
}
weapon_chainsaw.idle
{
sample sh/chainsaw_idle.wav
}
weapon_chainsaw.startup
{
sample sh/chainsaw_startup.wav
}
weapon_hammer.hit
{
sample sh/ham_hitw.wav
}
weapon_hammer.hitflesh
{
sample sh/ham_hitbod1.wav
sample sh/ham_hitbod2.wav
sample sh/ham_hitbod3.wav
}
weapon_hammer.miss
{
sample sh/ham_swing.wav
}