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