diff -urN --exclude=.svn et.orig/src/game/bg_animation.c etpub/src/game/bg_animation.c --- et.orig/src/game/bg_animation.c 2003-05-03 06:50:52.000000000 -0500 +++ etpub/src/game/bg_animation.c 2005-03-15 17:54:19.000000000 -0600 @@ -1422,6 +1422,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 ) @@ -1466,9 +1467,25 @@ Com_Printf( "anim1 (%s): %s", animBodyPartsStr[scriptCommand->bodyPart[1]].string, animModelInfo->animations[scriptCommand->animIndex[1]]->name ); Com_Printf( "\n" ); #endif + // 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 et.orig/src/game/bg_local.h etpub/src/game/bg_local.h --- et.orig/src/game/bg_local.h 2003-04-14 17:32:26.000000000 -0500 +++ etpub/src/game/bg_local.h 2005-03-29 16:27:47.000000000 -0600 @@ -75,3 +75,10 @@ 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 et.orig/src/game/bg_misc.c etpub/src/game/bg_misc.c --- et.orig/src/game/bg_misc.c 2003-08-28 15:43:22.000000000 -0500 +++ etpub/src/game/bg_misc.c 2005-03-24 09:44:05.000000000 -0600 @@ -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 ); @@ -4027,9 +4056,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 +4159,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 et.orig/src/game/bg_pmove.c etpub/src/game/bg_pmove.c --- et.orig/src/game/bg_pmove.c 2003-08-28 15:43:22.000000000 -0500 +++ etpub/src/game/bg_pmove.c 2005-03-29 16:27:47.000000000 -0600 @@ -15,8 +15,18 @@ #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 #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 #endif #define PM_IsSinglePlayerGame() (PM_GameType == GT_SINGLE_PLAYER || PM_GameType == GT_COOP) @@ -637,8 +647,10 @@ // JPW NERVE -- jumping in multiplayer uses and requires sprint juice (to prevent turbo skating, sprint + jumps) // don't allow jump accel //if (pm->cmd.serverTime - pm->pmext->jumpTime < 850) - if (pm->cmd.serverTime - pm->ps->jumpTime < 850) // Arnout: NOTE : TEMP DEBUG - return qfalse; + // josh: Allow a second quick jump if double jumping is on + if (pm->cmd.serverTime - pm->ps->jumpTime < 850 && (!PM_DOUBLE_JUMP || (pm->ps->pm_flags & PMF_DOUBLEJUMPING))) {// 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 @@ -666,7 +678,11 @@ pm->ps->pm_flags |= PMF_JUMP_HELD; pm->ps->groundEntityNum = ENTITYNUM_NONE; - pm->ps->velocity[2] = JUMP_VELOCITY; + if (pm->cmd.serverTime - pm->ps->jumpTime < 850 ) { + pm->ps->velocity[2] = PM_DOUBLE_JUMP_HEIGHT*JUMP_VELOCITY; + } else { + pm->ps->velocity[2] = JUMP_VELOCITY; + } PM_AddEvent( EV_JUMP ); if ( pm->cmd.forwardmove >= 0 ) { @@ -727,6 +743,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 @@ -772,11 +927,13 @@ // 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 ) { + if(((pm->ps->pm_flags & PMF_DUCKED && + pm->cmd.doubleTap == DT_FORWARD) || + (pm->cmd.wbuttons & WBUTTON_PRONE)) && + pm->cmd.serverTime - -pm->pmext->proneTime > 750) { + vec3_t org, flatforward, point; trace_t trace; - // 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]; @@ -812,6 +969,7 @@ pm->ps->eFlags |= EF_PRONE; pm->pmext->proneTime = pm->cmd.serverTime; // timestamp 'go prone' pm->pmext->proneGroundTime = pm->cmd.serverTime; + pm->maxs[2] = pm->ps->crouchMaxZ; } } } @@ -822,7 +980,11 @@ pm->ps->pm_type == PM_DEAD || pm->ps->eFlags & EF_MOUNTEDTANK || 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 @@ -833,7 +995,6 @@ 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 ) { @@ -887,9 +1048,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 ); @@ -1145,6 +1309,36 @@ float scale; usercmd_t cmd; + if ( PM_DOUBLE_JUMP && + !(pm->ps->pm_flags & PMF_DOUBLEJUMPING) + && pm->ps->velocity[2] > 0// Only on the up, like shrub + && PM_CheckJump () ) { + 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; @@ -1423,6 +1617,7 @@ VectorNormalize (pm->ps->velocity); VectorScale (pm->ps->velocity, forward, pm->ps->velocity); } + } @@ -1801,6 +1996,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) @@ -1955,14 +2151,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; @@ -2925,6 +3120,7 @@ */ void PM_CoolWeapons( void ) { int wp; + int maxHeat; // rain - for #172 for(wp=0;wpps->weapon) { if( pm->ps->persistant[PERS_HWEAPON_USE] || pm->ps->eFlags & EF_MOUNTEDTANK ) { - pm->ps->curWeapHeat = ( ( (float)pm->ps->weapHeat[WP_DUMMY_MG42] / MAX_MG42_HEAT) ) * 255.0f; + // rain - floor to prevent 8-bit wrap + pm->ps->curWeapHeat = floor( ( ( (float)pm->ps->weapHeat[WP_DUMMY_MG42] / MAX_MG42_HEAT) ) * 255.0f ); } else { - pm->ps->curWeapHeat = ( ( (float)pm->ps->weapHeat[pm->ps->weapon] / (float)GetAmmoTableData(pm->ps->weapon)->maxHeat) ) * 255.0f; + // rain - #172 - don't divide by 0 + maxHeat = GetAmmoTableData(pm->ps->weapon)->maxHeat; + // rain - floor to prevent 8-bit wrap + if (maxHeat != 0) + pm->ps->curWeapHeat = floor( ( ( (float)pm->ps->weapHeat[pm->ps->weapon] / (float)maxHeat) ) * 255.0f); + else + pm->ps->curWeapHeat = 0; } // if(pm->ps->weapHeat[pm->ps->weapon]) @@ -3128,7 +3331,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(); } @@ -3149,7 +3352,8 @@ if( pm->ps->weapHeat[WP_DUMMY_MG42] < 0 ) pm->ps->weapHeat[WP_DUMMY_MG42] = 0; - pm->ps->curWeapHeat = ( ( (float)pm->ps->weapHeat[WP_DUMMY_MG42] / MAX_MG42_HEAT) ) * 255.0f; + // rain - floor() to prevent 8-bit wrap + pm->ps->curWeapHeat = floor( ( ( (float)pm->ps->weapHeat[WP_DUMMY_MG42] / MAX_MG42_HEAT) ) * 255.0f ); } if( pm->ps->weaponTime > 0 ) { @@ -3211,7 +3415,11 @@ if( pm->ps->weapHeat[WP_DUMMY_MG42] < 0 ) pm->ps->weapHeat[WP_DUMMY_MG42] = 0; - pm->ps->curWeapHeat = ( ( (float)pm->ps->weapHeat[WP_DUMMY_MG42] / MAX_MG42_HEAT) ) * 255.0f; + // rain - floor() to prevent 8-bit wrap + //pm->ps->curWeapHeat = floor( ( (float)pm->ps->weapHeat[WP_DUMMY_MG42] / MAX_MG42_HEAT) ) * 255.0f; + // tjw: reverse rain's fix since it always sets curWeapHeat to 0. + // is 8-bit wrap even an issue here? + pm->ps->curWeapHeat = ( (float)pm->ps->weapHeat[WP_DUMMY_MG42] / MAX_MG42_HEAT) * 255.0f; } if( pm->ps->weaponTime > 0 ) { @@ -3418,9 +3626,26 @@ if ( pm->ps->weapon == WP_LUGER || pm->ps->weapon == WP_COLT || pm->ps->weapon == WP_SILENCER || pm->ps->weapon == WP_SILENCED_COLT || pm->ps->weapon == WP_KAR98 || pm->ps->weapon == WP_K43 || pm->ps->weapon == WP_CARBINE || pm->ps->weapon == WP_GARAND || pm->ps->weapon == WP_GARAND_SCOPE || pm->ps->weapon == WP_K43_SCOPE || BG_IsAkimboWeapon( pm->ps->weapon ) ) { + // rain - bug #11 - this is wrong, the frame where BUTTON_ATTACK is up + // will eventually be outside of the pmove loop + // rain - XXX - reverted to this behavior: it seems that my other prediction + // fixes have made this work properly, and the other method is a frame + // or two behind. (#275) + // rain - moved releasedFire into pmext instead of ps + // tjw - left releasedFire in ps for now + if ( pm->ps->releasedFire ) { - if ( (pm->cmd.buttons & BUTTON_ATTACK) && pm->ps->weaponTime <= 150 ) { - pm->ps->weaponTime = 0; + if ( (pm->cmd.buttons & BUTTON_ATTACK) ) { + // rain - akimbo weapons only have a 200ms delay, so + // use a shorter time for quickfire (#255) + + if (BG_IsAkimboWeapon(pm->ps->weapon)) { + if (pm->ps->weaponTime <= 50) + pm->ps->weaponTime = 0; + } else { + if (pm->ps->weaponTime <= 150) + pm->ps->weaponTime = 0; + } } } else if (!(pm->cmd.buttons & BUTTON_ATTACK)) { pm->ps->releasedFire = qtrue; @@ -3678,10 +3903,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; } } @@ -4121,10 +4354,10 @@ addTime = GetAmmoTableData(pm->ps->weapon)->nextShotTime; if( !pm->ps->ammoclip[BG_FindClipForWeapon(pm->ps->weapon)] ) { - if( akimboFire ) + if( !akimboFire ) addTime = 2 * GetAmmoTableData(pm->ps->weapon)->nextShotTime; } else if( !pm->ps->ammoclip[BG_FindClipForWeapon(BG_AkimboSidearm(pm->ps->weapon))] ) { - if( !akimboFire ) + if( akimboFire ) addTime = 2 * GetAmmoTableData(pm->ps->weapon)->nextShotTime; } @@ -4474,7 +4707,14 @@ temp = cmd->angles[1] + ps->delta_angles[1]; if( ps->stats[STAT_DEAD_YAW] == 999 ) ps->stats[STAT_DEAD_YAW] = SHORT2ANGLE(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 ); @@ -4494,7 +4734,7 @@ } ps->viewangles[i] = SHORT2ANGLE(temp); } - + if( BG_PlayerMounted(ps->eFlags) ) { float yaw, oldYaw; float degsSec = MG42_YAWSPEED; @@ -5090,7 +5330,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 @@ -5150,17 +5389,23 @@ pm->ps->eFlags &= ~(EF_FIRING | EF_ZOOMING); if( pm->cmd.wbuttons & WBUTTON_ZOOM && pm->ps->stats[STAT_HEALTH] >= 0 && !( pm->ps->weaponDelay ) ) { - if(pm->ps->stats[STAT_KEYS] & (1<ps->weapon)) { // don't allow binocs if using the sniper scope - if(!BG_PlayerMounted(pm->ps->eFlags)) { // or if mounted on a weapon - 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; - } + if(pm->ps->stats[STAT_KEYS] & (1<ps->weapon) && // don't allow binocs if using the sniper scope + !BG_PlayerMounted(pm->ps->eFlags) && // or if mounted on a weapon + // rain - don't allow binocs w/ mounted mob. MG42 or mortar + // either. + pm->ps->weapon != WP_MOBILE_MG42_SET && + pm->ps->weapon != WP_MORTAR_SET) { + + 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; } } @@ -5315,14 +5560,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(); } @@ -5484,8 +5729,13 @@ } } else { - if ( msec > 66 ) { - msec = 66; + // rain - this was 66 (15fps), but I've changed it to + // 50 (20fps, max rate of mg42) to alleviate some of the + // framerate dependency with the mg42. + // in reality, this should be split according to sv_fps, + // and pmove() shouldn't handle weapon firing + if ( msec > 50 ) { + msec = 50; } } pmove->cmd.serverTime = pmove->ps->commandTime + msec; @@ -5496,6 +5746,12 @@ } } + // rain - sanity check weapon heat + if (pmove->ps->curWeapHeat > 255) + pmove->ps->curWeapHeat = 255; + else if (pmove->ps->curWeapHeat < 0) + pmove->ps->curWeapHeat = 0; + //PM_CheckStuck(); if ( (pm->ps->stats[STAT_HEALTH] <= 0 || pm->ps->pm_type == PM_DEAD ) && pml.groundTrace.surfaceFlags & SURF_MONSTERSLICK ) diff -urN --exclude=.svn et.orig/src/game/bg_public.h etpub/src/game/bg_public.h --- et.orig/src/game/bg_public.h 2003-06-23 14:13:46.000000000 -0500 +++ etpub/src/game/bg_public.h 2005-03-25 11:02:05.000000000 -0600 @@ -417,10 +417,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 { @@ -459,6 +460,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*/) @@ -651,6 +654,7 @@ #define EF_BOUNCE_HALF 0x08000000 // for missiles #define EF_MOVER_STOP 0x10000000 // will push otherwise // (SA) moved down to make space for one more client flag #define EF_MOVER_BLOCKED 0x20000000 // mover was blocked dont lerp on the client // xkan, moved down to make space for client flag +#define EF_PLAYDEAD 0x40000000 // player looks dead #define BG_PlayerMounted( eFlags ) (( eFlags & EF_MG42_ACTIVE ) || ( eFlags & EF_MOUNTEDTANK ) || ( eFlags & EF_AAGUN_ACTIVE )) @@ -813,6 +817,17 @@ // 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 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 @@ -851,7 +866,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]; diff -urN --exclude=.svn et.orig/src/game/g_active.c etpub/src/game/g_active.c --- et.orig/src/game/g_active.c 2003-08-26 16:20:40.000000000 -0500 +++ etpub/src/game/g_active.c 2005-03-30 16:20:45.000000000 -0600 @@ -1,6 +1,8 @@ #include "g_local.h" +void G_PredictPlayerMove( gentity_t *ent, float frametime ); + /* =============== G_DamageFeedback @@ -17,7 +19,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 +377,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; } @@ -563,7 +568,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 ); @@ -599,7 +606,8 @@ client->timeResidual -= 1000; // 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; if ( ent->health > client->ps.stats[STAT_MAX_HEALTH] * 1.1){ @@ -618,6 +626,10 @@ } } } + + // notify client that they are playing dead + if(client->ps.eFlags & EF_PLAYDEAD && ent->health > 0) + CP("cp \"Playing Dead\" 1"); } /* @@ -655,9 +667,13 @@ gclient_t *client; int damage; vec3_t dir; + gentity_t *victim; + int kb_time = 0; client = ent->client; + victim = &level.gentities[ent->s.groundEntityNum]; + if ( oldEventSequence < client->ps.eventSequence - MAX_EVENTS ) { oldEventSequence = client->ps.eventSequence - MAX_EVENTS; } @@ -673,7 +689,7 @@ //case EV_FALL_DMG_30: case EV_FALL_DMG_50: //case EV_FALL_DMG_75: - + if ( ent->s.eType != ET_PLAYER ) { break; // not in the player model } @@ -684,34 +700,51 @@ else if (event == EV_FALL_DMG_50) { damage = 50; - ent->client->ps.pm_time = 1000; - ent->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; - VectorClear (ent->client->ps.velocity); + 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; - VectorClear (ent->client->ps.velocity); + 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; - VectorClear (ent->client->ps.velocity); + 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; - VectorClear (ent->client->ps.velocity); + kb_time = 250; } else damage = 5; // never used + + 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 && + victim->s.eType == ET_PLAYER && + g_goomba.integer) { + + if(kb_time) { + victim->client->ps.pm_time = kb_time; + victim->client->ps.pm_flags |= PMF_TIME_KNOCKBACK; + } + victim->pain_debounce_time = level.time + 200; // no normal pain sound + G_Damage (victim, ent, ent, NULL, NULL, (damage*g_goomba.integer*2), 0, MOD_CRUSH); + G_AddEvent(victim, EV_GENERAL_SOUND, + G_SoundIndex("sound/world/debris1.wav")); + // faller has a soft landing + damage *= 0.2f; + } + ent->pain_debounce_time = level.time + 200; // no normal pain sound G_Damage (ent, NULL, NULL, NULL, NULL, damage, 0, MOD_FALLING); break; @@ -890,10 +923,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 ); @@ -916,6 +954,22 @@ // G_Printf("serverTime >>>>>\n" ); } +//unlagged - backward reconciliation #4 + // frameOffset should be about the number of milliseconds into a frame + // this command packet was received, depending on how fast the server + // does a G_RunFrame() + //client->frameOffset = trap_Milliseconds() - level.frameStartTime; + // josh: not sure if this is right . . . + client->frameOffset = trap_Milliseconds() - level.time; +//unlagged - backward reconciliation #4 + +//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 + + msec = ucmd->serverTime - client->ps.commandTime; // following others may result in bad times, but we still want // to check for follow toggles @@ -967,6 +1021,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 @@ -993,11 +1052,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,13 +1219,22 @@ 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, ent->client->ps.commandTime, qtrue ); } 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 @@ -1192,7 +1268,10 @@ VectorCopy( ent->client->ps.origin, ent->r.currentOrigin ); // store the client's current position for antilag traces - G_StoreClientPosition( ent ); + // 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 ); @@ -1231,7 +1310,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 ); @@ -1288,9 +1368,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 ) @@ -1353,6 +1438,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) { @@ -1367,6 +1459,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 ) @@ -1602,6 +1699,10 @@ */ void ClientEndFrame( gentity_t *ent ) { int i; +//unlagged - smooth clients #1 + int frames; +//unlagged - smooth clients #1 + // used for informing of speclocked teams. @@ -1690,27 +1791,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, ent->client->ps.commandTime, qtrue ); - } 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, qtrue ); - } + //} //SendPendingPredictableEvents( &ent->client->ps ); @@ -1724,7 +1833,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 ); } @@ -1735,4 +1848,35 @@ // run entity scripting G_Script_ScriptRun( ent ); + +//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; + + // don't extrapolate more than two frames + if ( frames > 2 ) { + frames = 2; + + // if they missed more than two in a row, show the phone jack + // josh: the phone jack is drawn between walls in ET, turn this + // off since you'd have to change the client + //ent->client->ps.eFlags |= EF_CONNECTION; + //ent->s.eFlags |= EF_CONNECTION; + } + + // did the client miss any frames? + if ( frames > 0 && g_skipCorrection.integer ) { + // yep, missed one or more, so extrapolate the player's movement + G_PredictPlayerMove( ent, (float)frames / sv_fps.integer ); + // save network bandwidth + SnapVector( ent->s.pos.trBase ); + } +//unlagged - smooth clients #1 + + // 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 et.orig/src/game/g_antilag.c etpub/src/game/g_antilag.c --- et.orig/src/game/g_antilag.c 2003-09-02 15:50:26.000000000 -0500 +++ etpub/src/game/g_antilag.c 2005-03-30 16:20:45.000000000 -0600 @@ -1,46 +1,113 @@ #include "g_local.h" +///* +//============= +//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( float frac, vec3_t start, vec3_t end, 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 or teleporting in or out of the tank + if((ent->s.eFlags & EF_MOUNTEDTANK) + || (ent->s.eFlags & EF_TELEPORT_BIT)) + return qfalse; + if((ent->client->ps.eFlags & EF_MOUNTEDTANK) + || (ent->client->ps.eFlags & EF_TELEPORT_BIT)) + return qfalse; + + return qtrue; +} + void G_StoreClientPosition( gentity_t* ent ) { - int top, currentTime; + int top; - 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; - } - - top = ent->client->topMarker; + if(!G_AntilagSafe(ent)) return; - // new frame, mark the old marker's time as the end of the last frame - if( ent->client->clientMarkers[top].time < level.time) { - ent->client->clientMarkers[top].time = level.previousTime; - top = ent->client->topMarker = ent->client->topMarker == MAX_CLIENT_MARKERS - 1 ? 0 : ent->client->topMarker + 1; + ent->client->topMarker++; + if ( ent->client->topMarker >= MAX_CLIENT_MARKERS ) { + ent->client->topMarker = 0; } - currentTime = level.previousTime + trap_Milliseconds() - level.frameTime; - - if(currentTime > level.time) { - // owwie, we just went into the next frame... let's push them back - currentTime = level.time; - } + top = ent->client->topMarker; VectorCopy( ent->r.mins, ent->client->clientMarkers[top].mins ); VectorCopy( ent->r.maxs, ent->client->clientMarkers[top].maxs ); - VectorCopy( ent->r.currentOrigin, ent->client->clientMarkers[top].origin ); + // 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].servertime = level.time; - ent->client->clientMarkers[top].time = currentTime; + ent->client->clientMarkers[top].time = 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; i = j = ent->client->topMarker; do { @@ -56,9 +123,20 @@ return; } - 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)(ent->client->clientMarkers[j].time - time)) / (ent->client->clientMarkers[j].time - ent->client->clientMarkers[i].time); @@ -66,26 +144,100 @@ LerpPosition(ent->client->clientMarkers[j].origin, ent->client->clientMarkers[i].origin, frac, ent->r.currentOrigin); LerpPosition(ent->client->clientMarkers[j].mins, ent->client->clientMarkers[i].mins, frac, ent->r.mins); LerpPosition(ent->client->clientMarkers[j].maxs, ent->client->clientMarkers[i].maxs, frac, ent->r.maxs); + + // These are for Head / Legs + ent->client->ps.viewangles[0] = LerpAngle( + ent->client->clientMarkers[j].viewangles[0], + ent->client->clientMarkers[i].viewangles[0], + frac); + ent->client->ps.viewangles[1] = LerpAngle( + ent->client->clientMarkers[j].viewangles[1], + ent->client->clientMarkers[i].viewangles[1], + frac); + ent->client->ps.viewangles[2] = LerpAngle( + ent->client->clientMarkers[j].viewangles[2], + ent->client->clientMarkers[i].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 ( g_debugBullets.integer >= 2 && 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 ) { + + 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 ); - ent->client->backupMarker.servertime = 0; + //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 ); } } @@ -96,47 +248,45 @@ 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, ent ); + } else { + G_ReAdjustSingleClientPosition( list ); } + } } void G_ResetMarkers( gentity_t* ent ) { int i, time; - char buffer[256]; float period; + int eFlags; - trap_Cvar_VariableStringBuffer("sv_fps", buffer, sizeof(buffer)-1); + period = 1000.f/sv_fps.integer; - period = atoi(buffer); - 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; + if((eFlags & EF_TELEPORT_BIT)) + eFlags &= ~EF_TELEPORT_BIT; ent->client->topMarker = MAX_CLIENT_MARKERS - 1; - for ( i = MAX_CLIENT_MARKERS - 1, time = level.time; i >= 0; i--, time -= period ) { + for ( i = ent->client->topMarker, time = level.time; i >= 0; i--, time -= period ) { ent->client->clientMarkers[i].servertime = time; ent->client->clientMarkers[i].time = time; VectorCopy( ent->r.mins, ent->client->clientMarkers[i].mins ); VectorCopy( ent->r.maxs, ent->client->clientMarkers[i].maxs ); VectorCopy( ent->r.currentOrigin, ent->client->clientMarkers[i].origin ); + 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; } } @@ -151,9 +301,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 ); @@ -200,8 +350,8 @@ // Run a trace with players in historical positions. void G_HistoricalTrace( gentity_t* ent, trace_t *results, const vec3_t start, const vec3_t mins, const vec3_t maxs, const vec3_t end, int passEntityNum, int contentmask ) { - trace_t tr; - gentity_t *other; + //trace_t tr; + //gentity_t *other; int res; vec3_t dir; @@ -230,19 +380,294 @@ G_AdjustClientPositions( ent, 0, qfalse ); - if( results->entityNum >= 0 && results->entityNum < MAX_CLIENTS && (other = &g_entities[results->entityNum])->inuse ) { - G_AttachBodyParts( ent ) ; + // g_antilag 2: do the extra occlusion test. Don't ever use this: evil + // Never do this + //if( g_antilag.integer == 2 && results->entityNum >= 0 && results->entityNum < MAX_CLIENTS && (other = &g_entities[results->entityNum])->inuse ) { + // G_AttachBodyParts( ent ) ; + + // trap_Trace( &tr, start, mins, maxs, other->client->ps.origin, passEntityNum, contentmask ); + // res = G_SwitchBodyPartEntity(&g_entities[results->entityNum]); + // POSITION_READJUST + + // if( tr.entityNum != results->entityNum ) { + // trap_Trace( results, start, mins, maxs, end, passEntityNum, contentmask ); + // res = G_SwitchBodyPartEntity(&g_entities[results->entityNum]); + // POSITION_READJUST + // } - trap_Trace( &tr, start, mins, maxs, other->client->ps.origin, passEntityNum, contentmask ); - res = G_SwitchBodyPartEntity(&g_entities[results->entityNum]); - POSITION_READJUST + // G_DettachBodyParts(); + //} +} + +/* +=========================== +G_PredictPlayerClipVelocity + +Slide on the impacting surface +=========================== +*/ + +#ifndef OVERCLIP +#define OVERCLIP 1.001f +#endif + +void G_PredictPlayerClipVelocity( vec3_t in, vec3_t normal, vec3_t out ) { + float backoff; + + // find the magnitude of the vector "in" along "normal" + backoff = DotProduct (in, normal); + + // tilt the plane a bit to avoid floating-point error issues + if ( backoff < 0 ) { + backoff *= OVERCLIP; + } else { + backoff /= OVERCLIP; + } + + // slide along + VectorMA( in, -backoff, normal, out ); +} + +/* +======================== +G_PredictPlayerSlideMove + +Advance the given entity frametime seconds, sliding as appropriate +======================== +*/ +#define MAX_CLIP_PLANES 5 + +qboolean G_PredictPlayerSlideMove( gentity_t *ent, float frametime ) { + int bumpcount, numbumps; + vec3_t dir; + float d; + int numplanes; + vec3_t planes[MAX_CLIP_PLANES]; + vec3_t primal_velocity, velocity, origin; + vec3_t clipVelocity; + int i, j, k; + trace_t trace; + vec3_t end; + float time_left; + float into; + vec3_t endVelocity; + vec3_t endClipVelocity; + vec3_t worldUp = { 0.0f, 0.0f, 1.0f }; + + numbumps = 4; + + VectorCopy( ent->s.pos.trDelta, primal_velocity ); + VectorCopy( primal_velocity, velocity ); + VectorCopy( ent->s.pos.trBase, origin ); + + VectorCopy( velocity, endVelocity ); + + time_left = frametime; + + numplanes = 0; + + for ( bumpcount = 0; bumpcount < numbumps; bumpcount++ ) { - if( tr.entityNum != results->entityNum ) { - trap_Trace( results, start, mins, maxs, end, passEntityNum, contentmask ); - res = G_SwitchBodyPartEntity(&g_entities[results->entityNum]); - POSITION_READJUST + // calculate position we are trying to move to + VectorMA( origin, time_left, velocity, end ); + + // see if we can make it there + trap_Trace( &trace, origin, ent->r.mins, ent->r.maxs, end, ent->s.number, ent->clipmask ); + + if (trace.allsolid) { + // entity is completely trapped in another solid + VectorClear( velocity ); + VectorCopy( origin, ent->s.pos.trBase ); + return qtrue; } - G_DettachBodyParts(); + if (trace.fraction > 0) { + // actually covered some distance + VectorCopy( trace.endpos, origin ); + } + + if (trace.fraction == 1) { + break; // moved the entire distance + } + + time_left -= time_left * trace.fraction; + + if ( numplanes >= MAX_CLIP_PLANES ) { + // this shouldn't really happen + VectorClear( velocity ); + VectorCopy( origin, ent->s.pos.trBase ); + return qtrue; + } + + // + // if this is the same plane we hit before, nudge velocity + // out along it, which fixes some epsilon issues with + // non-axial planes + // + for ( i = 0; i < numplanes; i++ ) { + if ( DotProduct( trace.plane.normal, planes[i] ) > 0.99 ) { + VectorAdd( trace.plane.normal, velocity, velocity ); + break; + } + } + + if ( i < numplanes ) { + continue; + } + + VectorCopy( trace.plane.normal, planes[numplanes] ); + numplanes++; + + // + // modify velocity so it parallels all of the clip planes + // + + // find a plane that it enters + for ( i = 0; i < numplanes; i++ ) { + into = DotProduct( velocity, planes[i] ); + if ( into >= 0.1 ) { + continue; // move doesn't interact with the plane + } + + // slide along the plane + G_PredictPlayerClipVelocity( velocity, planes[i], clipVelocity ); + + // slide along the plane + G_PredictPlayerClipVelocity( endVelocity, planes[i], endClipVelocity ); + + // see if there is a second plane that the new move enters + for ( j = 0; j < numplanes; j++ ) { + if ( j == i ) { + continue; + } + + if ( DotProduct( clipVelocity, planes[j] ) >= 0.1 ) { + continue; // move doesn't interact with the plane + } + + // try clipping the move to the plane + G_PredictPlayerClipVelocity( clipVelocity, planes[j], clipVelocity ); + G_PredictPlayerClipVelocity( endClipVelocity, planes[j], endClipVelocity ); + + // see if it goes back into the first clip plane + if ( DotProduct( clipVelocity, planes[i] ) >= 0 ) { + continue; + } + + // slide the original velocity along the crease + CrossProduct( planes[i], planes[j], dir ); + VectorNormalize( dir ); + d = DotProduct( dir, velocity ); + VectorScale( dir, d, clipVelocity ); + + CrossProduct( planes[i], planes[j], dir ); + VectorNormalize( dir ); + d = DotProduct( dir, endVelocity ); + VectorScale( dir, d, endClipVelocity ); + + // see if there is a third plane the the new move enters + for ( k = 0; k < numplanes; k++ ) { + if ( k == i || k == j ) { + continue; + } + + if ( DotProduct( clipVelocity, planes[k] ) >= 0.1 ) { + continue; // move doesn't interact with the plane + } + + // stop dead at a tripple plane interaction + VectorClear( velocity ); + VectorCopy( origin, ent->s.pos.trBase ); + return qtrue; + } + } + + // if we have fixed all interactions, try another move + VectorCopy( clipVelocity, velocity ); + VectorCopy( endClipVelocity, endVelocity ); + break; + } + } + + VectorCopy( endVelocity, velocity ); + VectorCopy( origin, ent->s.pos.trBase ); + + return (bumpcount != 0); +} + + +/* +============================ +G_PredictPlayerStepSlideMove + +Advance the given entity frametime seconds, stepping and sliding as appropriate +============================ +*/ +#ifndef STEPSIZE +#define STEPSIZE 18 +#endif + +void G_PredictPlayerStepSlideMove( gentity_t *ent, float frametime ) { + vec3_t start_o, start_v, down_o, down_v; + vec3_t down, up; + trace_t trace; + float stepSize; + + VectorCopy (ent->s.pos.trBase, start_o); + VectorCopy (ent->s.pos.trDelta, start_v); + + if ( !G_PredictPlayerSlideMove( ent, frametime ) ) { + // not clipped, so forget stepping + return; + } + + VectorCopy( ent->s.pos.trBase, down_o); + VectorCopy( ent->s.pos.trDelta, down_v); + + VectorCopy (start_o, up); + up[2] += STEPSIZE; + + // test the player position if they were a stepheight higher + trap_Trace( &trace, start_o, ent->r.mins, ent->r.maxs, up, ent->s.number, ent->clipmask ); + if ( trace.allsolid ) { + return; // can't step up + } + + stepSize = trace.endpos[2] - start_o[2]; + + // try slidemove from this position + VectorCopy( trace.endpos, ent->s.pos.trBase ); + VectorCopy( start_v, ent->s.pos.trDelta ); + + G_PredictPlayerSlideMove( ent, frametime ); + + // push down the final amount + VectorCopy( ent->s.pos.trBase, down ); + down[2] -= stepSize; + trap_Trace( &trace, ent->s.pos.trBase, ent->r.mins, ent->r.maxs, down, ent->s.number, ent->clipmask ); + if ( !trace.allsolid ) { + VectorCopy( trace.endpos, ent->s.pos.trBase ); + } + if ( trace.fraction < 1.0 ) { + G_PredictPlayerClipVelocity( ent->s.pos.trDelta, trace.plane.normal, ent->s.pos.trDelta ); + } +} + +/* +=================== +G_PredictPlayerMove + +Advance the given entity frametime seconds, stepping and sliding as appropriate + +This is the entry point to the server-side-only prediction code +=================== +*/ +void G_PredictPlayerMove( gentity_t *ent, float frametime ) { + // Don't skip correct dead bodies, etc. + if (ent->client->ps.pm_flags & PMF_LIMBO || + !(ent->client->ps.pm_type == PM_NORMAL) || + ent->client->ps.pm_type == PM_DEAD) { + return; } + G_PredictPlayerStepSlideMove( ent, frametime ); } diff -urN --exclude=.svn et.orig/src/game/g_client.c etpub/src/game/g_client.c --- et.orig/src/game/g_client.c 2003-08-28 15:43:22.000000000 -0500 +++ etpub/src/game/g_client.c 2005-03-29 17:17:21.000000000 -0600 @@ -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); @@ -648,7 +746,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 +886,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 +1328,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; - if ( client->sess.sessionTeam == TEAM_SPECTATOR ) + 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 ) return; // Reset special weapon time @@ -808,13 +1348,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,279 +1374,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; - } - } 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 ) { @@ -1325,6 +1631,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"); @@ -1415,8 +1726,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 ); + } } @@ -1444,11 +1762,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 ]; @@ -1463,6 +1782,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) ) { @@ -1502,6 +1826,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; @@ -1513,11 +1864,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; @@ -1525,15 +1875,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 ) { @@ -1625,10 +2005,25 @@ // 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; + + // 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); } @@ -1647,11 +2042,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 ); } @@ -1676,14 +2079,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 ) { @@ -1721,27 +2136,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) { @@ -1845,7 +2270,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; @@ -1915,6 +2344,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 @@ -1934,10 +2366,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; @@ -1964,6 +2398,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; @@ -2000,7 +2435,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; @@ -2036,7 +2472,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; @@ -2047,7 +2483,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; @@ -2055,7 +2491,7 @@ client->sess.playerWeapon2 = client->sess.latchPlayerWeapon2; - if( update ) { + if( update || teamChange ) { ClientUserinfoChanged( index ); } } @@ -2065,8 +2501,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 @@ -2089,11 +2527,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 ); @@ -2209,9 +2652,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 ); @@ -2352,3 +2794,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)) { + return 18; + } + else if((hitEnt->client->ps.eFlags & EF_MOUNTEDTANK)) { + //return 48; + return hitEnt->r.maxs[2]; + } + else if((g_hitboxes.integer & HBF_STANDING)) { + return 36; + } + return hitEnt->r.maxs[2]; +} + diff -urN --exclude=.svn et.orig/src/game/g_cmds.c etpub/src/game/g_cmds.c --- et.orig/src/game/g_cmds.c 2003-08-28 15:43:22.000000000 -0500 +++ etpub/src/game/g_cmds.c 2005-03-30 16:20:23.000000000 -0600 @@ -4,6 +4,149 @@ 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_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_PlayDead + */ +void G_PlayDead(gentity_t *ent) +{ + + if(!ent->client) return; + if(!g_playDead.integer) return; + if(ent->health < 0) return; + 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); + */ + } +} + +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=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"); + } +} + /* ================== G_SendScore @@ -136,41 +279,65 @@ return qtrue; } +// josh: tjw moved the declaration to q_shared.h, q_shared.c needs this +// so I moved it to q_shared.c +///* +//================== +//ConcatArgs +//================== +//*/ +//char *ConcatArgs( int start ) { +// int i, c, tlen; +// static char line[MAX_STRING_CHARS]; +// int len; +// char arg[MAX_STRING_CHARS]; +// +// len = 0; +// c = trap_Argc(); +// for ( i = start ; i < c ; i++ ) { +// trap_Argv( i, arg, sizeof( arg ) ); +// tlen = strlen( arg ); +// if ( len + tlen >= MAX_STRING_CHARS - 1 ) { +// break; +// } +// memcpy( line + len, arg, tlen ); +// len += tlen; +// if ( i != c - 1 ) { +// line[len] = ' '; +// len++; +// } +// } +// +// line[len] = 0; +// +// return line; +//} /* ================== -ConcatArgs +DecolorString + +Remove color characters ================== */ -char *ConcatArgs( int start ) { - int i, c, tlen; - static char line[MAX_STRING_CHARS]; - int len; - char arg[MAX_STRING_CHARS]; - - len = 0; - c = trap_Argc(); - for ( i = start ; i < c ; i++ ) { - trap_Argv( i, arg, sizeof( arg ) ); - tlen = strlen( arg ); - if ( len + tlen >= MAX_STRING_CHARS - 1 ) { - break; - } - memcpy( line + len, arg, tlen ); - len += tlen; - if ( i != c - 1 ) { - line[len] = ' '; - len++; +void DecolorString( char *in, char *out) +{ + while(*in) { + if(*in == 27 || *in == '^') { + in++; // skip color code + if(*in) in++; + continue; } + *out++ = *in++; } - - line[len] = 0; - - return line; + *out = 0; } /* ================== + +/* +================== SanitizeString Remove case and control characters @@ -198,6 +365,68 @@ /* ================== +ClientNumbersFromString + +Sets plist to an array of integers that represent client numbers that have +names that are a partial match for s. List is terminated by a -1. + +Returns number of matching clientids. +================== +*/ +int ClientNumbersFromString( char *s, int *plist) { + gclient_t *p; + int i, found = 0; + char s2[MAX_STRING_CHARS]; + char n2[MAX_STRING_CHARS]; + char *m; + qboolean is_slot = qtrue; + + *plist = -1; + + // if a number is provided, it might be a slot # + for(i=0; i '9') { + is_slot = qfalse; + break; + } + } + if(is_slot) { + i = atoi(s); + if(i >= 0 && i < level.maxclients) { + p = &level.clients[i]; + if(p->pers.connected == CON_CONNECTED || + p->pers.connected == CON_CONNECTING) { + + *plist++ = i; + *plist = -1; + return 1; + } + } + } + + // now look for name matches + SanitizeString(s, s2, qtrue); + if(strlen(s2) < 1) return 0; + for(i=0; i < level.maxclients; i++) { + p = &level.clients[i]; + if(p->pers.connected != CON_CONNECTED && + p->pers.connected != CON_CONNECTING) { + + continue; + } + SanitizeString(p->pers.netname, n2, qtrue); + m = strstr(n2, s2); + if(m != NULL) { + *plist++ = i; + found++; + } + } + *plist = -1; + return found; +} + +/* +================== ClientNumberFromString Returns a player number for either a number or name string @@ -672,6 +901,38 @@ } } + +void G_DropItems(gentity_t *self) +{ + gitem_t *item= NULL; + + // drop flag regardless + if (self->client->ps.powerups[PW_REDFLAG]) { + item = BG_FindItem("Red Flag"); + if (!item) + item = BG_FindItem("Objective"); + + self->client->ps.powerups[PW_REDFLAG] = 0; + } + if (self->client->ps.powerups[PW_BLUEFLAG]) { + item = BG_FindItem("Blue Flag"); + if (!item) + item = BG_FindItem("Objective"); + + self->client->ps.powerups[PW_BLUEFLAG] = 0; + } + + if (item) { + vec3_t launchvel = { 0, 0, 0 }; + gentity_t *flag = LaunchItem(item, self->r.currentOrigin, launchvel, self->s.number); + + flag->s.modelindex2 = self->s.otherEntityNum2;// JPW NERVE FIXME set player->otherentitynum2 with old modelindex2 from flag and restore here + flag->message = self->message; // DHM - Nerve :: also restore item name + // Clear out player's temp copies + self->s.otherEntityNum2 = 0; + self->message = NULL; + } +} /* ================= SetTeam @@ -685,6 +946,11 @@ int specClient; int respawnsLeft; + // if the team changing player is a shrubbot admin with the + // '5' flag, they can switch teams regardless of balance + if(G_shrubbot_permission(ent, SBF_FORCETEAMCHANGE)) + force = qtrue; + // // see what change is requested // @@ -788,14 +1054,22 @@ client->pers.teamState.state = TEAM_BEGIN; } - if ( oldTeam != TEAM_SPECTATOR ) { - if ( !(ent->client->ps.pm_flags & PMF_LIMBO) ) { - // Kill him (makes sure he loses flags, etc) - ent->flags &= ~FL_GODMODE; + + if(oldTeam != TEAM_SPECTATOR && + !(ent->client->ps.pm_flags & PMF_LIMBO) ) { + + ent->flags &= ~FL_GODMODE; + // tjw: if they're not dead, don't kill + if(g_teamChangeKills.integer || ent->health <= 0) { ent->client->ps.stats[STAT_HEALTH] = ent->health = 0; player_die (ent, ent, ent, 100000, MOD_SWITCHTEAM); } + else { + ent->client->ps.stats[STAT_HEALTH] = ent->health; + G_DropItems(ent); + } } + // they go to the end of the line for tournements if ( team == TEAM_SPECTATOR ) { client->sess.spectatorTime = level.time; @@ -866,10 +1140,12 @@ G_verifyMatchState(oldTeam); BotRecordTeamChange( clientNum ); + /* // Reset stats when changing teams if(team != oldTeam) { G_deleteStats(clientNum); } + */ G_UpdateSpawnCounts(); @@ -910,7 +1186,7 @@ } } } - + ent->client->pers.lastTeamChangeTime = level.time; return qtrue; } @@ -1029,24 +1305,62 @@ return cnt; } -qboolean G_IsWeaponDisabled( gentity_t* ent, weapon_t weapon ) { +qboolean G_IsWeaponDisabled( gentity_t* ent, weapon_t weapon, qboolean quiet ) { int count, wcount; if( ent->client->sess.sessionTeam == TEAM_SPECTATOR ) { return qtrue; } - if( !G_IsHeavyWeapon( weapon ) ) { - return qfalse; - } - count = G_TeamCount( ent, -1 ); wcount = G_TeamCount( ent, weapon ); - if( wcount >= ceil( count * g_heavyWeaponRestriction.integer * 0.01f ) ) { - return qtrue; + if(G_IsHeavyWeapon(weapon)) { + if( wcount >= ceil( count * g_heavyWeaponRestriction.integer * 0.01f ) ) { + return qtrue; + } } + switch(weapon) { + case WP_PANZERFAUST: + if(team_maxPanzers.integer == -1) return qfalse; + if(wcount >= team_maxPanzers.integer) { + if(!quiet) + CP("cp \"^1PANZERFAUST not available^7\" 1"); + return qtrue; + } + case WP_MOBILE_MG42: + if(team_maxMG42s.integer == -1) return qfalse; + if(wcount >= team_maxMG42s.integer) { + if(!quiet) + CP("cp \"^1MG42 not available^7\" 1"); + return qtrue; + } + case WP_FLAMETHROWER: + if(team_maxFlamers.integer == -1) return qfalse; + if(wcount >= team_maxFlamers.integer) { + CP("cp \"^1FLAMETHROWER not available^7\" 1"); + return qtrue; + } + case WP_MORTAR: + if(team_maxMortars.integer == -1) return qfalse; + if(wcount >= team_maxMortars.integer) { + if(!quiet) + CP("cp \"^1MORTAR not available^7\" 1"); + return qtrue; + } + case WP_GPG40: + case WP_CARBINE: + if(team_maxGrenLaunchers.integer == -1) return qfalse; + if(wcount >= team_maxGrenLaunchers.integer) { + if(!quiet) + CP("cp \"^1GRENADE LAUNCHER not available^7\" 1"); + return qtrue; + } + } + + + return qfalse; } @@ -1058,7 +1372,7 @@ changed = qtrue; } - if( !G_IsWeaponDisabled( ent, w1 ) ) { + if( !G_IsWeaponDisabled( ent, w1, qfalse ) ) { if( ent->client->sess.latchPlayerWeapon != w1 ) { ent->client->sess.latchPlayerWeapon = w1; changed = qtrue; @@ -1067,7 +1381,7 @@ if( ent->client->sess.latchPlayerWeapon != 0 ) { ent->client->sess.latchPlayerWeapon = 0; changed = qtrue; - } + } } if( updateclient && changed ) { @@ -1087,6 +1401,7 @@ char weap[4], weap2[4]; weapon_t w, w2; + if ( trap_Argc() < 2 ) { char *pszTeamName; @@ -1118,13 +1433,16 @@ w = atoi( weap ); w2 = atoi( weap2 ); - ent->client->sess.latchPlayerType = atoi( ptype ); - if( ent->client->sess.latchPlayerType < PC_SOLDIER || ent->client->sess.latchPlayerType > PC_COVERTOPS ) { - ent->client->sess.latchPlayerType = PC_SOLDIER; + // tjw: allow old-school q2 players to use the '/team r' + // or '/team b' commands without losing their class + if(*ptype) { + ent->client->sess.latchPlayerType = atoi( ptype ); } + + if( ent->client->sess.latchPlayerType < PC_SOLDIER || + ent->client->sess.latchPlayerType > PC_COVERTOPS ) { - if( ent->client->sess.latchPlayerType < PC_SOLDIER || ent->client->sess.latchPlayerType > PC_COVERTOPS ) { - ent->client->sess.latchPlayerType = PC_SOLDIER; + ent->client->sess.latchPlayerType = PC_SOLDIER; } if( !SetTeam( ent, s, qfalse, w, w2, qtrue ) ) { @@ -1221,6 +1539,7 @@ void Cmd_Follow_f( gentity_t *ent, unsigned int dwCommand, qboolean fValue ) { int i; char arg[MAX_TOKEN_CHARS]; + int pids[MAX_CLIENTS]; if ( trap_Argc() != 2 ) { if ( ent->client->sess.spectatorState == SPECTATOR_FOLLOW ) { @@ -1236,7 +1555,13 @@ } trap_Argv( 1, arg, sizeof( arg ) ); - i = ClientNumberFromString( ent, arg ); + // josh: Let /follow match partial names + // Use > instead of != since could be a team name + if(ClientNumbersFromString(arg, pids) > 1) { + CP("cpm \"Partial Name Matches more than 1 Player.\n\""); + return; + } + i = pids[0]; if ( i == -1 ) { if(!Q_stricmp(arg, "allies")) i = TEAM_ALLIES; else if(!Q_stricmp(arg, "axis")) i = TEAM_AXIS; @@ -1394,7 +1719,6 @@ G_Say ================== */ -#define MAX_SAY_TEXT 150 void G_SayTo( gentity_t *ent, gentity_t *other, int mode, int color, const char *name, const char *message, qboolean localize ) { @@ -1437,38 +1761,49 @@ char name[64]; // don't let text be too long for malicious reasons char text[MAX_SAY_TEXT]; + char censoredText[MAX_SAY_TEXT]; qboolean localize = qfalse; char *loc; + Q_strncpyz( text, chatText, sizeof(text) ); + if (g_censor.string[0]) { + SanitizeString(text, censoredText, qtrue); + if (G_CensorText(censoredText)) { + // like shrub, if the text is censored, + // it becomes colorless + Q_strncpyz( text, censoredText, sizeof(text) ); + G_CensorPenalize(ent); + } + } + switch ( mode ) { default: case SAY_ALL: - G_LogPrintf( "say: %s: %s\n", ent->client->pers.netname, chatText ); + G_LogPrintf( "say: %s: %s\n", ent->client->pers.netname, text ); Com_sprintf (name, sizeof(name), "%s%c%c: ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE ); color = COLOR_GREEN; break; case SAY_BUDDY: localize = qtrue; - G_LogPrintf( "saybuddy: %s: %s\n", ent->client->pers.netname, chatText ); + G_LogPrintf( "saybuddy: %s: %s\n", ent->client->pers.netname, text ); loc = BG_GetLocationString( ent->r.currentOrigin ); Com_sprintf (name, sizeof(name), "[lof](%s%c%c) (%s): ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, loc); color = COLOR_YELLOW; break; case SAY_TEAM: localize = qtrue; - G_LogPrintf( "sayteam: %s: %s\n", ent->client->pers.netname, chatText ); + G_LogPrintf( "sayteam: %s: %s\n", ent->client->pers.netname, text ); loc = BG_GetLocationString( ent->r.currentOrigin ); Com_sprintf (name, sizeof(name), "[lof](%s%c%c) (%s): ", ent->client->pers.netname, Q_COLOR_ESCAPE, COLOR_WHITE, loc); color = COLOR_CYAN; break; case SAY_TEAMNL: - G_LogPrintf( "sayteamnl: %s: %s\n", ent->client->pers.netname, chatText ); + G_LogPrintf( "sayteamnl: %s: %s\n", ent->client->pers.netname, text ); Com_sprintf (name, sizeof(name), "(%s^7): ", ent->client->pers.netname); color = COLOR_CYAN; break; } - Q_strncpyz( text, chatText, sizeof(text) ); if ( target ) { if( !(target->client->sess.ignoreClients[(ent-g_entities) / 8] & (1 << ((ent-g_entities) % 8))) ) { @@ -1489,6 +1824,8 @@ G_SayTo( ent, other, mode, color, name, text, localize ); } } + + G_shrubbot_cmd_check(ent); } @@ -1500,7 +1837,13 @@ void Cmd_Say_f( gentity_t *ent, int mode, qboolean arg0 ) { if(trap_Argc() < 2 && !arg0) return; - G_Say(ent, NULL, mode, ConcatArgs(((arg0) ? 0 : 1))); + if(g_privateMessages.integer && + strstr(Q_SayConcatArgs(0), "say /m ")) { + + G_PrivateMessage(ent); + } + else + G_Say(ent, NULL, mode, ConcatArgs(((arg0) ? 0 : 1))); } extern void BotRecordVoiceChat( int client, int destclient, const char *id, int mode, qboolean noResponse ); @@ -2414,55 +2757,272 @@ // Rafael /* ================== -Cmd_Activate_f +G_UniformSteal formerly known as Cmd_Activate2_f ================== */ -qboolean Do_Activate2_f(gentity_t *ent, gentity_t *traceEnt) { +qboolean G_UniformSteal(gentity_t *ent, gentity_t *traceEnt) +{ qboolean found = qfalse; + if(traceEnt->activator) return qfalse; // already used corpse + if(ent->client->sess.playerType != PC_COVERTOPS) + return qfalse; + if(ent->client->ps.powerups[PW_OPS_DISGUISED]) + return qfalse; + if(ent->client->ps.powerups[PW_BLUEFLAG] || + ent->client->ps.powerups[PW_REDFLAG]) + return qfalse; + if(BODY_TEAM(traceEnt) == ent->client->sess.sessionTeam) + return qfalse; + if( BODY_VALUE(traceEnt) < 250 ) { + BODY_VALUE(traceEnt) += 5; + return qfalse; + } - if( ent->client->sess.playerType == PC_COVERTOPS && !ent->client->ps.powerups[PW_OPS_DISGUISED] ) { - if( !ent->client->ps.powerups[PW_BLUEFLAG] && !ent->client->ps.powerups[PW_REDFLAG] ) { - if( traceEnt->s.eType == ET_CORPSE ) { - if( BODY_TEAM(traceEnt) < 4 && BODY_TEAM(traceEnt) != ent->client->sess.sessionTeam ) { - found = qtrue; + traceEnt->nextthink = traceEnt->timestamp + BODY_TIME(BODY_TEAM(traceEnt)); - if( BODY_VALUE(traceEnt) >= 250 ) { + //BG_AnimScriptEvent( &ent->client->ps, ent->client->pers.character->animModelInfo, ANIM_ET_PICKUPGRENADE, qfalse, qtrue ); + //ent->client->ps.pm_flags |= PMF_TIME_LOCKPLAYER; + //ent->client->ps.pm_time = 2100; - traceEnt->nextthink = traceEnt->timestamp + BODY_TIME(BODY_TEAM(traceEnt)); - -// BG_AnimScriptEvent( &ent->client->ps, ent->client->pers.character->animModelInfo, ANIM_ET_PICKUPGRENADE, qfalse, qtrue ); -// ent->client->ps.pm_flags |= PMF_TIME_LOCKPLAYER; -// ent->client->ps.pm_time = 2100; + ent->client->ps.powerups[PW_OPS_DISGUISED] = 1; + ent->client->ps.powerups[PW_OPS_CLASS_1] = BODY_CLASS(traceEnt) & 1; + ent->client->ps.powerups[PW_OPS_CLASS_2] = BODY_CLASS(traceEnt) & 2; + ent->client->ps.powerups[PW_OPS_CLASS_3] = BODY_CLASS(traceEnt) & 4; - ent->client->ps.powerups[PW_OPS_DISGUISED] = 1; - ent->client->ps.powerups[PW_OPS_CLASS_1] = BODY_CLASS(traceEnt) & 1; - ent->client->ps.powerups[PW_OPS_CLASS_2] = BODY_CLASS(traceEn