Browse Source

fix the crosshair

master
Alison Watson 2 months ago
parent
commit
d319a39ade
26 changed files with 86 additions and 80 deletions
  1. +20
    -20
      pk7/language.gfx.txt
  2. +0
    -0
      pk7/lgfx/XHairs/angleb.png
  3. +0
    -0
      pk7/lgfx/XHairs/anglew.png
  4. +0
    -0
      pk7/lgfx/XHairs/basicb.png
  5. +0
    -0
      pk7/lgfx/XHairs/basicw.png
  6. +0
    -0
      pk7/lgfx/XHairs/circleb.png
  7. +0
    -0
      pk7/lgfx/XHairs/circlew.png
  8. +0
    -0
      pk7/lgfx/XHairs/crossb.png
  9. +0
    -0
      pk7/lgfx/XHairs/crossw.png
  10. +0
    -0
      pk7/lgfx/XHairs/delearb.png
  11. +0
    -0
      pk7/lgfx/XHairs/delearw.png
  12. +0
    -0
      pk7/lgfx/XHairs/deltab.png
  13. +0
    -0
      pk7/lgfx/XHairs/deltaw.png
  14. +0
    -0
      pk7/lgfx/XHairs/dotb.png
  15. +0
    -0
      pk7/lgfx/XHairs/dotw.png
  16. +0
    -0
      pk7/lgfx/XHairs/finib.png
  17. +0
    -0
      pk7/lgfx/XHairs/finiw.png
  18. +0
    -0
      pk7/lgfx/XHairs/ovalb.png
  19. +0
    -0
      pk7/lgfx/XHairs/ovalw.png
  20. +0
    -0
      pk7/lgfx/XHairs/xpb.png
  21. +0
    -0
      pk7/lgfx/XHairs/xpw.png
  22. +2
    -2
      pk7/lzscript/Client/Draw.zsc
  23. +10
    -9
      source/include/p_player.h
  24. +2
    -0
      source/p_player.c
  25. +51
    -49
      source/p_render.c
  26. +1
    -0
      source/p_settings.c

+ 20
- 20
pk7/language.gfx.txt View File

@@ -703,25 +703,25 @@ identifier,default
:Weapon:RendHit2,lgfx/Weapon/RendHit2.png
:Weapon:RendHit3,lgfx/Weapon/RendHit3.png
:Weapon:RendHit4,lgfx/Weapon/RendHit4.png
:XHairs:0b,lgfx/XHairs/0b.png
:XHairs:0w,lgfx/XHairs/0w.png
:XHairs:1b,lgfx/XHairs/1b.png
:XHairs:1w,lgfx/XHairs/1w.png
:XHairs:2b,lgfx/XHairs/2b.png
:XHairs:2w,lgfx/XHairs/2w.png
:XHairs:3b,lgfx/XHairs/3b.png
:XHairs:3w,lgfx/XHairs/3w.png
:XHairs:4b,lgfx/XHairs/4b.png
:XHairs:4w,lgfx/XHairs/4w.png
:XHairs:5b,lgfx/XHairs/5b.png
:XHairs:5w,lgfx/XHairs/5w.png
:XHairs:6b,lgfx/XHairs/6b.png
:XHairs:6w,lgfx/XHairs/6w.png
:XHairs:7b,lgfx/XHairs/7b.png
:XHairs:7w,lgfx/XHairs/7w.png
:XHairs:8b,lgfx/XHairs/8b.png
:XHairs:8w,lgfx/XHairs/8w.png
:XHairs:9b,lgfx/XHairs/9b.png
:XHairs:9w,lgfx/XHairs/9w.png
:XHairs:L,lgfx/XHairs/L.png
:XHairs:R,lgfx/XHairs/R.png
:XHairs:angleb,lgfx/XHairs/angleb.png
:XHairs:anglew,lgfx/XHairs/anglew.png
:XHairs:basicb,lgfx/XHairs/basicb.png
:XHairs:basicw,lgfx/XHairs/basicw.png
:XHairs:circleb,lgfx/XHairs/circleb.png
:XHairs:circlew,lgfx/XHairs/circlew.png
:XHairs:crossb,lgfx/XHairs/crossb.png
:XHairs:crossw,lgfx/XHairs/crossw.png
:XHairs:delearb,lgfx/XHairs/delearb.png
:XHairs:delearw,lgfx/XHairs/delearw.png
:XHairs:deltab,lgfx/XHairs/deltab.png
:XHairs:deltaw,lgfx/XHairs/deltaw.png
:XHairs:dotb,lgfx/XHairs/dotb.png
:XHairs:dotw,lgfx/XHairs/dotw.png
:XHairs:finib,lgfx/XHairs/finib.png
:XHairs:finiw,lgfx/XHairs/finiw.png
:XHairs:ovalb,lgfx/XHairs/ovalb.png
:XHairs:ovalw,lgfx/XHairs/ovalw.png
:XHairs:xpb,lgfx/XHairs/xpb.png
:XHairs:xpw,lgfx/XHairs/xpw.png

