View Single Post
PC Gamer
Veteran Member
Join Date: Mar 2014
Old 09-22-2020 , 23:58   Re: [TF2] Custom Weapons 3 (Beta 2)
Reply With Quote #258

Quote:
Originally Posted by torridgristle View Post
In game_sounds_weapons.txt there are sounds defined that use multiple sound files, is there a way to replace a sound that uses only one sound file with a sound that uses multiple randomly chosen sound files? Like the stock Revolver with the Enforcer?
You can make a plugin that replaces specific weapon sounds with something else. To replace the revolver shot sound with random enforcer sounds you can do something like this:
PHP Code:
#include <sourcemod>
#include <sdktools>

#pragma semicolon 1

public Plugin myinfo 
{
    
name "[TF2] Revolver Sound Replacement",
    
author "torridgristle",
    
description "Replaces Revolver Shooting Sounds with Enforcer Sounds",
    
version "PLUGIN_VERSION 1.0",
    
url "www.sourcemod.com"    
}

public 
OnPluginStart()
{
    
AddNormalSoundHook(SoundHook);
    
PrecacheSound("weapons/tf_spy_enforcer_revolver_01.wav");
    
PrecacheSound("weapons/tf_spy_enforcer_revolver_02.wav");
    
PrecacheSound("weapons/tf_spy_enforcer_revolver_03.wav");
    
PrecacheSound("weapons/tf_spy_enforcer_revolver_04.wav");
    
PrecacheSound("weapons/tf_spy_enforcer_revolver_05.wav");
    
PrecacheSound("weapons/tf_spy_enforcer_revolver_06.wav");
    
PrecacheSound("weapons/tf_spy_enforcer_revolver_crit.wav");    
}

public 
Action:SoundHook(clients[64], &numClientsString:sound[PLATFORM_MAX_PATH], &entity, &channel, &Float:volume, &level, &pitch, &flags)
{
    if (
StrEqual(sound"weapons/revolver_shoot.wav"))
    {
        
int iRand GetRandomInt(1,6);
        switch (
iRand)
        {
        case 
1:
            {
                
Format(soundsizeof(sound), "weapons/tf_spy_enforcer_revolver_01.wav");
                
EmitSoundToClient(entity"weapons/tf_spy_enforcer_revolver_01.wav"entity);
                return 
Plugin_Changed;
            }
        case 
2:
            {
                
Format(soundsizeof(sound), "weapons/tf_spy_enforcer_revolver_02.wav");
                
EmitSoundToClient(entity"weapons/tf_spy_enforcer_revolver_02.wav"entity);
                return 
Plugin_Changed;
            }
        case 
3:
            {
                
Format(soundsizeof(sound), "weapons/tf_spy_enforcer_revolver_03.wav");
                
EmitSoundToClient(entity"weapons/tf_spy_enforcer_revolver_03.wav"entity);
                return 
Plugin_Changed;
            }
        case 
4:
            {
                
Format(soundsizeof(sound), "weapons/tf_spy_enforcer_revolver_04.wav");
                
EmitSoundToClient(entity"weapons/tf_spy_enforcer_revolver_04.wav"entity);
                return 
Plugin_Changed;
            }
        case 
5:
            {
                
Format(soundsizeof(sound), "weapons/tf_spy_enforcer_revolver_05.wav");
                
EmitSoundToClient(entity"weapons/tf_spy_enforcer_revolver_05.wav"entity);
                return 
Plugin_Changed;
            }
        case 
6:
            {
                
Format(soundsizeof(sound), "weapons/tf_spy_enforcer_revolver_06.wav");
                
EmitSoundToClient(entity"weapons/tf_spy_enforcer_revolver_06.wav"entity);
                return 
Plugin_Changed;
            }                
        }            
    }
    if (
StrEqual(sound"weapons/revolver_shoot_crit.wav"))
    {
        
Format(soundsizeof(sound), "weapons/tf_spy_enforcer_revolver_crit.wav");
        
EmitSoundToClient(entity"weapons/tf_spy_enforcer_revolver_crit.wav"entity);
        return 
Plugin_Changed;
    }
    return 
Plugin_Continue;

Note: This plugin has not been tested so let me know if it works for you. It is supposed to replace a revolver shot sound with a randomly selected enforcer shot sound. There are six possible enforcer shot sounds. It also replaces a revolver critical shot sound with the enforcer critical shot sound. In my opinion all six of the enforcer shot sounds sounded almost identical.

Keep in mind that if you don't like the stock game sounds you can add your own sounds to the game. I added custom sounds to the Batsaber on my server to make it sound more like a lightsaber. I also changed some of the many annoying Announcer sounds such as control point warnings/flag drops/etc. to a much quieter duck quack.

Enjoy!
Attached Files
File Type: sp Get Plugin or Get Source (replacerevolversound.sp - 128 views - 2.6 KB)
PC Gamer is offline