]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/func/rainsnow.qc
Merge branch 'master' into Mario/bulldozer
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / func / rainsnow.qc
1 REGISTER_NET_LINKED(ENT_CLIENT_RAINSNOW)
2
3 #ifdef SVQC
4 bool rainsnow_SendEntity(entity this, entity to, float sf)
5 {
6         WriteHeader(MSG_ENTITY, ENT_CLIENT_RAINSNOW);
7         WriteByte(MSG_ENTITY, self.state);
8         WriteCoord(MSG_ENTITY, self.origin_x + self.mins_x);
9         WriteCoord(MSG_ENTITY, self.origin_y + self.mins_y);
10         WriteCoord(MSG_ENTITY, self.origin_z + self.mins_z);
11         WriteCoord(MSG_ENTITY, self.maxs_x - self.mins_x);
12         WriteCoord(MSG_ENTITY, self.maxs_y - self.mins_y);
13         WriteCoord(MSG_ENTITY, self.maxs_z - self.mins_z);
14         WriteShort(MSG_ENTITY, compressShortVector(self.dest));
15         WriteShort(MSG_ENTITY, self.count);
16         WriteByte(MSG_ENTITY, self.cnt);
17         return true;
18 }
19
20 /*QUAKED spawnfunc_func_rain (0 .5 .8) ?
21 This is an invisible area like a trigger, which rain falls inside of.
22
23 Keys:
24 "velocity"
25  falling direction (should be something like '0 0 -700', use the X and Y velocity for wind)
26 "cnt"
27  sets color of rain (default 12 - white)
28 "count"
29  adjusts density, this many particles fall every second for a 1024x1024 area, default is 2000
30 */
31 spawnfunc(func_rain)
32 {
33         self.dest = self.velocity;
34         self.velocity = '0 0 0';
35         if (!self.dest)
36                 self.dest = '0 0 -700';
37         self.angles = '0 0 0';
38         self.movetype = MOVETYPE_NONE;
39         self.solid = SOLID_NOT;
40         SetBrushEntityModel();
41         if (!self.cnt)
42                 self.cnt = 12;
43         if (!self.count)
44                 self.count = 2000;
45         self.count = 0.01 * self.count * (self.size_x / 1024) * (self.size_y / 1024);
46         if (self.count < 1)
47                 self.count = 1;
48         if(self.count > 65535)
49                 self.count = 65535;
50
51         self.state = 1; // 1 is rain, 0 is snow
52         self.Version = 1;
53
54         Net_LinkEntity(self, false, 0, rainsnow_SendEntity);
55 }
56
57
58 /*QUAKED spawnfunc_func_snow (0 .5 .8) ?
59 This is an invisible area like a trigger, which snow falls inside of.
60
61 Keys:
62 "velocity"
63  falling direction (should be something like '0 0 -300', use the X and Y velocity for wind)
64 "cnt"
65  sets color of rain (default 12 - white)
66 "count"
67  adjusts density, this many particles fall every second for a 1024x1024 area, default is 2000
68 */
69 spawnfunc(func_snow)
70 {
71         self.dest = self.velocity;
72         self.velocity = '0 0 0';
73         if (!self.dest)
74                 self.dest = '0 0 -300';
75         self.angles = '0 0 0';
76         self.movetype = MOVETYPE_NONE;
77         self.solid = SOLID_NOT;
78         SetBrushEntityModel();
79         if (!self.cnt)
80                 self.cnt = 12;
81         if (!self.count)
82                 self.count = 2000;
83         self.count = 0.01 * self.count * (self.size_x / 1024) * (self.size_y / 1024);
84         if (self.count < 1)
85                 self.count = 1;
86         if(self.count > 65535)
87                 self.count = 65535;
88
89         self.state = 0; // 1 is rain, 0 is snow
90         self.Version = 1;
91
92         Net_LinkEntity(self, false, 0, rainsnow_SendEntity);
93 }
94 #elif defined(CSQC)
95 void Draw_Rain(entity this)
96 {
97     te_particlerain(self.origin + self.mins, self.origin + self.maxs, self.velocity, floor(self.count * drawframetime + random()), self.glow_color);
98 }
99
100 void Draw_Snow(entity this)
101 {
102     te_particlesnow(self.origin + self.mins, self.origin + self.maxs, self.velocity, floor(self.count * drawframetime + random()), self.glow_color);
103 }
104
105 NET_HANDLE(ENT_CLIENT_RAINSNOW, bool isnew)
106 {
107         self.impulse = ReadByte(); // Rain, Snow, or Whatever
108         self.origin_x = ReadCoord();
109         self.origin_y = ReadCoord();
110         self.origin_z = ReadCoord();
111         self.maxs_x = ReadCoord();
112         self.maxs_y = ReadCoord();
113         self.maxs_z = ReadCoord();
114         self.velocity = decompressShortVector(ReadShort());
115         self.count = ReadShort() * 10;
116         self.glow_color = ReadByte(); // color
117
118         return = true;
119
120         self.mins    = -0.5 * self.maxs;
121         self.maxs    =  0.5 * self.maxs;
122         self.origin  = self.origin - self.mins;
123
124         setorigin(self, self.origin);
125         setsize(self, self.mins, self.maxs);
126         self.solid = SOLID_NOT;
127         if(self.impulse)
128                 self.draw = Draw_Rain;
129         else
130                 self.draw = Draw_Snow;
131 }
132 #endif