@@ -13826,18 +13826,22 @@ int ai_await_repair_frame(object *objp, ai_info *aip)
1382613826// Maybe should only do this if they are preventing their wing from re-entering.
1382713827void ai_maybe_self_destruct (object *objp, ai_info *aip)
1382813828{
13829+ Assertion (objp->type == OBJ_SHIP, " ai_maybe_self_destruct() can only be called with objects that are ships!" );
13830+ ship *shipp = &Ships[objp->instance ];
13831+
1382913832 // Some IFFs can be repaired, so no self-destruct.
1383013833 // In multiplayer, just don't self-destruct. I figured there would be a problem. -- MK, 3/19/98.
13831- if ((Iff_info[Ships[objp-> instance ]. team ].flags & IFFF_SUPPORT_ALLOWED) || (Game_mode & GM_MULTIPLAYER))
13834+ if ((Iff_info[shipp-> team ].flags & IFFF_SUPPORT_ALLOWED) || (Game_mode & GM_MULTIPLAYER))
1383213835 return ;
1383313836
1383413837 // Small ships in a wing blow themselves up after awhile if engine or weapons system has been destroyed.
1383513838 // Reason: Don't want them to prevent a re-emergence of the wing.
1383613839 // Note: Don't blow up if not in a wing for two reasons: One, won't affect re-emergence of waves and (1) disable the Dragon
1383713840 // mission would be broken.
13838- if ((Ship_info[Ships[objp->instance ].ship_info_index ].flags & SIF_SMALL_SHIP) && (Ships[objp->instance ].wingnum != -1 )) {
13839- if ((ship_get_subsystem_strength (&Ships[objp->instance ], SUBSYSTEM_ENGINE) <= 0 .0f ) ||
13840- (ship_get_subsystem_strength (&Ships[objp->instance ], SUBSYSTEM_WEAPONS) <= 0 .0f )) {
13841+ // Also, don't blow up the ship if it has a ship flag preventing this - Goober5000
13842+ if ((Ship_info[shipp->ship_info_index ].flags & SIF_SMALL_SHIP) && (shipp->wingnum >= 0 ) && !(shipp->flags2 & SF2_NO_DISABLED_SELF_DESTRUCT)) {
13843+ if ((ship_get_subsystem_strength (shipp, SUBSYSTEM_ENGINE) <= 0 .0f ) ||
13844+ (ship_get_subsystem_strength (shipp, SUBSYSTEM_WEAPONS) <= 0 .0f )) {
1384113845 if (aip->self_destruct_timestamp < 0 )
1384213846 aip->self_destruct_timestamp = timestamp (90 * 1000 ); // seconds until self-destruct
1384313847 } else {
0 commit comments