mirror of
https://github.com/ParadiseSS13/Paradise.git
synced 2026-08-24 12:37:26 +01:00
Lets you attach signalers to desk bells (#25375)
* Improves some desk bell interactions * more interactions * Update code/modules/paperwork/desk_bell.dm Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> Signed-off-by: Luc <89928798+lewcc@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: 1080pCat <96908085+1080pCat@users.noreply.github.com> Signed-off-by: Luc <89928798+lewcc@users.noreply.github.com> * burza review (finally) --------- Signed-off-by: Luc <89928798+lewcc@users.noreply.github.com> Co-authored-by: Burzah <116982774+Burzah@users.noreply.github.com> Co-authored-by: 1080pCat <96908085+1080pCat@users.noreply.github.com>
This commit is contained in:
@@ -15,18 +15,64 @@
|
||||
var/ring_cooldown_length = 0.5 SECONDS // This is here to protect against tinnitus.
|
||||
/// The sound the bell makes
|
||||
var/ring_sound = 'sound/machines/bell.ogg'
|
||||
/// The remote signaller that we're gonna activate to this bell
|
||||
var/obj/item/assembly/signaler/attached_signaler
|
||||
|
||||
/obj/item/desk_bell/examine(mob/user)
|
||||
. = ..()
|
||||
if(!isnull(attached_signaler))
|
||||
. += "<span class='notice'>There seems to be an antenna sticking out of the base.</span>"
|
||||
|
||||
/obj/item/desk_bell/Destroy()
|
||||
if(!isnull(attached_signaler))
|
||||
var/turf/cur_turf = get_turf(src)
|
||||
if(cur_turf)
|
||||
forceMove(attached_signaler, get_turf(src))
|
||||
else
|
||||
qdel(attached_signaler)
|
||||
UnregisterSignal(attached_signaler, COMSIG_ASSEMBLY_PULSED)
|
||||
attached_signaler = null
|
||||
return ..()
|
||||
|
||||
/obj/item/desk_bell/attackby(obj/item/I, mob/user, params)
|
||||
// can only attach its on your person
|
||||
if(istype(I, /obj/item/assembly/signaler))
|
||||
if(!in_inventory)
|
||||
to_chat(user, "<span class='warning'>[src] needs to be in your inventory if you want to attach [I] to it!</span>")
|
||||
return
|
||||
if(!isnull(attached_signaler))
|
||||
to_chat(user, "<span class='notice'>There's already a signaller attached!</span>")
|
||||
return
|
||||
var/obj/item/assembly/signaler/signal = I
|
||||
user.unEquip(signal)
|
||||
signal.forceMove(src)
|
||||
attached_signaler = signal
|
||||
if(signal.receiving)
|
||||
RegisterSignal(attached_signaler, COMSIG_ASSEMBLY_PULSED, PROC_REF(on_signal))
|
||||
user.visible_message(
|
||||
"<span class='notice'>[user] attaches [signal] to [src].</span>",
|
||||
"<span class='notice'>You attach [signal] to [src].</span>"
|
||||
)
|
||||
return ..()
|
||||
|
||||
/obj/item/desk_bell/proc/on_signal()
|
||||
SIGNAL_HANDLER // COMSIG_ASSEMBLY_PULSED
|
||||
INVOKE_ASYNC(src, PROC_REF(try_ring))
|
||||
|
||||
/obj/item/desk_bell/proc/try_ring(mob/user)
|
||||
if(ring_cooldown > world.time || !anchored)
|
||||
return TRUE
|
||||
if(!ring_bell(user) && user)
|
||||
to_chat(user, "<span class='notice'>[src] is silent. Some idiot broke it.</span>")
|
||||
ring_cooldown = world.time + ring_cooldown_length
|
||||
return TRUE
|
||||
|
||||
/obj/item/desk_bell/attack_hand(mob/living/user)
|
||||
if(in_inventory && ishuman(user))
|
||||
if(!user.get_active_hand())
|
||||
user.put_in_hands(src)
|
||||
return TRUE
|
||||
if(ring_cooldown > world.time || !anchored)
|
||||
return TRUE
|
||||
if(!ring_bell(user))
|
||||
to_chat(user, "<span class='notice'>[src] is silent. Some idiot broke it.</span>")
|
||||
ring_cooldown = world.time + ring_cooldown_length
|
||||
return TRUE
|
||||
return try_ring(user)
|
||||
|
||||
/obj/item/desk_bell/MouseDrop(atom/over_object)
|
||||
var/mob/M = usr
|
||||
@@ -79,12 +125,21 @@
|
||||
if(!tool.use_tool(src, user, 3 SECONDS, volume = tool.tool_volume))
|
||||
return
|
||||
anchored = FALSE
|
||||
return
|
||||
|
||||
if(attached_signaler) // in inventory
|
||||
if(!tool.use_tool(src, user, 0.5 SECONDS, volume = tool.tool_volume))
|
||||
return TRUE
|
||||
to_chat(user, "<span class='notice'>You remove [attached_signaler].</span>")
|
||||
user.put_in_hands(attached_signaler)
|
||||
attached_signaler = null
|
||||
|
||||
/// Check if the clapper breaks, and if it does, break it
|
||||
/obj/item/desk_bell/proc/check_clapper(mob/living/user)
|
||||
if(prob(times_rang / 50) && ring_cooldown_length)
|
||||
to_chat(user, "<span class='notice'>You hear [src]'s clapper fall off of its hinge. Nice job, you broke it.</span>")
|
||||
audible_message("<span class='notice'>You hear [src]'s clapper fall off its hinge.</span>")
|
||||
if(user)
|
||||
to_chat(user, "<span class='warning'>Nice job, you broke it.</span>")
|
||||
broken_ringer = TRUE
|
||||
|
||||
/// Ring the bell
|
||||
@@ -95,6 +150,8 @@
|
||||
// The lack of varying is intentional. The only variance occurs on the strike the bell breaks.
|
||||
playsound(src, ring_sound, 70, vary = broken_ringer, extrarange = SHORT_RANGE_SOUND_EXTRARANGE)
|
||||
flick("desk_bell_ring", src)
|
||||
if(attached_signaler)
|
||||
attached_signaler.signal()
|
||||
times_rang++
|
||||
return TRUE
|
||||
|
||||
|
||||
Reference in New Issue
Block a user