1 #include "lightningarc.qh"
3 REGISTER_NET_TEMP(TE_CSQC_ARC)
7 void te_csqc_lightningarc(vector from, vector to)
9 WriteHeader(MSG_BROADCAST, TE_CSQC_ARC);
11 WriteCoord(MSG_BROADCAST, from.x);
12 WriteCoord(MSG_BROADCAST, from.y);
13 WriteCoord(MSG_BROADCAST, from.z);
14 WriteCoord(MSG_BROADCAST, to.x);
15 WriteCoord(MSG_BROADCAST, to.y);
16 WriteCoord(MSG_BROADCAST, to.z);
30 //Draw_CylindricLine(this.fx_start, this.fx_end, this.fx_with, this.fx_texture, 0, time * 3, '1 1 1', 0.7, DRAWFLAG_ADDITIVE, view_origin);
31 Draw_CylindricLine(this.fx_start, this.fx_end, this.fx_with, this.fx_texture, (this.fx_with/256), 0, '1 1 1', 1, DRAWFLAG_ADDITIVE, view_origin);
34 void b_make(vector s,vector e, string t,float l,float z)
43 b.nextthink = time + l;
46 //b.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
50 void cl_effects_lightningarc(vector from, vector to, float seglength, float drifts, float drifte,
51 float branchfactor, float branchfactor_add)
53 float length = vlen(from - to);
54 if (length < 1) return;
56 // Use at most 16 te_lightning1 segments, as these eat up beam list segments.
57 // TODO: Change this to R_BeginPolygon code, then we no longer have this limit.
58 int steps = min(16, floor(length / seglength));
61 te_lightning1(NULL, from, to);
65 float steplength = length / steps;
66 vector direction = normalize(to - from);
68 if (length > seglength)
70 for (int i = 1; i < steps; i += 1)
72 float drift = drifts * (1 - (i / steps)) + drifte * (i / steps);
73 vector dirnew = normalize(direction * (1 - drift) + randomvec() * drift);
74 vector pos = pos_l + dirnew * steplength;
75 te_lightning1(NULL, pos_l, pos);
76 // WTF endless recursion if branchfactor is 1.0 (possibly due to adding branchfactor_add). FIXME
77 // if(random() < branchfactor)
78 // cl_effects_lightningarc(pos, pos + (dirnew * length * 0.25),seglength,drifts,drifte,min(branchfactor + branchfactor_add,1),branchfactor_add);
82 te_lightning1(NULL, pos_l, to);
86 te_lightning1(NULL, from, to);
90 NET_HANDLE(TE_CSQC_ARC, bool isNew)
102 if (autocvar_cl_effects_lightningarc_simple)
104 te_lightning1(NULL, from, to);
108 float seglength = autocvar_cl_effects_lightningarc_segmentlength;
109 float drifts = autocvar_cl_effects_lightningarc_drift_start;
110 float drifte = autocvar_cl_effects_lightningarc_drift_end;
111 float branchfactor = autocvar_cl_effects_lightningarc_branchfactor_start;
112 float branchfactor_add = autocvar_cl_effects_lightningarc_branchfactor_add;
114 cl_effects_lightningarc(from, to, seglength, drifts, drifte, branchfactor, branchfactor_add);