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

Function PlayerChooseDeathFate

Descent3/Player.cpp:2078–2110  ·  view source on GitHub ↗

Chooses the style of death a player is going to use

Source from the content-addressed store, hash-verified

2076
2077// Chooses the style of death a player is going to use
2078int PlayerChooseDeathFate(int slot, float damage, bool melee) {
2079 int fate;
2080 bool is_moving;
2081 object *playerobj = &Objects[Players[slot].objnum];
2082
2083 ASSERT(slot >= 0 && slot < MAX_PLAYERS);
2084
2085 if (vm_GetMagnitude(&playerobj->mtype.phys_info.velocity))
2086 is_moving = true;
2087 else
2088 is_moving = false;
2089
2090 fate = (damage <= DEATH_BREAKUP_THRESHOLD && is_moving && !melee && OBJECT_OUTSIDE(playerobj)) ? DEATH_BREAKUP
2091 : (damage <= DEATH_EXPLODE_THRESHOLD || melee) ? DEATH_FALL
2092 : DEATH_INSTANT;
2093
2094 if (fate == DEATH_BREAKUP) {
2095 if ((ps_rand() % 4) < 2)
2096 fate = DEATH_D2STYLE;
2097 } else if (fate == DEATH_FALL) {
2098 if ((ps_rand() % 4) != 3)
2099 fate = DEATH_D2STYLE;
2100 }
2101
2102 // split ship into subobjects. they should still be one object but now with several parts.
2103 if (playerobj->rtype.pobj_info.dying_model_num == -1) {
2104 if (fate == DEATH_BREAKUP) {
2105 fate = DEATH_FALL;
2106 }
2107 }
2108
2109 return fate;
2110}
2111
2112///////////////////////////////////////////////////////////////////////////////
2113// Starts player death sequence.

Callers 2

KillPlayerFunction · 0.85
StartPlayerDeathFunction · 0.85

Calls 2

ps_randFunction · 0.85
vm_GetMagnitudeFunction · 0.50

Tested by

no test coverage detected