]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/effects.qc
Cleanup
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / effects.qc
1 #include "effects.qh"
2
3 /*
4 .vector fx_start;
5 .vector fx_end;
6 .float  fx_with;
7 .string fx_texture;
8 .float  fx_lifetime;
9
10 void b_draw()
11 {
12     //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);
13     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);
14
15 }
16 void b_make(vector s,vector e, string t,float l,float z)
17 {
18     entity b;
19     b = spawn();
20     b.fx_texture = t;
21     b.fx_start = s;
22     b.fx_end = e;
23     b.fx_with = z;
24     b.think = SUB_Remove;
25     b.nextthink = time + l;
26         b.draw = b_draw;
27
28         //b.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
29 }
30 */
31
32 void cl_effects_lightningarc(vector from, vector to,float seglength,float drifts,float drifte,float branchfactor,float branchfactor_add)
33 {
34     vector direction,dirnew, pos, pos_l;
35     float length, steps, steplength, i,drift;
36
37     length     = vlen(from - to);
38     if(length < 1)
39         return;
40
41     // Use at most 16 te_lightning1 segments, as these eat up beam list segments.
42     // TODO: Change this to R_BeginPolygon code, then we no longer have this limit.
43     steps      = min(16, floor(length / seglength));
44     if(steps < 1)
45     {
46         te_lightning1(world,from,to);
47         return;
48     }
49
50     steplength = length / steps;
51     direction  = normalize(to - from);
52     pos_l = from;
53     if(length > seglength)
54     {
55         for(i = 1; i < steps; i += 1)
56         {
57             drift = drifts * (1 - (i / steps)) + drifte * (i / steps);
58             dirnew = normalize(direction * (1 - drift) + randomvec() * drift);
59             pos = pos_l +  dirnew * steplength;
60             te_lightning1(world,pos_l,pos);
61             // WTF endless recursion if branchfactor is 1.0 (possibly due to adding branchfactor_add). FIXME
62             // if(random() < branchfactor)
63             //     cl_effects_lightningarc(pos, pos + (dirnew * length * 0.25),seglength,drifts,drifte,min(branchfactor + branchfactor_add,1),branchfactor_add);
64
65             pos_l = pos;
66         }
67         te_lightning1(world,pos_l,to);
68
69     }
70     else
71         te_lightning1(world,from,to);
72
73 }
74
75 void Net_ReadLightningarc()
76 {
77         vector from, to;
78
79     from.x = ReadCoord(); from.y = ReadCoord(); from.z = ReadCoord();
80     to.x = ReadCoord(); to.y = ReadCoord(); to.z = ReadCoord();
81
82     if(autocvar_cl_effects_lightningarc_simple)
83     {
84         te_lightning1(world,from,to);
85     }
86     else
87     {
88         float seglength, drifts, drifte, branchfactor, branchfactor_add;
89
90         seglength        = autocvar_cl_effects_lightningarc_segmentlength;
91         drifts           = autocvar_cl_effects_lightningarc_drift_start;
92         drifte           = autocvar_cl_effects_lightningarc_drift_end;
93         branchfactor     = autocvar_cl_effects_lightningarc_branchfactor_start;
94         branchfactor_add = autocvar_cl_effects_lightningarc_branchfactor_add;
95
96         cl_effects_lightningarc(from,to,seglength,drifts,drifte,branchfactor,branchfactor_add);
97     }
98
99 }
100 void Net_ReadArc() { Net_ReadLightningarc(); }
101 NET_HANDLE(TE_CSQC_ARC, bool isNew)
102 {
103         Net_ReadArc();
104         return true;
105 }