]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/func/rainsnow.qc
Merge branch 'terencehill/v_deathtilt_fix' into 'master'
[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, this.state);
8         WriteCoord(MSG_ENTITY, this.origin_x + this.mins_x);
9         WriteCoord(MSG_ENTITY, this.origin_y + this.mins_y);
10         WriteCoord(MSG_ENTITY, this.origin_z + this.mins_z);
11         WriteCoord(MSG_ENTITY, this.maxs_x - this.mins_x);
12         WriteCoord(MSG_ENTITY, this.maxs_y - this.mins_y);
13         WriteCoord(MSG_ENTITY, this.maxs_z - this.mins_z);
14         WriteShort(MSG_ENTITY, compressShortVector(this.dest));
15         WriteShort(MSG_ENTITY, this.count);
16         WriteByte(MSG_ENTITY, this.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         this.dest = this.velocity;
34         this.velocity = '0 0 0';
35         if (!this.dest)
36                 this.dest = '0 0 -700';
37         this.angles = '0 0 0';
38         this.movetype = MOVETYPE_NONE;
39         this.solid = SOLID_NOT;
40         SetBrushEntityModel();
41         if (!this.cnt)
42                 this.cnt = 12;
43         if (!this.count)
44                 this.count = 2000;
45         this.count = 0.01 * this.count * (this.size_x / 1024) * (this.size_y / 1024);
46         if (this.count < 1)
47                 this.count = 1;
48         if(this.count > 65535)
49                 this.count = 65535;
50
51         this.state = 1; // 1 is rain, 0 is snow
52         this.Version = 1;
53
54         Net_LinkEntity(this, 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         this.dest = this.velocity;
72         this.velocity = '0 0 0';
73         if (!this.dest)
74                 this.dest = '0 0 -300';
75         this.angles = '0 0 0';
76         this.movetype = MOVETYPE_NONE;
77         this.solid = SOLID_NOT;
78         SetBrushEntityModel();
79         if (!this.cnt)
80                 this.cnt = 12;
81         if (!this.count)
82                 this.count = 2000;
83         this.count = 0.01 * this.count * (this.size_x / 1024) * (this.size_y / 1024);
84         if (this.count < 1)
85                 this.count = 1;
86         if(this.count > 65535)
87                 this.count = 65535;
88
89         this.state = 0; // 1 is rain, 0 is snow
90         this.Version = 1;
91
92         Net_LinkEntity(this, false, 0, rainsnow_SendEntity);
93 }
94 #elif defined(CSQC)
95 void Draw_Rain(entity this)
96 {
97     te_particlerain(this.origin + this.mins, this.origin + this.maxs, this.velocity, floor(this.count * drawframetime + random()), this.glow_color);
98 }
99
100 void Draw_Snow(entity this)
101 {
102     te_particlesnow(this.origin + this.mins, this.origin + this.maxs, this.velocity, floor(this.count * drawframetime + random()), this.glow_color);
103 }
104
105 NET_HANDLE(ENT_CLIENT_RAINSNOW, bool isnew)
106 {
107         this.impulse = ReadByte(); // Rain, Snow, or Whatever
108         this.origin_x = ReadCoord();
109         this.origin_y = ReadCoord();
110         this.origin_z = ReadCoord();
111         this.maxs_x = ReadCoord();
112         this.maxs_y = ReadCoord();
113         this.maxs_z = ReadCoord();
114         this.velocity = decompressShortVector(ReadShort());
115         this.count = ReadShort() * 10;
116         this.glow_color = ReadByte(); // color
117
118         return = true;
119
120         this.mins    = -0.5 * this.maxs;
121         this.maxs    =  0.5 * this.maxs;
122         this.origin  = this.origin - this.mins;
123
124         setorigin(this, this.origin);
125         setsize(this, this.mins, this.maxs);
126         this.solid = SOLID_NOT;
127         if(this.impulse)
128                 this.draw = Draw_Rain;
129         else
130                 this.draw = Draw_Snow;
131 }
132 #endif