[Help] HUD and Scoreboard icons

  • Please make sure you are familiar with the forum rules. You can find them here: https://forums.tripwireinteractive.com/index.php?threads/forum-rules.2334636/

forrestmark9

FNG / Fresh Meat
Nov 29, 2011
1,110
40
0
I need help with a particular system, due to the way I want to do this Chat Status will not work.

Anyway I want to setup a system via the HUD and Scoreboard that shows if the player is in the console or is chatting, etc draw a icon above there head and one next to there name in the scoreboard

Due to my limit knowledge of anything like this via HUD I only know that the overhead icons needs to be drawn via DrawPlayerInfo and with the scoreboard I don't know, I tried using DrawNamePostfixIcons but this doesn't work and only works in the chat and nowhere else.
 

FluX

Grizzled Veteran
Oct 26, 2010
5,394
234
63
www.fluxiserver.co.uk
Personally, i'll grab the code from the argentina which shows the icon above the head. Use the code to make your own boolean (guessing this is used) which will then add an icon to the HUD/scoreboard.
 

forrestmark9

FNG / Fresh Meat
Nov 29, 2011
1,110
40
0
Personally, i'll grab the code from the argentina which shows the icon above the head. Use the code to make your own boolean (guessing this is used) which will then add an icon to the HUD/scoreboard.

That code is super weird, all it's doing is checking constantly if the controller is typing then spawns an actor with a texture then attaches that actor to the head
 

FluX

Grizzled Veteran
Oct 26, 2010
5,394
234
63
www.fluxiserver.co.uk
Then you have found your answer. Instead of spawning the actor, set the boolean to true (bIsTyping inside the scoreboard for example) and set inside the scoreboard if bIsTyping, show icon. Or do it in the HUD.

Other option is to make a bool inside the PlayerReplicationInfo and have the HUD check it.
 

forrestmark9

FNG / Fresh Meat
Nov 29, 2011
1,110
40
0
Then you have found your answer. Instead of spawning the actor, set the boolean to true (bIsTyping inside the scoreboard for example) and set inside the scoreboard if bIsTyping, show icon. Or do it in the HUD.

Other option is to make a bool inside the PlayerReplicationInfo and have the HUD check it.

I already explained I know to do it via the HUD but I don't know HOW to do it as I've never done anything that uses Canvas on this scale other then DrawSpriteWidget
 

forrestmark9

FNG / Fresh Meat
Nov 29, 2011
1,110
40
0
Try to look into NadeWarn mutator.

I looked into it and used it as a base to make this

Code:
class HudChatOverlay extends HUDOverlay;

const CHAT_RADIUS = 750;
var Material ConsoleTex, ChatTex;

simulated function Render(Canvas C)
{
    local Pawn P;
    local PlayerController PC;

    P = HUD(Owner).PawnOwner;
    PC = PlayerController(P.Controller);
    if (P != None && P.Health > 0 && PC != none) 
        DrawIcons(C, PC, P.Location);
}

simulated function DrawIcons(Canvas C, PlayerController PC, vector PlayerLoc) {
    local vector ScreenLoc, CameraLoc, PlayerDir;
    local rotator CameraRot;
    local float TexSize, TexAdjust;

    ScreenLoc = C.WorldToScreen(PlayerLoc);
    C.GetCameraLocation(CameraLoc, CameraRot);
    PlayerDir = PlayerLoc - CameraLoc;
    if (PlayerDir dot vector(CameraRot) > 0) {
        TexSize = 64 * (3 - (VSize(PlayerDir) / CHAT_RADIUS * 2.4)); // scaled by distance from x3 to x0.6
        TexAdjust = TexSize / 2;
        C.Style = ERenderStyle.STY_Alpha;
        C.SetPos(ScreenLoc.X-TexAdjust, ScreenLoc.Y-TexAdjust);
        C.SetDrawColor(255,255,255,255);
        if( PC.bIsTyping && !PC.Player.Console.bVisible )
            C.DrawTile(ChatTex, TexSize, TexSize, 0, 0, 64, 64);
        else if( !PC.bIsTyping && PC.Player.Console.bVisible )
            C.DrawTile(ConsoleTex, TexSize, TexSize, 0, 0, 64, 64);
    }
}

