From a5a370ef8f853dbc161a34685a99454a5ed7fa4d Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Tue, 25 May 2021 08:38:06 +0200 Subject: [PATCH] Shared: Add isempty function pointers to the respective weapons that need it. --- src/shared/w_displacer.qc | 16 ++++++++++++++-- src/shared/w_eagle.qc | 21 +++++++++++++++++---- src/shared/w_m249.qc | 16 ++++++++++++++-- src/shared/w_shockrifle.qc | 16 ++++++++++++++-- src/shared/w_sniperrifle.qc | 22 +++++++++++++++++++--- src/shared/w_sporelauncher.qc | 16 ++++++++++++++-- 6 files changed, 92 insertions(+), 15 deletions(-) diff --git a/src/shared/w_displacer.qc b/src/shared/w_displacer.qc index 6b1d19f..8fe326c 100644 --- a/src/shared/w_displacer.qc +++ b/src/shared/w_displacer.qc @@ -306,6 +306,17 @@ w_displacer_hud(void) #endif } +int +w_displacer_isempty(void) +{ + player pl = (player)self; + + if (pl.ammo_uranium <= 0) + return 1; + + return 0; +} + void w_displacer_hudpic(int selected, vector pos, float a) { @@ -313,7 +324,7 @@ w_displacer_hudpic(int selected, vector pos, float a) player pl = (player)self; vector hud_col; - if (pl.ammo_uranium == 0) + if (w_displacer_isempty()) hud_col = [1,0,0]; else hud_col = g_hud_color; @@ -366,7 +377,8 @@ weapon_t w_displacer = .pmodel = w_displacer_pmodel, .deathmsg = w_displacer_deathmsg, .aimanim = w_displacer_aimanim, - .hudpic = w_displacer_hudpic + .hudpic = w_displacer_hudpic, + .isempty = w_displacer_isempty }; /* entity definitions for pickups */ diff --git a/src/shared/w_eagle.qc b/src/shared/w_eagle.qc index 05a122a..8400ba6 100644 --- a/src/shared/w_eagle.qc +++ b/src/shared/w_eagle.qc @@ -185,6 +185,7 @@ w_eagle_primary(void) #else View_SetMuzzleflash(MUZZLE_SMALL); #endif + pl.w_idle_next = 10.0f; } void @@ -317,6 +318,17 @@ w_eagle_aimanim(void) return self.flags & FL_CROUCHING ? ANIM_CR_AIMPYTHON : ANIM_AIMPYTHON; } +int +w_eagle_isempty(void) +{ + player pl = (player)self; + + if (pl.eagle_mag <= 0 && pl.ammo_357 <= 0) + return 1; + + return 0; +} + void w_eagle_hudpic(int selected, vector pos, float a) { @@ -324,7 +336,7 @@ w_eagle_hudpic(int selected, vector pos, float a) player pl = (player)self; vector hud_col; - if (pl.eagle_mag == 0 && pl.ammo_357 == 0) + if (w_eagle_isempty()) hud_col = [1,0,0]; else hud_col = g_hud_color; @@ -336,7 +348,7 @@ w_eagle_hudpic(int selected, vector pos, float a) "sprites/640hudof02.spr_0.tga", [0,90/256], [170/256,45/256], - g_hud_color, + hud_col, a, DRAWFLAG_ADDITIVE ); @@ -347,7 +359,7 @@ w_eagle_hudpic(int selected, vector pos, float a) "sprites/640hudof01.spr_0.tga", [0,90/256], [170/256,45/256], - g_hud_color, + hud_col, a, DRAWFLAG_ADDITIVE ); @@ -377,7 +389,8 @@ weapon_t w_eagle = .pmodel = w_eagle_pmodel, .deathmsg = w_eagle_deathmsg, .aimanim = w_eagle_aimanim, - .hudpic = w_eagle_hudpic + .hudpic = w_eagle_hudpic, + .isempty = w_eagle_isempty }; #ifdef SERVER diff --git a/src/shared/w_m249.qc b/src/shared/w_m249.qc index 439292e..be61078 100644 --- a/src/shared/w_m249.qc +++ b/src/shared/w_m249.qc @@ -268,6 +268,17 @@ w_m249_aimanim(void) return self.flags & ANIM_CR_AIMMP5 ? ANIM_CR_AIMCROWBAR : ANIM_AIMMP5; } +int +w_m249_isempty(void) +{ + player pl = (player)self; + + if (pl.m249_mag <= 0 && pl.ammo_556 <= 0) + return 1; + + return 0; +} + void w_m249_hudpic(int selected, vector pos, float a) { @@ -275,7 +286,7 @@ w_m249_hudpic(int selected, vector pos, float a) player pl = (player)self; vector hud_col; - if (pl.m249_mag == 0 && pl.ammo_556 == 0) + if (w_m249_isempty()) hud_col = [1,0,0]; else hud_col = g_hud_color; @@ -328,7 +339,8 @@ weapon_t w_m249 = .pmodel = w_m249_pmodel, .deathmsg = w_m249_deathmsg, .aimanim = w_m249_aimanim, - .hudpic = w_m249_hudpic + .hudpic = w_m249_hudpic, + .isempty = w_m249_isempty }; #ifdef SERVER diff --git a/src/shared/w_shockrifle.qc b/src/shared/w_shockrifle.qc index 1f75848..14f7241 100644 --- a/src/shared/w_shockrifle.qc +++ b/src/shared/w_shockrifle.qc @@ -238,6 +238,17 @@ w_shockrifle_aimanim(void) return self.flags & FL_CROUCHING ? ANIM_CR_AIMHIVE : ANIM_AIMHIVE; } +int +w_shockrifle_isempty(void) +{ + player pl = (player)self; + + if (pl.ammo_shock <= 0) + return 1; + + return 0; +} + void w_shockrifle_hudpic(int selected, vector pos, float a) { @@ -245,7 +256,7 @@ w_shockrifle_hudpic(int selected, vector pos, float a) player pl = (player)self; vector hud_col; - if (pl.ammo_shock == 0) + if (w_shockrifle_isempty()) hud_col = [1,0,0]; else hud_col = g_hud_color; @@ -298,7 +309,8 @@ weapon_t w_shockrifle = .pmodel = w_shockrifle_pmodel, .deathmsg = w_shockrifle_deathmsg, .aimanim = w_shockrifle_aimanim, - .hudpic = w_shockrifle_hudpic + .hudpic = w_shockrifle_hudpic, + .isempty = w_shockrifle_isempty }; #ifdef SERVER diff --git a/src/shared/w_sniperrifle.qc b/src/shared/w_sniperrifle.qc index d752c09..10ec279 100644 --- a/src/shared/w_sniperrifle.qc +++ b/src/shared/w_sniperrifle.qc @@ -125,7 +125,11 @@ w_sniperrifle_primary(void) } #ifdef SERVER - TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 40, [0.00873, 0.00873], WEAPON_SNIPERRIFLE); + if (pl.viewzoom != 1.0) + TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 65, [0, 0], WEAPON_SNIPERRIFLE); + else + TraceAttack_FireBullets(1, pl.origin + pl.view_ofs, 65, [0.05, 0.05], WEAPON_SNIPERRIFLE); + sound(pl, CHAN_WEAPON, "weapons/sniper_fire.wav", 1, ATTN_NORM); #else View_SetMuzzleflash(MUZZLE_SMALL); @@ -253,6 +257,17 @@ w_sniperrifle_aimanim(void) return self.flags & FL_CROUCHING ? ANIM_CR_AIMPYTHON : ANIM_AIMPYTHON; } +int +w_sniperrifle_isempty(void) +{ + player pl = (player)self; + + if (pl.sniper_mag <= 0 && pl.ammo_762 <= 0) + return 1; + + return 0; +} + void w_sniperrifle_hudpic(int s, vector pos, float a) { @@ -260,7 +275,7 @@ w_sniperrifle_hudpic(int s, vector pos, float a) player pl = (player)self; vector hud_col; - if (pl.sniper_mag == 0 && pl.ammo_762 == 0) + if (w_sniperrifle_isempty()) hud_col = [1,0,0]; else hud_col = g_hud_color; @@ -295,7 +310,8 @@ weapon_t w_sniperrifle = .pmodel = w_sniperrifle_pmodel, .deathmsg = w_sniperrifle_deathmsg, .aimanim = w_sniperrifle_aimanim, - .hudpic = w_sniperrifle_hudpic + .hudpic = w_sniperrifle_hudpic, + .isempty = w_sniperrifle_isempty }; #ifdef SERVER diff --git a/src/shared/w_sporelauncher.qc b/src/shared/w_sporelauncher.qc index 22af678..3784a2b 100644 --- a/src/shared/w_sporelauncher.qc +++ b/src/shared/w_sporelauncher.qc @@ -381,6 +381,17 @@ w_sporelauncher_aimanim(void) return self.flags & FL_CROUCHING ? ANIM_CR_AIMBOW : ANIM_AIMBOW; } +int +w_sporelauncher_isempty(void) +{ + player pl = (player)self; + + if (pl.sporelauncher_mag <= 0 && pl.ammo_spore <= 0) + return 1; + + return 0; +} + void w_sporelauncher_hudpic(int selected, vector pos, float a) { @@ -388,7 +399,7 @@ w_sporelauncher_hudpic(int selected, vector pos, float a) player pl = (player)self; vector hud_col; - if (pl.sporelauncher_mag == 0 && pl.ammo_spore == 0) + if (w_sporelauncher_isempty()) hud_col = [1,0,0]; else hud_col = g_hud_color; @@ -441,7 +452,8 @@ weapon_t w_sporelauncher = .pmodel = w_sporelauncher_pmodel, .deathmsg = w_sporelauncher_deathmsg, .aimanim = w_sporelauncher_aimanim, - .hudpic = w_sporelauncher_hudpic + .hudpic = w_sporelauncher_hudpic, + .isempty = w_sporelauncher_isempty }; #ifdef SERVER