From cded32327414d62faf6968b7722bd2e673d41bbd Mon Sep 17 00:00:00 2001 From: MMMiracles Date: Fri, 26 Jul 2019 15:23:56 -0400 Subject: [PATCH] Adds Hat Throwing (#45355) * adds hat throwing on people and borgs * clothing flags, hats can knock off non-items, borg hat blacklist check * prevents hats with items in them from being able to land on heads * removes extra equip, hats can go on the hatless again, tinfoil fix * if * bit flag --- code/__DEFINES/obj_flags.dm | 2 + code/_globalvars/bitfields.dm | 2 + code/controllers/subsystem/throwing.dm | 1 + code/game/atoms_movable.dm | 2 + code/modules/clothing/head/_head.dm | 46 +++++++++++++++++++ code/modules/clothing/head/collectable.dm | 10 ++-- code/modules/clothing/head/hardhat.dm | 1 + code/modules/clothing/head/helmet.dm | 2 +- code/modules/clothing/head/misc.dm | 8 ++++ code/modules/clothing/head/misc_special.dm | 6 +++ .../clothing/spacesuits/_spacesuits.dm | 2 +- code/modules/clothing/spacesuits/hardsuit.dm | 5 +- code/modules/clothing/suits/bio.dm | 2 +- code/modules/clothing/suits/cloaks.dm | 2 + code/modules/clothing/suits/utility.dm | 4 +- code/modules/clothing/suits/wiz_robe.dm | 1 + .../hydroponics/beekeeping/beekeeper_suit.dm | 2 +- 17 files changed, 87 insertions(+), 11 deletions(-) diff --git a/code/__DEFINES/obj_flags.dm b/code/__DEFINES/obj_flags.dm index c966e38980b..97eae9f71d2 100644 --- a/code/__DEFINES/obj_flags.dm +++ b/code/__DEFINES/obj_flags.dm @@ -40,3 +40,5 @@ #define VOICEBOX_DISABLED (1<<7) // The voicebox is currently turned off. #define SCAN_REAGENTS (1<<9) // Allows helmets, masks and glasses to scan reagents. #define BLOCKS_SHOVE_KNOCKDOWN (1<<10) // Prevents shovies against a dense object from knocking the wearer down. +#define SNUG_FIT (1<<11) //Prevents knock-off from things like hat-throwing. +#define ANTI_TINFOIL_MANEUVER (1<<12) //Hats with negative effects when worn (i.e the tinfoil hat). diff --git a/code/_globalvars/bitfields.dm b/code/_globalvars/bitfields.dm index 26d2360e6eb..10a05f156c2 100644 --- a/code/_globalvars/bitfields.dm +++ b/code/_globalvars/bitfields.dm @@ -145,6 +145,8 @@ GLOBAL_LIST_INIT(bitfields, list( "VOICEBOX_DISABLED" = VOICEBOX_DISABLED, "SCAN_REAGENTS" = SCAN_REAGENTS, "BLOCKS_SHOVE_KNOCKDOWN" = BLOCKS_SHOVE_KNOCKDOWN, + "SNUG_FIT" = SNUG_FIT, + "ANTI_TINFOIL_MANEUVER" = ANTI_TINFOIL_MANEUVER, ), "tesla_flags" = list( "TESLA_MOB_DAMAGE" = TESLA_MOB_DAMAGE, diff --git a/code/controllers/subsystem/throwing.dm b/code/controllers/subsystem/throwing.dm index bf79cbda345..96f359b0690 100644 --- a/code/controllers/subsystem/throwing.dm +++ b/code/controllers/subsystem/throwing.dm @@ -43,6 +43,7 @@ SUBSYSTEM_DEF(throwing) var/atom/movable/thrownthing var/atom/target var/turf/target_turf + var/target_zone var/init_dir var/maxrange var/speed diff --git a/code/game/atoms_movable.dm b/code/game/atoms_movable.dm index bef6eb6c742..190f9e7ae21 100644 --- a/code/game/atoms_movable.dm +++ b/code/game/atoms_movable.dm @@ -579,6 +579,8 @@ TT.diagonals_first = diagonals_first TT.force = force TT.callback = callback + if(!QDELETED(thrower)) + TT.target_zone = thrower.zone_selected var/dist_x = abs(target.x - src.x) var/dist_y = abs(target.y - src.y) diff --git a/code/modules/clothing/head/_head.dm b/code/modules/clothing/head/_head.dm index efea5e35d64..4776d1faef1 100644 --- a/code/modules/clothing/head/_head.dm +++ b/code/modules/clothing/head/_head.dm @@ -15,6 +15,52 @@ var/mob/living/carbon/human/H = loc H.update_hair() +///Special throw_impact for hats to frisbee hats at people to place them on their heads/attempt to de-hat them. +/obj/item/clothing/head/throw_impact(atom/hit_atom, datum/thrownthing/thrownthing) + . = ..() + ///if the thrown object's target zone isn't the head + if(thrownthing.target_zone != BODY_ZONE_HEAD) + return + ///ignore any hats with the tinfoil counter-measure enabled + if(clothing_flags & ANTI_TINFOIL_MANEUVER) + return + ///if the hat happens to be capable of holding contents and has something in it. mostly to prevent super cheesy stuff like stuffing a mini-bomb in a hat and throwing it + if(LAZYLEN(contents)) + return + if(iscarbon(hit_atom)) + var/mob/living/carbon/H = hit_atom + if(istype(H.head, /obj/item)) + var/obj/item/WH = H.head + ///check if the item has NODROP + if(HAS_TRAIT(WH, TRAIT_NODROP)) + H.visible_message("[src] bounces off [H]'s [WH.name]!", "[src] bounces off your [WH.name], falling to the floor.") + return + ///check if the item is an actual clothing head item, since some non-clothing items can be worn + if(istype(WH, /obj/item/clothing/head)) + var/obj/item/clothing/head/WHH = WH + ///SNUG_FIT hats are immune to being knocked off + if(WHH.clothing_flags & SNUG_FIT) + H.visible_message("[src] bounces off [H]'s [WHH.name]!", "[src] bounces off your [WHH.name], falling to the floor.") + return + ///if the hat manages to knock something off + if(H.dropItemToGround(WH)) + H.visible_message("[src] knocks [WH] off [H]'s head!", "[WH] is suddenly knocked off your head by [src]!") + if(H.equip_to_slot_if_possible(src, SLOT_HEAD, 0, 1, 1)) + H.visible_message("[src] lands neatly on [H]'s head!", "[src] lands perfectly onto your head!") + return + if(iscyborg(hit_atom)) + var/mob/living/silicon/robot/R = hit_atom + ///hats in the borg's blacklist bounce off + if(is_type_in_typecache(src, R.blacklisted_hats)) + R.visible_message("[src] bounces off [R]!", "[src] bounces off you, falling to the floor.") + return + else + R.visible_message("[src] lands neatly on top of [R]", "[src] lands perfectly on top of you.") + R.place_on_head(src) //hats aren't designed to snugly fit borg heads or w/e so they'll always manage to knock eachother off + + + + /obj/item/clothing/head/worn_overlays(isinhands = FALSE) . = list() if(!isinhands) diff --git a/code/modules/clothing/head/collectable.dm b/code/modules/clothing/head/collectable.dm index 90c0690534e..5457d32e8ab 100644 --- a/code/modules/clothing/head/collectable.dm +++ b/code/modules/clothing/head/collectable.dm @@ -13,12 +13,14 @@ /obj/item/clothing/head/collectable/slime name = "collectable slime cap!" desc = "It just latches right in place!" + clothing_flags = SNUG_FIT icon_state = "slime" dynamic_hair_suffix = "" /obj/item/clothing/head/collectable/xenom name = "collectable xenomorph helmet!" desc = "Hiss hiss hiss!" + clothing_flags = SNUG_FIT icon_state = "xenom" /obj/item/clothing/head/collectable/chef @@ -71,13 +73,14 @@ desc = "A collectable welding helmet. Now with 80% less lead! Not for actual welding. Any welding done while wearing this helmet is done so at the owner's own risk!" icon_state = "welding" item_state = "welding" - resistance_flags = NONE + clothing_flags = SNUG_FIT /obj/item/clothing/head/collectable/slime name = "collectable slime hat" desc = "Just like a real brain slug!" icon_state = "headslime" item_state = "headslime" + clothing_flags = SNUG_FIT /obj/item/clothing/head/collectable/flatcap name = "collectable flat cap" @@ -121,6 +124,7 @@ /obj/item/clothing/head/collectable/hardhat name = "collectable hard hat" desc = "WARNING! Offers no real protection, or luminosity, but damn, is it fancy!" + clothing_flags = SNUG_FIT icon_state = "hardhat0_yellow" item_state = "hardhat0_yellow" @@ -143,7 +147,7 @@ desc = "Go Red! I mean Green! I mean Red! No Green!" icon_state = "thunderdome" item_state = "thunderdome" - resistance_flags = NONE + clothing_flags = SNUG_FIT flags_inv = HIDEHAIR /obj/item/clothing/head/collectable/swat @@ -151,5 +155,5 @@ desc = "That's not real blood. That's red paint." //Reference to the actual description icon_state = "swat" item_state = "swat" - resistance_flags = NONE + clothing_flags = SNUG_FIT flags_inv = HIDEHAIR diff --git a/code/modules/clothing/head/hardhat.dm b/code/modules/clothing/head/hardhat.dm index ff49f131ed1..eb6766a4427 100644 --- a/code/modules/clothing/head/hardhat.dm +++ b/code/modules/clothing/head/hardhat.dm @@ -9,6 +9,7 @@ armor = list("melee" = 15, "bullet" = 5, "laser" = 20, "energy" = 10, "bomb" = 20, "bio" = 10, "rad" = 20, "fire" = 100, "acid" = 50) flags_inv = 0 actions_types = list(/datum/action/item_action/toggle_helmet_light) + clothing_flags = SNUG_FIT resistance_flags = FIRE_PROOF dynamic_hair_suffix = "+generic" diff --git a/code/modules/clothing/head/helmet.dm b/code/modules/clothing/head/helmet.dm index 94d1001bf93..cc6d2099d4e 100644 --- a/code/modules/clothing/head/helmet.dm +++ b/code/modules/clothing/head/helmet.dm @@ -10,7 +10,7 @@ heat_protection = HEAD max_heat_protection_temperature = HELMET_MAX_TEMP_PROTECT strip_delay = 60 - resistance_flags = NONE + clothing_flags = SNUG_FIT flags_cover = HEADCOVERSEYES flags_inv = HIDEHAIR diff --git a/code/modules/clothing/head/misc.dm b/code/modules/clothing/head/misc.dm index c7d4a7bba4b..dace2e3e9fe 100644 --- a/code/modules/clothing/head/misc.dm +++ b/code/modules/clothing/head/misc.dm @@ -65,6 +65,7 @@ icon_state = "syndicate-helm-black-red" item_state = "syndicate-helm-black-red" desc = "A plastic replica of a Syndicate agent's space helmet. You'll look just like a real murderous Syndicate agent in this! This is a toy, it is not made for use in space!" + clothing_flags = SNUG_FIT flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDEFACIALHAIR /obj/item/clothing/head/cueball @@ -72,6 +73,7 @@ desc = "A large, featureless white orb meant to be worn on your head. How do you even see out of this thing?" icon_state = "cueball" item_state="cueball" + clothing_flags = SNUG_FIT flags_cover = HEADCOVERSEYES|HEADCOVERSMOUTH flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDEFACIALHAIR @@ -80,6 +82,7 @@ desc = "A ball of white styrofoam. So festive." icon_state = "snowman_h" item_state = "snowman_h" + clothing_flags = SNUG_FIT flags_cover = HEADCOVERSEYES flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDEFACIALHAIR @@ -88,6 +91,7 @@ desc = "Fight for what's righteous!" icon_state = "justicered" item_state = "justicered" + clothing_flags = SNUG_FIT flags_inv = HIDEHAIR|HIDEEARS|HIDEEYES|HIDEFACE|HIDEFACIALHAIR flags_cover = HEADCOVERSEYES @@ -178,6 +182,7 @@ desc = "Bkaw!" icon_state = "chickenhead" item_state = "chickensuit" + clothing_flags = SNUG_FIT flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDEFACIALHAIR /obj/item/clothing/head/griffin @@ -185,6 +190,7 @@ desc = "Why not 'eagle head'? Who knows." icon_state = "griffinhat" item_state = "griffinhat" + clothing_flags = SNUG_FIT flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDEFACIALHAIR /obj/item/clothing/head/bearpelt @@ -198,6 +204,7 @@ icon_state = "xenos" item_state = "xenos_helm" desc = "A helmet made out of chitinous alien hide." + clothing_flags = SNUG_FIT flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDEFACIALHAIR /obj/item/clothing/head/fedora @@ -333,6 +340,7 @@ name = "foam lobster head" desc = "When everything's going to crab, protecting your head is the best choice." icon_state = "lobster_hat" + clothing_flags = SNUG_FIT flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDEFACIALHAIR /obj/item/clothing/head/drfreezehat diff --git a/code/modules/clothing/head/misc_special.dm b/code/modules/clothing/head/misc_special.dm index 2925fc9b774..d1d99826545 100644 --- a/code/modules/clothing/head/misc_special.dm +++ b/code/modules/clothing/head/misc_special.dm @@ -28,6 +28,7 @@ visor_flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE visor_flags_cover = HEADCOVERSEYES | HEADCOVERSMOUTH resistance_flags = FIRE_PROOF + clothing_flags = SNUG_FIT /obj/item/clothing/head/welding/attack_self(mob/user) weldingvisortoggle(user) @@ -113,6 +114,7 @@ icon_state = "hardhat0_pumpkin" item_state = "hardhat0_pumpkin" item_color = "pumpkin" + clothing_flags = SNUG_FIT flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDEFACIALHAIR armor = list("melee" = 0, "bullet" = 0, "laser" = 0,"energy" = 0, "bomb" = 0, "bio" = 0, "rad" = 0, "fire" = 0, "acid" = 0) brightness_on = 2 //luminosity when on @@ -162,6 +164,7 @@ desc = "A helmet made out of a box." icon_state = "cardborg_h" item_state = "cardborg_h" + clothing_flags = SNUG_FIT flags_cover = HEADCOVERSEYES flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEFACE|HIDEHAIR|HIDEFACIALHAIR @@ -255,6 +258,7 @@ desc = "A crude helmet made out of bronze plates. It offers very little in the way of protection." icon = 'icons/obj/clothing/clockwork_garb.dmi' icon_state = "clockwork_helmet_old" + clothing_flags = SNUG_FIT flags_inv = HIDEEARS|HIDEHAIR armor = list("melee" = 5, "bullet" = 0, "laser" = -5, "energy" = 0, "bomb" = 10, "bio" = 0, "rad" = 0, "fire" = 20, "acid" = 20) @@ -265,6 +269,7 @@ item_state = "foilhat" armor = list("melee" = 0, "bullet" = 0, "laser" = -5,"energy" = 0, "bomb" = 0, "bio" = 0, "rad" = -5, "fire" = 0, "acid" = 0) equip_delay_other = 140 + clothing_flags = ANTI_TINFOIL_MANEUVER var/datum/brain_trauma/mild/phobia/conspiracies/paranoia var/warped = FALSE @@ -306,6 +311,7 @@ name = "scorched tinfoil hat" desc = "A badly warped up hat. Quite unprobable this will still work against any of fictional and contemporary dangers it used to." warped = TRUE + clothing_flags &= ~ANTI_TINFOIL_MANEUVER if(!isliving(loc) || !paranoia) return var/mob/living/target = loc diff --git a/code/modules/clothing/spacesuits/_spacesuits.dm b/code/modules/clothing/spacesuits/_spacesuits.dm index 6224e2a3d91..900691f721a 100644 --- a/code/modules/clothing/spacesuits/_spacesuits.dm +++ b/code/modules/clothing/spacesuits/_spacesuits.dm @@ -4,7 +4,7 @@ name = "space helmet" icon_state = "spaceold" desc = "A special helmet with solar UV shielding to protect your eyes from harmful rays." - clothing_flags = STOPSPRESSUREDAMAGE | THICKMATERIAL + clothing_flags = STOPSPRESSUREDAMAGE | THICKMATERIAL | SNUG_FIT item_state = "spaceold" permeability_coefficient = 0.01 armor = list("melee" = 0, "bullet" = 0, "laser" = 0,"energy" = 0, "bomb" = 0, "bio" = 100, "rad" = 50, "fire" = 80, "acid" = 70) diff --git a/code/modules/clothing/spacesuits/hardsuit.dm b/code/modules/clothing/spacesuits/hardsuit.dm index cd50552f391..a663d9e6a5d 100644 --- a/code/modules/clothing/spacesuits/hardsuit.dm +++ b/code/modules/clothing/spacesuits/hardsuit.dm @@ -5,6 +5,7 @@ icon_state = "hardsuit0-engineering" item_state = "eng_helm" max_integrity = 300 + clothing_flags = SNUG_FIT armor = list("melee" = 10, "bullet" = 5, "laser" = 10, "energy" = 5, "bomb" = 10, "bio" = 100, "rad" = 75, "fire" = 50, "acid" = 75) var/basestate = "hardsuit" var/brightness_on = 4 //luminosity when on @@ -435,7 +436,7 @@ item_color = "medical" flash_protect = 0 armor = list("melee" = 30, "bullet" = 5, "laser" = 10, "energy" = 5, "bomb" = 10, "bio" = 100, "rad" = 60, "fire" = 60, "acid" = 75) - clothing_flags = STOPSPRESSUREDAMAGE | THICKMATERIAL | SCAN_REAGENTS + clothing_flags = STOPSPRESSUREDAMAGE | THICKMATERIAL | SCAN_REAGENTS | SNUG_FIT /obj/item/clothing/suit/space/hardsuit/medical icon_state = "hardsuit-medical" @@ -457,7 +458,7 @@ max_heat_protection_temperature = FIRE_SUIT_MAX_TEMP_PROTECT armor = list("melee" = 30, "bullet" = 5, "laser" = 10, "energy" = 5, "bomb" = 100, "bio" = 100, "rad" = 60, "fire" = 60, "acid" = 80) var/obj/machinery/doppler_array/integrated/bomb_radar - clothing_flags = STOPSPRESSUREDAMAGE | THICKMATERIAL | SCAN_REAGENTS + clothing_flags = STOPSPRESSUREDAMAGE | THICKMATERIAL | SCAN_REAGENTS | SNUG_FIT actions_types = list(/datum/action/item_action/toggle_helmet_light, /datum/action/item_action/toggle_research_scanner) /obj/item/clothing/head/helmet/space/hardsuit/rd/Initialize() diff --git a/code/modules/clothing/suits/bio.dm b/code/modules/clothing/suits/bio.dm index 350f9b14d5a..85c100bf651 100644 --- a/code/modules/clothing/suits/bio.dm +++ b/code/modules/clothing/suits/bio.dm @@ -4,7 +4,7 @@ icon_state = "bio" desc = "A hood that protects the head and face from biological contaminants." permeability_coefficient = 0.01 - clothing_flags = THICKMATERIAL | BLOCK_GAS_SMOKE_EFFECT + clothing_flags = THICKMATERIAL | BLOCK_GAS_SMOKE_EFFECT | SNUG_FIT armor = list("melee" = 0, "bullet" = 0, "laser" = 0,"energy" = 0, "bomb" = 0, "bio" = 100, "rad" = 80, "fire" = 30, "acid" = 100) flags_inv = HIDEMASK|HIDEEARS|HIDEEYES|HIDEHAIR|HIDEFACIALHAIR|HIDEFACE resistance_flags = ACID_PROOF diff --git a/code/modules/clothing/suits/cloaks.dm b/code/modules/clothing/suits/cloaks.dm index cb40b6bf05d..bd89649ba7a 100644 --- a/code/modules/clothing/suits/cloaks.dm +++ b/code/modules/clothing/suits/cloaks.dm @@ -63,6 +63,7 @@ icon_state = "golhood" desc = "A protective & concealing hood." armor = list("melee" = 35, "bullet" = 10, "laser" = 25, "energy" = 10, "bomb" = 25, "bio" = 0, "rad" = 0, "fire" = 60, "acid" = 60) + clothing_flags = SNUG_FIT flags_inv = HIDEEARS|HIDEEYES|HIDEHAIR|HIDEFACIALHAIR transparent_protection = HIDEMASK @@ -84,6 +85,7 @@ icon_state = "dragon" desc = "The skull of a dragon." armor = list("melee" = 70, "bullet" = 30, "laser" = 50, "energy" = 40, "bomb" = 70, "bio" = 60, "rad" = 50, "fire" = 100, "acid" = 100) + clothing_flags = SNUG_FIT heat_protection = HEAD max_heat_protection_temperature = FIRE_IMMUNITY_MAX_TEMP_PROTECT resistance_flags = FIRE_PROOF | ACID_PROOF diff --git a/code/modules/clothing/suits/utility.dm b/code/modules/clothing/suits/utility.dm index b53ec05dda1..7544771e63b 100644 --- a/code/modules/clothing/suits/utility.dm +++ b/code/modules/clothing/suits/utility.dm @@ -57,7 +57,7 @@ name = "bomb hood" desc = "Use in case of bomb." icon_state = "bombsuit" - clothing_flags = THICKMATERIAL + clothing_flags = THICKMATERIAL | SNUG_FIT armor = list("melee" = 20, "bullet" = 0, "laser" = 20,"energy" = 10, "bomb" = 100, "bio" = 0, "rad" = 0, "fire" = 80, "acid" = 50) flags_inv = HIDEFACE|HIDEMASK|HIDEEARS|HIDEEYES|HIDEHAIR|HIDEFACIALHAIR dynamic_hair_suffix = "" @@ -120,7 +120,7 @@ name = "radiation hood" icon_state = "rad" desc = "A hood with radiation protective properties. The label reads, 'Made with lead. Please do not consume insulation.'" - clothing_flags = THICKMATERIAL + clothing_flags = THICKMATERIAL | SNUG_FIT flags_inv = HIDEMASK|HIDEEARS|HIDEFACE|HIDEEYES|HIDEHAIR|HIDEFACIALHAIR armor = list("melee" = 0, "bullet" = 0, "laser" = 0,"energy" = 0, "bomb" = 0, "bio" = 60, "rad" = 100, "fire" = 30, "acid" = 30) strip_delay = 60 diff --git a/code/modules/clothing/suits/wiz_robe.dm b/code/modules/clothing/suits/wiz_robe.dm index 9d1a47f2311..93eb8181c79 100644 --- a/code/modules/clothing/suits/wiz_robe.dm +++ b/code/modules/clothing/suits/wiz_robe.dm @@ -7,6 +7,7 @@ armor = list("melee" = 30, "bullet" = 20, "laser" = 20, "energy" = 20, "bomb" = 20, "bio" = 20, "rad" = 20, "fire" = 100, "acid" = 100) strip_delay = 50 equip_delay_other = 50 + clothing_flags = SNUG_FIT resistance_flags = FIRE_PROOF | ACID_PROOF dog_fashion = /datum/dog_fashion/head/blue_wizard diff --git a/code/modules/hydroponics/beekeeping/beekeeper_suit.dm b/code/modules/hydroponics/beekeeping/beekeeper_suit.dm index 75d868cdcd6..977245e9eb8 100644 --- a/code/modules/hydroponics/beekeeping/beekeeper_suit.dm +++ b/code/modules/hydroponics/beekeeping/beekeeper_suit.dm @@ -4,7 +4,7 @@ desc = "Keeps the lil buzzing buggers out of your eyes." icon_state = "beekeeper" item_state = "beekeeper" - clothing_flags = THICKMATERIAL + clothing_flags = THICKMATERIAL | SNUG_FIT /obj/item/clothing/suit/beekeeper_suit