From 20f015a2ea8bfecf909dc841485f43500751217d Mon Sep 17 00:00:00 2001 From: ninjanomnom Date: Wed, 11 Jul 2018 01:12:45 -0400 Subject: [PATCH] Makes the squeak component slightly more horrifying The clown outfit got its hardcoded squeak on hit replaced with the component. Objects which can squeak which are thrown in disposals will squeak when they hit bends in the piping. --- code/__DEFINES/components.dm | 6 +++-- code/datums/components/squeak.dm | 23 ++++++++++++++++++-- code/game/objects/items.dm | 1 + code/modules/clothing/under/jobs/civilian.dm | 6 ++--- code/modules/recycling/disposal/holder.dm | 1 + 5 files changed, 30 insertions(+), 7 deletions(-) diff --git a/code/__DEFINES/components.dm b/code/__DEFINES/components.dm index 77832d83718..3fdf8ed8fdf 100644 --- a/code/__DEFINES/components.dm +++ b/code/__DEFINES/components.dm @@ -104,7 +104,8 @@ #define COMSIG_MOVABLE_BUCKLE "buckle" //from base of atom/movable/buckle_mob(): (mob, force) #define COMSIG_MOVABLE_UNBUCKLE "unbuckle" //from base of atom/movable/unbuckle_mob(): (mob, force) #define COMSIG_MOVABLE_THROW "movable_throw" //from base of atom/movable/throw_at(): (datum/thrownthing, spin) -#define COMSIG_MOVABLE_Z_CHANGED "movable_ztransit" //from base of atom/movable/onTransitZ(): (old_z, new_z) +#define COMSIG_MOVABLE_Z_CHANGED "movable_ztransit" //from base of atom/movable/onTransitZ(): (old_z, new_z) +#define COMSIG_MOVABLE_DISPOSING "movable_disposing" //called when the movable is added to a disposal holder object for disposal movement: (obj/structure/disposalholder/holder, obj/machinery/disposal/source) // /mob Signals #define COMSIG_MOB_RECEIVE_MAGIC "mob_receive_magic" //from base of mob/anti_magic_check(): (magic, holy, protection_sources) @@ -135,7 +136,8 @@ #define COMSIG_ITEM_DROPPED "item_drop" //from base of obj/item/dropped(): (mob/user) #define COMSIG_ITEM_PICKUP "item_pickup" //from base of obj/item/pickup(): (/mob/taker) #define COMSIG_ITEM_ATTACK_ZONE "item_attack_zone" //from base of mob/living/carbon/attacked_by(): (mob/living/carbon/target, mob/living/user, hit_zone) -#define COMSIG_ITEM_IMBUE_SOUL "item_imbue_soul" //return a truthy value to prevent ensouling, checked in /obj/effect/proc_holder/spell/targeted/lichdom/cast(): (mob/user) +#define COMSIG_ITEM_IMBUE_SOUL "item_imbue_soul" //return a truthy value to prevent ensouling, checked in /obj/effect/proc_holder/spell/targeted/lichdom/cast(): (mob/user) +#define COMSIG_ITEM_HIT_REACT "item_hit_react" //from base of obj/item/hit_reaction(): (list/args) // /obj/item/clothing signals #define COMSIG_SHOES_STEP_ACTION "shoes_step_action" //from base of obj/item/clothing/shoes/proc/step_action(): () diff --git a/code/datums/components/squeak.dm b/code/datums/components/squeak.dm index ab91e7dc5ac..cd93a536bcd 100644 --- a/code/datums/components/squeak.dm +++ b/code/datums/components/squeak.dm @@ -19,9 +19,12 @@ if(ismovableatom(parent)) RegisterSignal(parent, list(COMSIG_MOVABLE_BUMP, COMSIG_MOVABLE_IMPACT), .proc/play_squeak) RegisterSignal(parent, COMSIG_MOVABLE_CROSSED, .proc/play_squeak_turf) + RegisterSignal(parent, COMSIG_MOVABLE_DISPOSING, .proc/disposing_react) if(isitem(parent)) - RegisterSignal(parent, list(COMSIG_ITEM_ATTACK, COMSIG_ITEM_ATTACK_OBJ), .proc/play_squeak) + RegisterSignal(parent, list(COMSIG_ITEM_ATTACK, COMSIG_ITEM_ATTACK_OBJ, COMSIG_ITEM_HIT_REACT), .proc/play_squeak) RegisterSignal(parent, COMSIG_ITEM_ATTACK_SELF, .proc/use_squeak) + RegisterSignal(parent, COMSIG_ITEM_EQUIPPED, .proc/on_equip) + RegisterSignal(parent, COMSIG_ITEM_DROPPED, .proc/on_drop) if(istype(parent, /obj/item/clothing/shoes)) RegisterSignal(parent, COMSIG_SHOES_STEP_ACTION, .proc/step_squeak) @@ -57,4 +60,20 @@ /datum/component/squeak/proc/use_squeak() if(last_use + use_delay < world.time) last_use = world.time - play_squeak() \ No newline at end of file + play_squeak() + +/datum/component/squeak/proc/on_equip(mob/equipper, slot) + RegisterSignal(equipper, COMSIG_MOVABLE_DISPOSING, .proc/disposing_react, TRUE) + +/datum/component/squeak/proc/on_drop(mob/user) + UnregisterSignal(user, COMSIG_MOVABLE_DISPOSING) + +// Disposal pipes related shit +/datum/component/squeak/proc/disposing_react(obj/structure/disposalholder/holder, obj/machinery/disposal/source) + //We don't need to worry about unregistering this signal as it will happen for us automaticaly when the holder is qdeleted + RegisterSignal(holder, COMSIG_ATOM_DIR_CHANGE, .proc/holder_dir_change) + +/datum/component/squeak/proc/holder_dir_change(old_dir, new_dir) + //If the dir changes it means we're going through a bend in the pipes, let's pretend we bumped the wall + if(old_dir != new_dir) + play_squeak() diff --git a/code/game/objects/items.dm b/code/game/objects/items.dm index e0937376cb8..9cf4b3a8b60 100644 --- a/code/game/objects/items.dm +++ b/code/game/objects/items.dm @@ -346,6 +346,7 @@ GLOBAL_VAR_INIT(rpg_loot_items, FALSE) // afterattack() and attack() prototypes moved to _onclick/item_attack.dm for consistency /obj/item/proc/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK) + SEND_SIGNAL(src, COMSIG_ITEM_HIT_REACT, args) if(prob(final_block_chance)) owner.visible_message("[owner] blocks [attack_text] with [src]!") return 1 diff --git a/code/modules/clothing/under/jobs/civilian.dm b/code/modules/clothing/under/jobs/civilian.dm index 1115d822edc..69535b77b04 100644 --- a/code/modules/clothing/under/jobs/civilian.dm +++ b/code/modules/clothing/under/jobs/civilian.dm @@ -67,9 +67,9 @@ fitted = FEMALE_UNIFORM_TOP can_adjust = FALSE -/obj/item/clothing/under/rank/clown/hit_reaction(mob/living/carbon/human/owner, atom/movable/hitby, attack_text = "the attack", final_block_chance = 0, damage = 0, attack_type = MELEE_ATTACK) - playsound(loc, 'sound/items/bikehorn.ogg', 50, 1, -1) - return 0 +/obj/item/clothing/under/rank/clown/Initialize() + . = ..() + AddComponent(/datum/component/squeak, list('sound/items/bikehorn.ogg'=1), 50) /obj/item/clothing/under/rank/head_of_personnel desc = "It's a jumpsuit worn by someone who works in the position of \"Head of Personnel\"." diff --git a/code/modules/recycling/disposal/holder.dm b/code/modules/recycling/disposal/holder.dm index 65a5dce1f54..2c0a6aa646b 100644 --- a/code/modules/recycling/disposal/holder.dm +++ b/code/modules/recycling/disposal/holder.dm @@ -47,6 +47,7 @@ var/atom/movable/AM = A if(AM == src) continue + SEND_SIGNAL(AM, COMSIG_MOVABLE_DISPOSING, src, D) AM.forceMove(src) if(istype(AM, /obj/structure/bigDelivery) && !hasmob) var/obj/structure/bigDelivery/T = AM