Announcement

Collapse
No announcement yet.

cant highlight enemy players [ut2004]

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • replied
    i know that the ion cannon does exactly what your trying to do maybe you can look in that script - only a idea

    *Sneaks out

    Leave a comment:


  • replied
    heres an alpha release, i want to improve it so that the info is only displayed for the current target becuase currently it shows you info for all visible and sometimes not visible actors.

    InfoHUD.uc
    Code:
    Class InfoHUD extends Interaction;
    
    #exec texture import name=blacktex file=Textures\blacktex.pcx
    #exec texture import name=whitetex file=Textures\whitetex.pcx
    var bool bDraw;
    
    function bool KeyEvent(EInputKey Key, EInputAction Action, FLOAT Delta )
    {
        if ((Action == IST_Press) && (Key == IK_Alt))
            bDraw = True;
        if ((Action == IST_Release) && (Key == IK_Alt))
            bDraw= False;
    
        return false;
    }
    
    simulated function PostRender( canvas Canvas )
    {
        local Pawn P;
        local vector CameraLocation, dir, ScreenLocation;
        local rotator CameraRotation;
        local float dist, draw_scale;
        local int XPos, YPos;
    
        If (bDraw) //if none are true, dont do anything
            {
            foreach ViewportOwner.Actor.DynamicActors(class'Pawn', P)
                {
                if (ViewportOwner.Actor.Pawn == None || P == None)
                    Return;
    
                //A trace to tell if you can see this thing
                If ((Canvas.Viewport.Actor.FastTrace(P.Location, ViewportOwner.Actor.Pawn.Location)) && (P != ViewportOwner.Actor.Pawn) && (P.PlayerReplicationInfo != None) && (P.Health > 0))
                    {
                    //Convert 3d location to 2d for display on the Canvas
                    ScreenLocation = WorldToScreen(P.location);
                    Canvas.GetCameraLocation(CameraLocation, CameraRotation);
                    dir = P.Location - CameraLocation;
                    dist = VSize(dir); //Distance between me and them
                    if (dir dot vector(CameraRotation) > 0)
                        {
                        draw_scale = 512 / dist; //Calculate the drawscale, 512 is the "1:1" distance.
                        //Set drawing params
    
                        XPos = 0;//(H.HudCanvasScale * Canvas.SizeX) + (((1.0 - H.HudCanvasScale) / 2.0) * Canvas.SizeX);
                        YPos = 50;//(H.HudCanvasScale * Canvas.SizeY) + (((1.0 - H.HudCanvasScale) / 2.0) * Canvas.SizeY);
                        Canvas.SetPos(XPos,YPos);
                        Canvas.Style = 3;
                        Canvas.SetDrawColor(255,255,255,255);
    
                        Canvas.DrawText("NAME= " $ P.PlayerReplicationInfo.PlayerName);
                        Canvas.DrawText("ID= " $ P.PlayerReplicationInfo.PlayerID);
                        Canvas.DrawText("TEAM= " $ P.PlayerReplicationInfo.TeamID);
                        Canvas.DrawText("HEALTH= " $ P.Health);
                        Canvas.DrawText("WEAPON= " $ P.Weapon);
                        Canvas.DrawText("AMMO (mode 0)= " $ P.Weapon.AmmoAmount(0));
                        Canvas.DrawText("AMMO (mode 1)= " $ P.Weapon.AmmoAmount(1));
                        Canvas.DrawText("Score= " $ P.PlayerReplicationInfo.Score);
                        }
                    }
                }
            }
    }
    
    defaultproperties
    {
     bActive=true
     bVisible=True
    }
    and the mutator InfoHUDMut
    Code:
    class InfoHUDMut extends Mutator;
    
    var bool bAffectSpectators; // If this is set to true, an interaction will be created for spectators
    var bool bAffectPlayers; // If this is set to true, an interaction will be created for players
    var bool bHasInteraction;
    
    simulated function Tick(float DeltaTime)
    {
        local PlayerController PC;
    
        // If the player has an interaction already, exit function.
        if (bHasInteraction)
            Return;
        PC = Level.GetLocalPlayerController();
    
        // Run a check to see whether this mutator should create an interaction for the player
        if ( PC != None && ((PC.PlayerReplicationInfo.bIsSpectator && bAffectSpectators) || (bAffectPlayers && !PC.PlayerReplicationInfo.bIsSpectator)) )
        {
            PC.Player.InteractionMaster.AddInteraction("YourPackage.YourClass", PC.Player); // Create the interaction
            bHasInteraction = True; // Set the variable so this lot isn't called again
        }
    }
    
    DefaultProperties
    {
         bAffectSpectators=false
         bAffectPlayers=true
         RemoteRole=ROLE_SimulatedProxy
         bAlwaysRelevant=true
         FriendlyName="InfoHUD"
         Groupname="InfoHUD"
    }

    Leave a comment:


  • replied
    o....****... I forgot to post the error,

    Code:
    C:\UT2004\Axion\Classes\AxionHUD.uc(17) : Error, Call to 'FastTrace': Bad expression or missing ')'
    and with this code
    Code:
    foreach VisibleActors(class'Pawn',P, 200.000, Interaction.ViewportOwner.Actor.Pawn.Location);
                    If (P != ViewportOwner.Actor.Pawn) && (P.PlayerReplicationInfo != None) && (P.Health > 0))
    i get
    Code:
     Error: C:\UT2004\Axion\Classes\AxionHUD.uc(18) : Error, Call to 'VisibleActors': Bad expression or missing ')'
    when I remove the optional vector location I get
    Code:
     Error: C:\UT2004\Axion\Classes\AxionHUD.uc(19) : Error, Bad or missing expression after '!='
    I think this all has something do with the fact that im using ViewportOwner in a non-subclass of Interaction

    Leave a comment:


  • replied
    Do you realize that "I'm getting compiler errors" is similar to someone stating "My computer doesn't work" at a helpline?

    Leave a comment:


  • replied
    ive changed my objective with this code to instead provide info about the visible pawn.
    Code:
    simulated function InfoHUD(canvas Canvas)
    {
    local Pawn P;
    local vector CameraLocation, dir, ScreenLocation;
    local rotator CameraRotation;
    local float dist, draw_scale;
    local Controller C;
    
    for(C=C.Level.ControllerList; C!=none; C=C.nextController)
                {
                P = C.Pawn;
                If ((Canvas.Viewport.Actor.FastTrace(P.Location, ViewportOwner.Actor.Pawn.Location)) && (P != ViewportOwner.Actor.Pawn) && (P.PlayerReplicationInfo != None) && (P.Health > 0))
                    {
                    ScreenLocation = WorldToScreen(P.location);
                    Canvas.GetCameraLocation(CameraLocation, CameraRotation);
                    dir = P.Location - CameraLocation;
                    dist = VSize(dir);
    
                    if (dir dot vector(CameraRotation) > 0)
                        {
                        draw_scale = 512 / dist; //Calculate the drawscale, 512 is the "1:1" distance.
                        Canvas.SetPos(ScreenLocation.X - (32 * draw_scale), ScreenLocation.Y - (32 * draw_scale));
    
                        Canvas.Style = 3;
                        Canvas.Font = Canvas.MedFont;
                        Canvas.SetDrawColor(255,255,255,255);
                        Canvas.DrawText(P.name);
                        Canvas.DrawText("HEALTH=" @ P.Health);
                        Canvas.DrawText("WEAPON=" @ P.Weapon);
                        Canvas.DrawText("AMMO=" @ P.Weapon.AmmoAmount(0));
                        }
                    }
            }
    }
    Im getting compile erros with FastTrace and when I try to use foreach visibleactors() or radiusactors() i get similar ones.

    Leave a comment:


  • replied
    Three things:
    1. What exactly are you going to do with this interaction once you get it to work? Why not simply use a HudOverlay and console commands?
    2. Avoid using FastTrace, it's slow. While being the fastest possible way to check for a free line of sight, you should still always consider doing other checks first, especially in ForEach loops.
    3. Why do you check for TeamIndex == TeamIndex && TeamName == TeamName? Team == Team should do the tric as well, shouldn't it? (And yes, using "if ... else" is a good idea there...)

    Leave a comment:


  • replied
    @Angel_Mapper: If he uses the controller list then it will not work on clients though right? (I just seem to remember that on client machines the only player information they have is their own controller and then the pawns that they are currently being repliciated)

    Leave a comment:


  • replied
    Ouch, is that ForEach DynamicActors lagging at all? I'd use the ControllerList instead, much faster:

    local Controller C;

    for ( C=Level.ControllerList; C!=None; C=C.NextController )

    Leave a comment:


  • replied
    You should convert those two if statements to an if/else, because if a pawn is NOT a friendly, then he must be an enemy, correct? You dont have any neutral drawings, so it sounds likely. This also saves you having to do all of those deep reference checks.

    Since the code onlyworks for friendly units, my guess is that the TeamNames are "" or always the same. You should log the team name to see what they are.

    Leave a comment:


  • started a topic cant highlight enemy players [ut2004]

    cant highlight enemy players [ut2004]

    I got some code from the wiki and changed it a tiny bit and added my own textures. It basically waits for a keypress, iterates through the list of players, determines the team and location of the player relative to the viewport and then draws a texture with the word "FRIENDLY" or "ENEMY" right near the pawn. The problem is, in 1 version of my code, it puts the enemy and friendly textures up for both teams when the appropriate key is pressed. In the latter version of the code, there is only 1 key, when it is pressed ALL of the characters are to be identified (have the texture drawn near them) but only works for friendly players.
    Code:
    Class AxionInteraction extends Interaction
          config(Axion);
    
    #exec texture import name=blacktex file=Textures\blacktex.pcx
    #exec texture import name=whitetex file=Textures\whitetex.pcx
    var bool bDraw;
    
    function bool KeyEvent(EInputKey Key, EInputAction Action, FLOAT Delta )
    {
        if ((Action == IST_Press) && (Key == IK_Alt))
            bDraw = True;
        if ((Action == IST_Release) && (Key == IK_Alt))
            bDraw= False;
    
        return false;
    }
    
    simulated function PostRender(canvas Canvas)
    {
        local Pawn P;
        local vector CameraLocation, dir, ScreenLocation;
        local rotator CameraRotation;
        local float dist, draw_scale;
    
    if (bDraw)
    {
            foreach ViewportOwner.Actor.DynamicActors(class'Pawn', P)
                {
                //A trace to tell if you can see this thing
                If ((Canvas.Viewport.Actor.FastTrace(P.Location, ViewportOwner.Actor.Pawn.Location)) && (P != ViewportOwner.Actor.Pawn) && (P.PlayerReplicationInfo != None) && (P.Health > 0))
                {
                    //Convert 3d location to 2d for display on the Canvas
                    ScreenLocation = WorldToScreen(P.location);
                    Canvas.GetCameraLocation(CameraLocation, CameraRotation);
                    dir = P.Location - CameraLocation;
                    dist = VSize(dir); //Distance between me and them
    
                    if (dir dot vector(CameraRotation) > 0)
                    {
                        draw_scale = 512 / dist; //Calculate the drawscale, 512 is the "1:1" distance.
                        //Set drawing params
                        Canvas.SetPos(ScreenLocation.X - (32 * draw_scale), ScreenLocation.Y - (32 * draw_scale));
                        Canvas.Style = 3;
    
                        if ((P.PlayerReplicationInfo.Team.TeamIndex != ViewportOwner.Actor.Pawn.PlayerReplicationInfo.Team.TeamIndex) && (P.PlayerReplicationInfo.Team.TeamName != ViewportOwner.Actor.Pawn.PlayerReplicationInfo.Team.TeamName))
                        {
                                Canvas.SetDrawColor(255,100,100,255);
                                Canvas.DrawIcon(texture'whitetex', draw_scale);
                        }
                        if ((P.PlayerReplicationInfo.Team.TeamIndex == ViewportOwner.Actor.Pawn.PlayerReplicationInfo.Team.TeamIndex) && (P.PlayerReplicationInfo.Team.TeamName == ViewportOwner.Actor.Pawn.PlayerReplicationInfo.Team.TeamName))
                        {
                                Canvas.SetDrawColor(255,255,255,255);
                                Canvas.DrawIcon(texture'whitetex', draw_scale);
                        }
                    }
                 }
              }
         }
    }
    
    defaultproperties
    {
     bActive=true
     bVisible=True
     bDraw=False
    }
    to clarify this is an interaction and the key to activate is Alt, in case anyone wants to try it (just put in your own textures). Thanx to all in advance.
    edit: the whitetex is in both places just becuase my other one has some visibility issues, they are supposed to be different textures
Working...
X