diff --git a/code/__defines/clothing.dm b/code/__defines/clothing.dm index bce34e20888..0eda9396561 100644 --- a/code/__defines/clothing.dm +++ b/code/__defines/clothing.dm @@ -169,3 +169,8 @@ NOTICE: Do not leave trailing commas!!!! /obj/item/storage/backpack, \ /obj/item/bluespaceradio, \ /obj/item/defib_kit + +/// Wrapper for adding clothing based traits +#define ADD_CLOTHING_TRAIT(mob, trait) ADD_TRAIT(mob, trait, "[CLOTHING_TRAIT]_[REF(src)]") +/// Wrapper for removing clothing based traits +#define REMOVE_CLOTHING_TRAIT(mob, trait) REMOVE_TRAIT(mob, trait, "[CLOTHING_TRAIT]_[REF(src)]") diff --git a/code/__defines/traits/declarations.dm b/code/__defines/traits/declarations.dm index 16b13288c33..4e55946f422 100644 --- a/code/__defines/traits/declarations.dm +++ b/code/__defines/traits/declarations.dm @@ -41,3 +41,5 @@ Remember to update _globalvars/traits.dm if you're adding/removing/renaming trai #define INGESTED_TOXIN_IMMUNE "ingested_toxin_immune" /// If using melee, attacks will use the 'get_sparring_variant' if possible #define TRAIT_NONLETHAL_BLOWS "trait_nonlethal_blows" +/// Are we immune to specifically tesla? +#define TRAIT_TESLA_SHOCKIMMUNE "tesla_shock_immunity" diff --git a/code/_global_vars/traits/_traits.dm b/code/_global_vars/traits/_traits.dm index bf3102719d0..8e4be2f439c 100644 --- a/code/_global_vars/traits/_traits.dm +++ b/code/_global_vars/traits/_traits.dm @@ -26,6 +26,7 @@ GLOBAL_LIST_INIT(traits_by_type, list( "TRAIT_NOFIRE" = TRAIT_NOFIRE, "TRAIT_NOFIRE_SPREAD" = TRAIT_NOFIRE_SPREAD, "TRAIT_NO_EXTINGUISH" = TRAIT_NO_EXTINGUISH, + "TRAIT_TESLA_SHOCKIMMUNE" = TRAIT_TESLA_SHOCKIMMUNE, ), /obj = list( "TRAIT_CLIMBABLE" = TRAIT_CLIMBABLE, diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index d22c419ae63..2b6d28d2d79 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -10,6 +10,9 @@ var/list/restricted_accessory_slots var/list/starting_accessories + /// Trait modification, lazylist of traits to add/take away, on equipment/drop in the correct slot + var/list/clothing_traits + var/flash_protection = FLASH_PROTECTION_NONE var/tint = TINT_NONE var/list/enables_planes //Enables these planes in the wearing mob's plane_holder @@ -54,11 +57,16 @@ ..() if(enables_planes) user.recalculate_vis() + if(("[slot]" in slot_flags_enumeration) && (slot_flags & slot_flags_enumeration["[slot]"])) + for(var/trait in clothing_traits) + ADD_CLOTHING_TRAIT(user, trait) /obj/item/clothing/dropped(mob/user) ..() if(enables_planes) user.recalculate_vis() + for(var/trait in clothing_traits) + REMOVE_CLOTHING_TRAIT(user, trait) //BS12: Species-restricted clothing check. /obj/item/clothing/mob_can_equip(M as mob, slot, disable_warning = FALSE) @@ -1415,3 +1423,23 @@ /obj/item/clothing/under/equipped(var/mob/user, var/slot) . = ..() handle_digitigrade(user) + +/obj/item/clothing/proc/attach_clothing_traits(trait_or_traits) + if(!islist(trait_or_traits)) + trait_or_traits = list(trait_or_traits) + + LAZYOR(clothing_traits, trait_or_traits) + var/mob/wearer = loc + if(istype(wearer) && (wearer.get_inventory_slot(src) & slot_flags)) + for(var/new_trait in trait_or_traits) + ADD_CLOTHING_TRAIT(wearer, new_trait) + +/obj/item/clothing/proc/detach_clothing_traits(trait_or_traits) + if(!islist(trait_or_traits)) + trait_or_traits = list(trait_or_traits) + + LAZYREMOVE(clothing_traits, trait_or_traits) + var/mob/wearer = loc + if(istype(wearer)) + for(var/new_trait in trait_or_traits) + REMOVE_CLOTHING_TRAIT(wearer, new_trait) diff --git a/code/modules/clothing/gloves/boxing.dm b/code/modules/clothing/gloves/boxing.dm index 8e7d3419504..b62592bb80b 100644 --- a/code/modules/clothing/gloves/boxing.dm +++ b/code/modules/clothing/gloves/boxing.dm @@ -3,27 +3,7 @@ desc = "Because you really needed another excuse to punch your crewmates." icon_state = "boxing" item_state_slots = list(slot_r_hand_str = "red", slot_l_hand_str = "red") - -/obj/item/clothing/gloves/boxing/equipped(mob/user, slot) - . = ..() - if(user) - if(slot && slot == slot_gloves) - ADD_TRAIT(user, TRAIT_NONLETHAL_BLOWS, CLOTHING_TRAIT) - return - if(HAS_TRAIT_FROM(user, TRAIT_NONLETHAL_BLOWS, CLOTHING_TRAIT)) - REMOVE_TRAIT(user, TRAIT_NONLETHAL_BLOWS, CLOTHING_TRAIT) - -/obj/item/clothing/gloves/boxing/dropped(mob/user) - . = ..() - if(HAS_TRAIT_FROM(user, TRAIT_NONLETHAL_BLOWS, CLOTHING_TRAIT)) - REMOVE_TRAIT(user, TRAIT_NONLETHAL_BLOWS, CLOTHING_TRAIT) -/* -/obj/item/clothing/gloves/boxing/attackby(obj/item/W, mob/user) - if(W.has_tool_quality(TOOL_WIRECUTTER) || istype(W, /obj/item/surgical/scalpel)) - to_chat(user, span_notice("That won't work.")) //Nope - return - ..() -*/ + clothing_traits = list(TRAIT_NONLETHAL_BLOWS) /obj/item/clothing/gloves/boxing/green icon_state = "boxinggreen" diff --git a/code/modules/power/tesla/energy_ball.dm b/code/modules/power/tesla/energy_ball.dm index e2f97f93e51..e2130406f16 100644 --- a/code/modules/power/tesla/energy_ball.dm +++ b/code/modules/power/tesla/energy_ball.dm @@ -226,7 +226,7 @@ var/mob/living/L = A if(SEND_SIGNAL(L, COMSIG_CHECK_FOR_GODMODE) & COMSIG_GODMODE_CANCEL) continue - if(dist <= zap_range && (dist < closest_dist || !closest_mob) && L.stat != DEAD) + if(dist <= zap_range && (dist < closest_dist || !closest_mob) && L.stat != DEAD && !HAS_TRAIT(L, TRAIT_TESLA_SHOCKIMMUNE)) closest_mob = L closest_atom = A closest_dist = dist