Plays the animation that accompanies a weapon death
| 3064 | |
| 3065 | // Plays the animation that accompanies a weapon death |
| 3066 | void DoWeaponExploded(object *obj, vector *norm, vector *collision_point, object *hit_object) { |
| 3067 | weapon *w = &Weapons[obj->id]; |
| 3068 | light_info *li = &w->lighting_info; |
| 3069 | vector col_point, normal; |
| 3070 | |
| 3071 | if (w->flags & WF_ELECTRICAL) |
| 3072 | return; |
| 3073 | |
| 3074 | MakeShockwave(obj, obj->parent_handle); |
| 3075 | |
| 3076 | if (collision_point == NULL || !(Weapons[obj->id].flags & WF_PLANAR_BLAST)) |
| 3077 | col_point = obj->pos; |
| 3078 | else |
| 3079 | col_point = *collision_point; |
| 3080 | |
| 3081 | if (norm == NULL) |
| 3082 | normal = obj->orient.fvec; |
| 3083 | else |
| 3084 | normal = *norm; |
| 3085 | |
| 3086 | if (Weapons[obj->id].flags & WF_GRAVITY_FIELD) |
| 3087 | CreateGravityField(&obj->pos, obj->roomnum, Weapons[obj->id].gravity_size, Weapons[obj->id].gravity_time, |
| 3088 | obj->parent_handle); |
| 3089 | |
| 3090 | if (hit_object == Viewer_object && !(Weapons[obj->id].flags & WF_MATTER_WEAPON)) |
| 3091 | return; // Don't draw if its viewer who is getting hit |
| 3092 | |
| 3093 | if (Weapons[obj->id].flags & WF_PLANAR_BLAST) { |
| 3094 | if (Weapons[obj->id].flags & WF_BLAST_RING) { |
| 3095 | // Create a planar ring |
| 3096 | int visnum = VisEffectCreate(VIS_FIREBALL, BLAST_RING_INDEX, obj->roomnum, &col_point); |
| 3097 | if (visnum >= 0) { |
| 3098 | vis_effect *vis = &VisEffects[visnum]; |
| 3099 | vis->size = Weapons[obj->id].explode_size; |
| 3100 | vis->lifetime = Weapons[obj->id].explode_time; |
| 3101 | vis->lifeleft = Weapons[obj->id].explode_time; |
| 3102 | vis->custom_handle = GetTextureBitmap(Weapons[obj->id].explode_image_handle, 0); |
| 3103 | vis->flags |= VF_PLANAR; |
| 3104 | vis->end_pos = normal; |
| 3105 | vis->lighting_color = |
| 3106 | OPAQUE_FLAG | GR_RGB16(li->red_light2 * 255, li->green_light2 * 255, li->blue_light2 * 255); |
| 3107 | } |
| 3108 | } else { |
| 3109 | // Create a planar explosion |
| 3110 | int visnum; |
| 3111 | |
| 3112 | if (Weapons[obj->id].explode_image_handle > 0) { |
| 3113 | visnum = VisEffectCreate(VIS_FIREBALL, CUSTOM_EXPLOSION_INDEX, obj->roomnum, &col_point); |
| 3114 | if (visnum >= 0) { |
| 3115 | vis_effect *vis = &VisEffects[visnum]; |
| 3116 | vis->size = Weapons[obj->id].explode_size; |
| 3117 | vis->lifetime = Weapons[obj->id].explode_time; |
| 3118 | vis->lifeleft = Weapons[obj->id].explode_time; |
| 3119 | vis->custom_handle = Weapons[obj->id].explode_image_handle; |
| 3120 | vis->lighting_color = |
| 3121 | OPAQUE_FLAG | GR_RGB16(li->red_light2 * 255, li->green_light2 * 255, li->blue_light2 * 255); |
| 3122 | } |
| 3123 | } else |
no test coverage detected