]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/client/effects.qc
The end of the start
[xonotic/xonotic-data.pk3dir.git] / qcsrc / client / effects.qc
1 /*
2 .vector fx_start;
3 .vector fx_end;
4 .float  fx_with;
5 .string fx_texture;
6 .float  fx_lifetime;
7
8 void b_draw()
9 {
10     //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);
11     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);
12
13 }
14 void b_make(vector s,vector e, string t,float l,float z)
15 {
16     entity b;
17     b = spawn();
18     b.fx_texture = t;
19     b.fx_start = s;
20     b.fx_end = e;
21     b.fx_with = z;
22     b.think = SUB_Remove;
23     b.nextthink = time + l;
24         b.draw = b_draw;
25
26         //b.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
27 }
28 */
29
30 void cl_effetcs_lightningarc(vector from, vector to,float seglength,float drifts,float drifte,float branchfactor,float branchfactor_add)
31 {
32     vector direction,dirnew, pos, pos_l;
33     float length, steps, steplength, i,drift;
34
35     length     = vlen(from - to);
36     if(length < 1)
37         return;
38
39     steps      = floor(length / seglength);
40     if(steps < 1)
41     {
42         te_lightning1(world,from,to);
43         return;
44     }
45
46     steplength = length / steps;
47     direction  = normalize(to - from);
48     pos_l = from;
49     if(length > seglength)
50     {
51         for(i = 1; i < steps; i += 1)
52         {
53             drift = drifts * (1 - (i / steps)) + drifte * (i / steps);
54             dirnew = normalize(direction * (1 - drift) + randomvec() * drift);
55             pos = pos_l +  dirnew * steplength;
56             te_lightning1(world,pos_l,pos);
57             if(random() < branchfactor)
58                 cl_effetcs_lightningarc(pos, pos + (dirnew * length * 0.25),seglength,drifts,drifte,min(branchfactor + branchfactor_add,1),branchfactor_add);
59
60             pos_l = pos;
61         }
62         te_lightning1(world,pos_l,to);
63
64     }
65     else
66         te_lightning1(world,from,to);
67
68 }
69
70 void Net_ReadLightningarc()
71 {
72         vector from, to;
73
74     from_x = ReadCoord(); from_y = ReadCoord(); from_z = ReadCoord();
75     to_x   = ReadCoord(); to_y   = ReadCoord(); to_z   = ReadCoord();
76
77     if(autocvar_cl_effects_lightningarc_simple)
78     {
79         te_lightning1(world,from,to);
80     }
81     else
82     {
83         float seglength, drifts, drifte, branchfactor, branchfactor_add;
84
85         seglength        = autocvar_cl_effects_lightningarc_segmentlength;
86         drifts           = autocvar_cl_effects_lightningarc_drift_start;
87         drifte           = autocvar_cl_effects_lightningarc_drift_end;
88         branchfactor     = autocvar_cl_effects_lightningarc_branchfactor_start;
89         branchfactor_add = autocvar_cl_effects_lightningarc_branchfactor_add;
90
91         cl_effetcs_lightningarc(from,to,seglength,drifts,drifte,branchfactor,branchfactor_add);
92     }
93
94 }
95 void Net_ReadArc() { Net_ReadLightningarc(); }