1 #include "lightningarc.qh"
4 REGISTER_NET_TEMP(TE_CSQC_ARC)
8 void te_csqc_lightningarc(vector from, vector to)
10 WriteHeader(MSG_BROADCAST, TE_CSQC_ARC);
12 WriteCoord(MSG_BROADCAST, from.x);
13 WriteCoord(MSG_BROADCAST, from.y);
14 WriteCoord(MSG_BROADCAST, from.z);
15 WriteCoord(MSG_BROADCAST, to.x);
16 WriteCoord(MSG_BROADCAST, to.y);
17 WriteCoord(MSG_BROADCAST, to.z);
31 //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);
32 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);
35 void b_make(vector s,vector e, string t,float l,float z)
44 b.nextthink = time + l;
47 //b.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
51 void cl_effects_lightningarc(vector from, vector to, float seglength, float drifts, float drifte,
52 float branchfactor, float branchfactor_add)
54 float length = vlen(from - to);
55 if (length < 1) return;
57 // Use at most 16 te_lightning1 segments, as these eat up beam list segments.
58 // TODO: Change this to R_BeginPolygon code, then we no longer have this limit.
59 int steps = min(16, floor(length / seglength));
62 te_lightning1(NULL, from, to);
66 float steplength = length / steps;
67 vector direction = normalize(to - from);
69 if (length > seglength)
71 for (int i = 1; i < steps; i += 1)
73 float drift = drifts * (1 - (i / steps)) + drifte * (i / steps);
74 vector dirnew = normalize(direction * (1 - drift) + randomvec() * drift);
75 vector pos = pos_l + dirnew * steplength;
76 te_lightning1(NULL, pos_l, pos);
77 // WTF endless recursion if branchfactor is 1.0 (possibly due to adding branchfactor_add). FIXME
78 // if(random() < branchfactor)
79 // cl_effects_lightningarc(pos, pos + (dirnew * length * 0.25),seglength,drifts,drifte,min(branchfactor + branchfactor_add,1),branchfactor_add);
83 te_lightning1(NULL, pos_l, to);
87 te_lightning1(NULL, from, to);
91 NET_HANDLE(TE_CSQC_ARC, bool isNew)
103 if (autocvar_cl_effects_lightningarc_simple)
105 te_lightning1(NULL, from, to);
109 float seglength = autocvar_cl_effects_lightningarc_segmentlength;
110 float drifts = autocvar_cl_effects_lightningarc_drift_start;
111 float drifte = autocvar_cl_effects_lightningarc_drift_end;
112 float branchfactor = autocvar_cl_effects_lightningarc_branchfactor_start;
113 float branchfactor_add = autocvar_cl_effects_lightningarc_branchfactor_add;
115 cl_effects_lightningarc(from, to, seglength, drifts, drifte, branchfactor, branchfactor_add);