@@ -256,7 +256,8 @@ flag_def_list Subsystem_flags[] = {
256256 { "no disappear", MSS_FLAG2_NO_DISAPPEAR, 1},
257257 { "collide submodel", MSS_FLAG2_COLLIDE_SUBMODEL, 1},
258258 { "allow destroyed rotation", MSS_FLAG2_DESTROYED_ROTATION, 1},
259- { "turret use ammo", MSS_FLAG2_TURRET_USE_AMMO, 1}
259+ { "turret use ammo", MSS_FLAG2_TURRET_USE_AMMO, 1},
260+ { "autorepair if disabled", MSS_FLAG2_AUTOREPAIR_IF_DISABLED, 1},
260261};
261262
262263const int Num_subsystem_flags = sizeof(Subsystem_flags)/sizeof(flag_def_list);
@@ -310,6 +311,7 @@ flag_def_list Ship_flags[] = {
310311 { "no lighting", SIF2_NO_LIGHTING, 1 },
311312 { "auto spread shields", SIF2_AUTO_SPREAD_SHIELDS, 1 },
312313 { "model point shields", SIF2_MODEL_POINT_SHIELDS, 1 },
314+ { "repair disabled subsystems", SIF2_SUBSYS_REPAIR_WHEN_DISABLED, 1},
313315
314316 // to keep things clean, obsolete options go last
315317 { "ballistic primaries", -1, 255 }
@@ -6307,6 +6309,8 @@ int subsys_set(int objnum, int ignore_subsys_info)
63076309 ship_system->flags |= SSF_PLAY_SOUND_FOR_PLAYER;
63086310 if (model_system->flags2 & MSS_FLAG2_NO_DISAPPEAR)
63096311 ship_system->flags |= SSF_NO_DISAPPEAR;
6312+ if (model_system->flags2 & MSS_FLAG2_AUTOREPAIR_IF_DISABLED)
6313+ ship_system->flags |= SSF_AUTOREPAIR_IF_DISABLED;
63106314
63116315 ship_system->turn_rate = model_system->turn_rate;
63126316
@@ -8774,7 +8778,7 @@ void ship_auto_repair_frame(int shipnum, float frametime)
87748778 if ( ssp->current_hits < ssp->max_hits ) {
87758779
87768780 // only repair those subsystems which are not destroyed
8777- if ( ssp->max_hits <= 0 || ssp->current_hits <= 0 )
8781+ if ( ( ssp->max_hits <= 0) || (( ssp->current_hits <= 0) && !((sip->flags2 & SIF2_SUBSYS_REPAIR_WHEN_DISABLED) || (ssp->flags & SSF_AUTOREPAIR_IF_DISABLED))) )
87788782 continue;
87798783
87808784 // do incremental repair on the subsystem
@@ -8790,7 +8794,14 @@ void ship_auto_repair_frame(int shipnum, float frametime)
87908794 if ( ssip->aggregate_current_hits > ssip->aggregate_max_hits ) {
87918795 ssip->aggregate_current_hits = ssip->aggregate_max_hits;
87928796 }
8793- }
8797+ }
8798+
8799+ // check to see if this subsystem was totally non functional before -- if so, then
8800+ // reset the flags
8801+ if ( (ssp->system_info->type == SUBSYSTEM_ENGINE) && (sp->flags & SF_DISABLED) ) {
8802+ sp->flags &= ~SF_DISABLED;
8803+ ship_reset_disabled_physics(objp, sp->ship_info_index);
8804+ }
87948805 }
87958806 } // end for
87968807}
0 commit comments