Forum Thread
  Posts  
[UT] How to change the Crosshair (Forums : Coding & Scripting : [UT] How to change the Crosshair) Locked
Thread Options
Aug 17 2003 Anchor

For UT, How would I go about changing the crosshair/crosshair color? (normally changed through preferences) via UScript?

- Edited By [BDA]Perseus On Sun 17th, Aug 2003 @ 8:43:37pm

Aug 17 2003 Anchor

Depends what game your on about - that kinda stuffs useful yano?

--

Why wont it save me?

Aug 17 2003 Anchor

Yes sorry, heh, I just edited my post about that :)

Aug 17 2003 Anchor

Changed the title for you, sure someone will help soon.

--

Why wont it save me?

Aug 17 2003 Anchor

Thank you!

ShortCutMan
ShortCutMan ♥ Pure ♥ Bred ♥ Geek ♥
Aug 19 2003 Anchor

I'm not exactly sure how to change colours in UScript, but I did I quick search for ya, and found this in the Paint function:

C.DrawColor.R = 15 * H.CrosshairColor.R;
C.DrawColor.G = 15 * H.CrosshairColor.G;
C.DrawColor.B = 15 * H.CrosshairColor.B;

The varible "H" is the varible type of ChallengeHUD, so its comunicating with unreal Tournaments main HUD. CorsshairColour is obviously a colour varible. "R", "G", and "B", all refer to a colour, "R" is red, "G" is green, and "B" is blue. From what I know, this all represent Byte varibles, so you can't go over 255 for their value. Fiddle with different int's (No Float numbers for Byte's), and you get different colours. Hope this helps. :)

--

98% of the internet population has a Myspace. If you're part of the 98% that is an emo bastard, copy and paste this into your sig.
User Posted Image

Aug 19 2003 Anchor

Thank you...

Though I am still new at this... so maybe if you could help out a little more

so if H is from ChallengeHUD... I would do this?

class My_Mod expands ChallengeHUD;

if I wanted to expand : function Tick(float deltaTime)

How would I declare C and H?

- Edited By [BDA]Perseus On Tue 19th, Aug 2003 @ 9:44:17pm

Aug 20 2003 Anchor

Let me start by saying that I'm a UT2K3 coder, not UT. These functions are probably not exactly the same, but they are probably similar.

XInterface.HudBDeathMatch has the following function.

simulated function DrawCrosshair (Canvas C)
{
local float NormalScale;
local int i;
local float OldScale,OldW;

CrosshairStyle = Clamp(crosshairStyle, 0, Crosshairs.Length - 1);

if (!bCrosshairShow)
return;

NormalScale = Crosshairs[CrosshairStyle].TextureScale;
Crosshairs[CrosshairStyle].TextureScale *= CrosshairScale;

for( i = 0; i < ArrayCount(Crosshairs[CrosshairStyle].Tints); i++ )
{
CrossHairs[CrosshairStyle].Tints[i]= <b>CrossHairColor</b>;
//        NormalOpacity[i]= Crosshairs[CrosshairStyle].Tints[i].A;
//        Crosshairs[CrosshairStyle].Tints[i].A = float(Crosshairs[CrosshairStyle].Tints[i].A) * CrosshairOpacity;
}

OldScale = HudScale;
HudScale=1;
OldW = C.ColorModulate.W;
C.ColorModulate.W = 1;

DrawSpriteWidget (C, Crosshairs[CrosshairStyle]);

C.ColorModulate.W = OldW;

HudScale=OldScale;

Crosshairs[CrosshairStyle].TextureScale = NormalScale;

//    for( i = 0; i &lt; ArrayCount(Crosshairs[CrosshairStyle].Tints); i++ )
//        Crosshairs[CrosshairStyle].Tints[i].A = NormalOpacity[i];

DrawEnemyName&copy;;
}

Engine.Hud has

var() globalconfig color <b>CrossHairColor</b>;

and

defaultproperties
{
bMessageBeep=true
bHidden=True
RemoteRole=ROLE_None

bHideHUD=false

ConsoleColor=(R=153,G=216,B=253,A=255)

ProgressFontName=&quot;UT2003Fonts.FontEurostile12&quot;
MOTDColor=(R=255,G=255,B=255,A=255)
ProgressFadeTime=1.0

HudCanvasScale=0.95
HudScale=1.0

bShowWeaponInfo=true
bShowPersonalInfo=true
bShowPoints=true
bShowWeaponBar=true
bShowPortrait=true

bCrosshairShow=true
CrosshairScale=1.0
CrosshairOpacity=1.0
CrosshairStyle=0
<b>CrossHairColor=(R=255,G=255,B=255,A=255)</b>

ConsoleMessagePosX=0.00
ConsoleMessagePosY=1.00

WhiteColor=(R=255,G=255,B=255,A=255)
RedColor=(R=255,G=0,B=0,A=255)
BlueColor=(R=0,G=0,B=255,A=255)
GreenColor=(R=0,G=255,B=0,A=255)
GoldColor=(R=255,G=255,B=0,A=255)
TurqColor=(R=0,G=128,B=255,A=255)
GrayColor=(R=200,G=200,B=200,A=255)
CyanColor=(R=0,G=255,B=255,A=255)
PurpleColor=(R=255,G=0,B=255,A=255)

FontArrayNames(0)=&quot;Engine.DefaultFont&quot;
FontArrayNames(1)=&quot;Engine.DefaultFont&quot;
FontArrayNames(2)=&quot;Engine.DefaultFont&quot;
FontArrayNames(3)=&quot;Engine.DefaultFont&quot;
FontArrayNames(4)=&quot;Engine.DefaultFont&quot;
FontArrayNames(5)=&quot;Engine.DefaultFont&quot;
FontArrayNames(6)=&quot;Engine.DefaultFont&quot;
FontArrayNames(7)=&quot;Engine.DefaultFont&quot;
FontArrayNames(8)=&quot;Engine.DefaultFont&quot;

HudOpacity=255
ConsoleMessageCount=4
ConsoleFontSize=5
MessageFontOffset=0

bBuiltMOTD=false
}

So... to change the default color, just set the CrossHairColor value in the defaultproperties of your class. To override the player's configured crosshair color, you need to override the DrawCrossHair(Canvas C) function.

[edit]
To answer your question about C and H variables, if you've extended (or expanded) ChallengeHUD for your class, then H == self. C is probably the Canvas object, and it is not passed into Tick() as a parameter, so you'd have to create your own var Canvas myCanvas variable and set the value of myCanvas within some other function that actually passes Canvas as a parameter. Then, once you've got that variable set, C == myCanvas. If you do that, be sure to check for none to prevent AccessedNone errors.

Why do you want to mess around in Tick() anyway?
[/edit]

- Edited By scope.creep On Wed 20th, Aug 2003 @ 9:22:21am

[edit]
You may also be able to get the Canvas object by some sort of GetCanvas() function. Like I said, I'm not a UT coder.
[/edit]

- Edited By scope.creep On Wed 20th, Aug 2003 @ 9:25:19am

--

Give me ambiguity or give me... something else.

Dominant Species scope.creep User Posted Image

Reply to thread
click to sign in and post

Only registered members can share their thoughts. So come on! Join the community today (totally free - or sign in with your social account on the right) and join in the conversation.