From 69aaa52a7a19b3c1be2cf32fbf655daf0bd38f8d Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Tue, 8 Jun 2021 15:31:50 +0200 Subject: [PATCH] Updated the game-specific PMove code to be part of our player class --- src/shared/player.h | 4 ++++ src/shared/pmove.qc | 32 ++++++++++++++++---------------- 2 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/shared/player.h b/src/shared/player.h index 7b5fa05..8d05382 100644 --- a/src/shared/player.h +++ b/src/shared/player.h @@ -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; diff --git a/src/shared/pmove.qc b/src/shared/pmove.qc index 6bc735e..54c5742 100644 --- a/src/shared/pmove.qc +++ b/src/shared/pmove.qc @@ -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; } }