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

Function collide_generic_and_player

physics/collide.cpp:2067–2145  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2065}
2066
2067void collide_generic_and_player(object *robotobj, object *playerobj, vector *collision_point, vector *collision_normal,
2068 bool f_reverse_normal, fvi_info *hit_info) {
2069 if (f_reverse_normal)
2070 *collision_normal *= -1.0f;
2071
2072 vector rvel;
2073 if (robotobj->movement_type == MT_PHYSICS || robotobj->movement_type == MT_WALKING) {
2074 rvel = robotobj->mtype.phys_info.velocity;
2075 } else {
2076 rvel = Zero_vector;
2077 }
2078 rvel -= playerobj->mtype.phys_info.velocity;
2079 float speed = vm_NormalizeVector(&rvel);
2080 float scalar;
2081
2082 if (speed <= MIN_WALL_HIT_SOUND_VEL) {
2083 scalar = 0.0f;
2084 } else if (speed >= MAX_WALL_HIT_SOUND_VEL) {
2085 scalar = 1.0f;
2086 } else {
2087 scalar = (speed - MIN_WALL_HIT_SOUND_VEL) / (MAX_WALL_HIT_SOUND_VEL - MIN_WALL_HIT_SOUND_VEL);
2088 }
2089
2090 // Check for lava surface on an object
2091 if ((robotobj->type == OBJ_BUILDING) && hit_info) {
2092 poly_model *pm = GetPolymodelPointer(robotobj->rtype.pobj_info.model_num);
2093 int tmap = pm->textures[pm->submodel[hit_info->hit_subobject[0]].faces[hit_info->hit_face[0]].texnum];
2094
2095 if (GameTextures[tmap].flags & TF_LAVA) {
2096 if (!((Game_mode & GM_MULTI) && (Netgame.local_role == LR_CLIENT))) {
2097 int id = FindWeaponName("NapalmBlob");
2098 if (id >= 0)
2099 SetNapalmDamageEffect(playerobj, nullptr, id);
2100 else
2101 Int3();
2102 }
2103 scalar = 0; // don't make collide sound
2104 }
2105 }
2106
2107 if (scalar > .01 || (robotobj->mtype.phys_info.flags & PF_LOCK_MASK)) {
2108 pos_state cur_pos;
2109 cur_pos.position = collision_point;
2110 cur_pos.orient = &playerobj->orient;
2111 cur_pos.roomnum = playerobj->roomnum;
2112
2113 Sound_system.Play3dSound(SOUND_PLAYER_HIT_WALL, SND_PRIORITY_HIGHEST, &cur_pos, MAX_GAME_VOLUME * scalar);
2114
2115 ain_hear hear;
2116 hear.f_directly_player = true;
2117 hear.hostile_level = 0.10f;
2118 hear.curiosity_level = 0.5f;
2119 hear.max_dist = Sounds[SOUND_PLAYER_HIT_WALL].max_distance * scalar;
2120 AINotify(playerobj, AIN_HEAR_NOISE, (void *)&hear);
2121
2122 if ((scalar > .25f && (robotobj->movement_type == MT_WALKING || robotobj->movement_type == MT_PHYSICS)) ||
2123 ((robotobj->mtype.phys_info.flags & PF_LOCK_MASK) &&
2124 (robotobj->mtype.phys_info.flags & PF_POINT_COLLIDE_WALLS))) {

Callers

nothing calls this directly

Calls 9

vm_NormalizeVectorFunction · 0.85
GetPolymodelPointerFunction · 0.85
FindWeaponNameFunction · 0.85
SetNapalmDamageEffectFunction · 0.85
AINotifyFunction · 0.85
ApplyDamageToGenericFunction · 0.85
ApplyDamageToPlayerFunction · 0.85
Play3dSoundMethod · 0.80
bump_two_objectsFunction · 0.70

Tested by

no test coverage detected