From bcd2b0a3b08df01e3eb8f1c70fa689509252e550 Mon Sep 17 00:00:00 2001 From: Barhandar Date: Mon, 14 May 2018 02:55:31 +0300 Subject: [PATCH] Replaces adding goliath plates to clothing and APLUs with a customizable tracking component (#37525) add: Amount of goliath plates is now shown in examine for explorer suits and mining hardsuits. I was peeved by being unable to tell whether the armour is upgraded or not except by trying to stick more plates on it. I think a more correct way would be to add a plate amount var to these items similarly to APLU plating and then have description mention their amount and, for added transparency, that it's possible to improve it if there's 0 plates. Please point the errors/wrongs in it, since "current armour value minus constant divided by value each plate adds" is rather clunky code. --- code/datums/components/armor_plate.dm | 78 +++++++++++++++++++ code/game/mecha/working/ripley.dm | 11 ++- code/modules/clothing/spacesuits/hardsuit.dm | 11 ++- .../modules/mining/equipment/explorer_gear.dm | 8 ++ code/modules/mining/equipment/goliath_hide.dm | 36 +-------- tgstation.dme | 1 + 6 files changed, 105 insertions(+), 40 deletions(-) create mode 100644 code/datums/components/armor_plate.dm diff --git a/code/datums/components/armor_plate.dm b/code/datums/components/armor_plate.dm new file mode 100644 index 0000000000..0b94c389ce --- /dev/null +++ b/code/datums/components/armor_plate.dm @@ -0,0 +1,78 @@ +/datum/component/armor_plate + var/amount = 0 + var/maxamount = 3 + var/upgrade_item = /obj/item/stack/sheet/animalhide/goliath_hide + var/datum/armor/added_armor = list("melee" = 10) + var/upgrade_name + +/datum/component/armor_plate/Initialize(_maxamount,obj/item/_upgrade_item,datum/armor/_added_armor) + if(!isobj(parent)) + return COMPONENT_INCOMPATIBLE + + RegisterSignal(COMSIG_PARENT_EXAMINE, .proc/examine) + RegisterSignal(COMSIG_PARENT_ATTACKBY, .proc/applyplate) + RegisterSignal(COMSIG_PARENT_PREQDELETED, .proc/dropplates) + + if(_maxamount) + maxamount = _maxamount + if(_upgrade_item) + upgrade_item = _upgrade_item + if(_added_armor) + if(islist(_added_armor)) + added_armor = getArmor(arglist(_added_armor)) + else if (istype(_added_armor, /datum/armor)) + added_armor = _added_armor + else + stack_trace("Invalid type [_added_armor.type] passed as _armor_item argument to armorplate component") + else + added_armor = getArmor(arglist(added_armor)) + var/obj/item/typecast = upgrade_item + upgrade_name = initial(typecast.name) + +/datum/component/armor_plate/proc/examine(mob/user) + //upgrade_item could also be typecast here instead + if(ismecha(parent)) + if(amount) + if(amount < maxamount) + to_chat(user, "Its armor is enhanced with [amount] [upgrade_name].") + else + to_chat(user, "It's wearing a fearsome carapace entirely composed of [upgrade_name] - its pilot must be an experienced monster hunter.") + else + to_chat(user, "It has attachment points for strapping monster hide on for added protection.") + else + if(amount) + to_chat(user, "It has been strengthened with [amount]/[maxamount] [upgrade_name].") + else + to_chat(user, "It can be strengthened with up to [maxamount] [upgrade_name].") + +/datum/component/armor_plate/proc/applyplate(obj/item/I, mob/user, params) + if(!istype(I,upgrade_item)) + return + if(amount >= maxamount) + to_chat(user, "You can't improve [parent] any further!") + return + + if(istype(I,/obj/item/stack)) + I.use(1) + else + if(length(I.contents)) + to_chat(user, "[I] cannot be used for armoring while there's something inside!") + return + qdel(I) + + var/obj/O = parent + amount++ + O.armor = O.armor.attachArmor(added_armor) + + if(ismecha(O)) + var/obj/mecha/R = O + R.update_icon() + to_chat(user, "You strengthen [R], improving its resistance against melee, bullet and laser damage.") + else + to_chat(user, "You strengthen [O], improving its resistance against melee attacks.") + + +/datum/component/armor_plate/proc/dropplates(force) + if(ismecha(parent)) //items didn't drop the plates before and it causes erroneous behavior for the time being with collapsible helmets + for(var/i in 1 to amount) + new upgrade_item(get_turf(parent)) \ No newline at end of file diff --git a/code/game/mecha/working/ripley.dm b/code/game/mecha/working/ripley.dm index 429d954451..21ecc26905 100644 --- a/code/game/mecha/working/ripley.dm +++ b/code/game/mecha/working/ripley.dm @@ -31,8 +31,6 @@ ore.forceMove(ore_box) /obj/mecha/working/ripley/Destroy() - for(var/i=1, i <= hides, i++) - new /obj/item/stack/sheet/animalhide/goliath_hide(loc) //If a goliath-plated ripley gets killed, all the plates drop for(var/atom/movable/A in cargo) A.forceMove(drop_location()) step_rand(A) @@ -49,13 +47,18 @@ /obj/mecha/working/ripley/update_icon() ..() - if (hides) + GET_COMPONENT(C,/datum/component/armor_plate) + if (C.amount) cut_overlays() - if(hides < 3) + if(C.amount < 3) add_overlay(occupant ? "ripley-g" : "ripley-g-open") else add_overlay(occupant ? "ripley-g-full" : "ripley-g-full-open") +/obj/mecha/working/ripley/Initialize() + . = ..() + AddComponent(/datum/component/armor_plate,3,/obj/item/stack/sheet/animalhide/goliath_hide,list("melee" = 10, "bullet" = 5, "laser" = 5)) + /obj/mecha/working/ripley/firefighter desc = "Autonomous Power Loader Unit. This model is refitted with additional thermal protection." diff --git a/code/modules/clothing/spacesuits/hardsuit.dm b/code/modules/clothing/spacesuits/hardsuit.dm index 68d7073612..f5b4a31290 100644 --- a/code/modules/clothing/spacesuits/hardsuit.dm +++ b/code/modules/clothing/spacesuits/hardsuit.dm @@ -126,7 +126,7 @@ if(user.transferItemToLoc(I, src)) jetpack = I to_chat(user, "You successfully install the jetpack into [src].") - + return else if(istype(I, /obj/item/screwdriver)) if(!jetpack) to_chat(user, "[src] has no jetpack installed.") @@ -139,6 +139,8 @@ jetpack.forceMove(drop_location()) jetpack = null to_chat(user, "You successfully remove the jetpack from [src].") + return + return ..() /obj/item/clothing/suit/space/hardsuit/equipped(mob/user, slot) @@ -237,6 +239,9 @@ brightness_on = 7 allowed = list(/obj/item/flashlight, /obj/item/tank/internals, /obj/item/resonator, /obj/item/mining_scanner, /obj/item/t_scanner/adv_mining_scanner, /obj/item/gun/energy/kinetic_accelerator) +/obj/item/clothing/head/helmet/space/hardsuit/mining/Initialize() + . = ..() + AddComponent(/datum/component/armor_plate) /obj/item/clothing/suit/space/hardsuit/mining icon_state = "hardsuit-mining" @@ -250,6 +255,10 @@ helmettype = /obj/item/clothing/head/helmet/space/hardsuit/mining heat_protection = CHEST|GROIN|LEGS|FEET|ARMS|HANDS +/obj/item/clothing/suit/space/hardsuit/mining/Initialize() + . = ..() + AddComponent(/datum/component/armor_plate) + //Syndicate hardsuit /obj/item/clothing/head/helmet/space/hardsuit/syndi name = "blood-red hardsuit helmet" diff --git a/code/modules/mining/equipment/explorer_gear.dm b/code/modules/mining/equipment/explorer_gear.dm index 0bfb0b5f6d..36eb9d5e1b 100644 --- a/code/modules/mining/equipment/explorer_gear.dm +++ b/code/modules/mining/equipment/explorer_gear.dm @@ -25,6 +25,14 @@ armor = list("melee" = 30, "bullet" = 20, "laser" = 20, "energy" = 20, "bomb" = 50, "bio" = 100, "rad" = 50, "fire" = 50, "acid" = 50) resistance_flags = FIRE_PROOF +/obj/item/clothing/suit/hooded/explorer/Initialize() + . = ..() + AddComponent(/datum/component/armor_plate) + +/obj/item/clothing/head/hooded/explorer/Initialize() + . = ..() + AddComponent(/datum/component/armor_plate) + /obj/item/clothing/mask/gas/explorer name = "explorer gas mask" desc = "A military-grade gas mask that can be connected to an air supply." diff --git a/code/modules/mining/equipment/goliath_hide.dm b/code/modules/mining/equipment/goliath_hide.dm index b266b92584..85feaecf73 100644 --- a/code/modules/mining/equipment/goliath_hide.dm +++ b/code/modules/mining/equipment/goliath_hide.dm @@ -9,38 +9,4 @@ novariants = FALSE flags_1 = NOBLUDGEON_1 w_class = WEIGHT_CLASS_NORMAL - layer = MOB_LAYER - var/static/list/goliath_platable_armor_typecache = typecacheof(list( - /obj/item/clothing/head/helmet/space/hardsuit/mining, - /obj/item/clothing/suit/space/hardsuit/mining, - /obj/item/clothing/head/hooded/explorer, - /obj/item/clothing/suit/hooded/explorer)) - -/obj/item/stack/sheet/animalhide/goliath_hide/afterattack(atom/target, mob/user, proximity_flag) - if(!proximity_flag) - return - if(is_type_in_typecache(target, goliath_platable_armor_typecache)) - var/obj/item/clothing/C = target - if(C.armor.melee < 60) - C.armor = C.armor.setRating(melee = min(C.armor.melee + 10, 60)) - to_chat(user, "You strengthen [target], improving its resistance against melee attacks.") - use(1) - else - to_chat(user, "You can't improve [C] any further!") - else if(istype(target, /obj/mecha/working/ripley)) - var/obj/mecha/working/ripley/D = target - if(D.hides < 3) - D.hides++ - D.armor = D.armor.setRating(\ - melee = min(D.armor.melee + 10, 70),\ - bullet = min(D.armor.bullet + 5, 50),\ - laser = min(D.armor.laser + 5, 50)) - to_chat(user, "You strengthen [target], improving its resistance against melee attacks.") - D.update_icon() - if(D.hides == 3) - D.desc = "Autonomous Power Loader Unit. It's wearing a fearsome carapace entirely composed of goliath hide plates - its pilot must be an experienced monster hunter." - else - D.desc = "Autonomous Power Loader Unit. Its armour is enhanced with some goliath hide plates." - use(1) - else - to_chat(user, "You can't improve [D] any further!") + layer = MOB_LAYER \ No newline at end of file diff --git a/tgstation.dme b/tgstation.dme index 68ac88f3e6..d768813899 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -316,6 +316,7 @@ #include "code\datums\components\_component.dm" #include "code\datums\components\anti_magic.dm" #include "code\datums\components\archaeology.dm" +#include "code\datums\components\armor_plate.dm" #include "code\datums\components\beauty.dm" #include "code\datums\components\butchering.dm" #include "code\datums\components\caltrop.dm"