New material sounds Created 6 years ago2018-03-03 11:46:14 UTC by Screamernail Screamernail

Created 6 years ago2018-03-03 11:46:14 UTC by Screamernail Screamernail

Posted 6 years ago2018-03-03 11:46:14 UTC Post #338930
I want to make brand new materials for the GoldSource engine like sand, grass(Not just dirt) and make new footstep sounds for wood and glass(Half-Life need's it). I have the SDK and I wonder just where is the file that defines materials? I'm currently developing mods for the android version with Xash3D but it can be useful to make your own materials in both engines.

Is it even possible?
Screamernail ScreamernailYour personal Fear
Posted 6 years ago2018-03-03 12:49:35 UTC Post #338931
The file you're looking for is sound/materials.txt, it assigns materials to each texture. The file contains an explanation as to how it works.

Codewise you need to consider a few things:
https://github.com/ValveSoftware/halflife/blob/master/pm_shared/pm_shared.c#L191
https://github.com/ValveSoftware/halflife/blob/master/dlls/sound.cpp#L1539

The same code is in 2 places, the former is used by physics code on both the client and server side, the latter is only used on the server side to handle things like crowbar hitting a wooden box sort of thing.

Adding new materials is a bit clunky, bear with me:
First you need to define a constant used to identify it, that's done in 2 places:
https://github.com/ValveSoftware/halflife/blob/master/pm_shared/pm_materials.h#L21
https://github.com/ValveSoftware/halflife/blob/master/pm_shared/pm_shared.c#L92

You also need to define a constant that this first one gets converted to so it can be used more easily:
https://github.com/ValveSoftware/halflife/blob/master/pm_shared/pm_shared.c#L104

Converted in this function:
https://github.com/ValveSoftware/halflife/blob/master/pm_shared/pm_shared.c#L441

Now you need to handle the actual sound playback. This time it's in 3 places:
https://github.com/ValveSoftware/halflife/blob/master/pm_shared/pm_shared.c#L322
https://github.com/ValveSoftware/halflife/blob/master/dlls/sound.cpp#L1687
https://github.com/ValveSoftware/halflife/blob/master/cl_dll/ev_hldm.cpp#L156

All are identical but use different ways to do it due to different engine interfaces.

Yes, it sucks, it should be easier, but this is GoldSource.

If you need help i can quickly clean this up and make it use a single definition for everything, and bypass the hardcoded limits too if you need it.
Posted 6 years ago2018-03-06 10:13:17 UTC Post #338947
Should make this as a tutorial post.
Screamernail ScreamernailYour personal Fear
Posted 6 years ago2018-03-06 11:06:15 UTC Post #338948
I think Condition Zero Deleted Scenes had a scripting approach to make it less difficult to change (check out half-life/czeror/materials).
Posted 6 years ago2018-03-06 11:48:39 UTC Post #338952
Looks like that system is even more complicated, existing code still uses materials.txt as in the SDK, but the client uses this new material system for effects like bullet impacts and the like.
You must be logged in to post a response.