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

Function DoWallEffects

physics/collide.cpp:979–1042  ·  view source on GitHub ↗

Creates some effects where a weapon has collided with a wall

Source from the content-addressed store, hash-verified

977
978// Creates some effects where a weapon has collided with a wall
979void DoWallEffects(object *weapon, int surface_tmap) {
980 texture *texp = &GameTextures[surface_tmap];
981
982 if (texp->flags & (TF_VOLATILE + TF_LAVA + TF_WATER)) {
983 // Create some lava steam
984 if ((texp->flags & TF_WATER) || ((ps_rand() % 4) == 0)) {
985 int visnum = VisEffectCreate(VIS_FIREBALL, MED_SMOKE_INDEX, weapon->roomnum, &weapon->pos);
986 if (visnum >= 0) {
987 vis_effect *vis = &VisEffects[visnum];
988
989 vis->lifetime = .9f;
990 vis->lifeleft = .9f;
991
992 vis->movement_type = MT_PHYSICS;
993 vis->size = 3.0;
994 vm_MakeZero(&vis->velocity);
995 vis->velocity.y = 10;
996 }
997 }
998 } else if (texp->flags & TF_RUBBLE) {
999 if ((ps_rand() % 4) == 0) {
1000 int num_rubble = (ps_rand() % 3) + 1;
1001 int bm_handle = GetTextureBitmap(texp - GameTextures, 0);
1002 uint16_t *data = bm_data(bm_handle, 0);
1003
1004 uint16_t color = data[(bm_w(bm_handle, 0) * (bm_h(bm_handle, 0) / 2)) + (bm_w(bm_handle, 0) / 2)];
1005
1006 for (int i = 0; i < num_rubble; i++) {
1007 int visnum;
1008
1009 visnum = VisEffectCreate(VIS_FIREBALL, RUBBLE1_INDEX + (ps_rand() % 2), weapon->roomnum, &weapon->pos);
1010
1011 if (visnum >= 0) {
1012 vis_effect *vis = &VisEffects[visnum];
1013
1014 vis->movement_type = MT_PHYSICS;
1015 vis->mass = 100;
1016 vis->drag = .1f;
1017
1018 vis->phys_flags |= PF_GRAVITY | PF_NO_COLLIDE;
1019
1020 if ((ps_rand() % 3) == 0) {
1021 vis->velocity.x = (ps_rand() % 100) - 50;
1022 vis->velocity.y = -((ps_rand() % 200) - 30);
1023 vis->velocity.z = (ps_rand() % 100) - 50;
1024 } else {
1025 vis->velocity.x = (ps_rand() % 300) - 50;
1026 vis->velocity.y = -((ps_rand() % 200) - 30);
1027 vis->velocity.z = (ps_rand() % 300) - 50;
1028 }
1029
1030 vm_NormalizeVectorFast(&vis->velocity);
1031 vis->velocity *= 4 + (ps_rand() % 20);
1032 vis->size = .5 + (((ps_rand() % 11) - 5) * .05);
1033 vis->flags |= VF_USES_LIFELEFT;
1034 float lifetime = 1.0 + (((ps_rand() % 11) - 5) * .1);
1035 vis->lifeleft = lifetime;
1036 vis->lifetime = lifetime;

Callers 2

collide_weapon_and_wallFunction · 0.85

Calls 8

ps_randFunction · 0.85
VisEffectCreateFunction · 0.85
vm_MakeZeroFunction · 0.85
GetTextureBitmapFunction · 0.85
bm_dataFunction · 0.85
bm_wFunction · 0.85
bm_hFunction · 0.85
vm_NormalizeVectorFastFunction · 0.85

Tested by

no test coverage detected