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

Function StartPlayerDeath

Descent3/Player.cpp:2115–2251  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2113// Starts player death sequence.
2114
2115void StartPlayerDeath(int slot, float damage, bool melee, int fate) {
2116 int objnum;
2117 object *playerobj = &Objects[Players[slot].objnum];
2118 int killer_num = Players[playerobj->id].killer_objnum;
2119 object *killer;
2120
2121 ASSERT(slot >= 0 && slot < MAX_PLAYERS);
2122
2123 Players[playerobj->id].num_deaths_level++;
2124 Players[playerobj->id].num_deaths_total++;
2125 // Do killer object stuff
2126 if (killer_num < 0 || killer_num > MAX_OBJECTS)
2127 killer = NULL;
2128 else {
2129 killer = &Objects[killer_num];
2130 if (killer->type == OBJ_NONE)
2131 killer = NULL;
2132 }
2133
2134 // determine current state of player object.
2135 // create death camera if it doesn't exit
2136 if (slot == Player_num) {
2137 objnum = ObjCreate(OBJ_CAMERA, 0, playerobj->roomnum, &playerobj->pos, &playerobj->orient);
2138 if (objnum == -1) {
2139 mprintf(0, "Failed to create death cam.\n");
2140 Int3();
2141 } else {
2142 Death[slot].camera = &Objects[objnum];
2143 if (Objects[objnum].type == OBJ_NONE)
2144 Int3(); // Samir- This really shouldn't happen. will cause assertion
2145 }
2146
2147 Death[slot].oldviewer = Viewer_object;
2148
2149 // set screen mode
2150 if (Cinematic_inuse) {
2151 Death[slot].saved_cockpit = Cinematic_GetOldHudMode();
2152 } else {
2153 Death[slot].saved_cockpit = GetHUDMode();
2154 }
2155
2156 Death[slot].in_cockpit = true;
2157 }
2158
2159 // save player ship information that will be changed here.
2160 Death[slot].saved_ctrl_type = playerobj->control_type;
2161 Death[slot].saved_phys_flags = playerobj->mtype.phys_info.flags;
2162 Death[slot].saved_drag = playerobj->mtype.phys_info.drag;
2163 Death[slot].saved_player_modelnum = playerobj->rtype.pobj_info.model_num;
2164 Death[slot].saved_rotthrust = playerobj->mtype.phys_info.rotthrust;
2165 Death[slot].breakup_count = 0;
2166
2167 if (killer == NULL) // If the killer isn't valid, just use the reverse forward direction
2168 Death[slot].force_dir = -playerobj->orient.fvec;
2169 else
2170 Death[slot].force_dir = playerobj->pos - killer->pos;
2171
2172 vm_NormalizeVector(&Death[slot].force_dir);

Callers 1

InitiatePlayerDeathFunction · 0.85

Calls 7

ObjCreateFunction · 0.85
Cinematic_GetOldHudModeFunction · 0.85
GetHUDModeFunction · 0.85
vm_NormalizeVectorFunction · 0.85
PlayerChooseDeathFateFunction · 0.85
GetPolymodelPointerFunction · 0.85
SetObjectControlTypeFunction · 0.85

Tested by

no test coverage detected