Updated the game-specific PMove code to be part of our player class
This commit is contained in:
parent
e6dac8fe81
commit
69aaa52a7a
2 changed files with 20 additions and 16 deletions
|
@ -97,6 +97,10 @@ class player:base_player
|
|||
PREDICTED_FLOAT(anim_bottom);
|
||||
PREDICTED_FLOAT(anim_bottom_time);
|
||||
|
||||
virtual float(void) Physics_MaxSpeed;
|
||||
virtual void(float) Physics_Fall;
|
||||
virtual void(void) Physics_Jump;
|
||||
|
||||
#ifdef CLIENT
|
||||
/* External model */
|
||||
entity p_model;
|
||||
|
|
|
@ -40,11 +40,11 @@
|
|||
|
||||
/* values courtesy of https://wiki.alliedmods.net/Cs_weapons_information */
|
||||
float
|
||||
GamePMove_Maxspeed(player target)
|
||||
player::Physics_MaxSpeed(void)
|
||||
{
|
||||
float spd = serverkeyfloat("phy_maxspeed");
|
||||
|
||||
switch (target.activeweapon)
|
||||
switch (activeweapon)
|
||||
{
|
||||
case WEAPON_M3:
|
||||
spd *= 230/250;
|
||||
|
@ -130,7 +130,7 @@ GamePMove_Maxspeed(player target)
|
|||
default:
|
||||
}
|
||||
|
||||
if (target.flags & FL_CROUCHING) {
|
||||
if (flags & FL_CROUCHING) {
|
||||
spd *= 0.5f;
|
||||
}
|
||||
|
||||
|
@ -138,36 +138,36 @@ GamePMove_Maxspeed(player target)
|
|||
}
|
||||
|
||||
void
|
||||
GamePMove_Fall(player target, float impactspeed)
|
||||
player::Physics_Fall(float impactspeed)
|
||||
{
|
||||
impactspeed *= 1.25f;
|
||||
if (impactspeed > 580) {
|
||||
#ifdef SERVER
|
||||
float fFallDamage = (impactspeed - 580) * (100 / (1024 - 580)) * 0.75f;
|
||||
Damage_Apply(target, world, fFallDamage, 0, DMG_FALL | DMG_SKIP_ARMOR);
|
||||
Damage_Apply(this, world, fFallDamage, 0, DMG_FALL | DMG_SKIP_ARMOR);
|
||||
|
||||
if (random() < 0.5)
|
||||
sound(target, CHAN_AUTO, "player/pl_pain2.wav", 1.0, ATTN_NORM);
|
||||
sound(this, CHAN_AUTO, "player/pl_pain2.wav", 1.0, ATTN_NORM);
|
||||
else
|
||||
sound(target, CHAN_AUTO, "player/pl_pain4.wav", 1.0, ATTN_NORM);
|
||||
sound(this, CHAN_AUTO, "player/pl_pain4.wav", 1.0, ATTN_NORM);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
GamePMove_Jump(player target)
|
||||
player::Physics_Jump(void)
|
||||
{
|
||||
if (target.waterlevel >= 2) {
|
||||
if (target.watertype == CONTENT_WATER) {
|
||||
target.velocity[2] = 100;
|
||||
} else if (target.watertype == CONTENT_SLIME) {
|
||||
target.velocity[2] = 80;
|
||||
if (waterlevel >= 2) {
|
||||
if (watertype == CONTENT_WATER) {
|
||||
velocity[2] = 100;
|
||||
} else if (watertype == CONTENT_SLIME) {
|
||||
velocity[2] = 80;
|
||||
} else {
|
||||
target.velocity[2] = 50;
|
||||
velocity[2] = 50;
|
||||
}
|
||||
} else {
|
||||
/* slow the player down a bit to prevent bhopping like crazy */
|
||||
target.velocity *= 0.80f;
|
||||
target.velocity[2] += 200;
|
||||
velocity *= 0.80f;
|
||||
velocity[2] += 200;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue