Updated the game-specific PMove code to be part of our player class
This commit is contained in:
parent
a2602bb131
commit
8f051dd406
4 changed files with 51 additions and 73 deletions
|
@ -161,14 +161,13 @@ Player_DestroyWeaponModel(entity pp)
|
|||
remove(pl.p_model);
|
||||
}
|
||||
|
||||
void PMove_SetSize(entity targ);
|
||||
void
|
||||
Player_PreDraw(base_player pl, int thirdperson)
|
||||
{
|
||||
/* Handle the flashlights... */
|
||||
Player_Flashlight(pl);
|
||||
|
||||
PMove_SetSize(pl);
|
||||
pl.Physics_SetViewParms();
|
||||
Animation_PlayerUpdate((player)pl);
|
||||
Animation_TimerUpdate((player)pl, clframetime);
|
||||
Player_HandleWeaponModel(pl, thirdperson);
|
||||
|
|
|
@ -80,6 +80,9 @@ class player:base_player
|
|||
PREDICTED_INT(ammo_rpg_state);
|
||||
PREDICTED_INT(mode_tempstate);
|
||||
|
||||
virtual void(void) Physics_Jump;
|
||||
virtual void(void) Physics_WaterMove;
|
||||
|
||||
#ifdef CLIENT
|
||||
/* External model */
|
||||
entity p_model;
|
||||
|
|
|
@ -14,52 +14,24 @@
|
|||
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
#define PHY_JUMP_CHAINWINDOW 0.5
|
||||
#define PHY_JUMP_CHAIN 100
|
||||
#define PHY_JUMP_CHAINDECAY 50
|
||||
|
||||
.float waterlevel;
|
||||
.float watertype;
|
||||
|
||||
float GamePMove_Maxspeed(player target)
|
||||
void
|
||||
player::Physics_Jump(void)
|
||||
{
|
||||
return (target.flags & FL_CROUCHING) ? 135 : 270;
|
||||
}
|
||||
|
||||
void GamePMove_Fall(player target, float impactspeed)
|
||||
{
|
||||
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;
|
||||
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 {
|
||||
/* Half-Life: Longjump module */
|
||||
if (target.flags & FL_CROUCHING && target.g_items & 0x00008000i) {
|
||||
target.velocity = v_forward * 512;
|
||||
target.velocity[2] += 100;
|
||||
if (flags & FL_CROUCHING && g_items & 0x00008000i) {
|
||||
velocity = v_forward * 512;
|
||||
velocity[2] += 100;
|
||||
}
|
||||
if (target.flags & FL_ONGROUND)
|
||||
target.velocity[2] += 240;
|
||||
if (flags & FL_ONGROUND)
|
||||
velocity[2] += 240;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,64 +15,68 @@
|
|||
*/
|
||||
|
||||
void
|
||||
GamePMove_WaterMove(player target)
|
||||
player::Physics_WaterMove(void)
|
||||
{
|
||||
if (target.movetype == MOVETYPE_NOCLIP) {
|
||||
if (movetype == MOVETYPE_NOCLIP) {
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef SERVER
|
||||
if (target.health < 0) {
|
||||
if (health < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* we've just exited water */
|
||||
if (target.waterlevel != 3) {
|
||||
if (target.underwater_time < time) {
|
||||
Sound_Play(target, CHAN_BODY, "player.gasplight");
|
||||
} else if (target.underwater_time < time + 9) {
|
||||
Sound_Play(target, CHAN_BODY, "player.gaspheavy");
|
||||
if (waterlevel != 3) {
|
||||
if (underwater_time < time) {
|
||||
Sound_Play(this, CHAN_BODY, "player.gasplight");
|
||||
} else if (underwater_time < time + 9) {
|
||||
Sound_Play(this, CHAN_BODY, "player.gaspheavy");
|
||||
}
|
||||
target.underwater_time = time + 12;
|
||||
} else if (target.underwater_time < time) {
|
||||
underwater_time = time + 12;
|
||||
} else if (underwater_time < time) {
|
||||
/* we've been underwater... for too long. */
|
||||
if (target.pain_time < time) {
|
||||
Damage_Apply(target, world, 5, DMG_DROWN, 0);
|
||||
target.pain_time = time + 1;
|
||||
if (pain_time < time) {
|
||||
Damage_Apply(this, world, 5, DMG_DROWN, 0);
|
||||
pain_time = time + 1;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!target.waterlevel){
|
||||
if (target.flags & FL_INWATER) {
|
||||
if (!waterlevel){
|
||||
if (flags & FL_INWATER) {
|
||||
#ifdef SERVER
|
||||
Sound_Play(target, CHAN_BODY, "player.waterexit");
|
||||
Sound_Play(this, CHAN_BODY, "player.waterexit");
|
||||
#endif
|
||||
target.flags &= ~FL_INWATER;
|
||||
flags &= ~FL_INWATER;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef SERVER
|
||||
if (target.watertype == CONTENT_LAVA) {
|
||||
if (target.pain_time < time) {
|
||||
target.pain_time = time + 0.2;
|
||||
Damage_Apply(target, world, 10*target.waterlevel, DMG_BURN, 0);
|
||||
if (watertype == CONTENT_LAVA) {
|
||||
if (pain_time < time) {
|
||||
pain_time = time + 0.2;
|
||||
Damage_Apply(this, world, 10*waterlevel, DMG_BURN, 0);
|
||||
}
|
||||
} else if (target.watertype == CONTENT_SLIME) {
|
||||
if (target.pain_time < time) {
|
||||
target.pain_time = time + 1;
|
||||
Damage_Apply(target, world, 4*target.waterlevel, DMG_ACID, 0);
|
||||
} else if (watertype == CONTENT_SLIME) {
|
||||
if (pain_time < time) {
|
||||
pain_time = time + 1;
|
||||
Damage_Apply(this, world, 4*waterlevel, DMG_ACID, 0);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
if (!(target.flags & FL_INWATER)) {
|
||||
if (!(flags & FL_INWATER)) {
|
||||
#ifdef SERVER
|
||||
Sound_Play(target, CHAN_BODY, "player.waterenter");
|
||||
target.pain_time = 0;
|
||||
Sound_Play(this, CHAN_BODY, "player.waterenter");
|
||||
pain_time = 0;
|
||||
#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();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue