commit b509a5b4ca5cbad1c2b0dfe23da2871ff69f2501
Author: niffiwan <niffiwan.scp@gmail.com>
Date:   Mon Aug 25 19:56:00 2014 +1000

    Fix mantis 2804: beams can now use factors
    
    Add game_setting.tbl option that allows beams to use tabled
    Armor/Shield/Subsystem factor values
    Contains extra debug code that'll be removed before its added to trunk

diff --git a/code/mod_table/mod_table.cpp b/code/mod_table/mod_table.cpp
index e45f4bb..f9a4530 100644
--- a/code/mod_table/mod_table.cpp
+++ b/code/mod_table/mod_table.cpp
@@ -31,6 +31,7 @@ int FS2NetD_port = 0;
 float Briefing_window_FOV = 0.29375f;
 bool Disable_hc_message_ani = false;
 bool Red_alert_applies_to_delayed_ships = false;
+bool Beams_use_armour_shield_subsys_factors = false;
 
 
 void parse_mod_table(const char *filename)
@@ -259,6 +260,15 @@ void parse_mod_table(const char *filename)
 			mprintf(("Game Settings Table: Flight controls follow eyepoint orientation\n"));
 	}
 
+	if (optional_string("$Beams Use Armor/Shield/Subsystem Factors:")) {
+		stuff_boolean(&Beams_use_armour_shield_subsys_factors);
+		if (Beams_use_armour_shield_subsys_factors) {
+			mprintf(("Game Settings Table: Beams will use Armor/Shield/Subsystem Factors\n"));
+		} else {
+			mprintf(("Game Settings Table: Beams will ignore Armor/Shield/Subsystem Factors (retail behavior)\n"));
+		}
+	}
+
 	required_string("#END");
 }
 
diff --git a/code/mod_table/mod_table.h b/code/mod_table/mod_table.h
index 129d09e..8f82725 100644
--- a/code/mod_table/mod_table.h
+++ b/code/mod_table/mod_table.h
@@ -26,5 +26,6 @@ extern int FS2NetD_port;
 extern float Briefing_window_FOV;
 extern bool Disable_hc_message_ani;
 extern bool Red_alert_applies_to_delayed_ships;
+extern bool Beams_use_armour_shield_subsys_factors;
 
 void mod_table_init();
diff --git a/code/ship/shiphit.cpp b/code/ship/shiphit.cpp
index 0a5438c..19cf8c1 100644
--- a/code/ship/shiphit.cpp
+++ b/code/ship/shiphit.cpp
@@ -327,6 +327,11 @@ int shiphit_get_damage_weapon(object *damaging_objp)
 		case OBJ_SHOCKWAVE:
 			weapon_info_index = shockwave_get_weapon_index(damaging_objp->instance);
 			break;
+		case OBJ_BEAM:
+			if (Beams_use_armour_shield_subsys_factors) {
+				weapon_info_index = beam_get_weapon_info_index(damaging_objp);
+			}
+			break;
 		default:
 			weapon_info_index = -1;
 			break;
@@ -486,7 +491,8 @@ float do_subobj_hit_stuff(object *ship_objp, object *other_obj, vec3d *hitpos, i
 
 	// scale subsystem damage if appropriate
 	weapon_info_index = shiphit_get_damage_weapon(other_obj);	// Goober5000 - a NULL other_obj returns -1
-	if ((weapon_info_index >= 0) && (other_obj->type == OBJ_WEAPON)) {
+	if ((weapon_info_index >= 0) && ((other_obj->type == OBJ_WEAPON) ||
+				(Beams_use_armour_shield_subsys_factors && (other_obj->type == OBJ_BEAM)))) {
 		if ( Weapon_info[weapon_info_index].wi_flags2 & WIF2_TRAINING ) {
 			return damage_left;
 		}
@@ -729,6 +735,7 @@ float do_subobj_hit_stuff(object *ship_objp, object *other_obj, vec3d *hitpos, i
 			}
 
 			subsystem->current_hits -= damage_to_apply;
+			nprintf(("Damage", "Damage Subsys: %.1f, %s\n", damage_to_apply, ship_p->ship_name));
 			if (!(subsystem->flags & SSF_NO_AGGREGATE)) {
 				ship_p->subsys_info[subsystem->system_info->type].aggregate_current_hits -= damage_to_apply;
 			}
@@ -2097,8 +2104,12 @@ static void ship_do_damage(object *ship_objp, object *other_obj, vec3d *hitpos,
 				damage *= difficulty_scale_factor;
 			}
 
+			nprintf(("Damage", "Damage Shield: %.1f", damage)); // damage applied to shield
+
 			damage = apply_damage_to_shield(ship_objp, quadrant, damage);
 
+			nprintf(("Damage", " (%.1f), %s\n", damage, shipp->ship_name)); // damage leftover for hull, etc
+
 			if(damage > 0.0f){
 				subsystem_damage *= (damage / pre_shield);
 			} else {
@@ -2200,6 +2211,7 @@ static void ship_do_damage(object *ship_objp, object *other_obj, vec3d *hitpos,
 					}
 				}
 				ship_objp->hull_strength -= damage;
+				nprintf(("Damage", "Damage Hull  : %.1f, %s\n", damage, shipp->ship_name));
 			}
 
 			// let damage gauge know that player ship just took damage
