Merge material property definitions into the surfaceproperties system to streamline

everything more and to allow level designers custom properties without recompiling
the game-logic. This will also make it more Source Engine compatible.
This commit is contained in:
Marco Cawthorne 2022-10-15 22:43:32 -07:00
parent db2d3b1730
commit f01e90ad2e
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
30 changed files with 461 additions and 883 deletions

123
Documentation/Prop_data.md Normal file
View File

@ -0,0 +1,123 @@
# Prop data
The prop data system was introduced in **Source Engine
2004**, it's been integrated into Nuclide and supported in a few different ways.
## Overview {#overview}
It allows you to easily create, without any programming knowledge,
breakable props and entities.
That way, when you place prop_dynamic
entities into the world for example, they will all have the same
material, health and behavior when being interacted with.
Other entities, such as func_breakable can
also take advantage of them.
## Specs {#specs}
A global propdata definition file can be found at `scripts/propdata.txt`
and it contains structures for types and a separate section titled
**BreakableModels**. You can ignore the latter for now.
An example propdata.txt looks like this:
` "PropData.txt"`
` {`
` `
`   "sometype"`
`   {`
`     // .. key/field attributes`
`     // e.g.`
`     "health" "10"`
`     "breakable_model" "somematerial"`
`   }`
` `
`   "BreakableModels"`
`   {`
`     // completely unrelated to types defined in propdata.txt`
`     // but somehow still part of it?`
` `
`     "somematerial"`
`     {`
`       // model path / fadeout time pair`
`       // e.g.`
`       "foo.vvm" "2.5"`
`     }`
`   }`
` }`
The idea is that props specify the type of prop they are ("sometype")
and it defines a set of sensible defaults.
However, props can override any parts of this inside the model data
itself. Currently no model format FTEQW supports allows for reading of
said propdata. However we'll be loading "foobar.vvm.propdata" to remedy
this for those.
## Usage {#usage}
Any entity in Nuclide that inherits NSSurfacePropEntity can take advantage
of the propdata features.
Either the entity inside the map defines which propdata definition it
wants to use (via the .propdata string field), or the model file has a
text definition alongside as mentioned above.
### Map entity key {#map_entity_key}
An example for the example specification listed above would be a
propdata key/value pair as part of the entity definition:
` {`
`   "classname" "func_wall"`
`   "model"     "*42"`
`   "propdata"  "sometype"`
` }`
### Model propdata definition {#model_propdata_definition}
If you had a model, e.g. located at `models/foobar.vvm` then if you were
to place a file named `models/foobar.vvm.propdata` alongside it with the
following contents:
` PropData.txt`
` {`
`   prop_data`
`   {`
`     "health" "30"`
`     "breakable_model" "somematerial"`
`     "breakable_count" "10"`
`   }`
` }`
This registers an internal propdata definition with the name
**models/foobar.vvm.propdata** that would correspond to the above
contents. You have to absolutely make sure that the model's .propdata
file calls the data structure **prop_data** however, like described
above.
You don't have to do anything else in the entity, the prop model will
now have health of 30 and break into 'somematerial' upon its
destruction.
## Commands {#commands}
- **base <string>**: Which propdata fields to inherit.
- **blockLOS <bool>**: Will this prop break the line-of-sight of NPCs?
- **AIWalkable <bool>**: Can AI walk over this?
- **allow_static <bool>**: Will static props use this definition?
- **dmg.bullets <float>**: Damage multiplier for bullets.
- **dmg.club <float>**: Damage multiplier for melee weapons.
- **dmg.explosive <float>**: Damage multiplier for explosive weapons.
- **health <int>**: Absolute amount of health on spawn.
- **explosive_damage <int>**: Makes the entity explosive, with <int>
specifying the max amount of damage.
- **explosive_radius <float>**: Sets the explosion radius in q units.
Is 2.5 times the damage by default.
- **breakable_particle <string>**: Which particle effect to play when
this entity breaks.
- **breakable_model <string>**: Which models to spawn when it breaks.
- **breakable_count <int>**: The amount of models it'll spawn upon
breaking.

113
Documentation/Surf_data.md Normal file
View File

