class DebugInfoTips extends Mutator; var GeoHuman MyPlayer; var HUD MyHUD; simulated function Tick(float DeltaTime) { if ( !bHUDMutator && Level.NetMode != NM_DedicatedServer ) RegisterHUDMutator(); } simulated function PostRender(canvas Canvas) { MyPlayer = Canvas.Viewport.Actor; if ( MyPlayer != None ) MyHUD = MyPlayer.myHUD; RenderInfo(canvas); // This is important! It allows the next HUD mutator to draw on the canvas. if ( NextHUDMutator != None ) NextHUDMutator.PostRender(Canvas); } // Created by M.C. Spanky, aka Martin C. Martin, for Esc (www.esconline.org) function RenderInfo( canvas Canvas ) { local Pawn thisPawn; local float X, Y; local float W, H; local bool bOnScreen; local vector worldPosition; Super.PostRender(Canvas); for (thisPawn = Level.PawnList; thisPawn != None; thisPawn = thisPawn.NextPawn) { worldPosition = thisPawn.Location; worldPosition.Z += thisPawn.CollisionHeight; bOnScreen = WorldToScreen(worldPosition, Pawn(Owner), Canvas.ClipX, Canvas.ClipY, X, Y); if (bOnScreen && X > 0 && X < Canvas.ClipX && Y > 0 && Y < Canvas.ClipY) { Canvas.SetPos(0, 0); Canvas.TextSize(thisPawn.MenuName, W, H); Canvas.SetPos(X - W/2, Y - H/2); Canvas.DrawText(thisPawn.MenuName, false); } } } simulated static function bool WorldToScreen(Vector WorldLocation, Pawn ThePlayer, float ScreenWidth, float ScreenHeight, out float X, out float Y) { local vector EyePos, RelativeToPlayer; local float Scale; EyePos = ThePlayer.Location; EyePos.Z += ThePlayer.BaseEyeHeight; // Maybe ThePlayer.EyeHeight instead? RelativeToPlayer = (WorldLocation - EyePos) << ThePlayer.ViewRotation; if (RelativeToPlayer.X < 0.01) return false; Scale = (ScreenWidth / 2) / Tan(ThePlayer.FovAngle/2/180*Pi); X = RelativeToPlayer.Y / RelativeToPlayer.X * Scale + ScreenWidth / 2; Y = - RelativeToPlayer.Z / RelativeToPlayer.X * Scale + ScreenHeight / 2; return true; } /******************************************************************************** * Converts a given directional vector to canvas coordinates. * * X and Y values of the returned vector contain absolute coordinates. * * The function returns, whether the target direction is visible for the player. * * Created by Wormbo * ********************************************************************************/ simulated function bool MapToHUD(out vector Result, rotator ViewRotation, float FOV, vector TargetDir, Canvas Canvas) { local float TanFOVx, TanFOVy; local float TanX, TanY; local float dx, dy; local vector X, Y, Dir, XY; TanFOVx = Tan(FOV * Pi / 360); TanFOVy = (Canvas.ClipY / Canvas.ClipX) * TanFOVx; GetAxes(ViewRotation, Dir, X, Y); Dir *= TargetDir dot Dir; XY = TargetDir - Dir; dx = XY dot X; dy = XY dot Y; TanX = dx / VSize(dir); TanY = dy / VSize(dir); Result.X = Canvas.ClipX * 0.5 * (1 + TanX / TanFOVx); Result.Y = Canvas.ClipY * 0.5 * (1 - TanY / TanFOVy); return Dir dot vector(ViewRotation) > 0 && Result.X == FClamp(Result.X, Canvas.OrgX, Canvas.ClipX) && Result.Y == FClamp(Result.Y, Canvas.OrgY, Canvas.ClipY); } defaultproperties { RemoteRole=ROLE_SimulatedProxy bAlwaysRelevant=True bNetTemporary=True // Set to false if you need to replicate data to the clients more than once per level }