From d1962767b451bf3072cec143187db3961d1587bd Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Tue, 15 Mar 2022 19:34:26 -0700 Subject: [PATCH] Rebased against the latest Nuclide commit. --- src/client/entities.qc | 7 --- src/client/hud.qc | 5 +- src/client/hud_weaponselect.qc | 5 +- src/client/player.qc | 24 ++------- src/client/view.qc | 21 +++++--- src/server/gamerules_multiplayer.qc | 9 +++- src/server/player.qc | 4 +- src/shared/animations.qc | 2 +- src/shared/input.qc | 18 +++---- src/shared/player.qc | 2 +- src/shared/w_crossbow.qc | 72 +++++++++++--------------- src/shared/w_crowbar.qc | 36 ++++++------- src/shared/w_egon.qc | 63 ++++++++++------------- src/shared/w_gauss.qc | 76 ++++++++++++--------------- src/shared/w_glock.qc | 63 ++++++++++------------- src/shared/w_handgrenade.qc | 47 ++++++++--------- src/shared/w_hornetgun.qc | 57 ++++++++++---------- src/shared/w_mp5.qc | 65 +++++++++++------------ src/shared/w_python.qc | 55 +++++++++----------- src/shared/w_rpg.qc | 62 ++++++++++------------ src/shared/w_satchel.qc | 53 +++++++++---------- src/shared/w_shotgun.qc | 80 +++++++++++++---------------- src/shared/w_snark.qc | 43 +++++++--------- src/shared/w_tripmine.qc | 45 ++++++++-------- 24 files changed, 406 insertions(+), 508 deletions(-) diff --git a/src/client/entities.qc b/src/client/entities.qc index 93b9ce4..9632dd3 100644 --- a/src/client/entities.qc +++ b/src/client/entities.qc @@ -27,10 +27,3 @@ ClientGame_EntityUpdate(float id, float new) return (1); } - -void -ClientGame_EntityRemove(void) -{ - if (self.classname == "player") - Player_DestroyWeaponModel((base_player) self); -} diff --git a/src/client/hud.qc b/src/client/hud.qc index c976427..d359ebd 100644 --- a/src/client/hud.qc +++ b/src/client/hud.qc @@ -389,6 +389,7 @@ HUD_DrawLogo(void) void HUD_DrawNotify(void) { + player pl = (player)self; vector pos; float a; @@ -403,7 +404,7 @@ HUD_DrawNotify(void) a = bound(0.0, pSeatLocal->m_flPickupAlpha, 1.0); pos[1] += 48 * (1.0 - a); - Weapons_HUDPic(pSeatLocal->m_iPickupWeapon, 1, pos, a); + Weapons_HUDPic(pl, pSeatLocal->m_iPickupWeapon, 1, pos, a); HUD_ItemNotify_Draw(pos); HUD_AmmoNotify_Draw(pos); pSeatLocal->m_flPickupAlpha -= (clframetime * 0.5); @@ -439,7 +440,7 @@ HUD_Draw(void) g_hud_color = autocvar_con_color * (1 / 255); /* little point in not drawing these, even if you don't have a suit */ - Weapons_DrawCrosshair(); + Weapons_DrawCrosshair(pl); HUD_DrawWeaponSelect(); Obituary_Draw(); Textmenu_Draw(); diff --git a/src/client/hud_weaponselect.qc b/src/client/hud_weaponselect.qc index 3dbf116..c0a6fcd 100644 --- a/src/client/hud_weaponselect.qc +++ b/src/client/hud_weaponselect.qc @@ -83,6 +83,7 @@ HUD_DrawWeaponSelect_Trigger(void) { player pl = (player)pSeat->m_ePlayer; pl.activeweapon = pSeat->m_iHUDWeaponSelected; + sendevent("PlayerSwitchWeapon", "i", pSeat->m_iHUDWeaponSelected); sound(pSeat->m_ePlayer, CHAN_ITEM, "common/wpn_select.wav", 0.5f, ATTN_NONE); pSeat->m_iHUDWeaponSelected = pSeat->m_flHUDWeaponSelectTime = 0; @@ -204,13 +205,13 @@ HUD_DrawWeaponSelect(void) slot_selected = TRUE; if (x == wantpos) { // Selected Sprite - Weapons_HUDPic(pSeat->m_iHUDWeaponSelected, 1, vecPos, 1.0f); + Weapons_HUDPic(pl, pSeat->m_iHUDWeaponSelected, 1, vecPos, 1.0f); drawsubpic(vecPos, [170,45], g_hud3_spr, [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, 1.0f); + Weapons_HUDPic(pl, b, 0, vecPos, 1.0f); vecPos[1] += 50; } } else if (HUD_InSlotPos(i, x) != -1) { diff --git a/src/client/player.qc b/src/client/player.qc index 1a5e9ba..093272e 100644 --- a/src/client/player.qc +++ b/src/client/player.qc @@ -99,15 +99,8 @@ Player_HandleWeaponModel(base_player pp, float thirdperson) pl.p_model = spawn(); } - /* only make it visible when it's a thirdperson drawcall */ - pl.p_model.drawmask = (thirdperson) ? MASK_ENGINE:0; - - /* let's not waste any time doing bone calculations then */ - if (pl.p_model.drawmask == 0) - return; - /* what's the current weapon model supposed to be anyway? */ - string wmodel = Weapons_GetPlayermodel(pl.activeweapon); + string wmodel = Weapons_GetPlayermodel(pl, pl.activeweapon); /* we changed weapons, update skeletonindex */ if (pl.p_model.model != wmodel) { @@ -152,15 +145,6 @@ Player_HandleWeaponModel(base_player pp, float thirdperson) } } -/* we need to call this when a player entity gets removed */ -void -Player_DestroyWeaponModel(entity pp) -{ - player pl = (player)pp; - if (pl.p_model) - remove(pl.p_model); -} - void Player_PreDraw(base_player pp, int thirdperson) { @@ -169,10 +153,12 @@ Player_PreDraw(base_player pp, int thirdperson) /* Handle the flashlights... */ Player_Flashlight(pl); - Weapons_PreDraw(thirdperson); + Weapons_PreDraw(pl, thirdperson); pl.Physics_SetViewParms(); Animation_PlayerUpdate((player)pl); Animation_TimerUpdate((player)pl, clframetime); - Player_HandleWeaponModel(pl, thirdperson); + + if (thirdperson) + Player_HandleWeaponModel(pl, thirdperson); } diff --git a/src/client/view.qc b/src/client/view.qc index 5d1ef94..7809ea4 100644 --- a/src/client/view.qc +++ b/src/client/view.qc @@ -15,10 +15,8 @@ */ void -View_UpdateWeapon(entity vm, entity mflash) +View_UpdateWeapon(player pl, entity vm, entity mflash) { - player pl = (player)pSeat->m_ePlayer; - /* only bother upon change */ if (pSeat->m_iLastWeapon == pl.activeweapon) { return; @@ -30,9 +28,6 @@ View_UpdateWeapon(entity vm, entity mflash) return; } - /* hack, we changed the wep, move this into Game_Input/PMove */ - Weapons_Draw(); - /* we forced a weapon call outside the prediction, * thus we need to update all the net variables to * make sure these updates are recognized. this is @@ -41,6 +36,20 @@ View_UpdateWeapon(entity vm, entity mflash) SAVE_STATE(pl.w_idle_next); SAVE_STATE(pl.viewzoom); SAVE_STATE(pl.weapontime); + SAVE_STATE(pl.weaponframe); + + /* hack, we changed the wep, move this into Game_Input/PMove */ + Weapons_Draw(pl); + + /* we forced a weapon call outside the prediction, + * thus we need to update all the net variables to + * make sure these updates are recognized. this is + * vile but it'll have to do for now */ + ROLL_BACK(pl.w_attack_next); + ROLL_BACK(pl.w_idle_next); + ROLL_BACK(pl.viewzoom); + ROLL_BACK(pl.weapontime); + ROLL_BACK(pl.weaponframe); /* figure out when the attachments start. in FTE attachments for * HLMDL are treated as bones. they start at numbones + 1 */ diff --git a/src/server/gamerules_multiplayer.qc b/src/server/gamerules_multiplayer.qc index b7aef0a..1f607e2 100644 --- a/src/server/gamerules_multiplayer.qc +++ b/src/server/gamerules_multiplayer.qc @@ -153,7 +153,14 @@ HLMultiplayerRules::ConsoleCommand(base_player pp, string cmd) switch (argv(0)) { case "bot_add": - Bot_AddQuick(); + bot pete = Bot_AddQuick(); + Bot_RandomColormap(pete); + searchhandle pm = search_begin("models/player/*/*.mdl", TRUE, TRUE); + int r = floor(random(0, search_getsize(pm))); + string mdl = substring(search_getfilename(pm, r), 0, -5); + tokenizebyseparator(mdl, "/"); + forceinfokey(pete, "model", argv(2)); + search_end(pm); break; case "jumptest": makevectors(pp.v_angle); diff --git a/src/server/player.qc b/src/server/player.qc index 4ea5478..191054d 100644 --- a/src/server/player.qc +++ b/src/server/player.qc @@ -97,7 +97,7 @@ Player_UseUp(void) { } } -void Weapons_Draw(void); +void Weapons_Draw(player pl); void CSEv_PlayerSwitchWeapon_i(int w) @@ -106,7 +106,7 @@ CSEv_PlayerSwitchWeapon_i(int w) if (pl.activeweapon != w) { pl.activeweapon = w; - Weapons_Draw(); + Weapons_Draw(pl); } } diff --git a/src/shared/animations.qc b/src/shared/animations.qc index 27a4a25..4a2dcbb 100644 --- a/src/shared/animations.qc +++ b/src/shared/animations.qc @@ -61,7 +61,7 @@ Animation_PlayerUpdate(player pl) pl.basebone = gettagindex(pl, "Bip01 Spine1"); if (pl.anim_top_delay <= 0.0f) { - pl.anim_top = Weapons_GetAim(pl.activeweapon); + pl.anim_top = Weapons_GetAim(pl, pl.activeweapon); } if (vlen(pl.velocity) == 0) { diff --git a/src/shared/input.qc b/src/shared/input.qc index 93c5ff9..d66fabd 100644 --- a/src/shared/input.qc +++ b/src/shared/input.qc @@ -15,7 +15,7 @@ */ void -Game_Input(void) +Game_Input(player pl) { #ifdef SERVER CGameRules rules = (CGameRules)g_grMode; @@ -30,13 +30,11 @@ Game_Input(void) else Player_UseUp(); - if (self.impulse == 100) + if (pl.impulse == 100) Flashlight_Toggle(); if (cvar("sv_cheats") == 1) { - player pl = (player)self; - - if (self.impulse == 101) { + if (pl.impulse == 101) { pl.health = 100; pl.armor = 100; pl.g_items |= ITEM_SUIT; @@ -69,15 +67,15 @@ Game_Input(void) } } - self.impulse = 0; + pl.impulse = 0; #endif if (input_buttons & INPUT_BUTTON0) - Weapons_Primary(); + Weapons_Primary(pl); else if (input_buttons & INPUT_BUTTON4) - Weapons_Reload(); + Weapons_Reload(pl); else if (input_buttons & INPUT_BUTTON3) - Weapons_Secondary(); + Weapons_Secondary(pl); else - Weapons_Release(); + Weapons_Release(pl); } diff --git a/src/shared/player.qc b/src/shared/player.qc index 7f6f5d3..7687e0b 100644 --- a/src/shared/player.qc +++ b/src/shared/player.qc @@ -511,7 +511,7 @@ player::SendEntity(entity ePEnt, float fChanged) } /* other players don't need to know about these attributes */ - if (ePEnt != self) { + if (ePEnt != self && ePEnt.classname != "spectator") { fChanged &= ~PLAYER_ITEMS; fChanged &= ~PLAYER_HEALTH; fChanged &= ~PLAYER_ARMOR; diff --git a/src/shared/w_crossbow.qc b/src/shared/w_crossbow.qc index 9ad68cb..62d3e18 100644 --- a/src/shared/w_crossbow.qc +++ b/src/shared/w_crossbow.qc @@ -68,7 +68,7 @@ w_crossbow_wmodel(void) } string -w_crossbow_pmodel(void) +w_crossbow_pmodel(player pl) { return "models/p_crossbow.mdl"; } @@ -80,11 +80,9 @@ w_crossbow_deathmsg(void) } int -w_crossbow_pickup(int new, int startammo) +w_crossbow_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; - if (new) { pl.crossbow_mag = 5; return (1); @@ -102,22 +100,20 @@ w_crossbow_pickup(int new, int startammo) } void -w_crossbow_draw(void) +w_crossbow_draw(player pl) { - player pl = (player)self; - Weapons_SetModel("models/v_crossbow.mdl"); if (pl.crossbow_mag <= 0) - Weapons_ViewAnimation(CROSSBOW_DRAW2); + Weapons_ViewAnimation(pl, CROSSBOW_DRAW2); else - Weapons_ViewAnimation(CROSSBOW_DRAW1); + Weapons_ViewAnimation(pl, CROSSBOW_DRAW1); } void -w_crossbow_holster(void) +w_crossbow_holster(player pl) { - Weapons_ViewAnimation(CROSSBOW_HOLSTER1); + Weapons_ViewAnimation(pl, CROSSBOW_HOLSTER1); } #ifdef SERVER @@ -158,10 +154,8 @@ void Crossbolt_Touch(void) { #endif void -w_crossbow_primary(void) +w_crossbow_primary(player pl) { - player pl = (player)self; - if (pl.w_attack_next > 0.0) { return; } @@ -174,10 +168,10 @@ w_crossbow_primary(void) pl.crossbow_mag--; #ifndef CLIENT - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); entity bolt = spawn(); setmodel(bolt, "models/crossbow_bolt.mdl"); - setorigin(bolt, Weapons_GetCameraPos() + (v_forward * 16)); + setorigin(bolt, Weapons_GetCameraPos(pl) + (v_forward * 16)); bolt.owner = self; bolt.velocity = v_forward * 2000; bolt.movetype = MOVETYPE_FLYMISSILE; @@ -198,9 +192,9 @@ w_crossbow_primary(void) #endif if (pl.crossbow_mag) { - Weapons_ViewAnimation(CROSSBOW_FIRE1); + Weapons_ViewAnimation(pl, CROSSBOW_FIRE1); } else { - Weapons_ViewAnimation(CROSSBOW_FIRE3); + Weapons_ViewAnimation(pl, CROSSBOW_FIRE3); } if (self.flags & FL_CROUCHING) @@ -208,16 +202,15 @@ w_crossbow_primary(void) else Animation_PlayerTop(pl, ANIM_SHOOTBOW, 0.25f); - Weapons_ViewPunchAngle([-2,0,0]); + Weapons_ViewPunchAngle(pl, [-2,0,0]); pl.w_attack_next = 0.75f; pl.w_idle_next = 10.0f; } void -w_crossbow_secondary(void) +w_crossbow_secondary(player pl) { - player pl = (player)self; if (pl.w_attack_next) { return; } @@ -231,10 +224,8 @@ w_crossbow_secondary(void) } void -w_crossbow_reload(void) +w_crossbow_reload(player pl) { - player pl = (player)self; - if (pl.w_attack_next > 0.0) { return; } @@ -257,21 +248,19 @@ w_crossbow_reload(void) Sound_Play(pl, CHAN_ITEM, "weapon_crossbow.reload"); #endif - Weapons_ViewAnimation(CROSSBOW_RELOAD); + Weapons_ViewAnimation(pl, CROSSBOW_RELOAD); pl.w_attack_next = 4.5f; pl.w_idle_next = 10.0f; } void -w_crossbow_release(void) +w_crossbow_release(player pl) { - player pl = (player)self; - /* auto-reload if need be */ if (pl.w_attack_next <= 0.0) if (pl.crossbow_mag == 0 && pl.ammo_bolt > 0) { - Weapons_Reload(); + Weapons_Reload(pl); return; } @@ -282,15 +271,15 @@ w_crossbow_release(void) int r = floor(pseudorandom() * 2.0f); if (r == 1) { if (pl.crossbow_mag) { - Weapons_ViewAnimation(CROSSBOW_IDLE1); + Weapons_ViewAnimation(pl, CROSSBOW_IDLE1); } else { - Weapons_ViewAnimation(CROSSBOW_IDLE2); + Weapons_ViewAnimation(pl, CROSSBOW_IDLE2); } } else { if (pl.crossbow_mag) { - Weapons_ViewAnimation(CROSSBOW_FIDGET1); + Weapons_ViewAnimation(pl, CROSSBOW_FIDGET1); } else { - Weapons_ViewAnimation(CROSSBOW_FIDGET2); + Weapons_ViewAnimation(pl, CROSSBOW_FIDGET2); } } @@ -298,7 +287,7 @@ w_crossbow_release(void) } void -w_crossbow_crosshair(void) +w_crossbow_crosshair(player pl) { #ifdef CLIENT vector cross_pos; @@ -334,16 +323,15 @@ w_crossbow_crosshair(void) } float -w_crossbow_aimanim(void) +w_crossbow_aimanim(player pl) { - return self.flags & FL_CROUCHING ? ANIM_CR_AIMBOW : ANIM_AIMBOW; + return pl.flags & FL_CROUCHING ? ANIM_CR_AIMBOW : ANIM_AIMBOW; } void -w_crossbow_hudpic(int selected, vector pos, float a) +w_crossbow_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT - player pl = (player)self; vector hud_col; if (pl.crossbow_mag == 0 && pl.ammo_bolt == 0) @@ -380,17 +368,15 @@ w_crossbow_hudpic(int selected, vector pos, float a) } int -w_crossbow_isempty(void) +w_crossbow_isempty(player pl) { - player pl = (player)self; - if (pl.crossbow_mag <= 0 && pl.ammo_bolt <= 0) return 1; return 0; } -weapontype_t w_crossbow_type(void) +weapontype_t w_crossbow_type(player pl) { return WPNTYPE_RANGED; } @@ -408,7 +394,7 @@ weapon_t w_crossbow = .secondary = w_crossbow_secondary, .reload = w_crossbow_reload, .release = w_crossbow_release, - .crosshair = w_crossbow_crosshair, + .postdraw = w_crossbow_crosshair, .precache = w_crossbow_precache, .pickup = w_crossbow_pickup, .updateammo = w_crossbow_updateammo, diff --git a/src/shared/w_crowbar.qc b/src/shared/w_crowbar.qc index cf80a55..cc01828 100644 --- a/src/shared/w_crowbar.qc +++ b/src/shared/w_crowbar.qc @@ -62,7 +62,7 @@ w_crowbar_wmodel(void) return "models/w_crowbar.mdl"; } string -w_crowbar_pmodel(void) +w_crowbar_pmodel(player pl) { return "models/p_crowbar.mdl"; } @@ -74,30 +74,29 @@ w_crowbar_deathmsg(void) } void -w_crowbar_draw(void) +w_crowbar_draw(player pl) { Weapons_SetModel("models/v_crowbar.mdl"); - Weapons_ViewAnimation(CBAR_DRAW); + Weapons_ViewAnimation(pl, CBAR_DRAW); } void -w_crowbar_holster(void) +w_crowbar_holster(player pl) { - Weapons_ViewAnimation(CBAR_HOLSTER); + Weapons_ViewAnimation(pl, CBAR_HOLSTER); } void -w_crowbar_primary(void) +w_crowbar_primary(player pl) { int anim = 0; vector src; - player pl = (player)self; if (pl.w_attack_next) { return; } - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); src = pl.origin + pl.view_ofs; /* make sure we can gib corpses */ @@ -116,13 +115,13 @@ w_crowbar_primary(void) int r = (float)input_sequence % 3; switch (r) { case 0: - Weapons_ViewAnimation(trace_fraction >= 1 ? CBAR_ATTACK1MISS:CBAR_ATTACK1HIT); + Weapons_ViewAnimation(pl, trace_fraction >= 1 ? CBAR_ATTACK1MISS:CBAR_ATTACK1HIT); break; case 1: - Weapons_ViewAnimation(trace_fraction >= 1 ? CBAR_ATTACK2MISS:CBAR_ATTACK2HIT); + Weapons_ViewAnimation(pl, trace_fraction >= 1 ? CBAR_ATTACK2MISS:CBAR_ATTACK2HIT); break; default: - Weapons_ViewAnimation(trace_fraction >= 1 ? CBAR_ATTACK3MISS:CBAR_ATTACK3HIT); + Weapons_ViewAnimation(pl, trace_fraction >= 1 ? CBAR_ATTACK3MISS:CBAR_ATTACK3HIT); } if (self.flags & FL_CROUCHING) @@ -156,26 +155,25 @@ w_crowbar_primary(void) } void -w_crowbar_release(void) +w_crowbar_release(player pl) { - player pl = (player)self; if (pl.w_idle_next) { return; } - Weapons_ViewAnimation(CBAR_IDLE); + Weapons_ViewAnimation(pl, CBAR_IDLE); pl.w_idle_next = 15.0f; } float -w_crowbar_aimanim(void) +w_crowbar_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMCROWBAR : ANIM_AIMCROWBAR; } void -w_crowbar_hudpic(int selected, vector pos, float a) +w_crowbar_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT if (selected) { @@ -205,12 +203,12 @@ w_crowbar_hudpic(int selected, vector pos, float a) } int -w_crowbar_isempty(void) +w_crowbar_isempty(player pl) { return 0; } -weapontype_t w_crowbar_type(void) +weapontype_t w_crowbar_type(player pl) { return WPNTYPE_CLOSE; } @@ -228,7 +226,7 @@ weapon_t w_crowbar = .secondary = __NULL__, .reload = __NULL__, .release = w_crowbar_release, - .crosshair = __NULL__, + .postdraw = __NULL__, .precache = w_crowbar_precache, .pickup = __NULL__, .updateammo = w_crowbar_updateammo, diff --git a/src/shared/w_egon.qc b/src/shared/w_egon.qc index c4c03ea..616fb65 100644 --- a/src/shared/w_egon.qc +++ b/src/shared/w_egon.qc @@ -75,7 +75,7 @@ string w_egon_wmodel(void) { return "models/w_egon.mdl"; } -string w_egon_pmodel(void) +string w_egon_pmodel(player pl) { return "models/p_egon.mdl"; } @@ -84,10 +84,9 @@ string w_egon_deathmsg(void) return ""; } -int w_egon_pickup(int new, int startammo) +int w_egon_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (pl.ammo_uranium < MAX_A_URANIUM) { pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, MAX_A_URANIUM); @@ -99,38 +98,36 @@ int w_egon_pickup(int new, int startammo) return (1); } -void w_egon_draw(void) +void w_egon_draw(player pl) { - player pl = (player)self; pl.mode_tempstate = 0; Weapons_SetModel("models/v_egon.mdl"); - Weapons_ViewAnimation(EGON_DRAW); + Weapons_ViewAnimation(pl, EGON_DRAW); } -void w_egon_holster(void) +void w_egon_holster(player pl) { - Weapons_ViewAnimation(EGON_HOLSTER); + Weapons_ViewAnimation(pl, EGON_HOLSTER); } -void w_egon_release(void); +void w_egon_release(player pl); -void w_egon_primary(void) +void w_egon_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; } /* Ammo check */ if (pl.ammo_uranium <= 0) { - w_egon_release(); + w_egon_release(pl); return; } #ifdef SERVER - Weapons_MakeVectors(); - vector src = Weapons_GetCameraPos(); + Weapons_MakeVectors(pl); + vector src = Weapons_GetCameraPos(pl); vector endpos = src + v_forward * 1024; traceline(src, endpos, FALSE, pl); Damage_Radius(trace_endpos, pl, 14, 64, TRUE, DMG_ELECTRO); @@ -145,13 +142,13 @@ void w_egon_primary(void) sound(pl, CHAN_WEAPON, "weapons/egon_windup2.wav", 1, ATTN_NORM, 100, 0); #endif pl.mode_tempstate = 1; - Weapons_ViewPunchAngle([-5,0,0]); - Weapons_ViewAnimation(EGON_ALTFIREON); + Weapons_ViewPunchAngle(pl, [-5,0,0]); + Weapons_ViewAnimation(pl, EGON_ALTFIREON); pl.w_idle_next = 1.5f; } else if not (pl.w_idle_next > 0.0f) { /* wait 3 seconds (idle next) */ if (pl.mode_tempstate == 1) { - Weapons_ViewAnimation(EGON_ALTFIRECYCLE); + Weapons_ViewAnimation(pl, EGON_ALTFIRECYCLE); #ifdef SERVER sound(pl, CHAN_WEAPON, "weapons/egon_run3.wav", 1, ATTN_NORM, 100); #endif @@ -163,27 +160,26 @@ void w_egon_primary(void) pl.w_attack_next = 0.2f; } -void w_egon_reload(void) +void w_egon_reload(player pl) { } -void w_egon_release(void) +void w_egon_release(player pl) { - player pl = (player)self; if (pl.mode_tempstate != 0 && pl.mode_tempstate < 3) { #ifdef SERVER sound(pl, CHAN_WEAPON, "weapons/egon_off1.wav", 1, ATTN_NORM, 100, 0); #endif pl.mode_tempstate = 3; - Weapons_ViewPunchAngle([-2,0,0]); + Weapons_ViewPunchAngle(pl, [-2,0,0]); } pl.gflags &= ~GF_EGONBEAM; if (pl.mode_tempstate == 3) { - Weapons_ViewAnimation(EGON_ALTFIREOFF); + Weapons_ViewAnimation(pl, EGON_ALTFIREOFF); pl.w_idle_next = 1.0f; pl.w_attack_next = 1.1f; pl.mode_tempstate = 0; @@ -193,10 +189,10 @@ void w_egon_release(void) } int r = floor(pseudorandom() * 3.0f); if (r == 1) { - Weapons_ViewAnimation(EGON_FIDGET1); + Weapons_ViewAnimation(pl, EGON_FIDGET1); pl.w_idle_next = 2.666667f; } else { - Weapons_ViewAnimation(EGON_IDLE1); + Weapons_ViewAnimation(pl, EGON_IDLE1); pl.w_idle_next = 2.0f; } pl.mode_tempstate = 0; @@ -204,10 +200,9 @@ void w_egon_release(void) } void -w_egon_postdraw(int thirdperson) +w_egon_postdraw(player pl, int thirdperson) { #ifdef CLIENT - player pl = (player)self; if (!(pl.gflags & GF_EGONBEAM)) return; @@ -249,7 +244,7 @@ w_egon_postdraw(int thirdperson) #endif } -void w_egon_crosshair(void) +void w_egon_crosshair(player pl) { #ifdef CLIENT static vector cross_pos; @@ -261,15 +256,14 @@ void w_egon_crosshair(void) #endif } -float w_egon_aimanim(void) +float w_egon_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMEGON : ANIM_AIMEGON; } -void w_egon_hudpic(int selected, vector pos, float a) +void w_egon_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT - player pl = (player)self; vector hud_col; if (pl.ammo_uranium == 0) @@ -288,9 +282,8 @@ void w_egon_hudpic(int selected, vector pos, float a) } int -w_egon_isempty(void) +w_egon_isempty(player pl) { - player pl = (player)self; if (pl.ammo_uranium <= 0) return 1; @@ -299,9 +292,9 @@ w_egon_isempty(void) } weapontype_t -w_egon_type(void) +w_egon_type(player pl) { - return WPNTYPE_RANGED; + return WPNTYPE_FULLAUTO; } weapon_t w_egon = @@ -317,7 +310,7 @@ weapon_t w_egon = .secondary = w_egon_release, .reload = w_egon_reload, .release = w_egon_release, - .crosshair = w_egon_crosshair, + .postdraw = w_egon_crosshair, .precache = w_egon_precache, .pickup = w_egon_pickup, .updateammo = w_egon_updateammo, diff --git a/src/shared/w_gauss.qc b/src/shared/w_gauss.qc index d36e84d..9601ef9 100644 --- a/src/shared/w_gauss.qc +++ b/src/shared/w_gauss.qc @@ -36,7 +36,7 @@ enum GAUSS_DRAW }; -void w_gauss_release(void); +void w_gauss_release(player pl); void w_gauss_precache(void) { @@ -62,7 +62,7 @@ string w_gauss_wmodel(void) { return "models/w_gauss.mdl"; } -string w_gauss_pmodel(void) +string w_gauss_pmodel(player pl) { return "models/p_gauss.mdl"; } @@ -71,10 +71,9 @@ string w_gauss_deathmsg(void) return ""; } -int w_gauss_pickup(int new, int startammo) +int w_gauss_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (pl.ammo_uranium < MAX_A_URANIUM) { pl.ammo_uranium = bound(0, pl.ammo_uranium + 20, MAX_A_URANIUM); @@ -86,27 +85,25 @@ int w_gauss_pickup(int new, int startammo) return (1); } -void w_gauss_draw(void) +void w_gauss_draw(player pl) { - player pl = (player)self; pl.mode_tempstate = 0; Weapons_SetModel("models/v_gauss.mdl"); - Weapons_ViewAnimation(GAUSS_DRAW); + Weapons_ViewAnimation(pl, GAUSS_DRAW); } -void w_gauss_holster(void) +void w_gauss_holster(player pl) { - Weapons_ViewAnimation(GAUSS_HOLSTER); + Weapons_ViewAnimation(pl, GAUSS_HOLSTER); } #ifdef SERVER -void w_gauss_fire(int one) +void w_gauss_fire(player pl, int one) { - player pl = (player)self; int iLoop = 6; - Weapons_MakeVectors(); - vector src = Weapons_GetCameraPos(); + Weapons_MakeVectors(pl); + vector src = Weapons_GetCameraPos(pl); vector endpos = src + v_forward * 1024; traceline(src, endpos, FALSE, pl); @@ -154,9 +151,8 @@ void w_gauss_fire(int one) } #endif -void w_gauss_primary(void) +void w_gauss_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; } @@ -166,11 +162,11 @@ void w_gauss_primary(void) return; } - Weapons_ViewAnimation(GAUSS_FIRE2); - Weapons_ViewPunchAngle([-2,0,0]); + Weapons_ViewAnimation(pl, GAUSS_FIRE2); + Weapons_ViewPunchAngle(pl, [-2,0,0]); #ifdef SERVER - w_gauss_fire(1); - FX_GaussBeam(Weapons_GetCameraPos(), input_angles, 0, pl); + w_gauss_fire(pl, 1); + FX_GaussBeam(Weapons_GetCameraPos(pl), input_angles, 0, pl); #endif pl.ammo_uranium -= 2; @@ -184,9 +180,8 @@ void w_gauss_primary(void) pl.w_idle_next = 2.5f; } -void w_gauss_secondary(void) +void w_gauss_secondary(player pl) { - player pl = (player)self; #ifdef CLIENT if (pl.mode_tempstate) @@ -201,7 +196,7 @@ void w_gauss_secondary(void) /* Ammo check */ if (pl.ammo_uranium <= 0) { if (pl.mode_tempstate > 0) { - w_gauss_release(); + w_gauss_release(pl); } return; } @@ -216,11 +211,11 @@ void w_gauss_secondary(void) } if (pl.mode_tempstate == 1) { - Weapons_ViewAnimation(GAUSS_SPIN); + Weapons_ViewAnimation(pl, GAUSS_SPIN); pl.mode_tempstate = 2; pl.w_idle_next = 0.0f; } else if (!pl.mode_tempstate) { - Weapons_ViewAnimation(GAUSS_SPINUP); + Weapons_ViewAnimation(pl, GAUSS_SPINUP); #ifdef CLIENT sound(pl, CHAN_WEAPON, "ambience/pulsemachine.wav", 2, ATTN_NORM); #endif @@ -228,9 +223,8 @@ void w_gauss_secondary(void) } } -void w_gauss_release(void) +void w_gauss_release(player pl) { - player pl = (player)self; if (pl.w_idle_next > 0.0) { return; } @@ -241,23 +235,23 @@ void w_gauss_release(void) if (pl.mode_tempstate == 1) { pl.w_attack_next = 0.0f; pl.w_idle_next = 4.0f; - w_gauss_primary(); + w_gauss_primary(pl); pl.mode_tempstate = 0; return; } else if (pl.mode_tempstate == 2) { - Weapons_ViewAnimation(GAUSS_FIRE1); + Weapons_ViewAnimation(pl, GAUSS_FIRE1); if (self.flags & FL_CROUCHING) Animation_PlayerTop(pl, ANIM_CR_SHOOTGAUSS, 0.43f); else Animation_PlayerTop(pl, ANIM_SHOOTGAUSS, 0.43f); - Weapons_ViewPunchAngle([-5,0,0]); + Weapons_ViewPunchAngle(pl, [-5,0,0]); #ifdef CLIENT soundupdate(pl, CHAN_WEAPON, "", -1, ATTN_NORM, 0, 0, 0); #else - w_gauss_fire(0); - FX_GaussBeam(Weapons_GetCameraPos(), input_angles, 6, pl); + w_gauss_fire(pl, 0); + FX_GaussBeam(Weapons_GetCameraPos(pl), input_angles, 6, pl); #endif pl.w_attack_next = 1.5f; pl.w_idle_next = 4.0f; @@ -268,23 +262,23 @@ void w_gauss_release(void) int r = floor(pseudorandom() * 3.0f); switch (r) { case 1: - Weapons_ViewAnimation(GAUSS_IDLE2); + Weapons_ViewAnimation(pl, GAUSS_IDLE2); pl.w_idle_next = 4.0f; break; #ifndef GEARBOX case 2: - Weapons_ViewAnimation(GAUSS_FIDGET); + Weapons_ViewAnimation(pl, GAUSS_FIDGET); pl.w_idle_next = 3.0f; break; #endif default: - Weapons_ViewAnimation(GAUSS_IDLE1); + Weapons_ViewAnimation(pl, GAUSS_IDLE1); pl.w_idle_next = 4.0f; break; } } -void w_gauss_crosshair(void) +void w_gauss_crosshair(player pl) { #ifdef CLIENT vector cross_pos; @@ -319,15 +313,14 @@ void w_gauss_crosshair(void) #endif } -float w_gauss_aimanim(void) +float w_gauss_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMGAUSS : ANIM_AIMGAUSS; } -void w_gauss_hudpic(int selected, vector pos, float a) +void w_gauss_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT - player pl = (player)self; vector hud_col; if (pl.ammo_uranium == 0) @@ -364,9 +357,8 @@ void w_gauss_hudpic(int selected, vector pos, float a) } int -w_gauss_isempty(void) +w_gauss_isempty(player pl) { - player pl = (player)self; if (pl.ammo_uranium <= 0) return 1; @@ -375,7 +367,7 @@ w_gauss_isempty(void) } weapontype_t -w_gauss_type(void) +w_gauss_type(player pl) { return WPNTYPE_RANGED; } @@ -393,7 +385,7 @@ weapon_t w_gauss = .secondary = w_gauss_secondary, .reload = __NULL__, .release = w_gauss_release, - .crosshair = w_gauss_crosshair, + .postdraw = w_gauss_crosshair, .precache = w_gauss_precache, .pickup = w_gauss_pickup, .updateammo = w_gauss_updateammo, diff --git a/src/shared/w_glock.qc b/src/shared/w_glock.qc index b09ee28..6019db2 100644 --- a/src/shared/w_glock.qc +++ b/src/shared/w_glock.qc @@ -107,7 +107,7 @@ w_glock_wmodel(void) } string -w_glock_pmodel(void) +w_glock_pmodel(player pl) { return "models/p_9mmhandgun.mdl"; } @@ -119,10 +119,9 @@ w_glock_deathmsg(void) } int -w_glock_pickup(int new, int startammo) +w_glock_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (new) { pl.glock_mag = 18; @@ -140,22 +139,21 @@ w_glock_pickup(int new, int startammo) } void -w_glock_draw(void) +w_glock_draw(player pl) { Weapons_SetModel("models/v_9mmhandgun.mdl"); - Weapons_ViewAnimation(GLOCK_DRAW); + Weapons_ViewAnimation(pl, GLOCK_DRAW); } void -w_glock_holster(void) +w_glock_holster(player pl) { - Weapons_ViewAnimation(GLOCK_HOLSTER); + Weapons_ViewAnimation(pl, GLOCK_HOLSTER); } void -w_glock_primary(void) +w_glock_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; @@ -177,12 +175,12 @@ w_glock_primary(void) Sound_Play(pl, CHAN_WEAPON, "weapon_glock.fire"); #endif - Weapons_ViewPunchAngle([-2,0,0]); + Weapons_ViewPunchAngle(pl, [-2,0,0]); if (pl.glock_mag) { - Weapons_ViewAnimation(GLOCK_SHOOT); + Weapons_ViewAnimation(pl, GLOCK_SHOOT); } else { - Weapons_ViewAnimation(GLOCK_SHOOT_EMPTY); + Weapons_ViewAnimation(pl, GLOCK_SHOOT_EMPTY); } if (self.flags & FL_CROUCHING) @@ -195,9 +193,8 @@ w_glock_primary(void) } void -w_glock_secondary(void) +w_glock_secondary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0) { return; @@ -218,12 +215,12 @@ w_glock_secondary(void) Sound_Play(pl, CHAN_WEAPON, "weapon_glock.fire"); #endif - Weapons_ViewPunchAngle([-2,0,0]); + Weapons_ViewPunchAngle(pl, [-2,0,0]); if (pl.glock_mag) { - Weapons_ViewAnimation(GLOCK_SHOOT); + Weapons_ViewAnimation(pl, GLOCK_SHOOT); } else { - Weapons_ViewAnimation(GLOCK_SHOOT_EMPTY); + Weapons_ViewAnimation(pl, GLOCK_SHOOT_EMPTY); } if (self.flags & FL_CROUCHING) @@ -236,9 +233,8 @@ w_glock_secondary(void) } void -w_glock_reload(void) +w_glock_reload(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; @@ -252,9 +248,9 @@ w_glock_reload(void) } if (pl.glock_mag) { - Weapons_ViewAnimation(GLOCK_RELOAD); + Weapons_ViewAnimation(pl, GLOCK_RELOAD); } else { - Weapons_ViewAnimation(GLOCK_RELOAD_EMPTY); + Weapons_ViewAnimation(pl, GLOCK_RELOAD_EMPTY); } #ifdef SERVER @@ -272,15 +268,14 @@ w_glock_reload(void) } void -w_glock_release(void) +w_glock_release(player pl) { - player pl = (player)self; int r; /* auto-reload if need be */ if (pl.w_attack_next <= 0.0) if (pl.glock_mag == 0 && pl.ammo_9mm > 0) { - Weapons_Reload(); + Weapons_Reload(pl); return; } @@ -291,28 +286,28 @@ w_glock_release(void) r = floor(pseudorandom() * 3.0f); switch (r) { case 1: - Weapons_ViewAnimation(GLOCK_IDLE2); + Weapons_ViewAnimation(pl, GLOCK_IDLE2); pl.w_idle_next = 2.5f; break; case 2: - Weapons_ViewAnimation(GLOCK_IDLE3); + Weapons_ViewAnimation(pl, GLOCK_IDLE3); pl.w_idle_next = 3.5f; break; default: - Weapons_ViewAnimation(GLOCK_IDLE1); + Weapons_ViewAnimation(pl, GLOCK_IDLE1); pl.w_idle_next = 3.75f; break; } } float -w_glock_aimanim(void) +w_glock_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIM1HAND : ANIM_AIM1HAND; } void -w_glock_hud(void) +w_glock_hud(player pl) { #ifdef CLIENT vector cross_pos; @@ -349,10 +344,9 @@ w_glock_hud(void) } void -w_glock_hudpic(int selected, vector pos, float a) +w_glock_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT - player pl = (player)self; vector hud_col; if (pl.glock_mag == 0 && pl.ammo_9mm == 0) @@ -389,9 +383,8 @@ w_glock_hudpic(int selected, vector pos, float a) } int -w_glock_isempty(void) +w_glock_isempty(player pl) { - player pl = (player)self; if (pl.glock_mag <= 0 && pl.ammo_9mm <= 0) return 1; @@ -400,7 +393,7 @@ w_glock_isempty(void) } weapontype_t -w_glock_type(void) +w_glock_type(player pl) { return WPNTYPE_RANGED; } @@ -418,7 +411,7 @@ weapon_t w_glock = .secondary = w_glock_secondary, .reload = w_glock_reload, .release = w_glock_release, - .crosshair = w_glock_hud, + .postdraw = w_glock_hud, .precache = w_glock_precache, .pickup = w_glock_pickup, .updateammo = w_glock_updateammo, diff --git a/src/shared/w_handgrenade.qc b/src/shared/w_handgrenade.qc index 9e26115..594e794 100644 --- a/src/shared/w_handgrenade.qc +++ b/src/shared/w_handgrenade.qc @@ -53,7 +53,7 @@ string w_handgrenade_wmodel(void) { return "models/w_grenade.mdl"; } -string w_handgrenade_pmodel(void) +string w_handgrenade_pmodel(player pl) { return "models/p_grenade.mdl"; } @@ -62,10 +62,9 @@ string w_handgrenade_deathmsg(void) return ""; } -int w_handgrenade_pickup(int new, int startammo) +int w_handgrenade_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (pl.ammo_handgrenade < MAX_A_HANDGRENADE) { pl.ammo_handgrenade = bound(0, pl.ammo_handgrenade + 1, MAX_A_HANDGRENADE); @@ -78,7 +77,7 @@ int w_handgrenade_pickup(int new, int startammo) } #ifdef SERVER -void w_handgrenade_throw(void) +void w_handgrenade_throw(player pl) { static void WeaponFrag_Throw_Explode(void) { @@ -99,7 +98,6 @@ void w_handgrenade_throw(void) self.frame = 0; } - player pl = (player)self; vector vPLAngle = pl.v_angle; if (vPLAngle[0] < 0) { vPLAngle[0] = -10 + vPLAngle[0] * ((90 - 10) / 90.0); @@ -132,22 +130,20 @@ void w_handgrenade_throw(void) } #endif -void w_handgrenade_draw(void) +void w_handgrenade_draw(player pl) { - player pl = (player)self; pl.mode_tempstate = 0; Weapons_SetModel("models/v_grenade.mdl"); - Weapons_ViewAnimation(HANDGRENADE_DRAW); + Weapons_ViewAnimation(pl, HANDGRENADE_DRAW); } -void w_handgrenade_holster(void) +void w_handgrenade_holster(player pl) { } -void w_handgrenade_primary(void) +void w_handgrenade_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; } @@ -162,14 +158,14 @@ void w_handgrenade_primary(void) return; } - Weapons_ViewAnimation(HANDGRENADE_PULLPIN); + Weapons_ViewAnimation(pl, HANDGRENADE_PULLPIN); pl.mode_tempstate = 1; pl.w_attack_next = 0.5f; pl.w_idle_next = 0.5f; } -void w_handgrenade_hud(void) +void w_handgrenade_hud(player pl) { #ifdef CLIENT HUD_DrawAmmo2(); @@ -178,18 +174,17 @@ void w_handgrenade_hud(void) #endif } -void w_handgrenade_release(void) +void w_handgrenade_release(player pl) { - player pl = (player)self; if (pl.w_idle_next > 0.0) { return; } if (pl.mode_tempstate == 1) { - Weapons_ViewAnimation(HANDGRENADE_THROW1); + Weapons_ViewAnimation(pl, HANDGRENADE_THROW1); #ifdef SERVER - w_handgrenade_throw(); + w_handgrenade_throw(pl); #endif pl.ammo_handgrenade--; pl.mode_tempstate = 2; @@ -201,7 +196,7 @@ void w_handgrenade_release(void) else Animation_PlayerTop(pl, ANIM_SHOOTCROWBAR, 0.5f); } else if (pl.mode_tempstate == 2) { - Weapons_ViewAnimation(HANDGRENADE_DRAW); + Weapons_ViewAnimation(pl, HANDGRENADE_DRAW); #ifdef SERVER if (!pl.ammo_handgrenade) { Weapons_RemoveItem(pl, WEAPON_HANDGRENADE); @@ -213,26 +208,25 @@ void w_handgrenade_release(void) } else { int r = floor(pseudorandom() * 8.0f); if (r == 1) { - Weapons_ViewAnimation(HANDGRENADE_FIDGET); + Weapons_ViewAnimation(pl, HANDGRENADE_FIDGET); pl.w_idle_next = 2.5f; } else { - Weapons_ViewAnimation(HANDGRENADE_IDLE); + Weapons_ViewAnimation(pl, HANDGRENADE_IDLE); pl.w_idle_next = 3.0f; } } } float -w_handgrenade_aimanim(void) +w_handgrenade_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMCROWBAR : ANIM_AIMCROWBAR; } void -w_handgrenade_hudpic(int selected, vector pos, float a) +w_handgrenade_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT - player pl = (player)self; if (selected) { drawsubpic(pos, [170,45], g_hud6_spr, [0,0], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); @@ -245,9 +239,8 @@ w_handgrenade_hudpic(int selected, vector pos, float a) } int -w_handgrenade_isempty(void) +w_handgrenade_isempty(player pl) { - player pl = (player)self; if (pl.ammo_handgrenade <= 0) return 1; @@ -256,7 +249,7 @@ w_handgrenade_isempty(void) } weapontype_t -w_handgrenade_type(void) +w_handgrenade_type(player pl) { return WPNTYPE_THROW; } @@ -274,7 +267,7 @@ weapon_t w_handgrenade = .secondary = __NULL__, .reload = __NULL__, .release = w_handgrenade_release, - .crosshair = w_handgrenade_hud, + .postdraw = w_handgrenade_hud, .precache = w_handgrenade_precache, .pickup = w_handgrenade_pickup, .updateammo = w_handgrenade_updateammo, diff --git a/src/shared/w_hornetgun.qc b/src/shared/w_hornetgun.qc index 655bc58..6d80a41 100644 --- a/src/shared/w_hornetgun.qc +++ b/src/shared/w_hornetgun.qc @@ -49,10 +49,9 @@ w_hornetgun_precache(void) } int -w_hornetgun_pickup(int new, int startammo) +w_hornetgun_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; /* only pick it up once */ if (new) { @@ -72,7 +71,7 @@ string w_hornetgun_wmodel(void) { return "models/w_hgun.mdl"; } -string w_hornetgun_pmodel(void) +string w_hornetgun_pmodel(player pl) { return "models/p_hgun.mdl"; } @@ -82,21 +81,21 @@ string w_hornetgun_deathmsg(void) } void -w_hornetgun_draw(void) +w_hornetgun_draw(player pl) { Weapons_SetModel("models/v_hgun.mdl"); - Weapons_ViewAnimation(HORNETGUN_DRAW); + Weapons_ViewAnimation(pl, HORNETGUN_DRAW); } void -w_hornetgun_holster(void) +w_hornetgun_holster(player pl) { } #ifdef SERVER void -w_hornetgun_shoothornet(void) +w_hornetgun_shoothornet(player pl) { static void Hornet_Touch(void) { if (other.takedamage == DAMAGE_YES) { @@ -108,10 +107,10 @@ w_hornetgun_shoothornet(void) remove(self); } - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); entity bolt = spawn(); setmodel(bolt, "models/hornet.mdl"); - setorigin(bolt, Weapons_GetCameraPos() + (v_forward * 16) + (v_up * -8)); + setorigin(bolt, Weapons_GetCameraPos(pl) + (v_forward * 16) + (v_up * -8)); bolt.owner = self; bolt.velocity = v_forward * 1000; bolt.movetype = MOVETYPE_FLY; @@ -126,9 +125,8 @@ w_hornetgun_shoothornet(void) #endif void -w_hornetgun_release(void) +w_hornetgun_release(player pl) { - player pl = (player)self; if (pl.w_idle_next > 0.0) { return; @@ -150,40 +148,39 @@ w_hornetgun_release(void) r = floor(pseudorandom() * 3.0f); switch (r) { case 1: - Weapons_ViewAnimation(HORNETGUN_FIDGET1); + Weapons_ViewAnimation(pl, HORNETGUN_FIDGET1); pl.w_idle_next = 2.5f; break; case 2: - Weapons_ViewAnimation(HORNETGUN_FIDGET2); + Weapons_ViewAnimation(pl, HORNETGUN_FIDGET2); pl.w_idle_next = 2.1875f; break; default: - Weapons_ViewAnimation(HORNETGUN_IDLE); + Weapons_ViewAnimation(pl, HORNETGUN_IDLE); pl.w_idle_next = 1.875f; } } void -w_hornetgun_primary(void) +w_hornetgun_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; } /* Ammo check */ if (pl.ammo_hornet <= 0) { - w_hornetgun_release(); + w_hornetgun_release(pl); return; } #ifdef SERVER - w_hornetgun_shoothornet(); + w_hornetgun_shoothornet(pl); Sound_Play(pl, CHAN_WEAPON, "weapon_hornetgun.fire"); #endif pl.ammo_hornet--; - Weapons_ViewAnimation(HORNETGUN_SHOOT); + Weapons_ViewAnimation(pl, HORNETGUN_SHOOT); if (self.flags & FL_CROUCHING) Animation_PlayerTop(pl, ANIM_CR_SHOOTHIVE, 0.43f); @@ -195,26 +192,25 @@ w_hornetgun_primary(void) } void -w_hornetgun_secondary(void) +w_hornetgun_secondary(player pl) { - player pl = (player)self; if (pl.w_attack_next) { return; } /* Ammo check */ if (pl.ammo_hornet <= 0) { - w_hornetgun_release(); + w_hornetgun_release(pl); return; } #ifdef SERVER - w_hornetgun_shoothornet(); + w_hornetgun_shoothornet(pl); Sound_Play(pl, CHAN_WEAPON, "weapon_hornetgun.fire"); #endif pl.ammo_hornet--; - Weapons_ViewAnimation(HORNETGUN_SHOOT); + Weapons_ViewAnimation(pl, HORNETGUN_SHOOT); if (self.flags & FL_CROUCHING) Animation_PlayerTop(pl, ANIM_CR_SHOOTHIVE, 0.43f); @@ -226,7 +222,7 @@ w_hornetgun_secondary(void) } void -w_hornetgun_crosshair(void) +w_hornetgun_crosshair(player pl) { #ifdef CLIENT vector cross_pos; @@ -262,16 +258,15 @@ w_hornetgun_crosshair(void) } float -w_hornetgun_aimanim(void) +w_hornetgun_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMHIVE : ANIM_AIMHIVE; } void -w_hornetgun_hudpic(int selected, vector pos, float a) +w_hornetgun_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT - player pl = (player)self; if (selected) { drawsubpic( @@ -302,13 +297,13 @@ w_hornetgun_hudpic(int selected, vector pos, float a) } int -w_hornetgun_isempty(void) +w_hornetgun_isempty(player pl) { return 0; } weapontype_t -w_hornetgun_type(void) +w_hornetgun_type(player pl) { return WPNTYPE_RANGED; } @@ -326,7 +321,7 @@ weapon_t w_hornetgun = .secondary = w_hornetgun_secondary, .reload = __NULL__, .release = w_hornetgun_release, - .crosshair = w_hornetgun_crosshair, + .postdraw = w_hornetgun_crosshair, .precache = w_hornetgun_precache, .pickup = w_hornetgun_pickup, .updateammo = w_hornetgun_updateammo, diff --git a/src/shared/w_mp5.qc b/src/shared/w_mp5.qc index ca364e7..156e3ac 100644 --- a/src/shared/w_mp5.qc +++ b/src/shared/w_mp5.qc @@ -99,10 +99,9 @@ w_mp5_precache(void) } int -w_mp5_pickup(int new, int startammo) +w_mp5_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (new) { pl.mp5_mag = 25; @@ -132,7 +131,7 @@ w_mp5_wmodel(void) } string -w_mp5_pmodel(void) +w_mp5_pmodel(player pl) { return "models/p_9mmar.mdl"; } @@ -144,22 +143,21 @@ w_mp5_deathmsg(void) } void -w_mp5_draw(void) +w_mp5_draw(player pl) { Weapons_SetModel("models/v_9mmar.mdl"); - Weapons_ViewAnimation(MP5_DRAW); + Weapons_ViewAnimation(pl, MP5_DRAW); } void -w_mp5_holster(void) +w_mp5_holster(player pl) { - Weapons_ViewAnimation(MP5_DRAW); + Weapons_ViewAnimation(pl, MP5_DRAW); } void -w_mp5_primary(void) +w_mp5_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; @@ -175,12 +173,12 @@ w_mp5_primary(void) /* Actual firing */ int r = (float)input_sequence % 2; if (r) { - Weapons_ViewAnimation(MP5_FIRE1); + Weapons_ViewAnimation(pl, MP5_FIRE1); } else { - Weapons_ViewAnimation(MP5_FIRE2); + Weapons_ViewAnimation(pl, MP5_FIRE2); } - Weapons_ViewPunchAngle([-2,0,0]); + Weapons_ViewPunchAngle(pl, [-2,0,0]); #ifdef CLIENT View_SetMuzzleflash(MUZZLE_RIFLE); @@ -188,9 +186,9 @@ w_mp5_primary(void) #else /* singleplayer is more accurate */ if (cvar("sv_playerslots") == 1) { - TraceAttack_FireBullets(1, Weapons_GetCameraPos(), Skill_GetValue("plr_9mmAR_bullet", 5), [0.025,0.025], WEAPON_MP5); + TraceAttack_FireBullets(1, Weapons_GetCameraPos(pl), Skill_GetValue("plr_9mmAR_bullet", 5), [0.025,0.025], WEAPON_MP5); } else { - TraceAttack_FireBullets(1, Weapons_GetCameraPos(), Skill_GetValue("plr_9mmAR_bullet", 5), [0.05,0.05], WEAPON_MP5); + TraceAttack_FireBullets(1, Weapons_GetCameraPos(pl), Skill_GetValue("plr_9mmAR_bullet", 5), [0.05,0.05], WEAPON_MP5); } Sound_Play(pl, CHAN_WEAPON, "weapon_mp5.shoot"); @@ -206,9 +204,8 @@ w_mp5_primary(void) } void -w_mp5_secondary(void) +w_mp5_secondary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; @@ -235,10 +232,10 @@ w_mp5_secondary(void) remove(self); } - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); entity gren = spawn(); setmodel(gren, "models/grenade.mdl"); - setorigin(gren, Weapons_GetCameraPos() + (v_forward * 16)); + setorigin(gren, Weapons_GetCameraPos(pl) + (v_forward * 16)); gren.owner = self; gren.velocity = v_forward * 800; gren.angles = vectoangles(gren.velocity); @@ -252,8 +249,8 @@ w_mp5_secondary(void) Sound_Play(pl, CHAN_WEAPON, "weapon_mp5.gl"); #endif - Weapons_ViewPunchAngle([-10,0,0]); - Weapons_ViewAnimation(MP5_GRENADE); + Weapons_ViewPunchAngle(pl, [-10,0,0]); + Weapons_ViewAnimation(pl, MP5_GRENADE); if (self.flags & FL_CROUCHING) Animation_PlayerTop(pl, ANIM_CR_SHOOTMP5, 0.45f); @@ -265,9 +262,8 @@ w_mp5_secondary(void) } void -w_mp5_reload(void) +w_mp5_reload(player pl) { - player pl = (player)self; if (pl.w_attack_next) { return; } @@ -280,7 +276,7 @@ w_mp5_reload(void) return; } - Weapons_ViewAnimation(MP5_RELOAD); + Weapons_ViewAnimation(pl, MP5_RELOAD); #ifdef SERVER static void w_mp5_reload_done(void) { @@ -297,14 +293,13 @@ w_mp5_reload(void) } void -w_mp5_release(void) +w_mp5_release(player pl) { - player pl = (player)self; /* auto-reload if need be */ if (pl.w_attack_next <= 0.0) if (pl.mp5_mag == 0 && pl.ammo_9mm > 0) { - Weapons_Reload(); + Weapons_Reload(pl); return; } if (pl.w_idle_next > 0.0) { @@ -313,16 +308,16 @@ w_mp5_release(void) int r = floor(pseudorandom() * 3.0f); if (r == 1) { - Weapons_ViewAnimation(MP5_IDLE1); + Weapons_ViewAnimation(pl, MP5_IDLE1); } else { - Weapons_ViewAnimation(MP5_IDLE2); + Weapons_ViewAnimation(pl, MP5_IDLE2); } pl.w_idle_next = 15.0f; } void -w_mp5_crosshair(void) +w_mp5_crosshair(player pl) { #ifdef CLIENT vector cross_pos; @@ -372,16 +367,15 @@ w_mp5_crosshair(void) } float -w_mp5_aimanim(void) +w_mp5_aimanim(player pl) { return self.flags & ANIM_CR_AIMMP5 ? ANIM_CR_AIMCROWBAR : ANIM_AIMMP5; } void -w_mp5_hudpic(int selected, vector pos, float a) +w_mp5_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT - player pl = (player)self; vector hud_col; if (pl.mp5_mag == 0 && pl.ammo_9mm == 0 && pl.ammo_m203_grenade == 0) @@ -419,9 +413,8 @@ w_mp5_hudpic(int selected, vector pos, float a) } int -w_mp5_isempty(void) +w_mp5_isempty(player pl) { - player pl = (player)self; if (pl.mp5_mag <= 0 && pl.ammo_9mm <= 0 && pl.ammo_m203_grenade <= 0) return 1; @@ -430,7 +423,7 @@ w_mp5_isempty(void) } weapontype_t -w_mp5_type(void) +w_mp5_type(player pl) { return WPNTYPE_RANGED; } @@ -448,7 +441,7 @@ weapon_t w_mp5 = .secondary = w_mp5_secondary, .reload = w_mp5_reload, .release = w_mp5_release, - .crosshair = w_mp5_crosshair, + .postdraw = w_mp5_crosshair, .precache = w_mp5_precache, .pickup = w_mp5_pickup, .updateammo = w_mp5_updateammo, diff --git a/src/shared/w_python.qc b/src/shared/w_python.qc index 1e80276..97d8659 100644 --- a/src/shared/w_python.qc +++ b/src/shared/w_python.qc @@ -60,10 +60,9 @@ w_python_precache(void) } int -w_python_pickup(int new, int startammo) +w_python_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (new) { pl.python_mag = 6; @@ -93,7 +92,7 @@ w_python_wmodel(void) } string -w_python_pmodel(void) +w_python_pmodel(player pl) { return "models/p_357.mdl"; } @@ -105,7 +104,7 @@ w_python_deathmsg(void) } void -w_python_draw(void) +w_python_draw(player pl) { Weapons_SetModel("models/v_357.mdl"); @@ -116,19 +115,18 @@ w_python_draw(void) Weapons_SetGeomset("geomset 4 2\n"); } - Weapons_ViewAnimation(PYTHON_DRAW); + Weapons_ViewAnimation(pl, PYTHON_DRAW); } void -w_python_holster(void) +w_python_holster(player pl) { - Weapons_ViewAnimation(PYTHON_HOLSTER); + Weapons_ViewAnimation(pl, PYTHON_HOLSTER); } void -w_python_primary(void) +w_python_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; @@ -149,8 +147,8 @@ w_python_primary(void) Sound_Play(pl, CHAN_WEAPON, "weapon_357.shoot"); #endif - Weapons_ViewPunchAngle([-10,0,0]); - Weapons_ViewAnimation(PYTHON_FIRE1); + Weapons_ViewPunchAngle(pl, [-10,0,0]); + Weapons_ViewAnimation(pl, PYTHON_FIRE1); if (self.flags & FL_CROUCHING) Animation_PlayerTop(pl, ANIM_CR_SHOOTPYTHON, 0.43f); @@ -162,9 +160,8 @@ w_python_primary(void) } void -w_python_secondary(void) +w_python_secondary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; @@ -186,9 +183,8 @@ w_python_secondary(void) } void -w_python_reload(void) +w_python_reload(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; @@ -203,7 +199,7 @@ w_python_reload(void) } /* Audio-Visual bit */ - Weapons_ViewAnimation(PYTHON_RELOAD); + Weapons_ViewAnimation(pl, PYTHON_RELOAD); #ifdef SERVER static void w_python_reload_done(void) { @@ -221,14 +217,13 @@ w_python_reload(void) } void -w_python_release(void) +w_python_release(player pl) { - player pl = (player)self; /* auto-reload if need be */ if (pl.w_attack_next <= 0.0) if (pl.python_mag == 0 && pl.ammo_357 > 0) { - Weapons_Reload(); + Weapons_Reload(pl); return; } @@ -240,26 +235,26 @@ w_python_release(void) switch (r) { case 1: - Weapons_ViewAnimation(PYTHON_IDLE1); + Weapons_ViewAnimation(pl, PYTHON_IDLE1); pl.w_idle_next = 2.33f; break; case 2: - Weapons_ViewAnimation(PYTHON_FIDGET); + Weapons_ViewAnimation(pl, PYTHON_FIDGET); pl.w_idle_next = 5.66f; break; case 3: - Weapons_ViewAnimation(PYTHON_IDLE2); + Weapons_ViewAnimation(pl, PYTHON_IDLE2); pl.w_idle_next = 2.0f; break; default: - Weapons_ViewAnimation(PYTHON_IDLE3); + Weapons_ViewAnimation(pl, PYTHON_IDLE3); pl.w_idle_next = 2.93f; break; } } void -w_python_crosshair(void) +w_python_crosshair(player pl) { #ifdef CLIENT vector cross_pos; @@ -295,16 +290,15 @@ w_python_crosshair(void) } float -w_python_aimanim(void) +w_python_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMPYTHON : ANIM_AIMPYTHON; } void -w_python_hudpic(int selected, vector pos, float a) +w_python_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT - player pl = (player)self; vector hud_col; if (pl.python_mag == 0 && pl.ammo_357 == 0) @@ -341,9 +335,8 @@ w_python_hudpic(int selected, vector pos, float a) } int -w_python_isempty(void) +w_python_isempty(player pl) { - player pl = (player)self; if (pl.python_mag <= 0 && pl.ammo_357 <= 0) return 1; @@ -352,7 +345,7 @@ w_python_isempty(void) } weapontype_t -w_python_type(void) +w_python_type(player pl) { return WPNTYPE_RANGED; } @@ -370,7 +363,7 @@ weapon_t w_python = .secondary = w_python_secondary, .reload = w_python_reload, .release = w_python_release, - .crosshair = w_python_crosshair, + .postdraw = w_python_crosshair, .precache = w_python_precache, .pickup = w_python_pickup, .updateammo = w_python_updateammo, diff --git a/src/shared/w_rpg.qc b/src/shared/w_rpg.qc index 8f6a363..cf2f61e 100644 --- a/src/shared/w_rpg.qc +++ b/src/shared/w_rpg.qc @@ -58,7 +58,7 @@ string w_rpg_wmodel(void) { return "models/w_rpg.mdl"; } -string w_rpg_pmodel(void) +string w_rpg_pmodel(player pl) { return "models/p_rpg.mdl"; } @@ -67,10 +67,9 @@ string w_rpg_deathmsg(void) return ""; } -int w_rpg_pickup(int new, int startammo) +int w_rpg_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (new) { pl.rpg_mag = 1; @@ -87,20 +86,19 @@ int w_rpg_pickup(int new, int startammo) return (1); } -void w_rpg_draw(void) +void w_rpg_draw(player pl) { Weapons_SetModel("models/v_rpg.mdl"); - Weapons_ViewAnimation(RPG_DRAW1); + Weapons_ViewAnimation(pl, RPG_DRAW1); } -void w_rpg_holster(void) +void w_rpg_holster(player pl) { } -void w_rpg_primary(void) +void w_rpg_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; } @@ -134,10 +132,10 @@ void w_rpg_primary(void) self.nextthink = time; } - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); entity rocket = spawn(); setmodel(rocket, "models/rpgrocket.mdl"); - setorigin(rocket, Weapons_GetCameraPos() + (v_forward * 16)); + setorigin(rocket, Weapons_GetCameraPos(pl) + (v_forward * 16)); rocket.owner = self; rocket.movetype = MOVETYPE_FLY; rocket.solid = SOLID_BBOX; @@ -159,8 +157,8 @@ void w_rpg_primary(void) Sound_Play(pl, CHAN_WEAPON, "weapon_rpg.shoot"); #endif - Weapons_ViewAnimation(RPG_FIRE2); - Weapons_ViewPunchAngle([-10,0,0]); + Weapons_ViewAnimation(pl, RPG_FIRE2); + Weapons_ViewPunchAngle(pl, [-10,0,0]); if (self.flags & FL_CROUCHING) Animation_PlayerTop(pl, ANIM_CR_SHOOTRPG, 0.43f); @@ -171,9 +169,8 @@ void w_rpg_primary(void) pl.w_idle_next = 2.5f; } -void w_rpg_reload(void) +void w_rpg_reload(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0) { return; @@ -187,7 +184,7 @@ void w_rpg_reload(void) return; } - Weapons_ViewAnimation(RPG_RELOAD); + Weapons_ViewAnimation(pl, RPG_RELOAD); /* Audio-Visual Bit */ #ifdef SERVER @@ -204,14 +201,13 @@ void w_rpg_reload(void) pl.w_idle_next = 10.0f; } -void w_rpg_release(void) +void w_rpg_release(player pl) { - player pl = (player)self; /* auto-reload if need be */ if (pl.w_attack_next <= 0.0) if (pl.rpg_mag == 0 && pl.ammo_rocket > 0) { - Weapons_Reload(); + Weapons_Reload(pl); return; } @@ -223,22 +219,21 @@ void w_rpg_release(void) if (pl.rpg_mag > 0) { if (r == 1) { - Weapons_ViewAnimation(RPG_FIDGET); + Weapons_ViewAnimation(pl, RPG_FIDGET); } else { - Weapons_ViewAnimation(RPG_IDLE); + Weapons_ViewAnimation(pl, RPG_IDLE); } } else { if (r == 1) { - Weapons_ViewAnimation(RPG_FIDGET_UL); + Weapons_ViewAnimation(pl, RPG_FIDGET_UL); } else { - Weapons_ViewAnimation(RPG_IDLE_UL); + Weapons_ViewAnimation(pl, RPG_IDLE_UL); } } } -void w_rpg_secondary(void) +void w_rpg_secondary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; @@ -248,18 +243,17 @@ void w_rpg_secondary(void) pl.ammo_rpg_state = 1 - pl.ammo_rpg_state; pl.w_attack_next = 0.25f; - w_rpg_release(); + w_rpg_release(pl); } -float w_rpg_aimanim(void) +float w_rpg_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMRPG : ANIM_AIMRPG; } -void w_rpg_hudpic(int selected, vector pos, float a) +void w_rpg_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT - player pl = (player)self; vector hud_col; if (pl.rpg_mag == 0 && pl.ammo_rocket == 0) @@ -277,10 +271,9 @@ void w_rpg_hudpic(int selected, vector pos, float a) #endif } -void w_rpg_hud(void) +void w_rpg_hud(player pl) { #ifdef CLIENT - player pl = (player)self; vector cross_pos; vector aicon_pos; @@ -288,7 +281,7 @@ void w_rpg_hud(void) if (pl.ammo_rpg_state == 1) { float lerp; vector jitter; - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); vector src = pl.origin + pl.view_ofs; traceline(src, src + (v_forward * 256), FALSE, pl); lerp = Math_Lerp(18,6, trace_fraction); @@ -339,9 +332,8 @@ void w_rpg_hud(void) } int -w_rpg_isempty(void) +w_rpg_isempty(player pl) { - player pl = (player)self; if (pl.rpg_mag <= 0 && pl.ammo_rocket <= 0) return 1; @@ -350,7 +342,7 @@ w_rpg_isempty(void) } weapontype_t -w_rpg_type(void) +w_rpg_type(player pl) { return WPNTYPE_RANGED; } @@ -368,7 +360,7 @@ weapon_t w_rpg = .secondary = w_rpg_secondary, .reload = w_rpg_reload, .release = w_rpg_release, - .crosshair = w_rpg_hud, + .postdraw = w_rpg_hud, .precache = w_rpg_precache, .pickup = w_rpg_pickup, .updateammo = w_rpg_updateammo, diff --git a/src/shared/w_satchel.qc b/src/shared/w_satchel.qc index 0c0d4d2..312638a 100644 --- a/src/shared/w_satchel.qc +++ b/src/shared/w_satchel.qc @@ -97,7 +97,7 @@ w_satchel_wmodel(void) } string -w_satchel_pmodel(void) +w_satchel_pmodel(player pl) { return "models/p_satchel.mdl"; } @@ -122,10 +122,9 @@ w_satchel_precache(void) } int -w_satchel_pickup(int new, int startammo) +w_satchel_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (pl.ammo_satchel < MAX_A_SATCHEL) { pl.ammo_satchel = bound(0, pl.ammo_satchel + 1, MAX_A_SATCHEL); @@ -138,29 +137,27 @@ w_satchel_pickup(int new, int startammo) } void -w_satchel_draw(void) +w_satchel_draw(player pl) { - player pl = (player)self; if (pl.satchel_chg > 0) { Weapons_SetModel("models/v_satchel_radio.mdl"); - Weapons_ViewAnimation(RADIO_DRAW); + Weapons_ViewAnimation(pl, RADIO_DRAW); } else { Weapons_SetModel("models/v_satchel.mdl"); - Weapons_ViewAnimation(SATCHEL_DRAW); + Weapons_ViewAnimation(pl, SATCHEL_DRAW); } } void -w_satchel_holster(void) +w_satchel_holster(player pl) { } void -w_satchel_primary(void) +w_satchel_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next) { return; @@ -172,9 +169,9 @@ w_satchel_primary(void) } if (pl.satchel_chg <= 0) { - Weapons_ViewAnimation(RADIO_DRAW); + Weapons_ViewAnimation(pl, RADIO_DRAW); } else { - Weapons_ViewAnimation(RADIO_USE); + Weapons_ViewAnimation(pl, RADIO_USE); } #ifdef SERVER @@ -182,7 +179,7 @@ w_satchel_primary(void) if (!pl.satchel_chg) { vector throw; - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); throw = pl.velocity + (v_forward * 274); s_satchel_drop(self, pl.origin, throw); pl.satchel_chg++; @@ -219,9 +216,8 @@ w_satchel_primary(void) } void -w_satchel_secondary(void) +w_satchel_secondary(player pl) { - player pl = (player)self; if (pl.w_attack_next) { return; @@ -233,11 +229,11 @@ w_satchel_secondary(void) } Weapons_SetModel("models/v_satchel_radio.mdl"); - Weapons_ViewAnimation(RADIO_DRAW); + Weapons_ViewAnimation(pl, RADIO_DRAW); #ifdef SERVER vector throw; - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); throw = pl.velocity + (v_forward * 274); s_satchel_drop(self, pl.origin, throw); #endif @@ -255,36 +251,35 @@ w_satchel_secondary(void) } void -w_satchel_reload(void) +w_satchel_reload(player pl) { } void -w_satchel_release(void) +w_satchel_release(player pl) { - player pl = (player)self; if (pl.w_idle_next > 0.0) { return; } if (pl.satchel_chg <= 0) { - Weapons_ViewAnimation(SATCHEL_FIDGET); + Weapons_ViewAnimation(pl, SATCHEL_FIDGET); } else { - Weapons_ViewAnimation(RADIO_FIDGET); + Weapons_ViewAnimation(pl, RADIO_FIDGET); } pl.w_idle_next = 15.0f; } float -w_satchel_aimanim(void) +w_satchel_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMSQUEAK : ANIM_AIMSQUEAK; } void -w_satchel_hud(void) +w_satchel_hud(player pl) { #ifdef CLIENT HUD_DrawAmmo2(); @@ -294,10 +289,9 @@ w_satchel_hud(void) } void -w_satchel_hudpic(int selected, vector pos, float a) +w_satchel_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT - player pl = (player)self; if (selected) { drawsubpic(pos, [170,45], g_hud6_spr, [0,45/256], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); @@ -310,9 +304,8 @@ w_satchel_hudpic(int selected, vector pos, float a) } int -w_satchel_isempty(void) +w_satchel_isempty(player pl) { - player pl = (player)self; if (pl.satchel_chg <= 0) return 1; @@ -321,7 +314,7 @@ w_satchel_isempty(void) } weapontype_t -w_satchel_type(void) +w_satchel_type(player pl) { return WPNTYPE_THROW; } @@ -339,7 +332,7 @@ weapon_t w_satchel = .secondary = w_satchel_secondary, .reload = w_satchel_reload, .release = w_satchel_release, - .crosshair = w_satchel_hud, + .postdraw = w_satchel_hud, .precache = w_satchel_precache, .pickup = w_satchel_pickup, .updateammo = w_satchel_updateammo, diff --git a/src/shared/w_shotgun.qc b/src/shared/w_shotgun.qc index 56e16ac..73adca8 100644 --- a/src/shared/w_shotgun.qc +++ b/src/shared/w_shotgun.qc @@ -108,7 +108,7 @@ w_shotgun_wmodel(void) } string -w_shotgun_pmodel(void) +w_shotgun_pmodel(player pl) { return "models/p_shotgun.mdl"; } @@ -120,10 +120,9 @@ w_shotgun_deathmsg(void) } int -w_shotgun_pickup(int new, int startammo) +w_shotgun_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (new) { pl.shotgun_mag = 8; @@ -141,46 +140,44 @@ w_shotgun_pickup(int new, int startammo) } void -w_shotgun_draw(void) +w_shotgun_draw(player pl) { - player pl = (player)self; pl.mode_tempstate = 0; Weapons_SetModel("models/v_shotgun.mdl"); - Weapons_ViewAnimation(SHOTGUN_DRAW); + Weapons_ViewAnimation(pl, SHOTGUN_DRAW); } void -w_shotgun_holster(void) +w_shotgun_holster(player pl) { - Weapons_ViewAnimation(SHOTGUN_HOLSTER); + Weapons_ViewAnimation(pl, SHOTGUN_HOLSTER); } -void w_shotgun_release(void); +void w_shotgun_release(player pl); void -w_shotgun_primary(void) +w_shotgun_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next) { - w_shotgun_release(); + w_shotgun_release(pl); return; } /* interrupt reloading if no longer empty */ if (pl.mode_tempstate == SHOTTY_RELOAD && pl.shotgun_mag >= 1) { pl.mode_tempstate = SHOTTY_RELOAD_END; - w_shotgun_release(); + w_shotgun_release(pl); return; } else if (pl.mode_tempstate > SHOTTY_IDLE) { - w_shotgun_release(); + w_shotgun_release(pl); return; } /* Ammo check */ if (pl.shotgun_mag <= 0) { - w_shotgun_release(); + w_shotgun_release(pl); return; } @@ -197,8 +194,8 @@ w_shotgun_primary(void) View_AddEvent(w_shotgun_ejectshell, 0.5f); #endif - Weapons_ViewAnimation(SHOTGUN_FIRE1); - Weapons_ViewPunchAngle([-5,0,0]); + Weapons_ViewAnimation(pl, SHOTGUN_FIRE1); + Weapons_ViewPunchAngle(pl, [-5,0,0]); if (self.flags & FL_CROUCHING) Animation_PlayerTop(pl, ANIM_CR_SHOOTSHOTGUN, 0.41f); @@ -215,33 +212,32 @@ w_shotgun_primary(void) } void -w_shotgun_secondary(void) +w_shotgun_secondary(player pl) { - player pl = (player)self; if (pl.w_attack_next) { - w_shotgun_release(); + w_shotgun_release(pl); return; } /* interrupt reloading if no longer empty */ if (pl.mode_tempstate == SHOTTY_RELOAD && pl.shotgun_mag >= 2) { pl.mode_tempstate = SHOTTY_RELOAD_END; - w_shotgun_release(); + w_shotgun_release(pl); return; } else if (pl.mode_tempstate > SHOTTY_IDLE) { - w_shotgun_release(); + w_shotgun_release(pl); return; } /* Ammo check */ if (pl.shotgun_mag <= 1) { - w_shotgun_release(); + w_shotgun_release(pl); return; } - Weapons_ViewAnimation(SHOTGUN_FIRE2); - Weapons_ViewPunchAngle([-10,0,0]); + Weapons_ViewAnimation(pl, SHOTGUN_FIRE2); + Weapons_ViewPunchAngle(pl, [-10,0,0]); if (self.flags & FL_CROUCHING) Animation_PlayerTop(pl, ANIM_CR_SHOOTSHOTGUN, 0.41f); @@ -269,9 +265,8 @@ w_shotgun_secondary(void) } void -w_shotgun_reload(void) +w_shotgun_reload(player pl) { - player pl = (player)self; if (pl.shotgun_mag >= 8) { return; @@ -288,14 +283,13 @@ w_shotgun_reload(void) } void -w_shotgun_release(void) +w_shotgun_release(player pl) { - player pl = (player)self; /* auto-reload if need be */ if (pl.w_attack_next <= 0.0) if (pl.mode_tempstate == SHOTTY_IDLE && pl.shotgun_mag == 0 && pl.ammo_buckshot > 0) { - Weapons_Reload(); + Weapons_Reload(pl); return; } @@ -307,24 +301,24 @@ w_shotgun_release(void) int r = floor(pseudorandom() * 3.0f); switch (r) { case 1: - Weapons_ViewAnimation(SHOTGUN_IDLE2); + Weapons_ViewAnimation(pl, SHOTGUN_IDLE2); pl.w_idle_next = 2.222222f; break; case 2: - Weapons_ViewAnimation(SHOTGUN_IDLE3); + Weapons_ViewAnimation(pl, SHOTGUN_IDLE3); pl.w_idle_next = 5.0f; break; default: - Weapons_ViewAnimation(SHOTGUN_IDLE1); + Weapons_ViewAnimation(pl, SHOTGUN_IDLE1); pl.w_idle_next = 2.222222f; break; } } else if (pl.mode_tempstate == SHOTTY_RELOAD_START) { - Weapons_ViewAnimation(SHOTGUN_START_RELOAD); + Weapons_ViewAnimation(pl, SHOTGUN_START_RELOAD); pl.mode_tempstate = SHOTTY_RELOAD; pl.w_idle_next = 0.65f; } else if (pl.mode_tempstate == SHOTTY_RELOAD) { - Weapons_ViewAnimation(SHOTGUN_RELOAD); + Weapons_ViewAnimation(pl, SHOTGUN_RELOAD); pl.shotgun_mag++; pl.ammo_buckshot--; #ifdef SERVER @@ -336,7 +330,7 @@ w_shotgun_release(void) Weapons_UpdateAmmo(pl, pl.shotgun_mag, pl.ammo_buckshot, pl.mode_tempstate); pl.w_idle_next = 0.5f; } else if (pl.mode_tempstate == SHOTTY_RELOAD_END) { - Weapons_ViewAnimation(SHOTGUN_PUMP); + Weapons_ViewAnimation(pl, SHOTGUN_PUMP); #ifdef SERVER Sound_Play(pl, CHAN_WEAPON, "weapon_shotgun.cock"); #endif @@ -356,7 +350,7 @@ w_shotgun_release(void) } void -w_shotgun_crosshair(void) +w_shotgun_crosshair(player pl) { #ifdef CLIENT static vector cross_pos; @@ -370,16 +364,15 @@ w_shotgun_crosshair(void) } float -w_shotgun_aimanim(void) +w_shotgun_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMSHOTGUN : ANIM_AIMSHOTGUN; } void -w_shotgun_hudpic(int selected, vector pos, float a) +w_shotgun_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT - player pl = (player)self; vector hud_col; if (pl.shotgun_mag == 0 && pl.ammo_buckshot == 0) @@ -398,9 +391,8 @@ w_shotgun_hudpic(int selected, vector pos, float a) } int -w_shotgun_isempty(void) +w_shotgun_isempty(player pl) { - player pl = (player)self; if (pl.shotgun_mag <= 0 && pl.ammo_buckshot <= 0) return 1; @@ -409,7 +401,7 @@ w_shotgun_isempty(void) } weapontype_t -w_shotgun_type(void) +w_shotgun_type(player pl) { return WPNTYPE_RANGED; } @@ -427,7 +419,7 @@ weapon_t w_shotgun = .secondary = w_shotgun_secondary, .reload = w_shotgun_reload, .release = w_shotgun_release, - .crosshair = w_shotgun_crosshair, + .postdraw = w_shotgun_crosshair, .precache = w_shotgun_precache, .pickup = w_shotgun_pickup, .updateammo = w_shotgun_updateammo, diff --git a/src/shared/w_snark.qc b/src/shared/w_snark.qc index db9cd52..2d3148f 100644 --- a/src/shared/w_snark.qc +++ b/src/shared/w_snark.qc @@ -147,10 +147,9 @@ monster_snark::monster_snark(void) } #endif -int w_snark_pickup(int new, int startammo) +int w_snark_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (pl.ammo_snark < MAX_A_SNARK) { pl.ammo_snark = bound(0, pl.ammo_snark + 5, MAX_A_SNARK); @@ -162,13 +161,13 @@ int w_snark_pickup(int new, int startammo) return (1); } -void w_snark_draw(void) +void w_snark_draw(player pl) { Weapons_SetModel("models/v_squeak.mdl"); - Weapons_ViewAnimation(SNARK_DRAW); + Weapons_ViewAnimation(pl, SNARK_DRAW); } -void w_snark_holster(void) +void w_snark_holster(player pl) { } @@ -183,9 +182,8 @@ void w_snark_deploy(void) } #endif -void w_snark_primary(void) +void w_snark_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; } @@ -198,7 +196,7 @@ void w_snark_primary(void) pl.ammo_snark--; /* Audio-Visual Bit */ - Weapons_ViewAnimation(SNARK_THROW); + Weapons_ViewAnimation(pl, SNARK_THROW); if (self.flags & FL_CROUCHING) Animation_PlayerTop(pl, ANIM_CR_SHOOTSQUEAK, 0.41f); @@ -217,18 +215,17 @@ void w_snark_primary(void) pl.w_attack_next = 0.25f; } -void w_snark_secondary(void) +void w_snark_secondary(player pl) { } -void w_snark_reload(void) +void w_snark_reload(player pl) { } -void w_snark_release(void) +void w_snark_release(player pl) { int r; - player pl = (player)self; if (pl.w_idle_next > 0.0) { return; @@ -237,15 +234,15 @@ void w_snark_release(void) r = floor(pseudorandom() * 3.0f); switch (r) { case 0: - Weapons_ViewAnimation(SNARK_IDLE); + Weapons_ViewAnimation(pl, SNARK_IDLE); pl.w_idle_next = 1.875f; break; case 1: - Weapons_ViewAnimation(SNARK_FIDGET1); + Weapons_ViewAnimation(pl, SNARK_FIDGET1); pl.w_idle_next = 4.375f; break; default: - Weapons_ViewAnimation(SNARK_FIDGET2); + Weapons_ViewAnimation(pl, SNARK_FIDGET2); pl.w_idle_next = 5.0f; break; } @@ -276,7 +273,7 @@ string w_snark_wmodel(void) return "models/w_sqknest.mdl"; } -string w_snark_pmodel(void) +string w_snark_pmodel(player pl) { return "models/p_squeak.mdl"; } @@ -286,12 +283,12 @@ string w_snark_deathmsg(void) return ""; } -float w_snark_aimanim(void) +float w_snark_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMSQUEAK : ANIM_AIMSQUEAK; } -void w_snark_hud(void) +void w_snark_hud(player pl) { #ifdef CLIENT HUD_DrawAmmo2(); @@ -300,10 +297,9 @@ void w_snark_hud(void) #endif } -void w_snark_hudpic(int selected, vector pos, float a) +void w_snark_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT - player pl = (player)self; if (selected) { drawsubpic(pos, [170,45], g_hud6_spr, @@ -320,9 +316,8 @@ void w_snark_hudpic(int selected, vector pos, float a) } int -w_snark_isempty(void) +w_snark_isempty(player pl) { - player pl = (player)self; if (pl.ammo_snark <= 0) return 1; @@ -331,7 +326,7 @@ w_snark_isempty(void) } weapontype_t -w_snark_type(void) +w_snark_type(player pl) { return WPNTYPE_RANGED; } @@ -349,7 +344,7 @@ weapon_t w_snark = .secondary = w_snark_secondary, .reload = w_snark_reload, .release = w_snark_release, - .crosshair = w_snark_hud, + .postdraw = w_snark_hud, .precache = w_snark_precache, .pickup = w_snark_pickup, .updateammo = w_snark_updateammo, diff --git a/src/shared/w_tripmine.qc b/src/shared/w_tripmine.qc index e705c36..8aa3b46 100644 --- a/src/shared/w_tripmine.qc +++ b/src/shared/w_tripmine.qc @@ -222,7 +222,7 @@ string w_tripmine_wmodel(void) return "models/v_tripmine.mdl"; } -string w_tripmine_pmodel(void) +string w_tripmine_pmodel(player pl) { return "models/p_tripmine.mdl"; } @@ -232,10 +232,9 @@ string w_tripmine_deathmsg(void) return ""; } -int w_tripmine_pickup(int new, int startammo) +int w_tripmine_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (pl.ammo_tripmine < MAX_A_TRIPMINE) { pl.ammo_tripmine = bound(0, pl.ammo_tripmine + 1, MAX_A_TRIPMINE); @@ -247,21 +246,20 @@ int w_tripmine_pickup(int new, int startammo) return (1); } -void w_tripmine_draw(void) +void w_tripmine_draw(player pl) { Weapons_SetModel("models/v_tripmine.mdl"); - Weapons_ViewAnimation(TRIPMINE_DRAW); + Weapons_ViewAnimation(pl, TRIPMINE_DRAW); } -void w_tripmine_holster(void) +void w_tripmine_holster(player pl) { } void -w_tripmine_primary(void) +w_tripmine_primary(player pl) { - player pl = (player)self; vector src; if (pl.w_attack_next > 0.0) { @@ -272,8 +270,8 @@ w_tripmine_primary(void) return; } - src = Weapons_GetCameraPos(); - Weapons_MakeVectors(); + src = Weapons_GetCameraPos(pl); + Weapons_MakeVectors(pl); traceline(src, src + v_forward * 64, FALSE, pl); if (trace_fraction >= 1.0) { @@ -282,7 +280,7 @@ w_tripmine_primary(void) pl.ammo_tripmine--; - Weapons_ViewAnimation(TRIPMINE_FIRE2); + Weapons_ViewAnimation(pl, TRIPMINE_FIRE2); if (self.flags & FL_CROUCHING) Animation_PlayerTop(pl, ANIM_CR_SHOOTTRIPMINE, 0.41f); @@ -305,16 +303,15 @@ w_tripmine_primary(void) } void -w_tripmine_release(void) +w_tripmine_release(player pl) { - player pl = (player)self; if (pl.w_idle_next > 0.0) { return; } if (pl.a_ammo3 == 1) { - Weapons_ViewAnimation(TRIPMINE_DRAW); + Weapons_ViewAnimation(pl, TRIPMINE_DRAW); #ifdef SERVER if (pl.ammo_tripmine <= 0) { Weapons_RemoveItem(pl, WEAPON_TRIPMINE); @@ -329,28 +326,28 @@ w_tripmine_release(void) int r = (float)input_sequence % 3; switch (r) { case 1: - Weapons_ViewAnimation(TRIPMINE_IDLE1); + Weapons_ViewAnimation(pl, TRIPMINE_IDLE1); pl.w_idle_next = 3.0f; break; case 2: - Weapons_ViewAnimation(TRIPMINE_IDLE2); + Weapons_ViewAnimation(pl, TRIPMINE_IDLE2); pl.w_idle_next = 2.0f; break; default: - Weapons_ViewAnimation(TRIPMINE_FIDGET); + Weapons_ViewAnimation(pl, TRIPMINE_FIDGET); pl.w_idle_next = 3.34f; break; } } float -w_tripmine_aimanim(void) +w_tripmine_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMTRIPMINE : ANIM_AIMTRIPMINE; } void -w_tripmine_hud(void) +w_tripmine_hud(player pl) { #ifdef CLIENT HUD_DrawAmmo2(); @@ -360,10 +357,9 @@ w_tripmine_hud(void) } void -w_tripmine_hudpic(int selected, vector pos, float a) +w_tripmine_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT - player pl = (player)self; if (selected) { drawsubpic(pos, [170,45], g_hud6_spr, [0,90/256], [170/256,45/256], g_hud_color, a, DRAWFLAG_ADDITIVE); @@ -376,9 +372,8 @@ w_tripmine_hudpic(int selected, vector pos, float a) } int -w_tripmine_isempty(void) +w_tripmine_isempty(player pl) { - player pl = (player)self; if (pl.ammo_tripmine <= 0) return 1; @@ -387,7 +382,7 @@ w_tripmine_isempty(void) } weapontype_t -w_tripmine_type(void) +w_tripmine_type(player pl) { return WPNTYPE_CLOSE; } @@ -405,7 +400,7 @@ weapon_t w_tripmine = .secondary = __NULL__, .reload = __NULL__, .release = w_tripmine_release, - .crosshair = w_tripmine_hud, + .postdraw = w_tripmine_hud, .precache = w_tripmine_precache, .pickup = w_tripmine_pickup, .updateammo = w_tripmine_updateammo,