better CTF indicators
[divverent/nexuiz.git] / data / 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 SUB_Remove()
9 { remove(self); }
10
11 void b_draw()
12 {
13     //Draw_CylindricLine(self.fx_start, self.fx_end, self.fx_with, self.fx_texture, 0, time * 3, '1 1 1', 0.7, DRAWFLAG_ADDITIVE);
14     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);
15
16 }
17 void b_make(vector s,vector e, string t,float l,float z)
18 {
19     entity b;
20     b = spawn();
21     b.fx_texture = t;
22     b.fx_start = s;
23     b.fx_end = e;
24     b.fx_with = z;
25     b.think = SUB_Remove;
26     b.nextthink = time + l;
27         b.draw = b_draw;
28
29         //b.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
30 }
31 */
32
33 void cl_effetcs_lightningarc(vector from, vector to,float seglength,float drifts,float drifte,float branchfactor,float branchfactor_add)
34 {
35     vector direction,dirnew, pos, pos_l;
36     float length, steps, steplength, i,drift;
37
38     length     = vlen(from - to);
39     if(length < 1)
40         return;
41
42     steps      = floor(length / seglength);
43     if(steps < 1)
44     {
45         te_lightning1(world,from,to);
46         return;
47     }
48
49     steplength = length / steps;
50     direction  = normalize(to - from);
51     pos_l = from;
52     if(length > seglength)
53     {
54         for(i = 1; i < steps; i += 1)
55         {
56             drift = drifts * (1 - (i / steps)) + drifte * (i / steps);
57             dirnew = normalize(direction * (1 - drift) + randomvec() * drift);
58             pos = pos_l +  dirnew * steplength;
59             te_lightning1(world,pos_l,pos);
60             //b_make(pos_l, pos,"particles/lightning2",0.25,64);
61             if(random() < branchfactor)
62                 cl_effetcs_lightningarc(pos, pos + (dirnew * length * 0.25),seglength,drifts,drifte,min(branchfactor + branchfactor_add,1),branchfactor_add);
63
64             pos_l = pos;
65         }
66         te_lightning1(world,pos_l,to);
67         //b_make(pos_l, to,"particles/lightning2",0.25,64);
68
69     }
70     else
71         te_lightning1(world,from,to);
72         //b_make(from, to,"particles/lightning2",0.25,64);
73
74 }
75
76 void Net_ReadLightningarc()
77 {
78         vector from, to;
79
80     from_x = ReadCoord(); from_y = ReadCoord(); from_z = ReadCoord();
81     to_x   = ReadCoord(); to_y   = ReadCoord(); to_z   = ReadCoord();
82
83     if(cvar("cl_effects_lightningarc_simple"))
84     {
85         te_lightning1(world,from,to);
86     }
87     else
88     {
89         float seglength, drifts, drifte, branchfactor, branchfactor_add;
90
91         seglength    = cvar("cl_effects_lightningarc_segmentlength");
92         drifts       = cvar("cl_effects_lightningarc_drift_start");
93         drifte       = cvar("cl_effects_lightningarc_drift_end");
94         branchfactor = cvar("cl_effects_lightningarc_branchfactor_start");
95         branchfactor = cvar("cl_effects_lightningarc_branchfactor_add");
96
97         cl_effetcs_lightningarc(from,to,seglength,drifts,drifte,branchfactor,branchfactor_add);
98     }
99
100 }