Reduces damage to pilots from shots penetrating the cockpit (#23033)

I mistakenly assumed mech armour was good.

Only combat armour reduces the damage of any rifle round, all other mech
armour is worthless against actual weapons.
This commit is contained in:
FenodyreeAv
2026-08-13 16:22:56 +00:00
committed by GitHub
parent bcd7a179bb
commit 44b11d6804
11 changed files with 54 additions and 10 deletions
+13 -6
View File
@@ -30,10 +30,11 @@
armor_flags = armor_type
if(hidden)
hidden = TRUE
// Takes in incoming damage value
// Applies state changes to self, holder, and whatever else caused by damage mitigation
// Returns modified damage, a list to allow for flag modification or damage conversion, in the same format as the arguments.
/**
* Takes in incoming damage value
* Applies state changes to self, holder, and whatever else caused by damage mitigation
* Returns modified damage, a list to allow for flag modification or damage conversion, in the same format as the arguments.
*/
/datum/component/armor/proc/apply_damage_modifications(damage, damage_type, damage_flags, mob/living/victim, armor_pen, silent = FALSE)
if(armor_flags & ARMOR_TYPE_EXOSUIT)
if(prob(get_blocked(damage_type, damage_flags, armor_pen) * 100)) //extra removal of sharp and edge on account of us being big robots
@@ -42,7 +43,6 @@
if(damage <= 0)
return args.Copy()
var/blocked = get_blocked(damage_type, damage_flags, armor_pen, damage)
on_blocking(damage, damage_type, damage_flags, armor_pen, blocked)
@@ -66,7 +66,14 @@
/datum/component/armor/proc/on_blocking(damage, damage_type, damage_flags, armor_pen, blocked)
// A simpler proc used as a helper for above but can also be used externally. Does not modify state.
/**
* A simpler proc used as a helper for above but can also be used externally. Does not modify state.
* Returns a value between 0 and 1, representing the percentage of damage blocked by this armor component.
* armor_pen is subtracted from the armor value before calculating the percentage blocked.
* armor_range_mult is used to determine the range of damage that is mitigated by this armor
* under_armor_mult is used to determine how much damage is mitigated when the incoming damage is less than or equal to the armor value
* over_armor_mult is used to determine how much damage is mitigated when the incoming damage is greater than the armor value
*/
/datum/component/armor/proc/get_blocked(damage_type, damage_flags, armor_pen = 0, damage = 5)
var/key = get_armor_key(damage_type, damage_flags)
if(!key)
@@ -30,6 +30,13 @@
var/pilot_coverage = 100
var/transparent_cabin = FALSE
var/hide_pilot = TRUE
///Percentage chance for a projectile to hit the pilot if the hatch is open or penetrated. 100% means the pilot will always be hit, 0% means the pilot will never be hit. Side hits divide this value by 4.
var/cockpit_hatch_size = 80
///Multiplier for damage dealt to the pilot when hit by projectiles that penetrate the mech's cockpit.
var/cockpit_pilot_damage_multiplier = 0.5
///Multiplier for armour piercing value of a hit to the pilot when hit by projectiles that penetrate the mech's cockpit.
var/cockpit_pilot_armour_piercing_multiplier = 0.5
has_hardpoints = list(HARDPOINT_BACK, HARDPOINT_LEFT_SHOULDER, HARDPOINT_RIGHT_SHOULDER)
/**
@@ -70,6 +77,12 @@
QDEL_NULL(air_supply)
. = ..()
/obj/item/mech_component/chassis/mechanics_hints(mob/user, distance, is_adjacent)
. = ..()
. += SPAN_NOTICE("This chasis covers <b>[pilot_coverage]%</b> of the pilot's body.")
. += SPAN_NOTICE("When open or destroyed the cockpit hatch will allow <b>[cockpit_hatch_size]%</b> of incoming attacks to hit the pilot.")
. += SPAN_NOTICE("When closed but destroyed the cockpit hatch will reduce damage to the pilot by <b>[round((1 - cockpit_pilot_damage_multiplier) * 100, 0.1)]%</b>.")
/obj/item/mech_component/chassis/get_missing_parts_text()
. = ..()
+5 -4
View File
@@ -17,10 +17,10 @@
if(!hatch_closed) //Open hatches only expose the pilot to attacks from the front and a little bit from the sides.
if(incoming_attack_direction)
if (dir & incoming_attack_direction)
if(prob(80)) //80% chance to hit the pilot from the front if the hatch is open. If this is 100% turrets will shoot mechs with open hatches forever.
if(prob(body.cockpit_hatch_size)) //80% chance to hit the pilot from the front if the hatch is open. If this is 100% turrets will shoot mechs with open hatches forever.
return TRUE
if ((turn(dir, 90) & incoming_attack_direction) || (turn(dir, -90) & incoming_attack_direction))
if(prob(20)) //20% chance to hit the pilot from the sides if the hatch is open.
if(prob(body.cockpit_hatch_size / 4)) //20% chance to hit the pilot from the sides if the hatch is open.
return TRUE
return FALSE
@@ -120,8 +120,9 @@
if(target == body && body.damage_state == MECH_COMPONENT_DAMAGE_DAMAGED_TOTAL) //If the cockpit is destroyed, subsequent damage is applied to the pilot, modified by the mech's armour.
if(body && LAZYLEN(pilots))
var/mob/living/pilot = pick(pilots)
visible_message(SPAN_DANGER("\The [used_weapon] pierces the mangled cockpit of \the [src], striking the pilot inside!"))
pilot.apply_damage(damage, damagetype, def_zone, used_weapon, damage_flags, armor_pen, silent = FALSE)
if(prob(body.cockpit_hatch_size))
visible_message(SPAN_DANGER("\The [used_weapon] pierces the mangled cockpit of \the [src], striking the pilot inside!"))
pilot.apply_damage(damage * body.cockpit_pilot_damage_multiplier, damagetype, def_zone, used_weapon, damage_flags, armor_pen * body.cockpit_pilot_armour_piercing_multiplier, silent = FALSE)
//Only 2 types of damage concern mechs and vehicles
switch(damagetype)
@@ -57,6 +57,8 @@
name = "sealed exosuit chassis"
hatch_descriptor = "canopy"
pilot_coverage = 100
cockpit_hatch_size = 60
cockpit_pilot_damage_multiplier = 0.4
exosuit_desc_string = "an armored chassis"
desc = "A lightweight composite frame keeps the armor of this chassis respectable, but the interior spacious."
icon_state = "combat_body"
@@ -61,6 +61,8 @@
desc = "Despite its looks, this protective chassis provides supreme comfort to its pilot during their conquest."
hatch_descriptor = "bloodied ribcage"
pilot_coverage = 100
cockpit_hatch_size = 60
cockpit_pilot_damage_multiplier = 0.4
exosuit_desc_string = "a bloodied chassis"
icon_state = "cult_body"
max_damage = 150
@@ -53,6 +53,8 @@
hatch_descriptor = "hatch"
desc = "The HI-Koloss chassis is a veritable juggernaut, capable of protecting a pilot even in the most hostile of environments. It handles like a battlecruiser, however."
pilot_coverage = 100
cockpit_hatch_size = 70
cockpit_pilot_damage_multiplier = 0.3
exosuit_desc_string = "a heavily armored chassis"
icon_state = "heavy_body"
max_damage = 300
@@ -53,6 +53,8 @@
/obj/item/mech_component/chassis/light
name = "light exosuit chassis"
pilot_coverage = 100
cockpit_hatch_size = 50
cockpit_pilot_damage_multiplier = 0.8
transparent_cabin = TRUE
hatch_descriptor = "canopy"
exosuit_desc_string = "an open and light chassis"
@@ -40,6 +40,8 @@
hatch_descriptor = "hatch"
desc = "A cramped compartment and a senseless amount of armor is all this steel coffin contains."
pilot_coverage = 100
cockpit_hatch_size = 60
cockpit_pilot_damage_multiplier = 0.2
exosuit_desc_string = "a heavily armored chassis"
icon_state = "strider_body"
max_damage = 750
@@ -75,6 +75,8 @@
name = "open exosuit chassis"
hatch_descriptor = "roll cage"
pilot_coverage = 40
cockpit_hatch_size = 90
cockpit_pilot_damage_multiplier = 0.6 ///The hatch is thick, but the pilot coverage is poor.
exosuit_desc_string = "an industrial rollcage"
desc = "A Xion industrial brand roll cage. Technically OSHA compliant. Technically. This variant has an extra compartment for a copilot, but has no sealed atmosphere."
max_damage = 200
@@ -54,6 +54,8 @@
name = "\improper P'kus-3 chassis"
hatch_descriptor = "canopy"
pilot_coverage = 100
cockpit_hatch_size = 70
cockpit_pilot_damage_multiplier = 0.8
exosuit_desc_string = "a light armored chassis"
desc = "A lightweight composite frame keeps the armor of this chassis respectable, but the interior spacious."
icon_state = "egg_body"
@@ -97,6 +99,8 @@
icon_state = "strong_egg_body"
max_damage = 150
power_use = 250
cockpit_hatch_size = 40
cockpit_pilot_damage_multiplier = 0.5
cell_type = /obj/item/cell/mecha/nuclear