This repository has been archived by the owner on Nov 14, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
/
cshift.qc
75 lines (52 loc) · 1.63 KB
/
cshift.qc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
inline void(entity client, float density, vector color) csf_save = {
client.csf_color = color;
client.csf_density = density;
}
inline void(entity client) csf_apply = {
stuffcmd(client, "\nv_cshift ");
stuffcmd(client, ftos(client.csf_color_x));
stuffcmd(client, " ");
stuffcmd(client, ftos(client.csf_color_y));
stuffcmd(client, " ");
stuffcmd(client, ftos(client.csf_color_z));
stuffcmd(client, " ");
stuffcmd(client, ftos(client.csf_density));
stuffcmd(client, "\n");
}
void(entity client, float density, vector color) csf_set = {
csf_save(client, density, color);
csf_apply(client);
}
void() csfcontroller_think = {
entity e = self.owner;
if (self.pain_finished > time && e.csf_density != self.csf_density) {
float density;
vector color;
float fraction = 1 - (self.pain_finished - time) / self.speed; //wat
density = lerpHermite(e.csf_density, self.csf_density, fraction);
color = lerpVectorHermite(e.csf_color, self.csf_color, fraction);
csf_set(e, density, color);
self.nextthink = time + 0.04;
}
else {
csf_set(e, self.csf_density, self.csf_color);
}
}
void(entity client) csfcontroller_start = {
if (client.csfcontroller.classname == "csfcontroller" && client.csfcontroller.owner == client)
return;
entity e = spawn();
client.csfcontroller = e;
e.owner = client;
e.classname = "csfcontroller";
e.think = csfcontroller_think;
}
void(entity client, float density, vector color, float spd) csf_fade = {
csfcontroller_start(client);
entity ct = client.csfcontroller;
ct.speed = spd;
ct.pain_finished = time + spd;
ct.csf_color = color;
ct.csf_density = density;
ct.nextthink = time + 0.04;
}