pk7/lgfx/XHairs/7b.png → pk7/lgfx/XHairs/angleb.png View File


pk7/lgfx/XHairs/7w.png → pk7/lgfx/XHairs/anglew.png View File


pk7/lgfx/XHairs/4b.png → pk7/lgfx/XHairs/basicb.png View File


pk7/lgfx/XHairs/4w.png → pk7/lgfx/XHairs/basicw.png View File


pk7/lgfx/XHairs/1b.png → pk7/lgfx/XHairs/circleb.png View File


pk7/lgfx/XHairs/1w.png → pk7/lgfx/XHairs/circlew.png View File


pk7/lgfx/XHairs/0b.png → pk7/lgfx/XHairs/crossb.png View File


pk7/lgfx/XHairs/0w.png → pk7/lgfx/XHairs/crossw.png View File


pk7/lgfx/XHairs/5b.png → pk7/lgfx/XHairs/delearb.png View File


pk7/lgfx/XHairs/5w.png → pk7/lgfx/XHairs/delearw.png View File


pk7/lgfx/XHairs/2b.png → pk7/lgfx/XHairs/deltab.png View File


pk7/lgfx/XHairs/2w.png → pk7/lgfx/XHairs/deltaw.png View File


pk7/lgfx/XHairs/8b.png → pk7/lgfx/XHairs/dotb.png View File


pk7/lgfx/XHairs/8w.png → pk7/lgfx/XHairs/dotw.png View File


pk7/lgfx/XHairs/6b.png → pk7/lgfx/XHairs/finib.png View File


pk7/lgfx/XHairs/6w.png → pk7/lgfx/XHairs/finiw.png View File


pk7/lgfx/XHairs/3b.png → pk7/lgfx/XHairs/ovalb.png View File


pk7/lgfx/XHairs/3w.png → pk7/lgfx/XHairs/ovalw.png View File


pk7/lgfx/XHairs/9b.png → pk7/lgfx/XHairs/xpb.png View File


pk7/lgfx/XHairs/9w.png → pk7/lgfx/XHairs/xpw.png View File


+ 2
- 2
pk7/lzscript/Client/Draw.zsc View File

