Updated the game-specific PMove code to be part of our player class

This commit is contained in:
Marco Cawthorne 2021-06-08 15:31:21 +02:00
parent a2602bb131
commit 8f051dd406
4 changed files with 51 additions and 73 deletions

View file

@ -161,14 +161,13 @@ Player_DestroyWeaponModel(entity pp)
remove(pl.p_model); remove(pl.p_model);
} }
void PMove_SetSize(entity targ);
void void
Player_PreDraw(base_player pl, int thirdperson) Player_PreDraw(base_player pl, int thirdperson)
{ {
/* Handle the flashlights... */ /* Handle the flashlights... */
Player_Flashlight(pl); Player_Flashlight(pl);
PMove_SetSize(pl); pl.Physics_SetViewParms();
Animation_PlayerUpdate((player)pl); Animation_PlayerUpdate((player)pl);
Animation_TimerUpdate((player)pl, clframetime); Animation_TimerUpdate((player)pl, clframetime);
Player_HandleWeaponModel(pl, thirdperson); Player_HandleWeaponModel(pl, thirdperson);

View file

@ -80,6 +80,9 @@ class player:base_player
PREDICTED_INT(ammo_rpg_state); PREDICTED_INT(ammo_rpg_state);
PREDICTED_INT(mode_tempstate); PREDICTED_INT(mode_tempstate);
virtual void(void) Physics_Jump;
virtual void(void) Physics_WaterMove;
#ifdef CLIENT #ifdef CLIENT
/* External model */ /* External model */
entity p_model; entity p_model;

View file

@ -14,52 +14,24 @@
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/ */
#define PHY_JUMP_CHAINWINDOW 0.5 void
#define PHY_JUMP_CHAIN 100 player::Physics_Jump(void)
#define PHY_JUMP_CHAINDECAY 50
.float waterlevel;
.float watertype;
float GamePMove_Maxspeed(player target)
{ {
return (target.flags & FL_CROUCHING) ? 135 : 270; if (waterlevel >= 2) {
} if (watertype == CONTENT_WATER) {
velocity[2] = 100;
void GamePMove_Fall(player target, float impactspeed) } else if (watertype == CONTENT_SLIME) {
{ velocity[2] = 80;
if (impactspeed > 580) {
#ifdef SERVER
float fFallDamage = (impactspeed - 580) * (100 / (1024 - 580));
Damage_Apply(target, world, fFallDamage, 0, DMG_FALL);
Sound_Play(target, CHAN_VOICE, "player.fall");
#endif
target.punchangle += [15,0,(input_sequence & 1) ? 15 : -15];
} else if (impactspeed > 400) {
target.punchangle += [15,0,0];
#ifdef SERVER
Sound_Play(target, CHAN_VOICE, "player.lightfall");
#endif
}
}
void GamePMove_Jump(player target)
{
if (target.waterlevel >= 2) {
if (target.watertype == CONTENT_WATER) {
target.velocity[2] = 100;
} else if (target.watertype == CONTENT_SLIME) {
target.velocity[2] = 80;
} else { } else {
target.velocity[2] = 50; velocity[2] = 50;
} }
} else { } else {
/* Half-Life: Longjump module */ /* Half-Life: Longjump module */
if (target.flags & FL_CROUCHING && target.g_items & 0x00008000i) { if (flags & FL_CROUCHING && g_items & 0x00008000i) {
target.velocity = v_forward * 512; velocity = v_forward * 512;
target.velocity[2] += 100; velocity[2] += 100;
} }
if (target.flags & FL_ONGROUND) if (flags & FL_ONGROUND)
target.velocity[2] += 240; velocity[2] += 240;
} }
} }

View file

@ -15,64 +15,68 @@
*/ */
void void
GamePMove_WaterMove(player target) player::Physics_WaterMove(void)
{ {
if (target.movetype == MOVETYPE_NOCLIP) { if (movetype == MOVETYPE_NOCLIP) {
return; return;
} }
#ifdef SERVER #ifdef SERVER
if (target.health < 0) { if (health < 0) {
return; return;
} }
/* we've just exited water */ /* we've just exited water */
if (target.waterlevel != 3) { if (waterlevel != 3) {
if (target.underwater_time < time) { if (underwater_time < time) {
Sound_Play(target, CHAN_BODY, "player.gasplight"); Sound_Play(this, CHAN_BODY, "player.gasplight");
} else if (target.underwater_time < time + 9) { } else if (underwater_time < time + 9) {
Sound_Play(target, CHAN_BODY, "player.gaspheavy"); Sound_Play(this, CHAN_BODY, "player.gaspheavy");
} }
target.underwater_time = time + 12; underwater_time = time + 12;
} else if (target.underwater_time < time) { } else if (underwater_time < time) {
/* we've been underwater... for too long. */ /* we've been underwater... for too long. */
if (target.pain_time < time) { if (pain_time < time) {
Damage_Apply(target, world, 5, DMG_DROWN, 0); Damage_Apply(this, world, 5, DMG_DROWN, 0);
target.pain_time = time + 1; pain_time = time + 1;
} }
} }
#endif #endif
if (!target.waterlevel){ if (!waterlevel){
if (target.flags & FL_INWATER) { if (flags & FL_INWATER) {
#ifdef SERVER #ifdef SERVER
Sound_Play(target, CHAN_BODY, "player.waterexit"); Sound_Play(this, CHAN_BODY, "player.waterexit");
#endif #endif
target.flags &= ~FL_INWATER; flags &= ~FL_INWATER;
} }
return; return;
} }
#ifdef SERVER #ifdef SERVER
if (target.watertype == CONTENT_LAVA) { if (watertype == CONTENT_LAVA) {
if (target.pain_time < time) { if (pain_time < time) {
target.pain_time = time + 0.2; pain_time = time + 0.2;
Damage_Apply(target, world, 10*target.waterlevel, DMG_BURN, 0); Damage_Apply(this, world, 10*waterlevel, DMG_BURN, 0);
} }
} else if (target.watertype == CONTENT_SLIME) { } else if (watertype == CONTENT_SLIME) {
if (target.pain_time < time) { if (pain_time < time) {
target.pain_time = time + 1; pain_time = time + 1;
Damage_Apply(target, world, 4*target.waterlevel, DMG_ACID, 0); Damage_Apply(this, world, 4*waterlevel, DMG_ACID, 0);
} }
} }
#endif #endif
if (!(target.flags & FL_INWATER)) { if (!(flags & FL_INWATER)) {
#ifdef SERVER #ifdef SERVER
Sound_Play(target, CHAN_BODY, "player.waterenter"); Sound_Play(this, CHAN_BODY, "player.waterenter");
target.pain_time = 0; pain_time = 0;
#endif #endif
target.flags |= FL_INWATER; flags |= FL_INWATER;
}
/* we might need to apply extra-velocity to get out of water-volumes */
if (waterlevel >= 2) {
Physics_WaterJump();
} }
} }