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 = spawn();
33 b.fx_texture = t;
34 b.fx_start = s;
35 b.fx_end = e;
36 b.fx_with = z;
37 b.think = SUB_Remove;
38 b.nextthink = time + l;
39 b.draw = b_draw;
40
41 //b.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_PLAYERCLIP;
42}
43*/
44
45 void cl_effects_lightningarc(vector from, vector to, float seglength, float drifts, float drifte,
46 float branchfactor, float branchfactor_add)
47 {
48 float length = vlen(from - to);
49 if (length < 1) return;
50
51 // Use at most 16 te_lightning1 segments, as these eat up beam list segments.
52 // TODO: Change this to R_BeginPolygon code, then we no longer have this limit.
53 int steps = min(16, floor(length / seglength));
54 if (steps < 1)
55 {
56 te_lightning1(NULL, from, to);
57 return;
58 }
59
60 float steplength = length / steps;
61 vector direction = normalize(to - from);
62 vector pos_l = from;
63 if (length > seglength)
64 {
65 for (int i = 1; i < steps; ++i)
66 {
67 float drift = drifts * (1 - (i / steps)) + drifte * (i / steps);
68 vector dirnew = normalize(direction * (1 - drift) + randomvec() * drift);
69 vector pos = pos_l + dirnew * steplength;
70 te_lightning1(NULL, pos_l, pos);
71 // WTF endless recursion if branchfactor is 1.0 (possibly due to adding branchfactor_add). FIXME
72 // if(random() < branchfactor)
73 // cl_effects_lightningarc(pos, pos + (dirnew * length * 0.25),seglength,drifts,drifte,min(branchfactor + branchfactor_add,1),branchfactor_add);
74
75 pos_l = pos;
76 }
77 te_lightning1(NULL, pos_l, to);
78 }
79 else
80 {
81 te_lightning1(NULL, from, to);
82 }
83 }
84
85 NET_HANDLE(TE_CSQC_ARC, bool isNew)
86 {
87 vector from = ReadVector();
88 vector to = ReadVector();
89 return = true;
90
92 {
93 te_lightning1(NULL, from, to);
94 }
95 else
96 {
102
103 cl_effects_lightningarc(from, to, seglength, drifts, drifte, branchfactor, branchfactor_add);
104 }
105 }
106
107#endif
#define NET_HANDLE(id, param)
Definition net.qh:15
#define ReadVector()
Definition net.qh:350
#define WriteHeader(to, id)
Definition net.qh:265
#define REGISTER_NET_TEMP(id)
Definition net.qh:31
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