• Ragdoll Collision-Sounds
    11 replies, posted
Is there a list with all sounds which could be played if a ragdoll collides with something? Where is the code for playing them?
If I'm not wrong, the sounds played on collide of a ragdoll is defined by the engine itself. You can override the sounds played on ragdoll on collide with these functions: [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/Entity/AddCallback"]Entity:AddCallback[/URL] [IMG]http://wiki.garrysmod.com/favicon.ico[/IMG] [URL="http://wiki.garrysmod.com/page/ENTITY/PhysicsCollide"]ENT:PhysicsCollide[/URL] eg. [CODE] function play_custom_collide_sound(ent,data) if (data.Speed > 50) then ent:EmitSound(Sound("SolidMetal.ImpactHard")) end end ragdoll_entity:AddCallback("PhysicsCollide",play_custom_collide_sound) [/CODE]
I want to remove the ragdoll collision sounds if the player which died has some special conditions. The gamemode is TTT. Are the sounds defined in GMod or in the Source Engine? Because in the Source Engine i hadn't found anything. And would this work for ragdolls created by Player:CreateRagdoll()?
1. [CODE] function play_custom_collide_sound(ent,data) if (!SOME_SPECIAL_CONDITION) then ent:EmitSound(Sound("SolidMetal.ImpactHard")) end end ragdoll_entity:AddCallback("PhysicsCollide",play_custom_collide_sound) [/CODE] 2. If you have the courage to explore the Source Engine's physics sound system, then go ahead for this: [URL]https://github.com/ValveSoftware/source-sdk-2013/blob/0d8dceea4310fde5706b3ce1c70609d72a38efdf/mp/src/game/client/physics.cpp#L421[/URL] Good luck if you come back alive to this thread after seeing it! 3. For Player:CreateRagdoll(), it shoulds work too.
So something like this could override the sounds: [CODE]hook.Add(“CreateEntityRagdoll“, “CER_BlockSound“, function(owner,ragdoll) function play_custom_collide_sound(ent,data) ent:EmitSound(Sound("SolidMetal.ImpactHard")) end if owner:IsGhost() and owner:GetRagdollEntity() == ragdoll then ragdoll:AddCallback("PhysicsCollide",play_custom_collide_sound) end end)[/CODE] Or did I miss understand you?
[CODE] function play_custom_collide_sound(ent,data) if !owner:IsGhost() and owner:GetRagdollEntity() == ragdoll then -- !owner:IsGhost() = If NOT a ghost, THEN make sound ent:EmitSound(Sound("SolidMetal.ImpactHard")) end end hook.Add(“CreateEntityRagdoll“, “CER_BlockSound“, function(owner,ragdoll) ragdoll:AddCallback("PhysicsCollide",play_custom_collide_sound) end) [/CODE] And avoid re-creating the function everytime the hook will trigger. EDIT: If you want a better control over the physics sounds system. You could always try your luck by asking ability to disable collision sound of a ragdoll at: [URL]https://github.com/Facepunch/garrysmod-requests/issues[/URL]
The hook "CreateEntityRagdoll" is somehow not executed as soon as a ragdoll was created. And I can't use OnEntityCreated. So how can I block this sound? The problem is if a user which is playing the SpecDM dies then a ragdoll will be created. And if the ragdoll collides with something you can hear it even if you are alive. And I want to prevent this. The ragdoll will be created with Player:CreateRagdoll() in the "DoPlayerDeath"-Hook.
What could I do? Is there no chance to prevent playing the sound?
In order to prevent sounds from being played I would say your best bet would be the EntityEmitSound hook. [URL="http://wiki.garrysmod.com/page/GM/EntityEmitSound"]http://wiki.garrysmod.com/page/GM/EntityEmitSound[/URL]
[QUOTE=Zeh Matt;50606381]In order to prevent sounds from being played I would say your best bet would be the EntityEmitSound hook. [URL="http://wiki.garrysmod.com/page/GM/EntityEmitSound"]http://wiki.garrysmod.com/page/GM/EntityEmitSound[/URL][/QUOTE] It seems like these sounds couldn't be caught through this hook. I've added into the hook a simple function which is Printing the Sound Table. I tried spawning a ragdoll with Player:CreateRagdoll(). I heard the sounds but nothing got printed. :/
[QUOTE=markusmarkusz;50606718]It seems like these sounds couldn't be caught through this hook. I've added into the hook a simple function which is Printing the Sound Table. I tried spawning a ragdoll with Player:CreateRagdoll(). I heard the sounds but nothing got printed. :/[/QUOTE] It works fine on my side [CODE]{ ["OriginalSoundName"] = "physics/body/body_medium_scrape_rough_loop1.wav", ["SoundTime"] = 0, ["Flags"] = 1, ["Entity"] = <Entity>: Entity [193][class C_HL2MPRagdoll]>, ["DSP"] = 0, ["Channel"] = 0, ["SoundLevel"] = 70, ["Ambient"] = false, ["Pitch"] = 100, ["SoundName"] = "physics/body/body_medium_scrape_rough_loop1.wav", ["Volume"] = 0.013014395721257, }[/CODE] The hook must be used clientside since those ragdolls are clientside, if your ragdolls are server side so use the hook server side obviously.
Finally i solved my problem. [CODE] hook.Add("EntityEmitSound", "EES_SpecDM", function(sound) local ragsounds = { "physics/body/body_medium_break2.wav", "physics/body/body_medium_break3.wav", "physics/body/body_medium_break4.wav", "physics/body/body_medium_impact_hard1.wav", "physics/body/body_medium_impact_hard2.wav", "physics/body/body_medium_impact_hard3.wav", "physics/body/body_medium_impact_hard4.wav", "physics/body/body_medium_impact_hard5.wav", "physics/body/body_medium_impact_hard6.wav", "physics/body/body_medium_impact_soft1.wav", "physics/body/body_medium_impact_soft2.wav", "physics/body/body_medium_impact_soft3.wav", "physics/body/body_medium_impact_soft4.wav", "physics/body/body_medium_impact_soft5.wav", "physics/body/body_medium_impact_soft6.wav", "physics/body/body_medium_impact_soft7.wav", "physics/body/body_medium_scrape_rough_loop1.wav", "physics/body/body_medium_scrape_smooth_loop1.wav", "physics/body/body_medium_strain1.wav", "physics/body/body_medium_strain2.wav", "physics/body/body_medium_strain3.wav", } for k,s in pairs(ragsounds) do if sound["SoundName"] == s then if IsValid(sound["Entity"]) and sound["Entity"]:GetClass() == "class C_HL2MPRagdoll" or sound["Entity"]:GetClass() == "worldspawn" or sound["Entity"]:GetClass() == "hl2mp_ragdoll" then for _,ply in pairs(player.GetAll()) do if IsValid(ply) and ply:IsPlayer() and ply:IsSpec() then return false end end end end end end) [/CODE] I always though that the ragdoll or the player emits the sound. But now I know that the sound got also emitted by the entity "worldspawn".
Sorry, you need to Log In to post a reply to this thread.