@ -0,0 +1,113 @@
# Surface Properties
**Surfaces** are being abstracted into one API with the help of **Surf
Data** helper functions and large parts of NSSurfacePropEntity.
# Preface {#preface}
## The problem {#the_problem}
We need to define how a surface, speak a texture-mapped triangle,
behaves when being interacted with.
- What happens when e.g. a bullet collides with it?
- What sounds does it make when it collides with other objects?
- What physical properties does it have that make it special?
## History {#history}
In GoldSrc and similar engines, you'd specify
which material is used through 3 ways:
- The surface is a map texture, with a short material character
definition inside `sound/materials.txt` defining what the surface is
made of. See (MatGoldSrc.md) for details.
- The entity itself offers a list of materials to choose from for
impact/breaking properties. For example `func_breakable` has the
`material` key. Which then tells the rest of the codebase that this
object will respond like whatever it's defined as.
- The entity might hard-code what it's made of. For example you could
say an entity will always be `glass`, or always be `metal`. Level
designers can't change these.
**In that engine, this attribute merely affected audio visual feedback
like bullet impacts.**
They all sounded the same when it came to physics etc.
Nowadays the artists want more control, they want to decide if an entity
uses special particle effects for impacts, or sounds - the sound it
makes when it scrapes across the floor or gets shaken - the weight of
the object and the friction it deals with.
## Understanding the new way {#understanding_the_new_way}
So in Nuclide, there's a few options too as to how you're able to define
what property anything is made of.
- For the level geometry, a `surfaceparm` is used to
define what material properties to use. There are a lot of basic materials
to choose from there.
- For models, the `surfaceParm` command inside the .QC can be used to
define a surfaceparm.
- Entities can **specify** which entry from
`scripts/surfaceproperties.txt` get's used. This is required for
NSPhysicsEntity derived classes.
Those entities set their `surfdata` or `materialdata` key/value
field to be the name of an entity listed inside the
`surfaceproperties.txt` file.
- ...of course, the old way is supported as long as you're using a
legacy format that does not support **surfaceParms**. They'll get
mapped to a pair of pre-defined entries, which mods can override.
And instead of defining a single character defining the audio visual
appearance, you can now tweak every aspect of it. See **Scripting**
below.
Also, if an entity does not specify the material character inside the
script, Nuclide will figure it out on a surrounding surfaceparm basis.
# Scripting {#scripting}
Scripts are formatted like our soundDefs:
typename
{
key/value pairs
...
}
Available keys are:
"base" <string> what type to inherit
"gamematerial" <char> material character, e.g. W for wood
"climbable" <bool> ???
"thickness" <float> non-solid, air (?) thickness
"density" <int> material density in kg / m^3
"elasticity" <float> 0.0 - 1.0 ; soft to hard
"friction" <float> friction multiplier
"dampening" <float> drag multiplier
"jumpfactor" <float> bouncyness?
"maxspeedfactor" <float> maxvelocity?
"stepleft" <string> footstep left
"stepright" <string> footstep right
"bulletimpact" <string> soundDef to play on impact
"scraperough" <string> soundDef to play on rough scraping
"scrapesmooth" <string> soundDef to play on smooth scraping
"impacthard" <string> soundDef for hard impacts
"impactsoft" <string> soundDef for soft impacts
"shake" <string> sound to play when object is being shaken
"strain" <string> sound to play when object is being strained?
"break" <string> sound to play when object breaks
"roll/rolling" <string> sound to play when object rolls
none of these are concerning us right now:
"audioreflectivity" <float>
"audiohardnessfactor" <float>
"audioroughnessfactor" <float>
"scrapeRoughThreshold" <float>
"impactHardThreshold" <float>
"audioHardMinVelocity" <float>

View File

@ -886,6 +886,8 @@ INPUT = src/ \
Documentation/Materials/commands/ \
Documentation/Materials/MatShaders.md \
Documentation/Materials/MatGoldSrc.md \
Documentation/Surf_data.md \
Documentation/Prop_data.md \
Documentation/Sound/ \
Documentation/Models/ \
Documentation/History.md \

View File

@ -1,18 +1,18 @@
// define which material classes (right) are used for
// define which surface properties (right) are used for
// which material ids (letters on the left side)
B,BloodyFlesh
C,Concrete
D,Dirt
F,Flesh
G,Grate
H,Alien
K,Snow
M,Metal
N,Sand
O,Foliage
P,Computer
S,Slosh
T,Tile
V,Vent
W,Wood
Y,Glass
B,gs_material_flesh
C,gs_material_concrete
D,gs_material_dirt
F,gs_material_flesh
G,gs_material_grate
H,gs_material_alien
K,gs_material_snow
M,gs_material_metal
N,gs_material_sand
O,gs_material_foliage
P,gs_material_computer
S,gs_material_slosh
T,gs_material_tile
V,gs_material_vent
W,gs_material_wood
Y,gs_material_glass

View File

