Removal of Footsteps_Update outside of NSClientPlayer. Mods now have the full ability to override steps within the player class. Method name subject to change.

This commit is contained in:
Marco Cawthorne 2022-11-01 19:54:56 -07:00
parent 606edfadcc
commit 003bc5d88a
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
7 changed files with 92 additions and 110 deletions

View File

@ -94,7 +94,6 @@ var bool autocvar_mp_flashlight = true;
void FX_Impact(impactType_t, vector, vector);
void FX_Explosion(vector);
void FX_GibHuman(vector vecOrigin, vector vecDir, float flForce);
void Footsteps_Update(void);
void TraceAttack_FireBullets(int, vector, int, vector, int);
#ifdef BULLETPENETRATION

View File

@ -14,5 +14,4 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
void Footsteps_Init(void);
void Footsteps_Update(void);
void Footsteps_Init(void);

View File

@ -25,110 +25,3 @@ void
Footsteps_Init(void)
{
}
/*
=================
Footsteps_HLBSP
Footstep code for BSP version 30, which uses an external materials.txt
to specify materials.
=================
*/
void
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)) {
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,
SurfData_GetInfo(SurfData_TexToSurfData(tex_name), SURFDATA_SND_STEPLEFT));
} else {
Sound_Play(target, CHAN_BODY,
SurfData_GetInfo(SurfData_TexToSurfData(tex_name), SURFDATA_SND_STEPRIGHT));
}
}
/*
=================
Footsteps_Update
Run every frame for each player, plays material based footsteps
=================
*/
void
Footsteps_Update(void)
{
NSClientPlayer pl;
/* mp_footsteps is only available in MP matches */
if (Util_IsSingleplayer() == false)
if (autocvar(mp_footsteps, 1) == 0)
return;
if (self.classname != "player")
return;
pl = (NSClientPlayer)self;
if (pl.movetype == MOVETYPE_WALK) {
if ((pl.velocity[0] == 0 && pl.velocity[1] == 0) || pl.step_time > time)
return;
if (pl.waterlevel == 1) {
if (pl.step)
Sound_Play(pl, CHAN_BODY, "step_slosh.left");
else
Sound_Play(pl, CHAN_BODY, "step_slosh.right");
pl.step_time = time + 0.35f;
} else if (pl.waterlevel == 2) {
if (pl.step)
Sound_Play(pl, CHAN_BODY, "step_wade.left");
else
Sound_Play(pl, CHAN_BODY, "step_wade.right");
pl.step_time = time + 1.0f;
} else if (pl.waterlevel == 3) {
if (pl.step)
Sound_Play(pl, CHAN_BODY, "step_swim.left");
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;
Footsteps_HLBSP(pl);
/* switch between feet */
pl.step = 1 - pl.step;
}
}

View File

@ -143,6 +143,8 @@ NSClientPlayer:NSClientSpectator
virtual void(void) InputUse_Down;
virtual void(void) InputUse_Up;
#endif
virtual void Footsteps_Update(void);
};
/* all potential SendFlags bits we can possibly send */

View File

@ -1024,3 +1024,88 @@ NSClientPlayer::InputUse_Up(void)
}
}
#endif
void
NSClientPlayer::Footsteps_Update(void)
{
#ifdef SERVER
string mat_name = "";
string tex_name = "";
string sound = "";
/* mp_footsteps is only available in MP matches */
if (Util_IsSingleplayer() == false)
if (autocvar(mp_footsteps, 1) == 0)
return;
if (movetype != MOVETYPE_WALK)
return;
if ((velocity[0] == 0 && velocity[1] == 0) || step_time > time)
return;
if (waterlevel == 1) {
if (step)
StartSoundDef("step_slosh.left", CHAN_BODY, true);
else
StartSoundDef("step_slosh.right", CHAN_BODY, true);
step_time = time + 0.35f;
} else if (waterlevel == 2) {
if (step)
StartSoundDef("step_wade.left", CHAN_BODY, true);
else
StartSoundDef("step_wade.right", CHAN_BODY, true);
step_time = time + 1.0f;
} else if (waterlevel == 3) {
if (step)
StartSoundDef("step_swim.left", CHAN_BODY, true);
else
StartSoundDef("step_swim.right", CHAN_BODY, true);
step_time = time + 2.0f;
} else {
/* make it so we step once we land */
if (!(flags & FL_ONGROUND) && !(flags & FL_ONLADDER)) {
step_time = 0.0f;
return;
}
}
/* the footsteps call might overwrite this later */
step_time = time + 0.35;
//tracebox(origin, PHY_HULL_MIN, PHY_HULL_MAX, origin + [0,0,-48], MOVE_NORMAL, target);
traceline(origin + view_ofs, origin + [0,0,-48], FALSE, this);
tex_name = getsurfacetexture(trace_ent, getsurfacenearpoint(trace_ent, trace_endpos));
if (!(flags & FL_ONGROUND)) {
return;
} else if (flags & FL_ONLADDER) {
if (step)
StartSoundDef("step_ladder.left", CHAN_BODY, true);
else
StartSoundDef("step_ladder.right", CHAN_BODY, true);
/* switch between feet */
step = 1 - step;
return;
}
if (step) {
StartSoundDef(
SurfData_GetInfo(SurfData_TexToSurfData(tex_name), SURFDATA_SND_STEPLEFT),
CHAN_BODY,
true);
} else {
StartSoundDef(
SurfData_GetInfo(SurfData_TexToSurfData(tex_name), SURFDATA_SND_STEPRIGHT),
CHAN_BODY,
true);
}
/* switch between feet */
step = 1 - step;
#endif
}

View File

@ -1104,6 +1104,7 @@ NSEntity::StartSound(string strSample, float channel, float flags, bool broadcas
bool
NSEntity::StartSoundDef(string strSample, float channel, bool broadcast)
{
NSLog("StartSoundDef: %s %d %d", strSample, channel, broadcast);
Sound_Play(this, channel, strSample);
return (true);
}

View File

@ -385,6 +385,9 @@ NSClientPlayer::Physics_Run(void)
/* give us a chance to manipulate input_ globals before running physics */
Physics_InputPreMove();
/* handle footsteps */
Footsteps_Update();
/* handle drowning and other environmental factors */
Physics_WaterMove();