Skip to content

Commit

Permalink
insulated gloves now work under other gloves
Browse files Browse the repository at this point in the history
  • Loading branch information
silicons committed Dec 26, 2024
1 parent 08daed7 commit bcbf961
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@
new /datum/data/mining_equipment("Defense Equipment - Razor Drone Deployer",/obj/item/grenade/spawnergrenade/manhacks/station/locked, 1000),
new /datum/data/mining_equipment("Defense Equipment - Sentry Drone Deployer",/obj/item/grenade/spawnergrenade/ward, 1500),
new /datum/data/mining_equipment("Defense Equipment - Plasteel Machete", /obj/item/clothing/accessory/holster/machete/occupied, 500),
new /datum/data/mining_equipment("Defense Equipment - Kinetic Dagger", /obj/item/kinetic_crusher/dagger, 1200),
new /datum/data/mining_equipment("Defense Equipment - Kinetic Dagger", /obj/item/kinetic_crusher/dagger, 1000),
new /datum/data/mining_equipment("Defense Equipment - Kinetic Gauntlets", /obj/item/kinetic_gauntlets, 1000),
new /datum/data/mining_equipment("Bar Shelter Capsule", /obj/item/survivalcapsule/luxurybar, 10000)
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
new /datum/data/mining_equipment("Geiger Counter", /obj/item/geiger_counter, 75),
new /datum/data/mining_equipment("Defense Equipment - Steel Machete", /obj/item/material/knife/machete, 75),
new /datum/data/mining_equipment("Defense Equipment - Kinetic Dagger", /obj/item/kinetic_crusher/dagger, 75),
new /datum/data/mining_equipment("Defense Equipment - Kinetic Gauntlets", /obj/item/kinetic_gauntlets, 75),
new /datum/data/mining_equipment("Laser Pointer", /obj/item/laser_pointer, 90),
new /datum/data/mining_equipment("Digital Tablet - Advanced", /obj/item/modular_computer/tablet/preset/custom_loadout/advanced, 100),
new /datum/data/mining_equipment("Nanopaste Tube", /obj/item/stack/nanopaste, 100),
Expand Down
31 changes: 30 additions & 1 deletion code/modules/mob/inventory/inventory-query.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
//* This file is explicitly licensed under the MIT license. *//
//* Copyright (c) 2024 Citadel Station Developers *//

//* This file contains expensive, cached queries. *//
//! This file contains expensive, cached queries. !//

//* Coverage *//

/**
* todo: better coverage checks, coverage levels / flags
Expand All @@ -24,3 +26,30 @@

/datum/inventory/proc/invalidate_coverage_cache()
cache = list()

//* Siemens Coefficient *//

/**
* Returns overall siemens coefficient as a result of all covering items.
*
* * If multiple cover flags are specified, all items touching any of those coverages are considered.
* That's why this says 'simple'.
*
* @return overall siemens coefficient as multiplier
*/
/datum/inventory/proc/query_simple_covered_siemens_coefficient(body_cover_flags) as /list
if(!isnull(. = cache["siemens-single-[body_cover_flags]"]))
return
trim_simple_covered_siemens_coefficient_cache()
. = 1
for(var/obj/item/worn as anything in get_everything(~INV_FILTER_EQUIPMENT, TRUE))
if(worn.body_cover_flags & body_cover_flags)
. *= worn.siemens_coefficient
cache["siemens-single-[body_cover_flags]"] = .

/datum/inventory/proc/trim_simple_covered_siemens_coefficient_cache()
if(length(cache) > 100)
cache.len = 100

/datum/inventory/proc/invalidate_simple_covered_siemens_coefficient_cache()
cache = list()
13 changes: 0 additions & 13 deletions code/modules/mob/inventory/inventory.dm
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,6 @@
/datum/inventory/proc/invalidate_cache()
cache = list()

//* Queries *//

/**
* returns list() of items with body_cover_flags
*/
/datum/inventory/proc/items_that_cover(cover_flags)
if(cover_flags == NONE)
return list()
. = list()
for(var/obj/item/I as anything in owner.get_equipped_items())
if(I.body_cover_flags & cover_flags)
. += I

//* Slots *//

/**
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/carbon/human/defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
if(filter_zone)
// just one zone
var/obj/item/organ/external/part = get_organ(filter_zone)
for(var/obj/item/I as anything in inventory?.items_that_cover(part.body_part_flags))
for(var/obj/item/I as anything in inventory?.query_coverage(part.body_part_flags))
I.mob_armorcall(src, shieldcall_args, fake_attack)
if(shieldcall_args[SHIELDCALL_ARG_FLAGS] & SHIELDCALL_FLAG_TERMINATE)
break
Expand All @@ -23,7 +23,7 @@
continue
var/obj/item/organ/external/part = organs_by_name[key]
var/resultant = damage
for(var/obj/item/I as anything in inventory?.items_that_cover(part.body_part_flags))
for(var/obj/item/I as anything in inventory?.query_coverage(part.body_part_flags))
var/list/copied_args = args.Copy()
copied_args[SHIELDCALL_ARG_DAMAGE] = resultant
I.mob_armorcall(src, copied_args, fake_attack)
Expand Down
8 changes: 2 additions & 6 deletions code/modules/mob/living/carbon/human/human-defense-legacy.dm
Original file line number Diff line number Diff line change
Expand Up @@ -77,12 +77,8 @@
if (!def_zone)
return 1.0

var/siemens_coefficient = max(species.siemens_coefficient,0)

var/list/clothing_items = list(head, wear_mask, wear_suit, w_uniform, gloves, shoes) // What all are we checking?
for(var/obj/item/clothing/C in clothing_items)
if(istype(C) && (C.body_cover_flags & def_zone.body_part_flags)) // Is that body part being targeted covered?
siemens_coefficient *= C.siemens_coefficient
var/siemens_coefficient = max(species.siemens_coefficient, 0)
siemens_coefficient *= inventory.query_simple_covered_siemens_coefficient(def_zone.body_part_flags)

// Modifiers.
for(var/thing in modifiers)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/reagents/items/hypospray.dm
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
inject_verb = "spray"
inject_message = "[user] starts to [inject_verb] [target] with \the [src]."
var/block_flags = NONE
for(var/obj/item/I as anything in target.inventory.items_that_cover(limb.body_part_flags))
for(var/obj/item/I as anything in target.inventory.query_coverage(limb.body_part_flags))
block_flags |= (I.clothing_flags & (CLOTHING_THICK_MATERIAL | CLOTHING_INJECTION_PORT))
// got all coverage, proceed.
var/delay = injection_time
Expand Down

0 comments on commit bcbf961

Please sign in to comment.