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

Function CreateRandomSparks

Descent3/viseffect.cpp:852–895  ·  view source on GitHub ↗

Creates a some sparks that go in random directions

Source from the content-addressed store, hash-verified

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) {
853 // Make more sparks if Katmai
854 if (Katmai)
855 num_sparks *= 2;
856
857 // Create some sparks
858 for (int i = 0; i < num_sparks; i++) {
859 int sparknum;
860 int index;
861
862 if (ps_rand() % 2)
863 index = HOT_SPARK_INDEX;
864 else
865 index = COOL_SPARK_INDEX;
866
867 if (which_index != -1)
868 index = which_index;
869
870 sparknum = VisEffectCreate(VIS_FIREBALL, index, roomnum, pos);
871
872 if (sparknum >= 0) {
873 vis_effect *vis = &VisEffects[sparknum];
874
875 vis->movement_type = MT_PHYSICS;
876 vis->mass = 100;
877 vis->drag = .1f;
878
879 vis->phys_flags |= PF_GRAVITY | PF_NO_COLLIDE;
880
881 vis->velocity.x = (ps_rand() % 100) - 50;
882 vis->velocity.y = (ps_rand() % 100);
883 vis->velocity.z = (ps_rand() % 100) - 50;
884
885 vm_NormalizeVectorFast(&vis->velocity);
886 vis->velocity *= 10 + (ps_rand() % 10);
887 vis->velocity *= force_scalar;
888 vis->size = .2 + ((ps_rand() % 10) * .01);
889 vis->flags |= VF_USES_LIFELEFT;
890 float lifetime = 1 + ((ps_rand() % 10) * .15);
891 vis->lifeleft = lifetime;
892 vis->lifetime = lifetime;
893 }
894 }
895}
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) {

Callers 10

collide_weapon_and_wallFunction · 0.85
osipf_CreateRandomSparksFunction · 0.85
MultiDoObjectFunction · 0.85
MultiSendObjectFunction · 0.85
CreateExtraFireballsFunction · 0.85
DoGravityFieldEffectFunction · 0.85
DoExplosionFrameFunction · 0.85
DrawElectricalWeaponFunction · 0.85
PlayerShipExplodeFunction · 0.85
PlayerSwitchToObserverFunction · 0.85

Calls 3

ps_randFunction · 0.85
VisEffectCreateFunction · 0.85
vm_NormalizeVectorFastFunction · 0.85

Tested by

no test coverage detected