From 66b629b83a55eadd9099f4eacceeb3898ae09f1d Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Tue, 24 Mar 2020 16:20:58 +0100 Subject: [PATCH] Valve: Basic weapon pickup notification, cl_autoweaponswitch --- src/client/gearbox/hud_weaponselect.c | 4 ++-- src/client/rewolf/hud.c | 6 ++++++ src/client/rewolf/hud_weaponselect.c | 4 ++-- src/client/valve/defs.h | 5 +++++ src/client/valve/game_event.c | 8 ++++++++ src/client/valve/hud.c | 24 +++++++++++++++++++++++ src/client/valve/hud_weaponselect.c | 4 ++-- src/shared/events.h | 1 + src/shared/valve/w_crossbow.c | 6 +++--- src/shared/valve/w_crowbar.c | 6 +++--- src/shared/valve/w_egon.c | 8 ++++---- src/shared/valve/w_gauss.c | 6 +++--- src/shared/valve/w_glock.c | 6 +++--- src/shared/valve/w_handgrenade.c | 8 ++++---- src/shared/valve/w_hornetgun.c | 10 +++++----- src/shared/valve/w_mp5.c | 6 +++--- src/shared/valve/w_python.c | 6 +++--- src/shared/valve/w_rpg.c | 8 ++++---- src/shared/valve/w_satchel.c | 8 ++++---- src/shared/valve/w_shotgun.c | 8 ++++---- src/shared/valve/w_snark.c | 8 ++++---- src/shared/valve/w_tripmine.c | 8 ++++---- src/shared/valve/weapon_common.c | 28 +++++++++++++++++++++------ src/shared/valve/weapon_common.h | 4 ++-- 24 files changed, 125 insertions(+), 65 deletions(-) diff --git a/src/client/gearbox/hud_weaponselect.c b/src/client/gearbox/hud_weaponselect.c index bbfeb8d0..becf7d7d 100644 --- a/src/client/gearbox/hud_weaponselect.c +++ b/src/client/gearbox/hud_weaponselect.c @@ -145,14 +145,14 @@ void HUD_DrawWeaponSelect(void) slot_selected = TRUE; if (x == wantpos) { // Selected Sprite - Weapons_HUDPic(pSeat->fHUDWeaponSelected, 1, vecPos); + Weapons_HUDPic(pSeat->fHUDWeaponSelected, 1, vecPos, 1.0f); drawsubpic(vecPos, [170,45], "sprites/640hud3.spr_0.tga", [0,180/256], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); vecPos[1] += 50; } else if ((b=HUD_InSlotPos(i, x)) != -1) { // Unselected Sprite - Weapons_HUDPic(b, 0, vecPos); + Weapons_HUDPic(b, 0, vecPos, 1.0f); vecPos[1] += 50; } } else if (HUD_InSlotPos(i, x) != -1) { diff --git a/src/client/rewolf/hud.c b/src/client/rewolf/hud.c index 0d364562..481e71b2 100644 --- a/src/client/rewolf/hud.c +++ b/src/client/rewolf/hud.c @@ -249,6 +249,12 @@ void HUD_DrawAmmo3(void) } } +void +HUD_WeaponPickupNotify(int w) +{ + +} + void HUD_Draw(void) { g_hud_color = autocvar_con_color * (1 / 255); diff --git a/src/client/rewolf/hud_weaponselect.c b/src/client/rewolf/hud_weaponselect.c index fd5588d4..02a4a00b 100644 --- a/src/client/rewolf/hud_weaponselect.c +++ b/src/client/rewolf/hud_weaponselect.c @@ -147,13 +147,13 @@ void HUD_DrawWeaponSelect(void) slot_selected = TRUE; if (x == wantpos) { // Selected Sprite - Weapons_HUDPic(pSeat->fHUDWeaponSelected, 1, vecPos); + Weapons_HUDPic(pSeat->fHUDWeaponSelected, 1, vecPos, 1.0f); drawsubpic(vecPos, [170,45], "sprites/640hud3.spr_0.tga", [0,180/256], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); vecPos[1] += 50; } else if ((b=HUD_InSlotPos(i, x)) != -1) { // Unselected Sprite - Weapons_HUDPic(b, 0, vecPos); + Weapons_HUDPic(b, 0, vecPos, 1.0f); vecPos[1] += 50; } } else if (HUD_InSlotPos(i, x) != -1) { diff --git a/src/client/valve/defs.h b/src/client/valve/defs.h index d5353599..b8e1f7b6 100644 --- a/src/client/valve/defs.h +++ b/src/client/valve/defs.h @@ -14,6 +14,8 @@ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ +var int autocvar_cl_autoweaponswitch = TRUE; + vector g_hud_color; struct @@ -59,6 +61,8 @@ struct float ammo2_alpha; float ammo3_old; float ammo3_alpha; + int pickup_weapon; + float pickup_alpha; /* This is seperated from the other VGUI stuff so we can check scores * while buying and whatnot */ @@ -77,3 +81,4 @@ struct void HUD_DrawAmmo1(void); void HUD_DrawAmmo2(void); void HUD_DrawAmmo3(void); +void HUD_WeaponPickupNotify(int); diff --git a/src/client/valve/game_event.c b/src/client/valve/game_event.c index 62255910..a5d527fa 100644 --- a/src/client/valve/game_event.c +++ b/src/client/valve/game_event.c @@ -32,5 +32,13 @@ void Game_Parse_Event(float fHeader) Sound_PlayVOX(readstring()); } else if (fHeader == EV_VIEWMODEL) { View_PlayAnimation(readbyte()); + } else if (fHeader == EV_WEAPON_PICKUP) { + float w = readbyte(); + + if (autocvar_cl_autoweaponswitch == 1) { + sendevent("PlayerSwitchWeapon", "f", w); + } + + HUD_WeaponPickupNotify(w); } } diff --git a/src/client/valve/hud.c b/src/client/valve/hud.c index 7990fad6..b858537c 100644 --- a/src/client/valve/hud.c +++ b/src/client/valve/hud.c @@ -363,6 +363,29 @@ HUD_DrawLogo(void) } } +/* weapon/ammo pickup notifications */ + +void +HUD_DrawNotify(void) +{ + vector pos; + + if (pSeat->pickup_alpha <= 0.0f) { + return; + } + + pos = video_mins + [video_res[0] - 192, video_res[1] - 128]; + Weapons_HUDPic(pSeat->pickup_weapon, 1, pos, pSeat->pickup_alpha); + pSeat->pickup_alpha -= frametime; +} + +void +HUD_WeaponPickupNotify(int w) +{ + pSeat->pickup_weapon = w; + pSeat->pickup_alpha = 1.0f; +} + /* main entry */ void HUD_Draw(void) @@ -382,6 +405,7 @@ HUD_Draw(void) HUD_DrawHealth(); HUD_DrawArmor(); HUD_DrawFlashlight(); + HUD_DrawNotify(); Damage_Draw(); } diff --git a/src/client/valve/hud_weaponselect.c b/src/client/valve/hud_weaponselect.c index 3e2f12e6..3efbce13 100644 --- a/src/client/valve/hud_weaponselect.c +++ b/src/client/valve/hud_weaponselect.c @@ -139,13 +139,13 @@ void HUD_DrawWeaponSelect(void) slot_selected = TRUE; if (x == wantpos) { // Selected Sprite - Weapons_HUDPic(pSeat->fHUDWeaponSelected, 1, vecPos); + Weapons_HUDPic(pSeat->fHUDWeaponSelected, 1, vecPos, 1.0f); drawsubpic(vecPos, [170,45], "sprites/640hud3.spr_0.tga", [0,180/256], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); vecPos[1] += 50; } else if ((b=HUD_InSlotPos(i, x)) != -1) { // Unselected Sprite - Weapons_HUDPic(b, 0, vecPos); + Weapons_HUDPic(b, 0, vecPos, 1.0f); vecPos[1] += 50; } } else if (HUD_InSlotPos(i, x) != -1) { diff --git a/src/shared/events.h b/src/shared/events.h index 780cf264..41313083 100644 --- a/src/shared/events.h +++ b/src/shared/events.h @@ -20,6 +20,7 @@ enum { EV_WEAPON_PRIMARYATTACK, EV_WEAPON_SECONDARYATTACK, EV_WEAPON_RELOAD, + EV_WEAPON_PICKUP, EV_IMPACT, EV_GIBHUMAN, EV_BLOOD, diff --git a/src/shared/valve/w_crossbow.c b/src/shared/valve/w_crossbow.c index 607772fe..e9bbe410 100644 --- a/src/shared/valve/w_crossbow.c +++ b/src/shared/valve/w_crossbow.c @@ -331,7 +331,7 @@ w_crossbow_aimanim(void) } void -w_crossbow_hudpic(int selected, vector pos) +w_crossbow_hudpic(int selected, vector pos, float a) { #ifdef CSQC if (selected) { @@ -342,7 +342,7 @@ w_crossbow_hudpic(int selected, vector pos) [0,0], [170/256,45/256], g_hud_color, - 1.0f, + a, DRAWFLAG_ADDITIVE ); } else { @@ -353,7 +353,7 @@ w_crossbow_hudpic(int selected, vector pos) [0,0], [170/256,45/256], g_hud_color, - 1.0f, + a, DRAWFLAG_ADDITIVE ); } diff --git a/src/shared/valve/w_crowbar.c b/src/shared/valve/w_crowbar.c index 9d1e03d9..4a80ed17 100644 --- a/src/shared/valve/w_crowbar.c +++ b/src/shared/valve/w_crowbar.c @@ -185,7 +185,7 @@ w_crowbar_aimanim(void) } void -w_crowbar_hudpic(int selected, vector pos) +w_crowbar_hudpic(int selected, vector pos, float a) { #ifdef CSQC if (selected) { @@ -196,7 +196,7 @@ w_crowbar_hudpic(int selected, vector pos) [0,0], [170/256,45/256], g_hud_color, - 1.0f, + a, DRAWFLAG_ADDITIVE ); } else { @@ -207,7 +207,7 @@ w_crowbar_hudpic(int selected, vector pos) [0,0], [170/256,45/256], g_hud_color, - 1.0f, + a, DRAWFLAG_ADDITIVE ); } diff --git a/src/shared/valve/w_egon.c b/src/shared/valve/w_egon.c index 8e87fabb..aeb9b05a 100644 --- a/src/shared/valve/w_egon.c +++ b/src/shared/valve/w_egon.c @@ -165,13 +165,13 @@ float w_egon_aimanim(void) return self.flags & FL_CROUCHING ? ANIM_CR_AIMEGON : ANIM_AIMEGON; } -void w_egon_hudpic(int s, vector pos) +void w_egon_hudpic(int selected, vector pos, float a) { #ifdef CSQC - if (s) { - drawsubpic(pos, [170,45], "sprites/640hud5.spr_0.tga", [0,135/256], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); + if (selected) { + drawsubpic(pos, [170,45], "sprites/640hud5.spr_0.tga", [0,135/256], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); } else { - drawsubpic(pos, [170,45], "sprites/640hud2.spr_0.tga", [0,135/256], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); + drawsubpic(pos, [170,45], "sprites/640hud2.spr_0.tga", [0,135/256], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); } #endif } diff --git a/src/shared/valve/w_gauss.c b/src/shared/valve/w_gauss.c index d12e1b19..7fcd819a 100644 --- a/src/shared/valve/w_gauss.c +++ b/src/shared/valve/w_gauss.c @@ -391,7 +391,7 @@ float w_gauss_aimanim(void) return self.flags & FL_CROUCHING ? ANIM_CR_AIMGAUSS : ANIM_AIMGAUSS; } -void w_gauss_hudpic(int selected, vector pos) +void w_gauss_hudpic(int selected, vector pos, float a) { #ifdef CSQC if (selected) { @@ -402,7 +402,7 @@ void w_gauss_hudpic(int selected, vector pos) [0,90/256], [170/256,45/256], g_hud_color, - 1.0f, + a, DRAWFLAG_ADDITIVE ); } else { @@ -413,7 +413,7 @@ void w_gauss_hudpic(int selected, vector pos) [0,90/256], [170/256,45/256], g_hud_color, - 1.0f, + a, DRAWFLAG_ADDITIVE ); } diff --git a/src/shared/valve/w_glock.c b/src/shared/valve/w_glock.c index 438f8857..0cc33e06 100644 --- a/src/shared/valve/w_glock.c +++ b/src/shared/valve/w_glock.c @@ -297,7 +297,7 @@ w_glock_hud(void) } void -w_glock_hudpic(int selected, vector pos) +w_glock_hudpic(int selected, vector pos, float a) { #ifdef CSQC if (selected) { @@ -308,7 +308,7 @@ w_glock_hudpic(int selected, vector pos) [0,45/256], [170/256,45/256], g_hud_color, - 1.0f, + a, DRAWFLAG_ADDITIVE ); } else { @@ -319,7 +319,7 @@ w_glock_hudpic(int selected, vector pos) [0,45/256], [170/256,45/256], g_hud_color, - 1.0f, + a, DRAWFLAG_ADDITIVE ); } diff --git a/src/shared/valve/w_handgrenade.c b/src/shared/valve/w_handgrenade.c index ca8c0dce..5f78d1c1 100644 --- a/src/shared/valve/w_handgrenade.c +++ b/src/shared/valve/w_handgrenade.c @@ -226,13 +226,13 @@ w_handgrenade_aimanim(void) } void -w_handgrenade_hudpic(int s, vector pos) +w_handgrenade_hudpic(int selected, vector pos, float a) { #ifdef CSQC - if (s) { - drawsubpic(pos, [170,45], "sprites/640hud6.spr_0.tga", [0,0], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); + if (selected) { + drawsubpic(pos, [170,45], "sprites/640hud6.spr_0.tga", [0,0], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); } else { - drawsubpic(pos, [170,45], "sprites/640hud3.spr_0.tga", [0,0], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); + drawsubpic(pos, [170,45], "sprites/640hud3.spr_0.tga", [0,0], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); } #endif } diff --git a/src/shared/valve/w_hornetgun.c b/src/shared/valve/w_hornetgun.c index 415e6943..6018a69c 100644 --- a/src/shared/valve/w_hornetgun.c +++ b/src/shared/valve/w_hornetgun.c @@ -37,8 +37,8 @@ w_hornetgun_precache(void) precache_sound("agrunt/ag_fire3.wav"); precache_sound("hornet/ag_buzz1.wav"); - precache_sound("agrunt/ag_buzz2.wav"); - precache_sound("agrunt/ag_buzz3.wav"); + precache_sound("hornet/ag_buzz2.wav"); + precache_sound("hornet/ag_buzz3.wav"); precache_sound("hornet/ag_hornethit1.wav"); precache_sound("hornet/ag_hornethit2.wav"); @@ -292,7 +292,7 @@ w_hornetgun_aimanim(void) } void -w_hornetgun_hudpic(int selected, vector pos) +w_hornetgun_hudpic(int selected, vector pos, float a) { #ifdef CSQC if (selected) { @@ -303,7 +303,7 @@ w_hornetgun_hudpic(int selected, vector pos) [0,180/256], [170/256,45/256], g_hud_color, - 1.0f, + a, DRAWFLAG_ADDITIVE ); } else { @@ -314,7 +314,7 @@ w_hornetgun_hudpic(int selected, vector pos) [0,180/256], [170/256,45/256], g_hud_color, - 1.0f, + a, DRAWFLAG_ADDITIVE ); } diff --git a/src/shared/valve/w_mp5.c b/src/shared/valve/w_mp5.c index 63514d39..c7debf37 100644 --- a/src/shared/valve/w_mp5.c +++ b/src/shared/valve/w_mp5.c @@ -320,7 +320,7 @@ w_mp5_aimanim(void) } void -w_mp5_hudpic(int selected, vector pos) +w_mp5_hudpic(int selected, vector pos, float a) { #ifdef CSQC if (selected) { @@ -331,7 +331,7 @@ w_mp5_hudpic(int selected, vector pos) [0,135/256], [170/256,45/256], g_hud_color, - 1.0f, + a, DRAWFLAG_ADDITIVE ); } else { @@ -342,7 +342,7 @@ w_mp5_hudpic(int selected, vector pos) [0,135/256], [170/256,45/256], g_hud_color, - 1.0f, + a, DRAWFLAG_ADDITIVE ); } diff --git a/src/shared/valve/w_python.c b/src/shared/valve/w_python.c index d968e83a..97027f87 100644 --- a/src/shared/valve/w_python.c +++ b/src/shared/valve/w_python.c @@ -284,7 +284,7 @@ w_python_aimanim(void) } void -w_python_hudpic(int selected, vector pos) +w_python_hudpic(int selected, vector pos, float a) { #ifdef CSQC if (selected) { @@ -295,7 +295,7 @@ w_python_hudpic(int selected, vector pos) [0,90/256], [170/256,45/256], g_hud_color, - 1.0f, + a, DRAWFLAG_ADDITIVE ); } else { @@ -306,7 +306,7 @@ w_python_hudpic(int selected, vector pos) [0,90/256], [170/256,45/256], g_hud_color, - 1.0f, + a, DRAWFLAG_ADDITIVE ); } diff --git a/src/shared/valve/w_rpg.c b/src/shared/valve/w_rpg.c index bb7f77f1..31218324 100644 --- a/src/shared/valve/w_rpg.c +++ b/src/shared/valve/w_rpg.c @@ -243,13 +243,13 @@ float w_rpg_aimanim(void) return self.flags & FL_CROUCHING ? ANIM_CR_AIMRPG : ANIM_AIMRPG; } -void w_rpg_hudpic(int s, vector pos) +void w_rpg_hudpic(int selected, vector pos, float a) { #ifdef CSQC - if (s) { - drawsubpic(pos, [170,45], "sprites/640hud5.spr_0.tga", [0,45/256], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); + if (selected) { + drawsubpic(pos, [170,45], "sprites/640hud5.spr_0.tga", [0,45/256], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); } else { - drawsubpic(pos, [170,45], "sprites/640hud2.spr_0.tga", [0,45/256], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); + drawsubpic(pos, [170,45], "sprites/640hud2.spr_0.tga", [0,45/256], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); } #endif } diff --git a/src/shared/valve/w_satchel.c b/src/shared/valve/w_satchel.c index 50322e29..96a643d4 100644 --- a/src/shared/valve/w_satchel.c +++ b/src/shared/valve/w_satchel.c @@ -253,13 +253,13 @@ void w_satchel_hud(void) #endif } -void w_satchel_hudpic(int s, vector pos) +void w_satchel_hudpic(int selected, vector pos, float a) { #ifdef CSQC - if (s) { - drawsubpic(pos, [170,45], "sprites/640hud6.spr_0.tga", [0,45/256], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); + if (selected) { + drawsubpic(pos, [170,45], "sprites/640hud6.spr_0.tga", [0,45/256], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); } else { - drawsubpic(pos, [170,45], "sprites/640hud3.spr_0.tga", [0,45/256], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); + drawsubpic(pos, [170,45], "sprites/640hud3.spr_0.tga", [0,45/256], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); } #endif } diff --git a/src/shared/valve/w_shotgun.c b/src/shared/valve/w_shotgun.c index 9aa65047..df3b3998 100644 --- a/src/shared/valve/w_shotgun.c +++ b/src/shared/valve/w_shotgun.c @@ -274,13 +274,13 @@ float w_shotgun_aimanim(void) return self.flags & FL_CROUCHING ? ANIM_CR_AIMSHOTGUN : ANIM_AIMSHOTGUN; } -void w_shotgun_hudpic(int s, vector pos) +void w_shotgun_hudpic(int selected, vector pos, float a) { #ifdef CSQC - if (s) { - drawsubpic(pos, [170,45], "sprites/640hud4.spr_0.tga", [0,180/256], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); + if (selected) { + drawsubpic(pos, [170,45], "sprites/640hud4.spr_0.tga", [0,180/256], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); } else { - drawsubpic(pos, [170,45], "sprites/640hud1.spr_0.tga", [0,180/256], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); + drawsubpic(pos, [170,45], "sprites/640hud1.spr_0.tga", [0,180/256], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); } #endif } diff --git a/src/shared/valve/w_snark.c b/src/shared/valve/w_snark.c index f2b6dced..5ca46a45 100644 --- a/src/shared/valve/w_snark.c +++ b/src/shared/valve/w_snark.c @@ -252,17 +252,17 @@ void w_snark_hud(void) #endif } -void w_snark_hudpic(int s, vector pos) +void w_snark_hudpic(int selected, vector pos, float a) { #ifdef CSQC - if (s) { + if (selected) { drawsubpic(pos, [170,45], "sprites/640hud6.spr_0.tga", [0,135/256], [170/256,45/256], - g_hud_color, 1, DRAWFLAG_ADDITIVE); + g_hud_color, a, DRAWFLAG_ADDITIVE); } else { drawsubpic(pos, [170,45], "sprites/640hud3.spr_0.tga", [0,135/256], [170/256,45/256], - g_hud_color, 1, DRAWFLAG_ADDITIVE); + g_hud_color, a, DRAWFLAG_ADDITIVE); } #endif } diff --git a/src/shared/valve/w_tripmine.c b/src/shared/valve/w_tripmine.c index 47a52247..65042175 100644 --- a/src/shared/valve/w_tripmine.c +++ b/src/shared/valve/w_tripmine.c @@ -274,13 +274,13 @@ void w_tripmine_hud(void) #endif } -void w_tripmine_hudpic(int s, vector pos) +void w_tripmine_hudpic(int selected, vector pos, float a) { #ifdef CSQC - if (s) { - drawsubpic(pos, [170,45], "sprites/640hud6.spr_0.tga", [0,90/256], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); + if (selected) { + drawsubpic(pos, [170,45], "sprites/640hud6.spr_0.tga", [0,90/256], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); } else { - drawsubpic(pos, [170,45], "sprites/640hud3.spr_0.tga", [0,90/256], [170/256,45/256], g_hud_color, 1, DRAWFLAG_ADDITIVE); + drawsubpic(pos, [170,45], "sprites/640hud3.spr_0.tga", [0,90/256], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); } #endif } diff --git a/src/shared/valve/weapon_common.c b/src/shared/valve/weapon_common.c index 1c42c86d..6197ab7d 100644 --- a/src/shared/valve/weapon_common.c +++ b/src/shared/valve/weapon_common.c @@ -171,10 +171,10 @@ float Weapons_GetAim(int id) #endif #ifdef CSQC -void Weapons_HUDPic(int id, int s, vector pos) +void Weapons_HUDPic(int id, int s, vector pos, float a) { if (g_weapons[id].hudpic != __NULL__) { - g_weapons[id].hudpic(s, pos); + g_weapons[id].hudpic(s, pos, a); } } #endif @@ -242,6 +242,14 @@ int Weapons_IsPresent(player pl, int w) } #ifdef SSQC +void Weapons_PickupNotify(player pl, int w) +{ + WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET); + WriteByte(MSG_MULTICAST, EV_WEAPON_PICKUP); + WriteByte(MSG_MULTICAST, w); + msg_entity = (entity)pl; + multicast([0,0,0], MULTICAST_ONE); +} void Weapons_RefreshAmmo(player pl) { @@ -282,8 +290,12 @@ int Weapons_AddItem(player pl, int w) value = TRUE; /* it's new, so autoswitch? */ - pl.activeweapon = w; - Weapons_Draw(); + if (pl.activeweapon == 0) { + pl.activeweapon = w; + Weapons_Draw(); + } else { + Weapons_PickupNotify(pl, w); + } } } else { /* Call team pickup */ @@ -295,8 +307,12 @@ int Weapons_AddItem(player pl, int w) value = g_weapons[w].pickup(TRUE); /* it's new, so autoswitch? */ - pl.activeweapon = w; - Weapons_Draw(); + if (pl.activeweapon == 0) { + pl.activeweapon = w; + Weapons_Draw(); + } else { + Weapons_PickupNotify(pl, w); + } } } diff --git a/src/shared/valve/weapon_common.h b/src/shared/valve/weapon_common.h index e5d22f45..34789819 100644 --- a/src/shared/valve/weapon_common.h +++ b/src/shared/valve/weapon_common.h @@ -38,7 +38,7 @@ typedef struct string() pmodel; string() deathmsg; float() aimanim; - void(int, vector) hudpic; + void(int, vector, float) hudpic; } weapon_t; void Weapons_DrawCrosshair(void); @@ -64,5 +64,5 @@ void Weapons_ReloadWeapon(player, .int, .int, int); #else string Weapons_GetPlayermodel(int); int Weapons_GetAnimation(void); -void Weapons_HUDPic(int, int, vector); +void Weapons_HUDPic(int, int, vector, float); #endif