X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fw_electro.qc;h=2be1573cd34e0c6b049acfffbb8eba464b4bc328;hb=b4a912024bf4786b87ee5ab789c53befcc48acb2;hp=45a9b91f37dd855e56d72b0c6f675421096e9ef3;hpb=d23cd4201bf51011c6c2b4fe51e71b8d4e6f6708;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/w_electro.qc b/qcsrc/server/w_electro.qc index 45a9b91f3..2be1573cd 100644 --- a/qcsrc/server/w_electro.qc +++ b/qcsrc/server/w_electro.qc @@ -184,10 +184,40 @@ void W_Electro_Attack2() CSQCProjectile(proj, TRUE, PROJECTILE_ELECTRO, FALSE); // no culling, it has sound } -.entity lgbeam, exteriorlgbeam; -.float nextdamagethink; +.vector hook_start, hook_end; +float lgbeam_send(entity to, float sf) +{ + WriteByte(MSG_ENTITY, ENT_CLIENT_LGBEAM); + sf = sf & 0x7F; + if(sound_allowed(MSG_BROADCAST, self.owner)) + sf |= 0x80; + WriteByte(MSG_ENTITY, sf); + if(sf & 1) + { + WriteByte(MSG_ENTITY, num_for_edict(self.owner)); + } + if(sf & 2) + { + WriteCoord(MSG_ENTITY, self.hook_start_x); + WriteCoord(MSG_ENTITY, self.hook_start_y); + WriteCoord(MSG_ENTITY, self.hook_start_z); + } + if(sf & 4) + { + WriteCoord(MSG_ENTITY, self.hook_end_x); + WriteCoord(MSG_ENTITY, self.hook_end_y); + WriteCoord(MSG_ENTITY, self.hook_end_z); + } + return TRUE; +} +.entity lgbeam; +.float prevlgfire; void lgbeam_think() { + vector endpos; + float oldsolid; + + self.owner.prevlgfire = time; if (self.owner.weaponentity.state != WS_INUSE || (self.owner.ammo_cells <= 0 && !(self.owner.items & IT_UNLIMITED_WEAPON_AMMO)) || self != self.owner.lgbeam || self.owner.deadflag != DEAD_NO || !self.owner.BUTTON_ATCK) { remove(self); @@ -199,8 +229,24 @@ void lgbeam_think() makevectors(self.owner.v_angle); vector angle; angle = v_forward; + // get effect origin + vector vecs, org; + if(self.owner.weaponentity.movedir_x > 0) + vecs = self.owner.weaponentity.movedir; + else + vecs = '0 0 0'; + if(debug_shotorg != '0 0 0') + vecs = debug_shotorg; + org = self.owner.origin + self.owner.view_ofs + v_forward * vecs_x + v_right * -vecs_y + v_up * vecs_z; - traceline_antilag(self.owner, self.owner.origin + self.owner.view_ofs, self.owner.origin + self.owner.view_ofs + angle * cvar("g_balance_electro_primary_range"), FALSE, self.owner, ANTILAG_LATENCY(self.owner)); + oldsolid = self.owner.dphitcontentsmask; + self.owner.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE; + + WarpZone_traceline_antilag(self.owner, self.owner.origin + self.owner.view_ofs, self.owner.origin + self.owner.view_ofs + angle * cvar("g_balance_electro_primary_range"), MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner)); + endpos = WarpZone_UnTransformOrigin(WarpZone_trace_transform, trace_endpos); + WarpZone_traceline_antilag(self.owner, org, endpos + 4 * normalize(endpos - org), MOVE_NORMAL, self.owner, ANTILAG_LATENCY(self.owner)); + + self.owner.dphitcontentsmask = oldsolid; if not(self.owner.items & IT_UNLIMITED_WEAPON_AMMO) self.owner.ammo_cells = max(0, self.owner.ammo_cells - cvar("g_balance_electro_primary_ammo") * frametime); @@ -215,32 +261,27 @@ void lgbeam_think() } // draw effect - vector vecs, org; - if(self.owner.weaponentity.movedir_x > 0) + if(org != self.hook_start) { - vecs = self.owner.weaponentity.movedir; - vecs_y = -vecs_y; + self.SendFlags |= 2; + self.hook_start = org; + } + if(endpos != self.hook_end) + { + self.SendFlags |= 4; + self.hook_end = endpos; } - else - vecs = '0 0 0'; - org = self.owner.origin + self.owner.view_ofs + v_forward * vecs_x + v_right * vecs_y + v_up * vecs_z; - - // TODO turn into a csqc entity - WriteByte(MSG_BROADCAST, SVC_TEMPENTITY); - WriteByte(MSG_BROADCAST, TE_CSQC_BEAM); - WriteByte(MSG_BROADCAST, num_for_edict(self.owner)); - WriteByte(MSG_BROADCAST, sound_allowed(MSG_BROADCAST, self.owner) ? 1 : 2); - WriteCoord(MSG_BROADCAST, trace_endpos_x); - WriteCoord(MSG_BROADCAST, trace_endpos_y); - WriteCoord(MSG_BROADCAST, trace_endpos_z); - WriteCoord(MSG_BROADCAST, org_x); - WriteCoord(MSG_BROADCAST, org_y); - WriteCoord(MSG_BROADCAST, org_z); } // experimental lightning gun void W_Electro_Attack3 (void) { + // only play fire sound if 0.5 sec has passed since player let go the fire button + if(time - self.prevlgfire > 0.5) + { + sound (self, CHAN_WEAPON, "weapons/lgbeam_fire.wav", VOL_BASE, ATTN_NORM); + } + entity beam, oldself; self.lgbeam = beam = spawn(); @@ -251,6 +292,7 @@ void W_Electro_Attack3 (void) beam.shot_spread = 0; beam.bot_dodge = TRUE; beam.bot_dodgerating = cvar("g_balance_electro_primary_damage"); + Net_LinkEntity(beam, FALSE, 0, lgbeam_send); oldself = self; self = beam; @@ -261,10 +303,10 @@ void W_Electro_Attack3 (void) void ElectroInit() { weapon_action(WEP_ELECTRO, WR_PRECACHE); - electro_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), TRUE, FALSE, 1); - electro_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), TRUE, FALSE, 2); - electro_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), TRUE, FALSE, 3); - electro_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), TRUE, FALSE, 4); + electro_shotorigin[0] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), FALSE, FALSE, 1); + electro_shotorigin[1] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), FALSE, FALSE, 2); + electro_shotorigin[2] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), FALSE, FALSE, 3); + electro_shotorigin[3] = shotorg_adjust_values(CL_Weapon_GetShotOrg(WEP_ELECTRO), FALSE, FALSE, 4); } void spawnfunc_weapon_electro (void) @@ -359,7 +401,9 @@ float w_electro(float req) precache_sound ("weapons/electro_impact.wav"); precache_sound ("weapons/electro_impact_combo.wav"); if(cvar("g_balance_electro_lightning")) - precache_sound ("weapons/crylink_fire2.wav"); + { + precache_sound ("weapons/lgbeam_fire.wav"); + } } else if (req == WR_SETUP) weapon_setup(WEP_ELECTRO);