// shared_sbar.cpp CVAR( Int, cl_identifytarget, 2, CVAR_ARCHIVE ); player_t *P_PlayerScan( AActor *mo ); void DBaseStatusBar::DrawTargetName () { // [BC] The player may not have a body between intermission-less maps. if ( CPlayer->camera == NULL ) return; // Break out if we don't want to identify the target, or // a medal has just been awarded and is being displayed. if (( cl_identifytarget == 0 ) || ( MEDAL_GetDisplayedMedal( CPlayer->camera->player - players ) != NUM_MEDALS )) return; // Don't do any of this while still receiving a snapshot. if (( NETWORK_GetState( ) == NETSTATE_CLIENT ) && ( CLIENT_GetConnectionState( ) == CTS_RECEIVINGSNAPSHOT )) return; if (( CPlayer->bSpectating ) && ( lastmanstanding || teamlms ) && ( LASTMANSTANDING_GetState( ) == LMSS_INPROGRESS )) return; // Look for players directly in front of the player. if ( camera ) { player_t *pTargetPlayer; unsigned int ulTextColor; char szString[64]; // Search for a player directly in front of the camera. If none are found, exit. pTargetPlayer = P_PlayerScan( camera ); if ( pTargetPlayer == NULL ) return; // Attempt to use the team color. if ( teamgame || teamplay ) { ulTextColor = Teams[pTargetPlayer->userinfo.team].GetTextColor(); if ( pTargetPlayer->mo->IsTeammate(CPlayer->mo) ) { if(cl_identifytarget == 1) sprintf( szString, "%s\n\\cdAlly", pTargetPlayer->userinfo.netname ); else if(cl_identifytarget == 2) sprintf( szString, "%s\n\\cd%i%%", pTargetPlayer->userinfo.netname, pTargetPlayer->health); else if(cl_identifytarget == 3) sprintf( szString, "%s\n\\cdAlly\n%i%%", pTargetPlayer->userinfo.netname, pTargetPlayer->health); else sprintf( szString, "%s\n\\cd%i%%\nAlly", pTargetPlayer->userinfo.netname, pTargetPlayer->health); } else sprintf( szString, "%s\n\\cgEnemy", pTargetPlayer->userinfo.netname ); } // no team based game else if ( deathmatch ) { // If this player is carrying the terminator artifact display it. if ( terminator && (pTargetPlayer->Powers & PW_TERMINATORARTIFACT) ) { ulTextColor = CR_RED; sprintf( szString, "%s\n\\cgTerminator", pTargetPlayer->userinfo.netname ); } else { ulTextColor = CR_GRAY; sprintf( szString, "%s\n\\cgEnemy", pTargetPlayer->userinfo.netname ); } } // coop here else { sprintf( szString, "%s\n\\cd%i%%", pTargetPlayer->userinfo.netname, pTargetPlayer->health); ulTextColor = CR_GREEN; } AttachMessage(new DHUDMessageFadeOut( SmallFont, szString, 1.5f, gameinfo.gametype == GAME_Doom ? 0.96f : 0.95f, 0, 0, (EColorRange)ulTextColor, 2.f, 0.35f ), MAKE_ID('P','N','A','M') ); } } // p_map.cpp /* ================ = = P_PlayerScan = = Looks for other players directly in front of the player, = ignore (see trough) invisible players. ================ */ AActor *pSourceCamera; static bool ProcessPlayerHit(FTraceResults &trace) { // map hit, return if(trace.HitType != TRACE_HitActor) return false; // not a player, return if(trace.Actor->player == NULL) return false; // hit player, check visibility if((trace.Actor->renderflags & RF_INVISIBLE) || trace.Actor->alpha <= FRACUNIT / 3) return true; // player is invisible, ignore return false; // player is visible } player_t *P_PlayerScan( AActor *pSource ) { fixed_t vx, vy, vz, shootz; FTraceResults trace; int pitch; angle_t angle; pSourceCamera = pSource; angle = pSource->angle >> ANGLETOFINESHIFT; pitch = (angle_t)( pSource->pitch ) >> ANGLETOFINESHIFT; vx = FixedMul (finecosine[pitch], finecosine[angle]); vy = FixedMul (finecosine[pitch], finesine[angle]); vz = -finesine[pitch]; shootz = pSource->z - pSource->floorclip + (pSource->height>>1) + 8*FRACUNIT; if ( Trace( pSource->x, // Actor x pSource->y, // Actor y shootz, // Actor z pSource->Sector, vx, vy, vz, ( 32 * 64 * FRACUNIT ) /* MISSILERANGE */, // why not max? MF_SHOOTABLE, // Actor mask ML_BLOCKEVERYTHING, // Wall mask pSource, // Actor to ignore trace, // Result TRACE_NoSky, // Trace flags ProcessPlayerHit ) == false ) // Callback // Did not spot anything anything. { return ( NULL ); } else { // Return NULL if we did not hit an actor. if ( trace.HitType != TRACE_HitActor ) return ( NULL ); // Return NULL if the actor we hit is not a player. if ( trace.Actor->player == NULL ) return ( NULL ); if(trace.Actor->player) // Return the player we found. return ( trace.Actor->player ); } return (NULL); // hmm? }