2 REGISTER_NET_TEMP(TE_CSQC_ARC)
6 void te_csqc_lightningarc(vector from, vector to)
8 WriteHeader(MSG_BROADCAST, TE_CSQC_ARC);
10 WriteCoord(MSG_BROADCAST, from.x);
11 WriteCoord(MSG_BROADCAST, from.y);
12 WriteCoord(MSG_BROADCAST, from.z);
13 WriteCoord(MSG_BROADCAST, to.x);
14 WriteCoord(MSG_BROADCAST, to.y);
15 WriteCoord(MSG_BROADCAST, to.z);
29 //Draw_CylindricLine(self.fx_start, self.fx_end, self.fx_with, self.fx_texture, 0, time * 3, '1 1 1', 0.7, DRAWFLAG_ADDITIVE, view_origin);
30 Draw_CylindricLine(self.fx_start, self.fx_end, self.fx_with, self.fx_texture, (self.fx_with/256), 0, '1 1 1', 1, DRAWFLAG_ADDITIVE, view_origin);
33 void b_make(vector s,vector e, string t,float l,float z)
42 b.nextthink = time + l;
45 //b.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
49 void cl_effects_lightningarc(vector from, vector to, float seglength, float drifts, float drifte,
50 float branchfactor, float branchfactor_add)
52 float length = vlen(from - to);
53 if (length < 1) return;
55 // Use at most 16 te_lightning1 segments, as these eat up beam list segments.
56 // TODO: Change this to R_BeginPolygon code, then we no longer have this limit.
57 int steps = min(16, floor(length / seglength));
60 te_lightning1(world, from, to);
64 float steplength = length / steps;
65 vector direction = normalize(to - from);
67 if (length > seglength)
69 for (int i = 1; i < steps; i += 1)
71 float drift = drifts * (1 - (i / steps)) + drifte * (i / steps);
72 vector dirnew = normalize(direction * (1 - drift) + randomvec() * drift);
73 vector pos = pos_l + dirnew * steplength;
74 te_lightning1(world, pos_l, pos);
75 // WTF endless recursion if branchfactor is 1.0 (possibly due to adding branchfactor_add). FIXME
76 // if(random() < branchfactor)
77 // cl_effects_lightningarc(pos, pos + (dirnew * length * 0.25),seglength,drifts,drifte,min(branchfactor + branchfactor_add,1),branchfactor_add);
81 te_lightning1(world, pos_l, to);
85 te_lightning1(world, from, to);
89 NET_HANDLE(TE_CSQC_ARC, bool isNew)
101 if (autocvar_cl_effects_lightningarc_simple)
103 te_lightning1(world, from, to);
107 float seglength = autocvar_cl_effects_lightningarc_segmentlength;
108 float drifts = autocvar_cl_effects_lightningarc_drift_start;
109 float drifte = autocvar_cl_effects_lightningarc_drift_end;
110 float branchfactor = autocvar_cl_effects_lightningarc_branchfactor_start;
111 float branchfactor_add = autocvar_cl_effects_lightningarc_branchfactor_add;
113 cl_effects_lightningarc(from, to, seglength, drifts, drifte, branchfactor, branchfactor_add);