| 2280 | } |
| 2281 | |
| 2282 | void collide_player_and_weapon(object *playerobj, object *weapon, vector *collision_point, vector *collision_normal, |
| 2283 | bool f_reverse_normal, fvi_info *hit_info) { |
| 2284 | object *parent_obj; |
| 2285 | float damage_to_apply; |
| 2286 | uint8_t electrical = Weapons[weapon->id].flags & WF_ELECTRICAL ? 1 : 0; |
| 2287 | bool f_stick = ((weapon->mtype.phys_info.flags & PF_STICK) != 0); |
| 2288 | |
| 2289 | if (f_reverse_normal) |
| 2290 | *collision_normal *= -1.0f; |
| 2291 | |
| 2292 | parent_obj = ObjGet(weapon->parent_handle); |
| 2293 | |
| 2294 | if ((parent_obj) && (parent_obj->control_type == CT_AI)) { |
| 2295 | AINotify(parent_obj, AIN_WHIT_OBJECT, (void *)playerobj); |
| 2296 | } |
| 2297 | |
| 2298 | // Do weapon explosion stuff |
| 2299 | DoWeaponExploded(weapon, collision_normal, collision_point, playerobj); |
| 2300 | |
| 2301 | // Check to see if we should spawn |
| 2302 | /*if ((Weapons[weapon->id].flags & WF_SPAWNS_IMPACT) && Weapons[weapon->id].spawn_count>0 && |
| 2303 | Weapons[weapon->id].spawn_handle>=0) CreateImpactSpawnFromWeapon (weapon,collision_normal);*/ |
| 2304 | |
| 2305 | if ((Weapons[weapon->id].flags & WF_SPAWNS_ROBOT) && (Weapons[weapon->id].flags & WF_COUNTERMEASURE) && |
| 2306 | Weapons[weapon->id].robot_spawn_handle >= 0) |
| 2307 | CreateRobotSpawnFromWeapon(weapon); |
| 2308 | |
| 2309 | if (electrical) |
| 2310 | damage_to_apply = Weapons[weapon->id].player_damage * Frametime; |
| 2311 | else |
| 2312 | damage_to_apply = Weapons[weapon->id].player_damage; |
| 2313 | |
| 2314 | // Factor in multiplier |
| 2315 | damage_to_apply *= weapon->ctype.laser_info.multiplier; |
| 2316 | |
| 2317 | int damage_type = electrical ? PD_ENERGY_WEAPON : PD_MATTER_WEAPON; |
| 2318 | |
| 2319 | if (ApplyDamageToPlayer(playerobj, weapon, damage_type, damage_to_apply)) { |
| 2320 | // we were damaged! |
| 2321 | if (Weapons[weapon->id].sounds[WSI_IMPACT_ROBOT] != SOUND_NONE_INDEX) |
| 2322 | Sound_system.Play3dSound(Weapons[weapon->id].sounds[WSI_IMPACT_ROBOT], SND_PRIORITY_NORMAL, weapon); |
| 2323 | } |
| 2324 | #if 0 |
| 2325 | if(Demo_flags == DF_RECORDING) |
| 2326 | { |
| 2327 | DemoWriteCollidePlayerWeapon( playerobj, weapon, collision_point, collision_normal, f_reverse_normal, hit_info ); |
| 2328 | } |
| 2329 | else if(Demo_flags == DF_PLAYBACK) |
| 2330 | { |
| 2331 | //During playback we don't need the code below (actually it won't work) |
| 2332 | return; |
| 2333 | } |
| 2334 | #endif |
| 2335 | |
| 2336 | if (!electrical) { |
| 2337 | bump_two_objects(playerobj, weapon, collision_point, collision_normal, 0); |
| 2338 | |
| 2339 | if (!f_stick || (hit_info == nullptr)) { |
no test coverage detected