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