MCPcopy Create free account
hub / github.com/DescentDevelopers/Descent3 / DoSnowEffect

Function DoSnowEffect

Descent3/weather.cpp:172–228  ·  view source on GitHub ↗

Creates snow for this frame

Source from the content-addressed store, hash-verified

170
171// Creates snow for this frame
172void DoSnowEffect() {
173 if (OBJECT_OUTSIDE(Viewer_object)) {
174 int num = 20 + (ps_rand() % 15);
175
176 if (Weather.snowflakes_to_create + num > 250) {
177 num = 250 - Weather.snowflakes_to_create;
178
179 if (num < 1) {
180 Weather.snowflakes_to_create = 0;
181 return;
182 }
183 }
184
185 // angvec angs;
186 matrix mat;
187
188 // vm_ExtractAnglesFromMatrix (&angs,&Viewer_object->orient);
189 // vm_AnglesToMatrix (&mat,0,angs.h,0);
190
191 mat = Viewer_object->orient;
192
193 for (int i = 0; i < num; i++) {
194 vector pos = Viewer_object->pos;
195
196 float z = ((ps_rand() % 1000) / 1000.0) * 300;
197 float x = (((ps_rand() % 1000) - 500) / 500.0) * 200;
198 int y = (ps_rand() % 80);
199
200 pos += x * mat.rvec;
201 pos += y * mat.uvec;
202 pos += z * mat.fvec;
203
204 if (pos.z < 0 || pos.z >= TERRAIN_DEPTH * TERRAIN_SIZE)
205 continue;
206 if (pos.x < 0 || pos.x >= TERRAIN_WIDTH * TERRAIN_SIZE)
207 continue;
208
209 // Create falling rain
210 vector down_vec = {0, -30, 0};
211 int visnum = VisEffectCreate(VIS_FIREBALL, SNOWFLAKE_INDEX, Viewer_object->roomnum, &pos);
212 if (visnum >= 0) {
213 vis_effect *vis = &VisEffects[visnum];
214 float life = 1.5 + ((ps_rand() % 100) / 100.0);
215 vis->lifeleft = life;
216 vis->lifetime = life;
217 vis->lighting_color = GR_RGB16(200, 200, (ps_rand() % 50) + 200);
218 vis->size = ((ps_rand() % 1000) / 1000.0) + .5;
219
220 vis->flags |= VF_WINDSHIELD_EFFECT | VF_USES_LIFELEFT;
221
222 vis->velocity = down_vec;
223 }
224 }
225 }
226
227 Weather.snowflakes_to_create = 0;
228}
229

Callers 1

DoWeatherForFrameFunction · 0.85

Calls 3

ps_randFunction · 0.85
VisEffectCreateFunction · 0.85
GR_RGB16Function · 0.85

Tested by

no test coverage detected