Crosshairs



The crosshair is the graphic item in the center of your screen that you use to aim.
(a cross, a circle, a dot)

You can not use custom graphics for you crosshair.

But you can still have a custom crosshair.

This is my crosshair:

(click on the image to see a large version)



This is the code.
Just paste it after the line. #include "ui/menudef.h"

//--------------CUSTOM CROSSHAIR

menuDef {
rect 10 10 620 360
fullScreen MENU_FALSE
visible MENU_TRUE

// horizontal line left
itemDef {
rect 100 229.5 200 1
style WINDOW_STYLE_FILLED
backcolor 1 1 0 1
visible 1
}

// horizontal line right
itemDef {
rect 320 229.5 200 1
style WINDOW_STYLE_FILLED
backcolor 1 1 0 1
visible 1
}

// vertical line top
itemDef {
rect 309.5 50 1 170
style WINDOW_STYLE_FILLED
backcolor 1 1 0 1
visible 1
}

// vertical line bottom
itemDef {
rect 309.5 240 1 130
style WINDOW_STYLE_FILLED
backcolor 1 1 0 1
visible 1
}
}
New: a crosshair that changes color depending on your health value.
// little thin "+" custom crosshair
// changes color depending on your
// health value

menuDef {
rect 314.5 234.5 40 40
fullScreen MENU_FALSE
visible MENU_TRUE

//horizontal line
itemDef {
rect 0 5 10 .5
visible 1
ownerdraw CG_PLAYER_HEALTH
background "ui/assets/score/statsfillm.png"
addColorRange 0 50 1 0 0 1
addColorRange 51 100 1 1 0 1
addColorRange 101 200 0 1 0 1
}

//vertical line
itemDef {
rect 5 0 .5 10
visible 1
ownerdraw CG_PLAYER_HEALTH
background "ui/assets/score/statsfillm.png"
addColorRange 0 50 1 0 0 1
addColorRange 51 100 1 1 0 1
addColorRange 101 200 0 1 0 1
}

}


Another example (rather ugly):

(click on the image to see a large version)

In this case, I used the letter "x" and a dark background to improve contrast.
This is the code:

//--------------CUSTOM CROSSHAIR 2

menuDef {
rect 314.5 235 11 9
fullScreen MENU_FALSE
visible MENU_TRUE
//following two lines draw the dark background
style WINDOW_STYLE_FILLED
backcolor 0 0 0 .6

//letter x
itemDef {
rect 0 11 10 10
visible 1
textscale .4
text "x"
}
}


Animated crosshair that changes color (read & blue for team games, yellow for non-team games).

(click on the image to see a large version)

This is the code:

//--------------CUSTOM CROSSHAIR 3

menuDef {
rect 315 235 40 40
fullScreen MENU_FALSE
visible MENU_TRUE


itemDef {
rect 0 0 10 10
visible 1
style WINDOW_STYLE_FILLED
backcolor 1 1 0 .5
//this is the command that auto-changes color
ownerdraw CG_TEAM_COLORIZED

//this is the animated fan
background "textures/sfx/fan.png"
}
}




As you can see you can get creative and customize your crosshair.

2 comments:

  1. hey , how rotate the lines ?

    ReplyDelete
  2. It is NOT possible to make items rotate.
    I simply used an animated image.

    ReplyDelete