Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions code/botlib/be_aas_move.c
Original file line number Diff line number Diff line change
Expand Up @@ -840,9 +840,9 @@ int AAS_ClientMovementPrediction(struct aas_clientmove_s *move,
if (swimming) delta = 0;
// never take falling damage if completely underwater
/*
if (ent->waterlevel == 3) return;
if (ent->waterlevel == 2) delta *= 0.25;
if (ent->waterlevel == 1) delta *= 0.5;
if (ent->waterlevel == WATERLEVEL_SUBMERGED) return;
if (ent->waterlevel == WATERLEVEL_HALFWAY) delta *= 0.25;
if (ent->waterlevel == WATERLEVEL_FEET) delta *= 0.5;
*/
if (delta > 40)
{
Expand Down
12 changes: 6 additions & 6 deletions code/cgame/cg_event.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ int CG_WaterLevel(centity_t *cent) {
//
// get waterlevel, accounting for ducking
//
waterlevel = 0;
waterlevel = WATERLEVEL_NONE;

point[0] = cent->lerpOrigin[0];
point[1] = cent->lerpOrigin[1];
Expand All @@ -451,17 +451,17 @@ int CG_WaterLevel(centity_t *cent) {
if (contents & MASK_WATER) {
sample2 = viewheight - MINS_Z;
sample1 = sample2 / 2;
waterlevel = 1;
waterlevel = WATERLEVEL_FEET;
point[2] = cent->lerpOrigin[2] + MINS_Z + sample1;
contents = CG_PointContents(point, -1);

if (contents & MASK_WATER) {
waterlevel = 2;
waterlevel = WATERLEVEL_HALFWAY;
point[2] = cent->lerpOrigin[2] + MINS_Z + sample2;
contents = CG_PointContents(point, -1);

if (contents & MASK_WATER) {
waterlevel = 3;
waterlevel = WATERLEVEL_SUBMERGED;
}
}
}
Expand Down Expand Up @@ -494,7 +494,7 @@ void CG_PainEvent( centity_t *cent, int health ) {
snd = "*pain100_1.wav";
}
// play a gurp sound instead of a normal pain sound
if (CG_WaterLevel(cent) == 3) {
if (CG_WaterLevel(cent) == WATERLEVEL_SUBMERGED) {
if (rand()&1) {
trap_S_StartSound(NULL, cent->currentState.number, CHAN_VOICE, CG_CustomSound(cent->currentState.number, "sound/player/gurp1.wav"));
} else {
Expand Down Expand Up @@ -1169,7 +1169,7 @@ void CG_EntityEvent( centity_t *cent, vec3_t position ) {
case EV_DEATH3:
DEBUGNAME("EV_DEATHx");

if (CG_WaterLevel(cent) == 3) {
if (CG_WaterLevel(cent) == WATERLEVEL_SUBMERGED) {
trap_S_StartSound(NULL, es->number, CHAN_VOICE, CG_CustomSound(es->number, "*drown.wav"));
} else {
trap_S_StartSound(NULL, es->number, CHAN_VOICE, CG_CustomSound(es->number, va("*death%i.wav", event - EV_DEATH1 + 1)));
Expand Down
40 changes: 20 additions & 20 deletions code/game/bg_pmove.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ static void PM_Friction( void ) {
drop = 0;

// apply ground friction
if ( pm->waterlevel <= 1 ) {
if ( pm->waterlevel <= WATERLEVEL_FEET ) {
if ( pml.walking && !(pml.groundTrace.surfaceFlags & SURF_SLICK) ) {
// if getting knocked back, no friction
if ( ! (pm->ps->pm_flags & PMF_TIME_KNOCKBACK) ) {
Expand Down Expand Up @@ -406,7 +406,7 @@ static qboolean PM_CheckWaterJump( void ) {
}

// check for water jump
if ( pm->waterlevel != 2 ) {
if ( pm->waterlevel != WATERLEVEL_HALFWAY ) {
return qfalse;
}

Expand Down Expand Up @@ -699,7 +699,7 @@ static void PM_WalkMove( void ) {
float accelerate;
float vel;

if ( pm->waterlevel > 2 && DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) {
if ( pm->waterlevel > WATERLEVEL_HALFWAY && DotProduct( pml.forward, pml.groundTrace.plane.normal ) > 0 ) {
// begin swimming
PM_WaterMove();
return;
Expand All @@ -708,7 +708,7 @@ static void PM_WalkMove( void ) {

if ( PM_CheckJump () ) {
// jumped away
if ( pm->waterlevel > 1 ) {
if ( pm->waterlevel > WATERLEVEL_FEET ) {
PM_WaterMove();
} else {
PM_AirMove();
Expand Down Expand Up @@ -960,15 +960,15 @@ static void PM_CrashLand( void ) {
}

// never take falling damage if completely underwater
if ( pm->waterlevel == 3 ) {
if ( pm->waterlevel == WATERLEVEL_SUBMERGED ) {
return;
}

// reduce falling damage if there is standing water
if ( pm->waterlevel == 2 ) {
if ( pm->waterlevel == WATERLEVEL_HALFWAY ) {
delta *= 0.25;
}
if ( pm->waterlevel == 1 ) {
if ( pm->waterlevel == WATERLEVEL_FEET ) {
delta *= 0.5;
}

Expand Down Expand Up @@ -1210,7 +1210,7 @@ static void PM_SetWaterLevel( void ) {
//
// get waterlevel, accounting for ducking
//
pm->waterlevel = 0;
pm->waterlevel = WATERLEVEL_NONE;
pm->watertype = 0;

point[0] = pm->ps->origin[0];
Expand All @@ -1223,15 +1223,15 @@ static void PM_SetWaterLevel( void ) {
sample1 = sample2 / 2;

pm->watertype = cont;
pm->waterlevel = 1;
pm->waterlevel = WATERLEVEL_FEET;
point[2] = pm->ps->origin[2] + MINS_Z + sample1;
cont = pm->pointcontents (point, pm->ps->clientNum );
if ( cont & MASK_WATER ) {
pm->waterlevel = 2;
pm->waterlevel = WATERLEVEL_HALFWAY;
point[2] = pm->ps->origin[2] + MINS_Z + sample2;
cont = pm->pointcontents (point, pm->ps->clientNum );
if ( cont & MASK_WATER ){
pm->waterlevel = 3;
pm->waterlevel = WATERLEVEL_SUBMERGED;
}
}
}
Expand Down Expand Up @@ -1336,7 +1336,7 @@ static void PM_Footsteps( void ) {
PM_ContinueLegsAnim( LEGS_IDLECR );
}
// airborne leaves position in cycle intact, but doesn't advance
if ( pm->waterlevel > 1 ) {
if ( pm->waterlevel > WATERLEVEL_FEET ) {
PM_ContinueLegsAnim( LEGS_SWIM );
}
return;
Expand Down Expand Up @@ -1404,18 +1404,18 @@ static void PM_Footsteps( void ) {

// if we just crossed a cycle boundary, play an appropriate footstep event
if ( ( ( old + 64 ) ^ ( pm->ps->bobCycle + 64 ) ) & 128 ) {
if ( pm->waterlevel == 0 ) {
if ( pm->waterlevel == WATERLEVEL_NONE ) {
// on ground will only play sounds if running
if ( footstep && !pm->noFootsteps ) {
PM_AddEvent( PM_FootstepForSurface() );
}
} else if ( pm->waterlevel == 1 ) {
} else if ( pm->waterlevel == WATERLEVEL_FEET ) {
// splashing
PM_AddEvent( EV_FOOTSPLASH );
} else if ( pm->waterlevel == 2 ) {
} else if ( pm->waterlevel == WATERLEVEL_HALFWAY ) {
// wading / swimming at surface
PM_AddEvent( EV_SWIM );
} else if ( pm->waterlevel == 3 ) {
} else if ( pm->waterlevel == WATERLEVEL_SUBMERGED ) {
// no sound when completely underwater

}
Expand Down Expand Up @@ -1447,14 +1447,14 @@ static void PM_WaterEvents( void ) { // FIXME?
//
// check for head just going under water
//
if (pml.previous_waterlevel != 3 && pm->waterlevel == 3) {
if (pml.previous_waterlevel != WATERLEVEL_SUBMERGED && pm->waterlevel == WATERLEVEL_SUBMERGED) {
PM_AddEvent( EV_WATER_UNDER );
}

//
// check for head just coming out of water
//
if (pml.previous_waterlevel == 3 && pm->waterlevel != 3) {
if (pml.previous_waterlevel == WATERLEVEL_SUBMERGED && pm->waterlevel != WATERLEVEL_SUBMERGED) {
PM_AddEvent( EV_WATER_CLEAR );
}
}
Expand Down Expand Up @@ -1842,7 +1842,7 @@ void PmoveSingle (pmove_t *pmove) {
// clear results
pm->numtouch = 0;
pm->watertype = 0;
pm->waterlevel = 0;
pm->waterlevel = WATERLEVEL_NONE;

if ( pm->ps->stats[STAT_HEALTH] <= 0 ) {
pm->tracemask &= ~CONTENTS_BODY; // corpses can fly through bodies
Expand Down Expand Up @@ -1981,7 +1981,7 @@ void PmoveSingle (pmove_t *pmove) {
PM_AirMove();
} else if (pm->ps->pm_flags & PMF_TIME_WATERJUMP) {
PM_WaterJumpMove();
} else if ( pm->waterlevel > 1 ) {
} else if ( pm->waterlevel > WATERLEVEL_FEET ) {
// swimming
PM_WaterMove();
} else if ( pml.walking ) {
Expand Down
6 changes: 6 additions & 0 deletions code/game/bg_public.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,12 @@ typedef enum {

#define PMF_ALL_TIMES (PMF_TIME_WATERJUMP|PMF_TIME_LAND|PMF_TIME_KNOCKBACK)

// pmove->waterlevel
#define WATERLEVEL_NONE 0 // no water at all
#define WATERLEVEL_FEET 1 // just the feet are under water
#define WATERLEVEL_HALFWAY 2 // wading / swimming at surface
#define WATERLEVEL_SUBMERGED 3 // fully underwater (max possible waterlevel)

#define MAXTOUCH 32
typedef struct {
// state (in / out)
Expand Down
2 changes: 1 addition & 1 deletion code/game/g_active.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ void P_WorldEffects( gentity_t *ent ) {
//
// check for drowning
//
if ( waterlevel == 3 ) {
if ( waterlevel == WATERLEVEL_SUBMERGED ) {
// envirosuit give air
if ( envirosuit ) {
ent->client->airOutTime = level.time + 10000;
Expand Down
2 changes: 1 addition & 1 deletion code/game/g_client.c
Original file line number Diff line number Diff line change
Expand Up @@ -1155,7 +1155,7 @@ void ClientSpawn(gentity_t *ent) {
ent->r.contents = CONTENTS_BODY;
ent->clipmask = MASK_PLAYERSOLID;
ent->die = player_die;
ent->waterlevel = 0;
ent->waterlevel = WATERLEVEL_NONE;
ent->watertype = 0;
ent->flags = 0;

Expand Down