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.
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
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 }
edit: the whitetex is in both places just becuase my other one has some visibility issues, they are supposed to be different textures
Comment