From 2a9e4bebdd5b782ebbc7bdae32542dfedc083796 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Mon, 16 Mar 2020 04:24:18 -0700 Subject: [PATCH] priority --- code/__DEFINES/combat.dm | 8 ++++++++ code/__HELPERS/cmp.dm | 5 ++++- code/game/objects/items/storage/belt.dm | 2 +- code/modules/clothing/clothing.dm | 1 + code/modules/clothing/suits/_suits.dm | 1 + code/modules/clothing/under/_under.dm | 1 + code/modules/mob/living/carbon/human/human_block.dm | 2 +- code/modules/mob/living/living_block.dm | 3 +++ 8 files changed, 20 insertions(+), 3 deletions(-) diff --git a/code/__DEFINES/combat.dm b/code/__DEFINES/combat.dm index c88e181a27..714e011a29 100644 --- a/code/__DEFINES/combat.dm +++ b/code/__DEFINES/combat.dm @@ -243,3 +243,11 @@ GLOBAL_LIST_INIT(shove_disarming_types, typecacheof(list( /// Default if the above isn't set in the list. #define DEFAULT_REDIRECT_METHOD_PROJECTILE REDIRECT_METHOD_REFLECT + +/// Block priorities +#define BLOCK_PRIORITY_HELD_ITEM 100 +#define BLOCK_PRIORITY_CLOTHING 50 +#define BLOCK_PRIORITY_WEAR_SUIT 75 +#define BLOCK_PRIORITY_UNIFORM 25 + +#define BLOCK_PRIORITY_DEFAULT BLOCK_PRIORITY_HELD_ITEM diff --git a/code/__HELPERS/cmp.dm b/code/__HELPERS/cmp.dm index c95896d853..9b877e8fb0 100644 --- a/code/__HELPERS/cmp.dm +++ b/code/__HELPERS/cmp.dm @@ -116,4 +116,7 @@ GLOBAL_VAR_INIT(cmp_field, "name") if(a_sign != b_sign) return a_sign - b_sign else - return sorttext(b_name, a_name) \ No newline at end of file + return sorttext(b_name, a_name) + +/proc/cmp_item_block_priority_asc(obj/item/A, obj/item/B) + return A.block_priority - B.block_priority diff --git a/code/game/objects/items/storage/belt.dm b/code/game/objects/items/storage/belt.dm index 1c5d7734c6..091075189e 100755 --- a/code/game/objects/items/storage/belt.dm +++ b/code/game/objects/items/storage/belt.dm @@ -807,7 +807,7 @@ starting_sword = /obj/item/melee/rapier /obj/item/storage/belt/sabre/rapier/run_block(mob/living/owner, real_attack, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return) - if(attack_type & PROJECTILE_ATTACK) // No blocking bullets. + if(attack_type & ATTACK_TYPE_PROJECTILE) // No blocking bullets. return BLOCK_NONE return ..() diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index 7e2d73190a..780eda532b 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -3,6 +3,7 @@ resistance_flags = FLAMMABLE max_integrity = 200 integrity_failure = 0.4 + block_priority = BLOCK_PRIORITY_CLOTHING var/damaged_clothes = 0 //similar to machine's BROKEN stat and structure's broken var var/flash_protect = 0 //What level of bright light protection item has. 1 = Flashers, Flashes, & Flashbangs | 2 = Welding | -1 = OH GOD WELDING BURNT OUT MY RETINAS var/tint = 0 //Sets the item's level of visual impairment tint, normally set to the same as flash_protect diff --git a/code/modules/clothing/suits/_suits.dm b/code/modules/clothing/suits/_suits.dm index 1b2080feb1..e01ec2dde8 100644 --- a/code/modules/clothing/suits/_suits.dm +++ b/code/modules/clothing/suits/_suits.dm @@ -1,6 +1,7 @@ /obj/item/clothing/suit icon = 'icons/obj/clothing/suits.dmi' name = "suit" + block_priority = BLOCK_PRIORITY_WEAR_SUIT var/fire_resist = T0C+100 allowed = list(/obj/item/tank/internals/emergency_oxygen, /obj/item/tank/internals/plasmaman) armor = list("melee" = 0, "bullet" = 0, "laser" = 0,"energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 0, "acid" = 0) diff --git a/code/modules/clothing/under/_under.dm b/code/modules/clothing/under/_under.dm index 63e3a63968..5208903a39 100644 --- a/code/modules/clothing/under/_under.dm +++ b/code/modules/clothing/under/_under.dm @@ -3,6 +3,7 @@ name = "under" body_parts_covered = CHEST|GROIN|LEGS|ARMS permeability_coefficient = 0.9 + block_priority = BLOCK_PRIORITY_UNIFORM slot_flags = ITEM_SLOT_ICLOTHING armor = list("melee" = 0, "bullet" = 0, "laser" = 0,"energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 0, "acid" = 0) var/fitted = FEMALE_UNIFORM_FULL // For use in alternate clothing styles for women diff --git a/code/modules/mob/living/carbon/human/human_block.dm b/code/modules/mob/living/carbon/human/human_block.dm index c99942bf57..b1a5153ce5 100644 --- a/code/modules/mob/living/carbon/human/human_block.dm +++ b/code/modules/mob/living/carbon/human/human_block.dm @@ -1,7 +1,7 @@ /mob/living/carbon/human/get_blocking_items() . = ..() if(wear_suit) - . += wear_suit) + . += wear_suit if(w_uniform) . += w_uniform if(wear_neck) diff --git a/code/modules/mob/living/living_block.dm b/code/modules/mob/living/living_block.dm index c5add29b86..13e236a931 100644 --- a/code/modules/mob/living/living_block.dm +++ b/code/modules/mob/living/living_block.dm @@ -50,6 +50,7 @@ if((. & BLOCK_SUCCESS) && !(. & BLOCK_CONTINUE_CHAIN)) return var/list/obj/item/tocheck = get_blocking_items() + sortTim(tocheck, /proc/cmp_item_block_priority_asc) // i don't like this var/block_chance_modifier = round(damage / -3) for(var/obj/item/I in tocheck) @@ -72,6 +73,8 @@ /obj/item /// The 0% to 100% chance for the default implementation of random block rolls. var/block_chance = 0 + /// Block priority, higher means we check this higher in the "chain". + var/block_priority = BLOCK_PRIORITY_DEFAULT /obj/item/proc/run_block(mob/living/owner, real_attack, atom/object, damage, attack_text, attack_type, armour_penetration, mob/attacker, def_zone, final_block_chance, list/block_return) SEND_SIGNAL(src, COMSIG_ITEM_RUN_BLOCK, args)