From 7b4a04daaa9ce5de0842defe5072ec05b4c58f55 Mon Sep 17 00:00:00 2001 From: Joseph Stalin Date: Fri, 13 Sep 2019 00:28:12 +0500 Subject: [PATCH] Added teammate indication --- src/game/g_game.pas | 10 ++++++++-- src/game/g_player.pas | 29 ++++++++++++++++++++--------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/game/g_game.pas b/src/game/g_game.pas index 9d74f10..b89b037 100644 --- a/src/game/g_game.pas +++ b/src/game/g_game.pas @@ -3511,7 +3511,7 @@ end; procedure DrawPlayer(p: TPlayer); var - px, py, a, b, c, d: Integer; + px, py, a, b, c, d, i: Integer; //R: TRect; begin if (p = nil) or (p.FDummy) then @@ -3667,7 +3667,13 @@ begin renderMapInternal(-c, -d, true); if (gGameSettings.GameMode <> GM_SINGLE) and gPlayerIndicator then - p.DrawIndicator(); + if gPlayers[i] <> nil then + for i := 0 to High(gPlayers) do + if gPlayers[i] = p then gPlayers[i].DrawIndicator(_RGB(255, 255, 255)) + else if (gPlayers[i].Team = p.Team) and (gPlayers[i].Team <> TEAM_NONE) + then + gPlayers[i].DrawIndicator(gPlayers[i].GetColor); + if p.FSpectator then e_TextureFontPrintEx(p.GameX + PLAYER_RECT_CX - 4, p.GameY + PLAYER_RECT_CY - 4, diff --git a/src/game/g_player.pas b/src/game/g_player.pas index 962db66..181d7da 100644 --- a/src/game/g_player.pas +++ b/src/game/g_player.pas @@ -282,6 +282,7 @@ type procedure ReleaseKeys(); procedure SetModel(ModelName: String); procedure SetColor(Color: TRGB); + function GetColor(): TRGB; procedure SetWeapon(W: Byte); function IsKeyPressed(K: Byte): Boolean; function GetKeys(): Byte; @@ -319,7 +320,7 @@ type procedure DrawPickup(); procedure DrawRulez(); procedure DrawAim(); - procedure DrawIndicator(); + procedure DrawIndicator(Color: TRGB); procedure DrawBubble(); procedure DrawGUI(); procedure Update(); virtual; @@ -2034,6 +2035,11 @@ begin if FModel <> nil then FModel.Color := Color; end; +function TPlayer.GetColor(): TRGB; +begin + result := FModel.Color; +end; + procedure TPlayer.SwitchTeam; begin if g_Game_IsClient then @@ -2321,22 +2327,27 @@ begin inherited; end; -procedure TPlayer.DrawIndicator(); +procedure TPlayer.DrawIndicator(Color: TRGB); var indX, indY: Integer; indW, indH: Word; ID: DWORD; + c: TRGB; begin if FAlive then + begin + if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID) then begin - if g_Texture_Get('TEXTURE_PLAYER_INDICATOR', ID) then - begin - e_GetTextureSize(ID, @indW, @indH); - indX := FObj.X + FObj.Rect.X + (FObj.Rect.Width - indW) div 2; - indY := FObj.Y; - e_Draw(ID, indX, indY - indH, 0, True, False); - end; + e_GetTextureSize(ID, @indW, @indH); + indX := FObj.X + FObj.Rect.X + (FObj.Rect.Width - indW) div 2; + indY := FObj.Y; + + c := e_Colors; + e_Colors := Color; + e_Draw(ID, indX, indY - indH, 0, True, False); + e_Colors := c; end; + end; //e_TextureFontPrint(indX, indY, FName, gStdFont); // Shows player name overhead end; -- 2.29.2