Binary files et260/src/game/.g_active.c.swp and etpub/src/game/.g_active.c.swp differ diff -urN --exclude=.svn et260/src/game/bg_animation.c etpub/src/game/bg_animation.c --- et260/src/game/bg_animation.c 2005-04-12 12:11:50.000000000 -0500 +++ etpub/src/game/bg_animation.c 2005-04-15 12:04:46.000000000 -0500 @@ -1423,6 +1423,7 @@ animScriptItem_t *scriptItem = NULL; animScriptCommand_t *scriptCommand = NULL; int state = ps->aiState; + qboolean setTimer = qfalse; // Allow fallen movetype while dead if( ps->eFlags & EF_DEAD && movetype != ANIM_MT_FALLEN && movetype != ANIM_MT_FLAILING ) @@ -1462,14 +1463,46 @@ #ifdef DBGANIMS if( scriptCommand->bodyPart[0] ) - Com_Printf( "anim0 (%s): %s", animBodyPartsStr[scriptCommand->bodyPart[0]].string, animModelInfo->animations[scriptCommand->animIndex[0]]->name ); + Com_Printf( "anim0 (%s): %s %d", animBodyPartsStr[scriptCommand->bodyPart[0]].string, animModelInfo->animations[scriptCommand->animIndex[0]]->name, scriptCommand->animIndex[0] ); if( scriptCommand->bodyPart[1] ) - Com_Printf( "anim1 (%s): %s", animBodyPartsStr[scriptCommand->bodyPart[1]].string, animModelInfo->animations[scriptCommand->animIndex[1]]->name ); + Com_Printf( "anim1 (%s): %s %d", animBodyPartsStr[scriptCommand->bodyPart[1]].string, animModelInfo->animations[scriptCommand->animIndex[1]]->name, scriptCommand->animIndex[1]); Com_Printf( "\n" ); #endif + + // tjw: we need to match head boxes to the run animation + // in the game code. Is there a better way? + ps->eFlags &= ~EF_MOTION; + switch(scriptCommand->animIndex[0]) { + case 37: // alert_run_2h + case 40: // alert_crch_2h + case 44: // alert_bk_2h + case 47: // alert_crbk_2h + case 160: // prone_crawl + case 161: // prone_crawl_bk + ps->eFlags |= EF_MOTION; + break; + } + + + // tjw: this is a dirty dirty hack and should be removed + // if using a client mod (update the animation script). + // This is here because I added head hitboxes to + // corpses and we can't have their heads leaving the + // ground because the hitboxes can't do that. + if(movetype == ANIM_MT_FALLEN) { + setTimer = qtrue; + if(ps->torsoTimer < 3400) + return( BG_ExecuteCommand(ps, + animModelInfo, + scriptCommand, + setTimer, + qfalse, + qtrue) != -1 ); + + } // run it - return( BG_ExecuteCommand( ps, animModelInfo, scriptCommand, qfalse, isContinue, qfalse ) != -1 ); + return( BG_ExecuteCommand( ps, animModelInfo, scriptCommand, setTimer, isContinue, qfalse ) != -1 ); } /* diff -urN --exclude=.svn et260/src/game/bg_local.h etpub/src/game/bg_local.h --- et260/src/game/bg_local.h 2005-04-12 12:11:50.000000000 -0500 +++ etpub/src/game/bg_local.h 2005-04-20 13:22:54.000000000 -0500 @@ -71,7 +71,11 @@ qboolean PM_SlideMove( qboolean gravity ); void PM_StepSlideMove( qboolean gravity ); -qboolean PM_SlideMoveProne( qboolean gravity ); -void PM_StepSlideMoveProne( qboolean gravity ); - void PM_BeginWeaponChange( int oldweapon, int newweapon, qboolean reload ); + +// tjw +extern vmCvar_t g_weapons; +extern vmCvar_t g_spinCorpse; +// josh +extern vmCvar_t g_misc; +extern vmCvar_t g_doubleJumpHeight; diff -urN --exclude=.svn et260/src/game/bg_misc.c etpub/src/game/bg_misc.c --- et260/src/game/bg_misc.c 2005-04-12 12:11:50.000000000 -0500 +++ etpub/src/game/bg_misc.c 2005-04-15 12:04:46.000000000 -0500 @@ -13,12 +13,17 @@ #ifdef CGAMEDLL extern vmCvar_t cg_gameType; #define gametypeCvar cg_gameType +#define MISC_UW_AMMO_RESTORES_HELMET 0 // josh: no client mod #elif GAMEDLL extern vmCvar_t g_developer; extern vmCvar_t g_gametype; #define gametypeCvar g_gametype + extern vmCvar_t g_weapons; +#define MISC_UW_AMMO_RESTORES_HELMET \ + (g_weapons.integer & WPF_AMMO_RESTORES_HELMET) #else extern vmCvar_t ui_gameType; +#define MISC_UW_AMMO_RESTORES_HELMET 0 // josh: no ui stuff here #define gametypeCvar ui_gameType #endif @@ -64,6 +69,19 @@ "Bombardment Medal", "Silver Snake" }; +#ifdef GAMEDLL + +int skillLevels[SK_NUM_SKILLS][NUM_SKILL_LEVELS] = { + {0, 20, 50, 90, 140}, + {0, 20, 50, 90, 140}, + {0, 20, 50, 90, 140}, + {0, 20, 50, 90, 140}, + {0, 20, 50, 90, 140}, + {0, 20, 50, 90, 140}, + {0, 20, 50, 90, 140}, +}; + +#else const int skillLevels[NUM_SKILL_LEVELS] = { 0, // reaching level 0 @@ -74,6 +92,8 @@ // 200 // reaching level 5 }; +#endif + vec3_t playerlegsProneMins = { -13.5f, -13.5f, -24.f }; vec3_t playerlegsProneMaxs = { 13.5f, 13.5f, -14.4f }; @@ -153,7 +173,7 @@ { 90, 1, 30, 30, 30, 2400, DELAY_LOW, 150, 0, 0, MOD_THOMPSON }, // WP_THOMPSON // 8 { 45, 1, 15, 0, 4, 1000, DELAY_THROW, 1600, 0, 0, MOD_GRENADE_PINEAPPLE }, // WP_GRENADE_PINEAPPLE // 9 - { 96, 1, 32, 32, 32, 3100, DELAY_LOW, 150, 1200, 450, MOD_STEN }, // WP_STEN // 10 + { 96, 1, 32, 64, 32, 3100, DELAY_LOW, 150, 1200, 450, MOD_STEN }, // WP_STEN // 10 { 10, 1, 1, 0, 10, 1500, 50, 1000, 0, 0, MOD_SYRINGE }, // WP_MEDIC_SYRINGE // 11 { 1, 0, 1, 0, 0, 3000, 50, 1000, 0, 0, MOD_AMMO, }, // WP_AMMO // 12 { 1, 0, 1, 0, 1, 3000, 50, 1000, 0, 0, MOD_ARTY, }, // WP_ARTY // 13 @@ -2908,6 +2928,15 @@ int clip; int weapNumOfClips; + // Michael: add the helmet first, then do weapons + // it looks like the way to check if they have a helmet is by + // seeing if they have already been shot in the head + // to add the helmet, just clear the bit + if(MISC_UW_AMMO_RESTORES_HELMET && (ps->eFlags & EF_HEADSHOT)) { + ps->eFlags &= (EF_HEADSHOT ^ 0xFFFFFFFF); + } + + // Gordon: handle grenades first i = BG_GrenadesForClass( ps->stats[STAT_PLAYER_CLASS], skill ); weapon = BG_GrenadeTypeForTeam( teamNum ); @@ -3999,6 +4028,11 @@ if ( snap ) { SnapVector( s->pos.trBase ); } + // josh: This wasn't in here?! Why!? It's in Quake 3 + VectorCopy( ps->velocity, s->pos.trDelta ); + if ( snap ) { + SnapVector( s->pos.trDelta ); + } s->apos.trType = TR_INTERPOLATE; VectorCopy( ps->viewangles, s->apos.trBase ); @@ -4027,9 +4061,11 @@ s->eFlags = ps->eFlags; - if ( ps->stats[STAT_HEALTH] <= 0 ) { + if(ps->stats[STAT_HEALTH] <= 0 && + !(ps->eFlags & EF_PLAYDEAD)) { s->eFlags |= EF_DEAD; - } else { + } + else { s->eFlags &= ~EF_DEAD; } @@ -4128,9 +4164,11 @@ } s->eFlags = ps->eFlags; - if ( ps->stats[STAT_HEALTH] <= 0 ) { + if(ps->stats[STAT_HEALTH] <= 0 && + !(ps->eFlags & EF_PLAYDEAD)) { s->eFlags |= EF_DEAD; - } else { + } + else { s->eFlags &= ~EF_DEAD; } diff -urN --exclude=.svn et260/src/game/bg_pmove.c etpub/src/game/bg_pmove.c --- et260/src/game/bg_pmove.c 2005-04-12 12:11:50.000000000 -0500 +++ etpub/src/game/bg_pmove.c 2005-04-25 22:21:36.000000000 -0500 @@ -15,8 +15,20 @@ #ifdef CGAMEDLL #define PM_GameType cg_gameType.integer +#define PM_UW_SYRINGE 0 // tjw: no client mod +#define PM_UW_PLIERS 0 // tjw: no client mod +#define PM_CORPSE_SPIN 0 // tjw: no client mod +#define PM_DOUBLE_JUMP 0 // josh: no client mod +#define PM_DOUBLE_JUMP_HEIGHT 0 // josh: no client mod +#define PM_GARAND_RELOADS 0 // tjw: no client mod #elif GAMEDLL #define PM_GameType g_gametype.integer +#define PM_UW_SYRINGE (g_weapons.integer & WPF_UNDERWATER_SYRINGE) +#define PM_UW_PLIERS (g_weapons.integer & WPF_UNDERWATER_PLIERS) +#define PM_CORPSE_SPIN g_spinCorpse.integer +#define PM_DOUBLE_JUMP (g_misc.integer & MISC_DOUBLE_JUMP) +#define PM_DOUBLE_JUMP_HEIGHT g_doubleJumpHeight.value +#define PM_GARAND_RELOADS (g_weapons.integer & WPF_GARAND_RELOADS) #endif #define PM_IsSinglePlayerGame() (PM_GameType == GT_SINGLE_PLAYER || PM_GameType == GT_COOP) @@ -736,11 +748,10 @@ // JPW NERVE -- jumping in multiplayer uses and requires sprint juice (to prevent turbo skating, sprint + jumps) // don't allow jump accel - - // rain - revert to using pmext for this since pmext is fixed now. - // fix for #166 - if (pm->cmd.serverTime - pm->pmext->jumpTime < 850) - return qfalse; + //if (pm->cmd.serverTime - pm->pmext->jumpTime < 850) + if (pm->cmd.serverTime - pm->ps->jumpTime < 850 ) {// Arnout: NOTE : TEMP DEBUG + return qfalse; + } // don't allow if player tired // if (pm->pmext->sprintTime < 2500) // JPW pulled this per id request; made airborne jumpers wildly inaccurate with gunfire to compensate @@ -781,6 +792,66 @@ return qtrue; } +/* +============= +PM_CheckDoubleJump +============= +*/ +static qboolean PM_CheckDoubleJump( void ) { + + if ( !PM_DOUBLE_JUMP ) { + return qfalse; + } + + // no jumpin when prone + if( pm->ps->eFlags & EF_PRONE ) { + return qfalse; + } + + // josh: Don't allow if already double jumping + if (pm->ps->pm_flags & PMF_DOUBLEJUMPING) { + return qfalse; + } + + // Only allow double jump when going up + if (pm->ps->velocity[2] <= 0) { + return qfalse; + } + + if ( pm->ps->pm_flags & PMF_RESPAWNED ) { + return qfalse; // don't allow jump until all buttons are up + } + + if ( pm->cmd.upmove < 10 ) { + // not holding jump + return qfalse; + } + + // must wait for jump to be released + if ( pm->ps->pm_flags & PMF_JUMP_HELD ) { + // clear upmove so cmdscale doesn't lower running speed + pm->cmd.upmove = 0; + return qfalse; + } + + pml.groundPlane = qfalse; // jumping away + pml.walking = qfalse; + pm->ps->pm_flags |= PMF_JUMP_HELD; + + pm->ps->groundEntityNum = ENTITYNUM_NONE; + pm->ps->velocity[2] = PM_DOUBLE_JUMP_HEIGHT*JUMP_VELOCITY; + PM_AddEvent( EV_JUMP ); + + if ( pm->cmd.forwardmove >= 0 ) { + BG_AnimScriptEvent( pm->ps, pm->character->animModelInfo, ANIM_ET_JUMP, qfalse, qtrue ); + pm->ps->pm_flags &= ~PMF_BACKWARDS_JUMP; + } else { + BG_AnimScriptEvent( pm->ps, pm->character->animModelInfo, ANIM_ET_JUMPBK, qfalse, qtrue ); + pm->ps->pm_flags |= PMF_BACKWARDS_JUMP; + } + + return qtrue; +} /* ============= @@ -829,6 +900,145 @@ return qtrue; } + +/* + * PM_CheckPlayDead + * see if this player can lay down and look dead +*/ +static qboolean PM_CheckPlayDead (void) +{ + vec3_t org, flatforward, point; + trace_t trace; + + if(pm->ps->pm_type != PM_PLAYDEAD) return qfalse; + + // PM_PLAYDEAD is a one time only pm_type + pm->ps->pm_type = PM_NORMAL; + + if(!(pm->ps->eFlags & EF_PLAYDEAD)) { + if(pm->ps->pm_flags & PMF_LADDER) { + return qfalse; + } + + if(pm->ps->persistant[PERS_HWEAPON_USE] || + pm->ps->eFlags & EF_MOUNTEDTANK) { + + return qfalse; + } + + if(pm->waterlevel > 1) { + return qfalse; + } + + // see if we have the space to go prone + // we know our main body isn't in a solid, check for our legs + flatforward[0] = pml.forward[0]; + flatforward[1] = pml.forward[1]; + flatforward[2] = 0; + + org[0] = pm->ps->origin[0] + flatforward[0] * -32; + org[1] = pm->ps->origin[1] + flatforward[1] * -32; + org[2] = pm->ps->origin[2] + 24.f; // 24 units to play with + + // diff between playerlegsMins and playerlegsMaxs z + 24 units to play with + VectorSet( point, org[0], org[1], org[2] - ( 24.f - 2.4f ) - 24.f ); + + pm->trace (&trace, + org, + playerlegsProneMins, + playerlegsProneMaxs, + point, + pm->ps->clientNum, + pm->tracemask); + + if( trace.startsolid && trace.entityNum >= MAX_CLIENTS ) { + // starting in a solid, no prone at all + return qfalse; + } + else if( trace.fraction == 1.f ) { + // no ground to play dead on, so don't + return qfalse; + } + VectorCopy( trace.endpos, org ); + VectorSet( point, org[0], org[1], org[2] + ( 24.f - 2.4f ) ); + + pm->trace (&trace, + org, + playerlegsProneMins, + playerlegsProneMaxs, + point, + pm->ps->clientNum, + pm->tracemask); + + if (!trace.allsolid || trace.entityNum < MAX_CLIENTS) { + pm->ps->eFlags |= EF_PLAYDEAD; + pm->ps->eFlags |= EF_DEAD; + pm->ps->pm_type = PM_DEAD; + + // client uses stats[STAT_HEALTH] as the indicator for + // revive sprites and player position + pm->ps->stats[STAT_HEALTH] = 0; + + // make the hitbox like a dead guy + pm->maxs[2] = pm->ps->maxs[2] = pm->ps->crouchMaxZ; + return qtrue; + } + } + else { + // see if we have the space to stop playing dead + pm->mins[0] = pm->ps->mins[0]; + pm->mins[1] = pm->ps->mins[1]; + + pm->maxs[0] = pm->ps->maxs[0]; + pm->maxs[1] = pm->ps->maxs[1]; + + pm->mins[2] = pm->ps->mins[2]; + pm->maxs[2] = pm->ps->crouchMaxZ; + + pm->trace( &trace, + pm->ps->origin, + pm->mins, + pm->maxs, + pm->ps->origin, + pm->ps->clientNum, + pm->tracemask ); + + if(trace.allsolid) { + // this would have been turned up to ent->health + // before running a PM_PLAYDEAD. Set it back down + // if we can't stand up. + pm->ps->stats[STAT_HEALTH] = 0; + return qfalse; + } + + // crouch for a bit + pm->ps->pm_flags |= PMF_DUCKED; + + // turn the hitbox back up + pm->maxs[2] = pm->ps->maxs[2] = pm->ps->standViewHeight; + + // stop playdead + pm->ps->eFlags &= ~EF_PLAYDEAD; + pm->ps->eFlags &= ~EF_DEAD; + + // this is need to force the end of the fallen animation + // because of the timer hack in bg_animation.c + pm->ps->torsoTimer = 0; + BG_AnimScriptEvent(pm->ps, + pm->character->animModelInfo, + ANIM_ET_JUMPBK, + qfalse, + qtrue); + + // don't jump for a bit + pm->pmext->jumpTime = pm->cmd.serverTime - 650; + pm->ps->jumpTime = pm->cmd.serverTime - 650; + + return qtrue; + } + return qfalse; +} + /* ============== PM_CheckProne @@ -874,10 +1084,12 @@ // return qfalse; //} - if( ((pm->ps->pm_flags & PMF_DUCKED && pm->cmd.doubleTap == DT_FORWARD) || - (pm->cmd.wbuttons & WBUTTON_PRONE)) && pm->cmd.serverTime - -pm->pmext->proneTime > 750 ) { - trace_t trace; + if(((pm->ps->pm_flags & PMF_DUCKED && + pm->cmd.doubleTap == DT_FORWARD) || + (pm->cmd.wbuttons & WBUTTON_PRONE)) && + pm->cmd.serverTime - -pm->pmext->proneTime > 750) { + trace_t trace; pm->mins[0] = pm->ps->mins[0]; pm->mins[1] = pm->ps->mins[1]; @@ -907,7 +1119,11 @@ pm->ps->eFlags & EF_MOUNTEDTANK || // zinx - what was the reason for this, anyway? removing fixes bug 424 // pm->cmd.serverTime - pm->pmext->proneGroundTime > 450 || - ((pm->cmd.doubleTap == DT_BACK || pm->cmd.upmove > 10 || pm->cmd.wbuttons & WBUTTON_PRONE) && pm->cmd.serverTime - pm->pmext->proneTime > 750) ) { + ((pm->cmd.doubleTap == DT_BACK || + pm->cmd.upmove > 10 || + pm->cmd.wbuttons & WBUTTON_PRONE) + && pm->cmd.serverTime - pm->pmext->proneTime > 750)) { + trace_t trace; // see if we have the space to stop prone @@ -918,7 +1134,6 @@ pm->maxs[1] = pm->ps->maxs[1]; pm->mins[2] = pm->ps->mins[2]; - pm->maxs[2] = pm->ps->crouchMaxZ; pm->ps->eFlags &= ~EF_PRONE; PM_TraceAll( &trace, pm->ps->origin, pm->ps->origin ); @@ -975,9 +1190,12 @@ //if( frac > 1.f ) // frac = 1.f; - //pm->maxs[2] = pm->ps->maxs[2] - (frac * (pm->ps->standViewHeight - PRONE_VIEWHEIGHT)); - //pm->ps->viewheight = DEFAULT_VIEWHEIGHT - (frac * (DEFAULT_VIEWHEIGHT - PRONE_VIEWHEIGHT)); // default - prone to get a positive which is subtracted from default - pm->maxs[2] = pm->ps->maxs[2] - pm->ps->standViewHeight - PRONE_VIEWHEIGHT; + + //pm->maxs[2] = pm->ps->maxs[2] - pm->ps->standViewHeight - PRONE_VIEWHEIGHT; + // tjw: it appears that 12 is the magic number + // for the minimum maxs[2] that prevents + // player from getting stuck into the world. + pm->maxs[2] = 12; pm->ps->viewheight = PRONE_VIEWHEIGHT; return( qtrue ); @@ -1233,6 +1451,33 @@ float scale; usercmd_t cmd; + if ( PM_CheckDoubleJump () ) { + pm->ps->pm_flags |= PMF_DOUBLEJUMPING; + // jumped away + if ( pm->waterlevel > 1 ) { + PM_WaterMove(); + } //else { + // PM_AirMove(); + //} + + // this will probably never happen so the second jump won't + // drain your sprint meter. Just like shrub. + // Take out the if {} to make it drain + if (!(pm->cmd.serverTime - pm->pmext->jumpTime < 850)) { + + pm->pmext->sprintTime -= 2500; + if (pm->pmext->sprintTime < 0) + pm->pmext->sprintTime = 0; + + pm->pmext->jumpTime = pm->cmd.serverTime; + } + + // JPW NERVE + pm->ps->jumpTime = pm->cmd.serverTime; // Arnout: NOTE : TEMP DEBUG + + //return; + } + PM_Friction(); fmove = pm->cmd.forwardmove; @@ -1499,6 +1744,7 @@ VectorNormalize (pm->ps->velocity); VectorScale (pm->ps->velocity, forward, pm->ps->velocity); } + } @@ -1644,8 +1890,7 @@ // SURF_NODAMAGE is used for bounce pads where you don't ever // want to take damage or play a crunch sound - if ( !(pml.groundTrace.surfaceFlags & SURF_NODAMAGE) ) - { + if(!(pml.groundTrace.surfaceFlags & SURF_NODAMAGE) && !pm->predict) { if ( pm->debugLevel ) Com_Printf ("delta: %5.2f\n", delta); @@ -1883,6 +2128,7 @@ pml.groundPlane = qtrue; pml.walking = qtrue; + pm->ps->pm_flags &= ~PMF_DOUBLEJUMPING; // hitting solid ground will end a waterjump if (pm->ps->pm_flags & PMF_TIME_WATERJUMP) @@ -2037,14 +2283,13 @@ if (pm->ps->eFlags & EF_DEAD) { - - //if ( pm->ps->groundEntityNum == ENTITYNUM_NONE ) - if ( pm->ps->pm_flags & PMF_FLAILING ) { + if( pm->ps->pm_flags & PMF_FLAILING ) { animResult = BG_AnimScriptAnimation( pm->ps, pm->character->animModelInfo, ANIM_MT_FLAILING, qtrue ); if( !pm->ps->pm_time ) pm->ps->pm_flags &= ~PMF_FLAILING; // the eagle has landed - } else if ( !pm->ps->pm_time && !(pm->ps->pm_flags & PMF_LIMBO) ) { // DHM - Nerve :: before going to limbo, play a wounded/fallen animation + } + else if(!pm->ps->pm_time && !(pm->ps->pm_flags & PMF_LIMBO) ) { // DHM - Nerve :: before going to limbo, play a wounded/fallen animation if ( pm->ps->groundEntityNum == ENTITYNUM_NONE ) { // takeoff! pm->ps->pm_flags |= PMF_FLAILING; @@ -2305,20 +2550,42 @@ ============== */ static void PM_BeginWeaponReload( int weapon ) { - gitem_t* item; + //gitem_t* item; int reloadTime; // only allow reload if the weapon isn't already occupied (firing is okay) if(pm->ps->weaponstate != WEAPON_READY && pm->ps->weaponstate != WEAPON_FIRING ) return; - if(((weapon == WP_CARBINE) && pm->ps->ammoclip[WP_CARBINE] != 0) || ((weapon == WP_MOBILE_MG42 || weapon == WP_MOBILE_MG42_SET) && pm->ps->ammoclip[WP_MOBILE_MG42] != 0) || ((weapon == WP_GARAND || weapon == WP_GARAND_SCOPE) && pm->ps->ammoclip[WP_GARAND] != 0)) { - return; // Gordon: no reloading of the carbine until clip is empty + //if(((weapon == WP_CARBINE) && pm->ps->ammoclip[WP_CARBINE] != 0) || ((weapon == WP_MOBILE_MG42 || weapon == WP_MOBILE_MG42_SET) && pm->ps->ammoclip[WP_MOBILE_MG42] != 0) || ((weapon == WP_GARAND || weapon == WP_GARAND_SCOPE) && pm->ps->ammoclip[WP_GARAND] != 0)) { + // return; // Gordon: no reloading of the carbine until clip is empty + //} + switch(weapon) { + case WP_CARBINE: + if(PM_GARAND_RELOADS) + break; + if(pm->ps->ammoclip[WP_CARBINE] != 0) + return; + break; + case WP_GARAND: + case WP_GARAND_SCOPE: + if(PM_GARAND_RELOADS) + break; + if(pm->ps->ammoclip[WP_GARAND] != 0) + return; + break; + case WP_MOBILE_MG42: + case WP_MOBILE_MG42_SET: + if(pm->ps->ammoclip[WP_MOBILE_MG42] != 0) + return; + break; } if((weapon <= WP_NONE || weapon > WP_DYNAMITE) && !(weapon >= WP_KAR98 && weapon < WP_NUM_WEAPONS)) return; + // tjw: this should be handled in PM_CheckForReload() + /* item = BG_FindItemForWeapon(weapon); if(!item) { return; @@ -2327,6 +2594,7 @@ if(pm->ps->ammoclip[item->giAmmoIndex] >= GetAmmoTableData(weapon)->maxclip) { return; } + */ // no reload when you've got a chair in your hands /* if(pm->ps->eFlags & EF_MELEE_ACTIVE) @@ -2906,7 +3174,8 @@ pm->ps->weapon != WP_GRENADE_PINEAPPLE && pm->ps->weapon != WP_DYNAMITE && pm->ps->weapon != WP_SMOKE_BOMB && - pm->ps->weapon != WP_LANDMINE ) { + pm->ps->weapon != WP_LANDMINE && + pm->ps->weapon != WP_SATCHEL_DET) { return; } @@ -2924,9 +3193,6 @@ case WP_GRENADE_PINEAPPLE: case WP_DYNAMITE: COM_BitClear( pm->ps->weapons, pm->ps->weapon); - break; - default: - break; } PM_AddEvent( EV_NOAMMO ); @@ -3218,7 +3484,7 @@ // check for dead player if ( pm->ps->stats[STAT_HEALTH] <= 0 ) { - if(!pm->ps->pm_flags & PMF_LIMBO) { + if(!(pm->ps->pm_flags & PMF_LIMBO)) { PM_CoolWeapons(); } @@ -3313,7 +3579,7 @@ pm->ps->weapHeat[WP_DUMMY_MG42] = 0; // rain - floor() to prevent 8-bit wrap - pm->ps->curWeapHeat = floor( ( ( (float)pm->ps->weapHeat[WP_DUMMY_MG42] / MAX_MG42_HEAT) ) * 255.0f); + pm->ps->curWeapHeat = floor(((float)pm->ps->weapHeat[WP_DUMMY_MG42] / MAX_MG42_HEAT) * 255.0f); } if( pm->ps->weaponTime > 0 ) { @@ -3796,10 +4062,18 @@ pm->ps->weapon != WP_DYNAMITE && pm->ps->weapon != WP_LANDMINE && pm->ps->weapon != WP_TRIPMINE && - pm->ps->weapon != WP_SMOKE_BOMB ) { - PM_AddEvent(EV_NOFIRE_UNDERWATER); // event for underwater 'click' for nofire + pm->ps->weapon != WP_SMOKE_BOMB && + !(pm->ps->weapon == WP_MEDIC_SYRINGE + && PM_UW_SYRINGE) && + !(pm->ps->weapon == WP_PLIERS + && PM_UW_PLIERS) + ) { + + // event for underwater 'click' for nofire + PM_AddEvent(EV_NOFIRE_UNDERWATER); pm->ps->weaponTime = 500; - pm->ps->weaponDelay = 0; // avoid insta-fire after water exit on delayed weapon attacks + // avoid insta-fire after water exit on delayed weapon attacks + pm->ps->weaponDelay = 0; return; } } @@ -4603,7 +4877,14 @@ // rain - using a full short and converting on the client so that // we get >1 degree resolution ps->stats[STAT_DEAD_YAW] = temp; - return; // no view changes at all + // tjw: don't let corpses bury their heads in the sand + ps->viewangles[2] = 0; + ps->viewangles[0] = 0; + if(PM_CORPSE_SPIN) { + temp = cmd->angles[1] + ps->delta_angles[1]; + ps->viewangles[1] = SHORT2ANGLE(temp); + } + return; } VectorCopy( ps->viewangles, oldViewAngles ); @@ -4623,7 +4904,7 @@ } ps->viewangles[i] = SHORT2ANGLE(temp); } - + if( BG_PlayerMounted(ps->eFlags) ) { float yaw, oldYaw; float degsSec = MG42_YAWSPEED; @@ -5191,7 +5472,6 @@ if( pm->skill[SK_BATTLE_SENSE] >= 2 ) rechargebase *= 1.6f; } - pm->pmext->sprintTime += rechargebase*pml.frametime; // JPW NERVE adjusted for framerate independence if (pm->pmext->sprintTime > 5000) pm->pmext->sprintTime += rechargebase*pml.frametime; // JPW NERVE adjusted for framerate independence @@ -5265,6 +5545,13 @@ if( (pm->ps->weapon == WP_GRENADE_LAUNCHER || pm->ps->weapon == WP_GRENADE_PINEAPPLE || pm->ps->weapon == WP_DYNAMITE) && pm->ps->grenadeTimeLeft > 0) { pm->ps->eFlags &= ~EF_ZOOMING; } + // don't allow binocs if in the middle of throwing grenade + if( (pm->ps->weapon == WP_GRENADE_LAUNCHER || + pm->ps->weapon == WP_GRENADE_PINEAPPLE || + pm->ps->weapon == WP_DYNAMITE) && + pm->ps->grenadeTimeLeft > 0) { + pm->ps->eFlags &= ~EF_ZOOMING; + } } @@ -5428,14 +5715,14 @@ #endif } + // set watertype, and waterlevel PM_SetWaterLevel(); pml.previous_waterlevel = pmove->waterlevel; + PM_CheckPlayDead(); + // set mins, maxs, and viewheight - //if( !PM_CheckProne() ) { -// PM_CheckDuck (); - //} if( !PM_CheckProne() ) { PM_CheckDuck(); } @@ -5472,7 +5759,8 @@ } if( pm->ps->weapon == WP_SATCHEL_DET ) { if( !( pm->ps->ammoclip[ WP_SATCHEL_DET ] ) ) { - PM_BeginWeaponChange( WP_SATCHEL_DET, WP_SATCHEL, qtrue ); + // tjw: this causes the 2.60 client to freak out + //PM_BeginWeaponChange( WP_SATCHEL_DET, WP_SATCHEL, qtrue ); #ifdef CGAMEDLL cg.weaponSelect = WP_SATCHEL; #endif // CGAMEDLL @@ -5628,3 +5916,37 @@ return (0); } + +// PmovePredict +// +// Used to calculate player movement for g_skipCorrection. +// +// Before calling PmovePredict() the following player state +// values should be backed up and then restored after the +// new values have been copied to the entity state . +// +// PM_GroundTrace() and friends modify +// ps->groundEntityNum +// ps->pm_flags +// ps->pm_time +// ps->eFlags +// +// PM_StepSlideMove() and friends modify +// ps->origin +// ps->velocity + +void PmovePredict(pmove_t *pmove, float frametime) +{ + pm = pmove; + memset(&pml, 0, sizeof(pml)); + pml.frametime = frametime; + PM_GroundTrace(); + + // tjw: don't bother to figure out gravity if already on the ground + // or moving on a ladder. + if(pml.groundPlane || (pm->ps->pm_flags & PMF_LADDER)) + PM_StepSlideMove(qfalse); + else + PM_StepSlideMove(qtrue); + +} diff -urN --exclude=.svn et260/src/game/bg_public.h etpub/src/game/bg_public.h --- et260/src/game/bg_public.h 2005-04-12 12:11:50.000000000 -0500 +++ etpub/src/game/bg_public.h 2005-04-15 12:04:46.000000000 -0500 @@ -425,10 +425,11 @@ typedef enum { PM_NORMAL, // can accelerate and turn PM_NOCLIP, // noclip movement - PM_SPECTATOR, // still run into walls + PM_SPECTATOR, // still run into walls PM_DEAD, // no acceleration or turning, but free falling PM_FREEZE, // stuck in place with no control - PM_INTERMISSION // no movement or status bar + PM_INTERMISSION, // no movement or status bar + PM_PLAYDEAD // no movement or status bar } pmtype_t; typedef enum { @@ -467,6 +468,8 @@ #define PMF_TIME_LOAD 8192 // hold for this time after a load game, and prevent large thinks #define PMF_LIMBO 16384 // JPW NERVE limbo state, pm_time is time until reinforce #define PMF_TIME_LOCKPLAYER 32768 // DHM - Nerve :: Lock all movement and view changes +// josh: +#define PMF_DOUBLEJUMPING 65536 // DHM - Nerve :: Lock all movement and view changes #define PMF_ALL_TIMES (PMF_TIME_WATERJUMP|PMF_TIME_LAND|PMF_TIME_KNOCKBACK|PMF_TIME_LOCKPLAYER/*|PMF_TIME_LOAD*/) @@ -558,11 +561,15 @@ // these will be different functions during game and cgame void (*trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask ); int (*pointcontents)( const vec3_t point, int passEntityNum ); + // tjw: used to determine if the player move is for prediction + // if it is, the movement should trigger no events + qboolean predict; } pmove_t; // if a full pmove isn't done on the client, you can just update the angles void PM_UpdateViewAngles( playerState_t *ps, pmoveExt_t *pmext, usercmd_t *cmd, void (trace)( trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentMask ), int tracemask ); int Pmove (pmove_t *pmove); +void PmovePredict(pmove_t *pmove, float frametime); //=================================================================================== @@ -652,10 +659,10 @@ #define EF_PRONE_MOVING 0x00100000 // player is prone and moving #define EF_VIEWING_CAMERA 0x00200000 // player is viewing a camera #define EF_AAGUN_ACTIVE 0x00400000 // Gordon: player is manning an AA gun -#define EF_SPARE0 0x00800000 // Gordon: freed +#define EF_PLAYDEAD 0x00800000 // tjw: player is playing dead // !! NOTE: only place flags that don't need to go to the client beyond 0x00800000 -#define EF_SPARE1 0x01000000 // Gordon: freed +#define EF_MOTION 0x01000000 // tjw: player animation is in motion #define EF_SPARE2 0x02000000 // Gordon: freed #define EF_BOUNCE 0x04000000 // for missiles #define EF_BOUNCE_HALF 0x08000000 // for missiles @@ -823,6 +830,18 @@ // NOTE: this cannot be larger than 64 for AI/player weapons! } weapon_t; +#define WPF_NO_L0_FOPS_BINOCS 1 +#define WPF_UNDERWATER_SYRINGE 2 +#define WPF_UNDERWATER_PLIERS 4 +#define WPF_TM_AIRSTRIKE_RESTORE_FULL 8 +#define WPF_TM_AIRSTRIKE_RESTORE_HALF 16 +#define WPF_AMMO_RESTORES_HELMET 32 +#define WPF_DROP_BINOCS 64 +#define WPF_L4HW_KEEPS_PISTOL 128 +#define WPF_GARAND_RELOADS 256 + +#define MISC_DOUBLE_JUMP 1 + // JPW NERVE moved from cg_weapons (now used in g_active) for drop command, actual array in bg_misc.c extern int weapBanksMultiPlayer[MAX_WEAP_BANKS_MP][MAX_WEAPS_IN_BANK_MP]; // jpw @@ -861,7 +880,12 @@ extern const char* medalNames[SK_NUM_SKILLS]; #define NUM_SKILL_LEVELS 5 + +#ifdef GAMEDLL +extern int skillLevels[SK_NUM_SKILLS][NUM_SKILL_LEVELS]; +#else extern const int skillLevels[NUM_SKILL_LEVELS]; +#endif typedef struct { weaponStats_t weaponStats[WP_NUM_WEAPONS]; @@ -1458,6 +1482,9 @@ // OSP -- keep these 2 entries last MOD_SWITCHTEAM, + MOD_GOOMBA, + MOD_POISON, + MOD_NUM_MODS } meansOfDeath_t; diff -urN --exclude=.svn et260/src/game/etpub.h etpub/src/game/etpub.h --- et260/src/game/etpub.h 1969-12-31 18:00:00.000000000 -0600 +++ etpub/src/game/etpub.h 2005-04-21 13:32:26.000000000 -0500 @@ -0,0 +1,6 @@ +#ifndef _ETPUB_H +#define _ETPUB_H + +#define ETPUB_VERSION "0.4.3" + +#endif // ifndef _ETPUB_H diff -urN --exclude=.svn et260/src/game/g_active.c etpub/src/game/g_active.c --- et260/src/game/g_active.c 2005-04-12 12:11:50.000000000 -0500 +++ etpub/src/game/g_active.c 2005-04-25 22:21:36.000000000 -0500 @@ -1,4 +1,3 @@ - #include "g_local.h" /* @@ -17,7 +16,8 @@ vec3_t angles; client = player->client; - if ( client->ps.pm_type == PM_DEAD ) { + if ( client->ps.pm_type == PM_DEAD && + !(client->ps.eFlags & EF_PLAYDEAD)) { return; } @@ -374,7 +374,9 @@ ent->client->touchingTOI = NULL; // dead clients don't activate triggers! - if ( ent->client->ps.stats[STAT_HEALTH] <= 0 ) { + // tjw: unless they're only playing. + if ( ent->client->ps.stats[STAT_HEALTH] <= 0 && + !(ent->client->ps.eFlags & EF_PLAYDEAD)) { return; } @@ -437,6 +439,37 @@ } } +// returns true if a player was found to follow +qboolean G_SpectatorAttackFollow(gentity_t *ent) { + trace_t tr; + vec3_t forward, right, up; + vec3_t start, end; + gentity_t *vic; + + if(!ent->client) + return qfalse; + + AngleVectors(ent->client->ps.viewangles, forward, right, up); + VectorCopy(ent->client->ps.origin, start); + VectorMA(start, 8192, forward, end); + + G_HistoricalTrace(ent, + &tr, + start, + NULL, + NULL, + end, + ent->s.number, + MASK_SHOT); + vic = &g_entities[tr.entityNum]; + if(vic->client) { + ent->client->sess.spectatorState = SPECTATOR_FOLLOW; + ent->client->sess.spectatorClient = tr.entityNum; + return qtrue; + } + return qfalse; +} + /* ================= SpectatorThink @@ -522,11 +555,24 @@ client->oldwbuttons = client->wbuttons; client->wbuttons = ucmd->wbuttons; + // MV clients use these buttons locally for other things if(client->pers.mvCount < 1) { // attack button cycles through spectators - if ( ( client->buttons & BUTTON_ATTACK ) && ! ( client->oldbuttons & BUTTON_ATTACK ) ) { - Cmd_FollowCycle_f( ent, 1 ); + if(((client->buttons & BUTTON_ATTACK) && + !(client->oldbuttons & BUTTON_ATTACK)) && + !(client->buttons & BUTTON_ACTIVATE) && + ucmd->upmove == 0) { + + if(client->sess.spectatorState != SPECTATOR_FOLLOW) { + if(g_spectator.integer & SPECF_FL_CLICK_FOLLOW) { + if(G_SpectatorAttackFollow(ent)) + return; + if(!(g_spectator.integer & SPECF_FL_MISS_FOLLOW_NEXT)) + return; + } + } + Cmd_FollowCycle_f(ent, 1); } // activate button swaps places with bot else if( client->sess.sessionTeam != TEAM_SPECTATOR && @@ -535,14 +581,15 @@ ( g_entities[ent->client->sess.spectatorClient].r.svFlags & SVF_BOT ) ) { Cmd_SwapPlacesWithBot_f( ent, ent->client->sess.spectatorClient ); - } else if ( - ( client->sess.sessionTeam == TEAM_SPECTATOR ) && // don't let dead team players do free fly - ( client->sess.spectatorState == SPECTATOR_FOLLOW ) && - ( ( ( client->buttons & BUTTON_ACTIVATE ) && - ! ( client->oldbuttons & BUTTON_ACTIVATE )) || ucmd->upmove > 0 ) && - G_allowFollow(ent, TEAM_AXIS) && G_allowFollow(ent, TEAM_ALLIES) ) - { - // code moved to StopFollowing + } + else if(client->sess.sessionTeam == TEAM_SPECTATOR && + client->sess.spectatorState == SPECTATOR_FOLLOW && + (((client->buttons & BUTTON_ACTIVATE) && + !(client->oldbuttons & BUTTON_ACTIVATE)) || + ucmd->upmove > 0 ) && + G_allowFollow(ent, TEAM_AXIS) && + G_allowFollow(ent, TEAM_ALLIES)) { + StopFollowing(ent); } } @@ -580,7 +627,9 @@ g_spectatorInactivity.integer); } else if ( !client->pers.localClient ) { - if ( level.time > client->inactivityTime && client->inactivityWarning) { + if(level.time > client->inactivityTime && + client->inactivityWarning && + !G_shrubbot_permission(&g_entities[client-level.clients], SBF_IMMUNITY)) { client->inactivityWarning = qfalse; client->inactivityTime = level.time + 60 * 1000; trap_DropClient(client - level.clients, "Dropped due to inactivity", 0 ); @@ -608,6 +657,8 @@ */ void ClientTimerActions( gentity_t *ent, int msec ) { gclient_t *client; + gentity_t *attacker; + int regenRate1 = 3, regenRate2 = 2; client = ent->client; client->timeResidual += msec; @@ -615,15 +666,25 @@ while( client->timeResidual >= 1000 ) { client->timeResidual -= 1000; + // Calculate regen rate + if (g_medics.integer & MEDIC_REGENRATE21) { + regenRate1 = 2; + regenRate2 = 1; + } else if (g_medics.integer & MEDIC_REGENRATE10) { + regenRate1 = 1; + regenRate2 = 0; + } + // regenerate - if( client->sess.playerType == PC_MEDIC ) { + // tjw: dead players can't regenerate + if( client->sess.playerType == PC_MEDIC && !(client->ps.eFlags & EF_DEAD) ) { if( ent->health < client->ps.stats[STAT_MAX_HEALTH]) { - ent->health += 3; + ent->health += regenRate1; if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] * 1.1){ ent->health = client->ps.stats[STAT_MAX_HEALTH] * 1.1; } } else if( ent->health < client->ps.stats[STAT_MAX_HEALTH] * 1.12) { - ent->health += 2; + ent->health += regenRate2; if( ent->health > client->ps.stats[STAT_MAX_HEALTH] * 1.12 ) { ent->health = client->ps.stats[STAT_MAX_HEALTH] * 1.12; } @@ -634,7 +695,21 @@ ent->health--; } } + if(client->ps.poisoned && ent->health > 0 && g_poison.integer) { + attacker = g_entities + client->ps.poisonerEnt; + G_Damage(ent, attacker, attacker, NULL, NULL, + g_poison.integer, 0, MOD_POISON); + } + if(client->ps.poisoned && + (ent->health <= 0 || + client->ps.eFlags & EF_DEAD)) { + client->ps.poisoned = qfalse; + } } + + // notify client that they are playing dead + if(client->ps.eFlags & EF_PLAYDEAD && ent->health > 0) + CP("cp \"Playing Dead\" 1"); } /* @@ -672,6 +747,9 @@ gclient_t *client; int damage; vec3_t dir; + gentity_t *victim; + int kb_time = 0; + client = ent->client; @@ -683,7 +761,7 @@ switch ( event ) { case EV_FALL_NDIE: - //case EV_FALL_SHORT: + case EV_FALL_SHORT: case EV_FALL_DMG_10: case EV_FALL_DMG_15: case EV_FALL_DMG_25: @@ -694,6 +772,24 @@ // rain - VectorClear() used to be done here whenever falling // damage occured, but I moved it to bg_pmove where it belongs. + + victim = &level.gentities[ent->s.groundEntityNum]; + // groundEntityNum won't be set to the entity number + // of a wounded player if you landed on one. + // trace to see if we're on a wounded player. + if(!victim->client) { + trace_t tr; + vec3_t start, stop; + + VectorCopy(ent->r.currentOrigin, start); + VectorCopy(ent->r.currentOrigin, stop); + stop[2] -= 4; + trap_Trace (&tr, start, NULL, NULL, stop, + ent->s.number, MASK_SHOT); + victim = &level.gentities[tr.entityNum]; + + } + if ( ent->s.eType != ET_PLAYER ) { break; // not in the player model } @@ -704,30 +800,62 @@ else if (event == EV_FALL_DMG_50) { damage = 50; - ent->client->ps.pm_time = 1000; - ent->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; + kb_time = 1000; } else if (event == EV_FALL_DMG_25) { damage = 25; - ent->client->ps.pm_time = 250; - ent->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; + kb_time = 500; } else if (event == EV_FALL_DMG_15) { damage = 15; - ent->client->ps.pm_time = 1000; - ent->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; + kb_time = 250; } else if (event == EV_FALL_DMG_10) { damage = 10; - ent->client->ps.pm_time = 1000; - ent->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; + kb_time = 250; + } + else if(victim->client && g_goomba.integer) { + damage = 5; } - else - damage = 5; // never used + else { + break; + } + + //VectorClear (ent->client->ps.velocity); + VectorSet (dir, 0, 0, 1); + + if(kb_time) { + ent->client->ps.pm_time = kb_time; + ent->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; + } + + if(victim->client && g_goomba.integer) { + + if(kb_time) { + victim->client->ps.pm_time = kb_time; + victim->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; + } + // no normal pain sound + victim->pain_debounce_time = level.time + 200; + G_Damage (victim, ent, ent, NULL, NULL, + (damage * g_goomba.integer), 0, MOD_GOOMBA); + if(damage > 5) { + G_AddEvent(victim, EV_GENERAL_SOUND, + G_SoundIndex("sound/world/debris1.wav")); + // faller has a soft landing + damage *= 0.2f; + } + else { + G_AddEvent(victim, EV_GENERAL_SOUND, + G_SoundIndex("sound/player/land_hurt.wav")); + break; + } + } + ent->pain_debounce_time = level.time + 200; // no normal pain sound G_Damage (ent, NULL, NULL, NULL, NULL, damage, 0, MOD_FALLING); break; @@ -859,7 +987,9 @@ continue; } - if( cl->ps.stats[ STAT_PLAYER_CLASS ] != PC_MEDIC ) { + // tjw: ps.stats updated before spawn? + //if( cl->ps.stats[ STAT_PLAYER_CLASS ] != PC_MEDIC ) { + if(cl->sess.playerType != PC_MEDIC) { continue; } @@ -916,10 +1046,15 @@ return; } + // tjw: this is causing the segfault associated with antilag + // I'm assuming it's not important since currentAngles never + // seem to get used for anything (always 0?) + /* if( ent->s.eFlags & EF_MOUNTEDTANK ) { client->pmext.centerangles[YAW] = ent->tagParent->r.currentAngles[ YAW ]; client->pmext.centerangles[PITCH] = ent->tagParent->r.currentAngles[ PITCH ]; } + */ /* if (client->cameraPortal) { G_SetOrigin( client->cameraPortal, client->ps.origin ); @@ -932,6 +1067,69 @@ ent->client->ps.identifyClient = ucmd->identClient; // NERVE - SMF +//unlagged - true ping + // save the estimated ping in a queue for averaging later + + // we use level.previousTime to account for 50ms lag correction + // besides, this will turn out numbers more like what players are used to + // josh: changed it back. People don't like it. + client->pers.pingsamples[client->pers.samplehead] = + level.previousTime + + client->frameOffset - + ucmd->serverTime; + client->pers.samplehead++; + if ( client->pers.samplehead >= NUM_PING_SAMPLES ) { + client->pers.samplehead -= NUM_PING_SAMPLES; + } + + // initialize the real ping + if ( g_truePing.integer ) { + int i, sum = 0; + + // get an average of the samples we saved up + for ( i = 0; i < NUM_PING_SAMPLES; i++ ) { + sum += client->pers.pingsamples[i]; + } + + client->pers.realPing = sum / NUM_PING_SAMPLES; + } + else { + // if g_truePing is off, use the normal ping + client->pers.realPing = client->ps.ping; + } +//unlagged - true ping + + if(client->warping && g_maxWarp.integer) { + int frames = (level.framenum - client->lastUpdateFrame); + + if(frames > g_maxWarp.integer) + frames = g_maxWarp.integer; + ucmd->serverTime = level.previousTime; + client->ps.commandTime = level.previousTime - + (frames * (level.time - level.previousTime)); + client->warped = qtrue; + } + client->warping = qfalse; + + +//unlagged - smooth clients #1 + // keep track of this for later - we'll use this to decide whether or not + // to send extrapolated positions for this client + client->lastUpdateFrame = level.framenum; + + + +//unlagged - smooth clients #1 + +//unlagged - true ping + // make sure the true ping is over 0 - with cl_timenudge it can be less + if ( client->pers.realPing < 0 ) { + client->pers.realPing = 0; + } +//unlagged - true ping + + + // sanity check the command time to prevent speedup cheating if ( ucmd->serverTime > level.time + 200 ) { ucmd->serverTime = level.time + 200; @@ -942,6 +1140,18 @@ // G_Printf("serverTime >>>>>\n" ); } + //josh: Check for auto-mute and unmute if appropriate + if (client->sess.muted && + client->sess.auto_mute_time != -1 && + level.time - client->sess.auto_mute_time > + g_censorMuteTime.integer*1000) { + client->sess.muted = qfalse; + client->sess.auto_mute_time = -1; + CPx(ent - g_entities, "print \"^5You've been auto-unmuted. Language penalty lifted.\""); + AP(va("chat \"%s's^7 has been auto-unmuted. Language penalty lifted.\"", + ent->client->pers.netname )); + } + msec = ucmd->serverTime - client->ps.commandTime; // following others may result in bad times, but we still want // to check for follow toggles @@ -993,6 +1203,11 @@ SpectatorThink( ent, ucmd ); return; } + // bani's flamethrower exploit fix + if( client->flametime && level.time > client->flametime ) { + client->flametime = 0; + ent->r.svFlags &= ~SVF_BROADCAST; + } if((client->ps.eFlags & EF_VIEWING_CAMERA) || level.match_pause != PAUSE_NONE #ifdef SAVEGAME_SUPPORT @@ -1019,11 +1234,19 @@ VectorClear(client->ps.velocity); client->ps.pm_type = PM_FREEZE; } - } else if ( client->noclip ) { + } + else if ( client->noclip ) { client->ps.pm_type = PM_NOCLIP; - } else if ( client->ps.stats[STAT_HEALTH] <= 0 ) { + } + else if(client->ps.pm_type == PM_PLAYDEAD) { + // no need to change it since it will + // be adjusted by PM_CheckPlayDead regardless + } + else if(client->ps.stats[STAT_HEALTH] <= 0 || + client->ps.eFlags & EF_PLAYDEAD) { client->ps.pm_type = PM_DEAD; - } else { + } + else { client->ps.pm_type = PM_NORMAL; } @@ -1152,9 +1375,10 @@ monsterslick = Pmove( &pm ); // Gordon: thx to bani for this - // ikkyo - fix leaning players bug - VectorCopy( client->ps.velocity, ent->s.pos.trDelta ); - SnapVector( ent->s.pos.trDelta ); + // ikkyo - fix leaning players bug + // josh: This is now done in BG_PlayerStateToEntityState where it should be. + //VectorCopy( client->ps.velocity, ent->s.pos.trDelta ); + //SnapVector( ent->s.pos.trDelta ); // end // server cursor hints @@ -1178,12 +1402,24 @@ ent->r.eventTime = level.time; } +//unlagged - smooth clients #2 + // clients no longer do extrapolation if cg_smoothClients is 1, because + // skip correction is all handled server-side now + // since that's the case, it makes no sense to store the extra info + // in the client's snapshot entity, so let's save a little bandwidth + // Ridah, fixes jittery zombie movement +/* if (g_smoothClients.integer) { BG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, level.time, qfalse ); } else { BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qfalse ); } + else { +*/ + BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qtrue ); +// } +//unlagged - smooth clients #2 if ( !( ent->client->ps.eFlags & EF_FIRING ) ) { client->fireHeld = qfalse; // for grapple @@ -1216,6 +1452,12 @@ // NOTE: now copy the exact origin over otherwise clients can be snapped into solid VectorCopy( ent->client->ps.origin, ent->r.currentOrigin ); + // store the client's current position for antilag traces + // Neil Toronto says this should be in ClientEndFrame NOT here. + // This should track server frames NOT client ones since clients + // interpolate what the server says + //G_StoreClientPosition( ent ); + // touch other objects ClientImpacts( ent, &pm ); @@ -1253,7 +1495,8 @@ } // check for respawning - if( client->ps.stats[STAT_HEALTH] <= 0 ) { + if( client->ps.stats[STAT_HEALTH] <= 0 && + !(client->ps.eFlags & EF_PLAYDEAD)) { // DHM - Nerve WolfFindMedic( ent ); @@ -1290,6 +1533,32 @@ } } + if(g_debugHitboxes.integer == 2) { + gentity_t *bboxEnt, *head; + vec3_t b1, b2; + vec3_t maxs; + + VectorCopy(ent->r.currentOrigin, b1); + VectorCopy(ent->r.currentOrigin, b2); + VectorAdd(b1, ent->r.mins, b1); + VectorCopy(ent->r.maxs, maxs); + maxs[2] = ClientHitboxMaxZ(ent); + VectorAdd(b2, maxs, b2); + bboxEnt = G_TempEntity( b1, EV_RAILTRAIL ); + VectorCopy(b2, bboxEnt->s.origin2); + bboxEnt->s.dmgFlags = 1; + + head = G_BuildHead(ent); + VectorCopy(head->r.currentOrigin, b1); + VectorCopy(head->r.currentOrigin, b2); + VectorAdd(b1, head->r.mins, b1); + VectorAdd(b2, head->r.maxs, b2); + bboxEnt = G_TempEntity( b1, EV_RAILTRAIL ); + VectorCopy(b2, bboxEnt->s.origin2); + bboxEnt->s.dmgFlags = 1; + G_FreeEntity( head ); + } + // perform once-a-second actions if(level.match_pause == PAUSE_NONE) { ClientTimerActions( ent, msec ); @@ -1310,9 +1579,14 @@ ent->client->pers.oldcmd = ent->client->pers.cmd; trap_GetUsercmd( clientNum, &ent->client->pers.cmd ); +//unlagged - smooth clients #1 + // this is handled differently now +/* // mark the time we got info, so we can display the // phone jack if they don't get any for a while ent->client->lastCmdTime = level.time; +*/ +//unlagged - smooth clients #1 #ifdef ALLOW_GSYNC if ( !g_synchronousClients.integer ) @@ -1375,6 +1649,13 @@ gclient_t *cl; qboolean do_respawn = qfalse; // JPW NERVE + /* + G_Printf("(dwRedReinfOffset %d + timeCurrent %d - startTime %d) lastReinforceTime %d\n", + level.dwRedReinfOffset, + level.timeCurrent, + level.startTime, + ent->client->pers.lastReinforceTime); + */ // Players can respawn quickly in warmup if(g_gamestate.integer != GS_PLAYING && ent->client->respawnTime <= level.timeCurrent && ent->client->sess.sessionTeam != TEAM_SPECTATOR) { @@ -1389,6 +1670,11 @@ do_respawn = (testtime < ent->client->pers.lastReinforceTime); ent->client->pers.lastReinforceTime = testtime; } + /* + G_Printf("testtime %d lastReinforceTime %d\n\n", + testtime, + ent->client->pers.lastReinforceTime); + */ if( g_gametype.integer != GT_WOLF_LMS ) { if ( ( g_maxlives.integer > 0 || g_alliedmaxlives.integer > 0 || g_axismaxlives.integer > 0 ) @@ -1442,7 +1728,9 @@ int flags = (cl->ps.eFlags & ~(EF_VOTED)) | (ent->client->ps.eFlags & (EF_VOTED)); int ping = ent->client->ps.ping; - if(ent->client->sess.sessionTeam != TEAM_SPECTATOR && (ent->client->ps.pm_flags & PMF_LIMBO)) { + if(ent->client->sess.sessionTeam != TEAM_SPECTATOR && + (ent->client->ps.pm_flags & PMF_LIMBO)) { + int savedScore = ent->client->ps.persistant[PERS_SCORE]; int savedRespawns = ent->client->ps.persistant[PERS_RESPAWNS_LEFT]; int savedRespawnPenalty = ent->client->ps.persistant[PERS_RESPAWNS_PENALTY]; @@ -1452,15 +1740,15 @@ do_respawn = ent->client->ps.pm_time; ent->client->ps = cl->ps; - ent->client->ps.pm_flags |= PMF_FOLLOW; - ent->client->ps.pm_flags |= PMF_LIMBO; - ent->client->ps.pm_time = do_respawn; // put pm_time back ent->client->ps.persistant[PERS_RESPAWNS_LEFT] = savedRespawns; ent->client->ps.persistant[PERS_RESPAWNS_PENALTY] = savedRespawnPenalty; ent->client->ps.persistant[PERS_SCORE] = savedScore; // put score back ent->client->ps.powerups[PW_MVCLIENTLIST] = savedMVList; ent->client->ps.stats[STAT_PLAYER_CLASS] = savedClass; // NERVE - SMF - put player class back + ent->client->ps.pm_flags |= PMF_FOLLOW; + ent->client->ps.pm_flags |= PMF_LIMBO; + } else { ent->client->ps = cl->ps; ent->client->ps.pm_flags |= PMF_FOLLOW; @@ -1624,7 +1912,9 @@ */ void ClientEndFrame( gentity_t *ent ) { int i; - +//unlagged - smooth clients #1 + int frames; +//unlagged - smooth clients #1 // used for informing of speclocked teams. // Zero out here and set only for certain specs @@ -1712,27 +2002,35 @@ // apply all the damage taken this frame P_DamageFeedback (ent); - + +//unlagged - smooth clients #1 + // this is handled differently now +/* // add the EF_CONNECTION flag if we haven't gotten commands recently if ( level.time - ent->client->lastCmdTime > 1000 ) { ent->s.eFlags |= EF_CONNECTION; } else { ent->s.eFlags &= ~EF_CONNECTION; } +*/ +//unlagged - smooth client #1 - ent->client->ps.stats[STAT_HEALTH] = ent->health; // FIXME: get rid of ent->health... - // Gordon: WHY? other ents use it. + // don't tell the clients about this player's health + // when using playdead. It's a secret. + if(!(ent->s.eFlags & EF_PLAYDEAD)) + ent->client->ps.stats[STAT_HEALTH] = ent->health; G_SetClientSound (ent); // set the latest infor // Ridah, fixes jittery zombie movement - if (g_smoothClients.integer) { - BG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, level.time, qfalse ); - } else { + // josh: smoothClients is EVIL. Puts everyone off by at least 50 ms + //if (g_smoothClients.integer) { + // BG_PlayerStateToEntityStateExtraPolate( &ent->client->ps, &ent->s, ent->client->ps.commandTime, qtrue ); + //} else { BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qfalse ); - } + //} //SendPendingPredictableEvents( &ent->client->ps ); @@ -1746,7 +2044,11 @@ ent->r.contents = CONTENTS_CORPSE; } - if ( ent->health > 0 && ent->r.contents == CONTENTS_CORPSE && !(ent->s.eFlags & EF_MOUNTEDTANK)) { + if ( ent->health > 0 && + ent->r.contents == CONTENTS_CORPSE && + !(ent->s.eFlags & EF_MOUNTEDTANK) && + !(ent->s.eFlags & EF_PLAYDEAD) + ) { WolfReviveBbox( ent ); } @@ -1763,6 +2065,59 @@ // run entity scripting G_Script_ScriptRun( ent ); - // store the client's current position for antilag traces +//unlagged - smooth clients #1 + // mark as not missing updates initially + ent->client->ps.eFlags &= ~EF_CONNECTION; + + // see how many frames the client has missed + frames = level.framenum - ent->client->lastUpdateFrame - 1; + + if(g_maxWarp.integer && frames > g_maxWarp.integer) + ent->client->warping = qtrue; + + if(g_skipCorrection.integer && !ent->client->warped && frames > 0) { + if (frames > 2) { + // josh: I need frames to be = 2 here + frames = 2; + // these are disabled because the phone jack can give + // away other players position through walls. + //ent->client->ps.eFlags |= EF_CONNECTION; + //ent->s.eFlags |= EF_CONNECTION; + } + G_PredictPmove(ent, (float)frames / sv_fps.integer); + } + ent->client->warped = qfalse; + +//unlagged - smooth clients #1 + + if(g_debugHitboxes.integer == 1) { + gentity_t *bboxEnt, *head; + vec3_t b1, b2; + vec3_t maxs; + + VectorCopy(ent->r.currentOrigin, b1); + VectorCopy(ent->r.currentOrigin, b2); + VectorAdd(b1, ent->r.mins, b1); + VectorCopy(ent->r.maxs, maxs); + maxs[2] = ClientHitboxMaxZ(ent); + VectorAdd(b2, maxs, b2); + bboxEnt = G_TempEntity( b1, EV_RAILTRAIL ); + VectorCopy(b2, bboxEnt->s.origin2); + bboxEnt->s.dmgFlags = 1; + + head = G_BuildHead(ent); + VectorCopy(head->r.currentOrigin, b1); + VectorCopy(head->r.currentOrigin, b2); + VectorAdd(b1, head->r.mins, b1); + VectorAdd(b2, head->r.maxs, b2); + bboxEnt = G_TempEntity( b1, EV_RAILTRAIL ); + VectorCopy(b2, bboxEnt->s.origin2); + bboxEnt->s.dmgFlags = 1; + G_FreeEntity( head ); + + } + + // josh: moved over from ClientThink see the note there + // We want this to track the server's viewpoint G_StoreClientPosition( ent ); } diff -urN --exclude=.svn et260/src/game/g_antilag.c etpub/src/game/g_antilag.c --- et260/src/game/g_antilag.c 2005-04-12 12:11:50.000000000 -0500 +++ etpub/src/game/g_antilag.c 2005-04-22 11:48:11.000000000 -0500 @@ -1,38 +1,118 @@ #include "g_local.h" -void G_StoreClientPosition( gentity_t* ent ) { - int top; +/* +============= +TimeShiftLerp (from g_unlagged.c) + +Used below to interpolate between two previous vectors +Returns a vector "frac" times the distance between "start" and "end" +============= +*/ +static void TimeShiftLerp( vec3_t start, vec3_t end, float frac, vec3_t result ) { +// From CG_InterpolateEntityPosition in cg_ents.c: +/* + cent->lerpOrigin[0] = current[0] + f * ( next[0] - current[0] ); + cent->lerpOrigin[1] = current[1] + f * ( next[1] - current[1] ); + cent->lerpOrigin[2] = current[2] + f * ( next[2] - current[2] ); + + Angles would be done in a different function, but here they are only the s.angles + lerpAngles is copied over from ent->s.angles + cent->lerpAngles[0] = LerpAngle( current[0], next[0], f ); + cent->lerpAngles[1] = LerpAngle( current[1], next[1], f ); + cent->lerpAngles[2] = LerpAngle( current[2], next[2], f ); + +*/ +// Making these exactly the same should avoid floating-point error + + result[0] = start[0] + frac * ( end[0] - start[0] ); + result[1] = start[1] + frac * ( end[1] - start[1] ); + result[2] = start[2] + frac * ( end[2] - start[2] ); +} + +qboolean G_AntilagSafe(gentity_t *ent) +{ + if(!ent) + return qfalse; + + if(!ent->inuse) + return qfalse; + + if(!ent->r.linked) + return qfalse; + + if(!ent->client) + return qfalse; + + if(ent->client->sess.sessionTeam != TEAM_AXIS + && ent->client->sess.sessionTeam != TEAM_ALLIES) + return qfalse; + + if(ent->health <= 0) + return qfalse; + + if((ent->client->ps.pm_flags & PMF_LIMBO)) + return qfalse; + + // tjw: don't store clientMarkers for corpses, etc + if(!(ent->client->ps.pm_type == PM_NORMAL)) + return qfalse; + + // tjw: don't store clientMarkers for the player on + // the tank + if((ent->client->ps.eFlags & EF_MOUNTEDTANK)) + return qfalse; - if(!( ent->inuse && - (ent->client->sess.sessionTeam == TEAM_AXIS || ent->client->sess.sessionTeam == TEAM_ALLIES) && - ent->r.linked && - (ent->health > 0) && - !(ent->client->ps.pm_flags & PMF_LIMBO) && - (ent->client->ps.pm_type == PM_NORMAL) - )) { - return; - } + return qtrue; +} + +void G_StoreClientPosition( gentity_t* ent ) { + int top; + + if(!G_AntilagSafe(ent)) return; ent->client->topMarker++; - if( ent->client->topMarker >= MAX_CLIENT_MARKERS ) { + if ( ent->client->topMarker >= MAX_CLIENT_MARKERS ) { ent->client->topMarker = 0; } top = ent->client->topMarker; - VectorCopy( ent->r.mins, ent->client->clientMarkers[top].mins ); - VectorCopy( ent->r.maxs, ent->client->clientMarkers[top].maxs ); - VectorCopy( ent->s.pos.trBase, ent->client->clientMarkers[top].origin ); + VectorCopy(ent->r.mins, ent->client->clientMarkers[top].mins); + VectorCopy(ent->r.maxs, ent->client->clientMarkers[top].maxs); + + // change to trbase instead of origin, correct for client (use s!!) + VectorCopy(ent->s.pos.trBase, ent->client->clientMarkers[top].origin); + + ent->client->clientMarkers[top].time = level.time; + //ent->client->clientMarkers[top].servertime = level.time; + + //josh: more info needed for head / leg shots + // tjw: It seems that s.apos.trBase and ps.viewangles are in sync and + // the only usable angles for determining the direction the client + // is pointing. I don't know wtf r.currentAngles, + // s.angles, and s.angles2 are for. + // josh: Yeah, Neil says they were just copying the angle into every + // angle they could think of "just in case". He was very unimpressed. + VectorCopy(ent->s.apos.trBase, + ent->client->clientMarkers[top].viewangles); + + ent->client->clientMarkers[top].eFlags = ent->s.eFlags; + ent->client->clientMarkers[top].pm_flags = ent->client->ps.pm_flags; + ent->client->clientMarkers[top].viewheight = ent->client->ps.viewheight; + } -static void G_AdjustSingleClientPosition( gentity_t* ent, int time ) { +void G_AdjustSingleClientPosition( gentity_t* ent, int time, gentity_t* debugger) { int i, j; + // unlagged analogies: antilag i = unlagged j, antilag j = unlagged k if( time > level.time ) { time = level.time; } // no lerping forward.... + if(!G_AntilagSafe(ent)) return; + // find a pair of markers which bound the requested time i = j = ent->client->topMarker; do { @@ -51,42 +131,142 @@ return; } - // save current position to backup - if( ent->client->backupMarker.time != level.time ) { - VectorCopy( ent->r.currentOrigin, ent->client->backupMarker.origin ); - VectorCopy( ent->r.mins, ent->client->backupMarker.mins ); - VectorCopy( ent->r.maxs, ent->client->backupMarker.maxs ); + // josh: from unlagged make sure it doesn't get backed-up twice + if ( ent->client->backupMarker.time != level.time ) { + VectorCopy(ent->r.currentOrigin, ent->client->backupMarker.origin); + VectorCopy(ent->r.mins, ent->client->backupMarker.mins); + VectorCopy(ent->r.maxs, ent->client->backupMarker.maxs); + //josh: for Head, Legs + VectorCopy(ent->client->ps.viewangles, + ent->client->backupMarker.viewangles); + ent->client->backupMarker.eFlags = ent->client->ps.eFlags; + ent->client->backupMarker.pm_flags = ent->client->ps.pm_flags; + ent->client->backupMarker.viewheight = ent->client->ps.viewheight; + // josh: This was missing, but needed or else no readjustment ent->client->backupMarker.time = level.time; } - if( i != ent->client->topMarker ) { - float frac = (float)(time - ent->client->clientMarkers[i].time) / - (float)(ent->client->clientMarkers[j].time - ent->client->clientMarkers[i].time); - - LerpPosition( ent->client->clientMarkers[i].origin, ent->client->clientMarkers[j].origin, frac, ent->r.currentOrigin ); - LerpPosition( ent->client->clientMarkers[i].mins, ent->client->clientMarkers[j].mins, frac, ent->r.mins ); - LerpPosition( ent->client->clientMarkers[i].maxs, ent->client->clientMarkers[j].maxs, frac, ent->r.maxs ); + if(i != ent->client->topMarker) { + //float frac = ((float)(ent->client->clientMarkers[j].time - time)) / (ent->client->clientMarkers[j].time - ent->client->clientMarkers[i].time); + //josh: reversing the order to better match the client and prevent + //roundoff error + float frac = (float)(time - ent->client->clientMarkers[i].time) / + (float)(ent->client->clientMarkers[j].time - ent->client->clientMarkers[i].time); + + //LerpPosition(ent->client->clientMarkers[i].origin, ent->client->clientMarkers[j].origin, frac, ent->r.currentOrigin); + //LerpPosition(ent->client->clientMarkers[i].mins, ent->client->clientMarkers[j].mins, frac, ent->r.mins); + //LerpPosition(ent->client->clientMarkers[i].maxs, ent->client->clientMarkers[j].maxs, frac, ent->r.maxs); + //josh: Using TimeShiftLerp since it follows the client exactly + //meaning less roundoff error + TimeShiftLerp( + ent->client->clientMarkers[i].origin, + ent->client->clientMarkers[j].origin, + frac, + ent->r.currentOrigin); + TimeShiftLerp( + ent->client->clientMarkers[i].mins, + ent->client->clientMarkers[j].mins, + frac, + ent->r.mins); + TimeShiftLerp( + ent->client->clientMarkers[i].maxs, + ent->client->clientMarkers[j].maxs, + frac, + ent->r.maxs); + + // These are for Head / Legs + ent->client->ps.viewangles[0] = LerpAngle( + ent->client->clientMarkers[i].viewangles[0], + ent->client->clientMarkers[j].viewangles[0], + frac); + ent->client->ps.viewangles[1] = LerpAngle( + ent->client->clientMarkers[i].viewangles[1], + ent->client->clientMarkers[j].viewangles[1], + frac); + ent->client->ps.viewangles[2] = LerpAngle( + ent->client->clientMarkers[i].viewangles[2], + ent->client->clientMarkers[j].viewangles[2], + frac); + // josh: Set the ints to the closest ones in time since you can't + // lerp them. + if((ent->client->clientMarkers[j].time - time) + < (time - ent->client->clientMarkers[i].time)) { + + ent->client->ps.eFlags = + ent->client->clientMarkers[j].eFlags; + ent->client->ps.pm_flags = + ent->client->clientMarkers[j].pm_flags; + ent->client->ps.viewheight = + ent->client->clientMarkers[j].viewheight; + } else { + ent->client->ps.eFlags = + ent->client->clientMarkers[i].eFlags; + ent->client->ps.pm_flags = + ent->client->clientMarkers[i].pm_flags; + ent->client->ps.viewheight = + ent->client->clientMarkers[i].viewheight; + } + if ( debugger && debugger->client) { + // print some debugging stuff exactly like what the client does + // it starts with "Rec:" to let you know it backward-reconciled + char msg[2048]; + Com_sprintf( msg, sizeof(msg), + "print \"^1Rec: time: %d, j: %d, k: %d, origin: %0.2f %0.2f %0.2f\n" + "^2frac: %0.4f, origin1: %0.2f %0.2f %0.2f, origin2: %0.2f %0.2f %0.2f\n" + "^7level.time: %d, est time: %d, level.time delta: %d, est real ping: %d\n\"", + time, ent->client->clientMarkers[i].time, ent->client->clientMarkers[j].time, + ent->r.currentOrigin[0], ent->r.currentOrigin[1], ent->r.currentOrigin[2], + frac, + ent->client->clientMarkers[i].origin[0], + ent->client->clientMarkers[i].origin[1], + ent->client->clientMarkers[i].origin[2], + ent->client->clientMarkers[j].origin[0], + ent->client->clientMarkers[j].origin[1], + ent->client->clientMarkers[j].origin[2], + level.time, level.time + debugger->client->frameOffset, + level.time - time, level.time + debugger->client->frameOffset - time); + + trap_SendServerCommand( debugger - g_entities, msg ); + } } else { VectorCopy( ent->client->clientMarkers[j].origin, ent->r.currentOrigin ); VectorCopy( ent->client->clientMarkers[j].mins, ent->r.mins ); VectorCopy( ent->client->clientMarkers[j].maxs, ent->r.maxs ); + //// josh: BuildHead/Legs uses these + VectorCopy(ent->client->clientMarkers[j].viewangles, + ent->client->ps.viewangles); + ent->client->ps.eFlags = + ent->client->clientMarkers[j].eFlags; + ent->client->ps.pm_flags = + ent->client->clientMarkers[j].pm_flags; + ent->client->ps.viewheight = + ent->client->clientMarkers[j].viewheight; } trap_LinkEntity( ent ); } -static void G_ReAdjustSingleClientPosition( gentity_t* ent ) { - if( !ent || !ent->client ) { - return; - } +void G_ReAdjustSingleClientPosition( gentity_t* ent ) { - // restore from backup - if( ent->client->backupMarker.time == level.time ) { - VectorCopy( ent->client->backupMarker.origin, ent->r.currentOrigin ); - VectorCopy( ent->client->backupMarker.mins, ent->r.mins ); - VectorCopy( ent->client->backupMarker.maxs, ent->r.maxs ); - ent->client->backupMarker.time = 0; + if(!G_AntilagSafe(ent)) return; + if( ent->client->backupMarker.time == level.time) { + VectorCopy( ent->client->backupMarker.origin, ent->r.currentOrigin ); + VectorCopy( ent->client->backupMarker.mins, ent->r.mins ); + VectorCopy( ent->client->backupMarker.maxs, ent->r.maxs ); + //josh: Head, Legs stuff + VectorCopy(ent->client->backupMarker.viewangles, + ent->client->ps.viewangles); + + ent->client->ps.eFlags = + ent->client->backupMarker.eFlags; + ent->client->ps.pm_flags = + ent->client->backupMarker.pm_flags; + ent->client->ps.viewheight = + ent->client->backupMarker.viewheight; + + //ent->client->backupMarker.servertime = 0; + ent->client->backupMarker.time = 0; trap_LinkEntity( ent ); } } @@ -97,38 +277,33 @@ for( i = 0; i < level.numConnectedClients; i++, list++ ) { list = g_entities + level.sortedClients[i]; - // Gordon: ok lets test everything under the sun - if( list->client && - list->inuse && - (list->client->sess.sessionTeam == TEAM_AXIS || list->client->sess.sessionTeam == TEAM_ALLIES) && - (list != ent) && - list->r.linked && - (list->health > 0) && - !(list->client->ps.pm_flags & PMF_LIMBO) && - (list->client->ps.pm_type == PM_NORMAL) - ) { - if( forward ) { - G_AdjustSingleClientPosition( list, time ); - } else { - G_ReAdjustSingleClientPosition( list ); - } + // unlagged doesn't adjust the firing client + if (list == ent) continue; + if(forward) { + G_AdjustSingleClientPosition( list, time, NULL); + } else { + G_ReAdjustSingleClientPosition( list ); } + } } void G_ResetMarkers( gentity_t* ent ) { int i, time; - char buffer[ MAX_CVAR_VALUE_STRING ]; float period; + int eFlags; - trap_Cvar_VariableStringBuffer( "sv_fps", buffer, sizeof( buffer ) - 1 ); - - period = atoi( buffer ); + period = sv_fps.value; if( !period ) { period = 50; } else { period = 1000.f / period; } + eFlags = ent->client->ps.eFlags; + // tjw: don't save entity flags that are not allowed + // for clientMarkers + if((eFlags & EF_MOUNTEDTANK)) + eFlags &= ~EF_MOUNTEDTANK; ent->client->topMarker = MAX_CLIENT_MARKERS - 1; for( i = MAX_CLIENT_MARKERS - 1, time = level.time; i >= 0; i--, time -= period ) { @@ -136,6 +311,11 @@ VectorCopy( ent->r.maxs, ent->client->clientMarkers[i].maxs ); VectorCopy( ent->r.currentOrigin, ent->client->clientMarkers[i].origin ); ent->client->clientMarkers[i].time = time; + VectorCopy(ent->client->ps.viewangles, + ent->client->clientMarkers[i].viewangles); + ent->client->clientMarkers[i].eFlags = eFlags; + ent->client->clientMarkers[i].pm_flags = ent->client->ps.pm_flags; + ent->client->clientMarkers[i].viewheight = ent->client->ps.viewheight; } } @@ -150,9 +330,9 @@ (list->client->sess.sessionTeam == TEAM_AXIS || list->client->sess.sessionTeam == TEAM_ALLIES) && (list != ent) && list->r.linked && - (list->health > 0) && !(list->client->ps.pm_flags & PMF_LIMBO) && - (list->client->ps.pm_type == PM_NORMAL) + (list->client->ps.pm_type == PM_NORMAL || + list->client->ps.pm_type == PM_DEAD) ) { list->client->tempHead = G_BuildHead( list ); list->client->tempLeg = G_BuildLeg( list ); @@ -250,3 +430,131 @@ G_DettachBodyParts(); } + + +qboolean G_SkipCorrectionSafe(gentity_t *ent) +{ + if(!ent) + return qfalse; + + if(!ent->inuse) + return qfalse; + + if(!ent->r.linked) + return qfalse; + + if(!ent->client) + return qfalse; + + if(ent->client->sess.sessionTeam != TEAM_AXIS + && ent->client->sess.sessionTeam != TEAM_ALLIES) + return qfalse; + + if((ent->client->ps.pm_flags & PMF_LIMBO) || + (ent->client->ps.pm_flags & PMF_TIME_LOCKPLAYER)) + return qfalse; + + if(ent->health <= 0) + return qfalse; + + if(ent->client->ps.pm_type != PM_NORMAL) + return qfalse; + + // tjw: this causes segfault with new PM_TraceLegs() from + // 2.60 because it wants to update pm.pmext which + // we don't bother passing. + if((ent->client->ps.eFlags & EF_PRONE)) + return qfalse; + + if((ent->client->ps.eFlags & EF_MOUNTEDTANK)) + return qfalse; + + // tjw: perhaps 2 would be OK too? + if(ent->waterlevel > 1) + return qfalse; + + // tjw: don't bother with skip correction if the player + // isn't moving horizontally + if(!ent->client->ps.velocity[0] && !ent->client->ps.velocity[1]) + return qfalse; + + return qtrue; +} + + + +// G_PredictPmove +// +// Make use of the 'Pmove' functions to figure out where a player +// would have moved in the short amount of time indicated by frametime. +// +// After the Pmove is complete, copy the values to the player's entity +// state, but then copy the original player state values back to the +// player state so that the player's movements aren't effected in any way. +// +// The only Pmove functions used are PM_StepSlideMove() and +// PM_GroundTrace() since these are all that is needed for this +// short period of time. This means that a lot of movement types +// cannot be predicted and no prediction should be done for them +// See G_SkipCorrectionSafe() + +void G_PredictPmove(gentity_t *ent, float frametime) +{ + pmove_t pm; + vec3_t origin; + vec3_t velocity; + int groundEntityNum; + int pm_flags; + int pm_time; + int eFlags; + gclient_t *client; + + if(!G_SkipCorrectionSafe(ent)) + return; + + client = ent->client; + + // tjw: backup all the playerState values that may + // be altered by PmovePredict() + VectorCopy(client->ps.origin, origin); + VectorCopy(client->ps.velocity, velocity); + groundEntityNum = client->ps.groundEntityNum; + pm_flags = client->ps.pm_flags; + pm_time = client->ps.pm_time; + eFlags = client->ps.eFlags; + + memset(&pm, 0, sizeof(pm)); + pm.ps = &client->ps; + pm.character = client->pers.character; + pm.trace = trap_TraceCapsuleNoEnts; + pm.pointcontents = trap_PointContents; + pm.tracemask = MASK_PLAYERSOLID; + VectorCopy(ent->r.mins, pm.mins); + VectorCopy(ent->r.maxs, pm.maxs); + pm.predict = qtrue; + //pm.debugLevel = 1; + + PmovePredict(&pm, frametime); + + //G_Printf("origin: before %s after %s\n", + // vtos(ent->s.pos.trBase), + // vtos(client->ps.origin)); + + // tjw: update entity state with the resulting player state + VectorCopy(client->ps.origin, ent->s.pos.trBase); + VectorCopy(client->ps.velocity, ent->s.pos.trDelta); + ent->s.groundEntityNum = client->ps.groundEntityNum; + ent->s.eFlags = client->ps.eFlags; + + // tjw: this needs to be updated in case g_antilag is not enabled + VectorCopy(client->ps.origin, ent->r.currentOrigin); + + // tjw: restore player state so that their next command + // will process as if nothing has happened. + VectorCopy(origin, client->ps.origin); + VectorCopy(velocity, client->ps.velocity); + client->ps.groundEntityNum = groundEntityNum; + client->ps.pm_flags = pm_flags; + client->ps.pm_time = pm_time; + client->ps.eFlags = eFlags; +} diff -urN --exclude=.svn et260/src/game/g_client.c etpub/src/game/g_client.c --- et260/src/game/g_client.c 2005-04-12 12:11:50.000000000 -0500 +++ etpub/src/game/g_client.c 2005-04-25 22:21:37.000000000 -0500 @@ -297,11 +297,13 @@ */ void BodySink2( gentity_t *ent ) { ent->physicsObject = qfalse; - ent->nextthink = level.time + BODY_TIME(BODY_TEAM(ent))+1500; - ent->think = BodyUnlink; - ent->s.pos.trType = TR_LINEAR; - ent->s.pos.trTime = level.time; - VectorCopy( ent->r.currentOrigin, ent->s.pos.trBase ); + // tjw: BODY_TIME is how long they last all together, not just sink anim + //ent->nextthink = level.time + BODY_TIME(BODY_TEAM(ent))+1500; + ent->nextthink = level.time + 4000; + ent->think = BodyUnlink; + ent->s.pos.trType = TR_LINEAR; + ent->s.pos.trTime = level.time; + VectorCopy( ent->r.currentOrigin, ent->s.pos.trBase ); VectorSet( ent->s.pos.trDelta, 0, 0, -8 ); } @@ -418,10 +420,11 @@ body->r.contents = CONTENTS_CORPSE; body->r.ownerNum = ent->r.ownerNum; - BODY_TEAM(body) = ent->client->sess.sessionTeam; - BODY_CLASS(body) = ent->client->sess.playerType; - BODY_CHARACTER(body) = ent->client->pers.characterIndex; - BODY_VALUE(body) = 0; + BODY_TEAM(body) = ent->client->sess.sessionTeam; + BODY_CLASS(body) = ent->client->sess.playerType; + BODY_CHARACTER(body) = ent->client->pers.characterIndex; + BODY_VALUE(body) = 0; + BODY_WEAPON(body) = ent->client->sess.playerWeapon; body->s.time2 = 0; @@ -478,6 +481,99 @@ VectorCopy( ent->s.angles, ent->client->ps.viewangles); } + +void G_DropLimboHealth(gentity_t *ent) +{ + vec3_t launchvel, launchspot; + int packs = 0; + int i; + int cwt; + + if(g_dropHealth.integer == 0) return; + if(!ent->client) return; + if(ent->client->sess.playerType != PC_MEDIC) + return; + + packs = g_dropHealth.integer; + if(g_dropHealth.integer == -1) { + packs = 5; // max packs + cwt = ent->client->ps.classWeaponTime; + ent->client->ps.classWeaponTime += + (level.time + - ent->client->deathTime + + 10000); + } + for(i=0; iclient->ps.classWeaponTime >= level.time) { + + break; + } + launchvel[0] = crandom(); + launchvel[1] = crandom(); + launchvel[2] = 0; + VectorScale(launchvel, 100, launchvel); + launchvel[2] = (100 + (g_tossDistance.integer * 10)); + VectorCopy(ent->r.currentOrigin, launchspot); + + Weapon_Medic_Ext(ent, + launchspot, + launchspot, + launchvel); + } + ent->client->ps.classWeaponTime = cwt; +} + +void G_DropLimboAmmo(gentity_t *ent) +{ + vec3_t launchvel, launchspot; + int packs = 0; + int i; + int cwt; + + if(g_dropAmmo.integer == 0) return; + if(!ent->client) return; + if(ent->client->sess.playerType != PC_FIELDOPS) + return; + + packs = g_dropAmmo.integer; + if(g_dropAmmo.integer == -1) { + packs = 5; // max packs + cwt = ent->client->ps.classWeaponTime; + // adjust the charge timer so that the + // fops only drops as much ammo as he + // could have before he died. + // don't ask me where the 10000 comes + // from, it just makes this more + // accurate. + ent->client->ps.classWeaponTime += + (level.time + - ent->client->deathTime + + 10000); + } + for(i=0; iclient->ps.classWeaponTime >= level.time) { + + break; + } + launchvel[0] = crandom(); + launchvel[1] = crandom(); + launchvel[2] = 0; + + VectorScale(launchvel, 100, launchvel); + launchvel[2] = (100 + (g_tossDistance.integer * 10)); + VectorCopy(ent->r.currentOrigin, launchspot); + + Weapon_MagicAmmo_Ext(ent, + launchspot, + launchspot, + launchvel); + } + ent->client->ps.classWeaponTime = cwt; +} + + /* JPW NERVE ================ limbo @@ -513,6 +609,8 @@ if( makeCorpse ) { + G_DropLimboHealth(ent); + G_DropLimboAmmo(ent); CopyToBodyQue (ent); // make a nice looking corpse } else { trap_UnlinkEntity (ent); @@ -552,10 +650,29 @@ for(i=0; ips.pm_flags & PMF_LIMBO) || - (cl->sess.sessionTeam == TEAM_SPECTATOR && cl->sess.spectatorState == SPECTATOR_FOLLOW)) && - cl->sess.spectatorClient == ent - g_entities) {//ent->s.number ) { - Cmd_FollowCycle_f( &g_entities[level.sortedClients[i]], 1 ); + + if(cl->sess.spectatorClient != (ent - g_entities) || + cl->sess.spectatorState != SPECTATOR_FOLLOW || + (g_spectator.integer & SPECF_PERSIST_FOLLOW)) { + + continue; + } + + if((cl->ps.pm_flags & PMF_LIMBO)) { + + Cmd_FollowCycle_f( + &g_entities[level.sortedClients[i]], 1); + } + else if(cl->sess.sessionTeam == TEAM_SPECTATOR) { + + if((g_spectator.integer & SPECF_FL_ON_LIMBO)) { + cl->sess.spectatorState = SPECTATOR_FREE; + ClientBegin(cl - level.clients); + } + else { + Cmd_FollowCycle_f( + &g_entities[level.sortedClients[i]], 1); + } } } } @@ -648,7 +765,7 @@ G_DPrintf( "Respawning %s, %i lives left\n", ent->client->pers.netname, ent->client->ps.persistant[PERS_RESPAWNS_LEFT]); - ClientSpawn(ent, qfalse); + ClientSpawn(ent, qfalse, qfalse, qtrue); // DHM - Nerve :: Add back if we decide to have a spawn effect // add a teleportation effect @@ -788,6 +905,441 @@ void BotSetPOW(int entityNum, qboolean isPOW); + + +/* + G_AddClassSpecificTools //tjw + This stuff was stripped out of SetWolfSpawnWeapons() so it can + be used for class stealing. It needed cleaning up badly anyway. + It still does. + */ +void G_AddClassSpecificTools(gclient_t *client) +{ + int pc = client->sess.playerType; + qboolean add_binocs = qfalse; + + if(client->sess.skill[SK_BATTLE_SENSE] >= 1) + add_binocs = qtrue; + + switch(client->sess.playerType) { + case PC_ENGINEER: + AddWeaponToPlayer( client, WP_DYNAMITE, 0, 1, qfalse ); + AddWeaponToPlayer( client, WP_PLIERS, 0, 1, qfalse ); + AddWeaponToPlayer( client, + WP_LANDMINE, + GetAmmoTableData(WP_LANDMINE)->defaultStartingAmmo, + GetAmmoTableData(WP_LANDMINE)->defaultStartingClip, + qfalse ); + break; + case PC_COVERTOPS: + add_binocs = qtrue; + AddWeaponToPlayer(client, + WP_SMOKE_BOMB, + GetAmmoTableData(WP_SMOKE_BOMB)->defaultStartingAmmo, + GetAmmoTableData(WP_SMOKE_BOMB)->defaultStartingClip, + qfalse); + // See if we already have a satchel charge placed + // this needs to be here for class stealing + if( G_FindSatchel( &g_entities[client->ps.clientNum] ) ) { + AddWeaponToPlayer( client, WP_SATCHEL, 0, 0, qfalse ); + AddWeaponToPlayer( client, WP_SATCHEL_DET, 0, 1, qfalse ); + } else { + AddWeaponToPlayer( client, WP_SATCHEL, 0, 1, qfalse ); + AddWeaponToPlayer( client, WP_SATCHEL_DET, 0, 0, qfalse ); + } + break; + case PC_FIELDOPS: + add_binocs = qtrue; + AddWeaponToPlayer(client, WP_AMMO, 0, 1, qfalse); + AddWeaponToPlayer( client, + WP_SMOKE_MARKER, + GetAmmoTableData(WP_SMOKE_MARKER)->defaultStartingAmmo, + GetAmmoTableData(WP_SMOKE_MARKER)->defaultStartingClip, + qfalse); + break; + case PC_MEDIC: + AddWeaponToPlayer(client, + WP_MEDIC_SYRINGE, + GetAmmoTableData(WP_MEDIC_SYRINGE)->defaultStartingAmmo, + GetAmmoTableData(WP_MEDIC_SYRINGE)->defaultStartingClip, + qfalse); + if( client->sess.skill[SK_FIRST_AID] >= 4 ) + AddWeaponToPlayer(client, + WP_MEDIC_ADRENALINE, + GetAmmoTableData(WP_MEDIC_ADRENALINE)->defaultStartingAmmo, + GetAmmoTableData(WP_MEDIC_ADRENALINE)->defaultStartingClip, + qfalse); + + AddWeaponToPlayer(client, + WP_MEDKIT, + GetAmmoTableData(WP_MEDKIT)->defaultStartingAmmo, + GetAmmoTableData(WP_MEDKIT)->defaultStartingClip, + qfalse); + break; + case PC_SOLDIER: + break; + } + if(add_binocs) { + if(AddWeaponToPlayer(client, WP_BINOCULARS, 1, 0, qfalse)) { + client->ps.stats[STAT_KEYS] |= ( 1 << INV_BINOCS ); + } + } + //// Josh: adren in different classes when level 4 + if( (client->sess.playerType != PC_MEDIC + && (g_skills.integer & SKILLS_ADREN)) + && client->sess.skill[SK_FIRST_AID] >= 4 ) + AddWeaponToPlayer(client, + WP_MEDIC_ADRENALINE, + GetAmmoTableData(WP_MEDIC_ADRENALINE)->defaultStartingAmmo, + GetAmmoTableData(WP_MEDIC_ADRENALINE)->defaultStartingClip, + qfalse); + +} + +qboolean _SetSoldierSpawnWeapons(gclient_t *client) +{ + weapon_t w; + weapon_t w2, w3 = 0; + weapon_t ws = 0; + + w = client->sess.latchPlayerWeapon; + if(client->sess.sessionTeam == TEAM_AXIS) { + switch(w) { + case WP_MP40: + case WP_PANZERFAUST: + case WP_MORTAR: + case WP_FLAMETHROWER: + case WP_MOBILE_MG42: + break; + default: + w = WP_MP40; + } + AddWeaponToPlayer(client, WP_GRENADE_LAUNCHER, 0, 4, qfalse); + w2 = WP_LUGER; + if(client->sess.skill[SK_LIGHT_WEAPONS] >= 4) { + w2 = WP_AKIMBO_LUGER; + } + if( client->sess.skill[SK_HEAVY_WEAPONS] >= 4) { + w3 = WP_MP40; + if(!(g_weapons.integer & WPF_L4HW_KEEPS_PISTOL)) + w2 = 0; + } + } + else if(client->sess.sessionTeam == TEAM_ALLIES) { + switch(w) { + case WP_THOMPSON: + case WP_PANZERFAUST: + case WP_MORTAR: + case WP_FLAMETHROWER: + case WP_MOBILE_MG42: + break; + default: + w = WP_THOMPSON; + } + AddWeaponToPlayer(client, WP_GRENADE_PINEAPPLE, 0, 4, qfalse); + w2 = WP_COLT; + if(client->sess.skill[SK_LIGHT_WEAPONS] >= 4) { + w2 = WP_AKIMBO_COLT; + } + if( client->sess.skill[SK_HEAVY_WEAPONS] >= 4) { + w3 = WP_THOMPSON; + if(!(g_weapons.integer & WPF_L4HW_KEEPS_PISTOL)) + w2 = 0; + } + } + else { + return qfalse; + } + + AddWeaponToPlayer(client, + w, + GetAmmoTableData(w)->defaultStartingAmmo, + GetAmmoTableData(w)->defaultStartingClip, + qtrue); + + if(w == WP_MOBILE_MG42) { + ws = WP_MOBILE_MG42_SET; + } + else if(w == WP_MORTAR) { + ws = WP_MORTAR_SET; + } + + if(ws) { + AddWeaponToPlayer(client, + ws, + GetAmmoTableData(ws)->defaultStartingAmmo, + GetAmmoTableData(ws)->defaultStartingClip, + qfalse); + } + if(w2 == WP_AKIMBO_LUGER || w2 == WP_AKIMBO_COLT) { + client->ps.ammoclip[ + BG_FindClipForWeapon(BG_AkimboSidearm(w2))] = + GetAmmoTableData(w2)->defaultStartingClip; + } + AddWeaponToPlayer(client, + w2, + GetAmmoTableData(w2)->defaultStartingAmmo, + GetAmmoTableData(w2)->defaultStartingClip, + qfalse); + if(w3) { + AddWeaponToPlayer(client, + w3, + 2*GetAmmoTableData(w3)->defaultStartingAmmo, + GetAmmoTableData(w3)->defaultStartingClip, + qfalse); + } + return qtrue; +} + +qboolean _SetMedicSpawnWeapons(gclient_t *client) +{ + weapon_t w; + weapon_t w2; + + if(client->sess.sessionTeam == TEAM_AXIS) { + w = WP_MP40; + AddWeaponToPlayer(client, WP_GRENADE_LAUNCHER, 0, 1, qfalse); + w2 = WP_LUGER; + if(client->sess.skill[SK_LIGHT_WEAPONS] >= 4) { + w2 = WP_AKIMBO_LUGER; + } + } + else if(client->sess.sessionTeam == TEAM_ALLIES) { + w = WP_THOMPSON; + AddWeaponToPlayer(client, WP_GRENADE_PINEAPPLE, 0, 1, qfalse); + w2 = WP_COLT; + if(client->sess.skill[SK_LIGHT_WEAPONS] >= 4) { + w2 = WP_AKIMBO_COLT; + } + } + else { + return qfalse; + } + + AddWeaponToPlayer(client, + w, + 0, + GetAmmoTableData(w)->defaultStartingClip, + qtrue); + + if(w2 == WP_AKIMBO_LUGER || w2 == WP_AKIMBO_COLT) { + client->ps.ammoclip[ + BG_FindClipForWeapon(BG_AkimboSidearm(w2))] = + GetAmmoTableData(w2)->defaultStartingClip; + } + AddWeaponToPlayer(client, + w2, + GetAmmoTableData(w2)->defaultStartingAmmo, + GetAmmoTableData(w2)->defaultStartingClip, + qfalse); + return qtrue; +} + +qboolean _SetEngineerSpawnWeapons(gclient_t *client) +{ + weapon_t w; + weapon_t w2; + + w = client->sess.latchPlayerWeapon; + if(client->sess.sessionTeam == TEAM_AXIS) { + switch(w) { + case WP_KAR98: + case WP_MP40: + break; + default: + w = WP_MP40; + } + AddWeaponToPlayer(client, WP_GRENADE_LAUNCHER, 0, 4, qfalse); + w2 = WP_LUGER; + if(client->sess.skill[SK_LIGHT_WEAPONS] >= 4) { + w2 = WP_AKIMBO_LUGER; + } + } + else if(client->sess.sessionTeam == TEAM_ALLIES) { + switch(w) { + case WP_CARBINE: + case WP_THOMPSON: + break; + default: + w = WP_THOMPSON; + } + AddWeaponToPlayer(client, WP_GRENADE_PINEAPPLE, 0, 4, qfalse); + w2 = WP_COLT; + if(client->sess.skill[SK_LIGHT_WEAPONS] >= 4) { + w2 = WP_AKIMBO_COLT; + } + } + else { + return qfalse; + } + + AddWeaponToPlayer(client, + w, + GetAmmoTableData(w)->defaultStartingAmmo, + GetAmmoTableData(w)->defaultStartingClip, + qtrue); + + if(w == WP_KAR98) { + AddWeaponToPlayer(client, + WP_GPG40, + GetAmmoTableData(WP_GPG40)->defaultStartingAmmo, + GetAmmoTableData(WP_GPG40)->defaultStartingClip, + qfalse); + } + else if(w == WP_CARBINE) { + AddWeaponToPlayer(client, + WP_M7, + GetAmmoTableData(WP_M7)->defaultStartingAmmo, + GetAmmoTableData(WP_M7)->defaultStartingClip, + qfalse); + } + if(w2 == WP_AKIMBO_LUGER || w2 == WP_AKIMBO_COLT) { + client->ps.ammoclip[ + BG_FindClipForWeapon(BG_AkimboSidearm(w2))] = + GetAmmoTableData(w2)->defaultStartingClip; + } + AddWeaponToPlayer(client, + w2, + GetAmmoTableData(w2)->defaultStartingAmmo, + GetAmmoTableData(w2)->defaultStartingClip, + qfalse); + return qtrue; +} + +qboolean _SetFieldOpSpawnWeapons(gclient_t *client) +{ + weapon_t w; + weapon_t w2; + + if(client->sess.sessionTeam == TEAM_AXIS) { + w = WP_MP40; + AddWeaponToPlayer(client, WP_GRENADE_LAUNCHER, 0, 1, qfalse); + w2 = WP_LUGER; + if(client->sess.skill[SK_LIGHT_WEAPONS] >= 4) { + w2 = WP_AKIMBO_LUGER; + } + } + else if(client->sess.sessionTeam == TEAM_ALLIES) { + w = WP_THOMPSON; + AddWeaponToPlayer(client, WP_GRENADE_PINEAPPLE, 0, 1, qfalse); + w2 = WP_COLT; + if(client->sess.skill[SK_LIGHT_WEAPONS] >= 4) { + w2 = WP_AKIMBO_COLT; + } + } + else { + return qfalse; + } + + AddWeaponToPlayer(client, + w, + GetAmmoTableData(w)->defaultStartingAmmo, + GetAmmoTableData(w)->defaultStartingClip, + qtrue); + + if(w2 == WP_AKIMBO_LUGER || w2 == WP_AKIMBO_COLT) { + client->ps.ammoclip[ + BG_FindClipForWeapon(BG_AkimboSidearm(w2))] = + GetAmmoTableData(w2)->defaultStartingClip; + } + AddWeaponToPlayer(client, + w2, + GetAmmoTableData(w2)->defaultStartingAmmo, + GetAmmoTableData(w2)->defaultStartingClip, + qfalse); + return qtrue; + +} + +qboolean _SetCovertSpawnWeapons(gclient_t *client) +{ + weapon_t w; + weapon_t w2, w3; + weapon_t ws = 0; + + w = client->sess.latchPlayerWeapon; + if(client->sess.sessionTeam== TEAM_AXIS) { + switch(w) { + case WP_K43: + case WP_FG42: + case WP_STEN: + break; + default: + w = WP_STEN; + } + AddWeaponToPlayer(client, WP_GRENADE_LAUNCHER, 0, 2, qfalse); + w2 = WP_SILENCER; + w3 = WP_LUGER; + if(client->sess.skill[SK_LIGHT_WEAPONS] >= 4) { + w2 = WP_AKIMBO_SILENCEDLUGER; + w3 = 0; + } + } + else if(client->sess.sessionTeam == TEAM_ALLIES) { + switch(w) { + case WP_GARAND: + case WP_FG42: + case WP_STEN: + break; + default: + w = WP_STEN; + } + AddWeaponToPlayer(client, WP_GRENADE_PINEAPPLE, 0, 2, qfalse); + w2 = WP_SILENCED_COLT; + w3 = WP_COLT; + if(client->sess.skill[SK_LIGHT_WEAPONS] >= 4) { + w2 = WP_AKIMBO_SILENCEDCOLT; + w3 = 0; + } + } + else { + return qfalse; + } + + AddWeaponToPlayer(client, + w, + GetAmmoTableData(w)->defaultStartingAmmo, + GetAmmoTableData(w)->defaultStartingClip, + qtrue); + + if(w == WP_K43) { + ws = WP_K43_SCOPE; + } + else if(w == WP_GARAND) { + ws = WP_GARAND_SCOPE; + } + else if(w == WP_FG42) { + ws = WP_FG42SCOPE; + } + + if(ws) { + AddWeaponToPlayer(client, + ws, + GetAmmoTableData(ws)->defaultStartingAmmo, + GetAmmoTableData(ws)->defaultStartingClip, + qfalse); + } + if(w2 == WP_AKIMBO_SILENCEDLUGER || w2 == WP_AKIMBO_SILENCEDCOLT) { + client->ps.ammoclip[ + BG_FindClipForWeapon(BG_AkimboSidearm(w2))] = + GetAmmoTableData(w2)->defaultStartingClip; + } + AddWeaponToPlayer(client, + w2, + GetAmmoTableData(w2)->defaultStartingAmmo, + GetAmmoTableData(w2)->defaultStartingClip, + qfalse); + if(w3) { + AddWeaponToPlayer(client, + w3, + GetAmmoTableData(w3)->defaultStartingAmmo, + GetAmmoTableData(w3)->defaultStartingClip, + qfalse); + } + client->pmext.silencedSideArm = 1; + return qtrue; +} + /* =========== SetWolfSpawnWeapons @@ -795,11 +1347,18 @@ */ void SetWolfSpawnWeapons( gclient_t *client ) { - int pc = client->sess.playerType; - qboolean isBot = (g_entities[client->ps.clientNum].r.svFlags & SVF_BOT) ? qtrue : qfalse; - qboolean isPOW = (g_entities[client->ps.clientNum].r.svFlags & SVF_POW) ? qtrue : qfalse; + int pc; + qboolean isBot = qfalse; + qboolean isPOW = qfalse; + + pc = client->sess.playerType; + + if(g_entities[client->ps.clientNum].r.svFlags & SVF_BOT) + isBot = qtrue; + if(g_entities[client->ps.clientNum].r.svFlags & SVF_POW) + isPOW = qtrue; - if ( client->sess.sessionTeam == TEAM_SPECTATOR ) + if ( client->sess.sessionTeam == TEAM_SPECTATOR ) return; // Reset special weapon time @@ -808,13 +1367,15 @@ // Communicate it to cgame client->ps.stats[STAT_PLAYER_CLASS] = pc; - // Abuse teamNum to store player class as well (can't see stats for all clients in cgame) + // Abuse teamNum to store player class as well (can't see stats + // for all clients in cgame) client->ps.teamNum = pc; // JPW NERVE -- zero out all ammo counts memset(client->ps.ammo, 0, MAX_WEAPONS * sizeof(int)); - // All players start with a knife (not OR-ing so that it clears previous weapons) + // All players start with a knife (not OR-ing so that it clears + // previous weapons) client->ps.weapons[0] = 0; client->ps.weapons[1] = 0; @@ -832,281 +1393,43 @@ client->ps.weaponstate = WEAPON_READY; - // Engineer gets dynamite - if ( pc == PC_ENGINEER ) { - AddWeaponToPlayer( client, WP_DYNAMITE, 0, 1, qfalse ); - AddWeaponToPlayer( client, WP_PLIERS, 0, 1, qfalse ); - - if( g_knifeonly.integer != 1 ) { - if( client->sess.skill[SK_BATTLE_SENSE] >= 1 ) { - if( AddWeaponToPlayer( client, WP_BINOCULARS, 1, 0, qfalse ) ) { - client->ps.stats[STAT_KEYS] |= ( 1 << INV_BINOCS ); - } - } - - if (client->sess.sessionTeam == TEAM_AXIS) { - switch( client->sess.playerWeapon ) { - case WP_KAR98: - if( AddWeaponToPlayer( client, WP_KAR98, GetAmmoTableData(WP_KAR98)->defaultStartingAmmo, GetAmmoTableData(WP_KAR98)->defaultStartingClip, qtrue ) ) { - AddWeaponToPlayer( client, WP_GPG40, GetAmmoTableData(WP_GPG40)->defaultStartingAmmo, GetAmmoTableData(WP_GPG40)->defaultStartingClip, qfalse ); - } - break; - default: - AddWeaponToPlayer( client, WP_MP40, GetAmmoTableData(WP_MP40)->defaultStartingAmmo, GetAmmoTableData(WP_MP40)->defaultStartingClip, qtrue ); - break; - } - AddWeaponToPlayer( client, WP_LANDMINE, GetAmmoTableData(WP_LANDMINE)->defaultStartingAmmo, GetAmmoTableData(WP_LANDMINE)->defaultStartingClip, qfalse ); - AddWeaponToPlayer( client, WP_GRENADE_LAUNCHER, 0, 4, qfalse ); - - } else { - switch( client->sess.playerWeapon ) { - case WP_CARBINE: - if( AddWeaponToPlayer( client, WP_CARBINE, GetAmmoTableData(WP_CARBINE)->defaultStartingAmmo, GetAmmoTableData(WP_CARBINE)->defaultStartingClip, qtrue ) ) { - AddWeaponToPlayer( client, WP_M7, GetAmmoTableData(WP_M7)->defaultStartingAmmo, GetAmmoTableData(WP_M7)->defaultStartingClip, qfalse ); - } - break; - default: - AddWeaponToPlayer( client, WP_THOMPSON, GetAmmoTableData(WP_THOMPSON)->defaultStartingAmmo, GetAmmoTableData(WP_THOMPSON)->defaultStartingClip, qtrue ); - break; - } - AddWeaponToPlayer( client, WP_LANDMINE, GetAmmoTableData(WP_LANDMINE)->defaultStartingAmmo, GetAmmoTableData(WP_LANDMINE)->defaultStartingClip, qfalse ); - AddWeaponToPlayer( client, WP_GRENADE_PINEAPPLE, 0, 4, qfalse ); + if(g_knifeonly.integer) { + switch(pc) { + case PC_MEDIC: + AddWeaponToPlayer(client, + WP_MEDIC_SYRINGE, 0, 20, qfalse); + if(client->sess.skill[SK_FIRST_AID] >= 4) { + AddWeaponToPlayer(client, + WP_MEDIC_ADRENALINE, 0, 10, qfalse); } + break; + case PC_ENGINEER: + AddWeaponToPlayer(client, WP_DYNAMITE, 0, 1, qfalse); + AddWeaponToPlayer(client, WP_PLIERS, 0, 1, qfalse); + break; } + return; } - if ( g_knifeonly.integer != 1 ) { - // Field ops gets binoculars, ammo pack, artillery, and a grenade - if ( pc == PC_FIELDOPS ) { - AddWeaponToPlayer( client, WP_AMMO, 0, 1, qfalse ); - - if( AddWeaponToPlayer( client, WP_BINOCULARS, 1, 0, qfalse ) ) { - client->ps.stats[STAT_KEYS] |= ( 1 << INV_BINOCS ); - } - - AddWeaponToPlayer( client, WP_SMOKE_MARKER, GetAmmoTableData(WP_SMOKE_MARKER)->defaultStartingAmmo, GetAmmoTableData(WP_SMOKE_MARKER)->defaultStartingClip, qfalse ); - - if( client->sess.sessionTeam == TEAM_AXIS ) { - AddWeaponToPlayer( client, WP_MP40, GetAmmoTableData(WP_MP40)->defaultStartingAmmo, GetAmmoTableData(WP_MP40)->defaultStartingClip, qtrue ); - AddWeaponToPlayer( client, WP_GRENADE_LAUNCHER, 0, 1, qfalse ); - } else { - AddWeaponToPlayer( client, WP_THOMPSON, GetAmmoTableData(WP_THOMPSON)->defaultStartingAmmo, GetAmmoTableData(WP_THOMPSON)->defaultStartingClip, qtrue ); - AddWeaponToPlayer( client, WP_GRENADE_PINEAPPLE, 0, 1, qfalse ); - } - } else if( pc == PC_MEDIC ) { - if( client->sess.skill[SK_BATTLE_SENSE] >= 1 ) { - if( AddWeaponToPlayer( client, WP_BINOCULARS, 1, 0, qfalse ) ) { - client->ps.stats[STAT_KEYS] |= ( 1 << INV_BINOCS ); - } - } - - AddWeaponToPlayer( client, WP_MEDIC_SYRINGE, GetAmmoTableData(WP_MEDIC_SYRINGE)->defaultStartingAmmo, GetAmmoTableData(WP_MEDIC_SYRINGE)->defaultStartingClip, qfalse ); - if( client->sess.skill[SK_FIRST_AID] >= 4 ) - AddWeaponToPlayer( client, WP_MEDIC_ADRENALINE, GetAmmoTableData(WP_MEDIC_ADRENALINE)->defaultStartingAmmo, GetAmmoTableData(WP_MEDIC_ADRENALINE)->defaultStartingClip, qfalse ); - - AddWeaponToPlayer( client, WP_MEDKIT, GetAmmoTableData(WP_MEDKIT)->defaultStartingAmmo, GetAmmoTableData(WP_MEDKIT)->defaultStartingClip, qfalse ); - - if (client->sess.sessionTeam == TEAM_AXIS) { - AddWeaponToPlayer( client, WP_MP40, 0, GetAmmoTableData(WP_MP40)->defaultStartingClip, qtrue ); - AddWeaponToPlayer( client, WP_GRENADE_LAUNCHER, 0, 1, qfalse ); - } else { - AddWeaponToPlayer( client, WP_THOMPSON, 0, GetAmmoTableData(WP_THOMPSON)->defaultStartingClip, qtrue ); - AddWeaponToPlayer( client, WP_GRENADE_PINEAPPLE, 0, 1, qfalse ); - } - } else if ( pc == PC_SOLDIER ) { - if( client->sess.skill[SK_BATTLE_SENSE] >= 1 ) { - if( AddWeaponToPlayer( client, WP_BINOCULARS, 1, 0, qfalse ) ) { - client->ps.stats[STAT_KEYS] |= ( 1 << INV_BINOCS ); - } - } - - switch( client->sess.sessionTeam ) { - case TEAM_AXIS: - switch( client->sess.playerWeapon ) { - default: - case WP_MP40: - AddWeaponToPlayer( client, WP_MP40, 2*(GetAmmoTableData(WP_MP40)->defaultStartingAmmo), GetAmmoTableData(WP_MP40)->defaultStartingClip, qtrue ); - break; - case WP_PANZERFAUST: - AddWeaponToPlayer( client, WP_PANZERFAUST, GetAmmoTableData(WP_PANZERFAUST)->defaultStartingAmmo, GetAmmoTableData(WP_PANZERFAUST)->defaultStartingClip, qtrue ); - break; - case WP_FLAMETHROWER: - AddWeaponToPlayer( client, WP_FLAMETHROWER, GetAmmoTableData(WP_FLAMETHROWER)->defaultStartingAmmo, GetAmmoTableData(WP_FLAMETHROWER)->defaultStartingClip, qtrue ); - break; - case WP_MOBILE_MG42: - if( AddWeaponToPlayer( client, WP_MOBILE_MG42, GetAmmoTableData(WP_MOBILE_MG42)->defaultStartingAmmo, GetAmmoTableData(WP_MOBILE_MG42)->defaultStartingClip, qtrue ) ) { - AddWeaponToPlayer( client, WP_MOBILE_MG42_SET, GetAmmoTableData(WP_MOBILE_MG42_SET)->defaultStartingAmmo, GetAmmoTableData(WP_MOBILE_MG42_SET)->defaultStartingClip, qfalse ); - } - break; - case WP_MORTAR: - if( AddWeaponToPlayer( client, WP_MORTAR, GetAmmoTableData(WP_MORTAR)->defaultStartingAmmo, GetAmmoTableData(WP_MORTAR)->defaultStartingClip, qtrue ) ) { - AddWeaponToPlayer( client, WP_MORTAR_SET, GetAmmoTableData(WP_MORTAR_SET)->defaultStartingAmmo, GetAmmoTableData(WP_MORTAR_SET)->defaultStartingClip, qfalse ); - } - break; - } - break; - case TEAM_ALLIES: - switch( client->sess.playerWeapon ) { - default: - case WP_THOMPSON: - AddWeaponToPlayer( client, WP_THOMPSON, 2*(GetAmmoTableData(WP_THOMPSON)->defaultStartingAmmo), GetAmmoTableData(WP_THOMPSON)->defaultStartingClip, qtrue ); - break; - case WP_PANZERFAUST: - AddWeaponToPlayer( client, WP_PANZERFAUST, GetAmmoTableData(WP_PANZERFAUST)->defaultStartingAmmo, GetAmmoTableData(WP_PANZERFAUST)->defaultStartingClip, qtrue ); - break; - case WP_FLAMETHROWER: - AddWeaponToPlayer( client, WP_FLAMETHROWER, GetAmmoTableData(WP_FLAMETHROWER)->defaultStartingAmmo, GetAmmoTableData(WP_FLAMETHROWER)->defaultStartingClip, qtrue ); - break; - case WP_MOBILE_MG42: - if( AddWeaponToPlayer( client, WP_MOBILE_MG42, GetAmmoTableData(WP_MOBILE_MG42)->defaultStartingAmmo, GetAmmoTableData(WP_MOBILE_MG42)->defaultStartingClip, qtrue ) ) { - AddWeaponToPlayer( client, WP_MOBILE_MG42_SET, GetAmmoTableData(WP_MOBILE_MG42_SET)->defaultStartingAmmo, GetAmmoTableData(WP_MOBILE_MG42_SET)->defaultStartingClip, qfalse ); - } - break; - case WP_MORTAR: - if( AddWeaponToPlayer( client, WP_MORTAR, GetAmmoTableData(WP_MORTAR)->defaultStartingAmmo, GetAmmoTableData(WP_MORTAR)->defaultStartingClip, qtrue ) ) { - AddWeaponToPlayer( client, WP_MORTAR_SET, GetAmmoTableData(WP_MORTAR_SET)->defaultStartingAmmo, GetAmmoTableData(WP_MORTAR_SET)->defaultStartingClip, qfalse ); - } - break; - } - break; - default: - break; - } - } else if( pc == PC_COVERTOPS ) { - switch( client->sess.playerWeapon ) { - case WP_K43: - case WP_GARAND: - if( client->sess.sessionTeam == TEAM_AXIS ) { - if( AddWeaponToPlayer( client, WP_K43, GetAmmoTableData(WP_K43)->defaultStartingAmmo, GetAmmoTableData(WP_K43)->defaultStartingClip, qtrue ) ) { - AddWeaponToPlayer( client, WP_K43_SCOPE, GetAmmoTableData(WP_K43_SCOPE)->defaultStartingAmmo, GetAmmoTableData(WP_K43_SCOPE)->defaultStartingClip, qfalse ); - } - break; - } else { - if( AddWeaponToPlayer( client, WP_GARAND, GetAmmoTableData(WP_GARAND)->defaultStartingAmmo, GetAmmoTableData(WP_GARAND)->defaultStartingClip, qtrue ) ) { - AddWeaponToPlayer( client, WP_GARAND_SCOPE, GetAmmoTableData(WP_GARAND_SCOPE)->defaultStartingAmmo, GetAmmoTableData(WP_GARAND_SCOPE)->defaultStartingClip, qfalse ); - } - break; - } - case WP_FG42: - if( AddWeaponToPlayer( client, WP_FG42, GetAmmoTableData(WP_FG42)->defaultStartingAmmo, GetAmmoTableData(WP_FG42)->defaultStartingClip, qtrue ) ) { - AddWeaponToPlayer( client, WP_FG42SCOPE, GetAmmoTableData(WP_FG42SCOPE)->defaultStartingAmmo, GetAmmoTableData(WP_FG42SCOPE)->defaultStartingClip, qfalse ); - } - break; - default: - AddWeaponToPlayer( client, WP_STEN, 2*(GetAmmoTableData(WP_STEN)->defaultStartingAmmo), GetAmmoTableData(WP_STEN)->defaultStartingClip, qtrue ); - break; - } - - if( AddWeaponToPlayer( client, WP_BINOCULARS, 1, 0, qfalse ) ) { - client->ps.stats[STAT_KEYS] |= ( 1 << INV_BINOCS ); - } - - AddWeaponToPlayer( client, WP_SMOKE_BOMB, GetAmmoTableData(WP_SMOKE_BOMB)->defaultStartingAmmo, GetAmmoTableData(WP_SMOKE_BOMB)->defaultStartingClip, qfalse ); - - // See if we already have a satchel charge placed - NOTE: maybe we want to change this so the thing voids on death - if( G_FindSatchel( &g_entities[client->ps.clientNum] ) ) { - AddWeaponToPlayer( client, WP_SATCHEL, 0, 0, qfalse ); // Big Bang \o/ - AddWeaponToPlayer( client, WP_SATCHEL_DET, 0, 1, qfalse ); // Big Red Button for tha Big Bang - } else { - AddWeaponToPlayer( client, WP_SATCHEL, 0, 1, qfalse ); // Big Bang \o/ - AddWeaponToPlayer( client, WP_SATCHEL_DET, 0, 0, qfalse ); // Big Red Button for tha Big Bang - } - } - - switch( client->sess.sessionTeam ) { - case TEAM_AXIS: - switch( pc ) { - case PC_SOLDIER: - if( client->sess.skill[SK_HEAVY_WEAPONS] >= 4 && client->sess.playerWeapon2 == WP_MP40 ) { - AddWeaponToPlayer( client, WP_MP40, 2*(GetAmmoTableData(WP_MP40)->defaultStartingAmmo), GetAmmoTableData(WP_MP40)->defaultStartingClip, qtrue ); - } else if( client->sess.skill[SK_LIGHT_WEAPONS] >= 4 && client->sess.playerWeapon2 == WP_AKIMBO_LUGER ) { - client->ps.ammoclip[BG_FindClipForWeapon(BG_AkimboSidearm(WP_AKIMBO_LUGER))] = GetAmmoTableData(WP_AKIMBO_LUGER)->defaultStartingClip; - AddWeaponToPlayer( client, WP_AKIMBO_LUGER, GetAmmoTableData(WP_AKIMBO_LUGER)->defaultStartingAmmo, GetAmmoTableData(WP_AKIMBO_LUGER)->defaultStartingClip, qfalse ); - } else { - AddWeaponToPlayer( client, WP_LUGER, GetAmmoTableData(WP_LUGER)->defaultStartingAmmo, GetAmmoTableData(WP_LUGER)->defaultStartingClip, qfalse ); - } - break; - - case PC_COVERTOPS: - if( client->sess.skill[SK_LIGHT_WEAPONS] >= 4 && ( client->sess.playerWeapon2 == WP_AKIMBO_SILENCEDLUGER || client->sess.playerWeapon2 == WP_AKIMBO_LUGER ) ) { - client->ps.ammoclip[BG_FindClipForWeapon(BG_AkimboSidearm(WP_AKIMBO_SILENCEDLUGER))] = GetAmmoTableData(WP_AKIMBO_SILENCEDLUGER)->defaultStartingClip; - AddWeaponToPlayer( client, WP_AKIMBO_SILENCEDLUGER, GetAmmoTableData(WP_AKIMBO_SILENCEDLUGER)->defaultStartingAmmo, GetAmmoTableData(WP_AKIMBO_SILENCEDLUGER)->defaultStartingClip, qfalse ); - } else { - AddWeaponToPlayer( client, WP_LUGER, GetAmmoTableData(WP_LUGER)->defaultStartingAmmo, GetAmmoTableData(WP_LUGER)->defaultStartingClip, qfalse ); - AddWeaponToPlayer( client, WP_SILENCER, GetAmmoTableData(WP_SILENCER)->defaultStartingAmmo, GetAmmoTableData(WP_SILENCER)->defaultStartingClip, qfalse ); - client->pmext.silencedSideArm = 1; - } - break; - - default: - if( client->sess.skill[SK_LIGHT_WEAPONS] >= 4 && client->sess.playerWeapon2 == WP_AKIMBO_LUGER ) { - client->ps.ammoclip[BG_FindClipForWeapon(BG_AkimboSidearm(WP_AKIMBO_LUGER))] = GetAmmoTableData(WP_AKIMBO_LUGER)->defaultStartingClip; - AddWeaponToPlayer( client, WP_AKIMBO_LUGER, GetAmmoTableData(WP_AKIMBO_LUGER)->defaultStartingAmmo, GetAmmoTableData(WP_AKIMBO_LUGER)->defaultStartingClip, qfalse ); - } else { - AddWeaponToPlayer( client, WP_LUGER, GetAmmoTableData(WP_LUGER)->defaultStartingAmmo, GetAmmoTableData(WP_LUGER)->defaultStartingClip, qfalse ); - } - break; - } - break; - default: - switch( pc ) { - case PC_SOLDIER: - if( client->sess.skill[SK_HEAVY_WEAPONS] >= 4 && client->sess.playerWeapon2 == WP_THOMPSON ) { - AddWeaponToPlayer( client, WP_THOMPSON, 2*(GetAmmoTableData(WP_THOMPSON)->defaultStartingAmmo), GetAmmoTableData(WP_THOMPSON)->defaultStartingClip, qtrue ); - } else if( client->sess.skill[SK_LIGHT_WEAPONS] >= 4 && client->sess.playerWeapon2 == WP_AKIMBO_COLT ) { - client->ps.ammoclip[BG_FindClipForWeapon(BG_AkimboSidearm(WP_AKIMBO_COLT))] = GetAmmoTableData(WP_AKIMBO_COLT)->defaultStartingClip; - AddWeaponToPlayer( client, WP_AKIMBO_COLT, GetAmmoTableData(WP_AKIMBO_COLT)->defaultStartingAmmo, GetAmmoTableData(WP_AKIMBO_COLT)->defaultStartingClip, qfalse ); - } else { - AddWeaponToPlayer( client, WP_COLT, GetAmmoTableData(WP_COLT)->defaultStartingAmmo, GetAmmoTableData(WP_COLT)->defaultStartingClip, qfalse ); - } - break; - - case PC_COVERTOPS: - if( client->sess.skill[SK_LIGHT_WEAPONS] >= 4 && ( client->sess.playerWeapon2 == WP_AKIMBO_SILENCEDCOLT || client->sess.playerWeapon2 == WP_AKIMBO_COLT ) ) { - client->ps.ammoclip[BG_FindClipForWeapon(BG_AkimboSidearm(WP_AKIMBO_SILENCEDCOLT))] = GetAmmoTableData(WP_AKIMBO_SILENCEDCOLT)->defaultStartingClip; - AddWeaponToPlayer( client, WP_AKIMBO_SILENCEDCOLT, GetAmmoTableData(WP_AKIMBO_SILENCEDCOLT)->defaultStartingAmmo, GetAmmoTableData(WP_AKIMBO_SILENCEDCOLT)->defaultStartingClip, qfalse ); - } else { - AddWeaponToPlayer( client, WP_COLT, GetAmmoTableData(WP_COLT)->defaultStartingAmmo, GetAmmoTableData(WP_COLT)->defaultStartingClip, qfalse ); - AddWeaponToPlayer( client, WP_SILENCED_COLT, GetAmmoTableData(WP_SILENCED_COLT)->defaultStartingAmmo, GetAmmoTableData(WP_SILENCED_COLT)->defaultStartingClip, qfalse ); - client->pmext.silencedSideArm = 1; - } - break; - - default: - if( client->sess.skill[SK_LIGHT_WEAPONS] >= 4 && client->sess.playerWeapon2 == WP_AKIMBO_COLT ) { - client->ps.ammoclip[BG_FindClipForWeapon(BG_AkimboSidearm(WP_AKIMBO_COLT))] = GetAmmoTableData(WP_AKIMBO_COLT)->defaultStartingClip; - AddWeaponToPlayer( client, WP_AKIMBO_COLT, GetAmmoTableData(WP_AKIMBO_COLT)->defaultStartingAmmo, GetAmmoTableData(WP_AKIMBO_COLT)->defaultStartingClip, qfalse ); - } else { - AddWeaponToPlayer( client, WP_COLT, GetAmmoTableData(WP_COLT)->defaultStartingAmmo, GetAmmoTableData(WP_COLT)->defaultStartingClip, qfalse ); - } - break; - } - } - - if( pc == PC_SOLDIER ) { - if( client->sess.sessionTeam == TEAM_AXIS ) { - AddWeaponToPlayer( client, WP_GRENADE_LAUNCHER, 0, 4, qfalse ); - } else { - AddWeaponToPlayer( client, WP_GRENADE_PINEAPPLE, 0, 4, qfalse ); - } - } - if( pc == PC_COVERTOPS ) { - if( client->sess.sessionTeam == TEAM_AXIS ) { - AddWeaponToPlayer( client, WP_GRENADE_LAUNCHER, 0, 2, qfalse ); - } else { - AddWeaponToPlayer( client, WP_GRENADE_PINEAPPLE, 0, 2, qfalse ); - } - } - } else { - // Knifeonly block - if( pc == PC_MEDIC ) { - AddWeaponToPlayer( client, WP_MEDIC_SYRINGE, 0, 20, qfalse ); - if( client->sess.skill[SK_FIRST_AID] >= 4 ) - AddWeaponToPlayer( client, WP_MEDIC_ADRENALINE, 0, 10, qfalse ); - - } - // End Knifeonly stuff -- Ensure that medics get their basic stuff + switch(pc) { + case PC_SOLDIER: + _SetSoldierSpawnWeapons(client); + break; + case PC_MEDIC: + _SetMedicSpawnWeapons(client); + break; + case PC_ENGINEER: + _SetEngineerSpawnWeapons(client); + break; + case PC_FIELDOPS: + _SetFieldOpSpawnWeapons(client); + break; + case PC_COVERTOPS: + _SetCovertSpawnWeapons(client); + break; } + + G_AddClassSpecificTools(client); } int G_CountTeamMedics( team_t team, qboolean alivecheck ) { @@ -1327,6 +1650,11 @@ } } + // look for cg_hitsounds + s = Info_ValueForKey(userinfo, "cg_hitsounds"); + if(*s) client->pers.hitsounds = atoi(s); + else client->pers.hitsounds = 1; + // set name Q_strncpyz( oldname, client->pers.netname, sizeof( oldname ) ); s = Info_ValueForKey (userinfo, "name"); @@ -1417,8 +1745,15 @@ return; } - G_LogPrintf( "ClientUserinfoChanged: %i %s\n", clientNum, s ); - G_DPrintf( "ClientUserinfoChanged: %i :: %s\n", clientNum, s ); + if (g_logOptions.integer & LOGOPTS_GUID) // Log the GUIDs? + { + char *guid = Info_ValueForKey ( userinfo, "cl_guid" ); + G_LogPrintf( "ClientUserinfoChangedGUID: %i %s %s\n", clientNum, guid, s ); + G_DPrintf( "ClientUserinfoChangedGUID: %i :: %s %s\n", clientNum, guid, s ); + } else { + G_LogPrintf( "ClientUserinfoChanged: %i %s\n", clientNum, s ); + G_DPrintf( "ClientUserinfoChanged: %i :: %s\n", clientNum, s ); + } } @@ -1446,11 +1781,12 @@ char *value; gclient_t *client; char userinfo[MAX_INFO_STRING]; + char userinfo2[MAX_INFO_STRING]; gentity_t *ent; -#ifdef USEXPSTORAGE - ipXPStorage_t* xpBackup; - int i; -#endif // USEXPSTORAGE + int i; + int clientNum2; + char guid[33]; + ent = &g_entities[ clientNum ]; @@ -1465,6 +1801,11 @@ return "You are banned from this server."; } + // check for shrubbot ban + if(G_shrubbot_ban_check(userinfo)) + return "You are banned from this server."; + + // Xian - check for max lives enforcement ban if( g_gametype.integer != GT_WOLF_LMS ) { if( g_enforcemaxlives.integer && (g_maxlives.integer > 0 || g_axismaxlives.integer > 0 || g_alliedmaxlives.integer > 0) ) { @@ -1504,6 +1845,33 @@ ClientDisconnect( ent-g_entities ); } + // tjw: if the client has crashed, force disconnect of previous + // session so that the XP can be reclaimed + // tjw: this interferes with sv_wwwDlDisconnected + if((g_XPSave.integer & XPSF_ENABLE) && + firstTime && + (!trap_Cvar_VariableIntegerValue("sv_wwwDlDisconnected") || + (g_XPSave.integer & XPSF_WIPE_DUP_GUID))) { + + value = Info_ValueForKey (userinfo, "cl_guid"); + Q_strncpyz(guid, value, sizeof(guid)); + for (i = 0; i < level.numConnectedClients; i++) { + clientNum2 = level.sortedClients[i]; + if(clientNum == clientNum2) continue; + trap_GetUserinfo(clientNum2, + userinfo2, + sizeof(userinfo2)); + value = Info_ValueForKey (userinfo2, "cl_guid"); + if(!Q_stricmp(guid, value)) { + G_LogPrintf( "Forcing disconnect of " + "duplicate guid %s for client %i\n", + guid, + clientNum2); + ClientDisconnect(clientNum2); + } + } + } + // they can connect ent->client = level.clients + clientNum; client = ent->client; @@ -1515,11 +1883,10 @@ client->pers.connected = CON_CONNECTING; client->pers.connectTime = level.time; // DHM - Nerve - if( firstTime ) - client->pers.initialSpawn = qtrue; // DHM - Nerve - // read or initialize the session data if( firstTime ) { + client->pers.lastTeamChangeTime = 0; + client->pers.initialSpawn = qtrue; // DHM - Nerve G_InitSessionData( client, userinfo ); client->pers.enterTime = level.time; client->ps.persistant[PERS_SCORE] = 0; @@ -1527,15 +1894,45 @@ G_ReadSessionData( client ); } -#ifdef USEXPSTORAGE - value = Info_ValueForKey (userinfo, "ip"); - if( xpBackup = G_FindXPBackup( value ) ) { - for( i = 0; i < SK_NUM_SKILLS; i++ ) { - client->sess.skillpoints[ i ] = xpBackup->skills[ i ]; + // tjw: this should not be necessary, but there seems to be + // certain cases that allow new players to assume the + // stats of the last player that had this slot number. + // we're not storing wstats at all between levels now + // so this will need to be fixed the right way if we start. + G_deleteStats(clientNum); + + if(g_XPSave.integer & XPSF_ENABLE) { + + char *guid; + char userinfo[MAX_INFO_STRING]; + XPStorage_t* storage; + int i; + + client->XPSave_lives = -999; + trap_GetUserinfo( clientNum, userinfo, sizeof( userinfo ) ); + guid = Info_ValueForKey ( userinfo, "cl_guid" ); + storage = G_FindXPBackup(guid); + if(storage) { + // make the client aware that they have no lives before + // ClientBegin to avoid confusion + if(storage->lives != -999 && + storage->lives < 0) { + + client->ps.persistant[PERS_RESPAWNS_LEFT] = storage->lives; + + } + client->XPSave_lives = storage->lives; + for( i = 0; i < SK_NUM_SKILLS; i++ ) { + client->sess.skillpoints[i] = storage->skills[i]; + } + G_CalcRank( client ); + ent->client->ps.stats[STAT_XP] = 0; + for( i = 0; i < SK_NUM_SKILLS; i++ ) { + ent->client->ps.stats[STAT_XP] += ent->client->sess.skillpoints[i]; + } + BG_PlayerStateToEntityState( &ent->client->ps, &ent->s, qtrue ); } - G_CalcRank( client ); } -#endif // USEXPSTORAGE if( g_gametype.integer == GT_WOLF_CAMPAIGN ) { if( g_campaigns[level.currentCampaign].current == 0 || level.newCampaign ) { @@ -1627,15 +2024,33 @@ // int G_ComputeMaxLives(gclient_t *cl, int maxRespawns) { - float scaled = (float)(maxRespawns - 1) * (1.0f - ((float)(level.time - level.startTime) / (g_timelimit.value * 60000.0f))); - int val = (int)scaled; + float scaled; + int val; // rain - #102 - don't scale of the timelimit is 0 if (g_timelimit.value == 0.0) { return maxRespawns - 1; } + // tjw: do not give out lives in dual obj maps once time runs out. + if((float)(level.time - level.startTime) >= + (g_timelimit.value * 60000.0f)) { + + return -1; + } + + scaled = (float)(maxRespawns - 1) * (1.0f - ((float)(level.time - level.startTime) / (g_timelimit.value * 60000.0f))); + val = (int)scaled; + val += ((scaled - (float)val) < 0.5f) ? 0 : 1; + + if((g_XPSave.integer & XPSF_ENABLE) && + cl->XPSave_lives != -999 && + cl->XPSave_lives < val) { + + val = cl->XPSave_lives; + } + return(val); } @@ -1654,11 +2069,19 @@ gclient_t *client; int flags; int spawn_count, lives_left; // DHM - Nerve + int health; + qboolean maxlives; ent = g_entities + clientNum; client = level.clients + clientNum; + health = ent->health; + + maxlives = (g_maxlives.integer || + g_alliedmaxlives.integer || + g_axismaxlives.integer); + if ( ent->r.linked ) { trap_UnlinkEntity( ent ); } @@ -1688,14 +2111,26 @@ memset( &client->ps, 0, sizeof( client->ps ) ); client->ps.eFlags = flags; client->ps.persistant[PERS_SPAWN_COUNT] = spawn_count; - client->ps.persistant[PERS_RESPAWNS_LEFT] = lives_left; + if(!maxlives) + client->ps.persistant[PERS_RESPAWNS_LEFT] = -1; + else + client->ps.persistant[PERS_RESPAWNS_LEFT] = lives_left; client->pers.complaintClient = -1; client->pers.complaintEndTime = -1; - // locate ent at a spawn point - ClientSpawn( ent, qfalse ); + // tjw: even if g_teamChangeKills is 0, kill them if they try to + // change teams twice in one round to prevent team change + // spamming. + if(client->sess.sessionTeam == TEAM_AXIS) { + if(level.time - client->pers.lastTeamChangeTime < g_redlimbotime.integer) + health = 0; + } + if(client->sess.sessionTeam == TEAM_ALLIES) { + if(level.time - client->pers.lastTeamChangeTime < g_bluelimbotime.integer) + health = 0; + } // Xian -- Changed below for team independant maxlives if( g_gametype.integer != GT_WOLF_LMS ) { @@ -1733,27 +2168,37 @@ } } } - } + } + // locate ent at a spawn point + if(!g_teamChangeKills.integer && health > 0) { - // DHM - Nerve :: Start players in limbo mode if they change teams during the match - if(client->sess.sessionTeam != TEAM_SPECTATOR && (level.time - level.startTime > FRAMETIME * GAME_INIT_FRAMES) ) { -/* if( (client->sess.sessionTeam != TEAM_SPECTATOR && (level.time - client->pers.connectTime) > 60000) || - ( g_gamestate.integer == GS_PLAYING && ( client->sess.sessionTeam == TEAM_AXIS || client->sess.sessionTeam == TEAM_ALLIES ) && - g_gametype.integer == GT_WOLF_LMS && ( level.numTeamClients[0] > 0 || level.numTeamClients[1] > 0 ) ) ) {*/ - ent->health = 0; - ent->r.contents = CONTENTS_CORPSE; + ClientSpawn(ent, qfalse, qtrue, qfalse); + } + else { + ClientSpawn(ent, qfalse, qtrue, qtrue); + } - client->ps.pm_type = PM_DEAD; - client->ps.stats[STAT_HEALTH] = 0; - if( g_gametype.integer != GT_WOLF_LMS ) { - if( g_maxlives.integer > 0 ) { + // DHM - Nerve :: Start players in limbo mode if they change teams + // during the match + // tjw: don't kill the player unless they're dead already + if(client->sess.sessionTeam != TEAM_SPECTATOR && + level.time - level.startTime > FRAMETIME * GAME_INIT_FRAMES) { + + // tjw: otherwise players lose 2 lives. + // tjw: wtf does gametype have to do with it? + if(g_gametype.integer != GT_WOLF_LMS && maxlives) client->ps.persistant[PERS_RESPAWNS_LEFT]++; - } - } + + if(health <= 0 || g_teamChangeKills.integer) { + ent->health = 0; + ent->r.contents = CONTENTS_CORPSE; + client->ps.pm_type = PM_DEAD; + client->ps.stats[STAT_HEALTH] = 0; - limbo(ent, qfalse); + limbo(ent, qfalse); + } } if(client->sess.sessionTeam != TEAM_SPECTATOR) { @@ -1859,7 +2304,11 @@ Initializes all non-persistant parts of playerState ============ */ -void ClientSpawn( gentity_t *ent, qboolean revived ) +void ClientSpawn( + gentity_t *ent, + qboolean revived, + qboolean teamChange, + qboolean restoreHealth) { int index; vec3_t spawn_origin, spawn_angles; @@ -1929,6 +2378,9 @@ // toggle the teleport bit so the client knows to not lerp flags = ent->client->ps.eFlags & EF_TELEPORT_BIT; flags ^= EF_TELEPORT_BIT; +//unlagged reset history markers + G_ResetMarkers(ent); +//unlagged flags |= (client->ps.eFlags & EF_VOTED); // clear everything but the persistant data @@ -1948,10 +2400,12 @@ { qboolean set = client->maxlivescalced; + int XPSave_lives = client->XPSave_lives; memset( client, 0, sizeof(*client) ); client->maxlivescalced = set; + client->XPSave_lives = XPSave_lives; } client->pers = saved; @@ -1978,6 +2432,7 @@ // clear entity values client->ps.stats[STAT_MAX_HEALTH] = client->pers.maxHealth; + client->ps.eFlags = flags; // MrE: use capsules for AI and player //client->ps.eFlags |= EF_CAPSULE; @@ -2014,7 +2469,8 @@ client->ps.standViewHeight = DEFAULT_VIEWHEIGHT; client->ps.deadViewHeight = DEAD_VIEWHEIGHT; - client->ps.crouchMaxZ = client->ps.maxs[2] - (client->ps.standViewHeight - client->ps.crouchViewHeight); + //client->ps.crouchMaxZ = client->ps.maxs[2] - (client->ps.standViewHeight - client->ps.crouchViewHeight); + client->ps.crouchMaxZ = CROUCH_VIEWHEIGHT; client->ps.runSpeedScale = 0.8; client->ps.sprintSpeedScale = 1.1; @@ -2050,7 +2506,7 @@ client->sess.playerType = client->sess.latchPlayerType; - if( G_IsWeaponDisabled( ent, client->sess.latchPlayerWeapon ) ) { + if( G_IsWeaponDisabled( ent, client->sess.latchPlayerWeapon, qtrue ) ) { bg_playerclass_t* classInfo = BG_PlayerClassForPlayerState( &ent->client->ps ); client->sess.latchPlayerWeapon = classInfo->classWeapons[0]; update = qtrue; @@ -2061,7 +2517,7 @@ update = qtrue; } - if( G_IsWeaponDisabled( ent, client->sess.playerWeapon ) ) { + if( G_IsWeaponDisabled( ent, client->sess.playerWeapon, qtrue ) ) { bg_playerclass_t* classInfo = BG_PlayerClassForPlayerState( &ent->client->ps ); client->sess.playerWeapon = classInfo->classWeapons[0]; update = qtrue; @@ -2069,7 +2525,7 @@ client->sess.playerWeapon2 = client->sess.latchPlayerWeapon2; - if( update ) { + if( update || teamChange ) { ClientUserinfoChanged( index ); } } @@ -2079,8 +2535,10 @@ // Xian - Moved the invul. stuff out of SetWolfSpawnWeapons and put it here for clarity if ( g_fastres.integer == 1 && revived ) client->ps.powerups[PW_INVULNERABLE] = level.time + 1000; - else + else if(revived) client->ps.powerups[PW_INVULNERABLE] = level.time + 3000; + else + client->ps.powerups[PW_INVULNERABLE] = level.time + (g_spawnInvul.integer * 1000); } // End Xian @@ -2103,11 +2561,16 @@ // JPW NERVE ***NOTE*** the following line is order-dependent and must *FOLLOW* SetWolfSpawnWeapons() in multiplayer // AddMedicTeamBonus() now adds medic team bonus and stores in ps.stats[STAT_MAX_HEALTH]. - if( client->sess.skill[SK_BATTLE_SENSE] >= 3 ) - // We get some extra max health, but don't spawn with that much - ent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH] - 15; - else - ent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH]; + if(restoreHealth) { + if( client->sess.skill[SK_BATTLE_SENSE] >= 3 ) + // We get some extra max health, but don't spawn with that much + ent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH] - 15; + else + ent->health = client->ps.stats[STAT_HEALTH] = client->ps.stats[STAT_MAX_HEALTH]; + } + else { + client->ps.stats[STAT_HEALTH] = ent->health; + } G_SetOrigin( ent, spawn_origin ); VectorCopy( spawn_origin, client->ps.origin ); @@ -2230,9 +2693,8 @@ return; } -#ifdef USEXPSTORAGE - G_AddXPBackup( ent ); -#endif // USEXPSTORAGE + + if(g_XPSave.integer & XPSF_ENABLE) G_AddXPBackup( ent ); G_RemoveClientFromFireteams( clientNum, qtrue, qfalse ); G_RemoveFromAllIgnoreLists( clientNum ); @@ -2250,16 +2712,12 @@ && flag->client->sess.spectatorClient == clientNum ) { Cmd_FollowCycle_f( flag, 1 ); } - } - - // NERVE - SMF - remove complaint client - for ( i = 0 ; i < level.numConnectedClients ; i++ ) { + // NERVE - SMF - remove complaint client if ( flag->client->pers.complaintEndTime > level.time && flag->client->pers.complaintClient == clientNum ) { flag->client->pers.complaintClient = -1; flag->client->pers.complaintEndTime = -1; CPx( level.sortedClients[i], "complaint -2" ); - break; } } @@ -2374,3 +2832,38 @@ g_entities[clientNum].surfaceFlags = surfaceFlags; } + + +// ClientHitboxMaxZ returns the proper value to use for +// the entity's r.maxs[2] when running a trace. +float ClientHitboxMaxZ(gentity_t *hitEnt) +{ + if(!hitEnt) return 0; + if(!hitEnt->client) return hitEnt->r.maxs[2]; + + if((g_hitboxes.integer & HBF_CORPSE) && + (hitEnt->client->ps.eFlags & EF_DEAD)) { + return 4; + } + else if((g_hitboxes.integer & HBF_PLAYDEAD) && + (hitEnt->client->ps.eFlags & EF_PLAYDEAD)) { + return 4; + } + else if((g_hitboxes.integer & HBF_PRONE) && + (hitEnt->client->ps.eFlags & EF_PRONE)) { + return 4; + } + else if((g_hitboxes.integer & HBF_CROUCHING) && + (hitEnt->client->ps.eFlags & EF_CROUCHING)) { + // tjw: changed this because the crouched moving + // animation is higher than the idle one + // and that should be the most commonly used + //return 18; + return 24; + } + else if((g_hitboxes.integer & HBF_STANDING)) { + return 36; + } + return hitEnt->r.maxs[2]; +} + diff -urN --exclude=.svn et260/src/game/g_cmds.c etpub/src/game/g_cmds.c --- et260/src/game/g_cmds.c 2005-04-12 12:11:50.000000000 -0500 +++ etpub/src/game/g_cmds.c 2005-04-25 22:21:45.000000000 -0500 @@ -4,107 +4,335 @@ void GetBotAutonomies(int clientNum, int *weapAutonomy, int *moveAutonomy); qboolean G_IsOnFireteam(int entityNum, fireteamData_t** teamNum); +// Josh: like shrub, pretty naive +qboolean G_CensorText(char *text) +{ + qboolean foundWord = qfalse, lastWordFound = qfalse; + int word = 0; + char *textPos = text; + while (*textPos) { + lastWordFound = qfalse; + word = 0; + while (word < censorDictionary.num_words && *textPos) { + if(!Q_stricmpn(textPos, censorDictionary.words[word], strlen(censorDictionary.words[word]))) { + foundWord = qtrue; + if (word == censorDictionary.num_words - 1) { + lastWordFound = qtrue; + } + { + int i; + for (i = 0; + i < strlen( + censorDictionary.words[word]); + i++) { + *textPos++ = '*'; + } + } + } + word++; + } + // If it's the last word, it will already be incremented + if (!lastWordFound) + textPos++; + } + return foundWord; +} + +// Josh: Won't gib if already in limbo, same as shrub +void G_CensorPenalize(gentity_t *ent) +{ + if (!ent->client) return; + if (g_censorPenalty.integer & CNSRPNLTY_TMPMUTE){ + ent->client->sess.muted = qtrue; + ent->client->sess.auto_mute_time = level.time; + CPx(ent - g_entities, va("print \"^5You've been auto-muted for %d seconds for language.\"",g_censorMuteTime.integer )); + AP(va("chat \"%s^7 has been auto-muted for %d seconds for language.", + ent->client->pers.netname, g_censorMuteTime.integer )); + } + if (g_censorPenalty.integer & CNSRPNLTY_KILL) { + Cmd_Kill_f(ent); + return; + } + if (g_censorPenalty.integer & CNSRPNLTY_NOGIB){ + // KILL, don't GIB + ent->flags &= ~FL_GODMODE; + ent->client->ps.stats[STAT_HEALTH] = ent->health = 0; + ent->client->ps.persistant[PERS_HWEAPON_USE] = 0; // TTimo - if at MG42 + player_die(ent, ent, ent , 135, MOD_UNKNOWN); + } +} + /* -================== -G_SendScore + * G_PlayDead + */ +void G_PlayDead(gentity_t *ent) +{ -Sends current scoreboard information -================== -*/ -void G_SendScore( gentity_t *ent ) { - char entry[128]; - int i; - gclient_t *cl; - int numSorted; - int team, size, count; - char buffer[1024]; - char startbuffer[32]; + if(!ent->client) + return; + if(!g_playDead.integer) + return; + if(ent->health < 0) + return; + if(ent->client->ps.poisoned) + return; - // send the latest information on all clients - numSorted = level.numConnectedClients; - if ( numSorted > 64 ) { - numSorted = 64; + if(ent->client->ps.eFlags & EF_PLAYDEAD) { + + ent->client->ps.stats[STAT_HEALTH] = ent->health; + ent->client->ps.pm_type = PM_PLAYDEAD; + CP("cp \"SURPRISE!\" 1"); + /* + BG_AnimScriptEvent( + &ent->client->ps, + ent->client->pers.character->animModelInfo, + ANIM_ET_JUMP, + qfalse, + qtrue); + */ } + else { + ent->client->ps.pm_type = PM_PLAYDEAD; + /* + BG_AnimScriptEvent( + &ent->client->ps, + ent->client->pers.character->animModelInfo, + ANIM_ET_DEATH, + qfalse, + qtrue); + */ + } +} - i = 0; - // Gordon: team doesnt actually mean team, ignore... - for(team = 0; team < 2; team++) { - *buffer = '\0'; - *startbuffer = '\0'; - if( team == 0 ) { - Q_strncpyz(startbuffer, va("sc0 %i %i", level.teamScores[TEAM_AXIS], level.teamScores[TEAM_ALLIES]), 32 ); - } else { - Q_strncpyz(startbuffer, "sc1", 32 ); - } - size = strlen(startbuffer) + 1; - count = 0; +void G_PrivateMessage(gentity_t *ent) +{ + int pids[MAX_CLIENTS]; + char name[MAX_NAME_LENGTH]; + char netname[MAX_NAME_LENGTH]; + char cmd[12]; + char *msg; + int pcount; + int i; + int skipargs = 0; + gentity_t *tmpent; + qboolean sent = qfalse; + + if(!g_privateMessages.integer && ent) return; + Q_SayArgv(0, cmd, sizeof(cmd)); + if(!Q_stricmp(cmd, "say")) { + skipargs = 1; + Q_SayArgv(1, cmd, sizeof(cmd)); + } + if(Q_SayArgc() < 3+skipargs) { + SP(va("usage: %s [name|slot#] [message]\n", cmd)); + return; + } + Q_SayArgv(1+skipargs, name, sizeof(name)); + msg = Q_SayConcatArgs(2+skipargs); + pcount = ClientNumbersFromString(name, pids); + + if(ent) + Q_strncpyz(netname, + ent->client->pers.netname, + sizeof(name)); + else + Q_strncpyz(netname, "console", sizeof(name)); - for(; i < numSorted ; i++) { - int ping, playerClass, respawnsLeft; + for(i=0; i %s^7: (%d recipients^7): ^3%s^7\"", + netname, + name, + pcount, + msg)); + CPx(pids[i], va("cp \"^3private message from ^7%s^7\"", + netname)); + SP(va("private message sent to %s: ^3%s^7\n", + tmpent->client->pers.netname, + msg + )); + } + if(!sent) { + SP("player not found\n"); + } else if (g_logOptions.integer & LOGOPTS_PRIVMSG) { + G_LogPrintf( "privmsg: %s: %s: %s\n", netname, name, msg ); + } +} - cl = &level.clients[level.sortedClients[i]]; +void G_TeamDamageStats(gentity_t *ent) +{ + float teamHitPct; + if (!ent->client) return; - if(g_entities[level.sortedClients[i]].r.svFlags & SVF_POW) { - continue; - } + teamHitPct = + ent->client->sess.hits ? + (ent->client->sess.team_hits / ent->client->sess.hits)*(100): + 0; + + CPx(ent-g_entities, + va("print \"Team Hits: %.2f Total Hits: %.2f " + "Pct: %.2f Limit: %d\n\"", + ent->client->sess.team_hits, + ent->client->sess.hits, + teamHitPct, + g_teamDamageRestriction.integer + )); + return; +} - // NERVE - SMF - if on same team, send across player class - // Gordon: FIXME: remove/move elsewhere? - if ( cl->ps.persistant[PERS_TEAM] == ent->client->ps.persistant[PERS_TEAM] || G_smvLocateEntityInMVList(ent, level.sortedClients[i], qfalse)) { - playerClass = cl->ps.stats[STAT_PLAYER_CLASS]; - } else { - playerClass = 0; - } - // NERVE - SMF - number of respawns left - respawnsLeft = cl->ps.persistant[PERS_RESPAWNS_LEFT]; - if( g_gametype.integer == GT_WOLF_LMS ) { - if( g_entities[level.sortedClients[i]].health <= 0 ) { - respawnsLeft = -2; - } - } else { - if( (respawnsLeft == 0 && ((cl->ps.pm_flags & PMF_LIMBO) || (( level.intermissiontime ) && g_entities[level.sortedClients[i]].health <= 0))) ) { - respawnsLeft = -2; - } - } +// G_SendScore_Add +// +// Add score with clientNum at index i of level.sortedClients[] +// to the string buf. +// +// returns qtrue if the score was appended to buf, qfalse otherwise. +qboolean G_SendScore_Add(gentity_t *ent, int i, char *buf, int bufsize) +{ + gclient_t *cl; + int ping, playerClass, respawnsLeft; + char entry[128]; + int totalXP = 0; + int j; - if ( cl->pers.connected == CON_CONNECTING ) { - ping = -1; - } else { - ping = cl->ps.ping < 999 ? cl->ps.ping : 999; - } + entry[0] = '\0'; - if( g_gametype.integer == GT_WOLF_LMS ) { - Com_sprintf (entry, sizeof(entry), " %i %i %i %i %i %i %i", level.sortedClients[i], cl->ps.persistant[PERS_SCORE], ping, - (level.time - cl->pers.enterTime) / 60000, g_entities[level.sortedClients[i]].s.powerups, playerClass, respawnsLeft ); - } else { - int j, totalXP; + cl = &level.clients[level.sortedClients[i]]; - for( totalXP = 0, j = 0; j < SK_NUM_SKILLS; j++ ) { - totalXP += cl->sess.skillpoints[j]; - } + playerClass = 0; + // tjw: spectators should be able to see the player's class, + // but apperantly the client won't draw them even if we + // send it. *clientmod* + if(G_smvLocateEntityInMVList(ent, level.sortedClients[i], qfalse) || + cl->sess.sessionTeam == ent->client->sess.sessionTeam || + ent->client->sess.sessionTeam == TEAM_SPECTATOR) { - Com_sprintf (entry, sizeof(entry), " %i %i %i %i %i %i %i", level.sortedClients[i], totalXP, ping, - (level.time - cl->pers.enterTime) / 60000, g_entities[level.sortedClients[i]].s.powerups, playerClass, respawnsLeft ); - } + playerClass = cl->sess.playerType; + } - if(size + strlen(entry) > 1000) { - i--; // we need to redo this client in the next buffer (if we can) - break; - } - size += strlen(entry); + // NERVE - SMF - number of respawns left + respawnsLeft = cl->ps.persistant[PERS_RESPAWNS_LEFT]; + if(g_gametype.integer == GT_WOLF_LMS) { + if(g_entities[level.sortedClients[i]].health <= 0) { + respawns