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

Function CreateRandomParticles

Descent3/viseffect.cpp:898–931  ·  view source on GitHub ↗

Creates a some particles that go in random directions

Source from the content-addressed store, hash-verified

896
897// Creates a some particles that go in random directions
898void CreateRandomParticles(int num_sparks, vector *pos, int roomnum, int bm_handle, float size, float life) {
899 // Create some sparks
900 float tenth_life = life / 10.0;
901 float tenth_size = size / 10.0;
902
903 for (int i = 0; i < num_sparks; i++) {
904 int sparknum;
905
906 sparknum = VisEffectCreate(VIS_FIREBALL, PARTICLE_INDEX, roomnum, pos);
907
908 if (sparknum >= 0) {
909 vis_effect *vis = &VisEffects[sparknum];
910
911 vis->movement_type = MT_PHYSICS;
912 vis->mass = 100;
913 vis->drag = .1f;
914
915 vis->phys_flags |= PF_GRAVITY | PF_NO_COLLIDE;
916
917 vis->velocity.x = (ps_rand() % 100) - 50;
918 vis->velocity.y = (ps_rand() % 100);
919 vis->velocity.z = (ps_rand() % 100) - 50;
920
921 vm_NormalizeVectorFast(&vis->velocity);
922 vis->velocity *= 10 + (ps_rand() % 10);
923 vis->size = size + (((ps_rand() % 11) - 5) * tenth_size);
924 vis->flags |= VF_USES_LIFELEFT;
925 float lifetime = life + (((ps_rand() % 11) - 5) * tenth_life);
926 vis->lifeleft = lifetime;
927 vis->lifetime = lifetime;
928 vis->custom_handle = bm_handle;
929 }
930 }
931}
932
933// Draws a weapons fading line
934void DrawVisFadingLine(vis_effect *vis) {

Callers 1

WeaponDoFrameFunction · 0.85

Calls 3

VisEffectCreateFunction · 0.85
ps_randFunction · 0.85
vm_NormalizeVectorFastFunction · 0.85

Tested by

no test coverage detected