Raised This Month: $32 Target: $400
 8% 

Solved [TF2] Cannot mute minigun sounds...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Naydef
Senior Member
Join Date: Dec 2015
Location: Doom Town, Nevada
Old 09-02-2018 , 06:42   [TF2] Cannot mute minigun sounds...
Reply With Quote #1

Hello everyone,
What i'm trying to make now is FF2 subplugin which will replace minigun(tf_weapon_minigun) sounds with custom one. So far i have no luck while trying to mute the default sound played by the weapon:
1. Sound Hooks are not fired when the weapon is playing sounds
2. I found out it uses m_iWeaponState which plays sound for every client client-side, then i used code from Be the giant deflector heavyplugin to detect when minigun starts playing sound. It manages to play the new sound, but it doesn't stop the default one
3. Applied "minigun no spin sounds" attribute to the minigun, but this attribute doesn't want to work with stock minigun and it only stops windup sounds...
4. Another idea is to use SendProxy and send another value of m_iWeaponState netvar to clients, but looking at the leaked Source 2007 code, this will break client-side animation, not sure, but strongly sure this will happen, so didn't try this method
5. Another idea is to disable client-side prediction faking the cvar sv_client_predict, but i know this will deteriorate the game experience(laggy movement, slow action, etc)

I'm stuck and i don't know what to do to prevent minigun sounds from playing but without side effects. I can accept "NO" answer too, just tell me if it's possible or not

Edit:
My fast and dirty plugin for testing minigun sound replacement:
PHP Code:
#include <sourcemod>
#include <sdktools>
#include <freak_fortress_2>
#include <tf2attributes>

bool Locked1[MAXPLAYERS+1];
bool Locked2[MAXPLAYERS+1];
bool Locked3[MAXPLAYERS+1];
bool CanWindDown[MAXPLAYERS+1];

bool stopsound=false;

#define SOUND_GUNFIRE    ")mvm/giant_heavy/giant_heavy_gunfire.wav"
#define SOUND_GUNSPIN    ")mvm/giant_heavy/giant_heavy_gunspin.wav"
#define SOUND_WINDUP    ")mvm/giant_heavy/giant_heavy_gunwindup.wav"
#define SOUND_WINDDOWN    ")mvm/giant_heavy/giant_heavy_gunwinddown.wav"

#define SOUND_GUNFIRE_1    "mvm/giant_heavy/giant_heavy_gunfire.wav"
#define SOUND_GUNSPIN_1    "mvm/giant_heavy/giant_heavy_gunspin.wav"
#define SOUND_WINDUP_1    "mvm/giant_heavy/giant_heavy_gunwindup.wav"
#define SOUND_WINDDOWN_1    "mvm/giant_heavy/giant_heavy_gunwinddown.wav"

public OnPluginStart()
{
    
RegAdminCmd("sm_stopsounds"Command_StopSoundsADMFLAG_CHEATS"Stop a sound!");
    
//HookUserMessage(GetUserMessageId("PlayerTauntSoundLoopStart"), HookTauntMessage, true);
    //AddNormalSoundHook(HookSound);
    
PrecacheSound(SOUND_GUNFIRE_1);
    
PrecacheSound(SOUND_GUNSPIN_1);
    
PrecacheSound(SOUND_WINDUP_1);
    
PrecacheSound(SOUND_WINDDOWN_1);
}

public 
Action:Command_StopSounds(clientargs)
{
    
stopsound=!stopsound;
    
ReplyToCommand(client"Toggled!");
    
int value=1;
    if(
stopsound)
    {
        
int index=1;
        while ((
index FindEntityByClassname(index"tf_weapon_minigun")) != -1)
        {
            
TF2Attrib_SetByName(index"minigun no spin sounds"view_as<float>(value));
        }
    }
    return 
Plugin_Handled;

}