@@ -182,7 +182,7 @@ static void LL(Actor mo, int x, int y, int z, int w, color c = 0)
---- ---- ---- ---- ---- ---1 ---- ---- 8 1 - additive flag
---- ---- ---- ---- ---- ---- 1111 1111 0 8 - alpha OR fade num
*/
static void LS(Actor mo, string tex, int arg0, int arg1, int arg2, string arg3 = "")
static void LS(Actor mo, string tex, int arg0, int arg1, int arg2, int arg3 = 0)
{
let cl = Lith_URANUS(Find("Lith_URANUS"));
if(!cl.m_ForceDraw && mo != Players[ConsolePlayer].Camera) return;
@@ -217,7 +217,7 @@ static void LS(Actor mo, string tex, int arg0, int arg1, int arg2, string arg3 =
else
cl.m_D[p].Style = STYLE_Normal;

if(arg3 != "") {
if(arg3 != 0) {
if(cl.m_D[p].Type == Type_SpriteAlpha)
cl.m_D[p].Type = Type_SpriteStencilAlpha;
else


+ 10
- 9
source/include/p_player.h View File

@@ -144,15 +144,16 @@ void P_Log_SellWeapon(struct player *p, struct weaponinfo const *info, i96 score
void P_Log_Weapon(struct player *p, struct weaponinfo const *info);
i32 P_Wep_FromName(struct player *p, i32 name);

script extern void P_Wep_PTickPre(struct player *p);
extern void P_Dat_PTickPre(struct player *p);
script extern void P_CBI_PTick (struct player *p);
script extern void P_Inv_PTick (struct player *p);
script extern void P_Log_PTick (struct player *p);
script extern void P_Upg_PTick (struct player *p);
script extern void P_Wep_PTick (struct player *p);
script extern void P_Upg_PTickPst(struct player *p);
extern void P_Ren_PTickPst(struct player *p);
script void P_Wep_PTickPre (struct player *p);
void P_Dat_PTickPre (struct player *p);
script void P_CBI_PTick (struct player *p);
script void P_Inv_PTick (struct player *p);
script void P_Log_PTick (struct player *p);
script void P_Upg_PTick (struct player *p);
script void P_Wep_PTick (struct player *p);
script void P_Upg_PTickPst (struct player *p);
void P_Ren_PTickPst (struct player *p);
void P_Ren_Crosshair(struct player *p);

script void P_TeleportIn (struct player *p);
sync void P_TeleportOut(struct player *p, i32 tag);


+ 2
- 0
source/p_player.c View File

@@ -82,6 +82,8 @@ reinit:
P_Wep_PTickPre(p); /* Update weapon info */
P_Scr_PTickPre(p); /* Update score */

P_Ren_Crosshair(p);

if(!p->dead) P_Upg_PTick(p);
P_Upg_PTickPst(p);



+ 51
- 49
source/p_render.c View File

@@ -54,8 +54,30 @@ static void P_Ren_LevelUp(struct player *p) {
}
}

script static
/* Extern Functions -------------------------------------------------------- */

void P_Ren_PTickPst(struct player *p) {
P_Ren_Magic(p);
P_Ren_Step(p);
P_Ren_View(p);
P_Ren_Scope(p);
P_Ren_Style(p);
P_Ren_Advice(p);
P_Ren_LevelUp(p);
#ifndef NDEBUG
P_Ren_Debug(p);
#endif
}

void P_Ren_Crosshair(struct player *p) {
Str(sc_xhair_r, sCVAR "xhair_r");
Str(sc_xhair_g, sCVAR "xhair_g");
Str(sc_xhair_b, sCVAR "xhair_b");
Str(sc_xhair_a, sCVAR "xhair_a");
Str(sc_xhair_style, sCVAR "xhair_style");
Str(sc_xhair_enable, sCVAR "xhair_enable");
Str(sc_xhair_enablejuicer, sCVAR "xhair_enablejuicer");

SetSize(320, 240);

/* trace to where the crosshair should be in world space */
@@ -66,15 +88,14 @@ void P_Ren_Crosshair(struct player *p) {
/* unproject */
bool seen;
struct i32v2 xh = unproject(loc.x, loc.y, loc.z, &seen);

if(!seen) {
return;
}

/* draw a tracer for the targeting system */
if(P_Wep_CurType(p) == weapon_launcher &&
ACS_SetActivator(0, AAPTR_TRACER) && GetHealth(0) > 0) {
ACS_SetActivator(0, AAPTR_TRACER) &&
GetHealth(0) > 0) {
k32 x = GetX(0);
k32 y = GetY(0);
k32 z = GetZ(0) + GetHeight(0) / 2;
@@ -89,54 +110,35 @@ void P_Ren_Crosshair(struct player *p) {
p->setActivator();

/* draw the crosshair */
Str(sc_xhair_r, sCVAR "xhair_r");
Str(sc_xhair_g, sCVAR "xhair_g");
Str(sc_xhair_b, sCVAR "xhair_b");
Str(sc_xhair_a, sCVAR "xhair_a");
Str(sc_xhair_style, sCVAR "xhair_style");
Str(sc_xhair_enablejuicer, sCVAR "xhair_enablejuicer");

u32 r = p->getCVarI(sc_xhair_r); r = min(r, 255);
u32 g = p->getCVarI(sc_xhair_g); g = min(g, 255);
u32 b = p->getCVarI(sc_xhair_b); b = min(b, 255);
k32 a = p->getCVarI(sc_xhair_a); a = min(a, 255) / 255.0k;
u32 c = (r << 24) | (g << 16) | (b << 8);

i32 style = p->getCVarI(sc_xhair_style);

str gb = StrParam(":XHairs:%ib", style);
str gw = StrParam(":XHairs:%iw", style);

PrintSpriteA (gb, xh.x,0, xh.y,0, a);
PrintSpriteAC(gb, xh.x,0, xh.y,0, a, c);

if(p->getCVarI(sc_xhair_enablejuicer)) {
Str(sp_xhairs_l, s":XHairs:L");
Str(sp_xhairs_r, s":XHairs:R");

i32 xp = ceilk(p->extrpitch * 500.0k) + 10;

PrintSpriteAC(sp_xhairs_l, xh.x - xp,0, xh.y,0, a, c);
PrintSpriteAC(sp_xhairs_r, xh.x + xp,0, xh.y,0, a, c);
u32 r = p->getCVarI(sc_xhair_r); if(r > 255) r = 255;
u32 g = p->getCVarI(sc_xhair_g); if(g > 255) g = 255;
u32 b = p->getCVarI(sc_xhair_b); if(b > 255) b = 255;
k32 a = p->getCVarI(sc_xhair_a); if(a > 255) a = 255; a /= 255.0k;

if(p->getCVarI(sc_xhair_enable) && a > 0.0k) {
StrAry(xb, s":XHairs:circleb", s":XHairs:deltab", s":XHairs:ovalb",
s":XHairs:basicb", s":XHairs:delearb", s":XHairs:finib",
s":XHairs:angleb", s":XHairs:dotb", s":XHairs:xpb");
StrAry(xw, s":XHairs:circlew", s":XHairs:deltaw", s":XHairs:ovalw",
s":XHairs:basicw", s":XHairs:delearw", s":XHairs:finiw",
s":XHairs:anglew", s":XHairs:dotw", s":XHairs:xpw");

u32 c = (r << 16) | (g << 8) | (b << 0);
i32 style = p->getCVarI(sc_xhair_style);
PrintSpriteA (xb[style], xh.x,0, xh.y,0, a);
PrintSpriteAC(xw[style], xh.x,0, xh.y,0, a, c);

if(p->getCVarI(sc_xhair_enablejuicer)) {
Str(sp_xhairs_l, s":XHairs:L");
Str(sp_xhairs_r, s":XHairs:R");

i32 xp = ceilk(p->extrpitch * 500.0k) + 10;
PrintSpriteAC(sp_xhairs_l, xh.x - xp,0, xh.y,0, a, c);
PrintSpriteAC(sp_xhairs_r, xh.x + xp,0, xh.y,0, a, c);
}
}
}

/* Extern Functions -------------------------------------------------------- */

void P_Ren_PTickPst(struct player *p) {
P_Ren_Magic(p);
P_Ren_Step(p);
P_Ren_View(p);
P_Ren_Scope(p);
P_Ren_Style(p);
P_Ren_Advice(p);
P_Ren_LevelUp(p);
P_Ren_Crosshair(p);
#ifndef NDEBUG
P_Ren_Debug(p);
#endif
}

alloc_aut(0) script
void P_TeleportIn(struct player *p) {
p->teleportedout = false;


+ 1
- 0
source/p_settings.c View File

@@ -248,6 +248,7 @@ struct setting const st_hud[] = {
{S_integ, "xhair_r", S_clInteg, S_bndi(0, 255), "byte"},
{S_integ, "xhair_g", S_clInteg, S_bndi(0, 255), "byte"},
{S_integ, "xhair_b", S_clInteg, S_bndi(0, 255), "byte"},
{S_integ, "xhair_a", S_clInteg, S_bndi(0, 255), "byte"},
{S_empty},
{S_integ, "scanner_xoffs", S_clInteg, S_bndi(-160, 160), "pxls"},
{S_integ, "scanner_yoffs", S_clInteg, S_bndi(-160, 160), "pxls"},


Loading…
Cancel
Save