]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/w_laser.qc
mostly working code to use csqc entities for hook, electro, gauntlet (currently doesn...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / w_laser.qc
index 8633297a12d2c31bbbfe16d77b3b5d79a571322d..dd5e30ed8168d0ef625746f19b7bcfb758e88560 100644 (file)
@@ -101,6 +101,32 @@ void W_Laser_Attack (float issecondary)
        }
 }
 
+.vector hook_start, hook_end;
+float gauntletbeam_send(entity to, float sf)
+{
+       WriteByte(MSG_ENTITY, ENT_CLIENT_GAUNTLET);
+       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 gauntletbeam;
 .float prevgauntletfire;
 void gauntletbeam_think()
@@ -153,17 +179,16 @@ void gauntletbeam_think()
                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, 3);
-       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);
+       if(org != self.hook_start)
+       {
+               self.SendFlags |= 2;
+               self.hook_start = org;
+       }
+       if(trace_endpos != self.hook_end)
+       {
+               self.SendFlags |= 4;
+               self.hook_end = trace_endpos;
+       }
 }
 
 // experimental gauntlet
@@ -186,6 +211,7 @@ void W_Laser_Attack2 (float issecondary)
        beam.bot_dodge = TRUE;
        beam.bot_dodgerating = cvar("g_balance_laser_primary_damage");
        beam.cnt = issecondary;
+       Net_LinkEntity(beam, FALSE, 0, gauntletbeam_send);
 
        oldself = self;
        self = beam;