/*
public Action HookTauntMessage(UserMsg msg_id, BfRead msg, const int[] players, int playersNum, bool reliable, bool init)
{
    int byte = msg.ReadByte(); //The client index sending the sound
    char string[PLATFORM_MAX_PATH]; //The sound
    msg.ReadString(string, PLATFORM_MAX_PATH);
    
    if(stopsound)
    {
        PrintToServer("%i %s", byte, string);
        
        return Plugin_Handled;
    }
    return Plugin_Continue;
}
*/

public Action OnPlayerRunCmd(int iClientintiButtonsintiImpulsefloat[3fVelfloat[3fAngintiWeapon
{
    if(!
stopsound)
    {
        return 
Plugin_Continue;
    }
    if (
IsValidClient(iClient)) 
    {    
        
int weapon GetPlayerWeaponSlot(iClient0);
        
char classname[64];
        
GetEntityClassname(weaponclassnamesizeof(classname));
        if(
IsValidEntity(weapon) && StrEqual(classname"tf_weapon_minigun"false))
        {
            
int iWeaponState GetEntProp(weaponProp_Send"m_iWeaponState");
            if (
iWeaponState == && !Locked1[iClient])
            {
                
EmitSoundToAll(SOUND_WINDUPiClient);
            
//    PrintToChatAll("WeaponState = Windup");
                
                
Locked1[iClient] = true;
                
Locked2[iClient] = false;
                
Locked3[iClient] = false;
                
CanWindDown[iClient] = true;
                
                
StopSound(iClientSNDCHAN_AUTOSOUND_GUNSPIN);
                
StopSound(iClientSNDCHAN_AUTOSOUND_GUNFIRE);
            }
            else if (
iWeaponState == && !Locked2[iClient])
            {
                
EmitSoundToAll(SOUND_GUNFIREiClient);
            
//    PrintToChatAll("WeaponState = Firing");
                
                
Locked2[iClient] = true;
                
Locked1[iClient] = true;
                
Locked3[iClient] = false;
                
CanWindDown[iClient] = true;
                
                
StopSound(iClientSNDCHAN_AUTOSOUND_GUNSPIN);
                
StopSound(iClientSNDCHAN_AUTOSOUND_WINDUP);
            }
            else if (
iWeaponState == && !Locked3[iClient])
            {
                
EmitSoundToAll(SOUND_GUNSPINiClient);
            
//    PrintToChatAll("WeaponState = Spun Up");
                
                
Locked3[iClient] = true;
                
Locked1[iClient] = true;
                
Locked2[iClient] = false;
                
CanWindDown[iClient] = true;
                
                
StopSound(iClientSNDCHAN_AUTOSOUND_GUNFIRE);
                
StopSound(iClientSNDCHAN_AUTOSOUND_WINDUP);
            }
            else if (
iWeaponState == 0)
            {
                if (
CanWindDown[iClient])
                {
            
//        PrintToChatAll("WeaponState = WindDown");
                    
EmitSoundToAll(SOUND_WINDDOWNiClient);
                    
CanWindDown[iClient] = false;
                }
                
                
StopSound(iClientSNDCHAN_AUTOSOUND_GUNSPIN);
                
StopSound(iClientSNDCHAN_AUTOSOUND_GUNFIRE);
                
                
Locked1[iClient] = false;
                
Locked2[iClient] = false;
                
Locked3[iClient] = false;
            }
        }
    }
    return 
Plugin_Continue;
}

bool IsValidClient(client)
{
    if (
client <= 0) return false;
    if (
client MaxClients) return false;
    return 
IsClientInGame(client);
}


/*
#if SOURCEMOD_V_MAJOR==1 && SOURCEMOD_V_MINOR<=7
public Action:HookSound(clients[64], &numClients, String:sound[PLATFORM_MAX_PATH], &client, &channel, &Float:volume, &level, &pitch, &flags)
#else
public Action:HookSound(clients[64], &numClients, String:sound[PLATFORM_MAX_PATH], &client, &channel, &Float:volume, &level, &pitch, &flags, String:soundEntry[PLATFORM_MAX_PATH], &seed)
#endif
{
    if(stopsound)
    {
        PrintToChatAll("Sound: %s", sound);
        EmitSound(clients, numClients, "vo/engineer_ThanksForTheHeal02.mp3", client, channel, level, flags, volume, pitch);
        return Plugin_Stop;
    }
    return Plugin_Continue;
}
*/ 
What happens is that both the new and default sounds are played and overlapped
__________________
My plugins:
*None for now*


Steam:
naydef

Last edited by Naydef; 09-16-2018 at 05:56.
Naydef is offline
ThatKidWhoGames
Veteran Member
Join Date: Jun 2013
Location: IsValidClient()
Old 09-04-2018 , 12:07   Re: [TF2] Cannot mute minigun sounds...
Reply With Quote #2

Weapon sounds are client side sadly, no way of stopping them

Last edited by ThatKidWhoGames; 09-04-2018 at 12:08.
ThatKidWhoGames is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 09-05-2018 , 18:41   Re: [TF2] Cannot mute minigun sounds...
Reply With Quote #3

As a side note, I think that the MvM Giant Heavy's weapon sounds are actually tied to the weapon he has equipped. That is, the Deflector (item index 850, item class "tf_weapon_minigun").

I'm not sure if the Deflector's ability to shoot down rockets is part of the weapon itself or an attribute that the population manager adds to it. robot_giant.pop implies that the population manager adds it rather than it being part of the weapon itself.

Edit: If this isn't the case, it might be tied to the response system instead.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 09-05-2018 at 18:43.
Powerlord is offline
Benoist3012
Veteran Member
Join Date: Mar 2014
Location: CWave::ForceFinish()
Old 09-08-2018 , 16:27   Re: [TF2] Cannot mute minigun sounds...
Reply With Quote #4

Quote:
Originally Posted by Powerlord View Post
As a side note, I think that the MvM Giant Heavy's weapon sounds are actually tied to the weapon he has equipped. That is, the Deflector (item index 850, item class "tf_weapon_minigun").

I'm not sure if the Deflector's ability to shoot down rockets is part of the weapon itself or an attribute that the population manager adds to it. robot_giant.pop implies that the population manager adds it rather than it being part of the weapon itself.

Edit: If this isn't the case, it might be tied to the response system instead.
I remember while digging through disassembled code that the minigun sounds with giant & mvm checks was under a shared function so the sounds are server sided and client sided, there's no real way of blocking them. As for the deflector weapon it's just a regular minigun that shoots green bullets, as you said valve manually adds the deflect projectile attrib on it, it's not on by default.

Also we have normal giant heavies in mvm with no deflector weapon, which demonstrates that the minigun being muted for giants isn't tied to their weapon ID but rather because they are miniboss and the gamemode is mvm. You can experiment this by joining blu team in mvm as heavy, set the bool prop m_bIsMiniboss on true and your minigun will make the giant minigun sounds. An interesting fact is that it doesn't work outside of mvm it seems the client & server also checks for the gamemode not just if m_bIsMiniboss is on true.

Edit: the minigun also seems to create a instanced_scripted_scene entity with sound everytime it's winded up down, or maintained down. Dunno if they are worth checking, but perhaps try to kill them it may glitch the client into not playing the sounds (although I doubt it)
__________________

Last edited by Benoist3012; 09-08-2018 at 16:31.
Benoist3012 is offline
Naydef
Senior Member
Join Date: Dec 2015
Location: Doom Town, Nevada
Old 09-16-2018 , 05:56   Re: [TF2] Cannot mute minigun sounds...
Reply With Quote #5

Thanks for the answers, i will check later with instanced_scripted_scene.
__________________
My plugins:
*None for now*


Steam:
naydef
Naydef is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 15:01.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode