From 2bb6ca9628053aaf8a5cbd9c09a86962b6488bbc Mon Sep 17 00:00:00 2001 From: Marco Hladik Date: Tue, 15 Mar 2022 19:33:51 -0700 Subject: [PATCH] Rebased against the latest Nuclide commit. --- src/client/entities.qc | 8 ----- src/client/hud.qc | 5 +-- src/shared/input.qc | 10 +++--- src/shared/w_broom.qc | 32 +++++++++---------- src/shared/w_forks.qc | 50 ++++++++++++++---------------- src/shared/w_fryingpan.qc | 36 +++++++++++----------- src/shared/w_glove.qc | 34 ++++++++++----------- src/shared/w_hairspray.qc | 35 ++++++++++----------- src/shared/w_knife.qc | 41 ++++++++++++------------- src/shared/w_lego.qc | 40 +++++++++++------------- src/shared/w_legolauncher.qc | 42 ++++++++++++------------- src/shared/w_machette.qc | 52 +++++++++++++++---------------- src/shared/w_sodalauncher.qc | 59 +++++++++++++++++------------------- 13 files changed, 202 insertions(+), 242 deletions(-) diff --git a/src/client/entities.qc b/src/client/entities.qc index 4adf988..8d3cda0 100644 --- a/src/client/entities.qc +++ b/src/client/entities.qc @@ -24,11 +24,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 62d5f68..a35a6d0 100644 --- a/src/client/hud.qc +++ b/src/client/hud.qc @@ -360,13 +360,14 @@ void HUD_DrawNotify(void) { vector pos; + player pl = (player)pSeat->m_ePlayer; if (pSeatLocal->m_flPickupAlpha <= 0.0f) { return; } pos = g_hudmins + [g_hudres[0] - 192, g_hudres[1] - 128]; - Weapons_HUDPic(pSeatLocal->m_iPickupWeapon, 1, pos, pSeatLocal->m_flPickupAlpha); + Weapons_HUDPic(pl, pSeatLocal->m_iPickupWeapon, 1, pos, pSeatLocal->m_flPickupAlpha); pSeatLocal->m_flPickupAlpha -= clframetime; } @@ -386,7 +387,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(); diff --git a/src/shared/input.qc b/src/shared/input.qc index 091c05a..4c74ca1 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; @@ -56,11 +56,11 @@ Game_Input(void) #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/w_broom.qc b/src/shared/w_broom.qc index 977ff40..a075679 100644 --- a/src/shared/w_broom.qc +++ b/src/shared/w_broom.qc @@ -55,7 +55,7 @@ w_broom_wmodel(void) } string -w_broom_pmodel(void) +w_broom_pmodel(player pl) { return "models/p_broom.mdl"; } @@ -67,30 +67,29 @@ w_broom_deathmsg(void) } void -w_broom_draw(void) +w_broom_draw(player pl) { Weapons_SetModel("models/v_broom.mdl"); - Weapons_ViewAnimation(BROOM_DRAW); + Weapons_ViewAnimation(pl, BROOM_DRAW); } void -w_broom_holster(void) +w_broom_holster(player pl) { - Weapons_ViewAnimation(BROOM_HOLSTER); + Weapons_ViewAnimation(pl, BROOM_HOLSTER); } void -w_broom_primary(void) +w_broom_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 */ @@ -109,13 +108,13 @@ w_broom_primary(void) int r = (float)input_sequence % 3; switch (r) { case 0: - Weapons_ViewAnimation(trace_fraction >= 1 ? BROOM_ATTACK1MISS:BROOM_ATTACK1HIT); + Weapons_ViewAnimation(pl, trace_fraction >= 1 ? BROOM_ATTACK1MISS:BROOM_ATTACK1HIT); break; case 1: - Weapons_ViewAnimation(trace_fraction >= 1 ? BROOM_ATTACK2MISS:BROOM_ATTACK2HIT); + Weapons_ViewAnimation(pl, trace_fraction >= 1 ? BROOM_ATTACK2MISS:BROOM_ATTACK2HIT); break; default: - Weapons_ViewAnimation(trace_fraction >= 1 ? BROOM_ATTACK3MISS:BROOM_ATTACK3HIT); + Weapons_ViewAnimation(pl, trace_fraction >= 1 ? BROOM_ATTACK3MISS:BROOM_ATTACK3HIT); } if (pl.flags & FL_CROUCHING) { @@ -149,27 +148,26 @@ w_broom_primary(void) } void -w_broom_release(void) +w_broom_release(player pl) { - player pl = (player)self; if (pl.w_idle_next) { return; } - Weapons_ViewAnimation(BROOM_IDLE); + Weapons_ViewAnimation(pl, BROOM_IDLE); pl.w_idle_next = 15.0f; } float -w_broom_aimanim(void) +w_broom_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMCROWBAR : ANIM_AIMCROWBAR; } void -w_broom_hudpic(int selected, vector pos, float a) +w_broom_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT if (selected) { @@ -210,7 +208,7 @@ weapon_t w_broom = .secondary = __NULL__, .reload = __NULL__, .release = w_broom_release, - .crosshair = __NULL__, + .postdraw = __NULL__, .precache = w_broom_precache, .pickup = __NULL__, .updateammo = w_broom_updateammo, diff --git a/src/shared/w_forks.qc b/src/shared/w_forks.qc index a435465..46a18b1 100644 --- a/src/shared/w_forks.qc +++ b/src/shared/w_forks.qc @@ -66,7 +66,7 @@ w_forks_wmodel(void) return "models/w_forks.mdl"; } string -w_forks_pmodel(void) +w_forks_pmodel(player pl) { return "models/p_fork.mdl"; } @@ -78,10 +78,9 @@ w_forks_deathmsg(void) } int -w_forks_pickup(int new, int startammo) +w_forks_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (pl.ammo_forks < MAX_A_FORKS) { pl.ammo_forks = bound(0, pl.ammo_forks + 6, MAX_A_FORKS); } else { @@ -91,30 +90,29 @@ w_forks_pickup(int new, int startammo) return (1); } void -w_forks_draw(void) +w_forks_draw(player pl) { Weapons_SetModel("models/v_fork.mdl"); - Weapons_ViewAnimation(FORKS_DRAW); + Weapons_ViewAnimation(pl, FORKS_DRAW); } void -w_forks_holster(void) +w_forks_holster(player pl) { - Weapons_ViewAnimation(FORKS_HOLSTER); + Weapons_ViewAnimation(pl, FORKS_HOLSTER); } void -w_forks_primary(void) +w_forks_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; traceline(src, src + (v_forward * 32), FALSE, pl); @@ -122,7 +120,7 @@ w_forks_primary(void) pl.w_attack_next = 0.4f; pl.w_idle_next = 2.5f; - Weapons_ViewAnimation(FORKS_STAB); + Weapons_ViewAnimation(pl, FORKS_STAB); if (pl.flags & FL_CROUCHING) { Animation_PlayerTop(pl, ANIM_SHOOTCROWBAR, 0.5f); @@ -155,9 +153,8 @@ w_forks_primary(void) } void -w_forks_secondary(void) +w_forks_secondary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; @@ -196,10 +193,10 @@ w_forks_secondary(void) self.movetype = MOVETYPE_NONE; } - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); entity fork = spawn(); setmodel(fork, "models/fork.mdl"); - setorigin(fork, Weapons_GetCameraPos() + (v_forward * 16)); + setorigin(fork, Weapons_GetCameraPos(pl) + (v_forward * 16)); fork.owner = self; fork.velocity = v_forward * 2000; fork.movetype = MOVETYPE_FLY; @@ -213,17 +210,16 @@ w_forks_secondary(void) Sound_Play(pl, CHAN_WEAPON, "weapon_forks.throw"); #endif - Weapons_ViewPunchAngle([-2,0,0]); - Weapons_ViewAnimation(FORKS_THROW); + Weapons_ViewPunchAngle(pl, [-2,0,0]); + Weapons_ViewAnimation(pl, FORKS_THROW); pl.w_attack_next = 0.5f; pl.w_idle_next = 5.0f; } void -w_forks_release(void) +w_forks_release(player pl) { - player pl = (player)self; if (pl.w_idle_next > 0.0) { return; @@ -233,21 +229,21 @@ w_forks_release(void) r = (float)input_sequence % 3; switch (r) { case 1: - Weapons_ViewAnimation(FORKS_IDLE1); + Weapons_ViewAnimation(pl, FORKS_IDLE1); pl.w_idle_next = 1.3f; break; case 2: - Weapons_ViewAnimation(FORKS_IDLE2); + Weapons_ViewAnimation(pl, FORKS_IDLE2); pl.w_idle_next = 3.0f; break; default: - Weapons_ViewAnimation(FORKS_IDLE3); + Weapons_ViewAnimation(pl, FORKS_IDLE3); pl.w_idle_next = 1.285f; } } void -w_forks_crosshair(void) +w_forks_crosshair(player pl) { #ifdef CLIENT static vector cross_pos; @@ -278,13 +274,13 @@ w_forks_crosshair(void) } float -w_forks_aimanim(void) +w_forks_aimanim(player pl) { - return w_broom_aimanim(); + return w_broom_aimanim(pl); } void -w_forks_hudpic(int selected, vector pos, float a) +w_forks_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT if (selected) { @@ -325,7 +321,7 @@ weapon_t w_forks = .secondary = w_forks_secondary, .reload = __NULL__, .release = w_forks_release, - .crosshair = w_forks_crosshair, + .postdraw = w_forks_crosshair, .precache = w_forks_precache, .pickup = w_forks_pickup, .updateammo = w_forks_updateammo, diff --git a/src/shared/w_fryingpan.qc b/src/shared/w_fryingpan.qc index 5e7d693..ea2be94 100644 --- a/src/shared/w_fryingpan.qc +++ b/src/shared/w_fryingpan.qc @@ -51,7 +51,7 @@ w_fryingpan_wmodel(void) return "models/w_pan.mdl"; } string -w_fryingpan_pmodel(void) +w_fryingpan_pmodel(player pl) { return "models/p_pan.mdl"; } @@ -63,30 +63,29 @@ w_fryingpan_deathmsg(void) } void -w_fryingpan_draw(void) +w_fryingpan_draw(player pl) { Weapons_SetModel("models/v_pan.mdl"); - Weapons_ViewAnimation(FRYINGPAN_DRAW); + Weapons_ViewAnimation(pl, FRYINGPAN_DRAW); } void -w_fryingpan_holster(void) +w_fryingpan_holster(player pl) { - w_broom_holster(); + w_broom_holster(pl); } void -w_fryingpan_primary(void) +w_fryingpan_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; traceline(src, src + (v_forward * 32), FALSE, pl); @@ -94,7 +93,7 @@ w_fryingpan_primary(void) pl.w_attack_next = 1.0f; pl.w_idle_next = 2.5f; - Weapons_ViewAnimation(FRYINGPAN_HIT1); + Weapons_ViewAnimation(pl, FRYINGPAN_HIT1); if (pl.flags & FL_CROUCHING) { Animation_PlayerTop(pl, ANIM_SHOOTCROWBAR, 0.5f); @@ -129,17 +128,16 @@ w_fryingpan_primary(void) } void -w_fryingpan_secondary(void) +w_fryingpan_secondary(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; traceline(src, src + (v_forward * 32), FALSE, pl); @@ -147,7 +145,7 @@ w_fryingpan_secondary(void) pl.w_attack_next = 1.0f; pl.w_idle_next = 2.5f; - Weapons_ViewAnimation(FRYINGPAN_HIT2); + Weapons_ViewAnimation(pl, FRYINGPAN_HIT2); if (pl.flags & FL_CROUCHING) { Animation_PlayerTop(pl, ANIM_SHOOTCROWBAR, 0.5f); @@ -181,19 +179,19 @@ w_fryingpan_secondary(void) } void -w_fryingpan_release(void) +w_fryingpan_release(player pl) { - w_broom_release(); + w_broom_release(pl); } float -w_fryingpan_aimanim(void) +w_fryingpan_aimanim(player pl) { - return w_broom_aimanim(); + return w_broom_aimanim(pl); } void -w_fryingpan_hudpic(int selected, vector pos, float a) +w_fryingpan_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT if (selected) { @@ -234,7 +232,7 @@ weapon_t w_fryingpan = .secondary = w_fryingpan_secondary, .reload = __NULL__, .release = w_fryingpan_release, - .crosshair = __NULL__, + .postdraw = __NULL__, .precache = w_fryingpan_precache, .pickup = __NULL__, .updateammo = w_fryingpan_updateammo, diff --git a/src/shared/w_glove.qc b/src/shared/w_glove.qc index 5f46459..bd4875d 100644 --- a/src/shared/w_glove.qc +++ b/src/shared/w_glove.qc @@ -62,7 +62,7 @@ w_glove_wmodel(void) return "models/rune_slasher.mdl"; } string -w_glove_pmodel(void) +w_glove_pmodel(player pl) { return "models/p_glove.mdl"; } @@ -74,7 +74,7 @@ w_glove_deathmsg(void) } int -w_glove_pickup(int new, int startammo) +w_glove_pickup(player pl, int new, int startammo) { #ifdef SERVER /* Broadcast a message and sound upon picking up Rune */ @@ -105,32 +105,31 @@ w_glove_pickup(int new, int startammo) } void -w_glove_draw(void) +w_glove_draw(player pl) { Weapons_SetModel("models/v_glove.mdl"); - Weapons_ViewAnimation(GLOVE_DRAW); + Weapons_ViewAnimation(pl, GLOVE_DRAW); } void -w_glove_holster(void) +w_glove_holster(player pl) { - Weapons_ViewAnimation(GLOVE_HOLSTER); + Weapons_ViewAnimation(pl, GLOVE_HOLSTER); } void -w_glove_primary(void) +w_glove_primary(player pl) { int anim = 0; int r = 0; vector src; - player pl = (player)self; if (pl.w_attack_next) { return; } - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); src = pl.origin + pl.view_ofs; traceline(src, src + (v_forward * 32), FALSE, pl); @@ -144,11 +143,11 @@ w_glove_primary(void) r = (float)input_sequence % 2; switch (r) { case 1: - Weapons_ViewAnimation(GLOVE_SLICE); + Weapons_ViewAnimation(pl, GLOVE_SLICE); pl.w_idle_next = 3.6f; break; default: - Weapons_ViewAnimation(GLOVE_DICE); + Weapons_ViewAnimation(pl, GLOVE_DICE); pl.w_idle_next = 3.6f; break; } @@ -189,26 +188,25 @@ w_glove_primary(void) } void -w_glove_release(void) +w_glove_release(player pl) { - player pl = (player)self; if (pl.w_idle_next) { return; } - Weapons_ViewAnimation(GLOVE_IDLE); + Weapons_ViewAnimation(pl, GLOVE_IDLE); pl.w_idle_next = 2.0f; } float -w_glove_aimanim(void) +w_glove_aimanim(player pl) { - return w_broom_aimanim(); + return w_broom_aimanim(pl); } void -w_glove_hudpic(int selected, vector pos, float a) +w_glove_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT if (selected) { @@ -249,7 +247,7 @@ weapon_t w_glove = .secondary = __NULL__, .reload = __NULL__, .release = w_glove_release, - .crosshair = __NULL__, + .postdraw = __NULL__, .precache = w_glove_precache, .pickup = w_glove_pickup, .updateammo = w_glove_updateammo, diff --git a/src/shared/w_hairspray.qc b/src/shared/w_hairspray.qc index 637ef28..68c1445 100644 --- a/src/shared/w_hairspray.qc +++ b/src/shared/w_hairspray.qc @@ -59,7 +59,7 @@ w_hairspray_wmodel(void) } string -w_hairspray_pmodel(void) +w_hairspray_pmodel(player pl) { return "models/p_hairspray.mdl"; } @@ -71,10 +71,9 @@ w_hairspray_deathmsg(void) } int -w_hairspray_pickup(int new, int startammo) +w_hairspray_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (pl.ammo_spray < MAX_A_SPRAY) { pl.ammo_spray = bound(0, pl.ammo_spray + 20, MAX_A_SPRAY); } else { @@ -85,16 +84,16 @@ w_hairspray_pickup(int new, int startammo) } void -w_hairspray_draw(void) +w_hairspray_draw(player pl) { Weapons_SetModel("models/v_hairspray.mdl"); - Weapons_ViewAnimation(HAIRSPRAY_DRAW); + Weapons_ViewAnimation(pl, HAIRSPRAY_DRAW); } void -w_hairspray_holster(void) +w_hairspray_holster(player pl) { - Weapons_ViewAnimation(HAIRSPRAY_HOLSTER); + Weapons_ViewAnimation(pl, HAIRSPRAY_HOLSTER); } @@ -115,9 +114,8 @@ Flame_Touch(void) void -w_hairspray_primary(void) +w_hairspray_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; } @@ -135,13 +133,13 @@ w_hairspray_primary(void) /* Actual firing */ #ifdef CLIENT - Weapons_ViewAnimation(HAIRSPRAY_FIRE); + Weapons_ViewAnimation(pl, HAIRSPRAY_FIRE); pl.ammo_spray--; #else - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); entity flame = spawn(); setmodel(flame, "sprites/flame.spr"); - setorigin(flame, Weapons_GetCameraPos() + (v_forward * 16)); + setorigin(flame, Weapons_GetCameraPos(pl) + (v_forward * 16)); flame.owner = self; flame.velocity = v_forward * 300; flame.movetype = MOVETYPE_FLYMISSILE; @@ -170,20 +168,19 @@ w_hairspray_primary(void) } void -w_hairspray_release(void) +w_hairspray_release(player pl) { - player pl = (player)self; if (pl.w_idle_next) { return; } sound(pl, CHAN_WEAPON, "", 1.0, ATTN_NORM); - Weapons_ViewAnimation(HAIRSPRAY_IDLE); + Weapons_ViewAnimation(pl, HAIRSPRAY_IDLE); pl.w_idle_next = 2.0f; } void -w_hairspray_crosshair(void) +w_hairspray_crosshair(player pl) { #ifdef CLIENT static vector cross_pos; @@ -214,13 +211,13 @@ w_hairspray_crosshair(void) } float -w_hairspray_aimanim(void) +w_hairspray_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMBOW : ANIM_AIMBOW; } void -w_hairspray_hudpic(int selected, vector pos, float a) +w_hairspray_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT if (selected) { @@ -261,7 +258,7 @@ weapon_t w_hairspray = .secondary = __NULL__, .reload = __NULL__, .release = w_hairspray_release, - .crosshair = w_hairspray_crosshair, + .postdraw = w_hairspray_crosshair, .precache = w_hairspray_precache, .pickup = w_hairspray_pickup, .updateammo = w_hairspray_updateammo, diff --git a/src/shared/w_knife.qc b/src/shared/w_knife.qc index 5efba16..07cd42f 100644 --- a/src/shared/w_knife.qc +++ b/src/shared/w_knife.qc @@ -63,7 +63,7 @@ w_knife_wmodel(void) } string -w_knife_pmodel(void) +w_knife_pmodel(player pl) { return "models/p_knife.mdl"; } @@ -75,10 +75,9 @@ w_knife_deathmsg(void) } int -w_knife_pickup(int new, int startammo) +w_knife_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (pl.ammo_knives < MAX_A_KNIVES) { pl.ammo_knives = bound(0, pl.ammo_knives + 1, MAX_A_KNIVES); @@ -90,22 +89,21 @@ w_knife_pickup(int new, int startammo) } void -w_knife_draw(void) +w_knife_draw(player pl) { Weapons_SetModel("models/v_knife.mdl"); - Weapons_ViewAnimation(KNIFE_DRAW); + Weapons_ViewAnimation(pl, KNIFE_DRAW); } void -w_knife_holster(void) +w_knife_holster(player pl) { - Weapons_ViewAnimation(KNIFE_HOLSTER); + Weapons_ViewAnimation(pl, KNIFE_HOLSTER); } void -w_knife_primary(void) +w_knife_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; @@ -145,10 +143,10 @@ w_knife_primary(void) self.movetype = MOVETYPE_NONE; } - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); entity knife = spawn(); setmodel(knife, "models/w_knife.mdl"); - setorigin(knife, Weapons_GetCameraPos()); + setorigin(knife, Weapons_GetCameraPos(pl)); knife.owner = self; knife.velocity = v_forward * 1200; knife.movetype = MOVETYPE_FLY; @@ -173,8 +171,8 @@ w_knife_primary(void) return; } #else - Weapons_ViewPunchAngle([-2,0,0]); - Weapons_ViewAnimation(KNIFE_THROW); + Weapons_ViewPunchAngle(pl, [-2,0,0]); + Weapons_ViewAnimation(pl, KNIFE_THROW); /* Knife randomly changes submodel upon firing */ int r = (float)input_sequence % 2; Weapons_SetGeomset(r == 1 ? "geomset 0 0\n" : "geomset 0 1\n"); @@ -185,9 +183,8 @@ w_knife_primary(void) } void -w_knife_release(void) +w_knife_release(player pl) { - player pl = (player)self; if (pl.w_idle_next > 0.0) { return; @@ -197,21 +194,21 @@ w_knife_release(void) r = (float)input_sequence % 3; switch (r) { case 1: - Weapons_ViewAnimation(KNIFE_IDLE1); + Weapons_ViewAnimation(pl, KNIFE_IDLE1); pl.w_idle_next = 2.0f; break; case 2: - Weapons_ViewAnimation(KNIFE_IDLE2); + Weapons_ViewAnimation(pl, KNIFE_IDLE2); pl.w_idle_next = 3.0f; break; default: - Weapons_ViewAnimation(KNIFE_IDLE3); + Weapons_ViewAnimation(pl, KNIFE_IDLE3); pl.w_idle_next = 1.285f; } } void -w_knife_crosshair(void) +w_knife_crosshair(player pl) { #ifdef CLIENT static vector cross_pos; @@ -242,13 +239,13 @@ w_knife_crosshair(void) } float -w_knife_aimanim(void) +w_knife_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMBOW : ANIM_AIMBOW; } void -w_knife_hudpic(int selected, vector pos, float a) +w_knife_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT if (selected) { @@ -289,7 +286,7 @@ weapon_t w_knife = .secondary = __NULL__, .reload = __NULL__, .release = w_knife_release, - .crosshair = w_knife_crosshair, + .postdraw = w_knife_crosshair, .precache = w_knife_precache, .pickup = w_knife_pickup, .updateammo = w_knife_updateammo, diff --git a/src/shared/w_lego.qc b/src/shared/w_lego.qc index 4399f27..7825638 100644 --- a/src/shared/w_lego.qc +++ b/src/shared/w_lego.qc @@ -58,7 +58,7 @@ w_lego_wmodel(void) } string -w_lego_pmodel(void) +w_lego_pmodel(player pl) { return "models/p_lego.mdl"; } @@ -70,10 +70,9 @@ w_lego_deathmsg(void) } int -w_lego_pickup(int new, int startammo) +w_lego_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (pl.ammo_legogrenade < MAX_A_LEGOGRENADE) { pl.ammo_legogrenade = bound(0, pl.ammo_legogrenade + 1, MAX_A_LEGOGRENADE); @@ -86,7 +85,7 @@ w_lego_pickup(int new, int startammo) #ifdef SERVER void -w_lego_throw(void) +w_lego_throw(player pl) { static void WeaponLego_Throw_Touch(void) { float dmg = Skill_GetValue("plr_hand_grenade", 150); @@ -95,7 +94,6 @@ w_lego_throw(void) remove(self); } - player pl = (player)self; vector vPLAngle = pl.v_angle; if (vPLAngle[0] < 0) { vPLAngle[0] = -10 + vPLAngle[0] * ((90 - 10) / 90.0); @@ -128,24 +126,23 @@ w_lego_throw(void) #endif void -w_lego_draw(void) +w_lego_draw(player pl) { #ifdef CLIENT Weapons_SetModel("models/v_lego.mdl"); - Weapons_ViewAnimation(LEGO_DRAW); + Weapons_ViewAnimation(pl, LEGO_DRAW); #endif } void -w_lego_holster(void) +w_lego_holster(player pl) { } void -w_lego_primary(void) +w_lego_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; } @@ -167,7 +164,7 @@ w_lego_primary(void) #endif #ifdef CLIENT - Weapons_ViewAnimation(LEGO_PULLPIN); + Weapons_ViewAnimation(pl, LEGO_PULLPIN); #endif pl.a_ammo3 = 1; @@ -176,7 +173,7 @@ w_lego_primary(void) } void -w_lego_hud(void) +w_lego_hud(player pl) { #ifdef CLIENT static vector cross_pos; @@ -207,9 +204,8 @@ w_lego_hud(void) } void -w_lego_release(void) +w_lego_release(player pl) { - player pl = (player)self; if (pl.w_idle_next > 0.0) { return; @@ -218,17 +214,17 @@ w_lego_release(void) if (pl.a_ammo3 == 1) { #ifdef CLIENT pl.ammo_legogrenade--; - Weapons_ViewAnimation(LEGO_THROW); + Weapons_ViewAnimation(pl, LEGO_THROW); #else pl.ammo_legogrenade--; - w_lego_throw(); + w_lego_throw(pl); #endif pl.a_ammo3 = 2; pl.w_attack_next = 1.0f; pl.w_idle_next = 0.5f; } else if (pl.a_ammo3 == 2) { #ifdef CLIENT - Weapons_ViewAnimation(LEGO_DRAW); + Weapons_ViewAnimation(pl, LEGO_DRAW); #else if (!pl.ammo_legogrenade) { Weapons_RemoveItem(pl, WEAPON_LEGO); @@ -238,19 +234,19 @@ w_lego_release(void) pl.w_idle_next = 0.5f; pl.a_ammo3 = 0; } else { - Weapons_ViewAnimation(LEGO_IDLE); + Weapons_ViewAnimation(pl, LEGO_IDLE); pl.w_idle_next = 3.0f; } } float -w_lego_aimanim(void) +w_lego_aimanim(player pl) { - return self.flags & FL_CROUCHING ? ANIM_CR_AIMCROWBAR : ANIM_AIMCROWBAR; + return pl.flags & FL_CROUCHING ? ANIM_CR_AIMCROWBAR : ANIM_AIMCROWBAR; } void -w_lego_hudpic(int selected, vector pos, float a) +w_lego_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT if (selected) { @@ -273,7 +269,7 @@ weapon_t w_lego = .secondary = __NULL__, .reload = __NULL__, .release = w_lego_release, - .crosshair = w_lego_hud, + .postdraw = w_lego_hud, .precache = w_lego_precache, .pickup = w_lego_pickup, .updateammo = w_lego_updateammo, diff --git a/src/shared/w_legolauncher.qc b/src/shared/w_legolauncher.qc index 50e21f8..a03b4bd 100644 --- a/src/shared/w_legolauncher.qc +++ b/src/shared/w_legolauncher.qc @@ -59,7 +59,7 @@ w_legolauncher_wmodel(void) } string -w_legolauncher_pmodel(void) +w_legolauncher_pmodel(player pl) { return "models/p_legolauncher.mdl"; } @@ -71,10 +71,9 @@ w_legolauncher_deathmsg(void) } int -w_legolauncher_pickup(int new, int startammo) +w_legolauncher_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (pl.ammo_legos < MAX_A_LEGOS) { pl.ammo_legos = bound(0, pl.ammo_legos + 40, MAX_A_LEGOS); @@ -86,23 +85,22 @@ w_legolauncher_pickup(int new, int startammo) } void -w_legolauncher_draw(void) +w_legolauncher_draw(player pl) { Weapons_SetModel("models/v_legolauncher.mdl"); - Weapons_ViewAnimation(LEGOLAUNCHER_DRAW); + Weapons_ViewAnimation(pl, LEGOLAUNCHER_DRAW); } void -w_legolauncher_holster(void) +w_legolauncher_holster(player pl) { - Weapons_ViewAnimation(LEGOLAUNCHER_HOLSTER); + Weapons_ViewAnimation(pl, LEGOLAUNCHER_HOLSTER); } #ifdef SERVER void -w_legolauncher_shootlego(void) +w_legolauncher_shootlego(player pl) { - player pl = (player)self; static void Lego_Touch(void) { FX_LegoPiece(trace_endpos); @@ -122,11 +120,11 @@ w_legolauncher_shootlego(void) remove(self); } - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); entity lego = spawn(); setmodel(lego, "models/lego.mdl"); /* TODO needs to spawn more to the right */ - setorigin(lego, Weapons_GetCameraPos() + (v_forward * 16) + (v_right * 4) + (v_up * -8)); + setorigin(lego, Weapons_GetCameraPos(pl) + (v_forward * 16) + (v_right * 4) + (v_up * -8)); lego.owner = self; lego.velocity = v_forward * 2000; lego.movetype = MOVETYPE_FLY; @@ -139,9 +137,8 @@ w_legolauncher_shootlego(void) #endif void -w_legolauncher_primary(void) +w_legolauncher_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; @@ -160,12 +157,12 @@ w_legolauncher_primary(void) /* Actual firing */ #ifdef SERVER - w_legolauncher_shootlego(); + w_legolauncher_shootlego(pl); pl.ammo_legos--; Sound_Play(pl, CHAN_WEAPON, "weapon_legolauncher.fire"); #else - Weapons_ViewPunchAngle([-2,0,0]); - Weapons_ViewAnimation(LEGOLAUNCHER_SHOOT); + Weapons_ViewPunchAngle(pl, [-2,0,0]); + Weapons_ViewAnimation(pl, LEGOLAUNCHER_SHOOT); #endif if (self.flags & FL_CROUCHING) @@ -178,21 +175,20 @@ w_legolauncher_primary(void) } void -w_legolauncher_release(void) +w_legolauncher_release(player pl) { - player pl = (player)self; if (pl.w_idle_next > 0.0) { return; } - Weapons_ViewAnimation(LEGOLAUNCHER_IDLE); + Weapons_ViewAnimation(pl, LEGOLAUNCHER_IDLE); pl.w_idle_next = 3.0f; } void -w_legolauncher_crosshair(void) +w_legolauncher_crosshair(player pl) { #ifdef CLIENT vector aicon_pos; @@ -227,13 +223,13 @@ w_legolauncher_crosshair(void) } float -w_legolauncher_aimanim(void) +w_legolauncher_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMBOW : ANIM_AIMBOW; } void -w_legolauncher_hudpic(int selected, vector pos, float a) +w_legolauncher_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT if (selected) { @@ -274,7 +270,7 @@ weapon_t w_legolauncher = .secondary = __NULL__, .reload = __NULL__, .release = w_legolauncher_release, - .crosshair = w_legolauncher_crosshair, + .postdraw = w_legolauncher_crosshair, .precache = w_legolauncher_precache, .pickup = w_legolauncher_pickup, .updateammo = w_legolauncher_updateammo, diff --git a/src/shared/w_machette.qc b/src/shared/w_machette.qc index f9e5d47..a7108c3 100644 --- a/src/shared/w_machette.qc +++ b/src/shared/w_machette.qc @@ -52,7 +52,7 @@ w_machette_wmodel(void) return "models/w_machette.mdl"; } string -w_machette_pmodel(void) +w_machette_pmodel(player pl) { return "models/p_machette.mdl"; } @@ -64,7 +64,7 @@ w_machette_deathmsg(void) } int -w_machette_pickup(int new, int startammo) +w_machette_pickup(player pl, int new, int startammo) { #ifdef SERVER /* Broadcast a message and sound upon picking up Rune */ @@ -75,30 +75,29 @@ w_machette_pickup(int new, int startammo) } void -w_machette_draw(void) +w_machette_draw(player pl) { Weapons_SetModel("models/v_machette.mdl"); - Weapons_ViewAnimation(MACHETTE_DRAW); + Weapons_ViewAnimation(pl, MACHETTE_DRAW); } void -w_machette_holster(void) +w_machette_holster(player pl) { - Weapons_ViewAnimation(MACHETTE_HOLSTER); + Weapons_ViewAnimation(pl, MACHETTE_HOLSTER); } void -w_machette_primary(void) +w_machette_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; traceline(src, src + (v_forward * 32), FALSE, pl); @@ -106,7 +105,7 @@ w_machette_primary(void) pl.w_attack_next = 0.4f; pl.w_idle_next = 2.5f; - Weapons_ViewAnimation(MACHETTE_THROW); + Weapons_ViewAnimation(pl, MACHETTE_THROW); if (pl.flags & FL_CROUCHING) { Animation_PlayerTop(pl, ANIM_SHOOTCROWBAR, 0.5f); @@ -140,9 +139,8 @@ w_machette_primary(void) #ifdef SERVER void -w_machette_throw(void) +w_machette_throw(player pl) { - player pl = (player)self; static void Machette_Touch(void) { setmodel(self, "models/machette.mdl"); @@ -163,10 +161,10 @@ w_machette_throw(void) self.movetype = MOVETYPE_NONE; } - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); entity machette = spawn(); setmodel(machette, "models/machette.mdl"); - setorigin(machette, Weapons_GetCameraPos() + (v_forward * 16)); + setorigin(machette, Weapons_GetCameraPos(pl) + (v_forward * 16)); machette.owner = self; machette.velocity = v_forward * 2000; machette.movetype = MOVETYPE_FLY; @@ -179,9 +177,8 @@ w_machette_throw(void) #endif void -w_machette_secondary(void) +w_machette_secondary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; @@ -189,11 +186,11 @@ w_machette_secondary(void) /* Actual firing */ #ifdef SERVER - w_machette_throw(); + w_machette_throw(pl); Sound_Play(pl, CHAN_WEAPON, "weapon_machette.throw"); #else - Weapons_ViewPunchAngle([-2,0,0]); - Weapons_ViewAnimation(MACHETTE_THROW); + Weapons_ViewPunchAngle(pl, [-2,0,0]); + Weapons_ViewAnimation(pl, MACHETTE_THROW); #endif if (self.flags & FL_CROUCHING) @@ -206,9 +203,8 @@ w_machette_secondary(void) } void -w_machette_release(void) +w_machette_release(player pl) { - player pl = (player)self; if (pl.w_idle_next > 0.0) { return; @@ -218,27 +214,27 @@ w_machette_release(void) r = (float)input_sequence % 3; switch (r) { case 1: - Weapons_ViewAnimation(MACHETTE_IDLE1); + Weapons_ViewAnimation(pl, MACHETTE_IDLE1); pl.w_idle_next = 1.3f; break; case 2: - Weapons_ViewAnimation(MACHETTE_IDLE2); + Weapons_ViewAnimation(pl, MACHETTE_IDLE2); pl.w_idle_next = 3.0f; break; default: - Weapons_ViewAnimation(MACHETTE_IDLE3); + Weapons_ViewAnimation(pl, MACHETTE_IDLE3); pl.w_idle_next = 1.285f; } } float -w_machette_aimanim(void) +w_machette_aimanim(player pl) { - return w_broom_aimanim(); + return w_broom_aimanim(pl); } void -w_machette_hudpic(int selected, vector pos, float a) +w_machette_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT if (selected) { @@ -279,7 +275,7 @@ weapon_t w_machette = .secondary = w_machette_secondary, .reload = __NULL__, .release = w_machette_release, - .crosshair = __NULL__, + .postdraw = __NULL__, .precache = w_machette_precache, .pickup = w_machette_pickup, .updateammo = w_machette_updateammo, diff --git a/src/shared/w_sodalauncher.qc b/src/shared/w_sodalauncher.qc index 296b4cc..7540946 100644 --- a/src/shared/w_sodalauncher.qc +++ b/src/shared/w_sodalauncher.qc @@ -54,10 +54,9 @@ w_sodalauncher_precache(void) } int -w_sodalauncher_pickup(int new, int startammo) +w_sodalauncher_pickup(player pl, int new, int startammo) { #ifdef SERVER - player pl = (player)self; if (pl.ammo_soda < MAX_A_SODA) { pl.ammo_soda = bound(0, pl.ammo_soda + 3, MAX_A_SODA); } else { @@ -80,7 +79,7 @@ w_sodalauncher_wmodel(void) } string -w_sodalauncher_pmodel(void) +w_sodalauncher_pmodel(player pl) { return "models/p_soda.mdl"; } @@ -92,11 +91,11 @@ w_sodalauncher_deathmsg(void) } void -w_sodalauncher_draw(void) +w_sodalauncher_draw(player pl) { #ifdef CLIENT Weapons_SetModel("models/v_soda.mdl"); - Weapons_ViewAnimation(SODA_DRAW); + Weapons_ViewAnimation(pl, SODA_DRAW); /* needs the skin value to be set, no API yet * the soda cans in the viewmodel sync up with * the projectile and spill decals */ @@ -104,18 +103,17 @@ w_sodalauncher_draw(void) } void -w_sodalauncher_holster(void) +w_sodalauncher_holster(player pl) { - Weapons_ViewAnimation(SODA_HOLSTER); + Weapons_ViewAnimation(pl, SODA_HOLSTER); } /* TODO now just need parameters */ #ifdef SERVER void -w_sodalauncher_shoot(void) +w_sodalauncher_shoot(player pl) { - player pl = (player)self; /* Apply force */ if (pl.flags & FL_ONGROUND) { @@ -132,10 +130,10 @@ w_sodalauncher_shoot(void) remove(self); } - Weapons_MakeVectors(); + Weapons_MakeVectors(pl); entity soda = spawn(); setmodel(soda, "models/sodacan.mdl"); - setorigin(soda, Weapons_GetCameraPos() + (v_forward * 16)); + setorigin(soda, Weapons_GetCameraPos(pl) + (v_forward * 16)); soda.skin = floor(random(0,6)); soda.owner = self; soda.velocity = v_forward * 800; @@ -155,9 +153,9 @@ w_sodalauncher_shoot(void) * Sprite code in Nuclide is still WIP * so this is client-only for now */ void -w_sodalauncher_exhaust(void) { +w_sodalauncher_exhaust(player pl) { env_sprite eExhaust = spawn(env_sprite); - setorigin(eExhaust, Weapons_GetCameraPos() + (v_forward * 16)); + setorigin(eExhaust, Weapons_GetCameraPos(pl) + (v_forward * 16)); setmodel(eExhaust, "sprites/co2_puff.spr"); eExhaust.effects = EF_ADDITIVE; @@ -172,9 +170,8 @@ w_sodalauncher_exhaust(void) { #endif void -w_sodalauncher_primary(void) +w_sodalauncher_primary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; @@ -194,11 +191,11 @@ w_sodalauncher_primary(void) /* Actual firing * TODO make this one fast straight */ #ifdef CLIENT - Weapons_ViewPunchAngle([-10,0,0]); - Weapons_ViewAnimation(SODA_SHOOT_RELOAD); - w_sodalauncher_exhaust(); + Weapons_ViewPunchAngle(pl, [-10,0,0]); + Weapons_ViewAnimation(pl, SODA_SHOOT_RELOAD); + w_sodalauncher_exhaust(pl); #else - w_sodalauncher_shoot(); + w_sodalauncher_shoot(pl); pl.ammo_soda--; Sound_Play(pl, CHAN_WEAPON, "weapon_sodalauncher.fire"); #endif @@ -208,9 +205,8 @@ w_sodalauncher_primary(void) } /* TODO Actual secondary fire is the current primary fire code, just WIP */ void -w_sodalauncher_secondary(void) +w_sodalauncher_secondary(player pl) { - player pl = (player)self; if (pl.w_attack_next > 0.0) { return; @@ -229,11 +225,11 @@ w_sodalauncher_secondary(void) /* TODO make this one sag and slower */ #ifdef CLIENT - Weapons_ViewPunchAngle([-10,0,0]); - Weapons_ViewAnimation(SODA_SHOOT_RELOAD); - w_sodalauncher_exhaust(); + Weapons_ViewPunchAngle(pl, [-10,0,0]); + Weapons_ViewAnimation(pl, SODA_SHOOT_RELOAD); + w_sodalauncher_exhaust(pl); #else - w_sodalauncher_shoot(); + w_sodalauncher_shoot(pl); pl.ammo_soda--; Sound_Play(pl, CHAN_WEAPON, "weapon_sodalauncher.fire"); #endif @@ -243,20 +239,19 @@ w_sodalauncher_secondary(void) } void -w_sodalauncher_release(void) +w_sodalauncher_release(player pl) { - player pl = (player)self; if (pl.w_idle_next) { return; } - Weapons_ViewAnimation(SODA_IDLE); + Weapons_ViewAnimation(pl, SODA_IDLE); pl.w_idle_next = 3.0f; } void -w_sodalauncher_crosshair(void) +w_sodalauncher_crosshair(player pl) { #ifdef CLIENT static vector cross_pos; @@ -287,13 +282,13 @@ w_sodalauncher_crosshair(void) } float -w_sodalauncher_aimanim(void) +w_sodalauncher_aimanim(player pl) { return self.flags & FL_CROUCHING ? ANIM_CR_AIMBOW : ANIM_AIMBOW; } void -w_sodalauncher_hudpic(int selected, vector pos, float a) +w_sodalauncher_hudpic(player pl, int selected, vector pos, float a) { #ifdef CLIENT if (selected) { @@ -333,7 +328,7 @@ weapon_t w_sodalauncher = { .secondary = w_sodalauncher_secondary, .reload = __NULL__, .release = w_sodalauncher_release, - .crosshair = w_sodalauncher_crosshair, + .postdraw = w_sodalauncher_crosshair, .precache = w_sodalauncher_precache, .pickup = w_sodalauncher_pickup, .updateammo = w_sodalauncher_updateammo,