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