From f128a72f566a5e3756059ad29b5a07048334bdd1 Mon Sep 17 00:00:00 2001 From: Samual Date: Sun, 6 Mar 2011 19:58:13 -0500 Subject: [PATCH] Lets make the shotorigin work for lightning with everyone involved + some other things. --- qcsrc/client/Defs.qc | 1 + qcsrc/client/Main.qc | 7 +++++- qcsrc/client/hook.qc | 35 ++++++++++++++++++++------- qcsrc/common/constants.qh | 7 +++--- qcsrc/server/cl_client.qc | 4 ++++ qcsrc/server/g_world.qc | 1 + qcsrc/server/progs.src | 1 + qcsrc/server/w_electro.qc | 2 +- qcsrc/server/w_lightning.qc | 48 +++++++++++++++---------------------- qcsrc/server/w_lightning.qh | 2 ++ 10 files changed, 66 insertions(+), 42 deletions(-) create mode 100644 qcsrc/server/w_lightning.qh diff --git a/qcsrc/client/Defs.qc b/qcsrc/client/Defs.qc index 62acc6249..ab86f6981 100644 --- a/qcsrc/client/Defs.qc +++ b/qcsrc/client/Defs.qc @@ -233,6 +233,7 @@ float announcer_5min; float tempdb; float ClientProgsDB; vector hook_shotorigin[4]; +vector electro_shotorigin[4]; vector lightning_shotorigin[4]; vector gauntlet_shotorigin[4]; diff --git a/qcsrc/client/Main.qc b/qcsrc/client/Main.qc index 1424a8c27..f3ae91ca0 100644 --- a/qcsrc/client/Main.qc +++ b/qcsrc/client/Main.qc @@ -961,7 +961,8 @@ void(float bIsNewEntity) CSQC_Ent_Update = case ENT_CLIENT_WARPZONE_CAMERA: WarpZone_Camera_Read(bIsNewEntity); break; case ENT_CLIENT_TRIGGER_MUSIC: Ent_ReadTriggerMusic(); break; case ENT_CLIENT_HOOK: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_HOOK); break; - case ENT_CLIENT_LGBEAM: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_LGBEAM); break; + case ENT_CLIENT_ELECTRO_BEAM: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_ELECTRO_BEAM); break; + case ENT_CLIENT_LIGHTNING_BEAM: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_LIGHTNING_BEAM); break; case ENT_CLIENT_GAUNTLET: Ent_ReadHook(bIsNewEntity, ENT_CLIENT_GAUNTLET); break; case ENT_CLIENT_ACCURACY: Ent_ReadAccuracy(); break; default: @@ -1067,6 +1068,10 @@ void Ent_Init() hook_shotorigin[1] = decompressShotOrigin(ReadInt24_t()); hook_shotorigin[2] = decompressShotOrigin(ReadInt24_t()); hook_shotorigin[3] = decompressShotOrigin(ReadInt24_t()); + electro_shotorigin[0] = decompressShotOrigin(ReadInt24_t()); + electro_shotorigin[1] = decompressShotOrigin(ReadInt24_t()); + electro_shotorigin[2] = decompressShotOrigin(ReadInt24_t()); + electro_shotorigin[3] = decompressShotOrigin(ReadInt24_t()); lightning_shotorigin[0] = decompressShotOrigin(ReadInt24_t()); lightning_shotorigin[1] = decompressShotOrigin(ReadInt24_t()); lightning_shotorigin[2] = decompressShotOrigin(ReadInt24_t()); diff --git a/qcsrc/client/hook.qc b/qcsrc/client/hook.qc index 91f62154e..dc0780e04 100644 --- a/qcsrc/client/hook.qc +++ b/qcsrc/client/hook.qc @@ -75,7 +75,10 @@ void Draw_GrapplingHook() case ENT_CLIENT_HOOK: vs = hook_shotorigin[s]; break; - case ENT_CLIENT_LGBEAM: + case ENT_CLIENT_ELECTRO_BEAM: + vs = electro_shotorigin[s]; + break; + case ENT_CLIENT_LIGHTNING_BEAM: vs = lightning_shotorigin[s]; break; case ENT_CLIENT_GAUNTLET: @@ -92,7 +95,8 @@ void Draw_GrapplingHook() a = view_origin + view_forward * vs_x + view_right * -vs_y + view_up * vs_z; b = self.origin; break; - case ENT_CLIENT_LGBEAM: + case ENT_CLIENT_ELECTRO_BEAM: + case ENT_CLIENT_LIGHTNING_BEAM: case ENT_CLIENT_GAUNTLET: if(self.HookRange) b = view_origin + view_forward * self.HookRange; @@ -113,7 +117,8 @@ void Draw_GrapplingHook() a = self.velocity; b = self.origin; break; - case ENT_CLIENT_LGBEAM: + case ENT_CLIENT_ELECTRO_BEAM: + case ENT_CLIENT_LIGHTNING_BEAM: case ENT_CLIENT_GAUNTLET: a = self.origin; b = self.velocity; @@ -155,7 +160,13 @@ void Draw_GrapplingHook() rgb = '.3 1 .3'; } break; - case ENT_CLIENT_LGBEAM: + case ENT_CLIENT_ELECTRO_BEAM: + intensity = bound(0.2, 1 + Noise_Pink(self, frametime) * 1 + Noise_Burst(self, frametime, 0.03) * 0.3, 2); + offset = Noise_Brown(self, frametime) * 10; + tex = "particles/lgbeam"; + rgb = '1 1 1'; + break; + case ENT_CLIENT_LIGHTNING_BEAM: // todo intensity = bound(0.2, 1 + Noise_Pink(self, frametime) * 1 + Noise_Burst(self, frametime, 0.03) * 0.3, 2); offset = Noise_Brown(self, frametime) * 10; tex = "particles/lgbeam"; @@ -193,7 +204,8 @@ void Draw_GrapplingHook() self.drawmask = 0; } break; - case ENT_CLIENT_LGBEAM: + case ENT_CLIENT_ELECTRO_BEAM: + case ENT_CLIENT_LIGHTNING_BEAM: case ENT_CLIENT_GAUNTLET: setorigin(self, a); // beam origin! break; @@ -204,7 +216,10 @@ void Draw_GrapplingHook() default: case ENT_CLIENT_HOOK: break; - case ENT_CLIENT_LGBEAM: + case ENT_CLIENT_ELECTRO_BEAM: + pointparticles(particleeffectnum("electro_lightning"), trace_endpos, normalize(atrans - trace_endpos), frametime * intensity); // todo: new effect + break; + case ENT_CLIENT_LIGHTNING_BEAM: pointparticles(particleeffectnum("electro_lightning"), trace_endpos, normalize(atrans - trace_endpos), frametime * intensity); // todo: new effect break; case ENT_CLIENT_GAUNTLET: @@ -240,7 +255,8 @@ void Ent_ReadHook(float bIsNew, float type) case ENT_CLIENT_GAUNTLET: self.HookRange = 0; break; - case ENT_CLIENT_LGBEAM: + case ENT_CLIENT_ELECTRO_BEAM: + case ENT_CLIENT_LIGHTNING_BEAM: self.HookRange = ReadCoord(); break; } @@ -274,7 +290,10 @@ void Ent_ReadHook(float bIsNew, float type) setmodel(self, "models/hook.md3"); self.drawmask = MASK_NORMAL; break; - case ENT_CLIENT_LGBEAM: + case ENT_CLIENT_ELECTRO_BEAM: + sound (self, CHAN_PROJECTILE, "weapons/lgbeam_fly.wav", VOL_BASE, ATTN_NORM); + break; + case ENT_CLIENT_LIGHTNING_BEAM: sound (self, CHAN_PROJECTILE, "weapons/lgbeam_fly.wav", VOL_BASE, ATTN_NORM); break; case ENT_CLIENT_GAUNTLET: diff --git a/qcsrc/common/constants.qh b/qcsrc/common/constants.qh index 60633f574..eb92f5c94 100644 --- a/qcsrc/common/constants.qh +++ b/qcsrc/common/constants.qh @@ -110,9 +110,10 @@ const float ENT_CLIENT_WARPZONE = 24; const float ENT_CLIENT_WARPZONE_CAMERA = 25; const float ENT_CLIENT_TRIGGER_MUSIC = 26; const float ENT_CLIENT_HOOK = 27; -const float ENT_CLIENT_LGBEAM = 28; -const float ENT_CLIENT_GAUNTLET = 29; -const float ENT_CLIENT_ACCURACY = 30; +const float ENT_CLIENT_ELECTRO_BEAM = 28; +const float ENT_CLIENT_LIGHTNING_BEAM = 29; +const float ENT_CLIENT_GAUNTLET = 30; +const float ENT_CLIENT_ACCURACY = 31; const float ENT_CLIENT_TURRET = 40; diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 71584d350..b8d970702 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -1092,6 +1092,10 @@ float ClientInit_SendEntity(entity to, float sf) WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[1])); WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[2])); WriteInt24_t(MSG_ENTITY, compressShotOrigin(electro_shotorigin[3])); + WriteInt24_t(MSG_ENTITY, compressShotOrigin(lightning_shotorigin[0])); + WriteInt24_t(MSG_ENTITY, compressShotOrigin(lightning_shotorigin[1])); + WriteInt24_t(MSG_ENTITY, compressShotOrigin(lightning_shotorigin[2])); + WriteInt24_t(MSG_ENTITY, compressShotOrigin(lightning_shotorigin[3])); WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[0])); WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[1])); WriteInt24_t(MSG_ENTITY, compressShotOrigin(gauntlet_shotorigin[2])); diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 84402f013..977aade60 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -692,6 +692,7 @@ void spawnfunc_worldspawn (void) InitGameplayMode(); readlevelcvars(); GrappleHookInit(); + LightningInit(); ElectroInit(); LaserInit(); diff --git a/qcsrc/server/progs.src b/qcsrc/server/progs.src index c76395fdb..13a4c64eb 100644 --- a/qcsrc/server/progs.src +++ b/qcsrc/server/progs.src @@ -47,6 +47,7 @@ portals.qh g_hook.qh w_electro.qh +w_lightning.qh w_laser.qh scores.qh diff --git a/qcsrc/server/w_electro.qc b/qcsrc/server/w_electro.qc index f5491f39a..77477a23e 100644 --- a/qcsrc/server/w_electro.qc +++ b/qcsrc/server/w_electro.qc @@ -198,7 +198,7 @@ void W_Electro_Attack2() .vector hook_start, hook_end; float lgbeam_send(entity to, float sf) { - WriteByte(MSG_ENTITY, ENT_CLIENT_LGBEAM); + WriteByte(MSG_ENTITY, ENT_CLIENT_ELECTRO_BEAM); sf = sf & 0x7F; if(sound_allowed(MSG_BROADCAST, self.owner)) sf |= 0x80; diff --git a/qcsrc/server/w_lightning.qc b/qcsrc/server/w_lightning.qc index 2febfc262..d42028d3c 100644 --- a/qcsrc/server/w_lightning.qc +++ b/qcsrc/server/w_lightning.qc @@ -6,14 +6,13 @@ REGISTER_WEAPON(LIGHTNING, w_lightning, IT_CELLS, 5, WEP_FLAG_NORMAL | WEP_TYPE_ // Declarations ========================= .vector hook_start, hook_end; // used for beam .entity lightning_beam; // used for beam -//.float bot_aim_whichfiretype; // ??? .float BUTTON_ATCK_prev; // for better animation control .float lg_fire_prev; // for better animation control // Lightning functions ========================= float W_Lightning_Beam_Send(entity to, float sf) { - WriteByte(MSG_ENTITY, ENT_CLIENT_LGBEAM); + WriteByte(MSG_ENTITY, ENT_CLIENT_LIGHTNING_BEAM); sf = sf & 0x7F; if(sound_allowed(MSG_BROADCAST, self.owner)) sf |= 0x80; @@ -124,20 +123,6 @@ void W_Lightning_Attack1 (void) self = oldself; } -void LightningInit() -{ - weapon_action(WEP_LIGHTNING, WR_PRECACHE); - lightning_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LIGHTNING), FALSE, FALSE, 1); - lightning_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LIGHTNING), FALSE, FALSE, 2); - lightning_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LIGHTNING), FALSE, FALSE, 3); - lightning_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LIGHTNING), FALSE, FALSE, 4); -} - -void spawnfunc_weapon_lightning (void) -{ - weapon_defaultspawnfunc(WEP_LIGHTNING); -} - float w_lightning(float req) { if (req == WR_AIM) @@ -240,6 +225,20 @@ float w_lightning(float req) } return TRUE; }; + +void LightningInit() +{ + weapon_action(WEP_LIGHTNING, WR_PRECACHE); + lightning_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LIGHTNING), FALSE, FALSE, 1); + lightning_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LIGHTNING), FALSE, FALSE, 2); + lightning_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LIGHTNING), FALSE, FALSE, 3); + lightning_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_LIGHTNING), FALSE, FALSE, 4); +} + +void spawnfunc_weapon_lightning (void) // should this really be here? +{ + weapon_defaultspawnfunc(WEP_LIGHTNING); +} #endif #ifdef CSQC float w_lightning(float req) @@ -248,6 +247,7 @@ float w_lightning(float req) { vector org2; org2 = w_org + w_backoff * 6; + if(w_deathtype & HITTYPE_SECONDARY) { pointparticles(particleeffectnum("lightning_ballexplode"), org2, '0 0 0', 1); @@ -256,19 +256,9 @@ float w_lightning(float req) } else { - if(w_deathtype & HITTYPE_BOUNCE) - { - // this is sent as "primary (w_deathtype & HITTYPE_BOUNCE)" to distinguish it from (w_deathtype & HITTYPE_SECONDARY) bounced balls - pointparticles(particleeffectnum("lightning_combo"), org2, '0 0 0', 1); - if(!w_issilent) - sound(self, CHAN_PROJECTILE, "weapons/lightning_impact_combo.wav", VOL_BASE, ATTN_NORM); - } - else - { - pointparticles(particleeffectnum("lightning_impact"), org2, '0 0 0', 1); - if(!w_issilent) - sound(self, CHAN_PROJECTILE, "weapons/lightning_impact.wav", VOL_BASE, ATTN_NORM); - } + pointparticles(particleeffectnum("lightning_impact"), org2, '0 0 0', 1); + if(!w_issilent) + sound(self, CHAN_PROJECTILE, "weapons/lightning_impact.wav", VOL_BASE, ATTN_NORM); } } else if(req == WR_PRECACHE) diff --git a/qcsrc/server/w_lightning.qh b/qcsrc/server/w_lightning.qh new file mode 100644 index 000000000..57d6ceb0d --- /dev/null +++ b/qcsrc/server/w_lightning.qh @@ -0,0 +1,2 @@ +void LightningInit(); +vector lightning_shotorigin[4]; -- 2.39.2