Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
lightningarc.qc
Go to the documentation of this file.
1#include "lightningarc.qh"
2
3REGISTER_NET_TEMP(TE_CSQC_ARC)
4
5#if defined(SVQC)
6
8 {
9 WriteHeader(MSG_BROADCAST, TE_CSQC_ARC);
10
11 WriteVector(MSG_BROADCAST, from);
12 WriteVector(MSG_BROADCAST, to);
13 }
14
15#elif defined(CSQC)
16
17/*
18.vector fx_start;
19.vector fx_end;
20.float fx_with;
21.string fx_texture;
22.float fx_lifetime;
23
24void b_draw()
25{
26 //Draw_CylindricLine(this.fx_start, this.fx_end, this.fx_with, this.fx_texture, 0, time * 3, '1 1 1', 0.7, DRAWFLAG_ADDITIVE, view_origin);
27 Draw_CylindricLine(this.fx_start, this.fx_end, this.fx_with, this.fx_texture, (this.fx_with/256), 0, '1 1 1', 1, DRAWFLAG_ADDITIVE, view_origin);
28
29}
30void b_make(vector s,vector e, string t,float l,float z)
31{
32 entity b;
33 b = spawn();
34 b.fx_texture = t;
35 b.fx_start = s;
36 b.fx_end = e;
37 b.fx_with = z;
38 b.think = SUB_Remove;
39 b.nextthink = time + l;
40 b.draw = b_draw;
41
42 //b.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
43}
44*/
45
46 void cl_effects_lightningarc(vector from, vector to, float seglength, float drifts, float drifte,
47 float branchfactor, float branchfactor_add)
48 {
49 float length = vlen(from - to);
50 if (length < 1) return;
51
52 // Use at most 16 te_lightning1 segments, as these eat up beam list segments.
53 // TODO: Change this to R_BeginPolygon code, then we no longer have this limit.
54 int steps = min(16, floor(length / seglength));
55 if (steps < 1)
56 {
57 te_lightning1(NULL, from, to);
58 return;
59 }
60
61 float steplength = length / steps;
62 vector direction = normalize(to - from);
63 vector pos_l = from;
64 if (length > seglength)
65 {
66 for (int i = 1; i < steps; i += 1)
67 {
68 float drift = drifts * (1 - (i / steps)) + drifte * (i / steps);
69 vector dirnew = normalize(direction * (1 - drift) + randomvec() * drift);
70 vector pos = pos_l + dirnew * steplength;
71 te_lightning1(NULL, pos_l, pos);
72 // WTF endless recursion if branchfactor is 1.0 (possibly due to adding branchfactor_add). FIXME
73 // if(random() < branchfactor)
74 // cl_effects_lightningarc(pos, pos + (dirnew * length * 0.25),seglength,drifts,drifte,min(branchfactor + branchfactor_add,1),branchfactor_add);
75
76 pos_l = pos;
77 }
78 te_lightning1(NULL, pos_l, to);
79 }
80 else
81 {
82 te_lightning1(NULL, from, to);
83 }
84 }
85
86 NET_HANDLE(TE_CSQC_ARC, bool isNew)
87 {
88 vector from = ReadVector();
89 vector to = ReadVector();
90 return = true;
91
93 {
94 te_lightning1(NULL, from, to);
95 }
96 else
97 {
103
104 cl_effects_lightningarc(from, to, seglength, drifts, drifte, branchfactor, branchfactor_add);
105 }
106 }
107
108#endif
#define NET_HANDLE(id, param)
Definition net.qh:15
#define ReadVector()
Definition net.qh:367
#define WriteHeader(to, id)
Definition net.qh:221
#define REGISTER_NET_TEMP(id)
Definition net.qh:28
void te_csqc_lightningarc(vector from, vector to)
float autocvar_cl_effects_lightningarc_branchfactor_start
float autocvar_cl_effects_lightningarc_branchfactor_add
float autocvar_cl_effects_lightningarc_drift_start
float autocvar_cl_effects_lightningarc_segmentlength
float autocvar_cl_effects_lightningarc_drift_end
bool autocvar_cl_effects_lightningarc_simple
float vlen(vector v)
vector randomvec(void)
float min(float f,...)
vector normalize(vector v)
float floor(float f)
float MSG_BROADCAST
Definition menudefs.qc:55
#define NULL
Definition post.qh:14
vector
Definition self.qh:92