From e7eef8b7db9f34363954a4e0a5364999a56ec7dc Mon Sep 17 00:00:00 2001 From: Matt Atlas Date: Thu, 4 Mar 2021 16:52:27 +0100 Subject: [PATCH] Fixes rig armor not working and some other armor stuff. (#11365) --- code/__defines/armor.dm | 1 + code/datums/components/armor/armor.dm | 9 +++- code/game/objects/items.dm | 2 +- code/modules/clothing/clothing.dm | 16 ++++--- code/modules/clothing/head/misc_special.dm | 2 +- code/modules/clothing/spacesuits/rig/rig.dm | 17 ++++---- .../clothing/spacesuits/rig/suits/alien.dm | 2 +- code/modules/clothing/suits/miscellaneous.dm | 2 +- .../modules/heavy_vehicle/components/armor.dm | 2 +- .../mob/living/carbon/carbon_defense.dm | 5 ++- html/changelogs/mattatlas-livgardet.yml | 43 +++++++++++++++++++ 11 files changed, 80 insertions(+), 21 deletions(-) create mode 100644 html/changelogs/mattatlas-livgardet.yml diff --git a/code/__defines/armor.dm b/code/__defines/armor.dm index df211842e9d..ddba38187b1 100644 --- a/code/__defines/armor.dm +++ b/code/__defines/armor.dm @@ -2,6 +2,7 @@ // Some levels are marked with what they intend to block in such way. #define ARMOR_TYPE_STANDARD 1 #define ARMOR_TYPE_EXOSUIT 2 +#define ARMOR_TYPE_RIG 4 #define ARMOR_BALLISTIC_MINOR 10 #define ARMOR_BALLISTIC_SMALL 25 diff --git a/code/datums/components/armor/armor.dm b/code/datums/components/armor/armor.dm index d9ac8dafa7b..1c5b7ed24f7 100644 --- a/code/datums/components/armor/armor.dm +++ b/code/datums/components/armor/armor.dm @@ -16,10 +16,14 @@ // E.g. setting it to more than 1 will make mitigation drop off faster, effectively reducing the range of damage mitigation var/over_armor_mult = 1 -/datum/component/armor/Initialize(list/armor) + var/sealed = FALSE // Used with ARMOR_TYPE_RIG. + +/datum/component/armor/Initialize(list/armor, armor_type) ..() if(armor) armor_values = armor.Copy() + if(armor_type) + armor_flags = armor_type // Takes in incoming damage value // Applies state changes to self, holder, and whatever else caused by damage mitigation @@ -71,6 +75,9 @@ /datum/component/armor/proc/get_value(key) if(isnull(armor_values[key])) return 0 + if(armor_flags & ARMOR_TYPE_RIG) + if(key == "bio" && sealed) + return 100 return min(armor_values[key], 100) /datum/component/armor/proc/set_value(key, newval) diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index 46704e8d9c7..18a4ec3b383 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -103,7 +103,7 @@ if(islist(armor)) for(var/type in armor) if(armor[type]) - AddComponent(/datum/component/armor, armor, armor_degradation_speed) + AddComponent(/datum/component/armor, armor) break /obj/item/Destroy() diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index a6ba99a0fb5..4b76e1a205e 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -251,11 +251,17 @@ for(var/number in list(melee_armor, bullet_armor, laser_armor, energy_armor, bomb_armor)) number = between(0, number, 100) - armor["melee"] = melee_armor - armor["bullet"] = bullet_armor - armor["laser"] = laser_armor - armor["energy"] = energy_armor - armor["bomb"] = bomb_armor + var/datum/component/armor/armor_component = GetComponent(/datum/component/armor) + if(istype(armor_component)) + armor_component.RemoveComponent() + var/list/armor_list = list( + melee = melee_armor, + bullet = bullet_armor, + laser = laser_armor, + energy = energy_armor, + bomb = bomb_armor + ) + AddComponent(/datum/component/armor, armor_list) if(!isnull(material.conductivity)) siemens_coefficient = between(0, material.conductivity / 10, 10) diff --git a/code/modules/clothing/head/misc_special.dm b/code/modules/clothing/head/misc_special.dm index efb4fb0b8ba..bc1d9ffeee8 100644 --- a/code/modules/clothing/head/misc_special.dm +++ b/code/modules/clothing/head/misc_special.dm @@ -272,4 +272,4 @@ w_class = ITEMSIZE_SMALL body_parts_covered = HEAD attack_verb = list("warned", "cautioned", "smashed") - armor = list("melee" = 5, "bullet" = 0, "laser" = 0,"energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 0, "acid" = 0) + armor = list(melee = 5, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0) diff --git a/code/modules/clothing/spacesuits/rig/rig.dm b/code/modules/clothing/spacesuits/rig/rig.dm index a828d31ae32..22b4ae74261 100644 --- a/code/modules/clothing/spacesuits/rig/rig.dm +++ b/code/modules/clothing/spacesuits/rig/rig.dm @@ -166,7 +166,11 @@ piece.permeability_coefficient = permeability_coefficient piece.unacidable = unacidable piece.species_restricted = species_restricted - if(islist(armor)) piece.armor = armor.Copy() + if(islist(armor)) + var/datum/component/armor/armor_component = piece.GetComponent(/datum/component/armor) + if(istype(armor_component)) + armor_component.RemoveComponent() + piece.AddComponent(/datum/component/armor, armor, ARMOR_TYPE_STANDARD|ARMOR_TYPE_RIG) set_vision(!offline) update_icon(1) @@ -288,12 +292,9 @@ helmet.update_light(wearer) //sealed pieces become airtight, protecting against diseases - if (!seal_target) - LAZYINITLIST(piece.armor) - piece.armor["bio"] = 100 - else - LAZYINITLIST(piece.armor) - piece.armor["bio"] = LAZYACCESS(src.armor, "bio") || 0 + var/datum/component/armor/armor_component = piece.GetComponent(/datum/component/armor) + if(istype(armor_component)) + armor_component.sealed = !seal_target playsound(src, "[!seal_target ? 'sound/machines/rig/rig_deploy.ogg' : 'sound/machines/rig/rig_retract.ogg']", 20, FALSE) else @@ -670,7 +671,7 @@ equip_to = slot_shoes use_obj = boots check_slot = wearer.shoes - if(BP_CHEST) + if("chest") equip_to = slot_wear_suit use_obj = chest check_slot = wearer.wear_suit diff --git a/code/modules/clothing/spacesuits/rig/suits/alien.dm b/code/modules/clothing/spacesuits/rig/suits/alien.dm index 7157c3266b3..014b7e310df 100644 --- a/code/modules/clothing/spacesuits/rig/suits/alien.dm +++ b/code/modules/clothing/spacesuits/rig/suits/alien.dm @@ -33,7 +33,7 @@ armor = list( melee = ARMOR_MELEE_VERY_HIGH, bullet = ARMOR_BALLISTIC_AP, - laser = ARMOR_LASER_MAJOR, + laser = ARMOR_LASER_RIFLES, energy = ARMOR_ENERGY_STRONG, bomb = ARMOR_BOMB_RESISTANT, bio = ARMOR_BIO_SHIELDED, diff --git a/code/modules/clothing/suits/miscellaneous.dm b/code/modules/clothing/suits/miscellaneous.dm index 7d05ea75036..8b0d0487e0c 100644 --- a/code/modules/clothing/suits/miscellaneous.dm +++ b/code/modules/clothing/suits/miscellaneous.dm @@ -576,7 +576,7 @@ w_class = ITEMSIZE_SMALL body_parts_covered = UPPER_TORSO|LOWER_TORSO attack_verb = list("warned", "cautioned", "smashed") - armor = list("melee" = 5, "bullet" = 0, "laser" = 0,"energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 0, "acid" = 0) + armor = list(melee = 5, bullet = 0, laser = 0, energy = 0, bomb = 0, bio = 0, rad = 0) /obj/item/clothing/suit/caution/attack_self() toggle() diff --git a/code/modules/heavy_vehicle/components/armor.dm b/code/modules/heavy_vehicle/components/armor.dm index 0ad058d1b83..b3c2663c895 100644 --- a/code/modules/heavy_vehicle/components/armor.dm +++ b/code/modules/heavy_vehicle/components/armor.dm @@ -13,7 +13,7 @@ /obj/item/robot_parts/robot_component/armor/mech/Initialize() . = ..() - AddComponent(/datum/component/armor, armor, ARMOR_TYPE_EXOSUIT) + AddComponent(/datum/component/armor, armor, ARMOR_TYPE_STANDARD|ARMOR_TYPE_EXOSUIT) /obj/item/robot_parts/robot_component/armor/mech/radproof name = "radiation-proof armor plating" diff --git a/code/modules/mob/living/carbon/carbon_defense.dm b/code/modules/mob/living/carbon/carbon_defense.dm index d98317f8ca1..514316f5c89 100644 --- a/code/modules/mob/living/carbon/carbon_defense.dm +++ b/code/modules/mob/living/carbon/carbon_defense.dm @@ -146,8 +146,9 @@ //presumably, if they are wearing a helmet that stops pressure effects, then it probably covers the throat as well var/obj/item/clothing/head/helmet = get_equipped_item(slot_head) if(istype(helmet) && (helmet.body_parts_covered & HEAD) && (helmet.flags & STOPPRESSUREDAMAGE)) - //we don't do an armor_check here because this is not an impact effect like a weapon swung with momentum, that either penetrates or glances off. - damage_mod = 1.0 - (LAZYACCESS(helmet.armor, "melee")/100) + var/datum/component/armor/armor_component = helmet.GetComponent(/datum/component/armor) + if(armor_component) + damage_mod -= armor_component.get_blocked(BRUTE, damage_flags, W.armor_penetration, W.force*1.5) var/total_damage = 0 for(var/i in 1 to 3) diff --git a/html/changelogs/mattatlas-livgardet.yml b/html/changelogs/mattatlas-livgardet.yml new file mode 100644 index 00000000000..5d1b241d202 --- /dev/null +++ b/html/changelogs/mattatlas-livgardet.yml @@ -0,0 +1,43 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: MattAtlas + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - bugfix: "Fixed rig armor suddenly disappearing upon being deployed." + - bugfix: "Fixed various wrong armor definitions." + - bugfix: "Fixed the unathi breacher having wrong armor values for laser defense." \ No newline at end of file