Fills in death info to roughly appoximate the deaths from the old explosion system
| 956 | |
| 957 | // Fills in death info to roughly appoximate the deaths from the old explosion system |
| 958 | void GenerateDefaultDeath(object *obj, int *death_flags, float *delay_time) { |
| 959 | // Set some defaults |
| 960 | *death_flags = 0; |
| 961 | *delay_time = 0.0; |
| 962 | |
| 963 | if ((obj->type != OBJ_ROBOT && !(obj->type == OBJ_BUILDING && obj->ai_info)) || |
| 964 | (obj->movement_type != MT_WALKING && ((ps_rand() % 3) != 0)) || |
| 965 | (obj->movement_type == MT_WALKING && ((ps_rand() % 10) > 5))) { |
| 966 | |
| 967 | // Quick death |
| 968 | *death_flags = 0; |
| 969 | *delay_time = 0.0; |
| 970 | |
| 971 | // Maybe set blast ring |
| 972 | if ((ps_rand() % 3) == 0) |
| 973 | *death_flags |= DF_BLAST_RING; |
| 974 | } else { // slow death |
| 975 | |
| 976 | int alternate_death = 0; |
| 977 | bool f_upsidedown_walker = (obj->movement_type == MT_WALKING) && (obj->orient.uvec.y < 0.0f); |
| 978 | |
| 979 | if (!f_upsidedown_walker && (ps_rand() % 2) == 1) { |
| 980 | *death_flags = DF_DELAY_SPARKS; |
| 981 | alternate_death = 1; |
| 982 | } |
| 983 | |
| 984 | if (obj->type == OBJ_ROBOT || (obj->type == OBJ_BUILDING && obj->ai_info)) { |
| 985 | if (alternate_death || (obj->movement_type != MT_PHYSICS && obj->movement_type != MT_WALKING) || |
| 986 | (obj->movement_type == MT_WALKING && !f_upsidedown_walker)) { |
| 987 | *death_flags = DF_DELAY_SPARKS; |
| 988 | *delay_time = 3.0f; |
| 989 | alternate_death = 1; |
| 990 | } else { |
| 991 | if (obj->movement_type != MT_WALKING) |
| 992 | *death_flags = 0; |
| 993 | else |
| 994 | *death_flags = DF_DELAY_LOSES_ANTIGRAV; |
| 995 | } |
| 996 | |
| 997 | // Alternate death must last 3 seconds to correspond with sound effect |
| 998 | // If you change this assumption, tell Jerry |
| 999 | if (!alternate_death && Object_info[obj->id].anim) { |
| 1000 | if (obj->control_type == CT_AI && |
| 1001 | Object_info[obj->id].anim[obj->ai_info->movement_type].elem[AS_DEATH].to != 0.0f) { |
| 1002 | // compute time remaining in current animation |
| 1003 | float extra_time = obj->rtype.pobj_info.anim_time * |
| 1004 | (obj->rtype.pobj_info.anim_end_frame - obj->rtype.pobj_info.anim_frame) / |
| 1005 | (obj->rtype.pobj_info.anim_end_frame - obj->rtype.pobj_info.anim_start_frame); |
| 1006 | extra_time = std::min<float>(extra_time, 3.0); // limit extra time to 3 seconds |
| 1007 | *delay_time = Object_info[obj->id].anim[obj->ai_info->movement_type].elem[AS_DEATH].spc + 0.25 + extra_time; |
| 1008 | // Walkers last a little longer |
| 1009 | if (obj->movement_type == MT_WALKING) |
| 1010 | *delay_time += 2.0f; |
| 1011 | } else |
| 1012 | *delay_time = 2.0f; |
| 1013 | } |
| 1014 | } else { // If building, make it shoot up |
| 1015 | *death_flags |= DF_DELAY_FLYING; |