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

Function collide_weapon_and_wall

physics/collide.cpp:1087–1261  ·  view source on GitHub ↗

Process a collision between a weapon and a wall Returns true if the weapon hits the wall, and false if should keep going though the wall (for breakable glass)

Source from the content-addressed store, hash-verified

1085// Process a collision between a weapon and a wall
1086// Returns true if the weapon hits the wall, and false if should keep going though the wall (for breakable glass)
1087bool collide_weapon_and_wall(object *weapon, fix hitspeed, int hitseg, int hitwall, vector *hitpnt, vector *wall_normal,
1088 float hit_dot) {
1089 bool f_forcefield;
1090 bool f_volatile, f_lava, f_water;
1091 // mprintf(0, "Weapon hit wall, how nice.\n");
1092
1093 // #ifndef RELEASE
1094 if ((stricmp(Weapons[weapon->id].name, "Yellow flare") == 0) && (weapon->parent_handle == Player_object->handle) &&
1095 (KEY_STATE(KEY_LAPOSTRO))) {
1096 if (ROOMNUM_OUTSIDE(hitseg)) {
1097 AddHUDMessage("Terrain cell %d", CELLNUM(hitseg));
1098 } else {
1099 AddHUDMessage("Room %d face %d", hitseg, hitwall);
1100 }
1101 }
1102 // #endif
1103
1104 // Check if forcefield
1105 int tmap;
1106 if (!ROOMNUM_OUTSIDE(hitseg)) // Make sure we've hit a wall, and not terrain
1107 {
1108 tmap = Rooms[hitseg].faces[hitwall].tmap;
1109 } else {
1110 tmap = Terrain_tex_seg[Terrain_seg[CELLNUM(hitseg)].texseg_index].tex_index;
1111 }
1112 f_forcefield = (GameTextures[tmap].flags & TF_FORCEFIELD) != 0;
1113 f_volatile = (GameTextures[tmap].flags & TF_VOLATILE) != 0;
1114 f_lava = (GameTextures[tmap].flags & TF_LAVA) != 0;
1115 f_water = (GameTextures[tmap].flags & TF_WATER) != 0;
1116
1117 if (f_forcefield && !(Weapons[weapon->id].flags & WF_MATTER_WEAPON)) {
1118 ain_hear hear;
1119 hear.f_directly_player = false;
1120 hear.hostile_level = 0.9f;
1121 hear.curiosity_level = 0.1f;
1122
1123 if (sound_override_force_field == -1)
1124 hear.max_dist = Sounds[SOUND_FORCEFIELD_BOUNCE].max_distance;
1125 else
1126 hear.max_dist = Sounds[sound_override_force_field].max_distance;
1127
1128 AINotify(weapon, AIN_HEAR_NOISE, (void *)&hear);
1129
1130 if (sound_override_force_field == -1)
1131 Sound_system.Play3dSound(SOUND_FORCEFIELD_BOUNCE, SND_PRIORITY_HIGH, weapon);
1132 else
1133 Sound_system.Play3dSound(sound_override_force_field, SND_PRIORITY_HIGH, weapon);
1134
1135 return true;
1136 }
1137
1138 // Check for destroyable or breakable face
1139 if (!ROOMNUM_OUTSIDE(hitseg)) // First, make sure we've hit a wall, and not terrain
1140 {
1141 room *rp = &Rooms[hitseg];
1142 face *fp = &rp->faces[hitwall];
1143
1144 // Check for a trigger on this wall

Callers 1

collide_object_with_wallFunction · 0.85

Calls 15

AddHUDMessageFunction · 0.85
AINotifyFunction · 0.85
CheckTriggerFunction · 0.85
CreateFireballFunction · 0.85
ps_randFunction · 0.85
CreateRandomSparksFunction · 0.85
BreakGlassFaceFunction · 0.85
AddScorchFunction · 0.85
DeformTerrainFunction · 0.85
DoWallEffectsFunction · 0.85

Tested by

no test coverage detected