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

Function ClearPlayerFiring

Descent3/WeaponFire.cpp:2754–2792  ·  view source on GitHub ↗

Called when a player dies or switches weapons to clear out any active weapon stuff

Source from the content-addressed store, hash-verified

2752
2753// Called when a player dies or switches weapons to clear out any active weapon stuff
2754void ClearPlayerFiring(object *objp, int weapon_type) {
2755 // Check parms
2756 ASSERT(objp->type == OBJ_PLAYER);
2757 // ASSERT(objp->id == Player_num);
2758
2759 // Set up various vars
2760 player *player = &Players[objp->id];
2761 player_weapon *pw = &player->weapon[weapon_type];
2762
2763 // Clear firing flags
2764 if (objp->weapon_fire_flags & WFF_ON_OFF)
2765 StopOnOffWeapon(objp);
2766
2767 // Clear firing time
2768 pw->firing_time = 0.0;
2769 objp->weapon_fire_flags = 0;
2770 if (Demo_flags == DF_RECORDING) {
2771 DemoWriteObjWeapFireFlagChanged(OBJNUM(objp));
2772 }
2773
2774 // Clear zoom if there is one
2775 if (objp->id == Player_num) {
2776 player_weapon *pw = &player->weapon[weapon_type];
2777 int weapon_battery_index = pw->index;
2778 ship *ship = &Ships[player->ship_index];
2779
2780 if (ship->fire_flags[weapon_battery_index] & SFF_ZOOM) {
2781 DoZoomEffect(pw, 1);
2782 Players[Player_num].flags &= ~PLAYER_FLAGS_ZOOMED;
2783 Zoom_fov_time = 0;
2784 }
2785 }
2786
2787 // Stop firing sound if one playing
2788 if (pw->sound_handle != -1) {
2789 Sound_system.StopSoundImmediate(pw->sound_handle);
2790 pw->sound_handle = -1;
2791 }
2792}
2793
2794// Stops weapon sound & visual effects
2795void StopWeapon(object *obj, player_weapon *pw, otype_wb_info *wb) {

Callers 5

SetPrimaryWeaponFunction · 0.85
SetSecondaryWeaponFunction · 0.85
InitiatePlayerDeathFunction · 0.85

Calls 4

StopOnOffWeaponFunction · 0.85
DoZoomEffectFunction · 0.85
StopSoundImmediateMethod · 0.80

Tested by

no test coverage detected