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 WriteVector(MSG_BROADCAST, from);
12 WriteVector(MSG_BROADCAST, to);
26 //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);
27 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);
30 void b_make(vector s,vector e, string t,float l,float z)
39 b.nextthink = time + l;
42 //b.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
46 void cl_effects_lightningarc(vector from, vector to, float seglength, float drifts, float drifte,
47 float branchfactor, float branchfactor_add)
49 float length = vlen(from - to);
50 if (length < 1) return;
52 // Use at most 16 te_lightning1 segments, as these eat up beam list segments.
53 // TODO: Change this to R_BeginPolygon code, then we no longer have this limit.
54 int steps = min(16, floor(length / seglength));
57 te_lightning1(NULL, from, to);
61 float steplength = length / steps;
62 vector direction = normalize(to - from);
64 if (length > seglength)
66 for (int i = 1; i < steps; i += 1)
68 float drift = drifts * (1 - (i / steps)) + drifte * (i / steps);
69 vector dirnew = normalize(direction * (1 - drift) + randomvec() * drift);
70 vector pos = pos_l + dirnew * steplength;
71 te_lightning1(NULL, pos_l, pos);
72 // WTF endless recursion if branchfactor is 1.0 (possibly due to adding branchfactor_add). FIXME
73 // if(random() < branchfactor)
74 // cl_effects_lightningarc(pos, pos + (dirnew * length * 0.25),seglength,drifts,drifte,min(branchfactor + branchfactor_add,1),branchfactor_add);
78 te_lightning1(NULL, pos_l, to);
82 te_lightning1(NULL, from, to);
86 NET_HANDLE(TE_CSQC_ARC, bool isNew)
88 vector from = ReadVector();
89 vector to = ReadVector();
92 if (autocvar_cl_effects_lightningarc_simple)
94 te_lightning1(NULL, from, to);
98 float seglength = autocvar_cl_effects_lightningarc_segmentlength;
99 float drifts = autocvar_cl_effects_lightningarc_drift_start;
100 float drifte = autocvar_cl_effects_lightningarc_drift_end;
101 float branchfactor = autocvar_cl_effects_lightningarc_branchfactor_start;
102 float branchfactor_add = autocvar_cl_effects_lightningarc_branchfactor_add;
104 cl_effects_lightningarc(from, to, seglength, drifts, drifte, branchfactor, branchfactor_add);