defaultproperties
{
     ConsoleTex=Texture'FMXBaseResources2.Console'
     ChatTex=Texture'FMXBaseResources2.Chat'
}

I have no idea if it'll work as expected
 

forrestmark9

FNG / Fresh Meat
Nov 29, 2011
1,110
40
0
bIsTyping/bVisible is not replicated to the other players... so you need a custom PlayerReplicationInfo...

I see, I already have a custom PRI

Code:
var bool bConsole, bTyping;

replication
{
    reliable if( bNetDirty && (Role == Role_Authority) )
        bConsole, bTyping;
}

function Tick(float DT)
{
	Super.Tick(DT);

	bConsole = PlayerController(Owner).Player.Console.bVisible;
	bTyping = PlayerController(Owner).bIsTyping;
}

The only problem with the HudOverlay is the position it's putting the chat icon at the center of the players location and not above his head.
 
Last edited:

Skell

Active member
Mar 21, 2013
1,245
2
38
On the Internet.
Code:
class HudChatOverlay extends HUDOverlay;

const CHAT_RADIUS = 750;
var Material ConsoleTex, ChatTex;

simulated function Render(Canvas C)
{
    local Pawn P;
    local PlayerController PC;

    P = HUD(Owner).PawnOwner;
    PC = PlayerController(P.Controller);
    if (P != None && P.Health > 0 && PC != none) 
        DrawIcons(C, PC, P.Location);
}

simulated function DrawIcons(Canvas C, PlayerController PC, vector PlayerLoc) {
    local vector ScreenLoc, CameraLoc, PlayerDir, [COLOR=Lime]OffestLoc;[/COLOR]
    local rotator CameraRot;
    local float TexSize, TexAdjust;

    [COLOR=Lime]OffestLoc = PlayerLoc + vect(0,0,32);[/COLOR] //32 because I'm pretty sure that should be about above them

    ScreenLoc = C.WorldToScreen([COLOR=Lime]OffestLoc[/COLOR]);
    C.GetCameraLocation(CameraLoc, CameraRot);
    PlayerDir = [COLOR=Lime]OffestLoc [/COLOR]- CameraLoc;
    if (PlayerDir dot vector(CameraRot) > 0) {
        TexSize = 64 * (3 - (VSize(PlayerDir) / CHAT_RADIUS * 2.4)); // scaled by distance from x3 to x0.6
        TexAdjust = TexSize / 2;
        C.Style = ERenderStyle.STY_Alpha;
        C.SetPos(ScreenLoc.X-TexAdjust, ScreenLoc.Y-TexAdjust);
        C.SetDrawColor(255,255,255,255);
        if( PC.bIsTyping && !PC.Player.Console.bVisible )
            C.DrawTile(ChatTex, TexSize, TexSize, 0, 0, 64, 64);
        else if( !PC.bIsTyping && PC.Player.Console.bVisible )
            C.DrawTile(ConsoleTex, TexSize, TexSize, 0, 0, 64, 64);
    }
}

defaultproperties
{
     ConsoleTex=Texture'FMXBaseResources2.Console'
     ChatTex=Texture'FMXBaseResources2.Chat'
}

The only problem with the HudOverlay is the position it's putting the chat icon at the center of the players location and not above his head.

Since WorldToScreen() is, probably, taking the player's location from the middle of their body, simply adding an offset to that vector in the Z component should be enough.
 

Dr_Killjoy

FNG / Fresh Meat
Sep 30, 2012
260
0
0
Maybe in this case it's better to use
Code:
KFHP.CollisionHeight * 1.1
or smth like that.