.float beam_usevieworigin;
.float beam_initialized;
+.float beam_range;
.vector beam_shotorigin;
.vector beam_dir;
void Draw_ArcBeam()
{ start_pos = self.origin; }
// trace forward with an estimation
- WarpZone_TraceLine(start_pos, start_pos + view_forward * cvar("g_balance_arc_beam_range"), MOVE_NOMONSTERS, self);
+ WarpZone_TraceLine(start_pos, start_pos + view_forward * self.beam_range, MOVE_NOMONSTERS, self);
// untransform in case our trace went through a warpzone
vector vf, vr, vu;
setorigin(self, start_pos);
- vector beam_endpos_estimate = (start_pos + (beamdir * cvar("g_balance_arc_beam_range")));
+ vector beam_endpos_estimate = (start_pos + (beamdir * self.beam_range));
float i;
float segments = 20; // todo: calculate this in a similar way to server does
InterpolateOrigin_Undo();
- if(sf & 1) // starting location // not sent if beam is for owner
+ if(sf & 1) // settings information
+ {
+ self.beam_range = ReadCoord();
+ }
+
+ if(sf & 2) // starting location
{
self.origin_x = ReadCoord();
self.origin_y = ReadCoord();
}
setorigin(self, self.origin);
}
-
- if(sf & 2) // want/aim direction
+
+ if(sf & 4) // want/aim direction
{
self.v_angle_x = ReadCoord();
self.v_angle_y = ReadCoord();
self.v_angle_z = ReadCoord();
}
- if(sf & 4) // beam direction
+
+ if(sf & 8) // beam direction
{
self.angles_x = ReadCoord();
self.angles_y = ReadCoord();
self.angles_z = ReadCoord();
}
- if(sf & 8) // beam type
+
+ if(sf & 16) // beam type
{
self.beam_type = ReadByte();
}
{
WriteByte(MSG_ENTITY, ENT_CLIENT_ARC_BEAM);
- // don't send group 1, 2, or 3 if this beam is for the local player
- if((to == self.owner) || ((to.enemy == self.owner) && IS_SPEC(to))) { sf &= ~7; }
- WriteByte(MSG_ENTITY, sf);
+ // Truncate information when this beam is displayed to the owner client
+ // - The owner client has no use for beam start position or directions,
+ // it always figures this information out for itself with csqc code.
+ // - Spectating the owner also truncates this information.
+ if((to == self.owner) || ((to.enemy == self.owner) && IS_SPEC(to)))
+ {
+ #if 0
+ sf &= ~2;
+ sf &= ~4;
+ sf &= ~8;
+ #else
+ sf &= ~14;
+ #endif
+ }
- //WriteCoord(MSG_ENTITY, WEP_CVAR(arc, beam_range));
+ WriteByte(MSG_ENTITY, sf);
- if(sf & 1) // starting location
+ if(sf & 1) // settings information
+ {
+ WriteCoord(MSG_ENTITY, WEP_CVAR(arc, beam_range));
+ }
+ if(sf & 2) // starting location
{
WriteCoord(MSG_ENTITY, self.beam_start_x);
WriteCoord(MSG_ENTITY, self.beam_start_y);
WriteCoord(MSG_ENTITY, self.beam_start_z);
}
- if(sf & 2) // want/aim direction
+ if(sf & 4) // want/aim direction
{
WriteCoord(MSG_ENTITY, self.beam_wantdir_x);
WriteCoord(MSG_ENTITY, self.beam_wantdir_y);
WriteCoord(MSG_ENTITY, self.beam_wantdir_z);
}
- if(sf & 4) // beam direction
+ if(sf & 8) // beam direction
{
WriteCoord(MSG_ENTITY, self.beam_dir_x);
WriteCoord(MSG_ENTITY, self.beam_dir_y);
WriteCoord(MSG_ENTITY, self.beam_dir_z);
}
- if(sf & 8) // beam type
+ if(sf & 16) // beam type
{
WriteByte(MSG_ENTITY, self.beam_type);
}
// network information: shot origin and want/aim direction
if(self.beam_start != w_shotorg)
{
- self.SendFlags |= 1;
+ self.SendFlags |= 2;
self.beam_start = w_shotorg;
}
if(self.beam_wantdir != w_shotdir)
{
- self.SendFlags |= 2;
+ self.SendFlags |= 4;
self.beam_wantdir = w_shotdir;
}
// printf("blendfactor = %f\n", blendfactor);
// network information: beam direction
- self.SendFlags |= 4;
+ self.SendFlags |= 8;
// calculate how many segments are needed
float max_allowed_segments;
// network information: beam type
if(new_beam_type != self.beam_type)
{
- self.SendFlags |= 8;
+ self.SendFlags |= 16;
self.beam_type = new_beam_type;
}