@ -1,53 +1,159 @@
default
{
fx_bulletimpact "fx_impact.default"
bulletimpact "sfx_impact.default"
stepleft "step_default.left"
stepright "step_default.right"
}
gs_material_glass
{
gamematerial Y
bulletimpact "func_breakable.impact_glass"
fx_bulletimpact "fx_impact.glass"
bulletimpact "sfx_impact.glass"
stepleft "step_glass.left"
stepright "step_glass.right"
}
gs_material_wood
{
gamematerial W
bulletimpact "func_breakable.impact_wood"
fx_bulletimpact "fx_impact.wood"
bulletimpact "sfx_impact.wood"
stepleft "step_wood.left"
stepright "step_wood.right"
}
gs_material_metal
{
gamematerial M
bulletimpact "func_breakable.impact_metal"
fx_bulletimpact "fx_impact.metal"
bulletimpact "sfx_impact.metal"
stepleft "step_metal.left"
stepright "step_metal.right"
}
gs_material_flesh
{
gamematerial F
bulletimpact "func_breakable.impact_flesh"
fx_bulletimpact "fx_impact.flesh"
bulletimpact "sfx_impact.flesh"
stepleft "step_flesh.left"
stepright "step_flesh.right"
}
gs_material_cinderblock
{
gamematerial C
bulletimpact "func_breakable.impact_cinderblock"
fx_bulletimpact "fx_impact.concrete"
bulletimpact "sfx_impact.concrete"
stepleft "step_default.left"
stepright "step_default.right"
}
gs_material_tile
{
gamematerial T
bulletimpact "func_breakable.impact_tile"
fx_bulletimpact "fx_impact.tile"
bulletimpact "sfx_impact.tile"
stepleft "step_tile.left"
stepright "step_tile.right"
}
gs_material_computer
{
gamematerial P
bulletimpact "func_breakable.impact_computer"
fx_bulletimpact "fx_impact.computer"
bulletimpact "sfx_impact.computer"
stepleft "step_computer.left"
stepright "step_computer.right"
}
gs_material_unbreakableglass
{
gamematerial Y
bulletimpact "func_breakable.impact_glassunbreakable"
fx_bulletimpact "fx_impact.glass"
bulletimpact "sfx_impact.glass"
stepleft "step_glass.left"
stepright "step_glass.right"
}
gs_material_rocks
gs_material_rock
{
gamematerial C
bulletimpact "func_breakable.impact_rock"
fx_bulletimpact "fx_impact.rock"
bulletimpact "sfx_impact.rock"
stepleft "step_default.left"
stepright "step_default.right"
}
gs_material_flesh
{
fx_bulletimpact "fx_impact.flesh"
bulletimpact "sfx_impact.flesh"
stepleft "step_flesh.left"
stepright "step_flesh.right"
}
gs_material_concrete
{
fx_bulletimpact "fx_impact.concrete"
bulletimpact "sfx_impact.concrete"
stepleft "step_concrete.left"
stepright "step_concrete.right"
}
gs_material_dirt
{
fx_bulletimpact "fx_impact.dirt"
bulletimpact "sfx_impact.dirt"
stepleft "step_dirt.left"
stepright "step_dirt.right"
}
gs_material_grate
{
fx_bulletimpact "fx_impact.grate"
bulletimpact "sfx_impact.grate"
stepleft "step_grate.left"
stepright "step_grate.right"
}
gs_material_alien
{
fx_bulletimpact "fx_impact.alien"
bulletimpact "sfx_impact.alien"
stepleft "step_alien.left"
stepright "step_alien.right"
}
gs_material_snow
{
fx_bulletimpact "fx_impact.snow"
bulletimpact "sfx_impact.snow"
stepleft "step_snow.left"
stepright "step_snow.right"
}
gs_material_sand
{
fx_bulletimpact "fx_impact.sand"
bulletimpact "sfx_impact.sand"
stepleft "step_sand.left"
stepright "step_sand.right"
}
gs_material_foliage
{
fx_bulletimpact "fx_impact.foliage"
bulletimpact "sfx_impact.foliage"
stepleft "step_slosh.left"
stepright "step_slosh.right"
}
gs_material_slosh
{
fx_bulletimpact "fx_impact.slosh"
bulletimpact "sfx_impact.slosh"
stepleft "step_slosh.left"
stepright "step_slosh.right"
}
gs_material_vent
{
fx_bulletimpact "fx_impact.snow"
bulletimpact "sfx_impact.snow"
stepleft "step_vent.left"
stepright "step_vent.right"
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Alien:NSMaterial
{
void(void) Alien;
};
void
Alien::Alien(void)
{
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Computer:NSMaterial
{
void(void) Computer;
};
void
Computer::Computer(void)
{
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Concrete:NSMaterial
{
void(void) Concrete;
};
void
Concrete::Concrete(void)
{
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Dirt:NSMaterial
{
void(void) Dirt;
};
void
Dirt::Dirt(void)
{
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Flesh:NSMaterial
{
void(void) Flesh;
};
void
Flesh::Flesh(void)
{
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Foliage:NSMaterial
{
void(void) Foliage;
};
void
Foliage::Foliage(void)
{
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Glass:NSMaterial
{
void(void) Glass;
};
void
Glass::Glass(void)
{
}

View File

@ -1,25 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Grate:NSMaterial
{
void(void) Grate;
};
void
Grate::Grate(void)
{
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Metal:NSMaterial
{
void(void) Metal;
};
void
Metal::Metal(void)
{
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Sand:NSMaterial
{
void(void) Sand;
};
void
Sand::Sand(void)
{
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Slosh:NSMaterial
{
void(void) Slosh;
};
void
Slosh::Slosh(void)
{
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Snow:NSMaterial
{
void(void) Snow;
};
void
Snow::Snow(void)
{
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Tile:NSMaterial
{
void(void) Tile;
};
void
Tile::Tile(void)
{
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Vent:NSMaterial
{
void(void) Vent;
};
void
Vent::Vent(void)
{
}

View File

@ -1,26 +0,0 @@
/*
* Copyright (c) 2016-2022 Vera Visions LLC.
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF MIND, USE, DATA OR PROFITS, WHETHER
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
class Wood:NSMaterial
{
void(void) Wood;
};
void
Wood::Wood(void)
{
}

View File

@ -1,17 +0,0 @@
#includelist
Alien.qc
Computer.qc
Concrete.qc
Dirt.qc
Flesh.qc
Foliage.qc
Glass.qc
Grate.qc
Metal.qc
Sand.qc
Slosh.qc
Snow.qc
Tile.qc
Vent.qc
Wood.qc
#endlist

View File

@ -315,6 +315,8 @@ init(float prevprogs)
{
print("--------- Initializing Server-Module ----------\n");
Plugin_Init();
Sound_Init();
PropData_Init();
SurfData_Init();
}
@ -351,7 +353,6 @@ initents(void)
print("--------- Initializing Server Entities ----------\n");
/* sound shader init */
Sound_Init();
Materials_Init();
PMove_Init();

View File

@ -15,7 +15,4 @@
*/
void Footsteps_Init(void);
void Footsteps_HLBSP(NSClientPlayer target);
void Footsteps_VVBSP(NSClientPlayer target);
void Footsteps_Default(NSClientPlayer target);
void Footsteps_Update(void);

248
src/server/footsteps.qc Executable file → Normal file
View File

@ -24,44 +24,6 @@ Just precaching sound shaders for all the types of material oriented footsteps.
void
Footsteps_Init(void)
{
Sound_Precache("step_default.left");
Sound_Precache("step_default.right");
Sound_Precache("step_alien.left");
Sound_Precache("step_alien.right");
Sound_Precache("step_computer.left");
Sound_Precache("step_computer.right");
Sound_Precache("step_concrete.left");
Sound_Precache("step_concrete.right");
Sound_Precache("step_dirt.left");
Sound_Precache("step_dirt.right");
Sound_Precache("step_flesh.left");
Sound_Precache("step_flesh.right");
Sound_Precache("step_foliage.left");
Sound_Precache("step_foliage.right");
Sound_Precache("step_glass.left");
Sound_Precache("step_glass.right");
Sound_Precache("step_grate.left");
Sound_Precache("step_grate.right");
Sound_Precache("step_metal.left");
Sound_Precache("step_metal.right");
Sound_Precache("step_sand.left");
Sound_Precache("step_sand.right");
Sound_Precache("step_slosh.left");
Sound_Precache("step_slosh.right");
Sound_Precache("step_snow.left");
Sound_Precache("step_snow.right");
Sound_Precache("step_tile.left");
Sound_Precache("step_tile.right");
Sound_Precache("step_vent.left");
Sound_Precache("step_vent.right");
Sound_Precache("step_wood.left");
Sound_Precache("step_wood.right");
Sound_Precache("step_ladder.left");
Sound_Precache("step_ladder.right");
Sound_Precache("step_wade.left");
Sound_Precache("step_wade.right");
Sound_Precache("step_swim.left");
Sound_Precache("step_swim.right");
}
/*
@ -77,179 +39,33 @@ Footsteps_HLBSP(NSClientPlayer target)
{
string mat_name = "";
string tex_name = "";
string sound = "";
//tracebox(target.origin, PHY_HULL_MIN, PHY_HULL_MAX, target.origin + [0,0,-48], MOVE_NORMAL, target);
traceline(target.origin + target.view_ofs, target.origin + [0,0,-48], FALSE, target);
tex_name = getsurfacetexture(trace_ent, getsurfacenearpoint(trace_ent, trace_endpos));
if (target.flags & FL_ONGROUND) {
tex_name = Materials_FixName(tex_name);
switch((float)hash_get(hashMaterials, tex_name)) {
case MATID_ALIEN:
mat_name = "step_alien";
break;
case MATID_BLOODYFLESH:
mat_name = "step_flesh";
break;
case MATID_COMPUTER:
mat_name = "step_computer";
break;
case MATID_CONCRETE:
mat_name = "step_concrete";
break;
case MATID_DIRT:
mat_name = "step_dirt";
break;
case MATID_FLESH:
mat_name = "step_flesh";
break;
case MATID_FOLIAGE:
mat_name = "step_foliage";
break;
case MATID_GLASS:
mat_name = "step_glass";
break;
case MATID_GRATE:
mat_name = "step_grate";
break;
case MATID_METAL:
mat_name = "step_metal";
break;
case MATID_SLOSH:
mat_name = "step_slosh";
break;
case MATID_SNOW:
mat_name = "step_snow";
break;
case MATID_TILE:
mat_name = "step_tile";
break;
case MATID_VENT:
mat_name = "step_vent";
break;
case MATID_WOOD:
mat_name = "step_wood";
break;
default:
mat_name = "step_default";
break;
}
if (!(target.flags & FL_ONGROUND)) {
return;
} else if (target.flags & FL_ONLADDER) {
mat_name = "step_ladder";
if (target.step)
Sound_Play(target, CHAN_BODY, sprintf("%s.left", mat_name));
else
Sound_Play(target, CHAN_BODY, sprintf("%s.right", mat_name));
return;
}
if (target.step) {
Sound_Play(target, CHAN_BODY, sprintf("%s.left", mat_name));
Sound_Play(target, CHAN_BODY,
SurfData_GetInfo(SurfData_TexToSurfData(tex_name), SURFDATA_SND_STEPLEFT));
} else {
Sound_Play(target, CHAN_BODY, sprintf("%s.right", mat_name));
}
}
/*
=================
Footsteps_VVBSP
Modern BSP format which uses surfaceflags to specify materials on surfaces.
=================
*/
void
Footsteps_VVBSP(NSClientPlayer target)
{
string mat_name = "";
/* WIP */
if (target.flags & FL_ONGROUND) {
target.hitcontentsmaski = CONTENTBITS_POINTSOLID;
tracebox(target.origin, target.mins, target.maxs, (target.origin + [0,0,-16]), MOVE_NORMAL, target);
target.hitcontentsmaski = 0;
trace_surfaceflagsi &= ~SURF_MASK;
switch (trace_surfaceflagsi) {
case SURF_ALIEN:
mat_name = "step_alien";
break;
case SURF_BLOODYFLESH:
mat_name = "step_flesh";
break;
case SURF_FOLIAGE:
mat_name = "step_foliage";
break;
case SURF_COMPUTER:
mat_name = "step_computer";
break;
case SURF_DIRT:
mat_name = "step_dirt";
break;
case SURF_VENT:
mat_name = "step_vent";
break;
case SURF_GRATE:
mat_name = "step_grate";
break;
case SURF_METAL:
mat_name = "step_metal";
break;
case SURF_GLASS:
mat_name = "step_glass";
break;
case SURF_SAND:
mat_name = "step_sand";
break;
case SURF_SLOSH:
mat_name = "step_slosh";
break;
case SURF_SNOW:
mat_name = "step_snow";
break;
case SURF_TILE:
mat_name = "step_tile";
break;
case SURF_WOOD:
mat_name = "step_wood";
break;
case SURF_CONCRETE:
mat_name = "step_concrete";
break;
default:
mat_name = "step_default";
}
} else if (target.flags & FL_ONLADDER) {
mat_name = "step_ladder";
Sound_Play(target, CHAN_BODY,
SurfData_GetInfo(SurfData_TexToSurfData(tex_name), SURFDATA_SND_STEPRIGHT));
}
if (target.step) {
Sound_Play(target, CHAN_BODY, sprintf("%s.left", mat_name));
} else {
Sound_Play(target, CHAN_BODY, sprintf("%s.right", mat_name));
}
}
/*
=================
Footsteps_Default
Default for any map format which we don't support or don't know how to support
materials for.
=================
*/
void
Footsteps_Default(NSClientPlayer target)
{
string mat_name = "";
/* WIP */
if (target.flags & FL_ONGROUND) {
mat_name = "step_default";
} else if (target.flags & FL_ONLADDER) {
mat_name = "step_ladder";
}
if (target.step) {
Sound_Play(target, CHAN_BODY, sprintf("%s.left", mat_name));
} else {
Sound_Play(target, CHAN_BODY, sprintf("%s.right", mat_name));
}
}
/*
@ -275,54 +91,42 @@ Footsteps_Update(void)
pl = (NSClientPlayer)self;
if (pl.movetype == MOVETYPE_WALK) {
if ((pl.velocity[0] == 0 && pl.velocity[1] == 0) || pl.step_time > time) {
if ((pl.velocity[0] == 0 && pl.velocity[1] == 0) || pl.step_time > time)
return;
}
if (pl.waterlevel == 1) {
if (pl.step) {
if (pl.step)
Sound_Play(pl, CHAN_BODY, "step_slosh.left");
} else {
else
Sound_Play(pl, CHAN_BODY, "step_slosh.right");
}
pl.step_time = time + 0.35f;
} else if (pl.waterlevel == 2) {
if (pl.step) {
if (pl.step)
Sound_Play(pl, CHAN_BODY, "step_wade.left");
} else {
else
Sound_Play(pl, CHAN_BODY, "step_wade.right");
}
pl.step_time = time + 1.0f;
} else if (pl.waterlevel == 3) {
if (pl.step) {
if (pl.step)
Sound_Play(pl, CHAN_BODY, "step_swim.left");
} else {
else
Sound_Play(pl, CHAN_BODY, "step_swim.right");
}
pl.step_time = time + 2.0f;
} else {
/* make it so we step once we land */
if (!(pl.flags & FL_ONGROUND) && !(pl.flags & FL_ONLADDER)) {
pl.step_time = 0.0f;
return;
}
}
/* the footsteps call might overwrite this later */
pl.step_time = time + 0.35;
switch (serverkeyfloat("*bspversion")) {
case BSPVER_HL:
Footsteps_HLBSP(pl);
break;
case BSPVER_Q3: /* Q3 */
case BSPVER_RTCW: /* RtCW */
case BSPVER_RBSP: /* RFVBSP */
Footsteps_VVBSP(pl);
break;
default:
Footsteps_Default(pl);
}
}
Footsteps_HLBSP(pl);
/* switch between feet */
pl.step = 1 - pl.step;

View File

@ -14,44 +14,10 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
/** Parent-class of all materials, used for footsteps, impacts and more. */
class
NSMaterial
{
private:
string m_strMaterialName;
bool m_bPenetrable;
bool m_bFootsteps;
float m_flFriction;
string m_strStepSound;
nonvirtual void _PrecacheAndExit(string);
public:
void NSMaterial(void);
/** Returns the friction multiplier of this surface. */
virtual float GetFriction(void);
/** Returns whether the material creates footstep sounds. */
virtual bool Footsteps(void);
/** Returns whether or not the material is penetrable. */
virtual bool Penetrable(void);
/** Called whenever a client makes a stepping sound. */
virtual void FootstepSound(NSClient);
/** Called whenever a bullet impact happens onto this material. */
virtual void Impact(vector,vector);
/** Called upon init for each registered game material. */
virtual void Precache(void);
};
hashtable g_hashMaterials;
hashtable hashMaterials;
void Materials_Init(void);
NSMaterial Material_FromTexture(string);
/* legacy material compatibility */

View File

@ -14,83 +14,6 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void
NSMaterial::NSMaterial(void)
{
m_bPenetrable = false;
m_bFootsteps = false;
m_flFriction = 1.0f;
m_strStepSound = "step.default";
}
void
NSMaterial::_PrecacheAndExit(string cname)
{
/* make it searchable */
classname = "NSMaterial";
m_strMaterialName = cname;
Precache();
}
float
NSMaterial::GetFriction(void)
{
return (m_flFriction);
}
bool
NSMaterial::Footsteps(void)
{
return (m_bFootsteps);
}
bool
NSMaterial::Penetrable(void)
{
return (m_bPenetrable);
}
void
NSMaterial::Precache(void)
{
/* foobar */
}
void
NSMaterial::FootstepSound(NSClient client)
{
/* foobar */
}
void
NSMaterial::Impact(vector vecOrigin, vector vecAngle)
{
print(sprintf("Called impact on material %S at %v, %v\n", m_strMaterialName, vecOrigin, vecAngle));
}
/** Takes a material classname and precaches it. */
static void
Materials_PrecacheClass(string cname)
{
string func = strcat("spawnfunc_", cname);
/* does the material class exist? */
if (isfunction(func)) {
entity oldself = self;
void(void) vFunc;
vFunc = externvalue(-2, func);
NSMaterial new_mat = spawn(NSMaterial);
self = new_mat;
vFunc();
new_mat._PrecacheAndExit(cname);
self = oldself;
print(sprintf("material class %s cached successfully.\n", cname));
} else {
print(sprintf("material class %s failed to load.\n", cname));
}
}
/* general purpose functions to interact with the material system */
static void
@ -144,7 +67,6 @@ Materials_LoadFromMat(string filename)
if (command == "material") {
hash_add(g_hashMaterials, materialname, parameters, EV_STRING);
Materials_PrecacheClass(parameters);
print(sprintf("added Material %S type %S\n", materialname, parameters));
break;
}
@ -186,7 +108,6 @@ Materials_Mapper_Init(void)
if (tokenizebyseparator(sTemp, ",") == 2) {
g_hlmlut[c].id = argv(0);
g_hlmlut[c].matclass = argv(1);
Materials_PrecacheClass(argv(1));
c++;
}
}
@ -297,36 +218,3 @@ Materials_Init(void)
}
}
}
/** Returns an NSMaterial for a given material. */
NSMaterial
Material_FromTexture(string tex_name)
{
NSMaterial ret = __NULL__;
string mat = "";
/* older map formats need their names 'fixed' */
if (g_materialsAreLegacy == true) {
tex_name = Materials_FixName(tex_name);
}
mat = (string)hash_get(g_hashMaterials, tex_name);
if not (mat)
return __NULL__;
/** look for all existing materials */
if (mat != "")
for (entity f = world; (f = find(f, ::classname, "NSMaterial"));) {
ret = (NSMaterial)f;
/* we found it */
if (ret.m_strMaterialName == mat)
return ret;
}
/* just return a dummy NSMaterial... */
ret = spawn(NSMaterial);
ret._PrecacheAndExit(mat);
return ret;
}

View File

@ -32,5 +32,4 @@ util.qc
weapons.qc
../xr/include.src
../materials/include.src
#endlist

View File

@ -52,56 +52,6 @@ typedef enum
} materialType_t;
/* HLBSP materials.txt character id's */
//#define MATID_UNUSED1 'A'
#define MATID_BLOODYFLESH 'B'
#define MATID_CONCRETE 'C'
#define MATID_DIRT 'D'
//#define MATID_UNUSED2 'E'
#define MATID_FLESH 'F'
#define MATID_GRATE 'G'
#define MATID_ALIEN 'H'
//#define MATID_UNUSED3 'I'
//#define MATID_GRASS 'J'
//#define MATID_PLASTIC 'L'
#define MATID_METAL 'M'
#define MATID_FOLIAGE 'O'
#define MATID_COMPUTER 'P'
//#define MATID_ASPHALT 'Q'
//#define MATID_BRICK 'R'
#define MATID_SLOSH 'S'
#define MATID_TILE 'T'
#define MATID_CARDBOARD 'U'
#define MATID_VENT 'V'
#define MATID_WOOD 'W'
//#define MATID_UNUSED4 'X'
#define MATID_GLASS 'Y'
//#define MATID_UNUSED5 'Z'
/* CS defines snow as 'N' on GoldSrc, whereas in Source it's reserved for sand */
#ifdef CSTRIKE
#define MATID_SNOW 'N'
#define MATID_SAND 'K'
#else
#define MATID_SNOW 'K'
#define MATID_SAND 'N'
#endif
/* modern additions, not implemented yet */
#define MATID_CLAY 1
#define MATID_PLASTER 2
#define MATID_ROCK 3
#define MATID_RUBBER 4
#define MATID_SHEETROCK 5
#define MATID_CLOTH 6
#define MATID_CARPET 7
#define MATID_PAPER 8
#define MATID_UPHOLSTERY 9
#define MATID_PUDDLE 10
#define MATID_MUD 11
#define MATID_SANDBARREL 12
/* q3 bsp base flags */
#define SURF_NODAMAGE 0x1i // never give falling damage
#define SURF_SLICK 0x2i // effects game physics
@ -134,7 +84,7 @@ typedef enum
#define SURF_RESERVED6 0x04000000i
#define SURF_PENETRATE 0x08000000i
/* material surfaceflags (need to be masked) */
/* old TW material surfaceflags (need to be masked) */
#define SURF_MASK 0x0FFFFFFFi
#define SURF_ALIEN 0x10000000i
#define SURF_BLOODYFLESH 0x20000000i

View File

@ -84,6 +84,8 @@ typedef struct
string m_sndStrain;
string m_sndRoll;
string m_sndBreak;
string m_fxBulletImpact;
} surfaceData_t;
/* entity will have to have a .surfdata field pointing to an id */
@ -113,7 +115,7 @@ typedef enum
SURFDATA_SND_STRAIN,
SURFDATA_SND_ROLL,
SURFDATA_SND_BREAK,
SURFDATA_FX_IMPACT,
SURFDATA_FX_BULLETIMPACT,
} surfinfo_t;
/* initialized SurfaceKit */
@ -124,6 +126,8 @@ void SurfData_SetStage(string type);
/* Finishes initialization, returns valid SurfaceKit id */
int SurfData_Finish(void);
int SurfData_TexToSurfData(string tex_name);
/* Call an impact effect against an entity surface */
void SurfData_Impact(entity e, int fl, vector org, vector ang);

View File

@ -19,6 +19,7 @@
static materialType_t
SurfData_IDtoMaterial(float mat)
{
#if 0
switch (mat) {
case MATID_GLASS:
return GSMATERIAL_GLASS;
@ -47,12 +48,14 @@ SurfData_IDtoMaterial(float mat)
default:
return GSMATERIAL_NONE;
}
#endif
}
/* takes a material id (e.g. 'W' for wood) and returns an impact */
static impactType_t
SurfData_IDtoImpact(float mat)
{
#if 0
switch (mat) {
case MATID_GLASS:
return IMPACT_GLASS;
@ -106,6 +109,7 @@ SurfData_IDtoImpact(float mat)
default:
return IMPACT_DEFAULT;
}
#endif
}
/* takes a surfaceflag material bit and returns an impact */
@ -214,6 +218,9 @@ SurfData_ParseField(int i, int a)
case "rolling":
g_surfdata[i].m_sndBreak = argv(1);
break;
case "fx_bulletimpact":
g_surfdata[i].m_fxBulletImpact = argv(1);
break;
}
}
@ -305,6 +312,23 @@ SurfData_CountLine(string line)
return;
}
int
SurfData_TexToSurfData(string tex_name)
{
string mat = "";
/* older map formats need their names 'fixed' */
if (g_materialsAreLegacy == true)
tex_name = Materials_FixName(tex_name);
mat = (string)hash_get(g_hashMaterials, tex_name);
if not (mat)
return __NULL__;
/* we got the surfdata string, return that */
return SurfData_Load(mat);
}
/* Public API functions */
__variant
@ -353,8 +377,8 @@ SurfData_GetInfo(int i, int type)
return (__variant)g_surfdata[i].m_sndRoll;
case SURFDATA_SND_BREAK:
return (__variant)g_surfdata[i].m_sndBreak;
case SURFDATA_FX_IMPACT:
return (__variant)SurfData_IDtoImpact(g_surfdata[i].m_flMaterial);
case SURFDATA_FX_BULLETIMPACT:
return (__variant)g_surfdata[i].m_fxBulletImpact;
default:
return __NULL__;
}
@ -433,6 +457,12 @@ SurfData_Init(void)
SurfData_Parse(line);
}
fclose(fh);
for (int i = 0; i < g_surfdata_count; i++) {
Sound_Precache(g_surfdata[i].m_sndStepLeft);
Sound_Precache(g_surfdata[i].m_sndStepRight);
Sound_Precache(g_surfdata[i].m_sndBulletImpact);
}
}
static string g_curSurfData;
@ -462,15 +492,9 @@ void
SurfData_Impact(entity e, int fl, vector org, vector ang)
{
static void SurfData_Impact_SurfaceParm(entity e, int fl, vector org, vector ang) {
#ifdef OLD_MATERIALS
/* provided for backwards compatibility with the old surfaceflag based materials */
#ifdef OLD_MATERIALS
switch (serverkeyfloat("*bspversion")) {
case BSPVER_HL:
float surf;
string tex_name;
surf = getsurfacenearpoint(e, org);
tex_name = Materials_FixName(getsurfacetexture(e, surf));
FX_Impact(SurfData_IDtoImpact(HLMaterials_Fetch(tex_name)), org, ang);
break;
case BSPVER_Q3: /* Q3 */
case BSPVER_RTCW: /* RtCW */
case BSPVER_RBSP: /* RFVBSP */
@ -480,13 +504,20 @@ SurfData_Impact(entity e, int fl, vector org, vector ang)
default:
FX_Impact(IMPACT_DEFAULT, org, ang);
}
#else
#else
float surf = getsurfacenearpoint(e, org);
NSMaterial foo = Material_FromTexture(getsurfacetexture(e, surf));
string tex_name = getsurfacetexture(e, surf);
if (foo)
foo.Impact(org, ang);
#endif
string impactsfx = SurfData_GetInfo(SurfData_TexToSurfData(tex_name), SURFDATA_SND_BULLETIMPACT);
string impactfx = SurfData_GetInfo(SurfData_TexToSurfData(tex_name), SURFDATA_FX_BULLETIMPACT);
NSLog("playing impact sfx %S at %v", impactsfx, org);
NSLog("playing impact fx %S at %v", impactfx, org);
Sound_PlayAt(org, impactsfx);
#endif
}
/* the static world */
@ -496,7 +527,7 @@ SurfData_Impact(entity e, int fl, vector org, vector ang)
NSSurfacePropEntity foo = (NSSurfacePropEntity)e;
if (foo.HasSurfaceData() && foo.GetSurfaceData(SURFDATA_MATERIAL) != -1)
FX_Impact(foo.GetSurfaceData(SURFDATA_FX_IMPACT), org, ang);
FX_Impact(foo.GetSurfaceData(SURFDATA_FX_BULLETIMPACT), org, ang);
else
SurfData_Impact_SurfaceParm(e, fl, org, ang);
}