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