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

Function CreateRandomLineSparks

Descent3/viseffect.cpp:813–849  ·  view source on GitHub ↗

Creates a some sparks that go in random directions

Source from the content-addressed store, hash-verified

811
812// Creates a some sparks that go in random directions
813void CreateRandomLineSparks(int num_sparks, vector *pos, int roomnum, uint16_t color, float force_scalar) {
814 // Make more sparks if Katmai
815 if (Katmai)
816 num_sparks *= 2;
817
818 // Create some sparks
819 for (int i = 0; i < num_sparks; i++) {
820 int visnum = VisEffectCreate(VIS_FIREBALL, FADING_LINE_INDEX, roomnum, pos);
821 if (visnum >= 0) {
822 vis_effect *vis = &VisEffects[visnum];
823
824 vis->movement_type = MT_PHYSICS;
825 vis->mass = 500;
826 vis->drag = .001f;
827 vis->phys_flags |= PF_GRAVITY | PF_NO_COLLIDE;
828
829 vis->velocity.x = (ps_rand() % 100) - 50;
830 vis->velocity.y = (ps_rand() % 100);
831 vis->velocity.z = (ps_rand() % 100) - 50;
832
833 vm_NormalizeVectorFast(&vis->velocity);
834
835 vis->velocity *= 20 + (ps_rand() % 10);
836 vis->velocity *= force_scalar;
837 vis->size = .7 + ((ps_rand() % 10) * .04);
838 vis->flags |= VF_USES_LIFELEFT;
839 float lifetime = 1 + ((ps_rand() % 10) * .15);
840 vis->lifeleft = lifetime;
841 vis->lifetime = lifetime;
842
843 if (color == 0)
844 vis->lighting_color = GR_RGB16(200 + (ps_rand() % 50), 150 + (ps_rand() % 50), ps_rand() % 50);
845 else
846 vis->lighting_color = color;
847 }
848 }
849}
850
851// Creates a some sparks that go in random directions
852void CreateRandomSparks(int num_sparks, vector *pos, int roomnum, int which_index, float force_scalar) {

Callers 1

Calls 4

VisEffectCreateFunction · 0.85
ps_randFunction · 0.85
vm_NormalizeVectorFastFunction · 0.85
GR_RGB16Function · 0.85

Tested by

no test coverage detected