Figure out how long it will take the dying anim to play
| 1142 | |
| 1143 | // Figure out how long it will take the dying anim to play |
| 1144 | float GetDeathAnimTime(object *objp) { |
| 1145 | float death_time = 0.0; |
| 1146 | |
| 1147 | if (objp->control_type == CT_AI) { |
| 1148 | |
| 1149 | ASSERT(IS_GENERIC(objp->type)); |
| 1150 | |
| 1151 | if (Object_info[objp->id].anim[objp->ai_info->movement_type].elem[AS_DEATH].to != 0) { |
| 1152 | |
| 1153 | // calculate how long for the object to finish its current animation before starting death anim |
| 1154 | float extra_time = objp->rtype.pobj_info.anim_time * |
| 1155 | (objp->rtype.pobj_info.anim_end_frame - objp->rtype.pobj_info.anim_frame) / |
| 1156 | (objp->rtype.pobj_info.anim_end_frame - objp->rtype.pobj_info.anim_start_frame); |
| 1157 | extra_time = std::min<float>(extra_time, 3.0); // limit extra time to 3 seconds |
| 1158 | mprintf(0, "extra_time = %2f\n", extra_time); |
| 1159 | |
| 1160 | death_time = Object_info[objp->id].anim[objp->ai_info->movement_type].elem[AS_DEATH].spc + 0.25 + extra_time; |
| 1161 | } |
| 1162 | } |
| 1163 | |
| 1164 | return death_time; |
| 1165 | } |
| 1166 | |
| 1167 | // Kill an object |
| 1168 | // The caller can specify death information; if none is specified, a default death will be used. |