Love Deus Ex? Of course you do! Delve deeper into the world of conspiracies and revel the glorious Deus Ex series. So, join us!

Report article RSS Feed How to make a custom DX crosshair

As I wanted to make a new crosshair for my mod, I felt that I should make a tutorial about it ^^ This is my first tutorial so please don't judge it critically. I have linked to several of other tutorials.

Posted by SimonDenton on Aug 9th, 2009
Intermediate UI/HUD.

Welcome to the tutorial, by the end of this, you'll be playing around with your new crosshair in Deus Ex!

  • First off, you need a custom package, if you haven't done so you can learn how to make one here or here.
  • Secoundly your player class, to save my typing, simply go here
  • Thirdly, making the actual crosshair texture. Learn how to mask the texture here and how to import it into DX here

Now that the basics are done, you need to make your own game HUD. The player class links to the HUD in which links to your new crosshair class. I have an example of mine below, just simply copy and paste into notepad, then replace SummerHUD with the name of your HUD class and SummerCrosshair with the name of your future crosshair class. And finally replace CrossCircle with the name of your crosshair texture.

code:
//=============================================================================
// HUD: Superclass of the heads-up display.
//=============================================================================
class SummerHUD extends DeusExHUD;


//=============================================================================
// Variables.

var globalconfig int HudMode;   
var globalconfig int Crosshair;
var() class MainMenuType;
var() string HUDConfigWindowType;
var color WhiteColor;
var    Menu MainMenu;
var Mutator HUDMutator;
var PlayerPawn PlayerOwner; // always the actual owner

/*

struct HUDLocalizedMessage
{
    var Class Message;
    var int Switch;
    var PlayerReplicationInfo RelatedPRI;
    var Object OptionalObject;
    var float EndOfLife;
    var float LifeTime;
    var bool bDrawing;
    var int numLines;
    var string StringMessage;
    var color DrawColor;
    var font StringFont;
    var float XL, YL;
    var float YPos;
};

function ClearMessage(out HUDLocalizedMessage M)
{
    M.Message = None;
    M.Switch = 0;
    M.RelatedPRI = None;
    M.OptionalObject = None;
    M.EndOfLife = 0;
    M.StringMessage = "";
    M.DrawColor = WhiteColor;
    M.XL = 0;
    M.bDrawing = false;
}

function CopyMessage(out HUDLocalizedMessage M1, HUDLocalizedMessage M2)
{
    M1.Message = M2.Message;
    M1.Switch = M2.Switch;
    M1.RelatedPRI = M2.RelatedPRI;
    M1.OptionalObject = M2.OptionalObject;
    M1.EndOfLife = M2.EndOfLife;
    M1.StringMessage = M2.StringMessage;
    M1.DrawColor = M2.DrawColor;
    M1.XL = M2.XL;
    M1.YL = M2.YL;
    M1.YPos = M2.YPos;
    M1.bDrawing = M2.bDrawing;
    M1.LifeTime = M2.LifeTime;
    M1.numLines = M2.numLines;
}

//=============================================================================
// Status drawing.

simulated event PreRender( canvas Canvas );
simulated event PostRender( canvas Canvas );
simulated function InputNumber(byte F);
simulated function ChangeHud(int d);
simulated function ChangeCrosshair(int d);
simulated function DrawCrossHair( canvas Canvas, int StartX, int StartY);

//=============================================================================
// Messaging.

simulated function Message( PlayerReplicationInfo PRI, coerce string Msg, name N );
simulated function LocalizedMessage( class Message, optional int Switch, optional PlayerReplicationInfo RelatedPRI_1, optional PlayerReplicationInfo RelatedPRI_2, optional Object OptionalObject, optional string CriticalString );

simulated function PlayReceivedMessage( string S, string PName, ZoneInfo PZone )
{

    PlayerPawn(Owner).ClientMessage(S);
    if (PlayerPawn(Owner).bMessageBeep)
        PlayerPawn(Owner).PlayBeepSound();
}

// DisplayMessages is called by the Console in PostRender.
// It offers the HUD a chance to deal with messages instead of the
// Console.  Returns true if messages were dealt with.
simulated function bool DisplayMessages(canvas Canvas)
{
    return false;
}
// ----------------------------------------------------------------------
// InitWindow()
// ----------------------------------------------------------------------
*/

event InitWindow()
{
    Super.InitWindow();
    cross.destroy();
    cross = Crosshair(NewChild(Class'SummerCrosshair'));
    cross.SetBackground(Texture'CrossCircle');

}

defaultproperties
{
}

Save this file as the name of your GameHUD class, in this example it is SummerHUD.uc in your Package's Classes folder.

Now to link the player with the HUD. In your player class enter the code below, just replace SummerHUD with the name of your HUD class. In the below example I also made my own DataLinkPlay, you can simply ignore this if you do not want to make your own data link play.

code:
}

function Possess()
{

local DeusExRootWindow root;

Super.Possess();

root = DeusExRootWindow(rootWindow);

root.hud.Destroy();
root.hud = DeusexHUD(root.NewChild(Class'SummerHUD'));

root.hud.UpdateSettings(Self);
root.hud.SetWindowAlignments(HALIGN_Full,VALIGN_Full, 0, 0);
//datalinkPlay = Spawn(class'Summer101DataLinkPlay');
}

Now that the HUD is all good, time to make the crosshair class itself. Replace the SUMMER references with your own just like before in the below example. SummerCrosshair with the name of your crosshair class and CrossCircle with the name of your crosshair texture.

code:
//=============================================================================
// SummerCrosshair.
//=============================================================================
class SummerCrosshair extends Crosshair;

// ----------------------------------------------------------------------
// InitWindow()
// ----------------------------------------------------------------------

event InitWindow()
{
    local Color col;

    Super.InitWindow();

    SetBackgroundStyle(DSTY_Masked);
    SetBackground(Texture'CrossCircle');
    col.R = 255;
    col.G = 255;
    col.B = 255;
    SetCrosshairColor(col);
}


defaultproperties
{
}

Save this as the name of your crosshair class, in this case it is SummerCrosshair.

Now compile your package, assuming you know how. Now to link DX with your player class, go to User.ini in the Deus Ex System folder and edit:
Class=Summer.SummerJack

The above is my example, Summer is the name of your package and SummerJack is the player class name.

Besides what was linked, this was code made by Danjun and myself.

Post comment Comments
Syntαx_Error
Syntαx_Error Sep 22 2011, 12:01pm says:

You said that "you need to make your own game HUD". Concerning what you know, is there a similar process to customize the color schemes for menu/hud?

+1 vote     reply to comment
Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Established
Dec 22, 2010
Privacy
Public
Subscription
Open to all members
Homepage
Deusex.com
Contact
Send Message
Email
Members Only
Membership
Join this group
Group Watch
Track this group
Tutorial
Browse
Tutorials
Report Abuse
Report article
Related Mods
Summer 101 (Deus Ex)
Summer 101 Deus Ex - Single & Multiplayer Role Playing
Related Games
Deus Ex
Deus Ex Single & Multiplayer Adventure
Related Groups
Deus Ex Fan Group
Deus Ex Fan Group Fans & Clans group with 463 members
INVULNERABLE PRODUCTIONS
INVULNERABLE PRODUCTIONS Developer with 10 members
Summer 101 Dev
Summer 101 Dev Developer & Publisher with 9 members