Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // IN ST_HUD.CPP !!!!!
- // Ch0wW: Fix -- Unsure if 100% correct, but it's optimised slightly.
- // From bug 2029: http://zandronum.com/tracker/view.php?id=2029
- void DrawHUD_CoopInfo()
- {
- // [BB] Only draw the info if the user wishes to see it (cl_drawcoopinfo)
- // and if this is a cooperative or team based game mode. Further don't draw this in single player.
- if ( ( cl_drawcoopinfo == false ) || ( dmflags3 & DF3_NO_COOP_INFO )
- || ! ( (GAMEMODE_GetFlags( GAMEMODE_GetCurrentMode( )) & GMF_COOPERATIVE)
- || (GAMEMODE_GetFlags( GAMEMODE_GetCurrentMode( )) & GMF_PLAYERSONTEAMS) )
- || NETWORK_GetState() == NETSTATE_SINGLE )
- return;
- const bool bScale = HUD_IsScaled();
- // Ch0wW: Check the gamemode used by the server.
- // If the server is a casual one (ie: coop/survival/invasion), let the spectators
- // know about the health/ammo the player has.
- bool bIsCasual;
- if (GAMEMODE_GetCurrentMode() == GAMEMODE_COOPERATIVE ||
- GAMEMODE_GetCurrentMode() == GAMEMODE_SURVIVAL ||
- GAMEMODE_GetCurrentMode() == GAMEMODE_INVASION )
- bIsCasual = true;
- bool bIsShown;
- FString drawString;
- // [BB] We may not draw in the first 4 lines, this is reserved for chat messages.
- // Leave free another line to prevent the keys from being drawn over in ST's
- // fullscreen HUD.
- // [Dusk] Said message field can now have an arbitrary amount of lines, so
- // we cannot assume the default 4.
- const int yOffset = ( 1 + con_notifylines ) * SmallFont->GetHeight( );
- int playersDrawn = 0;
- for ( int i = 0; i < MAXPLAYERS; i++ )
- {
- // [BB] Only draw the info of players who are actually in the game.
- if ( (playeringame[i] == false) || ( players[i].bSpectating ) || (players[i].mo == NULL) )
- continue;
- // [BB] No need to draw the info of the player who's eyes we are looking through.
- if ( players[i].mo->CheckLocalView( consoleplayer ) )
- continue;
- // [BB] Only display team mates (in coop all players are team mates). Spectators see everybody.
- if ( players[consoleplayer].camera && !players[consoleplayer].camera->IsTeammate ( players[i].mo )
- && !( players[consoleplayer].camera->player && players[consoleplayer].camera->player->bSpectating ) )
- continue;
- // [BB] We need more spacing if there is SECTINFO.
- int curYPos = yOffset + (playersDrawn/2) * ( ( 4 + ( level.info->SectorInfo.Names.Size() > 0 ) ) * SmallFont->GetHeight( ) + 3 ) ;
- const bool drawLeft = ( playersDrawn % 2 == 0 );
- // [BB] Draw player name.
- drawString = players[i].userinfo.netname;
- V_ColorizeString( drawString );
- EColorRange nameColor = CR_GREY;
- // [BB] If the player is on a team, use the team's text color.
- if ( GAMEMODE_GetFlags( GAMEMODE_GetCurrentMode( )) & GMF_PLAYERSONTEAMS )
- nameColor = static_cast<EColorRange> ( TEAM_GetTextColor ( players[i].ulTeam ) );
- HUD_DrawTextAligned ( nameColor, curYPos, drawString.GetChars(), drawLeft, bScale );
- curYPos += SmallFont->GetHeight( ) + 1;
- // [BL] Draw the player's location, [BB] but only if the map has any SectorInfo.
- if ( level.info->SectorInfo.Names.Size() > 0 )
- {
- drawString = SECTINFO_GetPlayerLocation( i );
- V_ColorizeString( drawString );
- HUD_DrawTextAligned ( CR_GREY, curYPos, drawString.GetChars(), drawLeft, bScale );
- curYPos += SmallFont->GetHeight( ) + 1;
- }
- // (CHOWW) Health indicator is only seeable for players, OR If we can see his health
- // //!\\ UNSURE IF IT'S PERFECTLY CORRECT :/ !!
- if (!players[consoleplayer].bSpectating || bIsCasual)
- {
- // [BB] Draw player health (color coded) and armor.
- EColorRange healthColor = CR_RED;
- // [BB] Player is alive.
- if ( players[i].mo->health <= 0 )
- drawString = "dead";
- else if ( SERVER_IsPlayerAllowedToKnowHealth ( consoleplayer, i ) )
- {
- AInventory* pArmor = players[i].mo->FindInventory(RUNTIME_CLASS(ABasicArmor));
- drawString.Format( "%d \\cD/ %d", players[i].mo->health, pArmor ? pArmor->Amount : 0 );
- V_ColorizeString( drawString );
- if ( players[i].mo->health > 66 )
- healthColor = CR_GREEN;
- else if ( players[i].mo->health > 33 )
- healthColor = CR_GOLD;
- }
- else
- drawString = "??? / ???";
- HUD_DrawTextAligned ( healthColor, curYPos, drawString.GetChars(), drawLeft, bScale );
- curYPos += SmallFont->GetHeight( ) + 1;
- }
- // [BB] Draw player weapon and Ammo1/Ammo2, but only if the player is alive.
- // [Spleen] And don't draw ammo if sv_infiniteammo is enabled.
- //vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
- // CH0wW: COMPLETELY UNSURE OF THAT PART!!! TESTING IS IMPORTANT!!!!
- //^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- if (bIsCasual || !players[consoleplayer].bSpectating) // Ch0wW: If we're in a casual gamemode or that we're a player, you can get info from your friends
- {
- if (players[i].ReadyWeapon && players[i].mo->health > 0)
- {
- drawString = players[i].ReadyWeapon->GetClass()->TypeName;
- if ( players[i].ReadyWeapon->Ammo1 && ( ( dmflags & DF_INFINITE_AMMO ) == false ) )
- drawString.AppendFormat( " \\cf%d", players[i].ReadyWeapon->Ammo1->Amount );
- else
- drawString += " \\cg-";
- if ( players[i].ReadyWeapon->Ammo2 && ( ( dmflags & DF_INFINITE_AMMO ) == false ) )
- drawString.AppendFormat( " \\cf%d", players[i].ReadyWeapon->Ammo2->Amount );
- V_ColorizeString( drawString );
- HUD_DrawTextAligned ( CR_GREEN, curYPos, drawString.GetChars(), drawLeft, bScale );
- }
- else // Ch0wW: ELSE, in competitive and as a spectator...
- {
- EColorRange healthColor = CR_RED;
- // If he's dead, simply put "dead" ...
- if ( players[i].mo->health <= 0 ) {
- drawString = "dead";
- }
- else if (players[i].ReadyWeapon) // else, simply put his weapon drawn on the screen
- {
- healthColor = CR_GREEN;
- drawString = players[i].ReadyWeapon->GetClass()->TypeName;
- }
- V_ColorizeString( drawString );
- HUD_DrawTextAligned ( healthColor, curYPos, drawString.GetChars(), drawLeft, bScale );
- }
- playersDrawn++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement