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

Function KillObject

Descent3/damage.cpp:1036–1079  ·  view source on GitHub ↗

Applies a default death to an object Parameters: objp - the object to destroy killer - the object who is killing it, or NULL damage - how much damage was applied in the death blow?

Source from the content-addressed store, hash-verified

1034// killer - the object who is killing it, or NULL
1035// damage - how much damage was applied in the death blow?
1036void KillObject(object *objp, object *killer, float damage) {
1037 int death_flags = -1;
1038 float delay_time;
1039
1040 // Make sure a valid type
1041 ASSERT(IS_GENERIC(objp->type) || (objp->type == OBJ_DOOR));
1042
1043 // Bail if already dying or exploding
1044 if ((objp->flags & OF_DYING) || (objp->flags & OF_DEAD))
1045 return;
1046
1047 // Get death info from the object page
1048 if (IS_GENERIC(objp->type)) {
1049
1050 // Get random probability
1051 int r = (ps_rand() * 100 / (D3_RAND_MAX + 1)) + 1; // in range 1 to 100
1052
1053 // Loop through death types looking for chosen one
1054 for (int i = 0; i < MAX_DEATH_TYPES; i++) {
1055 int p = Object_info[objp->id].death_probabilities[i];
1056 if (r <= p) {
1057 float delay_min, delay_max;
1058
1059 death_flags = Object_info[objp->id].death_types[i].flags;
1060
1061 delay_min = Object_info[objp->id].death_types[i].delay_min;
1062 delay_max = Object_info[objp->id].death_types[i].delay_max;
1063
1064 delay_time = delay_min + (delay_max - delay_min) * ps_rand() / D3_RAND_MAX;
1065
1066 mprintf(0, "Using %d\n", i);
1067 break;
1068 }
1069 r -= p;
1070 }
1071 }
1072
1073 // If no death from page, generate default
1074 if (death_flags == -1)
1075 GenerateDefaultDeath(objp, &death_flags, &delay_time);
1076
1077 // Now kill the object
1078 KillObject(objp, killer, damage, death_flags, delay_time);
1079}
1080
1081// Sets the physics parameters for a falling object
1082void SetFallingPhysics(object *objp) {

Callers 5

osipf_ObjKillFunction · 0.85
MultiDoBlowupBuildingFunction · 0.85
MultiDoRobotExplodeFunction · 0.85
ApplyDamageToGenericFunction · 0.85
DemoReadKillObjectFunction · 0.85

Calls 15

ps_randFunction · 0.85
GenerateDefaultDeathFunction · 0.85
MultiSendKillObjectFunction · 0.85
ps_srandFunction · 0.85
DemoWriteKillObjectFunction · 0.85
DoorwayDestroyFunction · 0.85
GetDeathAnimTimeFunction · 0.85
CreateNewEventFunction · 0.85
PlayerScoreAddFunction · 0.85
DestroyObjectFunction · 0.85
SetObjectControlTypeFunction · 0.85
SetFallingPhysicsFunction · 0.85

Tested by

no test coverage detected